@snapshot-labs/snapshot.js 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/snapshot.cjs.js +2 -1
- package/dist/snapshot.esm.js +2 -1
- package/dist/snapshot.min.js +1 -1
- package/package.json +1 -1
- package/src/schemas/vote.json +2 -1
package/dist/snapshot.cjs.js
CHANGED
package/dist/snapshot.esm.js
CHANGED
package/dist/snapshot.min.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
14
|
and limitations under the License.
|
|
15
|
-
***************************************************************************** */var t=function(){return(t=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function e(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function r(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function n(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function i(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(n(arguments[e]));return t}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function a(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})})),e}function u(t){var e={exports:{}};return t(e,e.exports),e.exports}var h=u((function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:o);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function m(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?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(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=d(this);if(t)return t;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(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(m)}),this.text=function(){var t,e,r,n=d(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=p(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,e){t=h(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},f.prototype.delete=function(t){delete this.map[h(t)]},f.prototype.get=function(t){return t=h(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(h(t))},f.prototype.set=function(t,e){this.map[h(t)]=l(e)},f.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},f.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),c(t)},f.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),c(t)},f.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),c(t)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var r,n,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function A(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},g.call(w.prototype),g.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},A.error=function(){var t=new A(null,{status:0,statusText:""});return t.type="error",t};var _=[301,302,303,307,308];A.redirect=function(t,e){if(-1===_.indexOf(e))throw new RangeError("Invalid status code");return new A(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function M(t,r){return new Promise((function(n,o){var s=new w(t,r);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new A(i,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}M.polyfill=!0,t.fetch||(t.fetch=M,t.Headers=f,t.Request=w,t.Response=A),e.Headers=f,e.Request=w,e.Response=A,e.fetch=M}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e})),l={Space:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"settings",type:"string"}]},c={Proposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"type",type:"string"},{name:"title",type:"string"},{name:"body",type:"string"},{name:"discussion",type:"string"},{name:"choices",type:"string[]"},{name:"start",type:"uint64"},{name:"end",type:"uint64"},{name:"snapshot",type:"uint64"},{name:"plugins",type:"string"}]},f={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"}]},d={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"}]},p={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32"}]},m={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32[]"}]},y={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"string"}]},g={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32"}]},v={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32[]"}]},w={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"string"}]},b={Follow:[{name:"from",type:"address"},{name:"space",type:"string"}]},A={Unfollow:[{name:"from",type:"address"},{name:"space",type:"string"}]},_={Subscribe:[{name:"from",type:"address"},{name:"space",type:"string"}]},M={Unsubscribe:[{name:"from",type:"address"},{name:"space",type:"string"}]},E={Profile:[{name:"from",type:"address"},{name:"timestamp",type:"uint64"},{name:"profile",type:"string"}]},k={Alias:[{name:"from",type:"address"},{name:"alias",type:"address"}]},S=["https://hub.snapshot.org","https://testnet.snapshot.org"],x={name:"snapshot",version:"0.1.4"},U=function(){function t(t){void 0===t&&(t=S[0]),this.address=t}return t.prototype.sign=function(t,n,i,o){return e(this,void 0,void 0,(function(){var e,s,a;return r(this,(function(r){switch(r.label){case 0:return e=(null==t?void 0:t.getSigner)?t.getSigner():t,i.from||(i.from=n),i.timestamp||(i.timestamp=parseInt((Date.now()/1e3).toFixed())),s={domain:x,types:o,message:i},[4,e._signTypedData(x,s.types,i)];case 1:return a=r.sent(),console.log("Sign",{address:n,sig:a,data:s}),[4,this.send({address:n,sig:a,data:s})];case 2:return[2,r.sent()]}}))}))},t.prototype.send=function(t){return e(this,void 0,void 0,(function(){var e,n;return r(this,(function(r){return e=this.address+"/api/msg",n={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)},[2,new Promise((function(t,r){h(e,n).then((function(e){if(e.ok)return t(e.json());throw e})).catch((function(t){return t.json().then((function(t){return r(t)}))}))}))]}))}))},t.prototype.space=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,l)];case 1:return[2,e.sent()]}}))}))},t.prototype.proposal=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return i.discussion||(i.discussion=""),[4,this.sign(t,n,i,c)];case 1:return[2,e.sent()]}}))}))},t.prototype.cancelProposal=function(t,n,i){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return e=i.proposal.startsWith("0x"),[4,this.sign(t,n,i,e?d:f)];case 1:return[2,r.sent()]}}))}))},t.prototype.vote=function(t,n,i){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e=i.proposal.startsWith("0x"),o=e?g:p,["approval","ranked-choice"].includes(i.type)&&(o=e?v:m),["quadratic","weighted"].includes(i.type)&&(o=e?w:y,i.choice=JSON.stringify(i.choice)),"shutter"===(null==i?void 0:i.privacy)&&(o=e?w:y),delete i.privacy,delete i.type,[4,this.sign(t,n,i,o)];case 1:return[2,r.sent()]}}))}))},t.prototype.follow=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,b)];case 1:return[2,e.sent()]}}))}))},t.prototype.unfollow=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,A)];case 1:return[2,e.sent()]}}))}))},t.prototype.subscribe=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,_)];case 1:return[2,e.sent()]}}))}))},t.prototype.unsubscribe=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,M)];case 1:return[2,e.sent()]}}))}))},t.prototype.profile=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,E)];case 1:return[2,e.sent()]}}))}))},t.prototype.alias=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,k)];case 1:return[2,e.sent()]}}))}))},t}();let N=!1,P=!1;const I={debug:1,default:2,info:2,warning:3,error:4,off:5};let T=I.default,R=null;const $=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(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}();var C,O;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(C||(C={})),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"}(O||(O={}));const j="0123456789abcdef";class B{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==I[r]&&this.throwArgumentError("invalid log level name","logLevel",t),T>I[r]||console.log.apply(console,e)}debug(...t){this._log(B.levels.DEBUG,t)}info(...t){this._log(B.levels.INFO,t)}warn(...t){this._log(B.levels.WARNING,t)}makeError(t,e,r){if(P)return this.makeError("censored error",e,{});e||(e=B.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=j[e[t]>>4],r+=j[15&e[t]];n.push(t+"=Uint8Array(0x"+r+")")}else n.push(t+"="+JSON.stringify(e))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;let o="";switch(e){case O.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case O.CALL_EXCEPTION:case O.INSUFFICIENT_FUNDS:case O.MISSING_NEW:case O.NONCE_EXPIRED:case O.REPLACEMENT_UNDERPRICED:case O.TRANSACTION_REPLACED:case O.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(t+=" ("+n.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(r).forEach((function(t){s[t]=r[t]})),s}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,B.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){$&&this.throwError("platform missing String.prototype.normalize",B.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:$})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,B.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,B.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,B.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,B.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",B.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",B.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",B.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return R||(R=new B("logger/5.6.0")),R}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",B.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),N){if(!t)return;this.globalLogger().throwError("error censorship permanent",B.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}P=!!t,N=!!e}static setLogLevel(t){const e=I[t.toLowerCase()];null!=e?T=e:B.globalLogger().warn("invalid log level - "+t)}static from(t){return new B(t)}}B.errors=O,B.levels=C;const F=new B("bytes/5.6.1");function D(t){return!!t.toHexString}function L(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return L(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function z(t){return Z(t)&&!(t.length%2)||V(t)}function q(t){return"number"==typeof t&&t==t&&t%1==0}function V(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!q(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!q(r)||r<0||r>=256)return!1}return!0}function K(t,e){if(e||(e={}),"number"==typeof t){F.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),L(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),D(t)&&(t=t.toHexString()),Z(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":F.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return L(new Uint8Array(n))}return V(t)?L(new Uint8Array(t)):F.throwArgumentError("invalid arrayify value","value",t)}function G(t){const e=t.map(t=>K(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),L(n)}function H(t){let e=K(t);if(0===e.length)return e;let r=0;for(;r<e.length&&0===e[r];)r++;return r&&(e=e.slice(r)),e}function Z(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function J(t,e){if(e||(e={}),"number"==typeof t){F.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"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),D(t))return t.toHexString();if(Z(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":F.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(V(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return F.throwArgumentError("invalid hexlify value","value",t)}function Q(t){if("string"!=typeof t)t=J(t);else if(!Z(t)||t.length%2)return null;return(t.length-2)/2}function W(t,e,r){return"string"!=typeof t?t=J(t):(!Z(t)||t.length%2)&&F.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Y(t){let e="0x";return t.forEach(t=>{e+=J(t).substring(2)}),e}function X(t){const e=function(t){"string"!=typeof t&&(t=J(t));Z(t)||F.throwArgumentError("invalid hex string","value",t);t=t.substring(2);let e=0;for(;e<t.length&&"0"===t[e];)e++;return"0x"+t.substring(e)}(J(t,{hexPad:"left"}));return"0x"===e?"0x0":e}function tt(t,e){for("string"!=typeof t?t=J(t):Z(t)||F.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&F.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function et(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(z(t)){let r=K(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=J(r.slice(0,32)),e.s=J(r.slice(32,64))):65===r.length?(e.r=J(r.slice(0,32)),e.s=J(r.slice(32,64)),e.v=r[64]):F.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:F.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=J(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){const r=function(t,e){(t=K(t)).length>e&&F.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),L(r)}(K(e._vs),32);e._vs=J(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&F.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const i=J(r);null==e.s?e.s=i:e.s!==i&&F.throwArgumentError("signature v mismatch _vs","signature",t)}if(null==e.recoveryParam)null==e.v?F.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{const r=0===e.v||1===e.v?e.v:1-e.v%2;e.recoveryParam!==r&&F.throwArgumentError("signature recoveryParam mismatch v","signature",t)}null!=e.r&&Z(e.r)?e.r=tt(e.r,32):F.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&Z(e.s)?e.s=tt(e.s,32):F.throwArgumentError("signature missing or invalid s","signature",t);const r=K(e.s);r[0]>=128&&F.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=J(r);e._vs&&(Z(e._vs)||F.throwArgumentError("signature invalid _vs","signature",t),e._vs=tt(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&F.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function rt(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return n=J(new Buffer(n,"utf8")),[4,t.send("personal_sign",[n,i])];case 1:return[2,e.sent()]}}))}))}var nt=function(){function t(t){void 0===t&&(t=S[0]),this.address=t}return t.prototype.request=function(t,e){var r,n=this.address+"/api/"+t;return e&&(r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}),new Promise((function(t,e){h(n,r).then((function(e){if(e.ok)return t(e.json());throw e})).catch((function(t){return t.json().then((function(t){return e(t)}))}))}))},t.prototype.send=function(t){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.request("message",t)]}))}))},t.prototype.getSpaces=function(){return e(this,void 0,void 0,(function(){return r(this,(function(t){return[2,this.request("spaces")]}))}))},t.prototype.broadcast=function(t,n,i,o,s){return e(this,void 0,void 0,(function(){var e,a;return r(this,(function(r){switch(r.label){case 0:return e={address:n,msg:JSON.stringify({version:"0.1.3",timestamp:(Date.now()/1e3).toFixed(),space:i,type:o,payload:s})},a=e,[4,rt(t,e.msg,n)];case 1:return a.sig=r.sent(),[4,this.send(e)];case 2:return[2,r.sent()]}}))}))},t.prototype.sign=function(t,n,i,o,s){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return e={address:n,msg:JSON.stringify({version:"0.1.3",timestamp:(Date.now()/1e3).toFixed(),space:i,type:o,payload:s})},[4,rt(t,e.msg,n)];case 1:return[2,r.sent()]}}))}))},t.prototype.vote=function(t,n,i,o){var s=o.proposal,a=o.choice;return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"vote",{proposal:s,choice:a})]}))}))},t.prototype.proposal=function(t,n,i,o){var s=o.name,a=o.body,u=o.discussion,h=void 0===u?"":u,l=o.choices,c=o.start,f=o.end,d=o.snapshot,p=o.type,m=void 0===p?"single-choice":p,y=o.metadata,g=void 0===y?{}:y;return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"proposal",{name:s,body:a,discussion:h,choices:l,start:c,end:f,snapshot:d,type:m,metadata:g})]}))}))},t.prototype.deleteProposal=function(t,n,i,o){var s=o.proposal;return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"delete-proposal",{proposal:s})]}))}))},t.prototype.settings=function(t,n,i,o){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"settings",o)]}))}))},t}(),it={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Proposal",definitions:{Proposal:{title:"Proposal",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0,maxLength:14400},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1,maxItems:160},type:{type:"string",enum:["single-choice","approval","ranked-choice","quadratic","weighted","custom","basic"]},snapshot:{type:"number",title:"snapshot"},start:{type:"number",title:"start",minimum:1e9,maximum:2e9},end:{type:"number",title:"end",minimum:1e9,maximum:2e9,exclusiveMinimum:{$data:"1/start"}},metadata:{type:"object",title:"metadata"}},required:["name","body","choices","snapshot","start","end"],additionalProperties:!1}}},ot={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Vote",definitions:{Vote:{title:"Vote",type:"object",properties:{proposal:{type:"string",title:"proposal"},choice:{type:["number","array","object","boolean"],title:"choice"},metadata:{type:"object",title:"metadata"}},required:["proposal","choice"],additionalProperties:!1}}},st={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Profile",definitions:{Profile:{title:"Profile",type:"object",properties:{name:{type:"string",title:"name",maxLength:32},about:{type:"string",title:"about",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256}},required:[],additionalProperties:!1}}},at={space:{$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Space",definitions:{Space:{title:"Space",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:32},private:{type:"boolean"},about:{type:"string",title:"about",maxLength:160},guidelines:{type:"string",title:"guidelines",maxLength:1024},terms:{type:"string",title:"terms",format:"uri",maxLength:128},avatar:{type:"string",title:"avatar",format:"uri",maxLength:256},location:{type:"string",title:"location",maxLength:24},website:{type:"string",title:"website",format:"url",maxLength:128},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},email:{type:"string",title:"email",maxLength:32},network:{type:"string",title:"network",minLength:1,maxLength:32},symbol:{type:"string",title:"symbol",minLength:1,maxLength:16},skin:{type:"string",title:"skin",maxLength:32},domain:{type:"string",title:"domain",maxLength:64},strategies:{type:"array",minItems:1,maxItems:8,items:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},network:{type:"string",maxLength:12,title:"network"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},title:"strategies"},members:{type:"array",maxItems:100,items:{type:"string",pattern:"^0x[a-fA-F0-9]{40}$",minLength:42,maxLength:42},title:"members",uniqueItems:!0},admins:{type:"array",maxItems:100,items:{type:"string",pattern:"^0x[a-fA-F0-9]{40}$",minLength:42,maxLength:42},title:"admins",uniqueItems:!0},filters:{type:"object",properties:{defaultTab:{type:"string"},minScore:{type:"number",minimum:0},onlyMembers:{type:"boolean"},invalids:{type:"array",items:{type:"string",maxLength:64},title:"invalids"}},additionalProperties:!1},validation:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},plugins:{type:"object"},voting:{type:"object",properties:{delay:{type:"integer",minimum:0},period:{type:"integer",minimum:0},type:{type:"string",title:"type"},quorum:{type:"number",minimum:0},blind:{type:"boolean"},hideAbstain:{type:"boolean"},privacy:{type:"string",enum:["","shutter"]}},additionalProperties:!1},categories:{type:"array",maxItems:2,items:{type:"string",enum:["protocol","social","investment","grant","service","media","creator","collector"]}},treasuries:{type:"array",maxItems:10,items:{type:"object",properties:{name:{type:"string",title:"Name",examples:["e.g. Balancer DAO 1"],minLength:1,maxLength:64},address:{type:"string",title:"Contract address",examples:["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],pattern:"^0x[a-fA-F0-9]{40}$",minLength:42,maxLength:42},network:{type:"string",title:"Network",maxLength:12}},required:["name","address","network"],additionalProperties:!1}},parent:{type:"string",title:"parent"},children:{type:"array",maxItems:8,title:"children",items:{type:"string"}}},required:["name","network","symbol","strategies"],additionalProperties:!1}}}.definitions.Space,proposal:it.definitions.Proposal,vote:ot.definitions.Vote,profile:st.definitions.Profile},ut="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ht=[],lt=[],ct="undefined"!=typeof Uint8Array?Uint8Array:Array,ft=!1;function dt(){ft=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)ht[e]=t[e],lt[t.charCodeAt(e)]=e;lt["-".charCodeAt(0)]=62,lt["_".charCodeAt(0)]=63}function pt(t,e,r){for(var n,i,o=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(ht[(i=n)>>18&63]+ht[i>>12&63]+ht[i>>6&63]+ht[63&i]);return o.join("")}function mt(t){var e;ft||dt();for(var r=t.length,n=r%3,i="",o=[],s=0,a=r-n;s<a;s+=16383)o.push(pt(t,s,s+16383>a?a:s+16383));return 1===n?(e=t[r-1],i+=ht[e>>2],i+=ht[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=ht[e>>10],i+=ht[e>>4&63],i+=ht[e<<2&63],i+="="),o.push(i),o.join("")}function yt(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,h=u>>1,l=-7,c=r?i-1:0,f=r?-1:1,d=t[e+c];for(c+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+t[e+c],c+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+c],c+=f,l-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function gt(t,e,r,n,i,o){var s,a,u,h=8*o-i-1,l=(1<<h)-1,c=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?f/u:f*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=l?(a=0,s=l):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;t[r+d]=255&s,d+=p,s/=256,h-=8);t[r+d-p]|=128*m}var vt={}.toString,wt=Array.isArray||function(t){return"[object Array]"==vt.call(t)};Mt.TYPED_ARRAY_SUPPORT=void 0===ut.TYPED_ARRAY_SUPPORT||ut.TYPED_ARRAY_SUPPORT;var bt=At();function At(){return Mt.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _t(t,e){if(At()<e)throw new RangeError("Invalid typed array length");return Mt.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Mt.prototype:(null===t&&(t=new Mt(e)),t.length=e),t}function Mt(t,e,r){if(!(Mt.TYPED_ARRAY_SUPPORT||this instanceof Mt))return new Mt(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return St(this,t)}return Et(this,t,e,r)}function Et(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);Mt.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Mt.prototype:t=xt(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!Mt.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Pt(e,r),i=(t=_t(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(Nt(e)){var r=0|Ut(e.length);return 0===(t=_t(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?_t(t,0):xt(t,e);if("Buffer"===e.type&&wt(e.data))return xt(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function kt(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function St(t,e){if(kt(e),t=_t(t,e<0?0:0|Ut(e)),!Mt.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function xt(t,e){var r=e.length<0?0:0|Ut(e.length);t=_t(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function Ut(t){if(t>=At())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+At().toString(16)+" bytes");return 0|t}function Nt(t){return!(null==t||!t._isBuffer)}function Pt(t,e){if(Nt(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return re(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ne(t).length;default:if(n)return re(t).length;e=(""+e).toLowerCase(),n=!0}}function It(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Kt(this,e,r);case"utf8":case"utf-8":return zt(this,e,r);case"ascii":return qt(this,e,r);case"latin1":case"binary":return Vt(this,e,r);case"base64":return Lt(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Tt(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Rt(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Mt.from(e,n)),Nt(e))return 0===e.length?-1:$t(t,e,r,n,i);if("number"==typeof e)return e&=255,Mt.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):$t(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function $t(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var l=-1;for(o=r;o<a;o++)if(h(t,o)===h(e,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var c=!0,f=0;f<u;f++)if(h(t,o+f)!==h(e,f)){c=!1;break}if(c)return o}return-1}function Ct(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function Ot(t,e,r,n){return ie(re(e,t.length-r),t,r,n)}function jt(t,e,r,n){return ie(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function Bt(t,e,r,n){return jt(t,e,r,n)}function Ft(t,e,r,n){return ie(ne(e),t,r,n)}function Dt(t,e,r,n){return ie(function(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function Lt(t,e,r){return 0===e&&r===t.length?mt(t):mt(t.slice(e,r))}function zt(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,a,u,h=t[i],l=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=r)switch(c){case 1:h<128&&(l=h);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&h)<<6|63&o)>127&&(l=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=c}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}Mt.poolSize=8192,Mt._augment=function(t){return t.__proto__=Mt.prototype,t},Mt.from=function(t,e,r){return Et(null,t,e,r)},Mt.TYPED_ARRAY_SUPPORT&&(Mt.prototype.__proto__=Uint8Array.prototype,Mt.__proto__=Uint8Array),Mt.alloc=function(t,e,r){return function(t,e,r,n){return kt(e),e<=0?_t(t,e):void 0!==r?"string"==typeof n?_t(t,e).fill(r,n):_t(t,e).fill(r):_t(t,e)}(null,t,e,r)},Mt.allocUnsafe=function(t){return St(null,t)},Mt.allocUnsafeSlow=function(t){return St(null,t)},Mt.isBuffer=oe,Mt.compare=function(t,e){if(!Nt(t)||!Nt(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},Mt.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Mt.concat=function(t,e){if(!wt(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Mt.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=Mt.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!Nt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},Mt.byteLength=Pt,Mt.prototype._isBuffer=!0,Mt.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Tt(this,e,e+1);return this},Mt.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Tt(this,e,e+3),Tt(this,e+1,e+2);return this},Mt.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Tt(this,e,e+7),Tt(this,e+1,e+6),Tt(this,e+2,e+5),Tt(this,e+3,e+4);return this},Mt.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?zt(this,0,t):It.apply(this,arguments)},Mt.prototype.equals=function(t){if(!Nt(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Mt.compare(this,t)},Mt.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Mt.prototype.compare=function(t,e,r,n,i){if(!Nt(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=t.slice(e,r),l=0;l<a;++l)if(u[l]!==h[l]){o=u[l],s=h[l];break}return o<s?-1:s<o?1:0},Mt.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},Mt.prototype.indexOf=function(t,e,r){return Rt(this,t,e,r,!0)},Mt.prototype.lastIndexOf=function(t,e,r){return Rt(this,t,e,r,!1)},Mt.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ct(this,t,e,r);case"utf8":case"utf-8":return Ot(this,t,e,r);case"ascii":return jt(this,t,e,r);case"latin1":case"binary":return Bt(this,t,e,r);case"base64":return Ft(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Dt(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Mt.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function qt(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function Vt(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Kt(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=ee(t[o]);return i}function Gt(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function Ht(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function Zt(t,e,r,n,i,o){if(!Nt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function Jt(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function Qt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function Wt(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Yt(t,e,r,n,i){return i||Wt(t,0,r,4),gt(t,e,r,n,23,4),r+4}function Xt(t,e,r,n,i){return i||Wt(t,0,r,8),gt(t,e,r,n,52,8),r+8}Mt.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),Mt.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=Mt.prototype;else{var i=e-t;r=new Mt(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},Mt.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},Mt.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Mt.prototype.readUInt8=function(t,e){return e||Ht(t,1,this.length),this[t]},Mt.prototype.readUInt16LE=function(t,e){return e||Ht(t,2,this.length),this[t]|this[t+1]<<8},Mt.prototype.readUInt16BE=function(t,e){return e||Ht(t,2,this.length),this[t]<<8|this[t+1]},Mt.prototype.readUInt32LE=function(t,e){return e||Ht(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Mt.prototype.readUInt32BE=function(t,e){return e||Ht(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Mt.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},Mt.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Mt.prototype.readInt8=function(t,e){return e||Ht(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Mt.prototype.readInt16LE=function(t,e){e||Ht(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Mt.prototype.readInt16BE=function(t,e){e||Ht(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Mt.prototype.readInt32LE=function(t,e){return e||Ht(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Mt.prototype.readInt32BE=function(t,e){return e||Ht(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Mt.prototype.readFloatLE=function(t,e){return e||Ht(t,4,this.length),yt(this,t,!0,23,4)},Mt.prototype.readFloatBE=function(t,e){return e||Ht(t,4,this.length),yt(this,t,!1,23,4)},Mt.prototype.readDoubleLE=function(t,e){return e||Ht(t,8,this.length),yt(this,t,!0,52,8)},Mt.prototype.readDoubleBE=function(t,e){return e||Ht(t,8,this.length),yt(this,t,!1,52,8)},Mt.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||Zt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},Mt.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||Zt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Mt.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,1,255,0),Mt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Mt.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,65535,0),Mt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Jt(this,t,e,!0),e+2},Mt.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,65535,0),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Jt(this,t,e,!1),e+2},Mt.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,4294967295,0),Mt.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):Qt(this,t,e,!0),e+4},Mt.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,4294967295,0),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Qt(this,t,e,!1),e+4},Mt.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);Zt(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Mt.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);Zt(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Mt.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,1,127,-128),Mt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},Mt.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,32767,-32768),Mt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Jt(this,t,e,!0),e+2},Mt.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,32767,-32768),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Jt(this,t,e,!1),e+2},Mt.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,2147483647,-2147483648),Mt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Qt(this,t,e,!0),e+4},Mt.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Qt(this,t,e,!1),e+4},Mt.prototype.writeFloatLE=function(t,e,r){return Yt(this,t,e,!0,r)},Mt.prototype.writeFloatBE=function(t,e,r){return Yt(this,t,e,!1,r)},Mt.prototype.writeDoubleLE=function(t,e,r){return Xt(this,t,e,!0,r)},Mt.prototype.writeDoubleBE=function(t,e,r){return Xt(this,t,e,!1,r)},Mt.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!Mt.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},Mt.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Mt.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=Nt(t)?t:re(new Mt(t,n).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var te=/[^+\/0-9A-Za-z-_]/g;function ee(t){return t<16?"0"+t.toString(16):t.toString(16)}function re(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function ne(t){return function(t){var e,r,n,i,o,s;ft||dt();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[a-2]?2:"="===t[a-1]?1:0,s=new ct(3*a/4-o),n=o>0?a-4:a;var u=0;for(e=0,r=0;e<n;e+=4,r+=3)i=lt[t.charCodeAt(e)]<<18|lt[t.charCodeAt(e+1)]<<12|lt[t.charCodeAt(e+2)]<<6|lt[t.charCodeAt(e+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=lt[t.charCodeAt(e)]<<2|lt[t.charCodeAt(e+1)]>>4,s[u++]=255&i):1===o&&(i=lt[t.charCodeAt(e)]<<10|lt[t.charCodeAt(e+1)]<<4|lt[t.charCodeAt(e+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(te,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function ie(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function oe(t){return null!=t&&(!!t._isBuffer||se(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&se(t.slice(0,0))}(t))}function se(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var ae=a(Object.freeze({__proto__:null,INSPECT_MAX_BYTES:50,kMaxLength:bt,Buffer:Mt,SlowBuffer:function(t){return+t!=t&&(t=0),Mt.alloc(+t)},isBuffer:oe}));var ue=u((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"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:ae.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 h=t.charCodeAt(u)-48;o*=i,s=h>=49?h-49+10:h>=17?h-17+10:h,r(h>=0&&s<i,"Invalid character"),o+=s}return o}function h(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"==typeof 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"==typeof 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,h=0,l=r;l<a;l+=n)h=u(t,l,l+n,e),this.imuln(i),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==s){var c=1;for(h=u(t,l,t.length,e),l=0;l<s;l++)c*=e;this.imuln(c),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}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){h(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&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){i.prototype.inspect=l}else i.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],f=[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],d=[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?c[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 h=f[t],l=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(l).toString(t);n=(p=p.idivn(l)).isZero()?m+n:c[h-m.length]+m+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 p(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 h=1;h<n;h++){for(var l=u>>>26,c=67108863&u,f=Math.min(h,e.length-1),d=Math.max(0,h-t.length+1);d<=f;d++){var p=h-d|0;l+=(s=(i=0|t.words[p])*(o=0|e.words[d])+c)/67108864|0,c=67108863&s}r.words[h]=0|c,u=0|l}return 0!==u?r.words[h]=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 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(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];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,h=0,l=0|s[0],c=8191&l,f=l>>>13,d=0|s[1],p=8191&d,m=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,w=0|s[3],b=8191&w,A=w>>>13,_=0|s[4],M=8191&_,E=_>>>13,k=0|s[5],S=8191&k,x=k>>>13,U=0|s[6],N=8191&U,P=U>>>13,I=0|s[7],T=8191&I,R=I>>>13,$=0|s[8],C=8191&$,O=$>>>13,j=0|s[9],B=8191&j,F=j>>>13,D=0|a[0],L=8191&D,z=D>>>13,q=0|a[1],V=8191&q,K=q>>>13,G=0|a[2],H=8191&G,Z=G>>>13,J=0|a[3],Q=8191&J,W=J>>>13,Y=0|a[4],X=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ht=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(h+(n=Math.imul(c,L))|0)+((8191&(i=(i=Math.imul(c,z))+Math.imul(f,L)|0))<<13)|0;h=((o=Math.imul(f,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,L),i=(i=Math.imul(p,z))+Math.imul(m,L)|0,o=Math.imul(m,z);var gt=(h+(n=n+Math.imul(c,V)|0)|0)+((8191&(i=(i=i+Math.imul(c,K)|0)+Math.imul(f,V)|0))<<13)|0;h=((o=o+Math.imul(f,K)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,L),i=(i=Math.imul(g,z))+Math.imul(v,L)|0,o=Math.imul(v,z),n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,K)|0;var vt=(h+(n=n+Math.imul(c,H)|0)|0)+((8191&(i=(i=i+Math.imul(c,Z)|0)+Math.imul(f,H)|0))<<13)|0;h=((o=o+Math.imul(f,Z)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,L),i=(i=Math.imul(b,z))+Math.imul(A,L)|0,o=Math.imul(A,z),n=n+Math.imul(g,V)|0,i=(i=i+Math.imul(g,K)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,K)|0,n=n+Math.imul(p,H)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,Z)|0;var wt=(h+(n=n+Math.imul(c,Q)|0)|0)+((8191&(i=(i=i+Math.imul(c,W)|0)+Math.imul(f,Q)|0))<<13)|0;h=((o=o+Math.imul(f,W)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(M,L),i=(i=Math.imul(M,z))+Math.imul(E,L)|0,o=Math.imul(E,z),n=n+Math.imul(b,V)|0,i=(i=i+Math.imul(b,K)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,K)|0,n=n+Math.imul(g,H)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,H)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,W)|0;var bt=(h+(n=n+Math.imul(c,X)|0)|0)+((8191&(i=(i=i+Math.imul(c,tt)|0)+Math.imul(f,X)|0))<<13)|0;h=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,L),i=(i=Math.imul(S,z))+Math.imul(x,L)|0,o=Math.imul(x,z),n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,K)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,K)|0,n=n+Math.imul(b,H)|0,i=(i=i+Math.imul(b,Z)|0)+Math.imul(A,H)|0,o=o+Math.imul(A,Z)|0,n=n+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,tt)|0;var At=(h+(n=n+Math.imul(c,rt)|0)|0)+((8191&(i=(i=i+Math.imul(c,nt)|0)+Math.imul(f,rt)|0))<<13)|0;h=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,L),i=(i=Math.imul(N,z))+Math.imul(P,L)|0,o=Math.imul(P,z),n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,K)|0,n=n+Math.imul(M,H)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(E,H)|0,o=o+Math.imul(E,Z)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(g,X)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var _t=(h+(n=n+Math.imul(c,ot)|0)|0)+((8191&(i=(i=i+Math.imul(c,st)|0)+Math.imul(f,ot)|0))<<13)|0;h=((o=o+Math.imul(f,st)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(T,L),i=(i=Math.imul(T,z))+Math.imul(R,L)|0,o=Math.imul(R,z),n=n+Math.imul(N,V)|0,i=(i=i+Math.imul(N,K)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,K)|0,n=n+Math.imul(S,H)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,W)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var Mt=(h+(n=n+Math.imul(c,ut)|0)|0)+((8191&(i=(i=i+Math.imul(c,ht)|0)+Math.imul(f,ut)|0))<<13)|0;h=((o=o+Math.imul(f,ht)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(C,L),i=(i=Math.imul(C,z))+Math.imul(O,L)|0,o=Math.imul(O,z),n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,K)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,K)|0,n=n+Math.imul(N,H)|0,i=(i=i+Math.imul(N,Z)|0)+Math.imul(P,H)|0,o=o+Math.imul(P,Z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(m,ut)|0,o=o+Math.imul(m,ht)|0;var Et=(h+(n=n+Math.imul(c,ct)|0)|0)+((8191&(i=(i=i+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;h=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(B,L),i=(i=Math.imul(B,z))+Math.imul(F,L)|0,o=Math.imul(F,z),n=n+Math.imul(C,V)|0,i=(i=i+Math.imul(C,K)|0)+Math.imul(O,V)|0,o=o+Math.imul(O,K)|0,n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ht)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ht)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,ft)|0;var kt=(h+(n=n+Math.imul(c,pt)|0)|0)+((8191&(i=(i=i+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;h=((o=o+Math.imul(f,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(B,V),i=(i=Math.imul(B,K))+Math.imul(F,V)|0,o=Math.imul(F,K),n=n+Math.imul(C,H)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(O,H)|0,o=o+Math.imul(O,Z)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(N,X)|0,i=(i=i+Math.imul(N,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(b,ut)|0,i=(i=i+Math.imul(b,ht)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ht)|0,n=n+Math.imul(g,ct)|0,i=(i=i+Math.imul(g,ft)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ft)|0;var St=(h+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,Z))+Math.imul(F,H)|0,o=Math.imul(F,Z),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,W)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(N,rt)|0,i=(i=i+Math.imul(N,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ht)|0)+Math.imul(E,ut)|0,o=o+Math.imul(E,ht)|0,n=n+Math.imul(b,ct)|0,i=(i=i+Math.imul(b,ft)|0)+Math.imul(A,ct)|0,o=o+Math.imul(A,ft)|0;var xt=(h+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,mt)|0)+Math.imul(v,pt)|0))<<13)|0;h=((o=o+Math.imul(v,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(B,Q),i=(i=Math.imul(B,W))+Math.imul(F,Q)|0,o=Math.imul(F,W),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(O,X)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(N,ot)|0,i=(i=i+Math.imul(N,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ht)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ht)|0,n=n+Math.imul(M,ct)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,ft)|0;var Ut=(h+(n=n+Math.imul(b,pt)|0)|0)+((8191&(i=(i=i+Math.imul(b,mt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((o=o+Math.imul(A,mt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(B,X),i=(i=Math.imul(B,tt))+Math.imul(F,X)|0,o=Math.imul(F,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(N,ut)|0,i=(i=i+Math.imul(N,ht)|0)+Math.imul(P,ut)|0,o=o+Math.imul(P,ht)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ft)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,ft)|0;var Nt=(h+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,mt)|0)+Math.imul(E,pt)|0))<<13)|0;h=((o=o+Math.imul(E,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(B,rt),i=(i=Math.imul(B,nt))+Math.imul(F,rt)|0,o=Math.imul(F,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ht)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ht)|0,n=n+Math.imul(N,ct)|0,i=(i=i+Math.imul(N,ft)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ft)|0;var Pt=(h+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,mt)|0)+Math.imul(x,pt)|0))<<13)|0;h=((o=o+Math.imul(x,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(B,ot),i=(i=Math.imul(B,st))+Math.imul(F,ot)|0,o=Math.imul(F,st),n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ht)|0)+Math.imul(O,ut)|0,o=o+Math.imul(O,ht)|0,n=n+Math.imul(T,ct)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(R,ct)|0,o=o+Math.imul(R,ft)|0;var It=(h+(n=n+Math.imul(N,pt)|0)|0)+((8191&(i=(i=i+Math.imul(N,mt)|0)+Math.imul(P,pt)|0))<<13)|0;h=((o=o+Math.imul(P,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(B,ut),i=(i=Math.imul(B,ht))+Math.imul(F,ut)|0,o=Math.imul(F,ht),n=n+Math.imul(C,ct)|0,i=(i=i+Math.imul(C,ft)|0)+Math.imul(O,ct)|0,o=o+Math.imul(O,ft)|0;var Tt=(h+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(R,pt)|0))<<13)|0;h=((o=o+Math.imul(R,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(B,ct),i=(i=Math.imul(B,ft))+Math.imul(F,ct)|0,o=Math.imul(F,ft);var Rt=(h+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,mt)|0)+Math.imul(O,pt)|0))<<13)|0;h=((o=o+Math.imul(O,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var $t=(h+(n=Math.imul(B,pt))|0)+((8191&(i=(i=Math.imul(B,mt))+Math.imul(F,pt)|0))<<13)|0;return h=((o=Math.imul(F,mt))+(i>>>13)|0)+($t>>>26)|0,$t&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=wt,u[4]=bt,u[5]=At,u[6]=_t,u[7]=Mt,u[8]=Et,u[9]=kt,u[10]=St,u[11]=xt,u[12]=Ut,u[13]=Nt,u[14]=Pt,u[15]=It,u[16]=Tt,u[17]=Rt,u[18]=$t,0!==h&&(u[19]=h,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),h=Math.max(0,o-t.length+1);h<=u;h++){var l=o-h,c=(0|t.words[l])*(0|e.words[h]),f=67108863&c;a=67108863&(f=f+a|0),i+=(s=(s=s+(c/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function g(t,e,r){return y(t,e,r)}Math.imul||(m=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):g(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),g(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var h=0;h<s;h++)u.words[h]=this.words[h];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,h=0;h<this.length;h++)this.words[h]=this.words[h+s];else this.words[0]=0,this.length=1;var l=0;for(h=this.length-1;h>=0&&(0!==l||h>=i);h--){var c=0|this.words[h];this.words[h]=l<<26-o|c>>>o,l=c&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var l=n.clone()._ishlnsubmul(o,1,u);0===l.negative&&(n=l,a&&(a.words[u]=1));for(var c=u-1;c>=0;c--){var f=67108864*(0|n.words[o.length+c])+(0|n.words[o.length+c-1]);for(f=Math.min(f/s|0,67108863),n._ishlnsubmul(o,f,c);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(o,1,c),n.isZero()||(n.negative^=1);a&&(a.words[c]=f)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var l=n.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(c)),o.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(c)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(h)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var c=0,f=1;0==(n.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(n.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new E(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function A(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function k(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},n(b,w),b.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(A,w),n(_,w),n(M,w),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new A;else if("p192"===t)e=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return v[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,h).cmp(u);)l.redIAdd(u);for(var c=this.pow(l,o),f=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var m=d,y=0;0!==m.cmp(a);y++)m=m.redSqr();r(y<p);var g=this.pow(c,new i(1).iushln(p-y-1));f=f.redMul(g),c=g.redSqr(),d=d.redMul(c),p=y}return f},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var h=e.words[n],l=u-1;l>=0;l--){var c=h>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==s?(s<<=1,s|=c,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}u=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new k(t)},n(k,E),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)})).BN;const he=new B("bignumber/5.6.2"),le={};let ce=!1;class fe{constructor(t,e){t!==le&&he.throwError("cannot call constructor directly; use BigNumber.from",B.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return pe(me(this).fromTwos(t))}toTwos(t){return pe(me(this).toTwos(t))}abs(){return"-"===this._hex[0]?fe.from(this._hex.substring(1)):this}add(t){return pe(me(this).add(me(t)))}sub(t){return pe(me(this).sub(me(t)))}div(t){return fe.from(t).isZero()&&ye("division-by-zero","div"),pe(me(this).div(me(t)))}mul(t){return pe(me(this).mul(me(t)))}mod(t){const e=me(t);return e.isNeg()&&ye("division-by-zero","mod"),pe(me(this).umod(e))}pow(t){const e=me(t);return e.isNeg()&&ye("negative-power","pow"),pe(me(this).pow(e))}and(t){const e=me(t);return(this.isNegative()||e.isNeg())&&ye("unbound-bitwise-result","and"),pe(me(this).and(e))}or(t){const e=me(t);return(this.isNegative()||e.isNeg())&&ye("unbound-bitwise-result","or"),pe(me(this).or(e))}xor(t){const e=me(t);return(this.isNegative()||e.isNeg())&&ye("unbound-bitwise-result","xor"),pe(me(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&ye("negative-width","mask"),pe(me(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&ye("negative-width","shl"),pe(me(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&ye("negative-width","shr"),pe(me(this).shrn(t))}eq(t){return me(this).eq(me(t))}lt(t){return me(this).lt(me(t))}lte(t){return me(this).lte(me(t))}gt(t){return me(this).gt(me(t))}gte(t){return me(this).gte(me(t))}isNegative(){return"-"===this._hex[0]}isZero(){return me(this).isZero()}toNumber(){try{return me(this).toNumber()}catch(t){ye("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return he.throwError("this platform does not support BigInt",B.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?ce||(ce=!0,he.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?he.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",B.errors.UNEXPECTED_ARGUMENT,{}):he.throwError("BigNumber.toString does not accept parameters",B.errors.UNEXPECTED_ARGUMENT,{})),me(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof fe)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new fe(le,de(t)):t.match(/^-?[0-9]+$/)?new fe(le,de(new ue(t))):he.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&ye("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&ye("overflow","BigNumber.from",t),fe.from(String(t));const e=t;if("bigint"==typeof e)return fe.from(e.toString());if(V(e))return fe.from(J(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return fe.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(Z(t)||"-"===t[0]&&Z(t.substring(1))))return fe.from(t)}return he.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function de(t){if("string"!=typeof t)return de(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&he.throwArgumentError("invalid hex","value",t),"0x00"===(t=de(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function pe(t){return fe.from(de(t))}function me(t){const e=fe.from(t).toHexString();return"-"===e[0]?new ue("-"+e.substring(3),16):new ue(e.substring(2),16)}function ye(t,e,r){const n={fault:t,operation:e};return null!=r&&(n.value=r),he.throwError(t,B.errors.NUMERIC_FAULT,n)}var ge=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const ve=new B("properties/5.6.0");function we(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function be(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function Ae(t){return ge(this,void 0,void 0,(function*(){const e=Object.keys(t).map(e=>{const r=t[e];return Promise.resolve(r).then(t=>({key:e,value:t}))});return(yield Promise.all(e)).reduce((t,e)=>(t[e.key]=e.value,t),{})}))}function _e(t){const e={};for(const r in t)e[r]=t[r];return e}const Me={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Ee(t){if(function t(e){if(null==e||Me[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const r=Object.keys(e);for(let n=0;n<r.length;n++){let i=null;try{i=e[r[n]]}catch(t){continue}if(!t(i))return!1}return!0}return ve.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}(t))return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ke(t)));if("object"==typeof t){const e={};for(const r in t){const n=t[r];void 0!==n&&we(e,r,ke(n))}return e}return ve.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function ke(t){return Ee(t)}class Se{constructor(t){for(const e in t)this[e]=ke(t[e])}}const xe=new B("abi/5.3.1"),Ue={};let Ne={calldata:!0,memory:!0,storage:!0},Pe={calldata:!0,memory:!0};function Ie(t,e){if("bytes"===t||"string"===t){if(Ne[e])return!0}else if("address"===t){if("payable"===e)return!0}else if((t.indexOf("[")>=0||"tuple"===t)&&Pe[e])return!0;return(Ne[e]||"payable"===e)&&xe.throwArgumentError("invalid modifier","name",e),!1}function Te(t,e){for(let r in e)we(t,r,e[r])}const Re=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),$e=new RegExp(/^(.*)\[([0-9]*)\]$/);class Ce{constructor(t,e){t!==Ue&&xe.throwError("use fromString",B.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),Te(this,e);let r=this.type.match($e);Te(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:Ce.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==Re.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===Re.full?", ":",")+")"):e+=this.type,t!==Re.sighash&&(!0===this.indexed&&(e+=" indexed"),t===Re.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?Ce.fromString(t,e):Ce.fromObject(t)}static fromObject(t){return Ce.isParamType(t)?t:new Ce(Ue,{name:t.name||null,type:Ge(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(Ce.fromObject):null})}static fromString(t,e){return r=function(t,e){let r=t;function n(e){xe.throwArgumentError("unexpected character at position "+e,"param",t)}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;r<t.length;r++){let o=t[r];switch(o){case"(":s.state.allowType&&""===s.type?s.type="tuple":s.state.allowParams||n(r),s.state.allowType=!1,s.type=Ge(s.type),s.components=[i(s)],s=s.components[0];break;case")":delete s.state,"indexed"===s.name&&(e||n(r),s.indexed=!0,s.name=""),Ie(s.type,s.name)&&(s.name=""),s.type=Ge(s.type);let t=s;s=s.parent,s||n(r),delete t.parent,s.state.allowParams=!1,s.state.allowName=!0,s.state.allowArray=!0;break;case",":delete s.state,"indexed"===s.name&&(e||n(r),s.indexed=!0,s.name=""),Ie(s.type,s.name)&&(s.name=""),s.type=Ge(s.type);let a=i(s.parent);s.parent.components.push(a),delete s.parent,s=a;break;case" ":s.state.allowType&&""!==s.type&&(s.type=Ge(s.type),delete s.state.allowType,s.state.allowName=!0,s.state.allowParams=!0),s.state.allowName&&""!==s.name&&("indexed"===s.name?(e||n(r),s.indexed&&n(r),s.indexed=!0,s.name=""):Ie(s.type,s.name)?s.name="":s.state.allowName=!1);break;case"[":s.state.allowArray||n(r),s.type+=o,s.state.allowArray=!1,s.state.allowName=!1,s.state.readArray=!0;break;case"]":s.state.readArray||n(r),s.type+=o,s.state.readArray=!1,s.state.allowArray=!0,s.state.allowName=!0;break;default:s.state.allowType?(s.type+=o,s.state.allowParams=!0,s.state.allowArray=!0):s.state.allowName?(s.name+=o,delete s.state.allowArray):s.state.readArray?s.type+=o:n(r)}}return s.parent&&xe.throwArgumentError("unexpected eof","param",t),delete o.state,"indexed"===s.name?(e||n(r.length-7),s.indexed&&n(r.length-7),s.indexed=!0,s.name=""):Ie(s.type,s.name)&&(s.name=""),o.type=Ge(o.type),o}(t,!!e),Ce.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(t){return!(null==t||!t._isParamType)}}function Oe(t,e){return function(t){t=t.trim();let e=[],r="",n=0;for(let i=0;i<t.length;i++){let o=t[i];","===o&&0===n?(e.push(r),r=""):(r+=o,"("===o?n++:")"===o&&(n--,-1===n&&xe.throwArgumentError("unbalanced parenthesis","value",t)))}r&&e.push(r);return e}(t).map(t=>Ce.fromString(t,e))}class je{constructor(t,e){t!==Ue&&xe.throwError("use a static from method",B.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Te(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return je.isFragment(t)?t:"string"==typeof t?je.fromString(t):je.fromObject(t)}static fromObject(t){if(je.isFragment(t))return t;switch(t.type){case"function":return qe.fromObject(t);case"event":return Be.fromObject(t);case"constructor":return ze.fromObject(t);case"error":return Ke.fromObject(t);case"fallback":case"receive":return null}return xe.throwArgumentError("invalid fragment object","value",t)}static fromString(t){return"event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Be.fromString(t.substring(5).trim()):"function"===t.split(" ")[0]?qe.fromString(t.substring(8).trim()):"constructor"===t.split("(")[0].trim()?ze.fromString(t.trim()):"error"===t.split(" ")[0]?Ke.fromString(t.substring(5).trim()):xe.throwArgumentError("unsupported fragment","value",t)}static isFragment(t){return!(!t||!t._isFragment)}}class Be extends je{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==Re.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ",t!==Re.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?Be.fromString(t):Be.fromObject(t)}static fromObject(t){if(Be.isEventFragment(t))return t;"event"!==t.type&&xe.throwArgumentError("invalid event object","value",t);const e={name:Ze(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(Ce.fromObject):[],type:"event"};return new Be(Ue,e)}static fromString(t){let e=t.match(Je);e||xe.throwArgumentError("invalid event string","value",t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:xe.warn("unknown modifier: "+t)}}),Be.fromObject({name:e[1].trim(),anonymous:r,inputs:Oe(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function Fe(t,e){e.gas=null;let r=t.split("@");return 1!==r.length?(r.length>2&&xe.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||xe.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=fe.from(r[1]),r[0]):t}function De(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Le(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return null!=t.stateMutability?(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant&&xe.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable&&xe.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):null!=t.payable?(e.payable=!!t.payable,null!=t.constant||e.payable||"constructor"===t.type||xe.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&xe.throwArgumentError("cannot have constant payable function","value",t)):null!=t.constant?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):"constructor"!==t.type&&xe.throwArgumentError("unable to determine stateMutability","value",t),e}class ze extends je{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===Re.sighash&&xe.throwError("cannot format a constructor for sighash",B.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?ze.fromString(t):ze.fromObject(t)}static fromObject(t){if(ze.isConstructorFragment(t))return t;"constructor"!==t.type&&xe.throwArgumentError("invalid constructor object","value",t);let e=Le(t);e.constant&&xe.throwArgumentError("constructor cannot be constant","value",t);const r={name:null,type:t.type,inputs:t.inputs?t.inputs.map(Ce.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?fe.from(t.gas):null};return new ze(Ue,r)}static fromString(t){let e={type:"constructor"},r=(t=Fe(t,e)).match(Je);return r&&"constructor"===r[1].trim()||xe.throwArgumentError("invalid constructor string","value",t),e.inputs=Oe(r[2].trim(),!1),De(r[3].trim(),e),ze.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class qe extends ze{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),outputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==Re.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ",t!==Re.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?qe.fromString(t):qe.fromObject(t)}static fromObject(t){if(qe.isFunctionFragment(t))return t;"function"!==t.type&&xe.throwArgumentError("invalid function object","value",t);let e=Le(t);const r={type:t.type,name:Ze(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(Ce.fromObject):[],outputs:t.outputs?t.outputs.map(Ce.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?fe.from(t.gas):null};return new qe(Ue,r)}static fromString(t){let e={type:"function"},r=(t=Fe(t,e)).split(" returns ");r.length>2&&xe.throwArgumentError("invalid function string","value",t);let n=r[0].match(Je);if(n||xe.throwArgumentError("invalid function signature","value",t),e.name=n[1].trim(),e.name&&Ze(e.name),e.inputs=Oe(n[2],!1),De(n[3].trim(),e),r.length>1){let n=r[1].match(Je);""==n[1].trim()&&""==n[3].trim()||xe.throwArgumentError("unexpected tokens","value",t),e.outputs=Oe(n[2],!1)}else e.outputs=[];return qe.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function Ve(t){const e=t.format();return"Error(string)"!==e&&"Panic(uint256)"!==e||xe.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}class Ke extends je{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==Re.sighash&&(e+="error "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ",e.trim()}static from(t){return"string"==typeof t?Ke.fromString(t):Ke.fromObject(t)}static fromObject(t){if(Ke.isErrorFragment(t))return t;"error"!==t.type&&xe.throwArgumentError("invalid error object","value",t);const e={type:t.type,name:Ze(t.name),inputs:t.inputs?t.inputs.map(Ce.fromObject):[]};return Ve(new Ke(Ue,e))}static fromString(t){let e={type:"error"},r=t.match(Je);return r||xe.throwArgumentError("invalid error signature","value",t),e.name=r[1].trim(),e.name&&Ze(e.name),e.inputs=Oe(r[2],!1),Ve(Ke.fromObject(e))}static isErrorFragment(t){return t&&t._isFragment&&"error"===t.type}}function Ge(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const He=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Ze(t){return t&&t.match(He)||xe.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}const Je=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Qe=new B("abi/5.3.1");class We{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Qe.throwArgumentError(t,this.localName,e)}}class Ye{constructor(t){we(this,"wordSize",t||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(t)}get data(){return Y(this._data)}get length(){return this._dataLength}_writeData(t){return this._data.push(t),this._dataLength+=t.length,t.length}appendWriter(t){return this._writeData(G(t._data))}writeBytes(t){let e=K(t);const r=e.length%this.wordSize;return r&&(e=G([e,this._padding.slice(r)])),this._writeData(e)}_getValue(t){let e=K(fe.from(t));return e.length>this.wordSize&&Qe.throwError("value out-of-bounds",B.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=G([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){const t=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,e=>{this._data[t]=this._getValue(e)}}}class Xe{constructor(t,e,r,n){we(this,"_data",K(t)),we(this,"wordSize",e||32),we(this,"_coerceFunc",r),we(this,"allowLoose",n),this._offset=0}get data(){return J(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Xe.coerce(t,e)}_peekBytes(t,e,r){let n=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&r&&this._offset+e<=this._data.length?n=e:Qe.throwError("data out-of-bounds",B.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(t){return new Xe(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(t,e){let r=this._peekBytes(0,t,!!e);return this._offset+=r.length,r.slice(0,t)}readValue(){return fe.from(this.readBytes(this.wordSize))}}function tr(){throw new Error("setTimeout has not been defined")}function er(){throw new Error("clearTimeout has not been defined")}var rr=tr,nr=er;function ir(t){if(rr===setTimeout)return setTimeout(t,0);if((rr===tr||!rr)&&setTimeout)return rr=setTimeout,setTimeout(t,0);try{return rr(t,0)}catch(e){try{return rr.call(null,t,0)}catch(e){return rr.call(this,t,0)}}}"function"==typeof ut.setTimeout&&(rr=setTimeout),"function"==typeof ut.clearTimeout&&(nr=clearTimeout);var or,sr=[],ar=!1,ur=-1;function hr(){ar&&or&&(ar=!1,or.length?sr=or.concat(sr):ur=-1,sr.length&&lr())}function lr(){if(!ar){var t=ir(hr);ar=!0;for(var e=sr.length;e;){for(or=sr,sr=[];++ur<e;)or&&or[ur].run();ur=-1,e=sr.length}or=null,ar=!1,function(t){if(nr===clearTimeout)return clearTimeout(t);if((nr===er||!nr)&&clearTimeout)return nr=clearTimeout,clearTimeout(t);try{nr(t)}catch(e){try{return nr.call(null,t)}catch(e){return nr.call(this,t)}}}(t)}}function cr(t,e){this.fun=t,this.array=e}cr.prototype.run=function(){this.fun.apply(null,this.array)};function fr(){}var dr=fr,pr=fr,mr=fr,yr=fr,gr=fr,vr=fr,wr=fr;var br=ut.performance||{},Ar=br.now||br.mozNow||br.msNow||br.oNow||br.webkitNow||function(){return(new Date).getTime()};var _r=new Date;var Mr={nextTick:function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];sr.push(new cr(t,e)),1!==sr.length||ar||ir(lr)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:dr,addListener:pr,once:mr,off:yr,removeListener:gr,removeAllListeners:vr,emit:wr,binding:function(t){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*Ar.call(br),r=Math.floor(e),n=Math.floor(e%1*1e9);return t&&(r-=t[0],(n-=t[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-_r)/1e3}},Er=u((function(t){!function(){var e="input is invalid type",r="object"==typeof window,n=r?window:{};n.JS_SHA3_NO_WINDOW&&(r=!1);var i=!r&&"object"==typeof self;!n.JS_SHA3_NO_NODE_JS&&"object"==typeof Mr&&Mr.versions&&Mr.versions.node?n=o:i&&(n=self);var s=!n.JS_SHA3_NO_COMMON_JS&&t.exports,a=!n.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),h=[4,1024,262144,67108864],l=[0,8,16,24],c=[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],f=[224,256,384,512],d=[128,256],p=["hex","buffer","arrayBuffer","array","digest"],m={128:168,256:136};!n.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!a||!n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var y=function(t,e,r){return function(n){return new I(t,e,t).update(n)[r]()}},g=function(t,e,r){return function(n,i){return new I(t,e,i).update(n)[r]()}},v=function(t,e,r){return function(e,n,i,o){return M["cshake"+t].update(e,n,i,o)[r]()}},w=function(t,e,r){return function(e,n,i,o){return M["kmac"+t].update(e,n,i,o)[r]()}},b=function(t,e,r,n){for(var i=0;i<p.length;++i){var o=p[i];t[o]=e(r,n,o)}return t},A=function(t,e){var r=y(t,e,"hex");return r.create=function(){return new I(t,e,t)},r.update=function(t){return r.create().update(t)},b(r,y,t,e)},_=[{name:"keccak",padding:[1,256,65536,16777216],bits:f,createMethod:A},{name:"sha3",padding:[6,1536,393216,100663296],bits:f,createMethod:A},{name:"shake",padding:[31,7936,2031616,520093696],bits:d,createMethod:function(t,e){var r=g(t,e,"hex");return r.create=function(r){return new I(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},b(r,g,t,e)}},{name:"cshake",padding:h,bits:d,createMethod:function(t,e){var r=m[t],n=v(t,0,"hex");return n.create=function(n,i,o){return i||o?new I(t,e,n).bytepad([i,o],r):M["shake"+t].create(n)},n.update=function(t,e,r,i){return n.create(e,r,i).update(t)},b(n,v,t,e)}},{name:"kmac",padding:h,bits:d,createMethod:function(t,e){var r=m[t],n=w(t,0,"hex");return n.create=function(n,i,o){return new T(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)},b(n,w,t,e)}}],M={},E=[],k=0;k<_.length;++k)for(var S=_[k],x=S.bits,U=0;U<x.length;++U){var N=S.name+"_"+x[U];if(E.push(N),M[N]=S.createMethod(x[U],S.padding),"sha3"!==S.name){var P=S.name+x[U];E.push(P),M[P]=M[N]}}function I(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 T(t,e,r){I.call(this,t,e,r)}I.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var i,o,s=this.blocks,u=this.byteCount,h=t.length,c=this.blockCount,f=0,d=this.s;f<h;){if(this.reset)for(this.reset=!1,s[0]=this.block,i=1;i<c+1;++i)s[i]=0;if(r)for(i=this.start;f<h&&i<u;++f)s[i>>2]|=t[f]<<l[3&i++];else for(i=this.start;f<h&&i<u;++f)(o=t.charCodeAt(f))<128?s[i>>2]|=o<<l[3&i++]:o<2048?(s[i>>2]|=(192|o>>6)<<l[3&i++],s[i>>2]|=(128|63&o)<<l[3&i++]):o<55296||o>=57344?(s[i>>2]|=(224|o>>12)<<l[3&i++],s[i>>2]|=(128|o>>6&63)<<l[3&i++],s[i>>2]|=(128|63&o)<<l[3&i++]):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++f)),s[i>>2]|=(240|o>>18)<<l[3&i++],s[i>>2]|=(128|o>>12&63)<<l[3&i++],s[i>>2]|=(128|o>>6&63)<<l[3&i++],s[i>>2]|=(128|63&o)<<l[3&i++]);if(this.lastByteIndex=i,i>=u){for(this.start=i-u,this.block=s[c],i=0;i<c;++i)d[i]^=s[i];R(d),this.reset=!0}else this.start=i}return this},I.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},I.prototype.encodeString=function(t){var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}var i=0,o=t.length;if(r)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},I.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},I.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];R(n)}},I.prototype.toString=I.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&&(R(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},I.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&&R(r)}return i&&(u[o]=r[o],t=t.slice(0,a)),t},I.prototype.buffer=I.prototype.arrayBuffer,I.prototype.digest=I.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&&R(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},T.prototype=new I,T.prototype.finalize=function(){return this.encode(this.outputBits,!0),I.prototype.finalize.call(this)};var R=function(t){var e,r,n,i,o,s,a,u,h,l,f,d,p,m,y,g,v,w,b,A,_,M,E,k,S,x,U,N,P,I,T,R,$,C,O,j,B,F,D,L,z,q,V,K,G,H,Z,J,Q,W,Y,X,tt,et,rt,nt,it,ot,st,at,ut,ht,lt;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],h=t[5]^t[15]^t[25]^t[35]^t[45],l=t[6]^t[16]^t[26]^t[36]^t[46],f=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(s<<1|a>>>31),r=(p=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|h>>>31),r=o^(h<<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^(l<<1|f>>>31),r=a^(f<<1|l>>>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^(d<<1|p>>>31),r=h^(p<<1|d>>>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=l^(i<<1|o>>>31),r=f^(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,m=t[0],y=t[1],H=t[11]<<4|t[10]>>>28,Z=t[10]<<4|t[11]>>>28,N=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,q=t[40]<<18|t[41]>>>14,V=t[41]<<18|t[40]>>>14,C=t[2]<<1|t[3]>>>31,O=t[3]<<1|t[2]>>>31,g=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,J=t[22]<<10|t[23]>>>22,Q=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,T=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,lt=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,j=t[14]<<6|t[15]>>>26,B=t[15]<<6|t[14]>>>26,w=t[25]<<11|t[24]>>>21,b=t[24]<<11|t[25]>>>21,W=t[34]<<15|t[35]>>>17,Y=t[35]<<15|t[34]>>>17,R=t[45]<<29|t[44]>>>3,$=t[44]<<29|t[45]>>>3,k=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,F=t[26]<<25|t[27]>>>7,D=t[27]<<25|t[26]>>>7,A=t[36]<<21|t[37]>>>11,_=t[37]<<21|t[36]>>>11,X=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,K=t[8]<<27|t[9]>>>5,G=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,U=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,L=t[38]<<8|t[39]>>>24,z=t[39]<<8|t[38]>>>24,M=t[48]<<14|t[49]>>>18,E=t[49]<<14|t[48]>>>18,t[0]=m^~g&w,t[1]=y^~v&b,t[10]=k^~x&N,t[11]=S^~U&P,t[20]=C^~j&F,t[21]=O^~B&D,t[30]=K^~H&J,t[31]=G^~Z&Q,t[40]=et^~nt&ot,t[41]=rt^~it&st,t[2]=g^~w&A,t[3]=v^~b&_,t[12]=x^~N&I,t[13]=U^~P&T,t[22]=j^~F&L,t[23]=B^~D&z,t[32]=H^~J&W,t[33]=Z^~Q&Y,t[42]=nt^~ot&at,t[43]=it^~st&ut,t[4]=w^~A&M,t[5]=b^~_&E,t[14]=N^~I&R,t[15]=P^~T&$,t[24]=F^~L&q,t[25]=D^~z&V,t[34]=J^~W&X,t[35]=Q^~Y&tt,t[44]=ot^~at&ht,t[45]=st^~ut<,t[6]=A^~M&m,t[7]=_^~E&y,t[16]=I^~R&k,t[17]=T^~$&S,t[26]=L^~q&C,t[27]=z^~V&O,t[36]=W^~X&K,t[37]=Y^~tt&G,t[46]=at^~ht&et,t[47]=ut^~lt&rt,t[8]=M^~m&g,t[9]=E^~y&v,t[18]=R^~k&x,t[19]=$^~S&U,t[28]=q^~C&j,t[29]=V^~O&B,t[38]=X^~K&H,t[39]=tt^~G&Z,t[48]=ht^~et&nt,t[49]=lt^~rt&it,t[0]^=c[n],t[1]^=c[n+1]};if(s)t.exports=M;else for(k=0;k<E.length;++k)n[E[k]]=M[E[k]]}()}));function kr(t){return"0x"+Er.keccak_256(K(t))}const Sr=new B("rlp/5.6.1");function xr(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function Ur(t){return J(function t(e){if(Array.isArray(e)){let r=[];if(e.forEach((function(e){r=r.concat(t(e))})),r.length<=55)return r.unshift(192+r.length),r;const n=xr(r.length);return n.unshift(247+n.length),n.concat(r)}z(e)||Sr.throwArgumentError("RLP object must be BytesLike","object",e);const r=Array.prototype.slice.call(K(e));if(1===r.length&&r[0]<=127)return r;if(r.length<=55)return r.unshift(128+r.length),r;const n=xr(r.length);return n.unshift(183+n.length),n.concat(r)}(t))}const Nr=new B("address/5.6.1");function Pr(t){Z(t,20)||Nr.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=K(kr(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Ir={};for(let t=0;t<10;t++)Ir[String(t)]=String(t);for(let t=0;t<26;t++)Ir[String.fromCharCode(65+t)]=String(10+t);const Tr=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function Rr(t){let e=null;if("string"!=typeof t&&Nr.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Pr(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Nr.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map(t=>Ir[t]).join("");for(;e.length>=Tr;){let t=e.substring(0,Tr);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&Nr.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new ue(r,36).toString(16);e.length<40;)e="0"+e;e=Pr("0x"+e)}else Nr.throwArgumentError("invalid address","address",t);var r;return e}function $r(t){let e=null;try{e=Rr(t.from)}catch(e){Nr.throwArgumentError("missing from address","transaction",t)}return Rr(W(kr(Ur([e,H(K(fe.from(t.nonce).toHexString()))])),12))}class Cr extends We{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){try{Rr(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return Rr(tt(t.readValue().toHexString(),20))}}class Or extends We{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const jr=new B("abi/5.3.1");function Br(t,e,r){let n=null;if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map(e=>{const n=e.localName;return n||jr.throwError("cannot encode object for signature with missing names",B.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[n]&&jr.throwError("cannot encode object for signature with duplicate names",B.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[n]=!0,r[n]})}else jr.throwArgumentError("invalid tuple value","tuple",r);e.length!==n.length&&jr.throwArgumentError("types/value length mismatch","tuple",r);let i=new Ye(t.wordSize),o=new Ye(t.wordSize),s=[];e.forEach((t,e)=>{let r=n[e];if(t.dynamic){let e=o.length;t.encode(o,r);let n=i.writeUpdatableValue();s.push(t=>{n(t+e)})}else t.encode(i,r)}),s.forEach(t=>{t(i.length)});let a=t.appendWriter(i);return a+=t.appendWriter(o),a}function Fr(t,e){let r=[],n=t.subReader(0);e.forEach(e=>{let i=null;if(e.dynamic){let r=t.readValue(),o=n.subReader(r.toNumber());try{i=e.decode(o)}catch(t){if(t.code===B.errors.BUFFER_OVERRUN)throw t;i=t,i.baseType=e.name,i.name=e.localName,i.type=e.type}}else try{i=e.decode(t)}catch(t){if(t.code===B.errors.BUFFER_OVERRUN)throw t;i=t,i.baseType=e.name,i.name=e.localName,i.type=e.type}null!=i&&r.push(i)});const i=e.reduce((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t},{});e.forEach((t,e)=>{let n=t.localName;if(!n||1!==i[n])return;if("length"===n&&(n="_length"),null!=r[n])return;const o=r[e];o instanceof Error?Object.defineProperty(r,n,{get:()=>{throw o}}):r[n]=o});for(let t=0;t<r.length;t++){const e=r[t];e instanceof Error&&Object.defineProperty(r,t,{get:()=>{throw e}})}return Object.freeze(r)}class Dr extends We{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),jr.checkArgumentCount(e.length,r,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t<e.length;t++)n.push(this.coder);return Br(t,n,e)}decode(t){let e=this.length;-1===e&&(e=t.readValue().toNumber(),32*e>t._data.length&&jr.throwError("insufficient data length",B.errors.BUFFER_OVERRUN,{length:t._data.length,count:e}));let r=[];for(let t=0;t<e;t++)r.push(new Or(this.coder));return t.coerce(this.name,Fr(t,r))}}class Lr extends We{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){return t.writeValue(e?1:0)}decode(t){return t.coerce(this.type,!t.readValue().isZero())}}class zr extends We{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=K(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readValue().toNumber(),!0)}}class qr extends zr{constructor(t){super("bytes",t)}decode(t){return t.coerce(this.name,J(super.decode(t)))}}class Vr extends We{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),this.size=t}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=K(e);return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return t.coerce(this.name,J(t.readBytes(this.size)))}}class Kr extends We{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes([])}decode(t){return t.readBytes(0),t.coerce(this.name,null)}}const Gr=fe.from(-1),Hr=fe.from(0),Zr=fe.from(1),Jr=fe.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Qr extends We{constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),this.size=t,this.signed=e}defaultValue(){return 0}encode(t,e){let r=fe.from(e),n=Jr.mask(8*t.wordSize);if(this.signed){let t=n.mask(8*this.size-1);(r.gt(t)||r.lt(t.add(Zr).mul(Gr)))&&this._throwError("value out-of-bounds",e)}else(r.lt(Hr)||r.gt(n.mask(8*this.size)))&&this._throwError("value out-of-bounds",e);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*t.wordSize)),t.writeValue(r)}decode(t){let e=t.readValue().mask(8*this.size);return this.signed&&(e=e.fromTwos(8*this.size)),t.coerce(this.name,e)}}const Wr=new B("strings/5.6.1");var Yr,Xr;function tn(t,e,r,n,i){if(t===Xr.BAD_PREFIX||t===Xr.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Xr.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Yr||(Yr={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Xr||(Xr={}));const en=Object.freeze({error:function(t,e,r,n,i){return Wr.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:tn,replace:function(t,e,r,n,i){return t===Xr.OVERLONG?(n.push(i),0):(n.push(65533),tn(t,e,r))}});function rn(t,e){null==e&&(e=en.error),t=K(t);const r=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=e(128==(192&i)?Xr.UNEXPECTED_CONTINUE:Xr.BAD_PREFIX,n-1,t,r);continue}o=3,s=65535}if(n-1+o>=t.length){n+=e(Xr.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=e(Xr.MISSING_CONTINUE,n,t,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=e(Xr.OUT_OF_RANGE,n-1-o,t,r,a):a>=55296&&a<=57343?n+=e(Xr.UTF16_SURROGATE,n-1-o,t,r,a):a<=s?n+=e(Xr.OVERLONG,n-1-o,t,r,a):r.push(a))}return r}function nn(t,e=Yr.current){e!=Yr.current&&(Wr.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return K(r)}function on(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function sn(t,e){return on(rn(t,e))}function an(t,e=Yr.current){return rn(nn(t,e))}function un(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function hn(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let n=e+parseInt(r[0],16);return e=parseInt(r[1],16),{l:n,h:e}})}function ln(t,e){let r=0;for(let n=0;n<e.length;n++){let i=e[n];if(r+=i.l,t>=r&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}const cn=hn("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),fn="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),dn=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],pn=un("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),mn=un("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),yn=un("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r<t.length;r+=4)e.push(parseInt(t.substring(r,r+4),16));return e})),gn=hn("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function vn(t){if(t.match(/^[a-z0-9-]*$/i)&&t.length<=59)return t.toLowerCase();let e=an(t);var r;r=e.map(t=>{if(fn.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=ln(t,dn);if(e)return[t+e.s];let r=pn[t];if(r)return r;let n=mn[t];return n?[t+n[0]]:yn[t]||null}(t);return e||[t]}),e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[]),e=an(on(e),Yr.NFKC),e.forEach(t=>{if(ln(t,gn))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(ln(t,cn))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=on(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class wn extends zr{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,nn(e))}decode(t){return sn(super.decode(t))}}class bn extends We{constructor(t,e){let r=!1;const n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)});super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}defaultValue(){const t=[];this.coders.forEach(e=>{t.push(e.defaultValue())});const e=this.coders.reduce((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t},{});return this.coders.forEach((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))}),Object.freeze(t)}encode(t,e){return Br(t,this.coders,e)}decode(t){return t.coerce(this.name,Fr(t,this.coders))}}const An=new B("abi/5.3.1"),_n=new RegExp(/^bytes([0-9]*)$/),Mn=new RegExp(/^(u?int)([0-9]*)$/);class En{constructor(t){An.checkNew(new.target,En),we(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Cr(t.name);case"bool":return new Lr(t.name);case"string":return new wn(t.name);case"bytes":return new qr(t.name);case"array":return new Dr(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new bn((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new Kr(t.name)}let e=t.type.match(Mn);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&An.throwArgumentError("invalid "+e[1]+" bit length","param",t),new Qr(r/8,"int"===e[1],t.name)}if(e=t.type.match(_n),e){let r=parseInt(e[1]);return(0===r||r>32)&&An.throwArgumentError("invalid bytes length","param",t),new Vr(r,t.name)}return An.throwArgumentError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t,e){return new Xe(t,this._getWordSize(),this.coerceFunc,e)}_getWriter(){return new Ye(this._getWordSize())}getDefaultValue(t){const e=t.map(t=>this._getCoder(Ce.from(t)));return new bn(e,"_").defaultValue()}encode(t,e){t.length!==e.length&&An.throwError("types/values length mismatch",B.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});const r=t.map(t=>this._getCoder(Ce.from(t))),n=new bn(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e,r){const n=t.map(t=>this._getCoder(Ce.from(t)));return new bn(n,"_").decode(this._getReader(K(e),r))}}const kn=new En;function Sn(t){return kr(nn(t))}const xn=new B("hash/5.6.1"),Un=new Uint8Array(32);Un.fill(0);const Nn=new RegExp("^((.*)\\.)?([^.]+)$");function Pn(t){"string"!=typeof t&&xn.throwArgumentError("invalid ENS name; not a string","name",t);let e=t,r=Un;for(;e.length;){const n=e.match(Nn);null!=n&&""!==n[2]||xn.throwArgumentError("invalid ENS address; missing component","name",t);r=kr(G([r,kr(nn(vn(n[3])))])),e=n[2]||""}return J(r)}var In=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const Tn=new B("hash/5.6.1"),Rn=new Uint8Array(32);Rn.fill(0);const $n=fe.from(-1),Cn=fe.from(0),On=fe.from(1),jn=fe.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const Bn=tt(On.toHexString(),32),Fn=tt(Cn.toHexString(),32),Dn={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Ln=["name","version","chainId","verifyingContract","salt"];function zn(t){return function(e){return"string"!=typeof e&&Tn.throwArgumentError("invalid domain value for "+JSON.stringify(t),"domain."+t,e),e}}const qn={name:zn("name"),version:zn("version"),chainId:function(t){try{return fe.from(t).toString()}catch(t){}return Tn.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Rr(t).toLowerCase()}catch(t){}return Tn.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=K(t);if(32!==e.length)throw new Error("bad length");return J(e)}catch(t){}return Tn.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function Vn(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],n=parseInt(e[2]||"256");(n%8!=0||n>256||e[2]&&e[2]!==String(n))&&Tn.throwArgumentError("invalid numeric width","type",t);const i=jn.mask(r?n-1:n),o=r?i.add(On).mul($n):Cn;return function(e){const r=fe.from(e);return(r.lt(o)||r.gt(i))&&Tn.throwArgumentError("value out-of-bounds for "+t,"value",e),tt(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&Tn.throwArgumentError("invalid bytes width","type",t),function(e){return K(e).length!==r&&Tn.throwArgumentError("invalid length for "+t,"value",e),function(t){const e=K(t),r=e.length%32;return r?Y([e,Rn.slice(r)]):J(e)}(e)}}}switch(t){case"address":return function(t){return tt(Rr(t),32)};case"bool":return function(t){return t?Bn:Fn};case"bytes":return function(t){return kr(t)};case"string":return function(t){return Sn(t)}}return null}function Kn(t,e){return`${t}(${e.map(({name:t,type:e})=>e+" "+t).join(",")})`}class Gn{constructor(t){we(this,"types",Object.freeze(ke(t))),we(this,"_encoderCache",{}),we(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach(t=>{e[t]={},r[t]=[],n[t]={}});for(const n in t){const i={};t[n].forEach(o=>{i[o.name]&&Tn.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",t),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&Tn.throwArgumentError("circular type reference to "+JSON.stringify(s),"types",t);Vn(s)||(r[s]||Tn.throwArgumentError("unknown type "+JSON.stringify(s),"types",t),r[s].push(n),e[n][s]=!0)})}const i=Object.keys(r).filter(t=>0===r[t].length);0===i.length?Tn.throwArgumentError("missing primary type","types",t):i.length>1&&Tn.throwArgumentError("ambiguous primary types or unused types: "+i.map(t=>JSON.stringify(t)).join(", "),"types",t),we(this,"primaryType",i[0]),function i(o,s){s[o]&&Tn.throwArgumentError("circular type reference to "+JSON.stringify(o),"types",t),s[o]=!0,Object.keys(e[o]).forEach(t=>{r[t]&&(i(t,s),Object.keys(s).forEach(e=>{n[e][t]=!0}))}),delete s[o]}(this.primaryType,{});for(const e in n){const r=Object.keys(n[e]);r.sort(),this._types[e]=Kn(e,t[e])+r.map(e=>Kn(e,t[e])).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=Vn(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),n=parseInt(e[3]);return e=>{n>=0&&e.length!==n&&Tn.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let i=e.map(r);return this._types[t]&&(i=i.map(kr)),kr(Y(i))}}const r=this.types[t];if(r){const e=Sn(this._types[t]);return t=>{const n=r.map(({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this._types[r]?kr(n):n});return n.unshift(e),Y(n)}}return Tn.throwArgumentError("unknown type: "+t,"type",t)}encodeType(t){const e=this._types[t];return e||Tn.throwArgumentError("unknown type: "+JSON.stringify(t),"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return kr(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(Vn(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],i=parseInt(n[3]);return i>=0&&e.length!==i&&Tn.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map(e=>this._visit(t,e,r))}const i=this.types[t];return i?i.reduce((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t),{}):Tn.throwArgumentError("unknown type: "+t,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Gn(t)}static getPrimaryType(t){return Gn.from(t).primaryType}static hashStruct(t,e,r){return Gn.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=Dn[r];n||Tn.throwArgumentError("invalid typed-data domain key: "+JSON.stringify(r),"domain",t),e.push({name:r,type:n})}return e.sort((t,e)=>Ln.indexOf(t.name)-Ln.indexOf(e.name)),Gn.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return Y(["0x1901",Gn.hashDomain(t),Gn.from(e).hash(r)])}static hash(t,e,r){return kr(Gn.encode(t,e,r))}static resolveNames(t,e,r,n){return In(this,void 0,void 0,(function*(){t=_e(t);const i={};t.verifyingContract&&!Z(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=Gn.from(e);o.visit(r,(t,e)=>("address"!==t||Z(e,20)||(i[e]="0x"),e));for(const t in i)i[t]=yield n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=o.visit(r,(t,e)=>"address"===t&&i[e]?i[e]:e),{domain:t,value:r}}))}static getPayload(t,e,r){Gn.hashDomain(t);const n={},i=[];Ln.forEach(e=>{const r=t[e];null!=r&&(n[e]=qn[e](r),i.push({name:e,type:Dn[e]}))});const o=Gn.from(e),s=_e(e);return s.EIP712Domain?Tn.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,(t,e)=>{if(t.match(/^bytes(\d*)/))return J(K(e));if(t.match(/^u?int/))return fe.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&Tn.throwArgumentError("invalid string","value",e),e}return Tn.throwArgumentError("unsupported type","type",t)})}}}const Hn=new B("abi/5.3.1");class Zn extends Se{}class Jn extends Se{}class Qn extends Se{static isIndexed(t){return!(!t||!t._isIndexed)}}const Wn={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function Yn(t,e){const r=new Error("deferred error during ABI decoding triggered accessing "+t);return r.error=e,r}class Xn{constructor(t){Hn.checkNew(new.target,Xn);let e=[];e="string"==typeof t?JSON.parse(t):t,we(this,"fragments",e.map(t=>je.from(t)).filter(t=>null!=t)),we(this,"_abiCoder",be(new.target,"getAbiCoder")()),we(this,"functions",{}),we(this,"errors",{}),we(this,"events",{}),we(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void Hn.warn("duplicate definition - constructor"):void we(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;case"error":e=this.errors;break;default:return}let r=t.format();e[r]?Hn.warn("duplicate definition - "+r):e[r]=t}),this.deploy||we(this,"deploy",ze.from({payable:!1,type:"constructor"})),we(this,"_isInterface",!0)}format(t){t||(t=Re.full),t===Re.sighash&&Hn.throwArgumentError("interface does not support formatting sighash","format",t);const e=this.fragments.map(e=>e.format(t));return t===Re.json?JSON.stringify(e.map(t=>JSON.parse(t))):e}static getAbiCoder(){return kn}static getAddress(t){return Rr(t)}static getSighash(t){return W(Sn(t.format()),0,4)}static getEventTopic(t){return Sn(t.format())}getFunction(t){if(Z(t)){for(const e in this.functions)if(t===this.getSighash(e))return this.functions[e];Hn.throwArgumentError("no matching function","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.functions).filter(t=>t.split("(")[0]===e);return 0===r.length?Hn.throwArgumentError("no matching function","name",e):r.length>1&&Hn.throwArgumentError("multiple matching functions","name",e),this.functions[r[0]]}const e=this.functions[qe.fromString(t).format()];return e||Hn.throwArgumentError("no matching function","signature",t),e}getEvent(t){if(Z(t)){const e=t.toLowerCase();for(const t in this.events)if(e===this.getEventTopic(t))return this.events[t];Hn.throwArgumentError("no matching event","topichash",e)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.events).filter(t=>t.split("(")[0]===e);return 0===r.length?Hn.throwArgumentError("no matching event","name",e):r.length>1&&Hn.throwArgumentError("multiple matching events","name",e),this.events[r[0]]}const e=this.events[Be.fromString(t).format()];return e||Hn.throwArgumentError("no matching event","signature",t),e}getError(t){if(Z(t)){const e=be(this.constructor,"getSighash");for(const r in this.errors){if(t===e(this.errors[r]))return this.errors[r]}Hn.throwArgumentError("no matching error","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.errors).filter(t=>t.split("(")[0]===e);return 0===r.length?Hn.throwArgumentError("no matching error","name",e):r.length>1&&Hn.throwArgumentError("multiple matching errors","name",e),this.errors[r[0]]}const e=this.errors[qe.fromString(t).format()];return e||Hn.throwArgumentError("no matching error","signature",t),e}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),be(this.constructor,"getSighash")(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),be(this.constructor,"getEventTopic")(t)}_decodeParams(t,e){return this._abiCoder.decode(t,e)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeFunctionData(t,e){"string"==typeof t&&(t=this.getFunction(t));const r=K(e);return J(r.slice(0,4))!==this.getSighash(t)&&Hn.throwArgumentError(`data signature does not match function ${t.name}.`,"data",J(r)),this._decodeParams(t.inputs,r.slice(4))}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),J(G([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=K(e),n=null,i=null,o=null,s=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:{const t=J(r.slice(0,4)),e=Wn[t];if(e)i=this._abiCoder.decode(e.inputs,r.slice(4)),o=e.name,s=e.signature,e.reason&&(n=i[0]);else try{const e=this.getError(t);i=this._abiCoder.decode(e.inputs,r.slice(4)),o=e.name,s=e.format()}catch(t){console.log(t)}break}}return Hn.throwError("call revert exception",B.errors.CALL_EXCEPTION,{method:t.format(),errorArgs:i,errorName:o,errorSignature:s,reason:n})}encodeFunctionResult(t,e){return"string"==typeof t&&(t=this.getFunction(t)),J(this._abiCoder.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&Hn.throwError("too many arguments for "+t.format(),B.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];t.anonymous||r.push(this.getEventTopic(t));const n=(t,e)=>"string"===t.type?Sn(e):"bytes"===t.type?kr(J(e)):("address"===t.type&&this._abiCoder.encode(["address"],[e]),tt(J(e),32));for(e.forEach((e,i)=>{let o=t.inputs[i];o.indexed?null==e?r.push(null):"array"===o.baseType||"tuple"===o.baseType?Hn.throwArgumentError("filtering with tuples or arrays not supported","contract."+o.name,e):Array.isArray(e)?r.push(e.map(t=>n(o,t))):r.push(n(o,e)):null!=e&&Hn.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+o.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){"string"==typeof t&&(t=this.getEvent(t));const r=[],n=[],i=[];return t.anonymous||r.push(this.getEventTopic(t)),e.length!==t.inputs.length&&Hn.throwArgumentError("event arguments/values mismatch","values",e),t.inputs.forEach((t,o)=>{const s=e[o];if(t.indexed)if("string"===t.type)r.push(Sn(s));else if("bytes"===t.type)r.push(kr(s));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(this._abiCoder.encode([t.type],[s]))}else n.push(t),i.push(s)}),{data:this._abiCoder.encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);Z(r[0],32)&&r[0].toLowerCase()===e||Hn.throwError("fragment/topic mismatch",B.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],o=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Ce.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))});let s=null!=r?this._abiCoder.decode(n,G(r)):null,a=this._abiCoder.decode(i,e,!0),u=[],h=0,l=0;t.inputs.forEach((t,e)=>{if(t.indexed)if(null==s)u[e]=new Qn({_isIndexed:!0,hash:null});else if(o[e])u[e]=new Qn({_isIndexed:!0,hash:s[l++]});else try{u[e]=s[l++]}catch(t){u[e]=t}else try{u[e]=a[h++]}catch(t){u[e]=t}if(t.name&&null==u[t.name]){const r=u[e];r instanceof Error?Object.defineProperty(u,t.name,{get:()=>{throw Yn("property "+JSON.stringify(t.name),r)}}):u[t.name]=r}});for(let t=0;t<u.length;t++){const e=u[t];e instanceof Error&&Object.defineProperty(u,t,{get:()=>{throw Yn("index "+t,e)}})}return Object.freeze(u)}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new Jn({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:fe.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new Zn({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),args:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}const ti=new B("abstract-provider/5.3.0");class ei extends Se{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class ri{constructor(){ti.checkAbstract(new.target,ri),we(this,"_isProvider",!0)}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}static isProvider(t){return!(!t||!t._isProvider)}}var ni=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const ii=new B("abstract-signer/5.6.2"),oi=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],si=[B.errors.INSUFFICIENT_FUNDS,B.errors.NONCE_EXPIRED,B.errors.REPLACEMENT_UNDERPRICED];class ai{constructor(){ii.checkAbstract(new.target,ai),we(this,"_isSigner",!0)}getBalance(t){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)}))}getTransactionCount(t){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)}))}estimateGas(t){return ni(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const e=yield Ae(this.checkTransaction(t));return yield this.provider.estimateGas(e)}))}call(t,e){return ni(this,void 0,void 0,(function*(){this._checkProvider("call");const r=yield Ae(this.checkTransaction(t));return yield this.provider.call(r,e)}))}sendTransaction(t){return ni(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const e=yield this.populateTransaction(t),r=yield this.signTransaction(e);return yield this.provider.sendTransaction(r)}))}getChainId(){return ni(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(t){return ni(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)}))}checkTransaction(t){for(const e in t)-1===oi.indexOf(e)&&ii.throwArgumentError("invalid transaction key: "+e,"transaction",t);const e=_e(t);return null==e.from?e.from=this.getAddress():e.from=Promise.all([Promise.resolve(e.from),this.getAddress()]).then(e=>(e[0].toLowerCase()!==e[1].toLowerCase()&&ii.throwArgumentError("from address mismatch","transaction",t),e[0])),e}populateTransaction(t){return ni(this,void 0,void 0,(function*(){const e=yield Ae(this.checkTransaction(t));null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>ni(this,void 0,void 0,(function*(){if(null==t)return null;const e=yield this.resolveName(t);return null==e&&ii.throwArgumentError("provided ENS name resolves to null","tx.to",t),e}))),e.to.catch(t=>{}));const r=null!=e.maxFeePerGas||null!=e.maxPriorityFeePerGas;if(null==e.gasPrice||2!==e.type&&!r?0!==e.type&&1!==e.type||!r||ii.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t):ii.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t),2!==e.type&&null!=e.type||null==e.maxFeePerGas||null==e.maxPriorityFeePerGas)if(0===e.type||1===e.type)null==e.gasPrice&&(e.gasPrice=this.getGasPrice());else{const t=yield this.getFeeData();if(null==e.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(e.type=2,null!=e.gasPrice){const t=e.gasPrice;delete e.gasPrice,e.maxFeePerGas=t,e.maxPriorityFeePerGas=t}else null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(r&&ii.throwError("network does not support EIP-1559",B.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==e.gasPrice&&(e.gasPrice=t.gasPrice),e.type=0):ii.throwError("failed to get consistent fee data",B.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===e.type&&(null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else e.type=2;return null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{if(si.indexOf(t.code)>=0)throw t;return ii.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",B.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,tx:e})})),null==e.chainId?e.chainId=this.getChainId():e.chainId=Promise.all([Promise.resolve(e.chainId),this.getChainId()]).then(e=>(0!==e[1]&&e[0]!==e[1]&&ii.throwArgumentError("chainId address mismatch","transaction",t),e[0])),yield Ae(e)}))}_checkProvider(t){this.provider||ii.throwError("missing provider",B.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class ui extends ai{constructor(t,e){super(),we(this,"address",t),we(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{ii.throwError(t,B.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(t,e,r){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(t){return new ui(this.address,t)}}var hi=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const li=new B("contracts/5.0.3");function ci(t,e){return hi(this,void 0,void 0,(function*(){const r=yield e;try{return Rr(r)}catch(t){}return t||li.throwError("a provider or signer is needed to resolve ENS names",B.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"}),yield t.resolveName(r)}))}function fi(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>fi(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return ci(t,e);if("tuple"===r.type)return fi(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>fi(t,e,r.arrayChildren)))}return Promise.resolve(e)}function di(t,e,r){return hi(this,void 0,void 0,(function*(){let n={};r.length===e.inputs.length+1&&"object"==typeof r[r.length-1]&&(n=_e(r.pop())),li.checkArgumentCount(r.length,e.inputs.length,"passed to contract"),t.signer?n.from?n.from=Ae({override:ci(t.signer,n.from),signer:t.signer.getAddress()}).then(t=>hi(this,void 0,void 0,(function*(){return Rr(t.signer)!==t.override&&li.throwError("Contract with a Signer cannot override from",B.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),t.override}))):n.from=t.signer.getAddress():n.from&&(n.from=ci(t.provider,n.from));const i=yield Ae({args:fi(t.signer||t.provider,r,e.inputs),address:t.resolvedAddress,overrides:Ae(n)||{}}),o={data:t.interface.encodeFunctionData(e,i.args),to:i.address},s=i.overrides;if(null!=s.nonce&&(o.nonce=fe.from(s.nonce).toNumber()),null!=s.gasLimit&&(o.gasLimit=fe.from(s.gasLimit)),null!=s.gasPrice&&(o.gasPrice=fe.from(s.gasPrice)),null!=s.from&&(o.from=s.from),null==o.gasLimit&&null!=e.gas&&(o.gasLimit=fe.from(e.gas).add(21e3)),s.value){const t=fe.from(s.value);t.isZero()||e.payable||li.throwError("non-payable method cannot override value",B.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:n.value}),o.value=t}delete n.nonce,delete n.gasLimit,delete n.gasPrice,delete n.from,delete n.value;const a=Object.keys(n).filter(t=>null!=n[t]);return a.length&&li.throwError("cannot override "+a.map(t=>JSON.stringify(t)).join(","),B.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:a}),o}))}function pi(t,e,r){const n=t.signer||t.provider;return function(...i){return hi(this,void 0,void 0,(function*(){let o=void 0;if(i.length===e.inputs.length+1&&"object"==typeof i[i.length-1]){const t=_e(i.pop());null!=t.blockTag&&(o=yield t.blockTag),delete t.blockTag,i.push(t)}null!=t.deployTransaction&&(yield t._deployed(o));const s=yield di(t,e,i),a=yield n.call(s,o);try{let n=t.interface.decodeFunctionResult(e,a);return r&&1===e.outputs.length&&(n=n[0]),n}catch(e){throw e.code===B.errors.CALL_EXCEPTION&&(e.address=t.address,e.args=i,e.transaction=s),e}}))}}function mi(t,e,r){return e.constant?pi(t,e,r):function(t,e){return function(...r){return hi(this,void 0,void 0,(function*(){t.signer||li.throwError("sending a transaction requires a signer",B.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),null!=t.deployTransaction&&(yield t._deployed());const n=yield di(t,e,r),i=yield t.signer.sendTransaction(n),o=i.wait.bind(i);return i.wait=e=>o(e).then(e=>(e.events=e.logs.map(r=>{let n=ke(r),i=null;try{i=t.interface.parseLog(r)}catch(t){}return i&&(n.args=i.args,n.decode=(e,r)=>t.interface.decodeEventLog(i.eventFragment,e,r),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),i}))}}(t,e)}function yi(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.map(t=>Array.isArray(t)?t.join("|"):t).join(":"):""):"*"}class gi{constructor(t,e){we(this,"tag",t),we(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){const e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{const r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}getEmit(t){return[t]}}class vi extends gi{constructor(){super("error",null)}}class wi extends gi{constructor(t,e,r,n){const i={address:t};let o=e.getEventTopic(r);n?(o!==n[0]&&li.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[o],super(yi(i),i),we(this,"address",t),we(this,"interface",e),we(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e);try{t.args=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}catch(e){t.args=null,t.decodeError=e}}getEmit(t){const e=function(t){const e=[],r=function(t,n){if(Array.isArray(n))for(let i in n){const o=t.slice();o.push(i);try{r(o,n[i])}catch(t){e.push({path:o,error:t})}}};return r([],t),e}(t.args);if(e.length)throw e[0].error;const r=(t.args||[]).slice();return r.push(t),r}}class bi extends gi{constructor(t,e){super("*",{address:t}),we(this,"address",t),we(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);try{const e=this.interface.parseLog(t);t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.args=e.args}catch(t){}}}class Ai{constructor(t,e,r){li.checkNew(new.target,Ai),we(this,"interface",be(new.target,"getInterface")(e)),null==r?(we(this,"provider",null),we(this,"signer",null)):ai.isSigner(r)?(we(this,"provider",r.provider||null),we(this,"signer",r)):ri.isProvider(r)?(we(this,"provider",r),we(this,"signer",null)):li.throwArgumentError("invalid signer or provider","signerOrProvider",r),we(this,"callStatic",{}),we(this,"estimateGas",{}),we(this,"functions",{}),we(this,"populateTransaction",{}),we(this,"filters",{});{const t={};Object.keys(this.interface.events).forEach(e=>{const r=this.interface.events[e];we(this.filters,e,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(r,t)})),t[r.name]||(t[r.name]=[]),t[r.name].push(e)}),Object.keys(t).forEach(e=>{const r=t[e];1===r.length?we(this.filters,e,this.filters[r[0]]):li.warn(`Duplicate definition of ${e} (${r.join(", ")})`)})}if(we(this,"_runningEvents",{}),we(this,"_wrappedEmits",{}),we(this,"address",t),this.provider)we(this,"resolvedAddress",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{we(this,"resolvedAddress",Promise.resolve(Rr(t)))}catch(t){li.throwError("provider is required to use ENS name as contract address",B.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}const n={},i={};Object.keys(this.interface.functions).forEach(t=>{const e=this.interface.functions[t];if(i[t])li.warn("Duplicate ABI entry for "+JSON.stringify(name));else{i[t]=!0;{const r=e.name;n[r]||(n[r]=[]),n[r].push(t)}null==this[t]&&we(this,t,mi(this,e,!0)),null==this.functions[t]&&we(this.functions,t,mi(this,e,!1)),null==this.callStatic[t]&&we(this.callStatic,t,pi(this,e,!0)),null==this.populateTransaction[t]&&we(this.populateTransaction,t,function(t,e){return function(...r){return hi(this,void 0,void 0,(function*(){return di(t,e,r)}))}}(this,e)),null==this.estimateGas[t]&&we(this.estimateGas,t,function(t,e){const r=t.signer||t.provider;return function(...n){return hi(this,void 0,void 0,(function*(){r||li.throwError("estimate require a provider or signer",B.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const i=yield di(t,e,n);return yield r.estimateGas(i)}))}}(this,e))}}),Object.keys(n).forEach(t=>{const e=n[t];if(e.length>1)return;const r=e[0];null==this[t]&&we(this,t,this[r]),null==this.functions[t]&&we(this.functions,t,this.functions[r]),null==this.callStatic[t]&&we(this.callStatic,t,this.callStatic[r]),null==this.populateTransaction[t]&&we(this.populateTransaction,t,this.populateTransaction[r]),null==this.estimateGas[t]&&we(this.estimateGas,t,this.estimateGas[r])})}static getContractAddress(t){return $r(t)}static getInterface(t){return Xn.isInterface(t)?t:new Xn(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&li.throwError("contract not deployed",B.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||li.throwError("sending a transactions require a signer",B.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const e=_e(t||{});return["from","to"].forEach((function(t){null!=e[t]&&li.throwError("cannot override "+t,B.errors.UNSUPPORTED_OPERATION,{operation:t})})),e.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new ui(t,this.provider));const e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&we(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return Qn.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new vi);if("event"===t)return this._normalizeRunningEvent(new gi("event",null));if("*"===t)return this._normalizeRunningEvent(new bi(this.address,this.interface));const e=this.interface.getEvent(t);return this._normalizeRunningEvent(new wi(this.address,this.interface,e))}if(t.topics&&t.topics.length>0){try{const e=t.topics[0];if("string"!=typeof e)throw new Error("invalid topic");const r=this.interface.getEvent(e);return this._normalizeRunningEvent(new wi(this.address,this.interface,r,t.topics))}catch(t){}const e={address:this.address,topics:t.topics};return this._normalizeRunningEvent(new gi(yi(e),e))}return this._normalizeRunningEvent(new bi(this.address,this.interface))}_checkRunningEvents(t){if(0===t.listenerCount()){delete this._runningEvents[t.tag];const e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}}_wrapEvent(t,e,r){const n=ke(e);return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),t.prepareEvent(n),n}_addEventListener(t,e,r){if(this.provider||li.throwError("events require a provider or a signer with a provider",B.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){const r=r=>{let n=this._wrapEvent(t,r,e);if(null==n.decodeError)try{const e=t.getEmit(n);this.emit(t.filter,...e)}catch(t){n.decodeError=t.error}null!=t.filter&&this.emit("event",n),null!=n.decodeError&&this.emit("error",n.decodeError,n)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){const n=this._getRunningEvent(t),i=_e(n.filter);return"string"==typeof e&&Z(e,32)?(null!=r&&li.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockHash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;const r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){const t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(const t in this._runningEvents){const e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}const e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;const r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}
|
|
15
|
+
***************************************************************************** */var t=function(){return(t=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function e(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function r(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function n(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function i(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(n(arguments[e]));return t}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function a(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})})),e}function u(t){var e={exports:{}};return t(e,e.exports),e.exports}var h=u((function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:o);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function m(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?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(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=d(this);if(t)return t;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(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(m)}),this.text=function(){var t,e,r,n=d(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=p(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,e){t=h(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},f.prototype.delete=function(t){delete this.map[h(t)]},f.prototype.get=function(t){return t=h(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(h(t))},f.prototype.set=function(t,e){this.map[h(t)]=l(e)},f.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},f.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),c(t)},f.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),c(t)},f.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),c(t)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var r,n,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function A(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},g.call(w.prototype),g.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},A.error=function(){var t=new A(null,{status:0,statusText:""});return t.type="error",t};var _=[301,302,303,307,308];A.redirect=function(t,e){if(-1===_.indexOf(e))throw new RangeError("Invalid status code");return new A(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function M(t,r){return new Promise((function(n,o){var s=new w(t,r);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new A(i,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}M.polyfill=!0,t.fetch||(t.fetch=M,t.Headers=f,t.Request=w,t.Response=A),e.Headers=f,e.Request=w,e.Response=A,e.fetch=M}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e})),l={Space:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"settings",type:"string"}]},c={Proposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"type",type:"string"},{name:"title",type:"string"},{name:"body",type:"string"},{name:"discussion",type:"string"},{name:"choices",type:"string[]"},{name:"start",type:"uint64"},{name:"end",type:"uint64"},{name:"snapshot",type:"uint64"},{name:"plugins",type:"string"}]},f={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"}]},d={CancelProposal:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"}]},p={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32"}]},m={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"uint32[]"}]},y={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"string"},{name:"choice",type:"string"}]},g={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32"}]},v={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"uint32[]"}]},w={Vote:[{name:"from",type:"address"},{name:"space",type:"string"},{name:"timestamp",type:"uint64"},{name:"proposal",type:"bytes32"},{name:"choice",type:"string"}]},b={Follow:[{name:"from",type:"address"},{name:"space",type:"string"}]},A={Unfollow:[{name:"from",type:"address"},{name:"space",type:"string"}]},_={Subscribe:[{name:"from",type:"address"},{name:"space",type:"string"}]},M={Unsubscribe:[{name:"from",type:"address"},{name:"space",type:"string"}]},E={Profile:[{name:"from",type:"address"},{name:"timestamp",type:"uint64"},{name:"profile",type:"string"}]},k={Alias:[{name:"from",type:"address"},{name:"alias",type:"address"}]},S=["https://hub.snapshot.org","https://testnet.snapshot.org"],x={name:"snapshot",version:"0.1.4"},U=function(){function t(t){void 0===t&&(t=S[0]),this.address=t}return t.prototype.sign=function(t,n,i,o){return e(this,void 0,void 0,(function(){var e,s,a;return r(this,(function(r){switch(r.label){case 0:return e=(null==t?void 0:t.getSigner)?t.getSigner():t,i.from||(i.from=n),i.timestamp||(i.timestamp=parseInt((Date.now()/1e3).toFixed())),s={domain:x,types:o,message:i},[4,e._signTypedData(x,s.types,i)];case 1:return a=r.sent(),console.log("Sign",{address:n,sig:a,data:s}),[4,this.send({address:n,sig:a,data:s})];case 2:return[2,r.sent()]}}))}))},t.prototype.send=function(t){return e(this,void 0,void 0,(function(){var e,n;return r(this,(function(r){return e=this.address+"/api/msg",n={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)},[2,new Promise((function(t,r){h(e,n).then((function(e){if(e.ok)return t(e.json());throw e})).catch((function(t){return t.json().then((function(t){return r(t)}))}))}))]}))}))},t.prototype.space=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,l)];case 1:return[2,e.sent()]}}))}))},t.prototype.proposal=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return i.discussion||(i.discussion=""),[4,this.sign(t,n,i,c)];case 1:return[2,e.sent()]}}))}))},t.prototype.cancelProposal=function(t,n,i){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return e=i.proposal.startsWith("0x"),[4,this.sign(t,n,i,e?d:f)];case 1:return[2,r.sent()]}}))}))},t.prototype.vote=function(t,n,i){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e=i.proposal.startsWith("0x"),o=e?g:p,["approval","ranked-choice"].includes(i.type)&&(o=e?v:m),["quadratic","weighted"].includes(i.type)&&(o=e?w:y,i.choice=JSON.stringify(i.choice)),"shutter"===(null==i?void 0:i.privacy)&&(o=e?w:y),delete i.privacy,delete i.type,[4,this.sign(t,n,i,o)];case 1:return[2,r.sent()]}}))}))},t.prototype.follow=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,b)];case 1:return[2,e.sent()]}}))}))},t.prototype.unfollow=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,A)];case 1:return[2,e.sent()]}}))}))},t.prototype.subscribe=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,_)];case 1:return[2,e.sent()]}}))}))},t.prototype.unsubscribe=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,M)];case 1:return[2,e.sent()]}}))}))},t.prototype.profile=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,E)];case 1:return[2,e.sent()]}}))}))},t.prototype.alias=function(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this.sign(t,n,i,k)];case 1:return[2,e.sent()]}}))}))},t}();let N=!1,P=!1;const I={debug:1,default:2,info:2,warning:3,error:4,off:5};let T=I.default,R=null;const $=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(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}();var C,O;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(C||(C={})),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"}(O||(O={}));const j="0123456789abcdef";class B{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==I[r]&&this.throwArgumentError("invalid log level name","logLevel",t),T>I[r]||console.log.apply(console,e)}debug(...t){this._log(B.levels.DEBUG,t)}info(...t){this._log(B.levels.INFO,t)}warn(...t){this._log(B.levels.WARNING,t)}makeError(t,e,r){if(P)return this.makeError("censored error",e,{});e||(e=B.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=j[e[t]>>4],r+=j[15&e[t]];n.push(t+"=Uint8Array(0x"+r+")")}else n.push(t+"="+JSON.stringify(e))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;let o="";switch(e){case O.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case O.CALL_EXCEPTION:case O.INSUFFICIENT_FUNDS:case O.MISSING_NEW:case O.NONCE_EXPIRED:case O.REPLACEMENT_UNDERPRICED:case O.TRANSACTION_REPLACED:case O.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(t+=" ("+n.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(r).forEach((function(t){s[t]=r[t]})),s}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,B.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){$&&this.throwError("platform missing String.prototype.normalize",B.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:$})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,B.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,B.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,B.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,B.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",B.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",B.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",B.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return R||(R=new B("logger/5.6.0")),R}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",B.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),N){if(!t)return;this.globalLogger().throwError("error censorship permanent",B.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}P=!!t,N=!!e}static setLogLevel(t){const e=I[t.toLowerCase()];null!=e?T=e:B.globalLogger().warn("invalid log level - "+t)}static from(t){return new B(t)}}B.errors=O,B.levels=C;const F=new B("bytes/5.6.1");function D(t){return!!t.toHexString}function L(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return L(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function z(t){return Z(t)&&!(t.length%2)||V(t)}function q(t){return"number"==typeof t&&t==t&&t%1==0}function V(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!q(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!q(r)||r<0||r>=256)return!1}return!0}function K(t,e){if(e||(e={}),"number"==typeof t){F.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),L(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),D(t)&&(t=t.toHexString()),Z(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":F.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return L(new Uint8Array(n))}return V(t)?L(new Uint8Array(t)):F.throwArgumentError("invalid arrayify value","value",t)}function G(t){const e=t.map(t=>K(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),L(n)}function H(t){let e=K(t);if(0===e.length)return e;let r=0;for(;r<e.length&&0===e[r];)r++;return r&&(e=e.slice(r)),e}function Z(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function J(t,e){if(e||(e={}),"number"==typeof t){F.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"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),D(t))return t.toHexString();if(Z(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":F.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(V(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return F.throwArgumentError("invalid hexlify value","value",t)}function Q(t){if("string"!=typeof t)t=J(t);else if(!Z(t)||t.length%2)return null;return(t.length-2)/2}function W(t,e,r){return"string"!=typeof t?t=J(t):(!Z(t)||t.length%2)&&F.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Y(t){let e="0x";return t.forEach(t=>{e+=J(t).substring(2)}),e}function X(t){const e=function(t){"string"!=typeof t&&(t=J(t));Z(t)||F.throwArgumentError("invalid hex string","value",t);t=t.substring(2);let e=0;for(;e<t.length&&"0"===t[e];)e++;return"0x"+t.substring(e)}(J(t,{hexPad:"left"}));return"0x"===e?"0x0":e}function tt(t,e){for("string"!=typeof t?t=J(t):Z(t)||F.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&F.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function et(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(z(t)){let r=K(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=J(r.slice(0,32)),e.s=J(r.slice(32,64))):65===r.length?(e.r=J(r.slice(0,32)),e.s=J(r.slice(32,64)),e.v=r[64]):F.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:F.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=J(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){const r=function(t,e){(t=K(t)).length>e&&F.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),L(r)}(K(e._vs),32);e._vs=J(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&F.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const i=J(r);null==e.s?e.s=i:e.s!==i&&F.throwArgumentError("signature v mismatch _vs","signature",t)}if(null==e.recoveryParam)null==e.v?F.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{const r=0===e.v||1===e.v?e.v:1-e.v%2;e.recoveryParam!==r&&F.throwArgumentError("signature recoveryParam mismatch v","signature",t)}null!=e.r&&Z(e.r)?e.r=tt(e.r,32):F.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&Z(e.s)?e.s=tt(e.s,32):F.throwArgumentError("signature missing or invalid s","signature",t);const r=K(e.s);r[0]>=128&&F.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=J(r);e._vs&&(Z(e._vs)||F.throwArgumentError("signature invalid _vs","signature",t),e._vs=tt(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&F.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function rt(t,n,i){return e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return n=J(new Buffer(n,"utf8")),[4,t.send("personal_sign",[n,i])];case 1:return[2,e.sent()]}}))}))}var nt=function(){function t(t){void 0===t&&(t=S[0]),this.address=t}return t.prototype.request=function(t,e){var r,n=this.address+"/api/"+t;return e&&(r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}),new Promise((function(t,e){h(n,r).then((function(e){if(e.ok)return t(e.json());throw e})).catch((function(t){return t.json().then((function(t){return e(t)}))}))}))},t.prototype.send=function(t){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.request("message",t)]}))}))},t.prototype.getSpaces=function(){return e(this,void 0,void 0,(function(){return r(this,(function(t){return[2,this.request("spaces")]}))}))},t.prototype.broadcast=function(t,n,i,o,s){return e(this,void 0,void 0,(function(){var e,a;return r(this,(function(r){switch(r.label){case 0:return e={address:n,msg:JSON.stringify({version:"0.1.3",timestamp:(Date.now()/1e3).toFixed(),space:i,type:o,payload:s})},a=e,[4,rt(t,e.msg,n)];case 1:return a.sig=r.sent(),[4,this.send(e)];case 2:return[2,r.sent()]}}))}))},t.prototype.sign=function(t,n,i,o,s){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return e={address:n,msg:JSON.stringify({version:"0.1.3",timestamp:(Date.now()/1e3).toFixed(),space:i,type:o,payload:s})},[4,rt(t,e.msg,n)];case 1:return[2,r.sent()]}}))}))},t.prototype.vote=function(t,n,i,o){var s=o.proposal,a=o.choice;return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"vote",{proposal:s,choice:a})]}))}))},t.prototype.proposal=function(t,n,i,o){var s=o.name,a=o.body,u=o.discussion,h=void 0===u?"":u,l=o.choices,c=o.start,f=o.end,d=o.snapshot,p=o.type,m=void 0===p?"single-choice":p,y=o.metadata,g=void 0===y?{}:y;return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"proposal",{name:s,body:a,discussion:h,choices:l,start:c,end:f,snapshot:d,type:m,metadata:g})]}))}))},t.prototype.deleteProposal=function(t,n,i,o){var s=o.proposal;return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"delete-proposal",{proposal:s})]}))}))},t.prototype.settings=function(t,n,i,o){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.broadcast(t,n,i,"settings",o)]}))}))},t}(),it={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Proposal",definitions:{Proposal:{title:"Proposal",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0,maxLength:14400},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1,maxItems:160},type:{type:"string",enum:["single-choice","approval","ranked-choice","quadratic","weighted","custom","basic"]},snapshot:{type:"number",title:"snapshot"},start:{type:"number",title:"start",minimum:1e9,maximum:2e9},end:{type:"number",title:"end",minimum:1e9,maximum:2e9,exclusiveMinimum:{$data:"1/start"}},metadata:{type:"object",title:"metadata"}},required:["name","body","choices","snapshot","start","end"],additionalProperties:!1}}},ot={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Vote",definitions:{Vote:{title:"Vote",type:"object",properties:{proposal:{type:"string",title:"proposal"},choice:{type:["number","array","object","boolean","string"],title:"choice"},metadata:{type:"object",title:"metadata"}},required:["proposal","choice"],additionalProperties:!1}}},st={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Profile",definitions:{Profile:{title:"Profile",type:"object",properties:{name:{type:"string",title:"name",maxLength:32},about:{type:"string",title:"about",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256}},required:[],additionalProperties:!1}}},at={space:{$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Space",definitions:{Space:{title:"Space",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:32},private:{type:"boolean"},about:{type:"string",title:"about",maxLength:160},guidelines:{type:"string",title:"guidelines",maxLength:1024},terms:{type:"string",title:"terms",format:"uri",maxLength:128},avatar:{type:"string",title:"avatar",format:"uri",maxLength:256},location:{type:"string",title:"location",maxLength:24},website:{type:"string",title:"website",format:"url",maxLength:128},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},email:{type:"string",title:"email",maxLength:32},network:{type:"string",title:"network",minLength:1,maxLength:32},symbol:{type:"string",title:"symbol",minLength:1,maxLength:16},skin:{type:"string",title:"skin",maxLength:32},domain:{type:"string",title:"domain",maxLength:64},strategies:{type:"array",minItems:1,maxItems:8,items:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},network:{type:"string",maxLength:12,title:"network"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},title:"strategies"},members:{type:"array",maxItems:100,items:{type:"string",pattern:"^0x[a-fA-F0-9]{40}$",minLength:42,maxLength:42},title:"members",uniqueItems:!0},admins:{type:"array",maxItems:100,items:{type:"string",pattern:"^0x[a-fA-F0-9]{40}$",minLength:42,maxLength:42},title:"admins",uniqueItems:!0},filters:{type:"object",properties:{defaultTab:{type:"string"},minScore:{type:"number",minimum:0},onlyMembers:{type:"boolean"},invalids:{type:"array",items:{type:"string",maxLength:64},title:"invalids"}},additionalProperties:!1},validation:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},plugins:{type:"object"},voting:{type:"object",properties:{delay:{type:"integer",minimum:0},period:{type:"integer",minimum:0},type:{type:"string",title:"type"},quorum:{type:"number",minimum:0},blind:{type:"boolean"},hideAbstain:{type:"boolean"},privacy:{type:"string",enum:["","shutter"]}},additionalProperties:!1},categories:{type:"array",maxItems:2,items:{type:"string",enum:["protocol","social","investment","grant","service","media","creator","collector"]}},treasuries:{type:"array",maxItems:10,items:{type:"object",properties:{name:{type:"string",title:"Name",examples:["e.g. Balancer DAO 1"],minLength:1,maxLength:64},address:{type:"string",title:"Contract address",examples:["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],pattern:"^0x[a-fA-F0-9]{40}$",minLength:42,maxLength:42},network:{type:"string",title:"Network",maxLength:12}},required:["name","address","network"],additionalProperties:!1}},parent:{type:"string",title:"parent"},children:{type:"array",maxItems:8,title:"children",items:{type:"string"}}},required:["name","network","symbol","strategies"],additionalProperties:!1}}}.definitions.Space,proposal:it.definitions.Proposal,vote:ot.definitions.Vote,profile:st.definitions.Profile},ut="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ht=[],lt=[],ct="undefined"!=typeof Uint8Array?Uint8Array:Array,ft=!1;function dt(){ft=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)ht[e]=t[e],lt[t.charCodeAt(e)]=e;lt["-".charCodeAt(0)]=62,lt["_".charCodeAt(0)]=63}function pt(t,e,r){for(var n,i,o=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(ht[(i=n)>>18&63]+ht[i>>12&63]+ht[i>>6&63]+ht[63&i]);return o.join("")}function mt(t){var e;ft||dt();for(var r=t.length,n=r%3,i="",o=[],s=0,a=r-n;s<a;s+=16383)o.push(pt(t,s,s+16383>a?a:s+16383));return 1===n?(e=t[r-1],i+=ht[e>>2],i+=ht[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=ht[e>>10],i+=ht[e>>4&63],i+=ht[e<<2&63],i+="="),o.push(i),o.join("")}function yt(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,h=u>>1,l=-7,c=r?i-1:0,f=r?-1:1,d=t[e+c];for(c+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+t[e+c],c+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+c],c+=f,l-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function gt(t,e,r,n,i,o){var s,a,u,h=8*o-i-1,l=(1<<h)-1,c=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?f/u:f*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=l?(a=0,s=l):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;t[r+d]=255&s,d+=p,s/=256,h-=8);t[r+d-p]|=128*m}var vt={}.toString,wt=Array.isArray||function(t){return"[object Array]"==vt.call(t)};Mt.TYPED_ARRAY_SUPPORT=void 0===ut.TYPED_ARRAY_SUPPORT||ut.TYPED_ARRAY_SUPPORT;var bt=At();function At(){return Mt.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _t(t,e){if(At()<e)throw new RangeError("Invalid typed array length");return Mt.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Mt.prototype:(null===t&&(t=new Mt(e)),t.length=e),t}function Mt(t,e,r){if(!(Mt.TYPED_ARRAY_SUPPORT||this instanceof Mt))return new Mt(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return St(this,t)}return Et(this,t,e,r)}function Et(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);Mt.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Mt.prototype:t=xt(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!Mt.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Pt(e,r),i=(t=_t(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(Nt(e)){var r=0|Ut(e.length);return 0===(t=_t(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?_t(t,0):xt(t,e);if("Buffer"===e.type&&wt(e.data))return xt(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function kt(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function St(t,e){if(kt(e),t=_t(t,e<0?0:0|Ut(e)),!Mt.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function xt(t,e){var r=e.length<0?0:0|Ut(e.length);t=_t(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function Ut(t){if(t>=At())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+At().toString(16)+" bytes");return 0|t}function Nt(t){return!(null==t||!t._isBuffer)}function Pt(t,e){if(Nt(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return re(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ne(t).length;default:if(n)return re(t).length;e=(""+e).toLowerCase(),n=!0}}function It(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Kt(this,e,r);case"utf8":case"utf-8":return zt(this,e,r);case"ascii":return qt(this,e,r);case"latin1":case"binary":return Vt(this,e,r);case"base64":return Lt(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Tt(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Rt(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Mt.from(e,n)),Nt(e))return 0===e.length?-1:$t(t,e,r,n,i);if("number"==typeof e)return e&=255,Mt.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):$t(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function $t(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var l=-1;for(o=r;o<a;o++)if(h(t,o)===h(e,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var c=!0,f=0;f<u;f++)if(h(t,o+f)!==h(e,f)){c=!1;break}if(c)return o}return-1}function Ct(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function Ot(t,e,r,n){return ie(re(e,t.length-r),t,r,n)}function jt(t,e,r,n){return ie(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function Bt(t,e,r,n){return jt(t,e,r,n)}function Ft(t,e,r,n){return ie(ne(e),t,r,n)}function Dt(t,e,r,n){return ie(function(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function Lt(t,e,r){return 0===e&&r===t.length?mt(t):mt(t.slice(e,r))}function zt(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,a,u,h=t[i],l=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=r)switch(c){case 1:h<128&&(l=h);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&h)<<6|63&o)>127&&(l=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=c}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}Mt.poolSize=8192,Mt._augment=function(t){return t.__proto__=Mt.prototype,t},Mt.from=function(t,e,r){return Et(null,t,e,r)},Mt.TYPED_ARRAY_SUPPORT&&(Mt.prototype.__proto__=Uint8Array.prototype,Mt.__proto__=Uint8Array),Mt.alloc=function(t,e,r){return function(t,e,r,n){return kt(e),e<=0?_t(t,e):void 0!==r?"string"==typeof n?_t(t,e).fill(r,n):_t(t,e).fill(r):_t(t,e)}(null,t,e,r)},Mt.allocUnsafe=function(t){return St(null,t)},Mt.allocUnsafeSlow=function(t){return St(null,t)},Mt.isBuffer=oe,Mt.compare=function(t,e){if(!Nt(t)||!Nt(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},Mt.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Mt.concat=function(t,e){if(!wt(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Mt.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=Mt.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!Nt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},Mt.byteLength=Pt,Mt.prototype._isBuffer=!0,Mt.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Tt(this,e,e+1);return this},Mt.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Tt(this,e,e+3),Tt(this,e+1,e+2);return this},Mt.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Tt(this,e,e+7),Tt(this,e+1,e+6),Tt(this,e+2,e+5),Tt(this,e+3,e+4);return this},Mt.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?zt(this,0,t):It.apply(this,arguments)},Mt.prototype.equals=function(t){if(!Nt(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Mt.compare(this,t)},Mt.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Mt.prototype.compare=function(t,e,r,n,i){if(!Nt(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=t.slice(e,r),l=0;l<a;++l)if(u[l]!==h[l]){o=u[l],s=h[l];break}return o<s?-1:s<o?1:0},Mt.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},Mt.prototype.indexOf=function(t,e,r){return Rt(this,t,e,r,!0)},Mt.prototype.lastIndexOf=function(t,e,r){return Rt(this,t,e,r,!1)},Mt.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ct(this,t,e,r);case"utf8":case"utf-8":return Ot(this,t,e,r);case"ascii":return jt(this,t,e,r);case"latin1":case"binary":return Bt(this,t,e,r);case"base64":return Ft(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Dt(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Mt.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function qt(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function Vt(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Kt(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=ee(t[o]);return i}function Gt(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function Ht(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function Zt(t,e,r,n,i,o){if(!Nt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function Jt(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function Qt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function Wt(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Yt(t,e,r,n,i){return i||Wt(t,0,r,4),gt(t,e,r,n,23,4),r+4}function Xt(t,e,r,n,i){return i||Wt(t,0,r,8),gt(t,e,r,n,52,8),r+8}Mt.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),Mt.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=Mt.prototype;else{var i=e-t;r=new Mt(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},Mt.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},Mt.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Mt.prototype.readUInt8=function(t,e){return e||Ht(t,1,this.length),this[t]},Mt.prototype.readUInt16LE=function(t,e){return e||Ht(t,2,this.length),this[t]|this[t+1]<<8},Mt.prototype.readUInt16BE=function(t,e){return e||Ht(t,2,this.length),this[t]<<8|this[t+1]},Mt.prototype.readUInt32LE=function(t,e){return e||Ht(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Mt.prototype.readUInt32BE=function(t,e){return e||Ht(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Mt.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},Mt.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||Ht(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Mt.prototype.readInt8=function(t,e){return e||Ht(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Mt.prototype.readInt16LE=function(t,e){e||Ht(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Mt.prototype.readInt16BE=function(t,e){e||Ht(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Mt.prototype.readInt32LE=function(t,e){return e||Ht(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Mt.prototype.readInt32BE=function(t,e){return e||Ht(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Mt.prototype.readFloatLE=function(t,e){return e||Ht(t,4,this.length),yt(this,t,!0,23,4)},Mt.prototype.readFloatBE=function(t,e){return e||Ht(t,4,this.length),yt(this,t,!1,23,4)},Mt.prototype.readDoubleLE=function(t,e){return e||Ht(t,8,this.length),yt(this,t,!0,52,8)},Mt.prototype.readDoubleBE=function(t,e){return e||Ht(t,8,this.length),yt(this,t,!1,52,8)},Mt.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||Zt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},Mt.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||Zt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Mt.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,1,255,0),Mt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Mt.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,65535,0),Mt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Jt(this,t,e,!0),e+2},Mt.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,65535,0),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Jt(this,t,e,!1),e+2},Mt.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,4294967295,0),Mt.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):Qt(this,t,e,!0),e+4},Mt.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,4294967295,0),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Qt(this,t,e,!1),e+4},Mt.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);Zt(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Mt.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);Zt(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Mt.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,1,127,-128),Mt.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},Mt.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,32767,-32768),Mt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Jt(this,t,e,!0),e+2},Mt.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,2,32767,-32768),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Jt(this,t,e,!1),e+2},Mt.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,2147483647,-2147483648),Mt.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Qt(this,t,e,!0),e+4},Mt.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||Zt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Mt.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Qt(this,t,e,!1),e+4},Mt.prototype.writeFloatLE=function(t,e,r){return Yt(this,t,e,!0,r)},Mt.prototype.writeFloatBE=function(t,e,r){return Yt(this,t,e,!1,r)},Mt.prototype.writeDoubleLE=function(t,e,r){return Xt(this,t,e,!0,r)},Mt.prototype.writeDoubleBE=function(t,e,r){return Xt(this,t,e,!1,r)},Mt.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!Mt.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},Mt.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Mt.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=Nt(t)?t:re(new Mt(t,n).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var te=/[^+\/0-9A-Za-z-_]/g;function ee(t){return t<16?"0"+t.toString(16):t.toString(16)}function re(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function ne(t){return function(t){var e,r,n,i,o,s;ft||dt();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[a-2]?2:"="===t[a-1]?1:0,s=new ct(3*a/4-o),n=o>0?a-4:a;var u=0;for(e=0,r=0;e<n;e+=4,r+=3)i=lt[t.charCodeAt(e)]<<18|lt[t.charCodeAt(e+1)]<<12|lt[t.charCodeAt(e+2)]<<6|lt[t.charCodeAt(e+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=lt[t.charCodeAt(e)]<<2|lt[t.charCodeAt(e+1)]>>4,s[u++]=255&i):1===o&&(i=lt[t.charCodeAt(e)]<<10|lt[t.charCodeAt(e+1)]<<4|lt[t.charCodeAt(e+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(te,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function ie(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function oe(t){return null!=t&&(!!t._isBuffer||se(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&se(t.slice(0,0))}(t))}function se(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var ae=a(Object.freeze({__proto__:null,INSPECT_MAX_BYTES:50,kMaxLength:bt,Buffer:Mt,SlowBuffer:function(t){return+t!=t&&(t=0),Mt.alloc(+t)},isBuffer:oe}));var ue=u((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"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:ae.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 h=t.charCodeAt(u)-48;o*=i,s=h>=49?h-49+10:h>=17?h-17+10:h,r(h>=0&&s<i,"Invalid character"),o+=s}return o}function h(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"==typeof 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"==typeof 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,h=0,l=r;l<a;l+=n)h=u(t,l,l+n,e),this.imuln(i),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==s){var c=1;for(h=u(t,l,t.length,e),l=0;l<s;l++)c*=e;this.imuln(c),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}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){h(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&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){i.prototype.inspect=l}else i.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],f=[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],d=[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?c[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 h=f[t],l=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(l).toString(t);n=(p=p.idivn(l)).isZero()?m+n:c[h-m.length]+m+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 p(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 h=1;h<n;h++){for(var l=u>>>26,c=67108863&u,f=Math.min(h,e.length-1),d=Math.max(0,h-t.length+1);d<=f;d++){var p=h-d|0;l+=(s=(i=0|t.words[p])*(o=0|e.words[d])+c)/67108864|0,c=67108863&s}r.words[h]=0|c,u=0|l}return 0!==u?r.words[h]=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 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(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];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,h=0,l=0|s[0],c=8191&l,f=l>>>13,d=0|s[1],p=8191&d,m=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,w=0|s[3],b=8191&w,A=w>>>13,_=0|s[4],M=8191&_,E=_>>>13,k=0|s[5],S=8191&k,x=k>>>13,U=0|s[6],N=8191&U,P=U>>>13,I=0|s[7],T=8191&I,R=I>>>13,$=0|s[8],C=8191&$,O=$>>>13,j=0|s[9],B=8191&j,F=j>>>13,D=0|a[0],L=8191&D,z=D>>>13,q=0|a[1],V=8191&q,K=q>>>13,G=0|a[2],H=8191&G,Z=G>>>13,J=0|a[3],Q=8191&J,W=J>>>13,Y=0|a[4],X=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ht=at>>>13,lt=0|a[8],ct=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(h+(n=Math.imul(c,L))|0)+((8191&(i=(i=Math.imul(c,z))+Math.imul(f,L)|0))<<13)|0;h=((o=Math.imul(f,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,L),i=(i=Math.imul(p,z))+Math.imul(m,L)|0,o=Math.imul(m,z);var gt=(h+(n=n+Math.imul(c,V)|0)|0)+((8191&(i=(i=i+Math.imul(c,K)|0)+Math.imul(f,V)|0))<<13)|0;h=((o=o+Math.imul(f,K)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,L),i=(i=Math.imul(g,z))+Math.imul(v,L)|0,o=Math.imul(v,z),n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,K)|0;var vt=(h+(n=n+Math.imul(c,H)|0)|0)+((8191&(i=(i=i+Math.imul(c,Z)|0)+Math.imul(f,H)|0))<<13)|0;h=((o=o+Math.imul(f,Z)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,L),i=(i=Math.imul(b,z))+Math.imul(A,L)|0,o=Math.imul(A,z),n=n+Math.imul(g,V)|0,i=(i=i+Math.imul(g,K)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,K)|0,n=n+Math.imul(p,H)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,Z)|0;var wt=(h+(n=n+Math.imul(c,Q)|0)|0)+((8191&(i=(i=i+Math.imul(c,W)|0)+Math.imul(f,Q)|0))<<13)|0;h=((o=o+Math.imul(f,W)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(M,L),i=(i=Math.imul(M,z))+Math.imul(E,L)|0,o=Math.imul(E,z),n=n+Math.imul(b,V)|0,i=(i=i+Math.imul(b,K)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,K)|0,n=n+Math.imul(g,H)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,H)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,W)|0;var bt=(h+(n=n+Math.imul(c,X)|0)|0)+((8191&(i=(i=i+Math.imul(c,tt)|0)+Math.imul(f,X)|0))<<13)|0;h=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,L),i=(i=Math.imul(S,z))+Math.imul(x,L)|0,o=Math.imul(x,z),n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,K)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,K)|0,n=n+Math.imul(b,H)|0,i=(i=i+Math.imul(b,Z)|0)+Math.imul(A,H)|0,o=o+Math.imul(A,Z)|0,n=n+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,tt)|0;var At=(h+(n=n+Math.imul(c,rt)|0)|0)+((8191&(i=(i=i+Math.imul(c,nt)|0)+Math.imul(f,rt)|0))<<13)|0;h=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,L),i=(i=Math.imul(N,z))+Math.imul(P,L)|0,o=Math.imul(P,z),n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,K)|0,n=n+Math.imul(M,H)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(E,H)|0,o=o+Math.imul(E,Z)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(g,X)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var _t=(h+(n=n+Math.imul(c,ot)|0)|0)+((8191&(i=(i=i+Math.imul(c,st)|0)+Math.imul(f,ot)|0))<<13)|0;h=((o=o+Math.imul(f,st)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(T,L),i=(i=Math.imul(T,z))+Math.imul(R,L)|0,o=Math.imul(R,z),n=n+Math.imul(N,V)|0,i=(i=i+Math.imul(N,K)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,K)|0,n=n+Math.imul(S,H)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(x,H)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,W)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var Mt=(h+(n=n+Math.imul(c,ut)|0)|0)+((8191&(i=(i=i+Math.imul(c,ht)|0)+Math.imul(f,ut)|0))<<13)|0;h=((o=o+Math.imul(f,ht)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(C,L),i=(i=Math.imul(C,z))+Math.imul(O,L)|0,o=Math.imul(O,z),n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,K)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,K)|0,n=n+Math.imul(N,H)|0,i=(i=i+Math.imul(N,Z)|0)+Math.imul(P,H)|0,o=o+Math.imul(P,Z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(m,ut)|0,o=o+Math.imul(m,ht)|0;var Et=(h+(n=n+Math.imul(c,ct)|0)|0)+((8191&(i=(i=i+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;h=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(B,L),i=(i=Math.imul(B,z))+Math.imul(F,L)|0,o=Math.imul(F,z),n=n+Math.imul(C,V)|0,i=(i=i+Math.imul(C,K)|0)+Math.imul(O,V)|0,o=o+Math.imul(O,K)|0,n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ht)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ht)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,ft)|0;var kt=(h+(n=n+Math.imul(c,pt)|0)|0)+((8191&(i=(i=i+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;h=((o=o+Math.imul(f,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(B,V),i=(i=Math.imul(B,K))+Math.imul(F,V)|0,o=Math.imul(F,K),n=n+Math.imul(C,H)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(O,H)|0,o=o+Math.imul(O,Z)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(N,X)|0,i=(i=i+Math.imul(N,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(b,ut)|0,i=(i=i+Math.imul(b,ht)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ht)|0,n=n+Math.imul(g,ct)|0,i=(i=i+Math.imul(g,ft)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ft)|0;var St=(h+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,Z))+Math.imul(F,H)|0,o=Math.imul(F,Z),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,W)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(N,rt)|0,i=(i=i+Math.imul(N,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ht)|0)+Math.imul(E,ut)|0,o=o+Math.imul(E,ht)|0,n=n+Math.imul(b,ct)|0,i=(i=i+Math.imul(b,ft)|0)+Math.imul(A,ct)|0,o=o+Math.imul(A,ft)|0;var xt=(h+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,mt)|0)+Math.imul(v,pt)|0))<<13)|0;h=((o=o+Math.imul(v,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(B,Q),i=(i=Math.imul(B,W))+Math.imul(F,Q)|0,o=Math.imul(F,W),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(O,X)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(N,ot)|0,i=(i=i+Math.imul(N,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ht)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ht)|0,n=n+Math.imul(M,ct)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,ft)|0;var Ut=(h+(n=n+Math.imul(b,pt)|0)|0)+((8191&(i=(i=i+Math.imul(b,mt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((o=o+Math.imul(A,mt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(B,X),i=(i=Math.imul(B,tt))+Math.imul(F,X)|0,o=Math.imul(F,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(N,ut)|0,i=(i=i+Math.imul(N,ht)|0)+Math.imul(P,ut)|0,o=o+Math.imul(P,ht)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ft)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,ft)|0;var Nt=(h+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,mt)|0)+Math.imul(E,pt)|0))<<13)|0;h=((o=o+Math.imul(E,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(B,rt),i=(i=Math.imul(B,nt))+Math.imul(F,rt)|0,o=Math.imul(F,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ht)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ht)|0,n=n+Math.imul(N,ct)|0,i=(i=i+Math.imul(N,ft)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ft)|0;var Pt=(h+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,mt)|0)+Math.imul(x,pt)|0))<<13)|0;h=((o=o+Math.imul(x,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(B,ot),i=(i=Math.imul(B,st))+Math.imul(F,ot)|0,o=Math.imul(F,st),n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ht)|0)+Math.imul(O,ut)|0,o=o+Math.imul(O,ht)|0,n=n+Math.imul(T,ct)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(R,ct)|0,o=o+Math.imul(R,ft)|0;var It=(h+(n=n+Math.imul(N,pt)|0)|0)+((8191&(i=(i=i+Math.imul(N,mt)|0)+Math.imul(P,pt)|0))<<13)|0;h=((o=o+Math.imul(P,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(B,ut),i=(i=Math.imul(B,ht))+Math.imul(F,ut)|0,o=Math.imul(F,ht),n=n+Math.imul(C,ct)|0,i=(i=i+Math.imul(C,ft)|0)+Math.imul(O,ct)|0,o=o+Math.imul(O,ft)|0;var Tt=(h+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(R,pt)|0))<<13)|0;h=((o=o+Math.imul(R,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(B,ct),i=(i=Math.imul(B,ft))+Math.imul(F,ct)|0,o=Math.imul(F,ft);var Rt=(h+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,mt)|0)+Math.imul(O,pt)|0))<<13)|0;h=((o=o+Math.imul(O,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var $t=(h+(n=Math.imul(B,pt))|0)+((8191&(i=(i=Math.imul(B,mt))+Math.imul(F,pt)|0))<<13)|0;return h=((o=Math.imul(F,mt))+(i>>>13)|0)+($t>>>26)|0,$t&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=wt,u[4]=bt,u[5]=At,u[6]=_t,u[7]=Mt,u[8]=Et,u[9]=kt,u[10]=St,u[11]=xt,u[12]=Ut,u[13]=Nt,u[14]=Pt,u[15]=It,u[16]=Tt,u[17]=Rt,u[18]=$t,0!==h&&(u[19]=h,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),h=Math.max(0,o-t.length+1);h<=u;h++){var l=o-h,c=(0|t.words[l])*(0|e.words[h]),f=67108863&c;a=67108863&(f=f+a|0),i+=(s=(s=s+(c/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function g(t,e,r){return y(t,e,r)}Math.imul||(m=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):g(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),g(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var h=0;h<s;h++)u.words[h]=this.words[h];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,h=0;h<this.length;h++)this.words[h]=this.words[h+s];else this.words[0]=0,this.length=1;var l=0;for(h=this.length-1;h>=0&&(0!==l||h>=i);h--){var c=0|this.words[h];this.words[h]=l<<26-o|c>>>o,l=c&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var l=n.clone()._ishlnsubmul(o,1,u);0===l.negative&&(n=l,a&&(a.words[u]=1));for(var c=u-1;c>=0;c--){var f=67108864*(0|n.words[o.length+c])+(0|n.words[o.length+c-1]);for(f=Math.min(f/s|0,67108863),n._ishlnsubmul(o,f,c);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(o,1,c),n.isZero()||(n.negative^=1);a&&(a.words[c]=f)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var l=n.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(c)),o.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(c)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(h)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var c=0,f=1;0==(n.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(n.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new E(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function A(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function k(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},n(b,w),b.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(A,w),n(_,w),n(M,w),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new A;else if("p192"===t)e=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return v[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,h).cmp(u);)l.redIAdd(u);for(var c=this.pow(l,o),f=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var m=d,y=0;0!==m.cmp(a);y++)m=m.redSqr();r(y<p);var g=this.pow(c,new i(1).iushln(p-y-1));f=f.redMul(g),c=g.redSqr(),d=d.redMul(c),p=y}return f},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var h=e.words[n],l=u-1;l>=0;l--){var c=h>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==s?(s<<=1,s|=c,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}u=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new k(t)},n(k,E),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)})).BN;const he=new B("bignumber/5.6.2"),le={};let ce=!1;class fe{constructor(t,e){t!==le&&he.throwError("cannot call constructor directly; use BigNumber.from",B.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return pe(me(this).fromTwos(t))}toTwos(t){return pe(me(this).toTwos(t))}abs(){return"-"===this._hex[0]?fe.from(this._hex.substring(1)):this}add(t){return pe(me(this).add(me(t)))}sub(t){return pe(me(this).sub(me(t)))}div(t){return fe.from(t).isZero()&&ye("division-by-zero","div"),pe(me(this).div(me(t)))}mul(t){return pe(me(this).mul(me(t)))}mod(t){const e=me(t);return e.isNeg()&&ye("division-by-zero","mod"),pe(me(this).umod(e))}pow(t){const e=me(t);return e.isNeg()&&ye("negative-power","pow"),pe(me(this).pow(e))}and(t){const e=me(t);return(this.isNegative()||e.isNeg())&&ye("unbound-bitwise-result","and"),pe(me(this).and(e))}or(t){const e=me(t);return(this.isNegative()||e.isNeg())&&ye("unbound-bitwise-result","or"),pe(me(this).or(e))}xor(t){const e=me(t);return(this.isNegative()||e.isNeg())&&ye("unbound-bitwise-result","xor"),pe(me(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&ye("negative-width","mask"),pe(me(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&ye("negative-width","shl"),pe(me(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&ye("negative-width","shr"),pe(me(this).shrn(t))}eq(t){return me(this).eq(me(t))}lt(t){return me(this).lt(me(t))}lte(t){return me(this).lte(me(t))}gt(t){return me(this).gt(me(t))}gte(t){return me(this).gte(me(t))}isNegative(){return"-"===this._hex[0]}isZero(){return me(this).isZero()}toNumber(){try{return me(this).toNumber()}catch(t){ye("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return he.throwError("this platform does not support BigInt",B.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?ce||(ce=!0,he.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?he.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",B.errors.UNEXPECTED_ARGUMENT,{}):he.throwError("BigNumber.toString does not accept parameters",B.errors.UNEXPECTED_ARGUMENT,{})),me(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof fe)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new fe(le,de(t)):t.match(/^-?[0-9]+$/)?new fe(le,de(new ue(t))):he.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&ye("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&ye("overflow","BigNumber.from",t),fe.from(String(t));const e=t;if("bigint"==typeof e)return fe.from(e.toString());if(V(e))return fe.from(J(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return fe.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(Z(t)||"-"===t[0]&&Z(t.substring(1))))return fe.from(t)}return he.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function de(t){if("string"!=typeof t)return de(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&he.throwArgumentError("invalid hex","value",t),"0x00"===(t=de(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function pe(t){return fe.from(de(t))}function me(t){const e=fe.from(t).toHexString();return"-"===e[0]?new ue("-"+e.substring(3),16):new ue(e.substring(2),16)}function ye(t,e,r){const n={fault:t,operation:e};return null!=r&&(n.value=r),he.throwError(t,B.errors.NUMERIC_FAULT,n)}var ge=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const ve=new B("properties/5.6.0");function we(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function be(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function Ae(t){return ge(this,void 0,void 0,(function*(){const e=Object.keys(t).map(e=>{const r=t[e];return Promise.resolve(r).then(t=>({key:e,value:t}))});return(yield Promise.all(e)).reduce((t,e)=>(t[e.key]=e.value,t),{})}))}function _e(t){const e={};for(const r in t)e[r]=t[r];return e}const Me={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Ee(t){if(function t(e){if(null==e||Me[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const r=Object.keys(e);for(let n=0;n<r.length;n++){let i=null;try{i=e[r[n]]}catch(t){continue}if(!t(i))return!1}return!0}return ve.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}(t))return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ke(t)));if("object"==typeof t){const e={};for(const r in t){const n=t[r];void 0!==n&&we(e,r,ke(n))}return e}return ve.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function ke(t){return Ee(t)}class Se{constructor(t){for(const e in t)this[e]=ke(t[e])}}const xe=new B("abi/5.3.1"),Ue={};let Ne={calldata:!0,memory:!0,storage:!0},Pe={calldata:!0,memory:!0};function Ie(t,e){if("bytes"===t||"string"===t){if(Ne[e])return!0}else if("address"===t){if("payable"===e)return!0}else if((t.indexOf("[")>=0||"tuple"===t)&&Pe[e])return!0;return(Ne[e]||"payable"===e)&&xe.throwArgumentError("invalid modifier","name",e),!1}function Te(t,e){for(let r in e)we(t,r,e[r])}const Re=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),$e=new RegExp(/^(.*)\[([0-9]*)\]$/);class Ce{constructor(t,e){t!==Ue&&xe.throwError("use fromString",B.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),Te(this,e);let r=this.type.match($e);Te(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:Ce.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==Re.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===Re.full?", ":",")+")"):e+=this.type,t!==Re.sighash&&(!0===this.indexed&&(e+=" indexed"),t===Re.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?Ce.fromString(t,e):Ce.fromObject(t)}static fromObject(t){return Ce.isParamType(t)?t:new Ce(Ue,{name:t.name||null,type:Ge(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(Ce.fromObject):null})}static fromString(t,e){return r=function(t,e){let r=t;function n(e){xe.throwArgumentError("unexpected character at position "+e,"param",t)}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;r<t.length;r++){let o=t[r];switch(o){case"(":s.state.allowType&&""===s.type?s.type="tuple":s.state.allowParams||n(r),s.state.allowType=!1,s.type=Ge(s.type),s.components=[i(s)],s=s.components[0];break;case")":delete s.state,"indexed"===s.name&&(e||n(r),s.indexed=!0,s.name=""),Ie(s.type,s.name)&&(s.name=""),s.type=Ge(s.type);let t=s;s=s.parent,s||n(r),delete t.parent,s.state.allowParams=!1,s.state.allowName=!0,s.state.allowArray=!0;break;case",":delete s.state,"indexed"===s.name&&(e||n(r),s.indexed=!0,s.name=""),Ie(s.type,s.name)&&(s.name=""),s.type=Ge(s.type);let a=i(s.parent);s.parent.components.push(a),delete s.parent,s=a;break;case" ":s.state.allowType&&""!==s.type&&(s.type=Ge(s.type),delete s.state.allowType,s.state.allowName=!0,s.state.allowParams=!0),s.state.allowName&&""!==s.name&&("indexed"===s.name?(e||n(r),s.indexed&&n(r),s.indexed=!0,s.name=""):Ie(s.type,s.name)?s.name="":s.state.allowName=!1);break;case"[":s.state.allowArray||n(r),s.type+=o,s.state.allowArray=!1,s.state.allowName=!1,s.state.readArray=!0;break;case"]":s.state.readArray||n(r),s.type+=o,s.state.readArray=!1,s.state.allowArray=!0,s.state.allowName=!0;break;default:s.state.allowType?(s.type+=o,s.state.allowParams=!0,s.state.allowArray=!0):s.state.allowName?(s.name+=o,delete s.state.allowArray):s.state.readArray?s.type+=o:n(r)}}return s.parent&&xe.throwArgumentError("unexpected eof","param",t),delete o.state,"indexed"===s.name?(e||n(r.length-7),s.indexed&&n(r.length-7),s.indexed=!0,s.name=""):Ie(s.type,s.name)&&(s.name=""),o.type=Ge(o.type),o}(t,!!e),Ce.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(t){return!(null==t||!t._isParamType)}}function Oe(t,e){return function(t){t=t.trim();let e=[],r="",n=0;for(let i=0;i<t.length;i++){let o=t[i];","===o&&0===n?(e.push(r),r=""):(r+=o,"("===o?n++:")"===o&&(n--,-1===n&&xe.throwArgumentError("unbalanced parenthesis","value",t)))}r&&e.push(r);return e}(t).map(t=>Ce.fromString(t,e))}class je{constructor(t,e){t!==Ue&&xe.throwError("use a static from method",B.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Te(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return je.isFragment(t)?t:"string"==typeof t?je.fromString(t):je.fromObject(t)}static fromObject(t){if(je.isFragment(t))return t;switch(t.type){case"function":return qe.fromObject(t);case"event":return Be.fromObject(t);case"constructor":return ze.fromObject(t);case"error":return Ke.fromObject(t);case"fallback":case"receive":return null}return xe.throwArgumentError("invalid fragment object","value",t)}static fromString(t){return"event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Be.fromString(t.substring(5).trim()):"function"===t.split(" ")[0]?qe.fromString(t.substring(8).trim()):"constructor"===t.split("(")[0].trim()?ze.fromString(t.trim()):"error"===t.split(" ")[0]?Ke.fromString(t.substring(5).trim()):xe.throwArgumentError("unsupported fragment","value",t)}static isFragment(t){return!(!t||!t._isFragment)}}class Be extends je{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==Re.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ",t!==Re.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?Be.fromString(t):Be.fromObject(t)}static fromObject(t){if(Be.isEventFragment(t))return t;"event"!==t.type&&xe.throwArgumentError("invalid event object","value",t);const e={name:Ze(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(Ce.fromObject):[],type:"event"};return new Be(Ue,e)}static fromString(t){let e=t.match(Je);e||xe.throwArgumentError("invalid event string","value",t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:xe.warn("unknown modifier: "+t)}}),Be.fromObject({name:e[1].trim(),anonymous:r,inputs:Oe(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function Fe(t,e){e.gas=null;let r=t.split("@");return 1!==r.length?(r.length>2&&xe.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||xe.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=fe.from(r[1]),r[0]):t}function De(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Le(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return null!=t.stateMutability?(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant&&xe.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable&&xe.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):null!=t.payable?(e.payable=!!t.payable,null!=t.constant||e.payable||"constructor"===t.type||xe.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&xe.throwArgumentError("cannot have constant payable function","value",t)):null!=t.constant?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):"constructor"!==t.type&&xe.throwArgumentError("unable to determine stateMutability","value",t),e}class ze extends je{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===Re.sighash&&xe.throwError("cannot format a constructor for sighash",B.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?ze.fromString(t):ze.fromObject(t)}static fromObject(t){if(ze.isConstructorFragment(t))return t;"constructor"!==t.type&&xe.throwArgumentError("invalid constructor object","value",t);let e=Le(t);e.constant&&xe.throwArgumentError("constructor cannot be constant","value",t);const r={name:null,type:t.type,inputs:t.inputs?t.inputs.map(Ce.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?fe.from(t.gas):null};return new ze(Ue,r)}static fromString(t){let e={type:"constructor"},r=(t=Fe(t,e)).match(Je);return r&&"constructor"===r[1].trim()||xe.throwArgumentError("invalid constructor string","value",t),e.inputs=Oe(r[2].trim(),!1),De(r[3].trim(),e),ze.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class qe extends ze{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),outputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==Re.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ",t!==Re.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?qe.fromString(t):qe.fromObject(t)}static fromObject(t){if(qe.isFunctionFragment(t))return t;"function"!==t.type&&xe.throwArgumentError("invalid function object","value",t);let e=Le(t);const r={type:t.type,name:Ze(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(Ce.fromObject):[],outputs:t.outputs?t.outputs.map(Ce.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?fe.from(t.gas):null};return new qe(Ue,r)}static fromString(t){let e={type:"function"},r=(t=Fe(t,e)).split(" returns ");r.length>2&&xe.throwArgumentError("invalid function string","value",t);let n=r[0].match(Je);if(n||xe.throwArgumentError("invalid function signature","value",t),e.name=n[1].trim(),e.name&&Ze(e.name),e.inputs=Oe(n[2],!1),De(n[3].trim(),e),r.length>1){let n=r[1].match(Je);""==n[1].trim()&&""==n[3].trim()||xe.throwArgumentError("unexpected tokens","value",t),e.outputs=Oe(n[2],!1)}else e.outputs=[];return qe.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function Ve(t){const e=t.format();return"Error(string)"!==e&&"Panic(uint256)"!==e||xe.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}class Ke extends je{format(t){if(t||(t=Re.sighash),Re[t]||xe.throwArgumentError("invalid format type","format",t),t===Re.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==Re.sighash&&(e+="error "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===Re.full?", ":",")+") ",e.trim()}static from(t){return"string"==typeof t?Ke.fromString(t):Ke.fromObject(t)}static fromObject(t){if(Ke.isErrorFragment(t))return t;"error"!==t.type&&xe.throwArgumentError("invalid error object","value",t);const e={type:t.type,name:Ze(t.name),inputs:t.inputs?t.inputs.map(Ce.fromObject):[]};return Ve(new Ke(Ue,e))}static fromString(t){let e={type:"error"},r=t.match(Je);return r||xe.throwArgumentError("invalid error signature","value",t),e.name=r[1].trim(),e.name&&Ze(e.name),e.inputs=Oe(r[2],!1),Ve(Ke.fromObject(e))}static isErrorFragment(t){return t&&t._isFragment&&"error"===t.type}}function Ge(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const He=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Ze(t){return t&&t.match(He)||xe.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}const Je=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Qe=new B("abi/5.3.1");class We{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Qe.throwArgumentError(t,this.localName,e)}}class Ye{constructor(t){we(this,"wordSize",t||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(t)}get data(){return Y(this._data)}get length(){return this._dataLength}_writeData(t){return this._data.push(t),this._dataLength+=t.length,t.length}appendWriter(t){return this._writeData(G(t._data))}writeBytes(t){let e=K(t);const r=e.length%this.wordSize;return r&&(e=G([e,this._padding.slice(r)])),this._writeData(e)}_getValue(t){let e=K(fe.from(t));return e.length>this.wordSize&&Qe.throwError("value out-of-bounds",B.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=G([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){const t=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,e=>{this._data[t]=this._getValue(e)}}}class Xe{constructor(t,e,r,n){we(this,"_data",K(t)),we(this,"wordSize",e||32),we(this,"_coerceFunc",r),we(this,"allowLoose",n),this._offset=0}get data(){return J(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Xe.coerce(t,e)}_peekBytes(t,e,r){let n=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&r&&this._offset+e<=this._data.length?n=e:Qe.throwError("data out-of-bounds",B.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(t){return new Xe(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(t,e){let r=this._peekBytes(0,t,!!e);return this._offset+=r.length,r.slice(0,t)}readValue(){return fe.from(this.readBytes(this.wordSize))}}function tr(){throw new Error("setTimeout has not been defined")}function er(){throw new Error("clearTimeout has not been defined")}var rr=tr,nr=er;function ir(t){if(rr===setTimeout)return setTimeout(t,0);if((rr===tr||!rr)&&setTimeout)return rr=setTimeout,setTimeout(t,0);try{return rr(t,0)}catch(e){try{return rr.call(null,t,0)}catch(e){return rr.call(this,t,0)}}}"function"==typeof ut.setTimeout&&(rr=setTimeout),"function"==typeof ut.clearTimeout&&(nr=clearTimeout);var or,sr=[],ar=!1,ur=-1;function hr(){ar&&or&&(ar=!1,or.length?sr=or.concat(sr):ur=-1,sr.length&&lr())}function lr(){if(!ar){var t=ir(hr);ar=!0;for(var e=sr.length;e;){for(or=sr,sr=[];++ur<e;)or&&or[ur].run();ur=-1,e=sr.length}or=null,ar=!1,function(t){if(nr===clearTimeout)return clearTimeout(t);if((nr===er||!nr)&&clearTimeout)return nr=clearTimeout,clearTimeout(t);try{nr(t)}catch(e){try{return nr.call(null,t)}catch(e){return nr.call(this,t)}}}(t)}}function cr(t,e){this.fun=t,this.array=e}cr.prototype.run=function(){this.fun.apply(null,this.array)};function fr(){}var dr=fr,pr=fr,mr=fr,yr=fr,gr=fr,vr=fr,wr=fr;var br=ut.performance||{},Ar=br.now||br.mozNow||br.msNow||br.oNow||br.webkitNow||function(){return(new Date).getTime()};var _r=new Date;var Mr={nextTick:function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];sr.push(new cr(t,e)),1!==sr.length||ar||ir(lr)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:dr,addListener:pr,once:mr,off:yr,removeListener:gr,removeAllListeners:vr,emit:wr,binding:function(t){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*Ar.call(br),r=Math.floor(e),n=Math.floor(e%1*1e9);return t&&(r-=t[0],(n-=t[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-_r)/1e3}},Er=u((function(t){!function(){var e="input is invalid type",r="object"==typeof window,n=r?window:{};n.JS_SHA3_NO_WINDOW&&(r=!1);var i=!r&&"object"==typeof self;!n.JS_SHA3_NO_NODE_JS&&"object"==typeof Mr&&Mr.versions&&Mr.versions.node?n=o:i&&(n=self);var s=!n.JS_SHA3_NO_COMMON_JS&&t.exports,a=!n.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),h=[4,1024,262144,67108864],l=[0,8,16,24],c=[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],f=[224,256,384,512],d=[128,256],p=["hex","buffer","arrayBuffer","array","digest"],m={128:168,256:136};!n.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!a||!n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var y=function(t,e,r){return function(n){return new I(t,e,t).update(n)[r]()}},g=function(t,e,r){return function(n,i){return new I(t,e,i).update(n)[r]()}},v=function(t,e,r){return function(e,n,i,o){return M["cshake"+t].update(e,n,i,o)[r]()}},w=function(t,e,r){return function(e,n,i,o){return M["kmac"+t].update(e,n,i,o)[r]()}},b=function(t,e,r,n){for(var i=0;i<p.length;++i){var o=p[i];t[o]=e(r,n,o)}return t},A=function(t,e){var r=y(t,e,"hex");return r.create=function(){return new I(t,e,t)},r.update=function(t){return r.create().update(t)},b(r,y,t,e)},_=[{name:"keccak",padding:[1,256,65536,16777216],bits:f,createMethod:A},{name:"sha3",padding:[6,1536,393216,100663296],bits:f,createMethod:A},{name:"shake",padding:[31,7936,2031616,520093696],bits:d,createMethod:function(t,e){var r=g(t,e,"hex");return r.create=function(r){return new I(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},b(r,g,t,e)}},{name:"cshake",padding:h,bits:d,createMethod:function(t,e){var r=m[t],n=v(t,0,"hex");return n.create=function(n,i,o){return i||o?new I(t,e,n).bytepad([i,o],r):M["shake"+t].create(n)},n.update=function(t,e,r,i){return n.create(e,r,i).update(t)},b(n,v,t,e)}},{name:"kmac",padding:h,bits:d,createMethod:function(t,e){var r=m[t],n=w(t,0,"hex");return n.create=function(n,i,o){return new T(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)},b(n,w,t,e)}}],M={},E=[],k=0;k<_.length;++k)for(var S=_[k],x=S.bits,U=0;U<x.length;++U){var N=S.name+"_"+x[U];if(E.push(N),M[N]=S.createMethod(x[U],S.padding),"sha3"!==S.name){var P=S.name+x[U];E.push(P),M[P]=M[N]}}function I(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 T(t,e,r){I.call(this,t,e,r)}I.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var i,o,s=this.blocks,u=this.byteCount,h=t.length,c=this.blockCount,f=0,d=this.s;f<h;){if(this.reset)for(this.reset=!1,s[0]=this.block,i=1;i<c+1;++i)s[i]=0;if(r)for(i=this.start;f<h&&i<u;++f)s[i>>2]|=t[f]<<l[3&i++];else for(i=this.start;f<h&&i<u;++f)(o=t.charCodeAt(f))<128?s[i>>2]|=o<<l[3&i++]:o<2048?(s[i>>2]|=(192|o>>6)<<l[3&i++],s[i>>2]|=(128|63&o)<<l[3&i++]):o<55296||o>=57344?(s[i>>2]|=(224|o>>12)<<l[3&i++],s[i>>2]|=(128|o>>6&63)<<l[3&i++],s[i>>2]|=(128|63&o)<<l[3&i++]):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++f)),s[i>>2]|=(240|o>>18)<<l[3&i++],s[i>>2]|=(128|o>>12&63)<<l[3&i++],s[i>>2]|=(128|o>>6&63)<<l[3&i++],s[i>>2]|=(128|63&o)<<l[3&i++]);if(this.lastByteIndex=i,i>=u){for(this.start=i-u,this.block=s[c],i=0;i<c;++i)d[i]^=s[i];R(d),this.reset=!0}else this.start=i}return this},I.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},I.prototype.encodeString=function(t){var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}var i=0,o=t.length;if(r)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},I.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},I.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];R(n)}},I.prototype.toString=I.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&&(R(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},I.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&&R(r)}return i&&(u[o]=r[o],t=t.slice(0,a)),t},I.prototype.buffer=I.prototype.arrayBuffer,I.prototype.digest=I.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&&R(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},T.prototype=new I,T.prototype.finalize=function(){return this.encode(this.outputBits,!0),I.prototype.finalize.call(this)};var R=function(t){var e,r,n,i,o,s,a,u,h,l,f,d,p,m,y,g,v,w,b,A,_,M,E,k,S,x,U,N,P,I,T,R,$,C,O,j,B,F,D,L,z,q,V,K,G,H,Z,J,Q,W,Y,X,tt,et,rt,nt,it,ot,st,at,ut,ht,lt;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],h=t[5]^t[15]^t[25]^t[35]^t[45],l=t[6]^t[16]^t[26]^t[36]^t[46],f=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(s<<1|a>>>31),r=(p=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|h>>>31),r=o^(h<<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^(l<<1|f>>>31),r=a^(f<<1|l>>>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^(d<<1|p>>>31),r=h^(p<<1|d>>>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=l^(i<<1|o>>>31),r=f^(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,m=t[0],y=t[1],H=t[11]<<4|t[10]>>>28,Z=t[10]<<4|t[11]>>>28,N=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,q=t[40]<<18|t[41]>>>14,V=t[41]<<18|t[40]>>>14,C=t[2]<<1|t[3]>>>31,O=t[3]<<1|t[2]>>>31,g=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,J=t[22]<<10|t[23]>>>22,Q=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,T=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,lt=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,j=t[14]<<6|t[15]>>>26,B=t[15]<<6|t[14]>>>26,w=t[25]<<11|t[24]>>>21,b=t[24]<<11|t[25]>>>21,W=t[34]<<15|t[35]>>>17,Y=t[35]<<15|t[34]>>>17,R=t[45]<<29|t[44]>>>3,$=t[44]<<29|t[45]>>>3,k=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,F=t[26]<<25|t[27]>>>7,D=t[27]<<25|t[26]>>>7,A=t[36]<<21|t[37]>>>11,_=t[37]<<21|t[36]>>>11,X=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,K=t[8]<<27|t[9]>>>5,G=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,U=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,L=t[38]<<8|t[39]>>>24,z=t[39]<<8|t[38]>>>24,M=t[48]<<14|t[49]>>>18,E=t[49]<<14|t[48]>>>18,t[0]=m^~g&w,t[1]=y^~v&b,t[10]=k^~x&N,t[11]=S^~U&P,t[20]=C^~j&F,t[21]=O^~B&D,t[30]=K^~H&J,t[31]=G^~Z&Q,t[40]=et^~nt&ot,t[41]=rt^~it&st,t[2]=g^~w&A,t[3]=v^~b&_,t[12]=x^~N&I,t[13]=U^~P&T,t[22]=j^~F&L,t[23]=B^~D&z,t[32]=H^~J&W,t[33]=Z^~Q&Y,t[42]=nt^~ot&at,t[43]=it^~st&ut,t[4]=w^~A&M,t[5]=b^~_&E,t[14]=N^~I&R,t[15]=P^~T&$,t[24]=F^~L&q,t[25]=D^~z&V,t[34]=J^~W&X,t[35]=Q^~Y&tt,t[44]=ot^~at&ht,t[45]=st^~ut<,t[6]=A^~M&m,t[7]=_^~E&y,t[16]=I^~R&k,t[17]=T^~$&S,t[26]=L^~q&C,t[27]=z^~V&O,t[36]=W^~X&K,t[37]=Y^~tt&G,t[46]=at^~ht&et,t[47]=ut^~lt&rt,t[8]=M^~m&g,t[9]=E^~y&v,t[18]=R^~k&x,t[19]=$^~S&U,t[28]=q^~C&j,t[29]=V^~O&B,t[38]=X^~K&H,t[39]=tt^~G&Z,t[48]=ht^~et&nt,t[49]=lt^~rt&it,t[0]^=c[n],t[1]^=c[n+1]};if(s)t.exports=M;else for(k=0;k<E.length;++k)n[E[k]]=M[E[k]]}()}));function kr(t){return"0x"+Er.keccak_256(K(t))}const Sr=new B("rlp/5.6.1");function xr(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function Ur(t){return J(function t(e){if(Array.isArray(e)){let r=[];if(e.forEach((function(e){r=r.concat(t(e))})),r.length<=55)return r.unshift(192+r.length),r;const n=xr(r.length);return n.unshift(247+n.length),n.concat(r)}z(e)||Sr.throwArgumentError("RLP object must be BytesLike","object",e);const r=Array.prototype.slice.call(K(e));if(1===r.length&&r[0]<=127)return r;if(r.length<=55)return r.unshift(128+r.length),r;const n=xr(r.length);return n.unshift(183+n.length),n.concat(r)}(t))}const Nr=new B("address/5.6.1");function Pr(t){Z(t,20)||Nr.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=K(kr(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Ir={};for(let t=0;t<10;t++)Ir[String(t)]=String(t);for(let t=0;t<26;t++)Ir[String.fromCharCode(65+t)]=String(10+t);const Tr=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function Rr(t){let e=null;if("string"!=typeof t&&Nr.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Pr(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Nr.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map(t=>Ir[t]).join("");for(;e.length>=Tr;){let t=e.substring(0,Tr);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&Nr.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new ue(r,36).toString(16);e.length<40;)e="0"+e;e=Pr("0x"+e)}else Nr.throwArgumentError("invalid address","address",t);var r;return e}function $r(t){let e=null;try{e=Rr(t.from)}catch(e){Nr.throwArgumentError("missing from address","transaction",t)}return Rr(W(kr(Ur([e,H(K(fe.from(t.nonce).toHexString()))])),12))}class Cr extends We{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){try{Rr(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return Rr(tt(t.readValue().toHexString(),20))}}class Or extends We{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const jr=new B("abi/5.3.1");function Br(t,e,r){let n=null;if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map(e=>{const n=e.localName;return n||jr.throwError("cannot encode object for signature with missing names",B.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[n]&&jr.throwError("cannot encode object for signature with duplicate names",B.errors.INVALID_ARGUMENT,{argument:"values",coder:e,value:r}),t[n]=!0,r[n]})}else jr.throwArgumentError("invalid tuple value","tuple",r);e.length!==n.length&&jr.throwArgumentError("types/value length mismatch","tuple",r);let i=new Ye(t.wordSize),o=new Ye(t.wordSize),s=[];e.forEach((t,e)=>{let r=n[e];if(t.dynamic){let e=o.length;t.encode(o,r);let n=i.writeUpdatableValue();s.push(t=>{n(t+e)})}else t.encode(i,r)}),s.forEach(t=>{t(i.length)});let a=t.appendWriter(i);return a+=t.appendWriter(o),a}function Fr(t,e){let r=[],n=t.subReader(0);e.forEach(e=>{let i=null;if(e.dynamic){let r=t.readValue(),o=n.subReader(r.toNumber());try{i=e.decode(o)}catch(t){if(t.code===B.errors.BUFFER_OVERRUN)throw t;i=t,i.baseType=e.name,i.name=e.localName,i.type=e.type}}else try{i=e.decode(t)}catch(t){if(t.code===B.errors.BUFFER_OVERRUN)throw t;i=t,i.baseType=e.name,i.name=e.localName,i.type=e.type}null!=i&&r.push(i)});const i=e.reduce((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t},{});e.forEach((t,e)=>{let n=t.localName;if(!n||1!==i[n])return;if("length"===n&&(n="_length"),null!=r[n])return;const o=r[e];o instanceof Error?Object.defineProperty(r,n,{get:()=>{throw o}}):r[n]=o});for(let t=0;t<r.length;t++){const e=r[t];e instanceof Error&&Object.defineProperty(r,t,{get:()=>{throw e}})}return Object.freeze(r)}class Dr extends We{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),jr.checkArgumentCount(e.length,r,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t<e.length;t++)n.push(this.coder);return Br(t,n,e)}decode(t){let e=this.length;-1===e&&(e=t.readValue().toNumber(),32*e>t._data.length&&jr.throwError("insufficient data length",B.errors.BUFFER_OVERRUN,{length:t._data.length,count:e}));let r=[];for(let t=0;t<e;t++)r.push(new Or(this.coder));return t.coerce(this.name,Fr(t,r))}}class Lr extends We{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){return t.writeValue(e?1:0)}decode(t){return t.coerce(this.type,!t.readValue().isZero())}}class zr extends We{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=K(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readValue().toNumber(),!0)}}class qr extends zr{constructor(t){super("bytes",t)}decode(t){return t.coerce(this.name,J(super.decode(t)))}}class Vr extends We{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),this.size=t}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=K(e);return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return t.coerce(this.name,J(t.readBytes(this.size)))}}class Kr extends We{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes([])}decode(t){return t.readBytes(0),t.coerce(this.name,null)}}const Gr=fe.from(-1),Hr=fe.from(0),Zr=fe.from(1),Jr=fe.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Qr extends We{constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),this.size=t,this.signed=e}defaultValue(){return 0}encode(t,e){let r=fe.from(e),n=Jr.mask(8*t.wordSize);if(this.signed){let t=n.mask(8*this.size-1);(r.gt(t)||r.lt(t.add(Zr).mul(Gr)))&&this._throwError("value out-of-bounds",e)}else(r.lt(Hr)||r.gt(n.mask(8*this.size)))&&this._throwError("value out-of-bounds",e);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*t.wordSize)),t.writeValue(r)}decode(t){let e=t.readValue().mask(8*this.size);return this.signed&&(e=e.fromTwos(8*this.size)),t.coerce(this.name,e)}}const Wr=new B("strings/5.6.1");var Yr,Xr;function tn(t,e,r,n,i){if(t===Xr.BAD_PREFIX||t===Xr.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Xr.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Yr||(Yr={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Xr||(Xr={}));const en=Object.freeze({error:function(t,e,r,n,i){return Wr.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:tn,replace:function(t,e,r,n,i){return t===Xr.OVERLONG?(n.push(i),0):(n.push(65533),tn(t,e,r))}});function rn(t,e){null==e&&(e=en.error),t=K(t);const r=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=e(128==(192&i)?Xr.UNEXPECTED_CONTINUE:Xr.BAD_PREFIX,n-1,t,r);continue}o=3,s=65535}if(n-1+o>=t.length){n+=e(Xr.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=e(Xr.MISSING_CONTINUE,n,t,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=e(Xr.OUT_OF_RANGE,n-1-o,t,r,a):a>=55296&&a<=57343?n+=e(Xr.UTF16_SURROGATE,n-1-o,t,r,a):a<=s?n+=e(Xr.OVERLONG,n-1-o,t,r,a):r.push(a))}return r}function nn(t,e=Yr.current){e!=Yr.current&&(Wr.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return K(r)}function on(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function sn(t,e){return on(rn(t,e))}function an(t,e=Yr.current){return rn(nn(t,e))}function un(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function hn(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");1===r.length?r[1]="0":""===r[1]&&(r[1]="1");let n=e+parseInt(r[0],16);return e=parseInt(r[1],16),{l:n,h:e}})}function ln(t,e){let r=0;for(let n=0;n<e.length;n++){let i=e[n];if(r+=i.l,t>=r&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}const cn=hn("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),fn="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),dn=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],pn=un("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),mn=un("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),yn=un("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",(function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r<t.length;r+=4)e.push(parseInt(t.substring(r,r+4),16));return e})),gn=hn("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function vn(t){if(t.match(/^[a-z0-9-]*$/i)&&t.length<=59)return t.toLowerCase();let e=an(t);var r;r=e.map(t=>{if(fn.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=ln(t,dn);if(e)return[t+e.s];let r=pn[t];if(r)return r;let n=mn[t];return n?[t+n[0]]:yn[t]||null}(t);return e||[t]}),e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[]),e=an(on(e),Yr.NFKC),e.forEach(t=>{if(ln(t,gn))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(ln(t,cn))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=on(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class wn extends zr{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,nn(e))}decode(t){return sn(super.decode(t))}}class bn extends We{constructor(t,e){let r=!1;const n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)});super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}defaultValue(){const t=[];this.coders.forEach(e=>{t.push(e.defaultValue())});const e=this.coders.reduce((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t},{});return this.coders.forEach((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))}),Object.freeze(t)}encode(t,e){return Br(t,this.coders,e)}decode(t){return t.coerce(this.name,Fr(t,this.coders))}}const An=new B("abi/5.3.1"),_n=new RegExp(/^bytes([0-9]*)$/),Mn=new RegExp(/^(u?int)([0-9]*)$/);class En{constructor(t){An.checkNew(new.target,En),we(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Cr(t.name);case"bool":return new Lr(t.name);case"string":return new wn(t.name);case"bytes":return new qr(t.name);case"array":return new Dr(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new bn((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new Kr(t.name)}let e=t.type.match(Mn);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&An.throwArgumentError("invalid "+e[1]+" bit length","param",t),new Qr(r/8,"int"===e[1],t.name)}if(e=t.type.match(_n),e){let r=parseInt(e[1]);return(0===r||r>32)&&An.throwArgumentError("invalid bytes length","param",t),new Vr(r,t.name)}return An.throwArgumentError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t,e){return new Xe(t,this._getWordSize(),this.coerceFunc,e)}_getWriter(){return new Ye(this._getWordSize())}getDefaultValue(t){const e=t.map(t=>this._getCoder(Ce.from(t)));return new bn(e,"_").defaultValue()}encode(t,e){t.length!==e.length&&An.throwError("types/values length mismatch",B.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});const r=t.map(t=>this._getCoder(Ce.from(t))),n=new bn(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e,r){const n=t.map(t=>this._getCoder(Ce.from(t)));return new bn(n,"_").decode(this._getReader(K(e),r))}}const kn=new En;function Sn(t){return kr(nn(t))}const xn=new B("hash/5.6.1"),Un=new Uint8Array(32);Un.fill(0);const Nn=new RegExp("^((.*)\\.)?([^.]+)$");function Pn(t){"string"!=typeof t&&xn.throwArgumentError("invalid ENS name; not a string","name",t);let e=t,r=Un;for(;e.length;){const n=e.match(Nn);null!=n&&""!==n[2]||xn.throwArgumentError("invalid ENS address; missing component","name",t);r=kr(G([r,kr(nn(vn(n[3])))])),e=n[2]||""}return J(r)}var In=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const Tn=new B("hash/5.6.1"),Rn=new Uint8Array(32);Rn.fill(0);const $n=fe.from(-1),Cn=fe.from(0),On=fe.from(1),jn=fe.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const Bn=tt(On.toHexString(),32),Fn=tt(Cn.toHexString(),32),Dn={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Ln=["name","version","chainId","verifyingContract","salt"];function zn(t){return function(e){return"string"!=typeof e&&Tn.throwArgumentError("invalid domain value for "+JSON.stringify(t),"domain."+t,e),e}}const qn={name:zn("name"),version:zn("version"),chainId:function(t){try{return fe.from(t).toString()}catch(t){}return Tn.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Rr(t).toLowerCase()}catch(t){}return Tn.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=K(t);if(32!==e.length)throw new Error("bad length");return J(e)}catch(t){}return Tn.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function Vn(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],n=parseInt(e[2]||"256");(n%8!=0||n>256||e[2]&&e[2]!==String(n))&&Tn.throwArgumentError("invalid numeric width","type",t);const i=jn.mask(r?n-1:n),o=r?i.add(On).mul($n):Cn;return function(e){const r=fe.from(e);return(r.lt(o)||r.gt(i))&&Tn.throwArgumentError("value out-of-bounds for "+t,"value",e),tt(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&Tn.throwArgumentError("invalid bytes width","type",t),function(e){return K(e).length!==r&&Tn.throwArgumentError("invalid length for "+t,"value",e),function(t){const e=K(t),r=e.length%32;return r?Y([e,Rn.slice(r)]):J(e)}(e)}}}switch(t){case"address":return function(t){return tt(Rr(t),32)};case"bool":return function(t){return t?Bn:Fn};case"bytes":return function(t){return kr(t)};case"string":return function(t){return Sn(t)}}return null}function Kn(t,e){return`${t}(${e.map(({name:t,type:e})=>e+" "+t).join(",")})`}class Gn{constructor(t){we(this,"types",Object.freeze(ke(t))),we(this,"_encoderCache",{}),we(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach(t=>{e[t]={},r[t]=[],n[t]={}});for(const n in t){const i={};t[n].forEach(o=>{i[o.name]&&Tn.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",t),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&Tn.throwArgumentError("circular type reference to "+JSON.stringify(s),"types",t);Vn(s)||(r[s]||Tn.throwArgumentError("unknown type "+JSON.stringify(s),"types",t),r[s].push(n),e[n][s]=!0)})}const i=Object.keys(r).filter(t=>0===r[t].length);0===i.length?Tn.throwArgumentError("missing primary type","types",t):i.length>1&&Tn.throwArgumentError("ambiguous primary types or unused types: "+i.map(t=>JSON.stringify(t)).join(", "),"types",t),we(this,"primaryType",i[0]),function i(o,s){s[o]&&Tn.throwArgumentError("circular type reference to "+JSON.stringify(o),"types",t),s[o]=!0,Object.keys(e[o]).forEach(t=>{r[t]&&(i(t,s),Object.keys(s).forEach(e=>{n[e][t]=!0}))}),delete s[o]}(this.primaryType,{});for(const e in n){const r=Object.keys(n[e]);r.sort(),this._types[e]=Kn(e,t[e])+r.map(e=>Kn(e,t[e])).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=Vn(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),n=parseInt(e[3]);return e=>{n>=0&&e.length!==n&&Tn.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let i=e.map(r);return this._types[t]&&(i=i.map(kr)),kr(Y(i))}}const r=this.types[t];if(r){const e=Sn(this._types[t]);return t=>{const n=r.map(({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this._types[r]?kr(n):n});return n.unshift(e),Y(n)}}return Tn.throwArgumentError("unknown type: "+t,"type",t)}encodeType(t){const e=this._types[t];return e||Tn.throwArgumentError("unknown type: "+JSON.stringify(t),"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return kr(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(Vn(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],i=parseInt(n[3]);return i>=0&&e.length!==i&&Tn.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map(e=>this._visit(t,e,r))}const i=this.types[t];return i?i.reduce((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t),{}):Tn.throwArgumentError("unknown type: "+t,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Gn(t)}static getPrimaryType(t){return Gn.from(t).primaryType}static hashStruct(t,e,r){return Gn.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=Dn[r];n||Tn.throwArgumentError("invalid typed-data domain key: "+JSON.stringify(r),"domain",t),e.push({name:r,type:n})}return e.sort((t,e)=>Ln.indexOf(t.name)-Ln.indexOf(e.name)),Gn.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return Y(["0x1901",Gn.hashDomain(t),Gn.from(e).hash(r)])}static hash(t,e,r){return kr(Gn.encode(t,e,r))}static resolveNames(t,e,r,n){return In(this,void 0,void 0,(function*(){t=_e(t);const i={};t.verifyingContract&&!Z(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=Gn.from(e);o.visit(r,(t,e)=>("address"!==t||Z(e,20)||(i[e]="0x"),e));for(const t in i)i[t]=yield n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=o.visit(r,(t,e)=>"address"===t&&i[e]?i[e]:e),{domain:t,value:r}}))}static getPayload(t,e,r){Gn.hashDomain(t);const n={},i=[];Ln.forEach(e=>{const r=t[e];null!=r&&(n[e]=qn[e](r),i.push({name:e,type:Dn[e]}))});const o=Gn.from(e),s=_e(e);return s.EIP712Domain?Tn.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,(t,e)=>{if(t.match(/^bytes(\d*)/))return J(K(e));if(t.match(/^u?int/))return fe.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&Tn.throwArgumentError("invalid string","value",e),e}return Tn.throwArgumentError("unsupported type","type",t)})}}}const Hn=new B("abi/5.3.1");class Zn extends Se{}class Jn extends Se{}class Qn extends Se{static isIndexed(t){return!(!t||!t._isIndexed)}}const Wn={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function Yn(t,e){const r=new Error("deferred error during ABI decoding triggered accessing "+t);return r.error=e,r}class Xn{constructor(t){Hn.checkNew(new.target,Xn);let e=[];e="string"==typeof t?JSON.parse(t):t,we(this,"fragments",e.map(t=>je.from(t)).filter(t=>null!=t)),we(this,"_abiCoder",be(new.target,"getAbiCoder")()),we(this,"functions",{}),we(this,"errors",{}),we(this,"events",{}),we(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void Hn.warn("duplicate definition - constructor"):void we(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;case"error":e=this.errors;break;default:return}let r=t.format();e[r]?Hn.warn("duplicate definition - "+r):e[r]=t}),this.deploy||we(this,"deploy",ze.from({payable:!1,type:"constructor"})),we(this,"_isInterface",!0)}format(t){t||(t=Re.full),t===Re.sighash&&Hn.throwArgumentError("interface does not support formatting sighash","format",t);const e=this.fragments.map(e=>e.format(t));return t===Re.json?JSON.stringify(e.map(t=>JSON.parse(t))):e}static getAbiCoder(){return kn}static getAddress(t){return Rr(t)}static getSighash(t){return W(Sn(t.format()),0,4)}static getEventTopic(t){return Sn(t.format())}getFunction(t){if(Z(t)){for(const e in this.functions)if(t===this.getSighash(e))return this.functions[e];Hn.throwArgumentError("no matching function","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.functions).filter(t=>t.split("(")[0]===e);return 0===r.length?Hn.throwArgumentError("no matching function","name",e):r.length>1&&Hn.throwArgumentError("multiple matching functions","name",e),this.functions[r[0]]}const e=this.functions[qe.fromString(t).format()];return e||Hn.throwArgumentError("no matching function","signature",t),e}getEvent(t){if(Z(t)){const e=t.toLowerCase();for(const t in this.events)if(e===this.getEventTopic(t))return this.events[t];Hn.throwArgumentError("no matching event","topichash",e)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.events).filter(t=>t.split("(")[0]===e);return 0===r.length?Hn.throwArgumentError("no matching event","name",e):r.length>1&&Hn.throwArgumentError("multiple matching events","name",e),this.events[r[0]]}const e=this.events[Be.fromString(t).format()];return e||Hn.throwArgumentError("no matching event","signature",t),e}getError(t){if(Z(t)){const e=be(this.constructor,"getSighash");for(const r in this.errors){if(t===e(this.errors[r]))return this.errors[r]}Hn.throwArgumentError("no matching error","sighash",t)}if(-1===t.indexOf("(")){const e=t.trim(),r=Object.keys(this.errors).filter(t=>t.split("(")[0]===e);return 0===r.length?Hn.throwArgumentError("no matching error","name",e):r.length>1&&Hn.throwArgumentError("multiple matching errors","name",e),this.errors[r[0]]}const e=this.errors[qe.fromString(t).format()];return e||Hn.throwArgumentError("no matching error","signature",t),e}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),be(this.constructor,"getSighash")(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),be(this.constructor,"getEventTopic")(t)}_decodeParams(t,e){return this._abiCoder.decode(t,e)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeFunctionData(t,e){"string"==typeof t&&(t=this.getFunction(t));const r=K(e);return J(r.slice(0,4))!==this.getSighash(t)&&Hn.throwArgumentError(`data signature does not match function ${t.name}.`,"data",J(r)),this._decodeParams(t.inputs,r.slice(4))}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),J(G([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=K(e),n=null,i=null,o=null,s=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:{const t=J(r.slice(0,4)),e=Wn[t];if(e)i=this._abiCoder.decode(e.inputs,r.slice(4)),o=e.name,s=e.signature,e.reason&&(n=i[0]);else try{const e=this.getError(t);i=this._abiCoder.decode(e.inputs,r.slice(4)),o=e.name,s=e.format()}catch(t){console.log(t)}break}}return Hn.throwError("call revert exception",B.errors.CALL_EXCEPTION,{method:t.format(),errorArgs:i,errorName:o,errorSignature:s,reason:n})}encodeFunctionResult(t,e){return"string"==typeof t&&(t=this.getFunction(t)),J(this._abiCoder.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&Hn.throwError("too many arguments for "+t.format(),B.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];t.anonymous||r.push(this.getEventTopic(t));const n=(t,e)=>"string"===t.type?Sn(e):"bytes"===t.type?kr(J(e)):("address"===t.type&&this._abiCoder.encode(["address"],[e]),tt(J(e),32));for(e.forEach((e,i)=>{let o=t.inputs[i];o.indexed?null==e?r.push(null):"array"===o.baseType||"tuple"===o.baseType?Hn.throwArgumentError("filtering with tuples or arrays not supported","contract."+o.name,e):Array.isArray(e)?r.push(e.map(t=>n(o,t))):r.push(n(o,e)):null!=e&&Hn.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+o.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){"string"==typeof t&&(t=this.getEvent(t));const r=[],n=[],i=[];return t.anonymous||r.push(this.getEventTopic(t)),e.length!==t.inputs.length&&Hn.throwArgumentError("event arguments/values mismatch","values",e),t.inputs.forEach((t,o)=>{const s=e[o];if(t.indexed)if("string"===t.type)r.push(Sn(s));else if("bytes"===t.type)r.push(kr(s));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(this._abiCoder.encode([t.type],[s]))}else n.push(t),i.push(s)}),{data:this._abiCoder.encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);Z(r[0],32)&&r[0].toLowerCase()===e||Hn.throwError("fragment/topic mismatch",B.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],o=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Ce.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))});let s=null!=r?this._abiCoder.decode(n,G(r)):null,a=this._abiCoder.decode(i,e,!0),u=[],h=0,l=0;t.inputs.forEach((t,e)=>{if(t.indexed)if(null==s)u[e]=new Qn({_isIndexed:!0,hash:null});else if(o[e])u[e]=new Qn({_isIndexed:!0,hash:s[l++]});else try{u[e]=s[l++]}catch(t){u[e]=t}else try{u[e]=a[h++]}catch(t){u[e]=t}if(t.name&&null==u[t.name]){const r=u[e];r instanceof Error?Object.defineProperty(u,t.name,{get:()=>{throw Yn("property "+JSON.stringify(t.name),r)}}):u[t.name]=r}});for(let t=0;t<u.length;t++){const e=u[t];e instanceof Error&&Object.defineProperty(u,t,{get:()=>{throw Yn("index "+t,e)}})}return Object.freeze(u)}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new Jn({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:fe.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new Zn({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),args:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}const ti=new B("abstract-provider/5.3.0");class ei extends Se{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class ri{constructor(){ti.checkAbstract(new.target,ri),we(this,"_isProvider",!0)}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}static isProvider(t){return!(!t||!t._isProvider)}}var ni=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const ii=new B("abstract-signer/5.6.2"),oi=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],si=[B.errors.INSUFFICIENT_FUNDS,B.errors.NONCE_EXPIRED,B.errors.REPLACEMENT_UNDERPRICED];class ai{constructor(){ii.checkAbstract(new.target,ai),we(this,"_isSigner",!0)}getBalance(t){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)}))}getTransactionCount(t){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)}))}estimateGas(t){return ni(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const e=yield Ae(this.checkTransaction(t));return yield this.provider.estimateGas(e)}))}call(t,e){return ni(this,void 0,void 0,(function*(){this._checkProvider("call");const r=yield Ae(this.checkTransaction(t));return yield this.provider.call(r,e)}))}sendTransaction(t){return ni(this,void 0,void 0,(function*(){this._checkProvider("sendTransaction");const e=yield this.populateTransaction(t),r=yield this.signTransaction(e);return yield this.provider.sendTransaction(r)}))}getChainId(){return ni(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}getFeeData(){return ni(this,void 0,void 0,(function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()}))}resolveName(t){return ni(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)}))}checkTransaction(t){for(const e in t)-1===oi.indexOf(e)&&ii.throwArgumentError("invalid transaction key: "+e,"transaction",t);const e=_e(t);return null==e.from?e.from=this.getAddress():e.from=Promise.all([Promise.resolve(e.from),this.getAddress()]).then(e=>(e[0].toLowerCase()!==e[1].toLowerCase()&&ii.throwArgumentError("from address mismatch","transaction",t),e[0])),e}populateTransaction(t){return ni(this,void 0,void 0,(function*(){const e=yield Ae(this.checkTransaction(t));null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>ni(this,void 0,void 0,(function*(){if(null==t)return null;const e=yield this.resolveName(t);return null==e&&ii.throwArgumentError("provided ENS name resolves to null","tx.to",t),e}))),e.to.catch(t=>{}));const r=null!=e.maxFeePerGas||null!=e.maxPriorityFeePerGas;if(null==e.gasPrice||2!==e.type&&!r?0!==e.type&&1!==e.type||!r||ii.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t):ii.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t),2!==e.type&&null!=e.type||null==e.maxFeePerGas||null==e.maxPriorityFeePerGas)if(0===e.type||1===e.type)null==e.gasPrice&&(e.gasPrice=this.getGasPrice());else{const t=yield this.getFeeData();if(null==e.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(e.type=2,null!=e.gasPrice){const t=e.gasPrice;delete e.gasPrice,e.maxFeePerGas=t,e.maxPriorityFeePerGas=t}else null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(r&&ii.throwError("network does not support EIP-1559",B.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==e.gasPrice&&(e.gasPrice=t.gasPrice),e.type=0):ii.throwError("failed to get consistent fee data",B.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else 2===e.type&&(null==e.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null==e.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else e.type=2;return null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{if(si.indexOf(t.code)>=0)throw t;return ii.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",B.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,tx:e})})),null==e.chainId?e.chainId=this.getChainId():e.chainId=Promise.all([Promise.resolve(e.chainId),this.getChainId()]).then(e=>(0!==e[1]&&e[0]!==e[1]&&ii.throwArgumentError("chainId address mismatch","transaction",t),e[0])),yield Ae(e)}))}_checkProvider(t){this.provider||ii.throwError("missing provider",B.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class ui extends ai{constructor(t,e){super(),we(this,"address",t),we(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{ii.throwError(t,B.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(t,e,r){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(t){return new ui(this.address,t)}}var hi=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};const li=new B("contracts/5.0.3");function ci(t,e){return hi(this,void 0,void 0,(function*(){const r=yield e;try{return Rr(r)}catch(t){}return t||li.throwError("a provider or signer is needed to resolve ENS names",B.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"}),yield t.resolveName(r)}))}function fi(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>fi(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return ci(t,e);if("tuple"===r.type)return fi(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>fi(t,e,r.arrayChildren)))}return Promise.resolve(e)}function di(t,e,r){return hi(this,void 0,void 0,(function*(){let n={};r.length===e.inputs.length+1&&"object"==typeof r[r.length-1]&&(n=_e(r.pop())),li.checkArgumentCount(r.length,e.inputs.length,"passed to contract"),t.signer?n.from?n.from=Ae({override:ci(t.signer,n.from),signer:t.signer.getAddress()}).then(t=>hi(this,void 0,void 0,(function*(){return Rr(t.signer)!==t.override&&li.throwError("Contract with a Signer cannot override from",B.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),t.override}))):n.from=t.signer.getAddress():n.from&&(n.from=ci(t.provider,n.from));const i=yield Ae({args:fi(t.signer||t.provider,r,e.inputs),address:t.resolvedAddress,overrides:Ae(n)||{}}),o={data:t.interface.encodeFunctionData(e,i.args),to:i.address},s=i.overrides;if(null!=s.nonce&&(o.nonce=fe.from(s.nonce).toNumber()),null!=s.gasLimit&&(o.gasLimit=fe.from(s.gasLimit)),null!=s.gasPrice&&(o.gasPrice=fe.from(s.gasPrice)),null!=s.from&&(o.from=s.from),null==o.gasLimit&&null!=e.gas&&(o.gasLimit=fe.from(e.gas).add(21e3)),s.value){const t=fe.from(s.value);t.isZero()||e.payable||li.throwError("non-payable method cannot override value",B.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:n.value}),o.value=t}delete n.nonce,delete n.gasLimit,delete n.gasPrice,delete n.from,delete n.value;const a=Object.keys(n).filter(t=>null!=n[t]);return a.length&&li.throwError("cannot override "+a.map(t=>JSON.stringify(t)).join(","),B.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:a}),o}))}function pi(t,e,r){const n=t.signer||t.provider;return function(...i){return hi(this,void 0,void 0,(function*(){let o=void 0;if(i.length===e.inputs.length+1&&"object"==typeof i[i.length-1]){const t=_e(i.pop());null!=t.blockTag&&(o=yield t.blockTag),delete t.blockTag,i.push(t)}null!=t.deployTransaction&&(yield t._deployed(o));const s=yield di(t,e,i),a=yield n.call(s,o);try{let n=t.interface.decodeFunctionResult(e,a);return r&&1===e.outputs.length&&(n=n[0]),n}catch(e){throw e.code===B.errors.CALL_EXCEPTION&&(e.address=t.address,e.args=i,e.transaction=s),e}}))}}function mi(t,e,r){return e.constant?pi(t,e,r):function(t,e){return function(...r){return hi(this,void 0,void 0,(function*(){t.signer||li.throwError("sending a transaction requires a signer",B.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),null!=t.deployTransaction&&(yield t._deployed());const n=yield di(t,e,r),i=yield t.signer.sendTransaction(n),o=i.wait.bind(i);return i.wait=e=>o(e).then(e=>(e.events=e.logs.map(r=>{let n=ke(r),i=null;try{i=t.interface.parseLog(r)}catch(t){}return i&&(n.args=i.args,n.decode=(e,r)=>t.interface.decodeEventLog(i.eventFragment,e,r),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),i}))}}(t,e)}function yi(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.map(t=>Array.isArray(t)?t.join("|"):t).join(":"):""):"*"}class gi{constructor(t,e){we(this,"tag",t),we(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){const e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{const r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}getEmit(t){return[t]}}class vi extends gi{constructor(){super("error",null)}}class wi extends gi{constructor(t,e,r,n){const i={address:t};let o=e.getEventTopic(r);n?(o!==n[0]&&li.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[o],super(yi(i),i),we(this,"address",t),we(this,"interface",e),we(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e);try{t.args=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}catch(e){t.args=null,t.decodeError=e}}getEmit(t){const e=function(t){const e=[],r=function(t,n){if(Array.isArray(n))for(let i in n){const o=t.slice();o.push(i);try{r(o,n[i])}catch(t){e.push({path:o,error:t})}}};return r([],t),e}(t.args);if(e.length)throw e[0].error;const r=(t.args||[]).slice();return r.push(t),r}}class bi extends gi{constructor(t,e){super("*",{address:t}),we(this,"address",t),we(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);try{const e=this.interface.parseLog(t);t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.args=e.args}catch(t){}}}class Ai{constructor(t,e,r){li.checkNew(new.target,Ai),we(this,"interface",be(new.target,"getInterface")(e)),null==r?(we(this,"provider",null),we(this,"signer",null)):ai.isSigner(r)?(we(this,"provider",r.provider||null),we(this,"signer",r)):ri.isProvider(r)?(we(this,"provider",r),we(this,"signer",null)):li.throwArgumentError("invalid signer or provider","signerOrProvider",r),we(this,"callStatic",{}),we(this,"estimateGas",{}),we(this,"functions",{}),we(this,"populateTransaction",{}),we(this,"filters",{});{const t={};Object.keys(this.interface.events).forEach(e=>{const r=this.interface.events[e];we(this.filters,e,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(r,t)})),t[r.name]||(t[r.name]=[]),t[r.name].push(e)}),Object.keys(t).forEach(e=>{const r=t[e];1===r.length?we(this.filters,e,this.filters[r[0]]):li.warn(`Duplicate definition of ${e} (${r.join(", ")})`)})}if(we(this,"_runningEvents",{}),we(this,"_wrappedEmits",{}),we(this,"address",t),this.provider)we(this,"resolvedAddress",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{we(this,"resolvedAddress",Promise.resolve(Rr(t)))}catch(t){li.throwError("provider is required to use ENS name as contract address",B.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}const n={},i={};Object.keys(this.interface.functions).forEach(t=>{const e=this.interface.functions[t];if(i[t])li.warn("Duplicate ABI entry for "+JSON.stringify(name));else{i[t]=!0;{const r=e.name;n[r]||(n[r]=[]),n[r].push(t)}null==this[t]&&we(this,t,mi(this,e,!0)),null==this.functions[t]&&we(this.functions,t,mi(this,e,!1)),null==this.callStatic[t]&&we(this.callStatic,t,pi(this,e,!0)),null==this.populateTransaction[t]&&we(this.populateTransaction,t,function(t,e){return function(...r){return hi(this,void 0,void 0,(function*(){return di(t,e,r)}))}}(this,e)),null==this.estimateGas[t]&&we(this.estimateGas,t,function(t,e){const r=t.signer||t.provider;return function(...n){return hi(this,void 0,void 0,(function*(){r||li.throwError("estimate require a provider or signer",B.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const i=yield di(t,e,n);return yield r.estimateGas(i)}))}}(this,e))}}),Object.keys(n).forEach(t=>{const e=n[t];if(e.length>1)return;const r=e[0];null==this[t]&&we(this,t,this[r]),null==this.functions[t]&&we(this.functions,t,this.functions[r]),null==this.callStatic[t]&&we(this.callStatic,t,this.callStatic[r]),null==this.populateTransaction[t]&&we(this.populateTransaction,t,this.populateTransaction[r]),null==this.estimateGas[t]&&we(this.estimateGas,t,this.estimateGas[r])})}static getContractAddress(t){return $r(t)}static getInterface(t){return Xn.isInterface(t)?t:new Xn(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&li.throwError("contract not deployed",B.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||li.throwError("sending a transactions require a signer",B.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const e=_e(t||{});return["from","to"].forEach((function(t){null!=e[t]&&li.throwError("cannot override "+t,B.errors.UNSUPPORTED_OPERATION,{operation:t})})),e.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new ui(t,this.provider));const e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&we(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return Qn.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new vi);if("event"===t)return this._normalizeRunningEvent(new gi("event",null));if("*"===t)return this._normalizeRunningEvent(new bi(this.address,this.interface));const e=this.interface.getEvent(t);return this._normalizeRunningEvent(new wi(this.address,this.interface,e))}if(t.topics&&t.topics.length>0){try{const e=t.topics[0];if("string"!=typeof e)throw new Error("invalid topic");const r=this.interface.getEvent(e);return this._normalizeRunningEvent(new wi(this.address,this.interface,r,t.topics))}catch(t){}const e={address:this.address,topics:t.topics};return this._normalizeRunningEvent(new gi(yi(e),e))}return this._normalizeRunningEvent(new bi(this.address,this.interface))}_checkRunningEvents(t){if(0===t.listenerCount()){delete this._runningEvents[t.tag];const e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}}_wrapEvent(t,e,r){const n=ke(e);return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),t.prepareEvent(n),n}_addEventListener(t,e,r){if(this.provider||li.throwError("events require a provider or a signer with a provider",B.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){const r=r=>{let n=this._wrapEvent(t,r,e);if(null==n.decodeError)try{const e=t.getEmit(n);this.emit(t.filter,...e)}catch(t){n.decodeError=t.error}null!=t.filter&&this.emit("event",n),null!=n.decodeError&&this.emit("error",n.decodeError,n)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){const n=this._getRunningEvent(t),i=_e(n.filter);return"string"==typeof e&&Z(e,32)?(null!=r&&li.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockHash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;const r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){const t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(const t in this._runningEvents){const e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}const e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;const r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}
|
|
16
16
|
/*! https://mths.be/punycode v1.4.1 by @mathias */var _i=2147483647,Mi=/^xn--/,Ei=/[^\x20-\x7E]/,ki=/[\x2E\u3002\uFF0E\uFF61]/g,Si={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},xi=Math.floor,Ui=String.fromCharCode;function Ni(t){throw new RangeError(Si[t])}function Pi(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function Ii(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+Pi((t=t.replace(ki,".")).split("."),e).join(".")}function Ti(t){for(var e,r,n=[],i=0,o=t.length;i<o;)(e=t.charCodeAt(i++))>=55296&&e<=56319&&i<o?56320==(64512&(r=t.charCodeAt(i++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--):n.push(e);return n}function Ri(t){return Pi(t,(function(t){var e="";return t>65535&&(e+=Ui((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=Ui(t)})).join("")}function $i(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function Ci(t,e,r){var n=0;for(t=r?xi(t/700):t>>1,t+=xi(t/e);t>455;n+=36)t=xi(t/35);return xi(n+36*t/(t+38))}function Oi(t){var e,r,n,i,o,s,a,u,h,l,c,f=[],d=t.length,p=0,m=128,y=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)t.charCodeAt(n)>=128&&Ni("not-basic"),f.push(t.charCodeAt(n));for(i=r>0?r+1:0;i<d;){for(o=p,s=1,a=36;i>=d&&Ni("invalid-input"),((u=(c=t.charCodeAt(i++))-48<10?c-22:c-65<26?c-65:c-97<26?c-97:36)>=36||u>xi((_i-p)/s))&&Ni("overflow"),p+=u*s,!(u<(h=a<=y?1:a>=y+26?26:a-y));a+=36)s>xi(_i/(l=36-h))&&Ni("overflow"),s*=l;y=Ci(p-o,e=f.length+1,0==o),xi(p/e)>_i-m&&Ni("overflow"),m+=xi(p/e),p%=e,f.splice(p++,0,m)}return Ri(f)}function ji(t){var e,r,n,i,o,s,a,u,h,l,c,f,d,p,m,y=[];for(f=(t=Ti(t)).length,e=128,r=0,o=72,s=0;s<f;++s)(c=t[s])<128&&y.push(Ui(c));for(n=i=y.length,i&&y.push("-");n<f;){for(a=_i,s=0;s<f;++s)(c=t[s])>=e&&c<a&&(a=c);for(a-e>xi((_i-r)/(d=n+1))&&Ni("overflow"),r+=(a-e)*d,e=a,s=0;s<f;++s)if((c=t[s])<e&&++r>_i&&Ni("overflow"),c==e){for(u=r,h=36;!(u<(l=h<=o?1:h>=o+26?26:h-o));h+=36)m=u-l,p=36-l,y.push(Ui($i(l+m%p,0))),u=xi(m/p);y.push(Ui($i(u,0))),o=Ci(r,d,n==i),r=0,++n}++r,++e}return y.join("")}function Bi(t){return Ii(t,(function(t){return Mi.test(t)?Oi(t.slice(4).toLowerCase()):t}))}function Fi(t){return Ii(t,(function(t){return Ei.test(t)?"xn--"+ji(t):t}))}var Di={decode:Ti,encode:Ri},Li={version:"1.4.1",ucs2:Di,toASCII:Fi,toUnicode:Bi,encode:ji,decode:Oi},zi=a(Object.freeze({__proto__:null,decode:Oi,encode:ji,toUnicode:Bi,toASCII:Fi,version:"1.4.1",ucs2:Di,default:Li})),qi=u((function(t,e){t.exports=function(t){function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=e(t),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:{},i={exports:{}};
|
|
17
17
|
/**
|
|
18
18
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
package/package.json
CHANGED