@skip-go/widget-web-component 3.6.6 → 3.6.7
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/build/324.index.js +1 -0
- package/build/394.index.js +1 -0
- package/build/557.index.js +1 -0
- package/build/559.index.js +2 -0
- package/build/559.index.js.LICENSE.txt +23 -0
- package/build/586.index.js +1 -0
- package/build/696.index.js +2 -0
- package/build/696.index.js.LICENSE.txt +17 -0
- package/build/838.index.js +2 -0
- package/build/838.index.js.LICENSE.txt +23 -0
- package/build/996.index.js +1 -0
- package/build/index.js +15 -9
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 696.index.js.LICENSE.txt */
|
|
2
|
+
export const id=696;export const ids=[696];export const modules={96696:(t,e,r)=>{r.d(e,{EthereumProvider:()=>_f});var i=r(50046),n=r.n(i),s=r(24661),o=r(91315),a=r(20635),c=r(67822),h=r(68032),u=r(21663),f=r(1427),d=r(27687),l=r(91311),p=r(38877),g=r(76282),m=r(57729),b=r(35672),v=r(17367),y=r(39907),w=r(1048).Buffer;function A(t){const[e,r]=t.split(":");return{namespace:e,reference:r}}function _(t,e=[]){const r=[];return Object.keys(t).forEach((i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...n.accounts)})),r}function M(t,e){return t.includes(":")?[t]:e.chains||[]}var I=Object.defineProperty,E=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,x=(t,e,r)=>e in t?I(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R=(t,e)=>{for(var r in e||(e={}))S.call(e,r)&&x(t,r,e[r]);if(E)for(var r of E(e))P.call(e,r)&&x(t,r,e[r]);return t};const N="react-native",O="browser",C="js";function T(){return typeof y<"u"&&typeof y.versions<"u"&&typeof y.versions.node<"u"}function q(){return!(0,a.getDocument)()&&!!(0,a.getNavigator)()&&"ReactNative"===navigator.product}function D(){return!T()&&!!(0,a.getNavigator)()&&!!(0,a.getDocument)()}function k(){return q()?N:T()?"node":D()?O:"unknown"}function B(){return(0,c.g)()||{name:"",description:"",url:"",icons:[""]}}function U(t,e,i){const n=function(){if(k()===N&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Platform)<"u"){const{OS:t,Version:e}=r.g.Platform;return[t,e].join("-")}const t=(0,s.o0)();if(null===t)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return"browser"===t.type?[e,t.name,t.version].join("-"):[e,t.version].join("-")}(),o=function(){var t;const e=k();return e===O?[e,(null==(t=(0,a.getLocation)())?void 0:t.host)||"unknown"].join(":"):e}();return[[t,e].join("-"),[C,i].join("-"),n,o].join("/")}function z(t,e){return t.filter((t=>e.includes(t))).length===t.length}function j(t){return Object.fromEntries(t.entries())}function L(t){return new Map(Object.entries(t))}function F(t=o.FIVE_MINUTES,e){const r=(0,o.toMiliseconds)(t||o.FIVE_MINUTES);let i,n,s;return{resolve:t=>{s&&i&&(clearTimeout(s),i(t))},reject:t=>{s&&n&&(clearTimeout(s),n(t))},done:()=>new Promise(((t,o)=>{s=setTimeout((()=>{o(new Error(e))}),r),i=t,n=o}))}}function K(t,e,r){return new Promise((async(i,n)=>{const s=setTimeout((()=>n(new Error(r))),e);try{i(await t)}catch(t){n(t)}clearTimeout(s)}))}function H(t,e){if("string"==typeof e&&e.startsWith(`${t}:`))return e;if("topic"===t.toLowerCase()){if("string"!=typeof e)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}if("id"===t.toLowerCase()){if("number"!=typeof e)throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function $(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if("topic"===e&&"string"==typeof r)i.topic=r;else{if("id"!==e||!Number.isInteger(Number(r)))throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);i.id=Number(r)}return i}function V(t,e){return(0,o.fromMiliseconds)((e||Date.now())+(0,o.toMiliseconds)(t))}function J(t){return Date.now()>=(0,o.toMiliseconds)(t)}function Q(t,e){return`${t}${e?`:${e}`:""}`}function G(t=[],e=[]){return[...new Set([...t,...e])]}function Y(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function W(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}function Z(){return typeof y<"u"&&"true"===y.env.IS_VITEST}function X(t){return w.from(t,"base64").toString("utf-8")}var tt,et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof r.g<"u"?r.g:typeof self<"u"?self:{},rt={exports:{}};tt=rt,function(){var t="input is invalid type",e="object"==typeof window,r=e?window:{};r.JS_SHA3_NO_WINDOW&&(e=!1);var i=!e&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof y&&y.versions&&y.versions.node?r=et:i&&(r=self);var n=!r.JS_SHA3_NO_COMMON_JS&&tt.exports,s=!r.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",o="0123456789abcdef".split(""),a=[4,1024,262144,67108864],c=[0,8,16,24],h=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],f=[128,256],d=["hex","buffer","arrayBuffer","array","digest"],l={128:168,256:136};(r.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),s&&(r.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 p=function(t,e,r){return function(i){return new N(t,e,t).update(i)[r]()}},g=function(t,e,r){return function(i,n){return new N(t,e,n).update(i)[r]()}},m=function(t,e,r){return function(e,i,n,s){return _["cshake"+t].update(e,i,n,s)[r]()}},b=function(t,e,r){return function(e,i,n,s){return _["kmac"+t].update(e,i,n,s)[r]()}},v=function(t,e,r,i){for(var n=0;n<d.length;++n){var s=d[n];t[s]=e(r,i,s)}return t},w=function(t,e){var r=p(t,e,"hex");return r.create=function(){return new N(t,e,t)},r.update=function(t){return r.create().update(t)},v(r,p,t,e)},A=[{name:"keccak",padding:[1,256,65536,16777216],bits:u,createMethod:w},{name:"sha3",padding:[6,1536,393216,100663296],bits:u,createMethod:w},{name:"shake",padding:[31,7936,2031616,520093696],bits:f,createMethod:function(t,e){var r=g(t,e,"hex");return r.create=function(r){return new N(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},v(r,g,t,e)}},{name:"cshake",padding:a,bits:f,createMethod:function(t,e){var r=l[t],i=m(t,0,"hex");return i.create=function(i,n,s){return n||s?new N(t,e,i).bytepad([n,s],r):_["shake"+t].create(i)},i.update=function(t,e,r,n){return i.create(e,r,n).update(t)},v(i,m,t,e)}},{name:"kmac",padding:a,bits:f,createMethod:function(t,e){var r=l[t],i=b(t,0,"hex");return i.create=function(i,n,s){return new O(t,e,n).bytepad(["KMAC",s],r).bytepad([i],r)},i.update=function(t,e,r,n){return i.create(t,r,n).update(e)},v(i,b,t,e)}}],_={},M=[],I=0;I<A.length;++I)for(var E=A[I],S=E.bits,P=0;P<S.length;++P){var x=E.name+"_"+S[P];if(M.push(x),_[x]=E.createMethod(S[P],E.padding),"sha3"!==E.name){var R=E.name+S[P];M.push(R),_[R]=_[x]}}function N(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 i=0;i<50;++i)this.s[i]=0}function O(t,e,r){N.call(this,t,e,r)}N.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var r,i=typeof e;if("string"!==i){if("object"!==i)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);r=!0}for(var n,o,a=this.blocks,h=this.byteCount,u=e.length,f=this.blockCount,d=0,l=this.s;d<u;){if(this.reset)for(this.reset=!1,a[0]=this.block,n=1;n<f+1;++n)a[n]=0;if(r)for(n=this.start;d<u&&n<h;++d)a[n>>2]|=e[d]<<c[3&n++];else for(n=this.start;d<u&&n<h;++d)(o=e.charCodeAt(d))<128?a[n>>2]|=o<<c[3&n++]:o<2048?(a[n>>2]|=(192|o>>6)<<c[3&n++],a[n>>2]|=(128|63&o)<<c[3&n++]):o<55296||o>=57344?(a[n>>2]|=(224|o>>12)<<c[3&n++],a[n>>2]|=(128|o>>6&63)<<c[3&n++],a[n>>2]|=(128|63&o)<<c[3&n++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++d)),a[n>>2]|=(240|o>>18)<<c[3&n++],a[n>>2]|=(128|o>>12&63)<<c[3&n++],a[n>>2]|=(128|o>>6&63)<<c[3&n++],a[n>>2]|=(128|63&o)<<c[3&n++]);if(this.lastByteIndex=n,n>=h){for(this.start=n-h,this.block=a[f],n=0;n<f;++n)l[n]^=a[n];C(l),this.reset=!0}else this.start=n}return this},N.prototype.encode=function(t,e){var r=255&t,i=1,n=[r];for(r=255&(t>>=8);r>0;)n.unshift(r),r=255&(t>>=8),++i;return e?n.push(i):n.unshift(i),this.update(n),n.length},N.prototype.encodeString=function(e){var r,i=typeof e;if("string"!==i){if("object"!==i)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);r=!0}var n=0,o=e.length;if(r)n=o;else for(var a=0;a<e.length;++a){var c=e.charCodeAt(a);c<128?n+=1:c<2048?n+=2:c<55296||c>=57344?n+=3:(c=65536+((1023&c)<<10|1023&e.charCodeAt(++a)),n+=4)}return n+=this.encode(8*n),this.update(e),n},N.prototype.bytepad=function(t,e){for(var r=this.encode(e),i=0;i<t.length;++i)r+=this.encodeString(t[i]);var n=e-r%e,s=[];return s.length=n,this.update(s),this},N.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,i=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)i[e]^=t[e];C(i)}},N.prototype.toString=N.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,s=0,a=0,c="";a<i;){for(s=0;s<e&&a<i;++s,++a)t=r[s],c+=o[t>>4&15]+o[15&t]+o[t>>12&15]+o[t>>8&15]+o[t>>20&15]+o[t>>16&15]+o[t>>28&15]+o[t>>24&15];a%e==0&&(C(r),s=0)}return n&&(t=r[s],c+=o[t>>4&15]+o[15&t],n>1&&(c+=o[t>>12&15]+o[t>>8&15]),n>2&&(c+=o[t>>20&15]+o[t>>16&15])),c},N.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,i=this.outputBlocks,n=this.extraBytes,s=0,o=0,a=this.outputBits>>3;t=n?new ArrayBuffer(i+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(t);o<i;){for(s=0;s<e&&o<i;++s,++o)c[o]=r[s];o%e==0&&C(r)}return n&&(c[s]=r[s],t=t.slice(0,a)),t},N.prototype.buffer=N.prototype.arrayBuffer,N.prototype.digest=N.prototype.array=function(){this.finalize();for(var t,e,r=this.blockCount,i=this.s,n=this.outputBlocks,s=this.extraBytes,o=0,a=0,c=[];a<n;){for(o=0;o<r&&a<n;++o,++a)t=a<<2,e=i[o],c[t]=255&e,c[t+1]=e>>8&255,c[t+2]=e>>16&255,c[t+3]=e>>24&255;a%r==0&&C(i)}return s&&(t=a<<2,e=i[o],c[t]=255&e,s>1&&(c[t+1]=e>>8&255),s>2&&(c[t+2]=e>>16&255)),c},O.prototype=new N,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),N.prototype.finalize.call(this)};var C=function(t){var e,r,i,n,s,o,a,c,u,f,d,l,p,g,m,b,v,y,w,A,_,M,I,E,S,P,x,R,N,O,C,T,q,D,k,B,U,z,j,L,F,K,H,$,V,J,Q,G,Y,W,Z,X,tt,et,rt,it,nt,st,ot,at,ct,ht,ut;for(i=0;i<48;i+=2)n=t[0]^t[10]^t[20]^t[30]^t[40],s=t[1]^t[11]^t[21]^t[31]^t[41],o=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],c=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],d=t[7]^t[17]^t[27]^t[37]^t[47],e=(l=t[8]^t[18]^t[28]^t[38]^t[48])^(o<<1|a>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(a<<1|o>>>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=n^(c<<1|u>>>31),r=s^(u<<1|c>>>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=o^(f<<1|d>>>31),r=a^(d<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=c^(l<<1|p>>>31),r=u^(p<<1|l>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(n<<1|s>>>31),r=d^(s<<1|n>>>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,g=t[0],m=t[1],J=t[11]<<4|t[10]>>>28,Q=t[10]<<4|t[11]>>>28,R=t[20]<<3|t[21]>>>29,N=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ct=t[30]<<9|t[31]>>>23,K=t[40]<<18|t[41]>>>14,H=t[41]<<18|t[40]>>>14,D=t[2]<<1|t[3]>>>31,k=t[3]<<1|t[2]>>>31,b=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,G=t[22]<<10|t[23]>>>22,Y=t[23]<<10|t[22]>>>22,O=t[33]<<13|t[32]>>>19,C=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,ut=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,B=t[14]<<6|t[15]>>>26,U=t[15]<<6|t[14]>>>26,y=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,W=t[34]<<15|t[35]>>>17,Z=t[35]<<15|t[34]>>>17,T=t[45]<<29|t[44]>>>3,q=t[44]<<29|t[45]>>>3,E=t[6]<<28|t[7]>>>4,S=t[7]<<28|t[6]>>>4,it=t[17]<<23|t[16]>>>9,nt=t[16]<<23|t[17]>>>9,z=t[26]<<25|t[27]>>>7,j=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,$=t[8]<<27|t[9]>>>5,V=t[9]<<27|t[8]>>>5,P=t[18]<<20|t[19]>>>12,x=t[19]<<20|t[18]>>>12,st=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,L=t[38]<<8|t[39]>>>24,F=t[39]<<8|t[38]>>>24,M=t[48]<<14|t[49]>>>18,I=t[49]<<14|t[48]>>>18,t[0]=g^~b&y,t[1]=m^~v&w,t[10]=E^~P&R,t[11]=S^~x&N,t[20]=D^~B&z,t[21]=k^~U&j,t[30]=$^~J&G,t[31]=V^~Q&Y,t[40]=et^~it&st,t[41]=rt^~nt&ot,t[2]=b^~y&A,t[3]=v^~w&_,t[12]=P^~R&O,t[13]=x^~N&C,t[22]=B^~z&L,t[23]=U^~j&F,t[32]=J^~G&W,t[33]=Q^~Y&Z,t[42]=it^~st&at,t[43]=nt^~ot&ct,t[4]=y^~A&M,t[5]=w^~_&I,t[14]=R^~O&T,t[15]=N^~C&q,t[24]=z^~L&K,t[25]=j^~F&H,t[34]=G^~W&X,t[35]=Y^~Z&tt,t[44]=st^~at&ht,t[45]=ot^~ct&ut,t[6]=A^~M&g,t[7]=_^~I&m,t[16]=O^~T&E,t[17]=C^~q&S,t[26]=L^~K&D,t[27]=F^~H&k,t[36]=W^~X&$,t[37]=Z^~tt&V,t[46]=at^~ht&et,t[47]=ct^~ut&rt,t[8]=M^~g&b,t[9]=I^~m&v,t[18]=T^~E&P,t[19]=q^~S&x,t[28]=K^~D&B,t[29]=H^~k&U,t[38]=X^~$&J,t[39]=tt^~V&Q,t[48]=ht^~et&it,t[49]=ut^~rt&nt,t[0]^=h[i],t[1]^=h[i+1]};if(n)tt.exports=_;else for(I=0;I<M.length;++I)r[M[I]]=_[M[I]]}();var it=rt.exports;let nt=!1,st=!1;const ot={debug:1,default:2,info:2,warning:3,error:4,off:5};let at=ot.default,ct=null;const ht=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch{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 ut,ft;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(ut||(ut={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(ft||(ft={}));const dt="0123456789abcdef";class lt{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==ot[r]&&this.throwArgumentError("invalid log level name","logLevel",t),!(at>ot[r])&&console.log.apply(console,e)}debug(...t){this._log(lt.levels.DEBUG,t)}info(...t){this._log(lt.levels.INFO,t)}warn(...t){this._log(lt.levels.WARNING,t)}makeError(t,e,r){if(st)return this.makeError("censored error",e,{});e||(e=lt.errors.UNKNOWN_ERROR),r||(r={});const i=[];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+=dt[e[t]>>4],r+=dt[15&e[t]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch{i.push(t+"="+JSON.stringify(r[t].toString()))}})),i.push(`code=${e}`),i.push(`version=${this.version}`);const n=t;let s="";switch(e){case ft.NUMERIC_FAULT:{s="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":s+="-"+e;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case ft.CALL_EXCEPTION:case ft.INSUFFICIENT_FUNDS:case ft.MISSING_NEW:case ft.NONCE_EXPIRED:case ft.REPLACEMENT_UNDERPRICED:case ft.TRANSACTION_REPLACED:case ft.UNPREDICTABLE_GAS_LIMIT:s=e}s&&(t+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),i.length&&(t+=" ("+i.join(", ")+")");const o=new Error(t);return o.reason=n,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,lt.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,i){t||this.throwError(e,r,i)}assertArgument(t,e,r,i){t||this.throwArgumentError(e,r,i)}checkNormalize(t){ht&&this.throwError("platform missing String.prototype.normalize",lt.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ht})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,lt.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,lt.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,lt.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,lt.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||null==t)&&this.throwError("missing new",lt.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",lt.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||null==t)&&this.throwError("missing new",lt.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return ct||(ct=new lt("logger/5.7.0")),ct}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",lt.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),nt){if(!t)return;this.globalLogger().throwError("error censorship permanent",lt.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}st=!!t,nt=!!e}static setLogLevel(t){const e=ot[t.toLowerCase()];null!=e?at=e:lt.globalLogger().warn("invalid log level - "+t)}static from(t){return new lt(t)}}lt.errors=ft,lt.levels=ut;const pt=new lt("bytes/5.7.0");function gt(t){return!!t.toHexString}function mt(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return mt(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function bt(t){return"number"==typeof t&&t==t&&t%1==0}function vt(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t||!bt(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!bt(r)||r<0||r>=256)return!1}return!0}function yt(t,e){if(e||(e={}),"number"==typeof t){pt.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),mt(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),gt(t)&&(t=t.toHexString()),wt(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":pt.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let t=0;t<r.length;t+=2)i.push(parseInt(r.substring(t,t+2),16));return mt(new Uint8Array(i))}return vt(t)?mt(new Uint8Array(t)):pt.throwArgumentError("invalid arrayify value","value",t)}function wt(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const At="0123456789abcdef";function _t(t,e){if(e||(e={}),"number"==typeof t){pt.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=At[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),gt(t))return t.toHexString();if(wt(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":pt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(vt(t)){let e="0x";for(let r=0;r<t.length;r++){let i=t[r];e+=At[(240&i)>>4]+At[15&i]}return e}return pt.throwArgumentError("invalid hexlify value","value",t)}function Mt(t,e,r){return"string"!=typeof t?t=_t(t):(!wt(t)||t.length%2)&&pt.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function It(t,e){for("string"!=typeof t?t=_t(t):wt(t)||pt.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&pt.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(function(t){return wt(t)&&!(t.length%2)||vt(t)}(t)){let r=yt(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=_t(r.slice(0,32)),e.s=_t(r.slice(32,64))):65===r.length?(e.r=_t(r.slice(0,32)),e.s=_t(r.slice(32,64)),e.v=r[64]):pt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:pt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=_t(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=yt(t)).length>e&&pt.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),mt(r)}(yt(e._vs),32);e._vs=_t(r);const i=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=i:e.recoveryParam!==i&&pt.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const n=_t(r);null==e.s?e.s=n:e.s!==n&&pt.throwArgumentError("signature v mismatch _vs","signature",t)}if(null==e.recoveryParam)null==e.v?pt.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&&pt.throwArgumentError("signature recoveryParam mismatch v","signature",t)}null!=e.r&&wt(e.r)?e.r=It(e.r,32):pt.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&wt(e.s)?e.s=It(e.s,32):pt.throwArgumentError("signature missing or invalid s","signature",t);const r=yt(e.s);r[0]>=128&&pt.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=_t(r);e._vs&&(wt(e._vs)||pt.throwArgumentError("signature invalid _vs","signature",t),e._vs=It(e._vs,32)),null==e._vs?e._vs=i:e._vs!==i&&pt.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function St(t){return"0x"+it.keccak_256(yt(t))}var Pt={exports:{}},xt=function(t){var e=t.default;if("function"==typeof e){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})})),r}(Object.freeze({__proto__:null,default:{}}));!function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.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 s;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<"u"&&typeof window.Buffer<"u"?window.Buffer:xt.Buffer}catch{}function o(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function a(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function c(t,e,i,n){for(var s=0,o=0,a=Math.min(t.length,i),c=e;c<a;c++){var h=t.charCodeAt(c)-48;s*=n,o=h>=49?h-49+10:h>=17?h-17+10:h,r(h>=0&&o<n,"Invalid character"),s+=o}return s}function h(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){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"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){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 n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if("be"===i)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===i)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=a(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=a(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,h=0,u=r;u<a;u+=i)h=c(t,u,u+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==o){var f=1;for(h=c(t,u,t.length,e),u=0;u<o;u++)f*=e;this.imuln(f),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this._strip()},n.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},n.prototype._move=function(t){h(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},typeof Symbol<"u"&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch{n.prototype.inspect=u}else n.prototype.inspect=u;function u(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","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"],d=[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],l=[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];function p(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var h=1;h<i;h++){for(var u=c>>>26,f=67108863&c,d=Math.min(h,e.length-1),l=Math.max(0,h-t.length+1);l<=d;l++){var p=h-l|0;u+=(o=(n=0|t.words[p])*(s=0|e.words[l])+f)/67108864|0,f=67108863&o}r.words[h]=0|f,c=0|u}return 0!==c?r.words[h]=0|c:r.length--,r._strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],c=(16777215&(a<<n|s)).toString(16);s=a>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),i=0!==s||o!==this.length-1?f[6-c.length]+c+i:c+i}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var h=d[t],u=l[t];i="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(u).toString(t);i=(p=p.idivn(u)).isZero()?g+i:f[h-g.length]+g+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.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},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,"byte array longer than desired length"),r(s>0,"Requested array length <= 0");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](o,n),o},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|i;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===s?(r<t.length&&(t[r++]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|i;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===s?(r>=0&&(t[r--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.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},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.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},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.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()},n.prototype.ior=function(t){return r(!(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.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()},n.prototype.iand=function(t){return r(!(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(!(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;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,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},n.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)},n.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,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var g=function(t,e,r){var i,n,s,o=t.words,a=e.words,c=r.words,h=0,u=0|o[0],f=8191&u,d=u>>>13,l=0|o[1],p=8191&l,g=l>>>13,m=0|o[2],b=8191&m,v=m>>>13,y=0|o[3],w=8191&y,A=y>>>13,_=0|o[4],M=8191&_,I=_>>>13,E=0|o[5],S=8191&E,P=E>>>13,x=0|o[6],R=8191&x,N=x>>>13,O=0|o[7],C=8191&O,T=O>>>13,q=0|o[8],D=8191&q,k=q>>>13,B=0|o[9],U=8191&B,z=B>>>13,j=0|a[0],L=8191&j,F=j>>>13,K=0|a[1],H=8191&K,$=K>>>13,V=0|a[2],J=8191&V,Q=V>>>13,G=0|a[3],Y=8191&G,W=G>>>13,Z=0|a[4],X=8191&Z,tt=Z>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ct=8191&at,ht=at>>>13,ut=0|a[8],ft=8191&ut,dt=ut>>>13,lt=0|a[9],pt=8191<,gt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(h+(i=Math.imul(f,L))|0)+((8191&(n=(n=Math.imul(f,F))+Math.imul(d,L)|0))<<13)|0;h=((s=Math.imul(d,F))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,L),n=(n=Math.imul(p,F))+Math.imul(g,L)|0,s=Math.imul(g,F);var bt=(h+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,$)|0)+Math.imul(d,H)|0))<<13)|0;h=((s=s+Math.imul(d,$)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(b,L),n=(n=Math.imul(b,F))+Math.imul(v,L)|0,s=Math.imul(v,F),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(g,H)|0,s=s+Math.imul(g,$)|0;var vt=(h+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(d,J)|0))<<13)|0;h=((s=s+Math.imul(d,Q)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,L),n=(n=Math.imul(w,F))+Math.imul(A,L)|0,s=Math.imul(A,F),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,$)|0)+Math.imul(v,H)|0,s=s+Math.imul(v,$)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(g,J)|0,s=s+Math.imul(g,Q)|0;var yt=(h+(i=i+Math.imul(f,Y)|0)|0)+((8191&(n=(n=n+Math.imul(f,W)|0)+Math.imul(d,Y)|0))<<13)|0;h=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(M,L),n=(n=Math.imul(M,F))+Math.imul(I,L)|0,s=Math.imul(I,F),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(A,H)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(b,J)|0,n=(n=n+Math.imul(b,Q)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,Q)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,Y)|0,s=s+Math.imul(g,W)|0;var wt=(h+(i=i+Math.imul(f,X)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(d,X)|0))<<13)|0;h=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(S,L),n=(n=Math.imul(S,F))+Math.imul(P,L)|0,s=Math.imul(P,F),i=i+Math.imul(M,H)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(I,H)|0,s=s+Math.imul(I,$)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(A,J)|0,s=s+Math.imul(A,Q)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,W)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,X)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,X)|0,s=s+Math.imul(g,tt)|0;var At=(h+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(d,rt)|0))<<13)|0;h=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(R,L),n=(n=Math.imul(R,F))+Math.imul(N,L)|0,s=Math.imul(N,F),i=i+Math.imul(S,H)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(P,H)|0,s=s+Math.imul(P,$)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,Q)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,Q)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,W)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,W)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(v,X)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(g,rt)|0,s=s+Math.imul(g,it)|0;var _t=(h+(i=i+Math.imul(f,st)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(d,st)|0))<<13)|0;h=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(C,L),n=(n=Math.imul(C,F))+Math.imul(T,L)|0,s=Math.imul(T,F),i=i+Math.imul(R,H)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(N,H)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(S,J)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,Q)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(w,X)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(A,X)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(g,st)|0,s=s+Math.imul(g,ot)|0;var Mt=(h+(i=i+Math.imul(f,ct)|0)|0)+((8191&(n=(n=n+Math.imul(f,ht)|0)+Math.imul(d,ct)|0))<<13)|0;h=((s=s+Math.imul(d,ht)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(D,L),n=(n=Math.imul(D,F))+Math.imul(k,L)|0,s=Math.imul(k,F),i=i+Math.imul(C,H)|0,n=(n=n+Math.imul(C,$)|0)+Math.imul(T,H)|0,s=s+Math.imul(T,$)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,Q)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,W)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(M,X)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(b,st)|0,n=(n=n+Math.imul(b,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(g,ct)|0,s=s+Math.imul(g,ht)|0;var It=(h+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,dt)|0)+Math.imul(d,ft)|0))<<13)|0;h=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,L),n=(n=Math.imul(U,F))+Math.imul(z,L)|0,s=Math.imul(z,F),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,$)|0)+Math.imul(k,H)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(C,J)|0,n=(n=n+Math.imul(C,Q)|0)+Math.imul(T,J)|0,s=s+Math.imul(T,Q)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(S,X)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(P,X)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ht)|0)+Math.imul(v,ct)|0,s=s+Math.imul(v,ht)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(g,ft)|0,s=s+Math.imul(g,dt)|0;var Et=(h+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,gt)|0)+Math.imul(d,pt)|0))<<13)|0;h=((s=s+Math.imul(d,gt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,$))+Math.imul(z,H)|0,s=Math.imul(z,$),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(k,J)|0,s=s+Math.imul(k,Q)|0,i=i+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,W)|0)+Math.imul(T,Y)|0,s=s+Math.imul(T,W)|0,i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,i=i+Math.imul(w,ct)|0,n=(n=n+Math.imul(w,ht)|0)+Math.imul(A,ct)|0,s=s+Math.imul(A,ht)|0,i=i+Math.imul(b,ft)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(v,ft)|0,s=s+Math.imul(v,dt)|0;var St=(h+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;h=((s=s+Math.imul(g,gt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(U,J),n=(n=Math.imul(U,Q))+Math.imul(z,J)|0,s=Math.imul(z,Q),i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,W)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,W)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(T,X)|0,s=s+Math.imul(T,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,i=i+Math.imul(M,ct)|0,n=(n=n+Math.imul(M,ht)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ht)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(A,ft)|0,s=s+Math.imul(A,dt)|0;var Pt=(h+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,gt)|0)+Math.imul(v,pt)|0))<<13)|0;h=((s=s+Math.imul(v,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,W))+Math.imul(z,Y)|0,s=Math.imul(z,W),i=i+Math.imul(D,X)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(T,rt)|0,s=s+Math.imul(T,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(S,ct)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(P,ct)|0,s=s+Math.imul(P,ht)|0,i=i+Math.imul(M,ft)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ft)|0,s=s+Math.imul(I,dt)|0;var xt=(h+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,gt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((s=s+Math.imul(A,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,X),n=(n=Math.imul(U,tt))+Math.imul(z,X)|0,s=Math.imul(z,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(C,st)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(T,st)|0,s=s+Math.imul(T,ot)|0,i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(N,ct)|0,s=s+Math.imul(N,ht)|0,i=i+Math.imul(S,ft)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(P,ft)|0,s=s+Math.imul(P,dt)|0;var Rt=(h+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(I,pt)|0))<<13)|0;h=((s=s+Math.imul(I,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(z,rt)|0,s=Math.imul(z,it),i=i+Math.imul(D,st)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(T,ct)|0,s=s+Math.imul(T,ht)|0,i=i+Math.imul(R,ft)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,dt)|0;var Nt=(h+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,gt)|0)+Math.imul(P,pt)|0))<<13)|0;h=((s=s+Math.imul(P,gt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(z,st)|0,s=Math.imul(z,ot),i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ht)|0)+Math.imul(k,ct)|0,s=s+Math.imul(k,ht)|0,i=i+Math.imul(C,ft)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(T,ft)|0,s=s+Math.imul(T,dt)|0;var Ot=(h+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,gt)|0)+Math.imul(N,pt)|0))<<13)|0;h=((s=s+Math.imul(N,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(U,ct),n=(n=Math.imul(U,ht))+Math.imul(z,ct)|0,s=Math.imul(z,ht),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,dt)|0)+Math.imul(k,ft)|0,s=s+Math.imul(k,dt)|0;var Ct=(h+(i=i+Math.imul(C,pt)|0)|0)+((8191&(n=(n=n+Math.imul(C,gt)|0)+Math.imul(T,pt)|0))<<13)|0;h=((s=s+Math.imul(T,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,ft),n=(n=Math.imul(U,dt))+Math.imul(z,ft)|0,s=Math.imul(z,dt);var Tt=(h+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,gt)|0)+Math.imul(k,pt)|0))<<13)|0;h=((s=s+Math.imul(k,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var qt=(h+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,gt))+Math.imul(z,pt)|0))<<13)|0;return h=((s=Math.imul(z,gt))+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,c[0]=mt,c[1]=bt,c[2]=vt,c[3]=yt,c[4]=wt,c[5]=At,c[6]=_t,c[7]=Mt,c[8]=It,c[9]=Et,c[10]=St,c[11]=Pt,c[12]=xt,c[13]=Rt,c[14]=Nt,c[15]=Ot,c[16]=Ct,c[17]=Tt,c[18]=qt,0!==h&&(c[19]=h,r.length++),r};function m(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,c=Math.min(s,e.length-1),h=Math.max(0,s-t.length+1);h<=c;h++){var u=s-h,f=(0|t.words[u])*(0|e.words[h]),d=67108863&f;a=67108863&(d=d+a|0),n+=(o=(o=o+(f/67108864|0)|0)+(d>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function b(t,e,r){return m(t,e,r)}Math.imul||(g=p),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?g(this,t,e):r<63?p(this,t,e):r<1024?m(this,t,e):b(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),b(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var s=(0|this.words[n])*t,o=(67108863&s)+(67108863&i);i>>=26,i+=s/67108864|0,i+=o>>>26,this.words[n]=67108863&o}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var s=r.sqr();i<e.length;i++,s=s.sqr())0!==e[i]&&(r=r.mul(s));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,c=(0|this.words[e])-a<<i;this.words[e]=c|o,o=a>>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,c=i;if(n-=o,n=Math.max(0,n),c){for(var h=0;h<o;h++)c.words[h]=this.words[h];c.length=o}if(0!==o)if(this.length>o)for(this.length-=o,h=0;h<this.length;h++)this.words[h]=this.words[h+o];else this.words[0]=0,this.length=1;var u=0;for(h=this.length-1;h>=0&&(0!==u||h>=n);h--){var f=0|this.words[h];this.words[h]=u<<26-s|f>>>s,u=f&a}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i||!(this.words[i]&n))},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.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)},n.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},n.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()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,s=t.length+i;this._expand(s);var o,a=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+a;var c=(0|t.words[n])*e;a=((o-=67108863&c)>>26)-(c/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)a=(o=(0|this.words[n+i])+a)>>26,this.words[n+i]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,n=0;n<this.length;n++)a=(o=-(0|this.words[n])+a)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,o=0|s.words[s.length-1];0!=(r=26-this._countBits(o))&&(s=s.ushln(r),i.iushln(r),o=0|s.words[s.length-1]);var a,c=i.length-s.length;if("mod"!==e){(a=new n(null)).length=c+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var u=i.clone()._ishlnsubmul(s,1,c);0===u.negative&&(i=u,a&&(a.words[c]=1));for(var f=c-1;f>=0;f--){var d=67108864*(0|i.words[s.length+f])+(0|i.words[s.length+f-1]);for(d=Math.min(d/o|0,67108863),i._ishlnsubmul(s,d,f);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,f),i.isZero()||(i.negative^=1);a&&(a.words[f]=d)}return a&&a._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(s=a.div.neg()),"div"!==e&&(o=a.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:s,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(s=a.div.neg()),{div:s,mod:a.mod}):this.negative&t.negative?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var s,o,a},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.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,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(i*n+(0|this.words[s]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*i;this.words[n]=s/t|0,i=s%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),o=new n(0),a=new n(0),c=new n(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var d=0,l=1;!(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||o.isOdd())&&(s.iadd(u),o.isub(f)),s.iushrn(1),o.iushrn(1);for(var p=0,g=1;!(i.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(u),c.isub(f)),a.iushrn(1),c.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(a),o.isub(c)):(i.isub(e),a.isub(s),c.isub(o))}return{a,b:c,gcd:i.iushln(h)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),a=new n(0),c=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var h=0,u=1;!(i.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(i.iushrn(h);h-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var f=0,d=1;!(s.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(s.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);i.cmp(s)>=0?(i.isub(s),o.isub(a)):(s.isub(i),a.isub(o))}return(e=0===i.cmpn(1)?o:a).cmpn(0)<0&&e.iadd(t),e},n.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 i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var s=n,o=i;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.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},n.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 i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new I(t)},n.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)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.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 y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function A(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function I(t){if("string"==typeof t){var e=n._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 E(t){I.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.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 i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(w,y),w.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},w.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 i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(A,y),i(_,y),i(M,y),M.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new w;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},I.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},I.prototype._verify2=function(t,e){r(!(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},I.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},I.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},I.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)},I.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},I.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)},I.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},I.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},I.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},I.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},I.prototype.isqr=function(t){return this.imul(t,t.clone())},I.prototype.sqr=function(t){return this.mul(t,t)},I.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),o=0;!s.isZero()&&0===s.andln(1);)o++,s.iushrn(1);r(!s.isZero());var a=new n(1).toRed(this),c=a.redNeg(),h=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new n(2*u*u).toRed(this);0!==this.pow(u,h).cmp(c);)u.redIAdd(c);for(var f=this.pow(u,s),d=this.pow(t,s.addn(1).iushrn(1)),l=this.pow(t,s),p=o;0!==l.cmp(a);){for(var g=l,m=0;0!==g.cmp(a);m++)g=g.redSqr();r(m<p);var b=this.pow(f,new n(1).iushln(p-m-1));d=d.redMul(b),f=b.redSqr(),l=l.redMul(f),p=m}return d},I.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},I.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var s=r[0],o=0,a=0,c=e.bitLength()%26;for(0===c&&(c=26),i=e.length-1;i>=0;i--){for(var h=e.words[i],u=c-1;u>=0;u--){var f=h>>u&1;s!==r[0]&&(s=this.sqr(s)),0!==f||0!==o?(o<<=1,o|=f,(4==++a||0===i&&0===u)&&(s=this.mul(s,r[o]),a=0,o=0)):a=0}c=26}return s},I.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},I.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new E(t)},i(E,I),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,et)}(Pt);var Rt=Pt.exports;const Nt="bignumber/5.7.0";var Ot=Rt.BN;const Ct=new lt(Nt),Tt={},qt=9007199254740991;let Dt=!1;class kt{constructor(t,e){t!==Tt&&Ct.throwError("cannot call constructor directly; use BigNumber.from",lt.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return Ut(zt(this).fromTwos(t))}toTwos(t){return Ut(zt(this).toTwos(t))}abs(){return"-"===this._hex[0]?kt.from(this._hex.substring(1)):this}add(t){return Ut(zt(this).add(zt(t)))}sub(t){return Ut(zt(this).sub(zt(t)))}div(t){return kt.from(t).isZero()&&jt("division-by-zero","div"),Ut(zt(this).div(zt(t)))}mul(t){return Ut(zt(this).mul(zt(t)))}mod(t){const e=zt(t);return e.isNeg()&&jt("division-by-zero","mod"),Ut(zt(this).umod(e))}pow(t){const e=zt(t);return e.isNeg()&&jt("negative-power","pow"),Ut(zt(this).pow(e))}and(t){const e=zt(t);return(this.isNegative()||e.isNeg())&&jt("unbound-bitwise-result","and"),Ut(zt(this).and(e))}or(t){const e=zt(t);return(this.isNegative()||e.isNeg())&&jt("unbound-bitwise-result","or"),Ut(zt(this).or(e))}xor(t){const e=zt(t);return(this.isNegative()||e.isNeg())&&jt("unbound-bitwise-result","xor"),Ut(zt(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&jt("negative-width","mask"),Ut(zt(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&jt("negative-width","shl"),Ut(zt(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&jt("negative-width","shr"),Ut(zt(this).shrn(t))}eq(t){return zt(this).eq(zt(t))}lt(t){return zt(this).lt(zt(t))}lte(t){return zt(this).lte(zt(t))}gt(t){return zt(this).gt(zt(t))}gte(t){return zt(this).gte(zt(t))}isNegative(){return"-"===this._hex[0]}isZero(){return zt(this).isZero()}toNumber(){try{return zt(this).toNumber()}catch{jt("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Ct.throwError("this platform does not support BigInt",lt.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?Dt||(Dt=!0,Ct.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?Ct.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",lt.errors.UNEXPECTED_ARGUMENT,{}):Ct.throwError("BigNumber.toString does not accept parameters",lt.errors.UNEXPECTED_ARGUMENT,{})),zt(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof kt)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new kt(Tt,Bt(t)):t.match(/^-?[0-9]+$/)?new kt(Tt,Bt(new Ot(t))):Ct.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&jt("underflow","BigNumber.from",t),(t>=qt||t<=-qt)&&jt("overflow","BigNumber.from",t),kt.from(String(t));const e=t;if("bigint"==typeof e)return kt.from(e.toString());if(vt(e))return kt.from(_t(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return kt.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(wt(t)||"-"===t[0]&&wt(t.substring(1))))return kt.from(t)}return Ct.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function Bt(t){if("string"!=typeof t)return Bt(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&Ct.throwArgumentError("invalid hex","value",t),"0x00"===(t=Bt(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 Ut(t){return kt.from(Bt(t))}function zt(t){const e=kt.from(t).toHexString();return"-"===e[0]?new Ot("-"+e.substring(3),16):new Ot(e.substring(2),16)}function jt(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),Ct.throwError(t,lt.errors.NUMERIC_FAULT,i)}const Lt=new lt(Nt),Ft={},Kt=kt.from(0),Ht=kt.from(-1);function $t(t,e,r,i){const n={fault:e,operation:r};return void 0!==i&&(n.value=i),Lt.throwError(t,lt.errors.NUMERIC_FAULT,n)}let Vt="0";for(;Vt.length<256;)Vt+=Vt;function Jt(t){if("number"!=typeof t)try{t=kt.from(t).toNumber()}catch{}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Vt.substring(0,t):Lt.throwArgumentError("invalid decimal size","decimals",t)}function Qt(t,e){null==e&&(e=0);const r=Jt(e),i=(t=kt.from(t)).lt(Kt);i&&(t=t.mul(Ht));let n=t.mod(r).toString();for(;n.length<r.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=t.div(r).toString();return t=1===r.length?s:s+"."+n,i&&(t="-"+t),t}function Gt(t,e){null==e&&(e=0);const r=Jt(e);("string"!=typeof t||!t.match(/^-?[0-9.]+$/))&&Lt.throwArgumentError("invalid decimal value","value",t);const i="-"===t.substring(0,1);i&&(t=t.substring(1)),"."===t&&Lt.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&Lt.throwArgumentError("too many decimal points","value",t);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");"0"===o[o.length-1];)o=o.substring(0,o.length-1);for(o.length>r.length-1&&$t("fractional component exceeds decimals","underflow","parseFixed"),""===o&&(o="0");o.length<r.length-1;)o+="0";const a=kt.from(s),c=kt.from(o);let h=a.mul(r).add(c);return i&&(h=h.mul(Ht)),h}class Yt{constructor(t,e,r,i){t!==Ft&&Lt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",lt.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=e,this.width=r,this.decimals=i,this.name=(e?"":"u")+"fixed"+String(r)+"x"+String(i),this._multiplier=Jt(i),Object.freeze(this)}static from(t){if(t instanceof Yt)return t;"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,r=128,i=18;if("string"==typeof t){if("fixed"!==t)if("ufixed"===t)e=!1;else{const n=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);n||Lt.throwArgumentError("invalid fixed format","format",t),e="u"!==n[1],r=parseInt(n[2]),i=parseInt(n[3])}}else if(t){const n=(e,r,i)=>null==t[e]?i:(typeof t[e]!==r&&Lt.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=n("signed","boolean",e),r=n("width","number",r),i=n("decimals","number",i)}return r%8&&Lt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),i>80&&Lt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new Yt(Ft,e,r,i)}}class Wt{constructor(t,e,r,i){t!==Ft&&Lt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",lt.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=i,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&Lt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=Gt(this._value,this.format.decimals),r=Gt(t._value,t.format.decimals);return Wt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=Gt(this._value,this.format.decimals),r=Gt(t._value,t.format.decimals);return Wt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=Gt(this._value,this.format.decimals),r=Gt(t._value,t.format.decimals);return Wt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=Gt(this._value,this.format.decimals),r=Gt(t._value,t.format.decimals);return Wt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=Wt.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return this.isNegative()&&r&&(e=e.subUnsafe(Zt.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");1===t.length&&t.push("0");let e=Wt.from(t[0],this.format);const r=!t[1].match(/^(0*)$/);return!this.isNegative()&&r&&(e=e.addUnsafe(Zt.toFormat(e.format))),e}round(t){null==t&&(t=0);const e=this.toString().split(".");if(1===e.length&&e.push("0"),(t<0||t>80||t%1)&&Lt.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const r=Wt.from("1"+Vt.substring(0,t),this.format),i=Xt.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(i).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(t){return null==t?this._hex:(t%8&&Lt.throwArgumentError("invalid byte width","width",t),It(kt.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8))}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return Wt.fromString(this._value,t)}static fromValue(t,e,r){return null==r&&null!=e&&!function(t){return null!=t&&(kt.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||wt(t)||"bigint"==typeof t||vt(t))}(e)&&(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),Wt.fromString(Qt(t,e),Yt.from(r))}static fromString(t,e){null==e&&(e="fixed");const r=Yt.from(e),i=Gt(t,r.decimals);!r.signed&&i.lt(Kt)&&$t("unsigned value cannot be negative","overflow","value",t);let n=null;r.signed?n=i.toTwos(r.width).toHexString():(n=i.toHexString(),n=It(n,r.width/8));const s=Qt(i,r.decimals);return new Wt(Ft,n,s,r)}static fromBytes(t,e){null==e&&(e="fixed");const r=Yt.from(e);if(yt(t).length>r.width/8)throw new Error("overflow");let i=kt.from(t);r.signed&&(i=i.fromTwos(r.width));const n=i.toTwos((r.signed?0:1)+r.width).toHexString(),s=Qt(i,r.decimals);return new Wt(Ft,n,s,r)}static from(t,e){if("string"==typeof t)return Wt.fromString(t,e);if(vt(t))return Wt.fromBytes(t,e);try{return Wt.fromValue(t,0,e)}catch(t){if(t.code!==lt.errors.INVALID_ARGUMENT)throw t}return Lt.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const Zt=Wt.from(1),Xt=Wt.from("0.5"),te=new lt("strings/5.7.0");var ee,re;function ie(t,e,r,i,n){if(t===re.BAD_PREFIX||t===re.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i<r.length&&r[i]>>6==2;i++)t++;return t}return t===re.OVERRUN?r.length-e-1:0}function ne(t,e=ee.current){e!=ee.current&&(te.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const i=t.charCodeAt(e);if(i<128)r.push(i);else if(i<2048)r.push(i>>6|192),r.push(63&i|128);else if(55296==(64512&i)){e++;const n=t.charCodeAt(e);if(e>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const s=65536+((1023&i)<<10)+(1023&n);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return yt(r)}function se(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,i={};return t.split(",").forEach((t=>{let n=t.split(":");r+=parseInt(n[0],16),i[r]=e(n[1])})),i}function oe(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 i=e+parseInt(r[0],16);return e=parseInt(r[1],16),{l:i,h:e}}))}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(ee||(ee={})),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"}(re||(re={})),Object.freeze({error:function(t,e,r,i,n){return te.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:ie,replace:function(t,e,r,i,n){return t===re.OVERLONG?(i.push(n),0):(i.push(65533),ie(t,e,r))}}),oe("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"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((t=>parseInt(t,16))),se("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"),se("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"),se("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})),oe("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");const ae="hash/5.7.0";function ce(t,e){null==e&&(e=1);const r=[],i=r.forEach,n=function(t,e){i.call(t,(function(t){e>0&&Array.isArray(t)?n(t,e-1):r.push(t)}))};return n(t,e),r}function he(t){return 1&t?~t>>1:t>>1}function ue(t,e){let r=Array(t);for(let i=0,n=-1;i<t;i++)r[i]=n+=1+e();return r}function fe(t,e){let r=Array(t);for(let i=0,n=0;i<t;i++)r[i]=n+=he(e());return r}function de(t,e){let r=ue(t(),t),i=t(),n=ue(i,t),s=function(t,e){let r=Array(t);for(let i=0;i<t;i++)r[i]=1+e();return r}(i,t);for(let t=0;t<i;t++)for(let e=0;e<s[t];e++)r.push(n[t]+e);return e?r.map((t=>e[t])):r}function le(t,e,r){let i=Array(t).fill(void 0).map((()=>[]));for(let n=0;n<e;n++)fe(t,r).forEach(((t,e)=>i[e].push(t)));return i}function pe(t,e){let r=1+e(),i=e(),n=function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(r)}return e}(e);return ce(le(n.length,1+t,e).map(((t,e)=>{const s=t[0],o=t.slice(1);return Array(n[e]).fill(void 0).map(((t,e)=>{let n=e*i;return[s+e*r,o.map((t=>t+n))]}))})))}function ge(t,e){return le(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}const me=function(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,s=[0,1];for(let t=1;t<i;t++)s.push(n+=r());let o=r(),a=e;e+=o;let c=0,h=0;function u(){return 0==c&&(h=h<<8|t[e++],c=8),h>>--c&1}const f=Math.pow(2,31),d=f>>>1,l=d>>1,p=f-1;let g=0;for(let t=0;t<31;t++)g=g<<1|u();let m=[],b=0,v=f;for(;;){let t=Math.floor(((g-b+1)*n-1)/v),e=0,r=i;for(;r-e>1;){let i=e+r>>>1;t<s[i]?r=i:e=i}if(0==e)break;m.push(e);let o=b+Math.floor(v*s[e]/n),a=b+Math.floor(v*s[e+1]/n)-1;for(;!((o^a)&d);)g=g<<1&p|u(),o=o<<1&p,a=a<<1&p|1;for(;o&~a&l;)g=g&d|g<<1&p>>>1|u(),o=o<<1^d,a=(a^d)<<1|d|1;b=o,v=1+a-o}let y=i-4;return m.map((e=>{switch(e-y){case 3:return y+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return y+256+(t[a++]<<8|t[a++]);case 1:return y+t[a++];default:return e-1}}))}(t))}(function(t){t=atob(t);const e=[];for(let r=0;r<t.length;r++)e.push(t.charCodeAt(r));return yt(e)}("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="));function be(t){return"string"==typeof t&&(t=ne(t)),St(function(t){const e=t.map((t=>yt(t))),r=e.reduce(((t,e)=>t+e.length),0),i=new Uint8Array(r);return e.reduce(((t,e)=>(i.set(e,t),t+e.length)),0),mt(i)}([ne("Ethereum Signed Message:\n"),ne(String(t.length)),t]))}new Set(de(me)),new Set(de(me)),function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(pe(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(ge(r,t))}!function(t){const e={};for(let r=0;r<t.length;r++){const i=t[r];e[i[0]]=i[1]}}(ce(e))}(me),function(t){let e=de(t).sort(((t,e)=>t-e));!function r(){let i=[];for(;;){let n=de(t,e);if(0==n.length)break;i.push({set:new Set(n),node:r()})}i.sort(((t,e)=>e.set.size-t.set.size));let n=t(),s=n%3;n=n/3|0;let o=!!(1&n);return n>>=1,{branches:i,valid:s,fe0f:o,save:1==n,check:2==n}}()}(me),new lt(ae),new Uint8Array(32).fill(0),new lt("rlp/5.7.0");const ve=new lt("address/5.7.0");function ye(t){wt(t,20)||ve.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 i=yt(St(r));for(let t=0;t<40;t+=2)i[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&i[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const we={};for(let t=0;t<10;t++)we[String(t)]=String(t);for(let t=0;t<26;t++)we[String.fromCharCode(65+t)]=String(10+t);const Ae=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function _e(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}new lt("properties/5.7.0"),new lt(ae),new Uint8Array(32).fill(0),kt.from(-1);const Me=kt.from(0),Ie=kt.from(1);kt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),It(Ie.toHexString(),32),It(Me.toHexString(),32);var Ee={},Se={},Pe=xe;function xe(t,e){if(!t)throw new Error(e||"Assertion failed")}xe.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Re={exports:{}};"function"==typeof Object.create?Re.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Re.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var Ne=Pe,Oe=Re.exports;function Ce(t,e){return!(55296!=(64512&t.charCodeAt(e))||e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function Te(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function qe(t){return 1===t.length?"0"+t:t}function De(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}Se.inherits=Oe,Se.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=63&s|128):Ce(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=63&s|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=63&s|128)}else for(n=0;n<t.length;n++)r[n]=0|t[n];return r},Se.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=qe(t[r].toString(16));return e},Se.htonl=Te,Se.toHex32=function(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];"little"===e&&(n=Te(n)),r+=De(n.toString(16))}return r},Se.zero2=qe,Se.zero8=De,Se.join32=function(t,e,r,i){var n=r-e;Ne(n%4==0);for(var s=new Array(n/4),o=0,a=e;o<s.length;o++,a+=4){var c;c="big"===i?t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],s[o]=c>>>0}return s},Se.split32=function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];"big"===e?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},Se.rotr32=function(t,e){return t>>>e|t<<32-e},Se.rotl32=function(t,e){return t<<e|t>>>32-e},Se.sum32=function(t,e){return t+e>>>0},Se.sum32_3=function(t,e,r){return t+e+r>>>0},Se.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},Se.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},Se.sum64=function(t,e,r,i){var n=t[e],s=i+t[e+1]>>>0,o=(s<i?1:0)+r+n;t[e]=o>>>0,t[e+1]=s},Se.sum64_hi=function(t,e,r,i){return(e+i>>>0<e?1:0)+t+r>>>0},Se.sum64_lo=function(t,e,r,i){return e+i>>>0},Se.sum64_4_hi=function(t,e,r,i,n,s,o,a){var c=0,h=e;return c+=(h=h+i>>>0)<e?1:0,c+=(h=h+s>>>0)<s?1:0,t+r+n+o+(c+=(h=h+a>>>0)<a?1:0)>>>0},Se.sum64_4_lo=function(t,e,r,i,n,s,o,a){return e+i+s+a>>>0},Se.sum64_5_hi=function(t,e,r,i,n,s,o,a,c,h){var u=0,f=e;return u+=(f=f+i>>>0)<e?1:0,u+=(f=f+s>>>0)<s?1:0,u+=(f=f+a>>>0)<a?1:0,t+r+n+o+c+(u+=(f=f+h>>>0)<h?1:0)>>>0},Se.sum64_5_lo=function(t,e,r,i,n,s,o,a,c,h){return e+i+s+a+h>>>0},Se.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},Se.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},Se.shr64_hi=function(t,e,r){return t>>>r},Se.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0};var ke={},Be=Se,Ue=Pe;function ze(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}ke.BlockHash=ze,ze.prototype.update=function(t,e){if(t=Be.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Be.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},ze.prototype.digest=function(t){return this.update(this._pad()),Ue(null===this.pending),this._digest(t)},ze.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,"big"===this.endian){for(var s=8;s<this.padLength;s++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s<this.padLength;s++)i[n++]=0;return i};var je={},Le={},Fe=Se.rotr32;function Ke(t,e,r){return t&e^~t&r}function He(t,e,r){return t&e^t&r^e&r}function $e(t,e,r){return t^e^r}Le.ft_1=function(t,e,r,i){return 0===t?Ke(e,r,i):1===t||3===t?$e(e,r,i):2===t?He(e,r,i):void 0},Le.ch32=Ke,Le.maj32=He,Le.p32=$e,Le.s0_256=function(t){return Fe(t,2)^Fe(t,13)^Fe(t,22)},Le.s1_256=function(t){return Fe(t,6)^Fe(t,11)^Fe(t,25)},Le.g0_256=function(t){return Fe(t,7)^Fe(t,18)^t>>>3},Le.g1_256=function(t){return Fe(t,17)^Fe(t,19)^t>>>10};var Ve=Se,Je=ke,Qe=Le,Ge=Ve.rotl32,Ye=Ve.sum32,We=Ve.sum32_5,Ze=Qe.ft_1,Xe=Je.BlockHash,tr=[1518500249,1859775393,2400959708,3395469782];function er(){if(!(this instanceof er))return new er;Xe.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ve.inherits(er,Xe);var rr=er;er.blockSize=512,er.outSize=160,er.hmacStrength=80,er.padLength=64,er.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=Ge(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4];for(i=0;i<r.length;i++){var h=~~(i/20),u=We(Ge(n,5),Ze(h,s,o,a),c,r[i],tr[h]);c=a,a=o,o=Ge(s,30),s=n,n=u}this.h[0]=Ye(this.h[0],n),this.h[1]=Ye(this.h[1],s),this.h[2]=Ye(this.h[2],o),this.h[3]=Ye(this.h[3],a),this.h[4]=Ye(this.h[4],c)},er.prototype._digest=function(t){return"hex"===t?Ve.toHex32(this.h,"big"):Ve.split32(this.h,"big")};var ir=Se,nr=ke,sr=Le,or=Pe,ar=ir.sum32,cr=ir.sum32_4,hr=ir.sum32_5,ur=sr.ch32,fr=sr.maj32,dr=sr.s0_256,lr=sr.s1_256,pr=sr.g0_256,gr=sr.g1_256,mr=nr.BlockHash,br=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function vr(){if(!(this instanceof vr))return new vr;mr.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=br,this.W=new Array(64)}ir.inherits(vr,mr);var yr=vr;vr.blockSize=512,vr.outSize=256,vr.hmacStrength=192,vr.padLength=64,vr.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=cr(gr(r[i-2]),r[i-7],pr(r[i-15]),r[i-16]);var n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],h=this.h[5],u=this.h[6],f=this.h[7];for(or(this.k.length===r.length),i=0;i<r.length;i++){var d=hr(f,lr(c),ur(c,h,u),this.k[i],r[i]),l=ar(dr(n),fr(n,s,o));f=u,u=h,h=c,c=ar(a,d),a=o,o=s,s=n,n=ar(d,l)}this.h[0]=ar(this.h[0],n),this.h[1]=ar(this.h[1],s),this.h[2]=ar(this.h[2],o),this.h[3]=ar(this.h[3],a),this.h[4]=ar(this.h[4],c),this.h[5]=ar(this.h[5],h),this.h[6]=ar(this.h[6],u),this.h[7]=ar(this.h[7],f)},vr.prototype._digest=function(t){return"hex"===t?ir.toHex32(this.h,"big"):ir.split32(this.h,"big")};var wr=Se,Ar=yr;function _r(){if(!(this instanceof _r))return new _r;Ar.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}wr.inherits(_r,Ar);var Mr=_r;_r.blockSize=512,_r.outSize=224,_r.hmacStrength=192,_r.padLength=64,_r.prototype._digest=function(t){return"hex"===t?wr.toHex32(this.h.slice(0,7),"big"):wr.split32(this.h.slice(0,7),"big")};var Ir=Se,Er=ke,Sr=Pe,Pr=Ir.rotr64_hi,xr=Ir.rotr64_lo,Rr=Ir.shr64_hi,Nr=Ir.shr64_lo,Or=Ir.sum64,Cr=Ir.sum64_hi,Tr=Ir.sum64_lo,qr=Ir.sum64_4_hi,Dr=Ir.sum64_4_lo,kr=Ir.sum64_5_hi,Br=Ir.sum64_5_lo,Ur=Er.BlockHash,zr=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function jr(){if(!(this instanceof jr))return new jr;Ur.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=zr,this.W=new Array(160)}Ir.inherits(jr,Ur);var Lr=jr;function Fr(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function Kr(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function Hr(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function $r(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function Vr(t,e){var r=Pr(t,e,28)^Pr(e,t,2)^Pr(e,t,7);return r<0&&(r+=4294967296),r}function Jr(t,e){var r=xr(t,e,28)^xr(e,t,2)^xr(e,t,7);return r<0&&(r+=4294967296),r}function Qr(t,e){var r=Pr(t,e,14)^Pr(t,e,18)^Pr(e,t,9);return r<0&&(r+=4294967296),r}function Gr(t,e){var r=xr(t,e,14)^xr(t,e,18)^xr(e,t,9);return r<0&&(r+=4294967296),r}function Yr(t,e){var r=Pr(t,e,1)^Pr(t,e,8)^Rr(t,e,7);return r<0&&(r+=4294967296),r}function Wr(t,e){var r=xr(t,e,1)^xr(t,e,8)^Nr(t,e,7);return r<0&&(r+=4294967296),r}function Zr(t,e){var r=Pr(t,e,19)^Pr(e,t,29)^Rr(t,e,6);return r<0&&(r+=4294967296),r}function Xr(t,e){var r=xr(t,e,19)^xr(e,t,29)^Nr(t,e,6);return r<0&&(r+=4294967296),r}jr.blockSize=1024,jr.outSize=512,jr.hmacStrength=192,jr.padLength=128,jr.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=Zr(r[i-4],r[i-3]),s=Xr(r[i-4],r[i-3]),o=r[i-14],a=r[i-13],c=Yr(r[i-30],r[i-29]),h=Wr(r[i-30],r[i-29]),u=r[i-32],f=r[i-31];r[i]=qr(n,s,o,a,c,h,u,f),r[i+1]=Dr(n,s,o,a,c,h,u,f)}},jr.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],c=this.h[5],h=this.h[6],u=this.h[7],f=this.h[8],d=this.h[9],l=this.h[10],p=this.h[11],g=this.h[12],m=this.h[13],b=this.h[14],v=this.h[15];Sr(this.k.length===r.length);for(var y=0;y<r.length;y+=2){var w=b,A=v,_=Qr(f,d),M=Gr(f,d),I=Fr(f,0,l,0,g),E=Kr(0,d,0,p,0,m),S=this.k[y],P=this.k[y+1],x=r[y],R=r[y+1],N=kr(w,A,_,M,I,E,S,P,x,R),O=Br(w,A,_,M,I,E,S,P,x,R);w=Vr(i,n),A=Jr(i,n),_=Hr(i,0,s,0,a),M=$r(0,n,0,o,0,c);var C=Cr(w,A,_,M),T=Tr(w,A,_,M);b=g,v=m,g=l,m=p,l=f,p=d,f=Cr(h,u,N,O),d=Tr(u,u,N,O),h=a,u=c,a=s,c=o,s=i,o=n,i=Cr(N,O,C,T),n=Tr(N,O,C,T)}Or(this.h,0,i,n),Or(this.h,2,s,o),Or(this.h,4,a,c),Or(this.h,6,h,u),Or(this.h,8,f,d),Or(this.h,10,l,p),Or(this.h,12,g,m),Or(this.h,14,b,v)},jr.prototype._digest=function(t){return"hex"===t?Ir.toHex32(this.h,"big"):Ir.split32(this.h,"big")};var ti=Se,ei=Lr;function ri(){if(!(this instanceof ri))return new ri;ei.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}ti.inherits(ri,ei);var ii=ri;ri.blockSize=1024,ri.outSize=384,ri.hmacStrength=192,ri.padLength=128,ri.prototype._digest=function(t){return"hex"===t?ti.toHex32(this.h.slice(0,12),"big"):ti.split32(this.h.slice(0,12),"big")},je.sha1=rr,je.sha224=Mr,je.sha256=yr,je.sha384=ii,je.sha512=Lr;var ni={},si=Se,oi=ke,ai=si.rotl32,ci=si.sum32,hi=si.sum32_3,ui=si.sum32_4,fi=oi.BlockHash;function di(){if(!(this instanceof di))return new di;fi.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function li(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function pi(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function gi(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}si.inherits(di,fi),ni.ripemd160=di,di.blockSize=512,di.outSize=160,di.hmacStrength=192,di.padLength=64,di.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],s=this.h[3],o=this.h[4],a=r,c=i,h=n,u=s,f=o,d=0;d<80;d++){var l=ci(ai(ui(r,li(d,i,n,s),t[mi[d]+e],pi(d)),vi[d]),o);r=o,o=s,s=ai(n,10),n=i,i=l,l=ci(ai(ui(a,li(79-d,c,h,u),t[bi[d]+e],gi(d)),yi[d]),f),a=f,f=u,u=ai(h,10),h=c,c=l}l=hi(this.h[1],n,u),this.h[1]=hi(this.h[2],s,f),this.h[2]=hi(this.h[3],o,a),this.h[3]=hi(this.h[4],r,c),this.h[4]=hi(this.h[0],i,h),this.h[0]=l},di.prototype._digest=function(t){return"hex"===t?si.toHex32(this.h,"little"):si.split32(this.h,"little")};var mi=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],bi=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],vi=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],yi=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],wi=Se,Ai=Pe;function _i(t,e,r){if(!(this instanceof _i))return new _i(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(wi.toArray(e,r))}var Mi=_i;function Ii(t,e,r){return r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(e??r.path)}},t(r,r.exports),r.exports}_i.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),Ai(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},_i.prototype.update=function(t,e){return this.inner.update(t,e),this},_i.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)},function(t){var e=t;e.utils=Se,e.common=ke,e.sha=je,e.ripemd=ni,e.hmac=Mi,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(Ee);var Ei=Si;function Si(t,e){if(!t)throw new Error(e||"Assertion failed")}Si.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Pi=Ii((function(t,e){var r=e;function i(t){return 1===t.length?"0"+t:t}function n(t){for(var e="",r=0;r<t.length;r++)e+=i(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var i=0;i<t.length;i++)r[i]=0|t[i];return r}if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16));else for(i=0;i<t.length;i++){var n=t.charCodeAt(i),s=n>>8,o=255&n;s?r.push(s,o):r.push(o)}return r},r.zero2=i,r.toHex=n,r.encode=function(t,e){return"hex"===e?n(t):t}})),xi=Ii((function(t,e){var r=e;r.assert=Ei,r.toArray=Pi.toArray,r.zero2=Pi.zero2,r.toHex=Pi.toHex,r.encode=Pi.encode,r.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<<e+1,s=t.clone(),o=0;o<i.length;o++){var a,c=s.andln(n-1);s.isOdd()?(a=c>(n>>1)-1?(n>>1)-c:c,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,c=t.andln(3)+n&3,h=e.andln(3)+s&3;3===c&&(c=-1),3===h&&(h=-1),o=1&c?3!=(i=t.andln(7)+n&7)&&5!==i||2!==h?c:-c:0,r[0].push(o),a=1&h?3!=(i=e.andln(7)+s&7)&&5!==i||2!==c?h:-h:0,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new Rt(t,"hex","le")}})),Ri=xi.getNAF,Ni=xi.getJSF,Oi=xi.assert;function Ci(t,e){this.type=t,this.p=new Rt(e.p,16),this.red=e.prime?Rt.red(e.prime):Rt.mont(this.p),this.zero=new Rt(0).toRed(this.red),this.one=new Rt(1).toRed(this.red),this.two=new Rt(2).toRed(this.red),this.n=e.n&&new Rt(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Ti=Ci;function qi(t,e){this.curve=t,this.type=e,this.precomputed=null}Ci.prototype.point=function(){throw new Error("Not implemented")},Ci.prototype.validate=function(){throw new Error("Not implemented")},Ci.prototype._fixedNafMul=function(t,e){Oi(t.precomputed);var r=t._getDoubles(),i=Ri(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var s,o,a=[];for(s=0;s<i.length;s+=r.step){o=0;for(var c=s+r.step-1;c>=s;c--)o=(o<<1)+i[c];a.push(o)}for(var h=this.jpoint(null,null,null),u=this.jpoint(null,null,null),f=n;f>0;f--){for(s=0;s<a.length;s++)(o=a[s])===f?u=u.mixedAdd(r.points[s]):o===-f&&(u=u.mixedAdd(r.points[s].neg()));h=h.add(u)}return h.toP()},Ci.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,s=Ri(e,r,this._bitLength),o=this.jpoint(null,null,null),a=s.length-1;a>=0;a--){for(var c=0;a>=0&&0===s[a];a--)c++;if(a>=0&&c++,o=o.dblp(c),a<0)break;var h=s[a];Oi(0!==h),o="affine"===t.type?h>0?o.mixedAdd(n[h-1>>1]):o.mixedAdd(n[-h-1>>1].neg()):h>0?o.add(n[h-1>>1]):o.add(n[-h-1>>1].neg())}return"affine"===t.type?o.toP():o},Ci.prototype._wnafMulAdd=function(t,e,r,i,n){var s,o,a,c=this._wnafT1,h=this._wnafT2,u=this._wnafT3,f=0;for(s=0;s<i;s++){var d=(a=e[s])._getNAFPoints(t);c[s]=d.wnd,h[s]=d.points}for(s=i-1;s>=1;s-=2){var l=s-1,p=s;if(1===c[l]&&1===c[p]){var g=[e[l],null,null,e[p]];0===e[l].y.cmp(e[p].y)?(g[1]=e[l].add(e[p]),g[2]=e[l].toJ().mixedAdd(e[p].neg())):0===e[l].y.cmp(e[p].y.redNeg())?(g[1]=e[l].toJ().mixedAdd(e[p]),g[2]=e[l].add(e[p].neg())):(g[1]=e[l].toJ().mixedAdd(e[p]),g[2]=e[l].toJ().mixedAdd(e[p].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],b=Ni(r[l],r[p]);for(f=Math.max(b[0].length,f),u[l]=new Array(f),u[p]=new Array(f),o=0;o<f;o++){var v=0|b[0][o],y=0|b[1][o];u[l][o]=m[3*(v+1)+(y+1)],u[p][o]=0,h[l]=g}}else u[l]=Ri(r[l],c[l],this._bitLength),u[p]=Ri(r[p],c[p],this._bitLength),f=Math.max(u[l].length,f),f=Math.max(u[p].length,f)}var w=this.jpoint(null,null,null),A=this._wnafT4;for(s=f;s>=0;s--){for(var _=0;s>=0;){var M=!0;for(o=0;o<i;o++)A[o]=0|u[o][s],0!==A[o]&&(M=!1);if(!M)break;_++,s--}if(s>=0&&_++,w=w.dblp(_),s<0)break;for(o=0;o<i;o++){var I=A[o];0!==I&&(I>0?a=h[o][I-1>>1]:I<0&&(a=h[o][-I-1>>1].neg()),w="affine"===a.type?w.mixedAdd(a):w.add(a))}}for(s=0;s<i;s++)h[s]=null;return n?w:w.toP()},Ci.BasePoint=qi,qi.prototype.eq=function(){throw new Error("Not implemented")},qi.prototype.validate=function(){return this.curve.validate(this)},Ci.prototype.decodePoint=function(t,e){t=xi.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?Oi(t[t.length-1]%2==0):7===t[0]&&Oi(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},qi.prototype.encodeCompressed=function(t){return this.encode(t,!0)},qi.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},qi.prototype.encode=function(t,e){return xi.encode(this._encode(e),t)},qi.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},qi.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},qi.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var s=0;s<t;s++)i=i.dbl();r.push(i)}return{step:t,points:r}},qi.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},qi.prototype._getBeta=function(){return null},qi.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var Di=Ii((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),ki=xi.assert;function Bi(t){Ti.call(this,"short",t),this.a=new Rt(t.a,16).toRed(this.red),this.b=new Rt(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Di(Bi,Ti);var Ui=Bi;function zi(t,e,r,i){Ti.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new Rt(e,16),this.y=new Rt(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function ji(t,e,r,i){Ti.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Rt(0)):(this.x=new Rt(e,16),this.y=new Rt(r,16),this.z=new Rt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Bi.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r,i;if(t.beta)e=new Rt(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new Rt(t.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(e))?r=s[0]:(r=s[1],ki(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return i=t.basis?t.basis.map((function(t){return{a:new Rt(t.a,16),b:new Rt(t.b,16)}})):this._getEndoBasis(r),{beta:e,lambda:r,basis:i}}},Bi.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:Rt.mont(t),r=new Rt(2).toRed(e).redInvm(),i=r.redNeg(),n=new Rt(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(n).fromRed(),i.redSub(n).fromRed()]},Bi.prototype._getEndoBasis=function(t){for(var e,r,i,n,s,o,a,c,h,u=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=t,d=this.n.clone(),l=new Rt(1),p=new Rt(0),g=new Rt(0),m=new Rt(1),b=0;0!==f.cmpn(0);){var v=d.div(f);c=d.sub(v.mul(f)),h=g.sub(v.mul(l));var y=m.sub(v.mul(p));if(!i&&c.cmp(u)<0)e=a.neg(),r=l,i=c.neg(),n=h;else if(i&&2==++b)break;a=c,d=f,f=c,g=l,l=h,m=p,p=y}s=c.neg(),o=h;var w=i.sqr().add(n.sqr());return s.sqr().add(o.sqr()).cmp(w)>=0&&(s=e,o=r),i.negative&&(i=i.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:i,b:n},{a:s,b:o}]},Bi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),c=n.mul(r.b),h=s.mul(i.b);return{k1:t.sub(o).sub(a),k2:c.add(h).neg()}},Bi.prototype.pointFromX=function(t,e){(t=new Rt(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},Bi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},Bi.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s<t.length;s++){var o=this._endoSplit(e[s]),a=t[s],c=a._getBeta();o.k1.negative&&(o.k1.ineg(),a=a.neg(!0)),o.k2.negative&&(o.k2.ineg(),c=c.neg(!0)),i[2*s]=a,i[2*s+1]=c,n[2*s]=o.k1,n[2*s+1]=o.k2}for(var h=this._wnafMulAdd(1,i,n,2*s,r),u=0;u<2*s;u++)i[u]=null,n[u]=null;return h},Di(zi,Ti.BasePoint),Bi.prototype.point=function(t,e,r){return new zi(this,t,e,r)},Bi.prototype.pointFromJSON=function(t,e){return zi.fromJSON(this,t,e)},zi.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},zi.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},zi.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(e){return t.point(e[0],e[1],r)}var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},zi.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},zi.prototype.isInfinity=function(){return this.inf},zi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},zi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},zi.prototype.getX=function(){return this.x.fromRed()},zi.prototype.getY=function(){return this.y.fromRed()},zi.prototype.mul=function(t){return t=new Rt(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},zi.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},zi.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},zi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},zi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},zi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Di(ji,Ti.BasePoint),Bi.prototype.jpoint=function(t,e,r){return new ji(this,t,e,r)},ji.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},ji.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},ji.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),u=h.redMul(a),f=i.redMul(h),d=c.redSqr().redIAdd(u).redISub(f).redISub(f),l=c.redMul(f.redISub(d)).redISub(s.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,l,p)},ji.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),h=c.redMul(o),u=r.redMul(c),f=a.redSqr().redIAdd(h).redISub(u).redISub(u),d=a.redMul(u.redISub(f)).redISub(n.redMul(h)),l=this.z.redMul(o);return this.curve.jpoint(f,d,l)},ji.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,s=this.x,o=this.y,a=this.z,c=a.redSqr().redSqr(),h=o.redAdd(o);for(e=0;e<t;e++){var u=s.redSqr(),f=h.redSqr(),d=f.redSqr(),l=u.redAdd(u).redIAdd(u).redIAdd(i.redMul(c)),p=s.redMul(f),g=l.redSqr().redISub(p.redAdd(p)),m=p.redISub(g),b=l.redMul(m);b=b.redIAdd(b).redISub(d);var v=h.redMul(a);e+1<t&&(c=c.redMul(d)),s=g,a=v,h=b}return this.curve.jpoint(s,h.redMul(n),a)},ji.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},ji.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var a=i.redAdd(i).redIAdd(i),c=a.redSqr().redISub(o).redISub(o),h=s.redIAdd(s);h=(h=h.redIAdd(h)).redIAdd(h),t=c,e=a.redMul(o.redISub(c)).redISub(h),r=this.y.redAdd(this.y)}else{var u=this.x.redSqr(),f=this.y.redSqr(),d=f.redSqr(),l=this.x.redAdd(f).redSqr().redISub(u).redISub(d);l=l.redIAdd(l);var p=u.redAdd(u).redIAdd(u),g=p.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),t=g.redISub(l).redISub(l),e=p.redMul(l.redISub(t)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},ji.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var a=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),c=a.redSqr().redISub(o).redISub(o);t=c;var h=s.redIAdd(s);h=(h=h.redIAdd(h)).redIAdd(h),e=a.redMul(o.redISub(c)).redISub(h),r=this.y.redAdd(this.y)}else{var u=this.z.redSqr(),f=this.y.redSqr(),d=this.x.redMul(f),l=this.x.redSub(u).redMul(this.x.redAdd(u));l=l.redAdd(l).redIAdd(l);var p=d.redIAdd(d),g=(p=p.redIAdd(p)).redAdd(p);t=l.redSqr().redISub(g),r=this.y.redAdd(this.z).redSqr().redISub(f).redISub(u);var m=f.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),e=l.redMul(p.redISub(t)).redISub(m)}return this.curve.jpoint(t,e,r)},ji.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),a=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(n)),c=e.redAdd(e),h=(c=c.redIAdd(c)).redMul(o),u=a.redSqr().redISub(h.redAdd(h)),f=h.redISub(u),d=o.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=a.redMul(f).redISub(d),p=r.redAdd(r).redMul(i);return this.curve.jpoint(u,l,p)},ji.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),s=n.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(i),a=(o=(o=(o=o.redIAdd(o)).redAdd(o).redIAdd(o)).redISub(s)).redSqr(),c=i.redIAdd(i);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var h=n.redIAdd(o).redSqr().redISub(s).redISub(a).redISub(c),u=e.redMul(h);u=(u=u.redIAdd(u)).redIAdd(u);var f=this.x.redMul(a).redISub(u);f=(f=f.redIAdd(f)).redIAdd(f);var d=this.y.redMul(h.redMul(c.redISub(h)).redISub(o.redMul(a)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=this.z.redAdd(o).redSqr().redISub(r).redISub(a);return this.curve.jpoint(f,d,l)},ji.prototype.mul=function(t,e){return t=new Rt(t,e),this.curve._wnafMul(this,t)},ji.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return 0===this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)},ji.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},ji.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},ji.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Li=Ii((function(t,e){var r=e;r.base=Ti,r.short=Ui,r.mont=null,r.edwards=null})),Fi=Ii((function(t,e){var r,i=e,n=xi.assert;function s(t){"short"===t.type?this.curve=new Li.short(t):"edwards"===t.type?this.curve=new Li.edwards(t):this.curve=new Li.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new s(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ee.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ee.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ee.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ee.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ee.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ee.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ee.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch{r=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ee.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Ki(t){if(!(this instanceof Ki))return new Ki(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Pi.toArray(t.entropy,t.entropyEnc||"hex"),r=Pi.toArray(t.nonce,t.nonceEnc||"hex"),i=Pi.toArray(t.pers,t.persEnc||"hex");Ei(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Hi=Ki;Ki.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},Ki.prototype._hmac=function(){return new Ee.hmac(this.hash,this.K)},Ki.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Ki.prototype.reseed=function(t,e,r,i){"string"!=typeof e&&(i=r,r=e,e=null),t=Pi.toArray(t,e),r=Pi.toArray(r,i),Ei(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Ki.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=Pi.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length<t;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var s=n.slice(0,t);return this._update(r),this._reseed++,Pi.encode(s,e)};var $i=xi.assert;function Vi(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Ji=Vi;Vi.fromPublic=function(t,e,r){return e instanceof Vi?e:new Vi(t,{pub:e,pubEnc:r})},Vi.fromPrivate=function(t,e,r){return e instanceof Vi?e:new Vi(t,{priv:e,privEnc:r})},Vi.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Vi.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Vi.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Vi.prototype._importPrivate=function(t,e){this.priv=new Rt(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Vi.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?$i(t.x,"Need x coordinate"):("short"===this.ec.curve.type||"edwards"===this.ec.curve.type)&&$i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Vi.prototype.derive=function(t){return t.validate()||$i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Vi.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Vi.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Vi.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Qi=xi.assert;function Gi(t,e){if(t instanceof Gi)return t;this._importDER(t,e)||(Qi(t.r&&t.s,"Signature without r or s"),this.r=new Rt(t.r,16),this.s=new Rt(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Yi=Gi;function Wi(){this.place=0}function Zi(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return!(n<=127)&&(e.place=o,n)}function Xi(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function tn(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Gi.prototype._importDER=function(t,e){t=xi.toArray(t,e);var r=new Wi;if(48!==t[r.place++])return!1;var i=Zi(t,r);if(!1===i||i+r.place!==t.length||2!==t[r.place++])return!1;var n=Zi(t,r);if(!1===n)return!1;var s=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var o=Zi(t,r);if(!1===o||t.length!==o+r.place)return!1;var a=t.slice(r.place,o+r.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new Rt(s),this.s=new Rt(a),this.recoveryParam=null,!0},Gi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Xi(e),r=Xi(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];tn(i,e.length),(i=i.concat(e)).push(2),tn(i,r.length);var n=i.concat(r),s=[48];return tn(s,n.length),s=s.concat(n),xi.encode(s,t)};var en=function(){throw new Error("unsupported")},rn=xi.assert;function nn(t){if(!(this instanceof nn))return new nn(t);"string"==typeof t&&(rn(Object.prototype.hasOwnProperty.call(Fi,t),"Unknown curve "+t),t=Fi[t]),t instanceof Fi.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var sn=nn;nn.prototype.keyPair=function(t){return new Ji(this,t)},nn.prototype.keyFromPrivate=function(t,e){return Ji.fromPrivate(this,t,e)},nn.prototype.keyFromPublic=function(t,e){return Ji.fromPublic(this,t,e)},nn.prototype.genKeyPair=function(t){t||(t={});for(var e=new Hi({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||en(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new Rt(2));;){var n=new Rt(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},nn.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},nn.prototype.sign=function(t,e,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new Rt(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),a=new Hi({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),c=this.n.sub(new Rt(1)),h=0;;h++){var u=i.k?i.k(h):new Rt(a.generate(this.n.byteLength()));if(!((u=this._truncateToN(u,!0)).cmpn(1)<=0||u.cmp(c)>=0)){var f=this.g.mul(u);if(!f.isInfinity()){var d=f.getX(),l=d.umod(this.n);if(0!==l.cmpn(0)){var p=u.invm(this.n).mul(l.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var g=(f.getY().isOdd()?1:0)|(0!==d.cmp(l)?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),g^=1),new Yi({r:l,s:p,recoveryParam:g})}}}}}},nn.prototype.verify=function(t,e,r,i){t=this._truncateToN(new Rt(t,16)),r=this.keyFromPublic(r,i);var n=(e=new Yi(e,"hex")).r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),c=a.mul(t).umod(this.n),h=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(c,r.getPublic(),h)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(c,r.getPublic(),h)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},nn.prototype.recoverPubKey=function(t,e,r,i){rn((3&r)===r,"The recovery param is more than two bits"),e=new Yi(e,i);var n=this.n,s=new Rt(t),o=e.r,a=e.s,c=1&r,h=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");o=h?this.curve.pointFromX(o.add(this.curve.n),c):this.curve.pointFromX(o,c);var u=e.r.invm(n),f=n.sub(s).mul(u).umod(n),d=a.mul(u).umod(n);return this.g.mulAdd(f,o,d)},nn.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new Yi(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var on=Ii((function(t,e){var r=e;r.version="6.5.4",r.utils=xi,r.rand=function(){throw new Error("unsupported")},r.curve=Li,r.curves=Fi,r.ec=sn,r.eddsa=null})).ec;const an=new lt("signing-key/5.7.0");let cn=null;function hn(){return cn||(cn=new on("secp256k1")),cn}class un{constructor(t){_e(this,"curve","secp256k1"),_e(this,"privateKey",_t(t)),32!==function(t){if("string"!=typeof t)t=_t(t);else if(!wt(t)||t.length%2)return null;return(t.length-2)/2}(this.privateKey)&&an.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=hn().keyFromPrivate(yt(this.privateKey));_e(this,"publicKey","0x"+e.getPublic(!1,"hex")),_e(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),_e(this,"_isSigningKey",!0)}_addPoint(t){const e=hn().keyFromPublic(yt(this.publicKey)),r=hn().keyFromPublic(yt(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=hn().keyFromPrivate(yt(this.privateKey)),r=yt(t);32!==r.length&&an.throwArgumentError("bad digest length","digest",t);const i=e.sign(r,{canonical:!0});return Et({recoveryParam:i.recoveryParam,r:It("0x"+i.r.toString(16),32),s:It("0x"+i.s.toString(16),32)})}computeSharedSecret(t){const e=hn().keyFromPrivate(yt(this.privateKey)),r=hn().keyFromPublic(yt(fn(t)));return It("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function fn(t,e){const r=yt(t);if(32===r.length){const t=new un(r);return e?"0x"+hn().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?_t(r):"0x"+hn().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+hn().keyFromPublic(r).getPublic(!0,"hex"):_t(r):an.throwArgumentError("invalid public or private key","key","[REDACTED]")}var dn;function ln(t,e){return function(t){return function(t){let e=null;if("string"!=typeof t&&ve.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=ye(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ve.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=>we[t])).join("");for(;e.length>=Ae;){let t=e.substring(0,Ae);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)&&ve.throwArgumentError("bad icap checksum","address",t),e=function(t){return new Ot(t,36).toString(16)}(t.substring(4));e.length<40;)e="0"+e;e=ye("0x"+e)}else ve.throwArgumentError("invalid address","address",t);return e}(Mt(St(Mt(fn(t),1)),12))}(function(t,e){const r=Et(e),i={r:yt(r.r),s:yt(r.s)};return"0x"+hn().recoverPubKey(yt(t),i,r.recoveryParam).encode("hex",!1)}(yt(t),e))}new lt("transactions/5.7.0"),function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"}(dn||(dn={}));var pn=Object.defineProperty,gn=Object.defineProperties,mn=Object.getOwnPropertyDescriptors,bn=Object.getOwnPropertySymbols,vn=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable,wn=(t,e,r)=>e in t?pn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;const An=t=>t?.split(":"),_n=t=>{const e=t&&An(t);if(e)return t.includes("did:pkh:")?e[3]:e[1]},Mn=t=>{const e=t&&An(t);if(e)return e[2]+":"+e[3]},In=t=>{const e=t&&An(t);if(e)return e.pop()};async function En(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=Sn(n,n.iss),o=In(n.iss);return await async function(t,e,r,i,n,s){switch(r.t){case"eip191":return function(t,e,r){return ln(be(e),r).toLowerCase()===t.toLowerCase()}(t,e,r.s);case"eip1271":return await async function(t,e,r,i,n,s){try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=r.substring(2),u=o+be(e).substring(2)+a+c+h,f=await fetch(`${s||"https://rpc.walletconnect.org/v1"}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:u},"latest"]})}),{result:d}=await f.json();return!!d&&d.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(t){return console.error("isValidEip1271Signature: ",t),!1}}(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}(o,s,i,_n(n.iss),r)}const Sn=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=In(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${_n(e)}`,c=`Nonce: ${t.nonce}`,h=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,f=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,l=t.resources?`Resources:${t.resources.map((t=>`\n- ${t}`)).join("")}`:void 0,p=qn(t.resources);return p&&(n=function(t="",e){Pn(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;return Object.keys(e.att).forEach((t=>{const r=Object.keys(e.att[t]).map((t=>({ability:t.split("/")[0],action:t.split("/")[1]})));r.sort(((t,e)=>t.action.localeCompare(e.action)));const s={};r.forEach((t=>{s[t.ability]||(s[t.ability]=[]),s[t.ability].push(t.action)}));const o=Object.keys(s).map((e=>(n++,`(${n}) '${e}': '${s[e].join("', '")}' for '${t}'.`)));i.push(o.join(", ").replace(".,","."))})),`${t?t+" ":""}${r}${i.join(" ")}`}(n,Nn(p))),[r,i,"",n,"",s,o,a,c,h,u,f,d,l].filter((t=>null!=t)).join("\n")};function Pn(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(null==e||!e.length)throw new Error("No resources found in `att` property");e.forEach((e=>{const r=t.att[e];if(Array.isArray(r))throw new Error(`Resource must be an object: ${e}`);if("object"!=typeof r)throw new Error(`Resource must be an object: ${e}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${e}`);Object.keys(r).forEach((t=>{const e=r[t];if(!Array.isArray(e))throw new Error(`Ability limits ${t} must be an array of objects, found: ${e}`);if(!e.length)throw new Error(`Value of ${t} is empty array, must be an array with objects`);e.forEach((e=>{if("object"!=typeof e)throw new Error(`Ability limits (${t}) must be an array of objects, found: ${e}`)}))}))}))}function xn(t,e,r={}){e=e?.sort(((t,e)=>t.localeCompare(e)));const i=e.map((e=>({[`${t}/${e}`]:[r]})));return Object.assign({},...i)}function Rn(t){return Pn(t),`urn:recap:${function(t){return w.from(JSON.stringify(t)).toString("base64")}(t).replace(/=/g,"")}`}function Nn(t){const e=function(t){return JSON.parse(w.from(t,"base64").toString("utf-8"))}(t.replace("urn:recap:",""));return Pn(e),e}function On(t,e){const r=function(t,e){Pn(t),Pn(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort(((t,e)=>t.localeCompare(e))),i={att:{}};return r.forEach((r=>{var n,s;Object.keys((null==(n=t.att)?void 0:n[r])||{}).concat(Object.keys((null==(s=e.att)?void 0:s[r])||{})).sort(((t,e)=>t.localeCompare(e))).forEach((n=>{var s,o;i.att[r]=((t,e)=>gn(t,mn(e)))(((t,e)=>{for(var r in e||(e={}))vn.call(e,r)&&wn(t,r,e[r]);if(bn)for(var r of bn(e))yn.call(e,r)&&wn(t,r,e[r]);return t})({},i.att[r]),{[n]:(null==(s=t.att[r])?void 0:s[n])||(null==(o=e.att[r])?void 0:o[n])})}))})),i}(Nn(t),Nn(e));return Rn(r)}function Cn(t){var e;const r=Nn(t);Pn(r);const i=null==(e=r.att)?void 0:e.eip155;return i?Object.keys(i).map((t=>t.split("/")[1])):[]}function Tn(t){const e=Nn(t);Pn(e);const r=[];return Object.values(e.att).forEach((t=>{Object.values(t).forEach((t=>{var e;null!=(e=t?.[0])&&e.chains&&r.push(t[0].chains)}))})),[...new Set(r.flat())]}function qn(t){if(!t)return;const e=t?.[t.length-1];return function(t){return t&&t.includes("urn:recap:")}(e)?e:void 0}const Dn="base10",kn="base16",Bn="base64pad",Un="base64url",zn="utf8";function jn(){const t=(0,d.randomBytes)(32);return(0,g.dI)(t,kn)}function Ln(t){const e=(0,l.tW)((0,g.sH)(t,kn));return(0,g.dI)(e,kn)}function Fn(t){const e=(0,l.tW)((0,g.sH)(t,zn));return(0,g.dI)(e,kn)}function Kn(t){return(0,g.sH)(`${t}`,Dn)}function Hn(t){return Number((0,g.dI)(t,Dn))}function $n(t){const{encoding:e=Bn}=t;if(2===Hn(t.type))return(0,g.dI)((0,g.xW)([t.type,t.sealed]),e);if(1===Hn(t.type)){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,g.dI)((0,g.xW)([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return(0,g.dI)((0,g.xW)([t.type,t.iv,t.sealed]),e)}function Vn(t){const{encoded:e,encoding:r=Bn}=t,i=(0,g.sH)(e,r),n=i.slice(0,1);if(1===Hn(n)){const t=33,e=t+12,r=i.slice(1,t),s=i.slice(t,e);return{type:n,sealed:i.slice(e),iv:s,senderPublicKey:r}}if(2===Hn(n))return{type:n,sealed:i.slice(1),iv:(0,d.randomBytes)(12)};const s=i.slice(1,13);return{type:n,sealed:i.slice(13),iv:s}}function Jn(t){const e=t?.type||0;if(1===e){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Qn(t){return 1===t.type&&"string"==typeof t.senderPublicKey&&"string"==typeof t.receiverPublicKey}function Gn(t){return 2===t.type}function Yn(t){return t?.relay||{protocol:"irn"}}function Wn(t){const e=v.CG[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Zn=Object.defineProperty,Xn=Object.defineProperties,ts=Object.getOwnPropertyDescriptors,es=Object.getOwnPropertySymbols,rs=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,ns=(t,e,r)=>e in t?Zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ss=(t,e)=>{for(var r in e||(e={}))rs.call(e,r)&&ns(t,r,e[r]);if(es)for(var r of es(e))is.call(e,r)&&ns(t,r,e[r]);return t};function os(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach((e=>{if(e.startsWith(i)){const n=e.replace(i,""),s=t[e];r[n]=s}})),r}function as(t){if(!t.includes("wc:")){const e=X(t);null!=e&&e.includes("wc:")&&(t=e)}const e=(t=(t=t.includes("wc://")?t.replace("wc://",""):t).includes("wc:")?t.replace("wc:",""):t).indexOf(":"),r=-1!==t.indexOf("?")?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=h.parse(s),a="string"==typeof o.methods?o.methods.split(","):void 0;return{protocol:i,topic:cs(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:os(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function cs(t){return t.startsWith("//")?t.substring(2):t}function hs(t){return`${t.protocol}:${t.topic}@${t.version}?`+h.stringify(ss(((t,e)=>Xn(t,ts(e)))(ss({symKey:t.symKey},function(t,e="-"){const r={};return Object.keys(t).forEach((i=>{const n="relay"+e+i;t[i]&&(r[n]=t[i])})),r}(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}function us(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function fs(t){const e=[];return t.forEach((t=>{const[r,i]=t.split(":");e.push(`${r}:${i}`)})),e}function ds(t){return t.includes(":")}function ls(t){return ds(t)?t.split(":")[0]:t}function ps(t,e){const r=function(t){const e={};return t?.forEach((t=>{const[r,i]=t.split(":");e[r]||(e[r]={accounts:[],chains:[],events:[]}),e[r].accounts.push(t),e[r].chains.push(`${r}:${i}`)})),e}(e=e.map((t=>t.replace("did:pkh:",""))));for(const[e,i]of Object.entries(r))i.methods?i.methods=G(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return r}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const gs={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},ms={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function bs(t,e){const{message:r,code:i}=ms[t];return{message:e?`${r} ${e}`:r,code:i}}function vs(t,e){const{message:r,code:i}=gs[t];return{message:e?`${r} ${e}`:r,code:i}}function ys(t,e){return!!Array.isArray(t)&&(!(typeof e<"u"&&t.length)||t.every(e))}function ws(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function As(t){return typeof t>"u"}function _s(t,e){return!(!e||!As(t))||"string"==typeof t&&!!t.trim().length}function Ms(t,e){return!(!e||!As(t))||"number"==typeof t&&!isNaN(t)}function Is(t){return!(!_s(t,!1)||!t.includes(":"))&&2===t.split(":").length}function Es(t){let e=!0;return ys(t)?t.length&&(e=t.every((t=>_s(t,!1)))):e=!1,e}function Ss(t,e){let r=null;return Object.values(t).forEach((t=>{if(r)return;const i=function(t,e){let r=null;return Es(t?.methods)?Es(t?.events)||(r=vs("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=vs("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}(t,`${e}, namespace`);i&&(r=i)})),r}function Ps(t,e){let r=null;if(t&&ws(t)){const i=Ss(t,e);i&&(r=i);const n=function(t,e){let r=null;return Object.values(t).forEach((t=>{if(r)return;const i=function(t,e){let r=null;return ys(t)?t.forEach((t=>{r||function(t){if(_s(t,!1)&&t.includes(":")){const e=t.split(":");if(3===e.length){const t=e[0]+":"+e[1];return!!e[2]&&Is(t)}}return!1}(t)||(r=vs("UNSUPPORTED_ACCOUNTS",`${e}, account ${t} should be a string and conform to "namespace:chainId:address" format`))})):r=vs("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}(t?.accounts,`${e} namespace`);i&&(r=i)})),r}(t,e);n&&(r=n)}else r=bs("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function xs(t){return _s(t.protocol,!0)}function Rs(t){return typeof t<"u"&&null!==typeof t}function Ns(t,e){return!(!Is(e)||!function(t){const e=[];return Object.values(t).forEach((t=>{e.push(...fs(t.accounts))})),e}(t).includes(e))}function Os(t,e,r){let i=null;const n=function(t){const e={};return Object.keys(t).forEach((r=>{var i;r.includes(":")?e[r]=t[r]:null==(i=t[r].chains)||i.forEach((i=>{e[i]={methods:t[r].methods,events:t[r].events}}))})),e}(t),s=function(t){const e={};return Object.keys(t).forEach((r=>{if(r.includes(":"))e[r]=t[r];else{const i=fs(t[r].accounts);i?.forEach((i=>{e[i]={accounts:t[r].accounts.filter((t=>t.includes(`${i}:`))),methods:t[r].methods,events:t[r].events}}))}})),e}(e),o=Object.keys(n),a=Object.keys(s),c=Cs(Object.keys(t)),h=Cs(Object.keys(e)),u=c.filter((t=>!h.includes(t)));return u.length&&(i=bs("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n Required: ${u.toString()}\n Received: ${Object.keys(e).toString()}`)),z(o,a)||(i=bs("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(e).forEach((t=>{if(!t.includes(":")||i)return;const n=fs(e[t].accounts);n.includes(t)||(i=bs("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${t}\n Required: ${t}\n Approved: ${n.toString()}`))})),o.forEach((t=>{i||(z(n[t].methods,s[t].methods)?z(n[t].events,s[t].events)||(i=bs("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${t}`)):i=bs("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${t}`))})),i}function Cs(t){return[...new Set(t.map((t=>t.includes(":")?t.split(":")[0]:t)))]}function Ts(){const t=k();return new Promise((e=>{switch(t){case O:e(D()&&navigator?.onLine);break;case N:e(async function(){if(q()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo){const t=await(null==r.g?void 0:r.g.NetInfo.fetch());return t?.isConnected}return!0}());break;default:e(!0)}}))}const qs={};class Ds{static get(t){return qs[t]}static set(t,e){qs[t]=e}static delete(t){delete qs[t]}}var ks=r(37147),Bs=r(13338),Us=r(70255),zs=r(94549);class js extends zs.H{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}class Ls extends zs.H{constructor(t,e){super(),this.core=t,this.logger=e,this.records=new Map}}class Fs{constructor(t,e){this.logger=t,this.core=e}}class Ks extends zs.H{constructor(t,e){super(),this.relayer=t,this.logger=e}}class Hs extends zs.H{constructor(t){super()}}class $s{constructor(t,e,r,i){this.core=t,this.logger=e,this.name=r}}class Vs extends zs.H{constructor(t,e){super(),this.relayer=t,this.logger=e}}class Js extends zs.H{constructor(t,e){super(),this.core=t,this.logger=e}}class Qs{constructor(t,e,r){this.core=t,this.logger=e,this.store=r}}class Gs{constructor(t,e){this.projectId=t,this.logger=e}}class Ys{constructor(t,e,r){this.core=t,this.logger=e,this.telemetryEnabled=r}}n();class Ws{constructor(t){this.opts=t,this.protocol="wc",this.version=2}}i.EventEmitter;class Zs{constructor(t){this.client=t}}var Xs=r(25607),to=r(93786),eo=r(14350),ro=r(63342),io=r(18677),no=r.n(io);const so="core",oo=`wc@2:${so}:`,ao={database:":memory:"},co="client_ed25519_seed",ho=o.ONE_DAY,uo=o.SIX_HOURS,fo="wss://relay.walletconnect.org",lo="relayer_message",po="relayer_message_ack",go="relayer_connection_stalled",mo="relayer_publish",bo="payload",vo="connect",yo="disconnect",wo="error",Ao="2.17.0",_o={link_mode:"link_mode",relay:"relay"},Mo="WALLETCONNECT_LINK_MODE_APPS",Io="subscription_created",Eo="subscription_deleted",So=1e3*o.FIVE_SECONDS,Po={wc_pairingDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:o.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:o.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:o.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:o.ONE_DAY,prompt:!1,tag:0},res:{ttl:o.ONE_DAY,prompt:!1,tag:0}}},xo="pairing_create",Ro="pairing_delete",No="history_created",Oo="history_updated",Co="history_deleted",To="expirer_created",qo="expirer_deleted",Do="expirer_expired",ko="https://verify.walletconnect.org",Bo=ko,Uo=`${Bo}/v3`,zo=["https://verify.walletconnect.com",ko],jo="malformed_pairing_uri",Lo="session_approve_started";var Fo=function(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;var e=0;if(" "!==t[e]){for(var i=0,n=0;t[e]===c;)i++,e++;for(var s=(t.length-e)*h+1>>>0,o=new Uint8Array(s);t[e];){var u=r[t.charCodeAt(e)];if(255===u)return;for(var f=0,d=s-1;(0!==u||f<n)&&-1!==d;d--,f++)u+=a*o[d]>>>0,o[d]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");n=f,e++}if(" "!==t[e]){for(var l=s-n;l!==s&&0===o[l];)l++;for(var p=new Uint8Array(i+(s-l)),g=i;l!==s;)p[g++]=o[l++];return p}}}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,i=0,n=0,s=e.length;n!==s&&0===e[n];)n++,r++;for(var o=(s-n)*u+1>>>0,h=new Uint8Array(o);n!==s;){for(var f=e[n],d=0,l=o-1;(0!==f||d<i)&&-1!==l;l--,d++)f+=256*h[l]>>>0,h[l]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");i=d,n++}for(var p=o-i;p!==o&&0===h[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=t.charAt(h[p]);return g},decodeUnsafe:f,decode:function(t){var r=f(t);if(r)return r;throw new Error(`Non-${e} character`)}}};const Ko=t=>{if(t instanceof Uint8Array&&"Uint8Array"===t.constructor.name)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};class Ho{constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class $o{constructor(t,e,r){if(this.name=t,this.prefix=e,void 0===e.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if("string"==typeof t){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(t){return Jo(this,t)}}class Vo{constructor(t){this.decoders=t}or(t){return Jo(this,t)}decode(t){const e=t[0],r=this.decoders[e];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Jo=(t,e)=>new Vo({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Qo{constructor(t,e,r,i){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=i,this.encoder=new Ho(t,e,r),this.decoder=new $o(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const Go=({name:t,prefix:e,encode:r,decode:i})=>new Qo(t,e,r,i),Yo=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Fo(r,e);return Go({prefix:t,name:e,encode:i,decode:t=>Ko(n(t))})},Wo=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Go({prefix:e,name:t,encode:t=>((t,e,r)=>{const i="="===e[e.length-1],n=(1<<r)-1;let s="",o=0,a=0;for(let i=0;i<t.length;++i)for(a=a<<8|t[i],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s})(t,i,r),decode:e=>((t,e,r,i)=>{const n={};for(let t=0;t<e.length;++t)n[e[t]]=t;let s=t.length;for(;"="===t[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,h=0;for(let e=0;e<s;++e){const s=n[t[e]];if(void 0===s)throw new SyntaxError(`Non-${i} character`);c=c<<r|s,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(e,i,r,t)}),Zo=Go({prefix:"\0",name:"identity",encode:t=>(t=>(new TextDecoder).decode(t))(t),decode:t=>(t=>(new TextEncoder).encode(t))(t)});var Xo=Object.freeze({__proto__:null,identity:Zo});const ta=Wo({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ea=Object.freeze({__proto__:null,base2:ta});const ra=Wo({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ia=Object.freeze({__proto__:null,base8:ra});const na=Yo({prefix:"9",name:"base10",alphabet:"0123456789"});var sa=Object.freeze({__proto__:null,base10:na});const oa=Wo({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),aa=Wo({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ca=Object.freeze({__proto__:null,base16:oa,base16upper:aa});const ha=Wo({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ua=Wo({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),fa=Wo({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),da=Wo({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),la=Wo({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pa=Wo({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ga=Wo({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ma=Wo({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ba=Wo({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var va=Object.freeze({__proto__:null,base32:ha,base32upper:ua,base32pad:fa,base32padupper:da,base32hex:la,base32hexupper:pa,base32hexpad:ga,base32hexpadupper:ma,base32z:ba});const ya=Yo({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),wa=Yo({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Aa=Object.freeze({__proto__:null,base36:ya,base36upper:wa});const _a=Yo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ma=Yo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ia=Object.freeze({__proto__:null,base58btc:_a,base58flickr:Ma});const Ea=Wo({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Sa=Wo({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pa=Wo({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),xa=Wo({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ra=Object.freeze({__proto__:null,base64:Ea,base64pad:Sa,base64url:Pa,base64urlpad:xa});const Na=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Oa=Na.reduce(((t,e,r)=>(t[r]=e,t)),[]),Ca=Na.reduce(((t,e,r)=>(t[e.codePointAt(0)]=r,t)),[]),Ta=Go({prefix:"🚀",name:"base256emoji",encode:function(t){return t.reduce(((t,e)=>t+Oa[e]),"")},decode:function(t){const e=[];for(const r of t){const t=Ca[r.codePointAt(0)];if(void 0===t)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}});var qa=Object.freeze({__proto__:null,base256emoji:Ta}),Da=128,ka=-128,Ba=Math.pow(2,31),Ua=Math.pow(2,7),za=Math.pow(2,14),ja=Math.pow(2,21),La=Math.pow(2,28),Fa=Math.pow(2,35),Ka=Math.pow(2,42),Ha=Math.pow(2,49),$a=Math.pow(2,56),Va=Math.pow(2,63),Ja=function t(e,r,i){r=r||[];for(var n=i=i||0;e>=Ba;)r[i++]=255&e|Da,e/=128;for(;e&ka;)r[i++]=255&e|Da,e>>>=7;return r[i]=0|e,t.bytes=i-n+1,r},Qa=function(t){return t<Ua?1:t<za?2:t<ja?3:t<La?4:t<Fa?5:t<Ka?6:t<Ha?7:t<$a?8:t<Va?9:10};const Ga=(t,e,r=0)=>(Ja(t,e,r),e),Ya=t=>Qa(t),Wa=(t,e)=>{const r=e.byteLength,i=Ya(t),n=i+Ya(r),s=new Uint8Array(n+r);return Ga(t,s,0),Ga(r,s,i),s.set(e,n),new Za(t,r,e,s)};class Za{constructor(t,e,r,i){this.code=t,this.size=e,this.digest=r,this.bytes=i}}const Xa=({name:t,code:e,encode:r})=>new tc(t,e,r);class tc{constructor(t,e,r){this.name=t,this.code=e,this.encode=r}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?Wa(this.code,e):e.then((t=>Wa(this.code,t)))}throw Error("Unknown type, must be binary type")}}const ec=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),rc=Xa({name:"sha2-256",code:18,encode:ec("SHA-256")}),ic=Xa({name:"sha2-512",code:19,encode:ec("SHA-512")});Object.freeze({__proto__:null,sha256:rc,sha512:ic});const nc=Ko,sc={code:0,name:"identity",encode:nc,digest:t=>Wa(0,nc(t))};Object.freeze({__proto__:null,identity:sc}),new TextEncoder,new TextDecoder;const oc={...Xo,...ea,...ia,...sa,...ca,...va,...Aa,...Ia,...Ra,...qa};function ac(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const cc=ac("utf8","u",(t=>"u"+new TextDecoder("utf8").decode(t)),(t=>(new TextEncoder).encode(t.substring(1)))),hc=ac("ascii","a",(t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}),(t=>{const e=function(t=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}((t=t.substring(1)).length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e})),uc={utf8:cc,"utf-8":cc,hex:oc.base16,latin1:hc,ascii:hc,binary:hc,...oc};class fc{constructor(t,e){this.core=t,this.logger=e,this.keychain=new Map,this.name="keychain",this.version="0.3",this.initialized=!1,this.storagePrefix=oo,this.init=async()=>{if(!this.initialized){const t=await this.getKeyChain();typeof t<"u"&&(this.keychain=t),this.initialized=!0}},this.has=t=>(this.isInitialized(),this.keychain.has(t)),this.set=async(t,e)=>{this.isInitialized(),this.keychain.set(t,e),await this.persist()},this.get=t=>{this.isInitialized();const e=this.keychain.get(t);if(typeof e>"u"){const{message:e}=bs("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(e)}return e},this.del=async t=>{this.isInitialized(),this.keychain.delete(t),await this.persist()},this.core=t,this.logger=(0,Us.U5)(e,this.name)}get context(){return(0,Us.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,j(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?L(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}}class dc{constructor(t,e,r){this.core=t,this.logger=e,this.name="crypto",this.randomSessionIdentifier=jn(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=t=>(this.isInitialized(),this.keychain.has(t)),this.getClientId=async()=>{this.isInitialized();const t=await this.getClientSeed(),e=b.generateKeyPair(t);return b.encodeIss(e.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const t=function(){const t=p.TZ();return{privateKey:(0,g.dI)(t.secretKey,kn),publicKey:(0,g.dI)(t.publicKey,kn)}}();return this.setPrivateKey(t.publicKey,t.privateKey)},this.signJWT=async t=>{this.isInitialized();const e=await this.getClientSeed(),r=b.generateKeyPair(e),i=this.randomSessionIdentifier,n=ho;return await b.signJWT(i,t,n,r)},this.generateSharedKey=(t,e,r)=>{this.isInitialized();const i=function(t,e){const r=p.Tc((0,g.sH)(t,kn),(0,g.sH)(e,kn),!0),i=new f.i(l.aD,r).expand(32);return(0,g.dI)(i,kn)}(this.getPrivateKey(t),e);return this.setSymKey(i,r)},this.setSymKey=async(t,e)=>{this.isInitialized();const r=e||Ln(t);return await this.keychain.set(r,t),r},this.deleteKeyPair=async t=>{this.isInitialized(),await this.keychain.del(t)},this.deleteSymKey=async t=>{this.isInitialized(),await this.keychain.del(t)},this.encode=async(t,e,r)=>{this.isInitialized();const i=Jn(r),n=(0,Xs.h)(e);if(Gn(i))return function(t,e){const r=Kn(2),i=(0,d.randomBytes)(12);return $n({type:r,sealed:(0,g.sH)(t,zn),iv:i,encoding:e})}(n,r?.encoding);if(Qn(i)){const e=i.senderPublicKey,r=i.receiverPublicKey;t=await this.generateSharedKey(e,r)}const s=this.getSymKey(t),{type:o,senderPublicKey:a}=i;return function(t){const e=Kn(typeof t.type<"u"?t.type:0);if(1===Hn(e)&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?(0,g.sH)(t.senderPublicKey,kn):void 0,i=typeof t.iv<"u"?(0,g.sH)(t.iv,kn):(0,d.randomBytes)(12);return $n({type:e,sealed:new u.g6((0,g.sH)(t.symKey,kn)).seal(i,(0,g.sH)(t.message,zn)),iv:i,senderPublicKey:r,encoding:t.encoding})}({type:o,symKey:s,message:n,senderPublicKey:a,encoding:r?.encoding})},this.decode=async(t,e,r)=>{this.isInitialized();const i=function(t,e){const r=Vn({encoded:t,encoding:e?.encoding});return Jn({type:Hn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?(0,g.dI)(r.senderPublicKey,kn):void 0,receiverPublicKey:e?.receiverPublicKey})}(e,r);if(Gn(i)){const t=function(t,e){const{sealed:r}=Vn({encoded:t,encoding:e});return(0,g.dI)(r,zn)}(e,r?.encoding);return(0,Xs.j)(t)}if(Qn(i)){const e=i.receiverPublicKey,r=i.senderPublicKey;t=await this.generateSharedKey(e,r)}try{const i=function(t){const e=new u.g6((0,g.sH)(t.symKey,kn)),{sealed:r,iv:i}=Vn({encoded:t.encoded,encoding:t?.encoding}),n=e.open(i,r);if(null===n)throw new Error("Failed to decrypt");return(0,g.dI)(n,zn)}({symKey:this.getSymKey(t),encoded:e,encoding:r?.encoding});return(0,Xs.j)(i)}catch(e){this.logger.error(`Failed to decode message from topic: '${t}', clientId: '${await this.getClientId()}'`),this.logger.error(e)}},this.getPayloadType=(t,e=Bn)=>Hn(Vn({encoded:t,encoding:e}).type),this.getPayloadSenderPublicKey=(t,e=Bn)=>{const r=Vn({encoded:t,encoding:e});return r.senderPublicKey?(0,g.dI)(r.senderPublicKey,kn):void 0},this.core=t,this.logger=(0,Us.U5)(e,this.name),this.keychain=r||new fc(this.core,this.logger)}get context(){return(0,Us.oI)(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(co)}catch{t=jn(),await this.keychain.set(co,t)}return function(t,e="utf8"){const r=uc[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return"utf8"!==e&&"utf-8"!==e||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${t}`):globalThis.Buffer.from(t,"utf8")}(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}}class lc extends Fs{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=oo,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const t=await this.getRelayerMessages();typeof t<"u"&&(this.messages=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}finally{this.initialized=!0}}},this.set=async(t,e)=>{this.isInitialized();const r=Fn(e);let i=this.messages.get(t);return typeof i>"u"&&(i={}),typeof i[r]<"u"||(i[r]=e,this.messages.set(t,i),await this.persist()),r},this.get=t=>{this.isInitialized();let e=this.messages.get(t);return typeof e>"u"&&(e={}),e},this.has=(t,e)=>(this.isInitialized(),typeof this.get(t)[Fn(e)]<"u"),this.del=async t=>{this.isInitialized(),this.messages.delete(t),await this.persist()},this.logger=(0,Us.U5)(t,this.name),this.core=e}get context(){return(0,Us.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,j(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?L(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}}class pc extends Ks{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new i.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,o.toMiliseconds)(o.ONE_MINUTE),this.failedPublishTimeout=(0,o.toMiliseconds)(o.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(t,e,r)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:t,message:e,opts:r}});const n=r?.ttl||uo,s=Yn(r),o=r?.prompt||!1,a=r?.tag||0,c=r?.id||(0,eo.getBigIntRpcId)().toString(),h={topic:t,message:e,opts:{ttl:n,relay:s,prompt:o,tag:a,id:c,attestation:r?.attestation}},u=`Failed to publish payload, please try again. id:${c} tag:${a}`,f=Date.now();let d,l=1;try{for(;void 0===d;){if(Date.now()-f>this.publishTimeout)throw new Error(u);this.logger.trace({id:c,attempts:l},`publisher.publish - attempt ${l}`),d=await await K(this.rpcPublish(t,e,n,s,o,a,c,r?.attestation).catch((t=>this.logger.warn(t))),this.publishTimeout,u),l++,d||await new Promise((t=>setTimeout(t,this.failedPublishTimeout)))}this.relayer.events.emit(mo,h),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:c,topic:t,message:e,opts:r}})}catch(t){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(t),null!=(i=r?.internal)&&i.throwOnFailedPublish)throw t;this.queue.set(c,h)}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.relayer=t,this.logger=(0,Us.U5)(e,this.name),this.registerEventListeners()}get context(){return(0,Us.oI)(this.logger)}rpcPublish(t,e,r,i,n,s,o,a){var c,h,u,f;const d={method:Wn(i.protocol).publish,params:{topic:t,message:e,ttl:r,prompt:n,tag:s,attestation:a},id:o};return As(null==(c=d.params)?void 0:c.prompt)&&(null==(h=d.params)||delete h.prompt),As(null==(u=d.params)?void 0:u.tag)&&(null==(f=d.params)||delete f.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:d}),this.relayer.request(d)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach((async t=>{const{topic:e,message:r,opts:i}=t;await this.publish(e,r,i)}))}registerEventListeners(){this.relayer.core.heartbeat.on(ks.li.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(go);this.checkQueue()})),this.relayer.on(po,(t=>{this.removeRequestFromQueue(t.id.toString())}))}}class gc{constructor(){this.map=new Map,this.set=(t,e)=>{const r=this.get(t);this.exists(t,e)||this.map.set(t,[...r,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u")return void this.map.delete(t);if(!this.map.has(t))return;const r=this.get(t);if(!this.exists(t,e))return;const i=r.filter((t=>t!==e));i.length?this.map.set(t,i):this.map.delete(t)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var mc=Object.defineProperty,bc=Object.defineProperties,vc=Object.getOwnPropertyDescriptors,yc=Object.getOwnPropertySymbols,wc=Object.prototype.hasOwnProperty,Ac=Object.prototype.propertyIsEnumerable,_c=(t,e,r)=>e in t?mc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mc=(t,e)=>{for(var r in e||(e={}))wc.call(e,r)&&_c(t,r,e[r]);if(yc)for(var r of yc(e))Ac.call(e,r)&&_c(t,r,e[r]);return t},Ic=(t,e)=>bc(t,vc(e));class Ec extends Vs{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new gc,this.events=new i.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=oo,this.subscribeTimeout=(0,o.toMiliseconds)(o.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(t,e)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}});try{const r=Yn(e),i={topic:t,relay:r,transportType:e?.transportType};this.pending.set(t,i);const n=await this.rpcSubscribe(t,r,e?.transportType);return"string"==typeof n&&(this.onSubscribe(n,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}})),n}catch(t){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(t),t}},this.unsubscribe=async(t,e)=>{await this.restartToComplete(),this.isInitialized(),typeof e?.id<"u"?await this.unsubscribeById(t,e.id,e):await this.unsubscribeByTopic(t,e)},this.isSubscribed=async t=>{if(this.topics.includes(t))return!0;const e=`${this.pendingSubscriptionWatchLabel}_${t}`;return await new Promise(((r,i)=>{const n=new o.Watch;n.start(e);const s=setInterval((()=>{!this.pending.has(t)&&this.topics.includes(t)&&(clearInterval(s),n.stop(e),r(!0)),n.elapsed(e)>=So&&(clearInterval(s),n.stop(e),i(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1))},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=(0,Us.U5)(e,this.name),this.clientId=""}get context(){return(0,Us.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,e){let r=!1;try{r=this.getSubscription(t).topic===e}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){const r=this.topicMap.get(t);await Promise.all(r.map((async r=>await this.unsubscribeById(t,r,e))))}async unsubscribeById(t,e,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}});try{const i=Yn(r);await this.rpcUnsubscribe(t,e,i);const n=vs("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,e,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}})}catch(t){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(t),t}}async rpcSubscribe(t,e,r=_o.relay){r===_o.relay&&await this.restartToComplete();const i={method:Wn(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{const e=Fn(t+this.clientId);return r===_o.link_mode?(setTimeout((()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(i).catch((t=>this.logger.warn(t)))}),(0,o.toMiliseconds)(o.ONE_SECOND)),e):await await K(this.relayer.request(i).catch((t=>this.logger.warn(t))),this.subscribeTimeout)?e:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(go)}return null}async rpcBatchSubscribe(t){if(!t.length)return;const e={method:Wn(t[0].relay.protocol).batchSubscribe,params:{topics:t.map((t=>t.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:e});try{return await await K(this.relayer.request(e).catch((t=>this.logger.warn(t))),this.subscribeTimeout)}catch{this.relayer.events.emit(go)}}async rpcBatchFetchMessages(t){if(!t.length)return;const e={method:Wn(t[0].relay.protocol).batchFetchMessages,params:{topics:t.map((t=>t.topic))}};let r;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:e});try{r=await await K(this.relayer.request(e).catch((t=>this.logger.warn(t))),this.subscribeTimeout)}catch{this.relayer.events.emit(go)}return r}rpcUnsubscribe(t,e,r){const i={method:Wn(r.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(t,e){this.setSubscription(t,Ic(Mc({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach((t=>{this.setSubscription(t.id,Mc({},t)),this.pending.delete(t.topic)}))}async onUnsubscribe(t,e,r){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,r),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,e){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e)}addSubscription(t,e){this.subscriptions.set(t,Mc({},e)),this.topicMap.set(e.topic,t),this.events.emit(Io,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const e=this.subscriptions.get(t);if(!e){const{message:e}=bs("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(e)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});const r=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(r.topic,t),this.events.emit(Eo,Ic(Mc({},r),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e<t;e++){const t=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(t),await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:t}=bs("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const e=await this.rpcBatchSubscribe(t);ys(e)&&this.onBatchSubscribe(e.map(((e,r)=>Ic(Mc({},t[r]),{id:e}))))}async batchFetchMessages(t){if(!t.length)return;this.logger.trace(`Fetching batch messages for ${t.length} subscriptions`);const e=await this.rpcBatchFetchMessages(t);e&&e.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(e.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const t=[];this.pending.forEach((e=>{t.push(e)})),await this.batchSubscribe(t),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(ks.li.pulse,(async()=>{await this.checkPending()})),this.events.on(Io,(async t=>{const e=Io;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})),this.events.on(Eo,(async t=>{const e=Eo;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise((t=>{const e=setInterval((()=>{this.restartInProgress||(clearInterval(e),t())}),this.pollingInterval)}))}}var Sc=Object.defineProperty,Pc=Object.getOwnPropertySymbols,xc=Object.prototype.hasOwnProperty,Rc=Object.prototype.propertyIsEnumerable,Nc=(t,e,r)=>e in t?Sc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;class Oc extends Hs{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new i.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,o.toMiliseconds)(o.THIRTY_SECONDS+o.ONE_SECOND),this.request=async t=>{var e,r;this.logger.debug("Publishing Request Payload");const i=t.id||(0,eo.getBigIntRpcId)().toString();await this.toEstablishConnection();try{const n=this.provider.request(t);this.requestsInFlight.set(i,{promise:n,request:t}),this.logger.trace({id:i,method:t.method,topic:null==(e=t.params)?void 0:e.topic},"relayer.request - attempt to publish...");const s=await new Promise((async(t,e)=>{const r=()=>{e(new Error(`relayer.request - publish interrupted, id: ${i}`))};this.provider.on(yo,r);const s=await n;this.provider.off(yo,r),t(s)}));return this.logger.trace({id:i,method:t.method,topic:null==(r=t.params)?void 0:r.topic},"relayer.request - published"),s}catch(t){throw this.logger.debug(`Failed to Publish Request: ${i}`),t}finally{this.requestsInFlight.delete(i)}},this.resetPingTimeout=()=>{if(T())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout((()=>{var t,e,r;null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)||r.terminate()}),this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit("relayer_connect")},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit("relayer_error",t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(bo,this.onPayloadHandler),this.provider.on(vo,this.onConnectHandler),this.provider.on(yo,this.onDisconnectHandler),this.provider.on(wo,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&"string"!=typeof t.logger?(0,Us.U5)(t.logger,this.name):(0,Us.h6)((0,Us.iP)({level:t.logger||"error"})),this.messages=new lc(this.logger,t.core),this.subscriber=new Ec(this,this.logger),this.publisher=new pc(this,this.logger),this.relayUrl=t?.relayUrl||fo,this.projectId=t.projectId,this.bundleId=function(){var t;try{return q()&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Application)<"u"?null==(t=r.g.Application)?void 0:t.applicationId:void 0}catch{return}}(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(t){this.logger.warn(t)}}get context(){return(0,Us.oI)(this.logger)}get connected(){var t,e,r;return 1===(null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)?void 0:r.readyState)}get connecting(){var t,e,r;return 0===(null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)?void 0:r.readyState)}async publish(t,e,r){this.isInitialized(),await this.publisher.publish(t,e,r),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now(),transportType:_o.relay})}async subscribe(t,e){var r;this.isInitialized(),"relay"===e?.transportType&&await this.toEstablishConnection();let i,n=(null==(r=this.subscriber.topicMap.get(t))?void 0:r[0])||"";const s=e=>{e.topic===t&&(this.subscriber.off(Io,s),i())};return await Promise.all([new Promise((t=>{i=t,this.subscriber.on(Io,s)})),new Promise((async r=>{n=await this.subscriber.subscribe(t,e)||n,r()}))]),n}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map((t=>t.promise)))}catch(t){this.logger.warn(t)}this.hasExperiencedNetworkDisruption||this.connected?await K(this.provider.disconnect(),2e3,"provider.disconnect()").catch((()=>this.onProviderDisconnect())):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(t){await this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise((async(t,e)=>{const r=()=>{this.provider.off(yo,r),e(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(yo,r),await K(this.provider.connect(),(0,o.toMiliseconds)(o.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch((t=>{e(t)})).finally((()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0})),this.subscriber.start().catch((t=>{this.logger.error(t),this.onDisconnectHandler()})),this.hasExperiencedNetworkDisruption=!1,t()}))}catch(t){this.logger.error(t);const e=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(e.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(t){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Ts())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(t){if(0===t?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const e=t.sort(((t,e)=>t.publishedAt-e.publishedAt));this.logger.trace(`Batch of ${e.length} message events sorted`);for(const t of e)try{await this.onMessageEvent(t)}catch(t){this.logger.warn(t)}this.logger.trace(`Batch of ${e.length} message events processed`)}async onLinkMessageEvent(t,e){const{topic:r}=t;if(!e.sessionExists){const t={topic:r,expiry:V(o.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,t)}this.events.emit(lo,t),await this.recordMessageEvent(t)}startPingTimeout(){var t,e,r,i,n;if(T())try{null!=(e=null==(t=this.provider)?void 0:t.connection)&&e.socket&&(null==(n=null==(i=null==(r=this.provider)?void 0:r.connection)?void 0:i.socket)||n.once("ping",(()=>{this.resetPingTimeout()}))),this.resetPingTimeout()}catch(t){this.logger.warn(t)}}isConnectionStalled(t){return this.staleConnectionErrors.some((e=>t.includes(e)))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new to.F(new ro.A(function({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a}){const c=r.split("?"),u={auth:n,ua:U(t,e,i),projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},f=function(t,e){let r=h.parse(t);return r=R(R({},r),e),h.stringify(r)}(c[1]||"",u);return c[0]+"?"+f}({sdkVersion:Ao,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:e,message:r}=t;await this.messages.set(e,r)}async shouldIgnoreMessageEvent(t){const{topic:e,message:r}=t;if(!r||0===r.length)return this.logger.debug(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug(`Ignoring message for non-subscribed topic ${e}`),!0;const i=this.messages.has(e,r);return i&&this.logger.debug(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),(0,eo.isJsonRpcRequest)(t)){if(!t.method.endsWith("_subscription"))return;const e=t.params,{topic:r,message:i,publishedAt:n,attestation:s}=e.data,o={topic:r,message:i,publishedAt:n,transportType:_o.relay,attestation:s};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((t,e)=>{for(var r in e||(e={}))xc.call(e,r)&&Nc(t,r,e[r]);if(Pc)for(var r of Pc(e))Rc.call(e,r)&&Nc(t,r,e[r]);return t})({type:"event",event:e.id},o)),this.events.emit(e.id,o),await this.acknowledgePayload(t),await this.onMessageEvent(o)}else(0,eo.isJsonRpcResponse)(t)&&this.events.emit(po,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(lo,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const e=(0,eo.formatJsonRpcResult)(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(bo,this.onPayloadHandler),this.provider.off(vo,this.onConnectHandler),this.provider.off(yo,this.onDisconnectHandler),this.provider.off(wo,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let t=await Ts();!function(t){switch(k()){case O:!function(t){!q()&&D()&&(window.addEventListener("online",(()=>t(!0))),window.addEventListener("offline",(()=>t(!1))))}(t);break;case N:!function(t){q()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo&&r.g?.NetInfo.addEventListener((e=>t(e?.isConnected)))}(t)}}((async e=>{t!==e&&(t=e,e?await this.restartTransport().catch((t=>this.logger.error(t))):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}))}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit("relayer_disconnect"),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout((async()=>{await this.transportOpen().catch((t=>this.logger.error(t)))}),(0,o.toMiliseconds)(.1))))}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise((t=>{const e=setInterval((()=>{this.connected&&(clearInterval(e),t())}),this.connectionStatusPollingInterval)})),await this.transportOpen())}}var Cc=Object.defineProperty,Tc=Object.getOwnPropertySymbols,qc=Object.prototype.hasOwnProperty,Dc=Object.prototype.propertyIsEnumerable,kc=(t,e,r)=>e in t?Cc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bc=(t,e)=>{for(var r in e||(e={}))qc.call(e,r)&&kc(t,r,e[r]);if(Tc)for(var r of Tc(e))Dc.call(e,r)&&kc(t,r,e[r]);return t};class Uc extends $s{constructor(t,e,r,i=oo,n=void 0){super(t,e,r,i),this.core=t,this.logger=e,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=oo,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>{this.getKey&&null!==t&&!As(t)?this.map.set(this.getKey(t),t):function(t){var e;return null==(e=t?.proposer)?void 0:e.publicKey}(t)?this.map.set(t.id,t):function(t){return t?.topic}(t)&&this.map.set(t.topic,t)})),this.cached=[],this.initialized=!0)},this.set=async(t,e)=>{this.isInitialized(),this.map.has(t)?await this.update(t,e):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:t,value:e}),this.map.set(t,e),await this.persist())},this.get=t=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:t}),this.getData(t)),this.getAll=t=>(this.isInitialized(),t?this.values.filter((e=>Object.keys(t).every((r=>no()(e[r],t[r]))))):this.values),this.update=async(t,e)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:t,update:e});const r=Bc(Bc({},this.getData(t)),e);this.map.set(t,r),await this.persist()},this.delete=async(t,e)=>{this.isInitialized(),this.map.has(t)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:t,reason:e}),this.map.delete(t),this.addToRecentlyDeleted(t),await this.persist())},this.logger=(0,Us.U5)(e,this.name),this.storagePrefix=i,this.getKey=n}get context(){return(0,Us.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const e=this.map.get(t);if(!e){if(this.recentlyDeleted.includes(t)){const{message:e}=bs("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(e),new Error(e)}const{message:e}=bs("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(e),new Error(e)}return e}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:t}=bs("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}}class zc{constructor(t,e){this.core=t,this.logger=e,this.name="pairing",this.version="0.3",this.events=new(n()),this.initialized=!1,this.storagePrefix=oo,this.ignoredPayloadTypes=[1],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:t})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...t])]},this.create=async t=>{this.isInitialized();const e=jn(),r=await this.core.crypto.setSymKey(e),i=V(o.FIVE_MINUTES),n={protocol:"irn"},s={topic:r,expiry:i,relay:n,active:!1,methods:t?.methods},a=hs({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:e,relay:n,expiryTimestamp:i,methods:t?.methods});return this.events.emit(xo,s),this.core.expirer.set(r,i),await this.pairings.set(r,s),await this.core.relayer.subscribe(r,{transportType:t?.transportType}),{topic:r,uri:a}},this.pair=async t=>{this.isInitialized();const e=this.core.eventClient.createEvent({properties:{topic:t?.uri,trace:["pairing_started"]}});this.isValidPair(t,e);const{topic:r,symKey:i,relay:n,expiryTimestamp:s,methods:a}=as(t.uri);let c;if(e.props.properties.topic=r,e.addTrace("pairing_uri_validation_success"),e.addTrace("pairing_uri_not_expired"),this.pairings.keys.includes(r)){if(c=this.pairings.get(r),e.addTrace("existing_pairing"),c.active)throw e.setError("active_pairing_already_exists"),new Error(`Pairing already exists: ${r}. Please try again with a new connection URI.`);e.addTrace("pairing_not_expired")}const h=s||V(o.FIVE_MINUTES),u={topic:r,relay:n,expiry:h,active:!1,methods:a};this.core.expirer.set(r,h),await this.pairings.set(r,u),e.addTrace("store_new_pairing"),t.activatePairing&&await this.activate({topic:r}),this.events.emit(xo,u),e.addTrace("emit_inactive_pairing"),this.core.crypto.keychain.has(r)||await this.core.crypto.setSymKey(i,r),e.addTrace("subscribing_pairing_topic");try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{e.setError("no_internet_connection")}try{await this.core.relayer.subscribe(r,{relay:n})}catch(t){throw e.setError("subscribe_pairing_topic_failure"),t}return e.addTrace("subscribe_pairing_topic_success"),u},this.activate=async({topic:t})=>{this.isInitialized();const e=V(o.THIRTY_DAYS);this.core.expirer.set(t,e),await this.pairings.update(t,{active:!0,expiry:e})},this.ping=async t=>{this.isInitialized(),await this.isValidPing(t);const{topic:e}=t;if(this.pairings.keys.includes(e)){const t=await this.sendRequest(e,"wc_pairingPing",{}),{done:r,resolve:i,reject:n}=F();this.events.once(Q("pairing_ping",t),(({error:t})=>{t?n(t):i()})),await r()}},this.updateExpiry=async({topic:t,expiry:e})=>{this.isInitialized(),await this.pairings.update(t,{expiry:e})},this.updateMetadata=async({topic:t,metadata:e})=>{this.isInitialized(),await this.pairings.update(t,{peerMetadata:e})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async t=>{this.isInitialized(),await this.isValidDisconnect(t);const{topic:e}=t;this.pairings.keys.includes(e)&&(await this.sendRequest(e,"wc_pairingDelete",vs("USER_DISCONNECTED")),await this.deletePairing(e))},this.formatUriFromPairing=t=>{this.isInitialized();const{topic:e,relay:r,expiry:i,methods:n}=t,s=this.core.crypto.keychain.get(e);return hs({protocol:this.core.protocol,version:this.core.version,topic:e,symKey:s,relay:r,expiryTimestamp:i,methods:n})},this.sendRequest=async(t,e,r)=>{const i=(0,eo.formatJsonRpcRequest)(e,r),n=await this.core.crypto.encode(t,i),s=Po[e].req;return this.core.history.set(t,i),this.core.relayer.publish(t,n,s),i.id},this.sendResult=async(t,e,r)=>{const i=(0,eo.formatJsonRpcResult)(t,r),n=await this.core.crypto.encode(e,i),s=await this.core.history.get(e,t),o=Po[s.request.method].res;await this.core.relayer.publish(e,n,o),await this.core.history.resolve(i)},this.sendError=async(t,e,r)=>{const i=(0,eo.formatJsonRpcError)(t,r),n=await this.core.crypto.encode(e,i),s=await this.core.history.get(e,t),o=Po[s.request.method]?Po[s.request.method].res:Po.unregistered_method.res;await this.core.relayer.publish(e,n,o),await this.core.history.resolve(i)},this.deletePairing=async(t,e)=>{await this.core.relayer.unsubscribe(t),await Promise.all([this.pairings.delete(t,vs("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(t),e?Promise.resolve():this.core.expirer.del(t)])},this.cleanup=async()=>{const t=this.pairings.getAll().filter((t=>J(t.expiry)));await Promise.all(t.map((t=>this.deletePairing(t.topic))))},this.onRelayEventRequest=t=>{const{topic:e,payload:r}=t;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(e,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(e,r);default:return this.onUnknownRpcMethodRequest(e,r)}},this.onRelayEventResponse=async t=>{const{topic:e,payload:r}=t,i=(await this.core.history.get(e,r.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(e,r):this.onUnknownRpcMethodResponse(i)},this.onPairingPingRequest=async(t,e)=>{const{id:r}=e;try{this.isValidPing({topic:t}),await this.sendResult(r,t,!0),this.events.emit("pairing_ping",{id:r,topic:t})}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onPairingPingResponse=(t,e)=>{const{id:r}=e;setTimeout((()=>{(0,eo.isJsonRpcResult)(e)?this.events.emit(Q("pairing_ping",r),{}):(0,eo.isJsonRpcError)(e)&&this.events.emit(Q("pairing_ping",r),{error:e.error})}),500)},this.onPairingDeleteRequest=async(t,e)=>{const{id:r}=e;try{this.isValidDisconnect({topic:t}),await this.deletePairing(t),this.events.emit(Ro,{id:r,topic:t})}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onUnknownRpcMethodRequest=async(t,e)=>{const{id:r,method:i}=e;try{if(this.registeredMethods.includes(i))return;const e=vs("WC_METHOD_UNSUPPORTED",i);await this.sendError(r,t,e),this.logger.error(e)}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onUnknownRpcMethodResponse=t=>{this.registeredMethods.includes(t)||this.logger.error(vs("WC_METHOD_UNSUPPORTED",t))},this.isValidPair=(t,e)=>{var r;if(!Rs(t)){const{message:r}=bs("MISSING_OR_INVALID",`pair() params: ${t}`);throw e.setError(jo),new Error(r)}if(!function(t){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(_s(t,!1))return!!e(t)||e(X(t))}catch{}return!1}(t.uri)){const{message:r}=bs("MISSING_OR_INVALID",`pair() uri: ${t.uri}`);throw e.setError(jo),new Error(r)}const i=as(t?.uri);if(null==(r=i?.relay)||!r.protocol){const{message:t}=bs("MISSING_OR_INVALID","pair() uri#relay-protocol");throw e.setError(jo),new Error(t)}if(null==i||!i.symKey){const{message:t}=bs("MISSING_OR_INVALID","pair() uri#symKey");throw e.setError(jo),new Error(t)}if(null!=i&&i.expiryTimestamp&&(0,o.toMiliseconds)(i?.expiryTimestamp)<Date.now()){e.setError("pairing_expired");const{message:t}=bs("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(t)}},this.isValidPing=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidDisconnect=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidPairingTopic=async t=>{if(!_s(t,!1)){const{message:e}=bs("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.pairings.keys.includes(t)){const{message:e}=bs("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(J(this.pairings.get(t).expiry)){await this.deletePairing(t);const{message:e}=bs("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}},this.core=t,this.logger=(0,Us.U5)(e,this.name),this.pairings=new Uc(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,Us.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(lo,(async t=>{const{topic:e,message:r,transportType:i}=t;if(!this.pairings.keys.includes(e)||i===_o.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const n=await this.core.crypto.decode(e,r);try{(0,eo.isJsonRpcRequest)(n)?(this.core.history.set(e,n),this.onRelayEventRequest({topic:e,payload:n})):(0,eo.isJsonRpcResponse)(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:e,payload:n}),this.core.history.delete(e,n.id))}catch(t){this.logger.error(t)}}))}registerExpirerEvents(){this.core.expirer.on(Do,(async t=>{const{topic:e}=$(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit("pairing_expire",{topic:e}))}))}}class jc extends Ls{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new i.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=oo,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>this.records.set(t.id,t))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(t,e,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:t,request:e,chainId:r}),this.records.has(e.id))return;const i={id:e.id,topic:t,request:{method:e.method,params:e.params||null},chainId:r,expiry:V(o.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(No,i)},this.resolve=async t=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:t}),!this.records.has(t.id))return;const e=await this.getRecord(t.id);typeof e.response>"u"&&(e.response=(0,eo.isJsonRpcError)(t)?{error:t.error}:{result:t.result},this.records.set(e.id,e),this.persist(),this.events.emit(Oo,e))},this.get=async(t,e)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:t,id:e}),await this.getRecord(e)),this.delete=(t,e)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:e}),this.values.forEach((r=>{if(r.topic===t){if(typeof e<"u"&&r.id!==e)return;this.records.delete(r.id),this.events.emit(Co,r)}})),this.persist()},this.exists=async(t,e)=>(this.isInitialized(),!!this.records.has(e)&&(await this.getRecord(e)).topic===t),this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=(0,Us.U5)(e,this.name)}get context(){return(0,Us.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const t=[];return this.values.forEach((e=>{if(typeof e.response<"u")return;const r={topic:e.topic,request:(0,eo.formatJsonRpcRequest)(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(r)})),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const e=this.records.get(t);if(!e){const{message:e}=bs("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(e)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:t}=bs("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(No,(t=>{const e=No;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})})),this.events.on(Oo,(t=>{const e=Oo;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})})),this.events.on(Co,(t=>{const e=Co;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})})),this.core.heartbeat.on(ks.li.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach((e=>{(0,o.toMiliseconds)(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.records.delete(e.id),this.events.emit(Co,e,!1),t=!0)})),t&&this.persist()}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Lc extends Js{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new i.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=oo,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>this.expirations.set(t.target,t))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=t=>{try{const e=this.formatTarget(t);return typeof this.getExpiration(e)<"u"}catch{return!1}},this.set=(t,e)=>{this.isInitialized();const r=this.formatTarget(t),i={target:r,expiry:e};this.expirations.set(r,i),this.checkExpiry(r,i),this.events.emit(To,{target:r,expiration:i})},this.get=t=>{this.isInitialized();const e=this.formatTarget(t);return this.getExpiration(e)},this.del=t=>{if(this.isInitialized(),this.has(t)){const e=this.formatTarget(t),r=this.getExpiration(e);this.expirations.delete(e),this.events.emit(qo,{target:e,expiration:r})}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=(0,Us.U5)(e,this.name)}get context(){return(0,Us.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if("string"==typeof t)return function(t){return H("topic",t)}(t);if("number"==typeof t)return function(t){return H("id",t)}(t);const{message:e}=bs("UNKNOWN_TYPE","Target type: "+typeof t);throw new Error(e)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit("expirer_sync")}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:t}=bs("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const e=this.expirations.get(t);if(!e){const{message:e}=bs("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(e),new Error(e)}return e}checkExpiry(t,e){const{expiry:r}=e;(0,o.toMiliseconds)(r)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(Do,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((t,e)=>this.checkExpiry(e,t)))}registerEventListeners(){this.core.heartbeat.on(ks.li.pulse,(()=>this.checkExpirations())),this.events.on(To,(t=>{const e=To;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})),this.events.on(Do,(t=>{const e=Do;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})),this.events.on(qo,(t=>{const e=qo;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}}var Fc={};function Kc(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}function Hc(t){const e=Kc(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Object.defineProperty(Fc,"__esModule",{value:!0}),Fc.getLocalStorage=Fc.getLocalStorageOrThrow=Fc.getCrypto=Fc.getCryptoOrThrow=Fc.getLocation=Fc.getLocationOrThrow=Fc.getNavigator=Fc.getNavigatorOrThrow=$c=Fc.getDocument=Fc.getDocumentOrThrow=Fc.getFromWindowOrThrow=Fc.getFromWindow=void 0,Fc.getFromWindow=Kc,Fc.getFromWindowOrThrow=Hc,Fc.getDocumentOrThrow=function(){return Hc("document")};var $c=Fc.getDocument=function(){return Kc("document")};Fc.getNavigatorOrThrow=function(){return Hc("navigator")},Fc.getNavigator=function(){return Kc("navigator")},Fc.getLocationOrThrow=function(){return Hc("location")},Fc.getLocation=function(){return Kc("location")},Fc.getCryptoOrThrow=function(){return Hc("crypto")},Fc.getCrypto=function(){return Kc("crypto")},Fc.getLocalStorageOrThrow=function(){return Hc("localStorage")},Fc.getLocalStorage=function(){return Kc("localStorage")};class Vc extends Qs{constructor(t,e,r){super(t,e,r),this.core=t,this.logger=e,this.store=r,this.name="verify-api",this.verifyUrlV3=Uo,this.storagePrefix=oo,this.version=2,this.init=async()=>{var t;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,o.toMiliseconds)(null==(t=this.publicKey)?void 0:t.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async t=>{if(!D()||this.isDevEnv)return;const e=window.location.origin,{id:r,decryptedId:i}=t,n=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${e}&id=${r}&decryptedId=${i}`;try{const t=$c(),e=this.startAbortTimer(5*o.ONE_SECOND),i=await new Promise(((i,s)=>{const o=()=>{window.removeEventListener("message",c),t.body.removeChild(a),s("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=t.createElement("iframe");a.src=n,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=n=>{if(n.data&&"string"==typeof n.data)try{const s=JSON.parse(n.data);if("verify_attestation"===s.type){if((0,b.decodeJWT)(s.attestation).payload.id!==r)return;clearInterval(e),t.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),i(null===s.attestation?"":s.attestation)}}catch(t){this.logger.warn(t)}};t.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})}));return this.logger.debug("jwt attestation",i),i}catch(t){this.logger.warn(t)}return""},this.resolve=async t=>{if(this.isDevEnv)return"";const{attestationId:e,hash:r,encryptedId:i}=t;if(""===e)return void this.logger.debug("resolve: attestationId is empty, skipping");if(e){if((0,b.decodeJWT)(e).payload.id!==i)return;const t=await this.isValidJwtAttestation(e);if(t)return t.isVerified?t:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!r)return;const n=this.getVerifyUrl(t?.verifyUrl);return this.fetchAttestation(r,n)},this.fetchAttestation=async(t,e)=>{this.logger.debug(`resolving attestation: ${t} from url: ${e}`);const r=this.startAbortTimer(5*o.ONE_SECOND),i=await fetch(`${e}/attestation/${t}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(r),200===i.status?await i.json():void 0},this.getVerifyUrl=t=>{let e=t||Bo;return zo.includes(e)||(this.logger.info(`verify url: ${e}, not included in trusted list, assigning default: ${Bo}`),e=Bo),e},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const t=this.startAbortTimer(o.FIVE_SECONDS),e=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(t),await e.json()}catch(t){this.logger.warn(t)}},this.persistPublicKey=async t=>{this.logger.debug("persisting public key to local storage",t),await this.store.setItem(this.storeKey,t),this.publicKey=t},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async t=>{const e=await this.getPublicKey();try{if(e)return this.validateAttestation(t,e)}catch(t){this.logger.error(t),this.logger.warn("error validating attestation")}const r=await this.fetchAndPersistPublicKey();try{if(r)return this.validateAttestation(t,r)}catch(t){this.logger.error(t),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise((async t=>{const e=await this.fetchPublicKey();e&&(await this.persistPublicKey(e),t(e))}));const t=await this.fetchPromise;return this.fetchPromise=void 0,t},this.validateAttestation=(t,e)=>{const r=function(t,e){const[r,i,n]=t.split("."),s=function(t){return w.from(function(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}(t),"base64")}(n);if(64!==s.length)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${r}.${i}`,h=(new l.aD).update(w.from(c)).digest(),u=function(t){return new m.ec("p256").keyFromPublic({x:w.from(t.x,"base64").toString("hex"),y:w.from(t.y,"base64").toString("hex")},"hex")}(e),f=w.from(h).toString("hex");if(!u.verify(f,{r:o,s:a}))throw new Error("Invalid signature");return(0,b.decodeJWT)(t).payload}(t,e.publicKey),i={hasExpired:(0,o.toMiliseconds)(r.exp)<Date.now(),payload:r};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}},this.logger=(0,Us.U5)(e,this.name),this.abortController=new AbortController,this.isDevEnv=Z(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,Us.oI)(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout((()=>this.abortController.abort()),(0,o.toMiliseconds)(t))}}class Jc extends Gs{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.context="echo",this.registerDeviceToken=async t=>{const{clientId:e,token:r,notificationType:i,enableEncrypted:n=!1}=t,s=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:e,type:i,token:r,always_raw:n})})},this.logger=(0,Us.U5)(e,this.context)}}var Qc=Object.defineProperty,Gc=Object.getOwnPropertySymbols,Yc=Object.prototype.hasOwnProperty,Wc=Object.prototype.propertyIsEnumerable,Zc=(t,e,r)=>e in t?Qc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xc=(t,e)=>{for(var r in e||(e={}))Yc.call(e,r)&&Zc(t,r,e[r]);if(Gc)for(var r of Gc(e))Wc.call(e,r)&&Zc(t,r,e[r]);return t};class th extends Ys{constructor(t,e,r=!0){super(t,e,r),this.core=t,this.logger=e,this.context="event-client",this.storagePrefix=oo,this.storageVersion=.1,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Z())try{const t={eventId:W(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:U(this.core.relayer.protocol,this.core.relayer.version,Ao)}}};await this.sendEvent([t])}catch(t){this.logger.warn(t)}},this.createEvent=t=>{const{event:e="ERROR",type:r="",properties:{topic:i,trace:n}}=t,s=W(),o=this.core.projectId||"",a=Date.now(),c=Xc({eventId:s,timestamp:a,props:{event:e,type:r,properties:{topic:i,trace:n}},bundleId:o,domain:this.getAppDomain()},this.setMethods(s));return this.telemetryEnabled&&(this.events.set(s,c),this.shouldPersist=!0),c},this.getEvent=t=>{const{eventId:e,topic:r}=t;if(e)return this.events.get(e);const i=Array.from(this.events.values()).find((t=>t.props.properties.topic===r));return i?Xc(Xc({},i),this.setMethods(i.eventId)):void 0},this.deleteEvent=t=>{const{eventId:e}=t;this.events.delete(e),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(ks.li.pulse,(async()=>{this.shouldPersist&&await this.persist(),this.events.forEach((t=>{(0,o.fromMiliseconds)(Date.now())-(0,o.fromMiliseconds)(t.timestamp)>86400&&(this.events.delete(t.eventId),this.shouldPersist=!0)}))}))},this.setMethods=t=>({addTrace:e=>this.addTrace(t,e),setError:e=>this.setError(t,e)}),this.addTrace=(t,e)=>{const r=this.events.get(t);r&&(r.props.properties.trace.push(e),this.events.set(t,r),this.shouldPersist=!0)},this.setError=(t,e)=>{const r=this.events.get(t);r&&(r.props.type=e,r.timestamp=Date.now(),this.events.set(t,r),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const t=await this.core.storage.getItem(this.storageKey)||[];if(!t.length)return;t.forEach((t=>{this.events.set(t.eventId,Xc(Xc({},t),this.setMethods(t.eventId)))}))}catch(t){this.logger.warn(t)}},this.submit=async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const t=[];for(const[e,r]of this.events)r.props.type&&t.push(r);if(0!==t.length)try{if((await this.sendEvent(t)).ok)for(const e of t)this.events.delete(e.eventId),this.shouldPersist=!0}catch(t){this.logger.warn(t)}},this.sendEvent=async t=>{const e=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ao}${e}`,{method:"POST",body:JSON.stringify(t)})},this.getAppDomain=()=>B().url,this.logger=(0,Us.U5)(e,this.context),this.telemetryEnabled=r,r?this.restore().then((async()=>{await this.submit(),this.setEventListeners()})):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var eh=Object.defineProperty,rh=Object.getOwnPropertySymbols,ih=Object.prototype.hasOwnProperty,nh=Object.prototype.propertyIsEnumerable,sh=(t,e,r)=>e in t?eh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oh=(t,e)=>{for(var r in e||(e={}))ih.call(e,r)&&sh(t,r,e[r]);if(rh)for(var r of rh(e))nh.call(e,r)&&sh(t,r,e[r]);return t};class ah extends js{constructor(t){var e;super(t),this.protocol="wc",this.version=2,this.name=so,this.events=new i.EventEmitter,this.initialized=!1,this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.dispatchEnvelope=({topic:t,message:e,sessionExists:r})=>{if(!t||!e)return;const i={topic:t,message:e,publishedAt:Date.now(),transportType:_o.link_mode};this.relayer.onLinkMessageEvent(i,{sessionExists:r})},this.projectId=t?.projectId,this.relayUrl=t?.relayUrl||fo,this.customStoragePrefix=null!=t&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const r=(0,Us.iP)({level:"string"==typeof t?.logger&&t.logger?t.logger:"error"}),{logger:n,chunkLoggerController:s}=(0,Us.D5)({opts:r,maxSizeInBytes:t?.maxLogBlobSizeInBytes,loggerOverride:t?.logger});this.logChunkController=s,null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var t,e;null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(null==(e=this.logChunkController)||e.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,Us.U5)(n,this.name),this.heartbeat=new ks.VH,this.crypto=new dc(this,this.logger,t?.keychain),this.history=new jc(this,this.logger),this.expirer=new Lc(this,this.logger),this.storage=null!=t&&t.storage?t.storage:new Bs.A(oh(oh({},ao),t?.storageOptions)),this.relayer=new Oc({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new zc(this,this.logger),this.verify=new Vc(this,this.logger,this.storage),this.echoClient=new Jc(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new th(this,this.logger,t?.telemetryEnabled)}static async init(t){const e=new ah(t);await e.initialize();const r=await e.crypto.getClientId();return await e.storage.setItem("WALLETCONNECT_CLIENT_ID",r),e}get context(){return(0,Us.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var t;return null==(t=this.logChunkController)?void 0:t.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(t){this.linkModeSupportedApps.includes(t)||(this.linkModeSupportedApps.push(t),await this.storage.setItem(Mo,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Mo)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}const ch=ah,hh="client",uh=`wc@2:${hh}:`,fh=hh,dh="WALLETCONNECT_DEEPLINK_CHOICE",lh="Proposal expired",ph=o.SEVEN_DAYS,gh={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},mh={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},bh="IDLE",vh="ACTIVE",yh=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],wh="wc@1.5:auth:",Ah=`${wh}:PUB_KEY`;var _h=Object.defineProperty,Mh=Object.defineProperties,Ih=Object.getOwnPropertyDescriptors,Eh=Object.getOwnPropertySymbols,Sh=Object.prototype.hasOwnProperty,Ph=Object.prototype.propertyIsEnumerable,xh=(t,e,r)=>e in t?_h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rh=(t,e)=>{for(var r in e||(e={}))Sh.call(e,r)&&xh(t,r,e[r]);if(Eh)for(var r of Eh(e))Ph.call(e,r)&&xh(t,r,e[r]);return t},Nh=(t,e)=>Mh(t,Ih(e));class Oh extends Zs{constructor(t){super(t),this.name="engine",this.events=new(n()),this.initialized=!1,this.requestQueue={state:bh,queue:[]},this.sessionRequestQueue={state:bh,queue:[]},this.requestQueueDelay=o.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(gh)}),this.initialized=!0,setTimeout((()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),(0,o.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const e=Nh(Rh({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(e);const{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:s,relays:a}=e;let c,h=r,u=!1;try{h&&(u=this.client.core.pairing.pairings.get(h).active)}catch(t){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),t}if(!h||!u){const{topic:t,uri:e}=await this.client.core.pairing.create();h=t,c=e}if(!h){const{message:t}=bs("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(t)}const f=await this.client.core.crypto.generateKeyPair(),d=gh.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,l=V(d),p=Rh({requiredNamespaces:i,optionalNamespaces:n,relays:a??[{protocol:"irn"}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:l,pairingTopic:h},s&&{sessionProperties:s}),{reject:g,resolve:m,done:b}=F(d,lh);this.events.once(Q("session_connect"),(async({error:t,session:e})=>{if(t)g(t);else if(e){e.self.publicKey=f;const t=Nh(Rh({},e),{pairingTopic:p.pairingTopic,requiredNamespaces:p.requiredNamespaces,optionalNamespaces:p.optionalNamespaces,transportType:_o.relay});await this.client.session.set(e.topic,t),await this.setExpiry(e.topic,e.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:e.peer.metadata}),this.cleanupDuplicatePairings(t),m(t)}}));const v=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:p,throwOnFailedPublish:!0});return await this.setProposal(v,Rh({id:v},p)),{uri:c,approval:b}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(t){throw this.client.logger.error("pair() failed"),t}},this.approve=async t=>{var e,r,i;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(e=t?.id)?void 0:e.toString(),trace:[Lo]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(t){throw n.setError("no_internet_connection"),t}try{await this.isValidProposalId(t?.id)}catch(e){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),n.setError("proposal_not_found"),e}try{await this.isValidApprove(t)}catch(t){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError("session_approve_namespace_validation_failure"),t}const{id:s,relayProtocol:o,namespaces:a,sessionProperties:c,sessionConfig:h}=t,u=this.client.proposal.get(s);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:f,proposer:d,requiredNamespaces:l,optionalNamespaces:p}=u;let g=null==(r=this.client.core.eventClient)?void 0:r.getEvent({topic:f});g||(g=null==(i=this.client.core.eventClient)?void 0:i.createEvent({type:Lo,properties:{topic:f,trace:[Lo,"session_namespaces_validation_success"]}}));const m=await this.client.core.crypto.generateKeyPair(),b=d.publicKey,v=await this.client.core.crypto.generateSharedKey(m,b),y=Rh(Rh({relay:{protocol:o??"irn"},namespaces:a,controller:{publicKey:m,metadata:this.client.metadata},expiry:V(ph)},c&&{sessionProperties:c}),h&&{sessionConfig:h}),w=_o.relay;g.addTrace("subscribing_session_topic");try{await this.client.core.relayer.subscribe(v,{transportType:w})}catch(t){throw g.setError("subscribe_session_topic_failure"),t}g.addTrace("subscribe_session_topic_success");const A=Nh(Rh({},y),{topic:v,requiredNamespaces:l,optionalNamespaces:p,pairingTopic:f,acknowledged:!1,self:y.controller,peer:{publicKey:d.publicKey,metadata:d.metadata},controller:m,transportType:_o.relay});await this.client.session.set(v,A),g.addTrace("store_session");try{g.addTrace("publishing_session_settle"),await this.sendRequest({topic:v,method:"wc_sessionSettle",params:y,throwOnFailedPublish:!0}).catch((t=>{throw g?.setError("session_settle_publish_failure"),t})),g.addTrace("session_settle_publish_success"),g.addTrace("publishing_session_approve"),await this.sendResult({id:s,topic:f,result:{relay:{protocol:o??"irn"},responderPublicKey:m},throwOnFailedPublish:!0}).catch((t=>{throw g?.setError("session_approve_publish_failure"),t})),g.addTrace("session_approve_publish_success")}catch(t){throw this.client.logger.error(t),this.client.session.delete(v,vs("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(v),t}return this.client.core.eventClient.deleteEvent({eventId:g.eventId}),await this.client.core.pairing.updateMetadata({topic:f,metadata:d.metadata}),await this.client.proposal.delete(s,vs("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(v,V(ph)),{topic:v,acknowledged:()=>Promise.resolve(this.client.session.get(v))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(t){throw this.client.logger.error("reject() -> isValidReject() failed"),t}const{id:e,reason:r}=t;let i;try{i=this.client.proposal.get(e).pairingTopic}catch(t){throw this.client.logger.error(`reject() -> proposal.get(${e}) failed`),t}i&&(await this.sendError({id:e,topic:i,error:r,rpcOpts:gh.wc_sessionPropose.reject}),await this.client.proposal.delete(e,vs("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(t){throw this.client.logger.error("update() -> isValidUpdate() failed"),t}const{topic:e,namespaces:r}=t,{done:i,resolve:n,reject:s}=F(),o=(0,eo.payloadId)(),a=(0,eo.getBigIntRpcId)().toString(),c=this.client.session.get(e).namespaces;return this.events.once(Q("session_update",o),(({error:t})=>{t?s(t):n()})),await this.client.session.update(e,{namespaces:r}),await this.sendRequest({topic:e,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:a}).catch((t=>{this.client.logger.error(t),this.client.session.update(e,{namespaces:c}),s(t)})),{acknowledged:i}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(t){throw this.client.logger.error("extend() -> isValidExtend() failed"),t}const{topic:e}=t,r=(0,eo.payloadId)(),{done:i,resolve:n,reject:s}=F();return this.events.once(Q("session_extend",r),(({error:t})=>{t?s(t):n()})),await this.setExpiry(e,V(ph)),this.sendRequest({topic:e,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch((t=>{s(t)})),{acknowledged:i}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(t){throw this.client.logger.error("request() -> isValidRequest() failed"),t}const{chainId:e,request:i,topic:n,expiry:s=gh.wc_sessionRequest.req.ttl}=t,o=this.client.session.get(n);o?.transportType===_o.relay&&await this.confirmOnlineStateOrThrow();const c=(0,eo.payloadId)(),h=(0,eo.getBigIntRpcId)().toString(),{done:u,resolve:f,reject:d}=F(s,"Request expired. Please try again.");this.events.once(Q("session_request",c),(({error:t,result:e})=>{t?d(t):f(e)}));const l=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);return l?(await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:Nh(Rh({},i),{expiryTimestamp:V(s)}),chainId:e},expiry:s,throwOnFailedPublish:!0,appLink:l}).catch((t=>d(t))),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:e,id:c}),await u()):await Promise.all([new Promise((async t=>{await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:Nh(Rh({},i),{expiryTimestamp:V(s)}),chainId:e},expiry:s,throwOnFailedPublish:!0}).catch((t=>d(t))),this.client.events.emit("session_request_sent",{topic:n,request:i,chainId:e,id:c}),t()})),new Promise((async t=>{var e;if(null==(e=o.sessionConfig)||!e.disableDeepLink){const t=await async function(t,e){let r="";try{if(D()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(t){console.error(t)}return r}(this.client.core.storage,dh);await async function({id:t,topic:e,wcDeepLink:i}){var n;try{if(!i)return;const s="string"==typeof i?JSON.parse(i):i,o=s?.href;if("string"!=typeof o)return;const c=function(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let n=`${t}`;return n=t.startsWith("https://t.me")?`${n}${t.includes("?")?"&startapp=":"?startapp="}${function(t,e=!1){const r=w.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}(i,!0)}`:`${n}/wc?${i}`,n}(o,t,e),h=k();if(h===O){if(null==(n=(0,a.getDocument)())||!n.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");c.startsWith("https://")||c.startsWith("http://")?window.open(c,"_blank","noreferrer noopener"):window.open(c,typeof window<"u"&&(window.TelegramWebviewProxy||window.Telegram||window.TelegramWebviewProxyProto)?"_blank":"_self","noreferrer noopener")}else h===N&&typeof(null==r.g?void 0:r.g.Linking)<"u"&&await r.g.Linking.openURL(c)}catch(t){console.error(t)}}({id:c,topic:n,wcDeepLink:t})}t()})),u()]).then((t=>t[2]))},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:e,response:r}=t,{id:i}=r,n=this.client.session.get(e);n.transportType===_o.relay&&await this.confirmOnlineStateOrThrow();const s=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,eo.isJsonRpcResult)(r)?await this.sendResult({id:i,topic:e,result:r.result,throwOnFailedPublish:!0,appLink:s}):(0,eo.isJsonRpcError)(r)&&await this.sendError({id:i,topic:e,error:r.error,appLink:s}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(t){throw this.client.logger.error("ping() -> isValidPing() failed"),t}const{topic:e}=t;if(this.client.session.keys.includes(e)){const t=(0,eo.payloadId)(),r=(0,eo.getBigIntRpcId)().toString(),{done:i,resolve:n,reject:s}=F();this.events.once(Q("session_ping",t),(({error:t})=>{t?s(t):n()})),await Promise.all([this.sendRequest({topic:e,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:t,relayRpcId:r}),i()])}else this.client.core.pairing.pairings.keys.includes(e)&&await this.client.core.pairing.ping({topic:e})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:e,event:r,chainId:i}=t,n=(0,eo.getBigIntRpcId)().toString();await this.sendRequest({topic:e,method:"wc_sessionEvent",params:{event:r,chainId:i},throwOnFailedPublish:!0,relayRpcId:n})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:e}=t;if(this.client.session.keys.includes(e))await this.sendRequest({topic:e,method:"wc_sessionDelete",params:vs("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:e,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=bs("MISMATCHED_TOPIC",`Session or pairing topic not found: ${e}`);throw new Error(t)}await this.client.core.pairing.disconnect({topic:e})}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter((e=>function(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return!!z(n,i)&&(i.forEach((e=>{const{accounts:i,methods:n,events:o}=t.namespaces[e],a=fs(i),c=r[e];z(M(e,c),a)&&z(c.methods,n)&&z(c.events,o)||(s=!1)})),s)}(e,t)))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,e)=>{var r;this.isInitialized(),this.isValidAuthenticate(t);const i=e&&this.client.core.linkModeSupportedApps.includes(e)&&(null==(r=this.client.metadata.redirect)?void 0:r.linkMode),n=i?_o.link_mode:_o.relay;n===_o.relay&&await this.confirmOnlineStateOrThrow();const{chains:s,statement:o="",uri:a,domain:c,nonce:h,type:u,exp:f,nbf:d,methods:l=[],expiry:p}=t,g=[...t.resources||[]],{topic:m,uri:b}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:m,uri:b}});const v=await this.client.core.crypto.generateKeyPair(),y=Ln(v);if(await Promise.all([this.client.auth.authKeys.set(Ah,{responseTopic:y,publicKey:v}),this.client.auth.pairingTopics.set(y,{topic:y,pairingTopic:m})]),await this.client.core.relayer.subscribe(y,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${m}`),l.length>0){const{namespace:t}=A(s[0]);let e=function(t,e,r){const i=function(t,e,r,i={}){return r?.sort(((t,e)=>t.localeCompare(e))),{att:{[t]:xn(e,r,i)}}}(t,e,r);return Rn(i)}(t,"request",l);qn(g)&&(e=On(e,g.pop())),g.push(e)}const w=p&&p>gh.wc_sessionAuthenticate.req.ttl?p:gh.wc_sessionAuthenticate.req.ttl,_={authPayload:{type:u??"caip122",chains:s,statement:o,aud:a,domain:c,version:"1",nonce:h,iat:(new Date).toISOString(),exp:f,nbf:d,resources:g},requester:{publicKey:v,metadata:this.client.metadata},expiryTimestamp:V(w)},M={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:s,methods:[...new Set(["personal_sign",...l])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:m,proposer:{publicKey:v,metadata:this.client.metadata},expiryTimestamp:V(gh.wc_sessionPropose.req.ttl)},{done:I,resolve:E,reject:S}=F(w,"Request expired"),P=async({error:t,session:e})=>{if(this.events.off(Q("session_request",R),x),t)S(t);else if(e){e.self.publicKey=v,await this.client.session.set(e.topic,e),await this.setExpiry(e.topic,e.expiry),m&&await this.client.core.pairing.updateMetadata({topic:m,metadata:e.peer.metadata});const t=this.client.session.get(e.topic);await this.deleteProposal(N),E({session:t})}},x=async t=>{var r,i,s;if(await this.deletePendingAuthRequest(R,{message:"fulfilled",code:0}),t.error){const e=vs("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return t.error.code===e.code?void 0:(this.events.off(Q("session_connect"),P),S(t.error.message))}await this.deleteProposal(N),this.events.off(Q("session_connect"),P);const{cacaos:o,responder:a}=t.result,c=[],h=[];for(const t of o){await En({cacao:t,projectId:this.client.core.projectId})||(this.client.logger.error(t,"Signature verification failed"),S(vs("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:e}=t,r=qn(e.resources),i=[Mn(e.iss)],n=In(e.iss);if(r){const t=Cn(r),e=Tn(r);c.push(...t),i.push(...e)}for(const t of i)h.push(`${t}:${n}`)}const u=await this.client.core.crypto.generateSharedKey(v,a.publicKey);let f;c.length>0&&(f={topic:u,acknowledged:!0,self:{publicKey:v,metadata:this.client.metadata},peer:a,controller:a.publicKey,expiry:V(ph),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:m,namespaces:ps([...new Set(c)],[...new Set(h)]),transportType:n},await this.client.core.relayer.subscribe(u,{transportType:n}),await this.client.session.set(u,f),m&&await this.client.core.pairing.updateMetadata({topic:m,metadata:a.metadata}),f=this.client.session.get(u)),null!=(r=this.client.metadata.redirect)&&r.linkMode&&null!=(i=a.metadata.redirect)&&i.linkMode&&null!=(s=a.metadata.redirect)&&s.universal&&e&&(this.client.core.addLinkModeSupportedApp(a.metadata.redirect.universal),this.client.session.update(u,{transportType:_o.link_mode})),E({auths:o,session:f})},R=(0,eo.payloadId)(),N=(0,eo.payloadId)();let O;this.events.once(Q("session_connect"),P),this.events.once(Q("session_request",R),x);try{if(i){const t=(0,eo.formatJsonRpcRequest)("wc_sessionAuthenticate",_,R);this.client.core.history.set(m,t);const r=await this.client.core.crypto.encode("",t,{type:2,encoding:Un});O=us(e,m,r)}else await Promise.all([this.sendRequest({topic:m,method:"wc_sessionAuthenticate",params:_,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:R}),this.sendRequest({topic:m,method:"wc_sessionPropose",params:M,expiry:gh.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:N})])}catch(t){throw this.events.off(Q("session_connect"),P),this.events.off(Q("session_request",R),x),t}return await this.setProposal(N,Rh({id:N},M)),await this.setAuthRequest(R,{request:Nh(Rh({},_),{verifyContext:{}}),pairingTopic:m,transportType:n}),{uri:O??b,response:I}},this.approveSessionAuthenticate=async t=>{const{id:e,auths:r}=t,i=this.client.core.eventClient.createEvent({properties:{topic:e.toString(),trace:["authenticated_session_approve_started"]}});try{this.isInitialized()}catch(t){throw i.setError("no_internet_connection"),t}const n=this.getPendingAuthRequest(e);if(!n)throw i.setError("authenticated_session_pending_request_not_found"),new Error(`Could not find pending auth request with id ${e}`);const s=n.transportType||_o.relay;s===_o.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=Ln(o),h={type:1,receiverPublicKey:o,senderPublicKey:a},u=[],f=[];for(const t of r){if(!await En({cacao:t,projectId:this.client.core.projectId})){i.setError("invalid_cacao");const t=vs("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:e,topic:c,error:t,encodeOpts:h}),new Error(t.message)}i.addTrace("cacaos_verified");const{p:r}=t,n=qn(r.resources),s=[Mn(r.iss)],o=In(r.iss);if(n){const t=Cn(n),e=Tn(n);u.push(...t),s.push(...e)}for(const t of s)f.push(`${t}:${o}`)}const d=await this.client.core.crypto.generateSharedKey(a,o);let l;if(i.addTrace("create_authenticated_session_topic"),u?.length>0){l={topic:d,acknowledged:!0,self:{publicKey:a,metadata:this.client.metadata},peer:{publicKey:o,metadata:n.requester.metadata},controller:o,expiry:V(ph),authentication:r,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:ps([...new Set(u)],[...new Set(f)]),transportType:s},i.addTrace("subscribing_authenticated_session_topic");try{await this.client.core.relayer.subscribe(d,{transportType:s})}catch(t){throw i.setError("subscribe_authenticated_session_topic_failure"),t}i.addTrace("subscribe_authenticated_session_topic_success"),await this.client.session.set(d,l),i.addTrace("store_authenticated_session"),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}i.addTrace("publishing_authenticated_session_approve");try{await this.sendResult({topic:c,id:e,result:{cacaos:r,responder:{publicKey:a,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,s)})}catch(t){throw i.setError("authenticated_session_approve_publish_failure"),t}return await this.client.auth.requests.delete(e,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:i.eventId}),{session:l}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:e,reason:r}=t,i=this.getPendingAuthRequest(e);if(!i)throw new Error(`Could not find pending auth request with id ${e}`);i.transportType===_o.relay&&await this.confirmOnlineStateOrThrow();const n=i.requester.publicKey,s=await this.client.core.crypto.generateKeyPair(),o=Ln(n),a={type:1,receiverPublicKey:n,senderPublicKey:s};await this.sendError({id:e,topic:o,error:r,encodeOpts:a,rpcOpts:gh.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(i.requester.metadata,i.transportType)}),await this.client.auth.requests.delete(e,{message:"rejected",code:0}),await this.client.proposal.delete(e,vs("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:e,iss:r}=t;return Sn(e,r)},this.processRelayMessageCache=()=>{setTimeout((async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}}),50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const e=this.client.core.pairing.pairings.get(t.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter((r=>{var i,n;return(null==(i=r.peerMetadata)?void 0:i.url)&&(null==(n=r.peerMetadata)?void 0:n.url)===t.peer.metadata.url&&r.topic&&r.topic!==e.topic}));if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map((t=>this.client.core.pairing.disconnect({topic:t.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(t){this.client.logger.error(t)}},this.deleteSession=async t=>{var e;const{topic:r,expirerHasDeleted:i=!1,emitEvent:n=!0,id:s=0}=t,{self:o}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await this.client.session.delete(r,vs("USER_DISCONNECTED")),this.addToRecentlyDeleted(r,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),i||this.client.core.expirer.del(r),this.client.core.storage.removeItem(dh).catch((t=>this.client.logger.warn(t))),this.getPendingSessionRequests().forEach((t=>{t.topic===r&&this.deletePendingSessionRequest(t.id,vs("USER_DISCONNECTED"))})),r===(null==(e=this.sessionRequestQueue.queue[0])?void 0:e.topic)&&(this.sessionRequestQueue.state=bh),n&&this.client.events.emit("session_delete",{id:s,topic:r})},this.deleteProposal=async(t,e)=>{if(e)try{const e=this.client.proposal.get(t),r=this.client.core.eventClient.getEvent({topic:e.pairingTopic});r?.setError("proposal_expired")}catch{}await Promise.all([this.client.proposal.delete(t,vs("USER_DISCONNECTED")),e?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,e,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,e),r?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter((e=>e.id!==t)),r&&(this.sessionRequestQueue.state=bh,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,e,r=!1)=>{await Promise.all([this.client.auth.requests.delete(t,e),r?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,e)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,e),await this.client.session.update(t,{expiry:e}))},this.setProposal=async(t,e)=>{this.client.core.expirer.set(t,V(gh.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,e)},this.setAuthRequest=async(t,e)=>{const{request:r,pairingTopic:i,transportType:n=_o.relay}=e;this.client.core.expirer.set(t,r.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:r.authPayload,requester:r.requester,expiryTimestamp:r.expiryTimestamp,id:t,pairingTopic:i,verifyContext:r.verifyContext,transportType:n})},this.setPendingSessionRequest=async t=>{const{id:e,topic:r,params:i,verifyContext:n}=t,s=i.request.expiryTimestamp||V(gh.wc_sessionRequest.req.ttl);this.client.core.expirer.set(e,s),await this.client.pendingRequest.set(e,{id:e,topic:r,params:i,verifyContext:n})},this.sendRequest=async t=>{const{topic:e,method:i,params:n,expiry:s,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c,appLink:h}=t,u=(0,eo.formatJsonRpcRequest)(i,n,a);let f;const d=!!h;try{const t=d?Un:Bn;f=await this.client.core.crypto.encode(e,u,{encoding:t})}catch(t){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${e} failed`),t}let l;if(yh.includes(i)){const t=Fn(JSON.stringify(u)),e=Fn(f);l=await this.client.core.verify.register({id:e,decryptedId:t})}const p=gh[i].req;if(p.attestation=l,s&&(p.ttl=s),o&&(p.id=o),this.client.core.history.set(e,u),d){const t=us(h,e,f);await r.g.Linking.openURL(t,this.client.name)}else{const t=gh[i].req;s&&(t.ttl=s),o&&(t.id=o),c?(t.internal=Nh(Rh({},t.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(e,f,t)):this.client.core.relayer.publish(e,f,t).catch((t=>this.client.logger.error(t)))}return u.id},this.sendResult=async t=>{const{id:e,topic:i,result:n,throwOnFailedPublish:s,encodeOpts:o,appLink:a}=t,c=(0,eo.formatJsonRpcResult)(e,n);let h;const u=a&&typeof(null==r.g?void 0:r.g.Linking)<"u";try{const t=u?Un:Bn;h=await this.client.core.crypto.encode(i,c,Nh(Rh({},o||{}),{encoding:t}))}catch(t){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),t}let f;try{f=await this.client.core.history.get(i,e)}catch(t){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${e}) failed`),t}if(u){const t=us(a,i,h);await r.g.Linking.openURL(t,this.client.name)}else{const t=gh[f.request.method].res;s?(t.internal=Nh(Rh({},t.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,h,t)):this.client.core.relayer.publish(i,h,t).catch((t=>this.client.logger.error(t)))}await this.client.core.history.resolve(c)},this.sendError=async t=>{const{id:e,topic:i,error:n,encodeOpts:s,rpcOpts:o,appLink:a}=t,c=(0,eo.formatJsonRpcError)(e,n);let h;const u=a&&typeof(null==r.g?void 0:r.g.Linking)<"u";try{const t=u?Un:Bn;h=await this.client.core.crypto.encode(i,c,Nh(Rh({},s||{}),{encoding:t}))}catch(t){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),t}let f;try{f=await this.client.core.history.get(i,e)}catch(t){throw this.client.logger.error(`sendError() -> history.get(${i}, ${e}) failed`),t}if(u){const t=us(a,i,h);await r.g.Linking.openURL(t,this.client.name)}else{const t=o||gh[f.request.method].res;this.client.core.relayer.publish(i,h,t)}await this.client.core.history.resolve(c)},this.cleanup=async()=>{const t=[],e=[];this.client.session.getAll().forEach((e=>{let r=!1;J(e.expiry)&&(r=!0),this.client.core.crypto.keychain.has(e.topic)||(r=!0),r&&t.push(e.topic)})),this.client.proposal.getAll().forEach((t=>{J(t.expiryTimestamp)&&e.push(t.id)})),await Promise.all([...t.map((t=>this.deleteSession({topic:t}))),...e.map((t=>this.deleteProposal(t)))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state!==vh){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=vh;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(t){this.client.logger.warn(t)}}this.requestQueue.state=bh}else this.client.logger.info("Request queue already active, skipping...")},this.processRequest=async t=>{const{topic:e,payload:r,attestation:i,transportType:n,encryptedId:s}=t,o=r.method;if(!this.shouldIgnorePairingRequest({topic:e,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:e,payload:r,attestation:i,encryptedId:s});case"wc_sessionSettle":return await this.onSessionSettleRequest(e,r);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(e,r);case"wc_sessionExtend":return await this.onSessionExtendRequest(e,r);case"wc_sessionPing":return await this.onSessionPingRequest(e,r);case"wc_sessionDelete":return await this.onSessionDeleteRequest(e,r);case"wc_sessionRequest":return await this.onSessionRequest({topic:e,payload:r,attestation:i,encryptedId:s,transportType:n});case"wc_sessionEvent":return await this.onSessionEventRequest(e,r);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:e,payload:r,attestation:i,encryptedId:s,transportType:n});default:return this.client.logger.info(`Unsupported request method ${o}`)}},this.onRelayEventResponse=async t=>{const{topic:e,payload:r,transportType:i}=t,n=(await this.client.core.history.get(e,r.id)).request.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeResponse(e,r,i);case"wc_sessionSettle":return this.onSessionSettleResponse(e,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(e,r);case"wc_sessionExtend":return this.onSessionExtendResponse(e,r);case"wc_sessionPing":return this.onSessionPingResponse(e,r);case"wc_sessionRequest":return this.onSessionRequestResponse(e,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(e,r);default:return this.client.logger.info(`Unsupported response method ${n}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:e}=t,{message:r}=bs("MISSING_OR_INVALID",`Decoded payload on topic ${e} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)},this.shouldIgnorePairingRequest=t=>{const{topic:e,requestMethod:r}=t,i=this.expectedPairingMethodMap.get(e);return!(!i||i.includes(r)||!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))},this.onSessionProposeRequest=async t=>{const{topic:e,payload:r,attestation:i,encryptedId:n}=t,{params:s,id:o}=r;try{const t=this.client.core.eventClient.getEvent({topic:e});this.isValidConnect(Rh({},r.params));const a=s.expiryTimestamp||V(gh.wc_sessionPropose.req.ttl),c=Rh({id:o,pairingTopic:e,expiryTimestamp:a},s);await this.setProposal(o,c);const h=await this.getVerifyContext({attestationId:i,hash:Fn(JSON.stringify(r)),encryptedId:n,metadata:c.proposer.metadata});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),t?.setError("proposal_listener_not_found")),t?.addTrace("emit_session_proposal"),this.client.events.emit("session_proposal",{id:o,params:c,verifyContext:h})}catch(t){await this.sendError({id:o,topic:e,error:t,rpcOpts:gh.wc_sessionPropose.autoReject}),this.client.logger.error(t)}},this.onSessionProposeResponse=async(t,e,r)=>{const{id:i}=e;if((0,eo.isJsonRpcResult)(e)){const{result:n}=e;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:n});const s=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:s});const o=s.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=n.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const h=await this.client.core.relayer.subscribe(c,{transportType:r});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:t})}else if((0,eo.isJsonRpcError)(e)){await this.client.proposal.delete(i,vs("USER_DISCONNECTED"));const t=Q("session_connect");if(0===this.events.listenerCount(t))throw new Error(`emitting ${t} without any listeners, 954`);this.events.emit(Q("session_connect"),{error:e.error})}},this.onSessionSettleRequest=async(t,e)=>{const{id:r,params:i}=e;try{this.isValidSessionSettleRequest(i);const{relay:r,controller:n,expiry:s,namespaces:o,sessionProperties:a,sessionConfig:c}=e.params,h=Nh(Rh(Rh({topic:t,relay:r,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:n.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},a&&{sessionProperties:a}),c&&{sessionConfig:c}),{transportType:_o.relay}),u=Q("session_connect");if(0===this.events.listenerCount(u))throw new Error(`emitting ${u} without any listeners 997`);this.events.emit(Q("session_connect"),{session:h}),await this.sendResult({id:e.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionSettleResponse=async(t,e)=>{const{id:r}=e;(0,eo.isJsonRpcResult)(e)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Q("session_approve",r),{})):(0,eo.isJsonRpcError)(e)&&(await this.client.session.delete(t,vs("USER_DISCONNECTED")),this.events.emit(Q("session_approve",r),{error:e.error}))},this.onSessionUpdateRequest=async(t,e)=>{const{params:r,id:i}=e;try{const e=`${t}_session_update`,n=Ds.get(e);if(n&&this.isRequestOutOfSync(n,i))return this.client.logger.info(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:t,error:vs("INVALID_UPDATE_REQUEST")});this.isValidUpdate(Rh({topic:t},r));try{Ds.set(e,i),await this.client.session.update(t,{namespaces:r.namespaces}),await this.sendResult({id:i,topic:t,result:!0,throwOnFailedPublish:!0})}catch(t){throw Ds.delete(e),t}this.client.events.emit("session_update",{id:i,topic:t,params:r})}catch(e){await this.sendError({id:i,topic:t,error:e}),this.client.logger.error(e)}},this.isRequestOutOfSync=(t,e)=>parseInt(e.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,e)=>{const{id:r}=e,i=Q("session_update",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,eo.isJsonRpcResult)(e)?this.events.emit(Q("session_update",r),{}):(0,eo.isJsonRpcError)(e)&&this.events.emit(Q("session_update",r),{error:e.error})},this.onSessionExtendRequest=async(t,e)=>{const{id:r}=e;try{this.isValidExtend({topic:t}),await this.setExpiry(t,V(ph)),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:r,topic:t})}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionExtendResponse=(t,e)=>{const{id:r}=e,i=Q("session_extend",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,eo.isJsonRpcResult)(e)?this.events.emit(Q("session_extend",r),{}):(0,eo.isJsonRpcError)(e)&&this.events.emit(Q("session_extend",r),{error:e.error})},this.onSessionPingRequest=async(t,e)=>{const{id:r}=e;try{this.isValidPing({topic:t}),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:t})}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionPingResponse=(t,e)=>{const{id:r}=e,i=Q("session_ping",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);setTimeout((()=>{(0,eo.isJsonRpcResult)(e)?this.events.emit(Q("session_ping",r),{}):(0,eo.isJsonRpcError)(e)&&this.events.emit(Q("session_ping",r),{error:e.error})}),500)},this.onSessionDeleteRequest=async(t,e)=>{const{id:r}=e;try{this.isValidDisconnect({topic:t,reason:e.params}),Promise.all([new Promise((e=>{this.client.core.relayer.once(mo,(async()=>{e(await this.deleteSession({topic:t,id:r}))}))})),this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:vs("USER_DISCONNECTED")})]).catch((t=>this.client.logger.error(t)))}catch(t){this.client.logger.error(t)}},this.onSessionRequest=async t=>{var e,r,i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=t,{id:h,params:u}=s;try{await this.isValidRequest(Rh({topic:n},u));const t=this.client.session.get(n),s={id:h,topic:n,params:u,verifyContext:await this.getVerifyContext({attestationId:o,hash:Fn(JSON.stringify((0,eo.formatJsonRpcRequest)("wc_sessionRequest",u,h))),encryptedId:a,metadata:t.peer.metadata,transportType:c})};await this.setPendingSessionRequest(s),c===_o.link_mode&&null!=(e=t.peer.metadata.redirect)&&e.universal&&this.client.core.addLinkModeSupportedApp(null==(r=t.peer.metadata.redirect)?void 0:r.universal),null!=(i=this.client.signConfig)&&i.disableRequestQueue?this.emitSessionRequest(s):(this.addSessionRequestToSessionRequestQueue(s),this.processSessionRequestQueue())}catch(t){await this.sendError({id:h,topic:n,error:t}),this.client.logger.error(t)}},this.onSessionRequestResponse=(t,e)=>{const{id:r}=e,i=Q("session_request",r);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,eo.isJsonRpcResult)(e)?this.events.emit(Q("session_request",r),{result:e.result}):(0,eo.isJsonRpcError)(e)&&this.events.emit(Q("session_request",r),{error:e.error})},this.onSessionEventRequest=async(t,e)=>{const{id:r,params:i}=e;try{const e=`${t}_session_event_${i.event.name}`,n=Ds.get(e);if(n&&this.isRequestOutOfSync(n,r))return void this.client.logger.info(`Discarding out of sync request - ${r}`);this.isValidEmit(Rh({topic:t},i)),this.client.events.emit("session_event",{id:r,topic:t,params:i}),Ds.set(e,r)}catch(e){await this.sendError({id:r,topic:t,error:e}),this.client.logger.error(e)}},this.onSessionAuthenticateResponse=(t,e)=>{const{id:r}=e;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:e}),(0,eo.isJsonRpcResult)(e)?this.events.emit(Q("session_request",r),{result:e.result}):(0,eo.isJsonRpcError)(e)&&this.events.emit(Q("session_request",r),{error:e.error})},this.onSessionAuthenticateRequest=async t=>{var e;const{topic:r,payload:i,attestation:n,encryptedId:s,transportType:o}=t;try{const{requester:t,authPayload:a,expiryTimestamp:c}=i.params,h=await this.getVerifyContext({attestationId:n,hash:Fn(JSON.stringify(i)),encryptedId:s,metadata:t.metadata,transportType:o}),u={requester:t,pairingTopic:r,id:i.id,authPayload:a,verifyContext:h,expiryTimestamp:c};await this.setAuthRequest(i.id,{request:u,pairingTopic:r,transportType:o}),o===_o.link_mode&&null!=(e=t.metadata.redirect)&&e.universal&&this.client.core.addLinkModeSupportedApp(t.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:r,params:i.params,id:i.id,verifyContext:h})}catch(t){this.client.logger.error(t);const e=i.params.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),s=this.getAppLinkIfEnabled(i.params.requester.metadata,o),a={type:1,receiverPublicKey:e,senderPublicKey:n};await this.sendError({id:i.id,topic:r,error:t,encodeOpts:a,rpcOpts:gh.wc_sessionAuthenticate.autoReject,appLink:s})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=bh,this.processSessionRequestQueue()}),(0,o.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:e})=>{const r=this.client.core.history.pending;r.length>0&&r.filter((e=>e.topic===t&&"wc_sessionRequest"===e.request.method)).forEach((t=>{const r=Q("session_request",t.request.id);if(0===this.events.listenerCount(r))throw new Error(`emitting ${r} without any listeners`);this.events.emit(Q("session_request",t.request.id),{error:e})}))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===vh)return void this.client.logger.info("session request queue is already active.");const t=this.sessionRequestQueue.queue[0];if(t)try{this.sessionRequestQueue.state=vh,this.emitSessionRequest(t)}catch(t){this.client.logger.error(t)}else this.client.logger.info("session request queue is empty.")},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const e=this.client.proposal.getAll().find((e=>e.pairingTopic===t.topic));e&&this.onSessionProposeRequest({topic:t.topic,payload:(0,eo.formatJsonRpcRequest)("wc_sessionPropose",{requiredNamespaces:e.requiredNamespaces,optionalNamespaces:e.optionalNamespaces,relays:e.relays,proposer:e.proposer,sessionProperties:e.sessionProperties},e.id)})},this.isValidConnect=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(e)}const{pairingTopic:e,requiredNamespaces:r,optionalNamespaces:i,sessionProperties:n,relays:s}=t;if(As(e)||await this.isValidPairingTopic(e),!function(t){let e=!1;return t?t&&ys(t)&&t.length&&t.forEach((t=>{e=xs(t)})):e=!0,e}(s)){const{message:t}=bs("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(t)}!As(r)&&0!==ws(r)&&this.validateNamespaces(r,"requiredNamespaces"),!As(i)&&0!==ws(i)&&this.validateNamespaces(i,"optionalNamespaces"),As(n)||this.validateSessionProps(n,"sessionProperties")},this.validateNamespaces=(t,e)=>{const r=function(t,e,r){let i=null;if(t&&ws(t)){const n=Ss(t,e);n&&(i=n);const s=function(t,e,r){let i=null;return Object.entries(t).forEach((([t,n])=>{if(i)return;const s=function(t,e,r){let i=null;return ys(e)&&e.length?e.forEach((t=>{i||Is(t)||(i=vs("UNSUPPORTED_CHAINS",`${r}, chain ${t} should be a string and conform to "namespace:chainId" format`))})):Is(t)||(i=vs("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}(t,M(t,n),`${e} ${r}`);s&&(i=s)})),i}(t,e,r);s&&(i=s)}else i=bs("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}(t,"connect()",e);if(r)throw new Error(r.message)},this.isValidApprove=async t=>{if(!Rs(t))throw new Error(bs("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:e,namespaces:r,relayProtocol:i,sessionProperties:n}=t;this.checkRecentlyDeleted(e),await this.isValidProposalId(e);const s=this.client.proposal.get(e),o=Ps(r,"approve()");if(o)throw new Error(o.message);const a=Os(s.requiredNamespaces,r,"approve()");if(a)throw new Error(a.message);if(!_s(i,!0)){const{message:t}=bs("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(t)}As(n)||this.validateSessionProps(n,"sessionProperties")},this.isValidReject=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(e)}const{id:e,reason:r}=t;if(this.checkRecentlyDeleted(e),await this.isValidProposalId(e),!function(t){return!!(t&&"object"==typeof t&&t.code&&Ms(t.code,!1)&&t.message&&_s(t.message,!1))}(r)){const{message:t}=bs("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(t)}},this.isValidSessionSettleRequest=t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(e)}const{relay:e,controller:r,namespaces:i,expiry:n}=t;if(!xs(e)){const{message:t}=bs("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(t)}const s=function(t){let e=null;return _s(t?.publicKey,!1)||(e=bs("MISSING_OR_INVALID","onSessionSettleRequest() controller public key should be a string")),e}(r);if(s)throw new Error(s.message);const o=Ps(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(J(n)){const{message:t}=bs("EXPIRED","onSessionSettleRequest()");throw new Error(t)}},this.isValidUpdate=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(e)}const{topic:e,namespaces:r}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const i=this.client.session.get(e),n=Ps(r,"update()");if(n)throw new Error(n.message);const s=Os(i.requiredNamespaces,r,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(e)}const{topic:e}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e)},this.isValidRequest=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(e)}const{topic:e,request:r,chainId:i,expiry:n}=t;this.checkRecentlyDeleted(e),await this.isValidSessionTopic(e);const{namespaces:s}=this.client.session.get(e);if(!Ns(s,i)){const{message:t}=bs("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(t)}if(!function(t){return!(As(t)||!_s(t.method,!1))}(r)){const{message:t}=bs("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(t)}if(!function(t,e,r){return!!_s(r,!1)&&function(t,e){const r=[];return Object.values(t).forEach((t=>{fs(t.accounts).includes(e)&&r.push(...t.methods)})),r}(t,e).includes(r)}(s,i,r.method)){const{message:t}=bs("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(t)}if(n&&!function(t,e){return Ms(t,!1)&&t<=e.max&&t>=e.min}(n,mh)){const{message:t}=bs("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${mh.min} and ${mh.max}`);throw new Error(t)}},this.isValidRespond=async t=>{var e;if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(e)}const{topic:r,response:i}=t;try{await this.isValidSessionTopic(r)}catch(r){throw null!=(e=t?.response)&&e.id&&this.cleanupAfterResponse(t),r}if(!function(t){return!(As(t)||As(t.result)&&As(t.error)||!Ms(t.id,!1)||!_s(t.jsonrpc,!1))}(i)){const{message:t}=bs("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(t)}},this.isValidPing=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e)},this.isValidEmit=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(e)}const{topic:e,event:r,chainId:i}=t;await this.isValidSessionTopic(e);const{namespaces:n}=this.client.session.get(e);if(!Ns(n,i)){const{message:t}=bs("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(t)}if(!function(t){return!(As(t)||!_s(t.name,!1))}(r)){const{message:t}=bs("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(t)}if(!function(t,e,r){return!!_s(r,!1)&&function(t,e){const r=[];return Object.values(t).forEach((t=>{fs(t.accounts).includes(e)&&r.push(...t.events)})),r}(t,e).includes(r)}(n,i,r.name)){const{message:t}=bs("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(t)}},this.isValidDisconnect=async t=>{if(!Rs(t)){const{message:e}=bs("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(e)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e)},this.isValidAuthenticate=t=>{const{chains:e,uri:r,domain:i,nonce:n}=t;if(!Array.isArray(e)||0===e.length)throw new Error("chains is required and must be a non-empty array");if(!_s(r,!1))throw new Error("uri is required parameter");if(!_s(i,!1))throw new Error("domain is required parameter");if(!_s(n,!1))throw new Error("nonce is required parameter");if([...new Set(e.map((t=>A(t).namespace)))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:s}=A(e[0]);if("eip155"!==s)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:e,hash:r,encryptedId:i,metadata:n,transportType:s}=t,o={verified:{verifyUrl:n.verifyUrl||Bo,validation:"UNKNOWN",origin:n.url||""}};try{if(s===_o.link_mode){const t=this.getAppLinkIfEnabled(n,s);return o.verified.validation=t&&new URL(t).origin===new URL(n.url).origin?"VALID":"INVALID",o}const t=await this.client.core.verify.resolve({attestationId:e,hash:r,encryptedId:i,verifyUrl:n.verifyUrl});t&&(o.verified.origin=t.origin,o.verified.isScam=t.isScam,o.verified.validation=t.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(t){this.client.logger.warn(t)}return this.client.logger.debug(`Verify context: ${JSON.stringify(o)}`),o},this.validateSessionProps=(t,e)=>{Object.values(t).forEach((t=>{if(!_s(t,!1)){const{message:r}=bs("MISSING_OR_INVALID",`${e} must be in Record<string, string> format. Received: ${JSON.stringify(t)}`);throw new Error(r)}}))},this.getPendingAuthRequest=t=>{const e=this.client.auth.requests.get(t);return"object"==typeof e?e:void 0},this.addToRecentlyDeleted=(t,e)=>{if(this.recentlyDeletedMap.set(t,e),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let t=0;const e=this.recentlyDeletedLimit/2;for(const r of this.recentlyDeletedMap.keys()){if(t++>=e)break;this.recentlyDeletedMap.delete(r)}}},this.checkRecentlyDeleted=t=>{const e=this.recentlyDeletedMap.get(t);if(e){const{message:r}=bs("MISSING_OR_INVALID",`Record was recently deleted - ${e}: ${t}`);throw new Error(r)}},this.isLinkModeEnabled=(t,e)=>{var i,n,s,o,a,c,h,u,f;return!(!t||e!==_o.link_mode)&&!0===(null==(n=null==(i=this.client.metadata)?void 0:i.redirect)?void 0:n.linkMode)&&void 0!==(null==(o=null==(s=this.client.metadata)?void 0:s.redirect)?void 0:o.universal)&&""!==(null==(c=null==(a=this.client.metadata)?void 0:a.redirect)?void 0:c.universal)&&void 0!==(null==(h=t?.redirect)?void 0:h.universal)&&""!==(null==(u=t?.redirect)?void 0:u.universal)&&!0===(null==(f=t?.redirect)?void 0:f.linkMode)&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(null==r.g?void 0:r.g.Linking)<"u"},this.getAppLinkIfEnabled=(t,e)=>{var r;return this.isLinkModeEnabled(t,e)?null==(r=t?.redirect)?void 0:r.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const e=Y(t,"topic")||"",r=decodeURIComponent(Y(t,"wc_ev")||""),i=this.client.session.keys.includes(e);i&&this.client.session.update(e,{transportType:_o.link_mode}),this.client.core.dispatchEnvelope({topic:e,message:r,sessionExists:i})},this.registerLinkModeListeners=async()=>{var t;if(Z()||q()&&null!=(t=this.client.metadata.redirect)&&t.linkMode){const t=null==r.g?void 0:r.g.Linking;if(typeof t<"u"){t.addEventListener("url",this.handleLinkModeMessage,this.client.name);const e=await t.getInitialURL();e&&setTimeout((()=>{this.handleLinkModeMessage({url:e})}),50)}}}}isInitialized(){if(!this.initialized){const{message:t}=bs("NOT_INITIALIZED",this.name);throw new Error(t)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(lo,(t=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(t):this.onRelayMessage(t)}))}async onRelayMessage(t){const{topic:e,message:r,attestation:i,transportType:n}=t,{publicKey:s}=this.client.auth.authKeys.keys.includes(Ah)?this.client.auth.authKeys.get(Ah):{responseTopic:void 0,publicKey:void 0},o=await this.client.core.crypto.decode(e,r,{receiverPublicKey:s,encoding:n===_o.link_mode?Un:Bn});try{(0,eo.isJsonRpcRequest)(o)?(this.client.core.history.set(e,o),this.onRelayEventRequest({topic:e,payload:o,attestation:i,transportType:n,encryptedId:Fn(r)})):(0,eo.isJsonRpcResponse)(o)?(await this.client.core.history.resolve(o),await this.onRelayEventResponse({topic:e,payload:o,transportType:n}),this.client.core.history.delete(e,o.id)):this.onRelayEventUnknownPayload({topic:e,payload:o,transportType:n})}catch(t){this.client.logger.error(t)}}registerExpirerEvents(){this.client.core.expirer.on(Do,(async t=>{const{topic:e,id:r}=$(t.target);return r&&this.client.pendingRequest.keys.includes(r)?await this.deletePendingSessionRequest(r,bs("EXPIRED"),!0):r&&this.client.auth.requests.keys.includes(r)?await this.deletePendingAuthRequest(r,bs("EXPIRED"),!0):void(e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r})))}))}registerPairingEvents(){this.client.core.pairing.events.on(xo,(t=>this.onPairingCreated(t))),this.client.core.pairing.events.on(Ro,(t=>{this.addToRecentlyDeleted(t.topic,"pairing")}))}isValidPairingTopic(t){if(!_s(t,!1)){const{message:e}=bs("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=bs("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(J(this.client.core.pairing.pairings.get(t).expiry)){const{message:e}=bs("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}}async isValidSessionTopic(t){if(!_s(t,!1)){const{message:e}=bs("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(e)}if(this.checkRecentlyDeleted(t),!this.client.session.keys.includes(t)){const{message:e}=bs("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(e)}if(J(this.client.session.get(t).expiry)){await this.deleteSession({topic:t});const{message:e}=bs("EXPIRED",`session topic: ${t}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(t)){const{message:e}=bs("MISSING_OR_INVALID",`session topic does not exist in keychain: ${t}`);throw await this.deleteSession({topic:t}),new Error(e)}}async isValidSessionOrPairingTopic(t){if(this.checkRecentlyDeleted(t),this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else{if(!this.client.core.pairing.pairings.keys.includes(t)){if(_s(t,!1)){const{message:e}=bs("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(e)}{const{message:e}=bs("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(e)}}this.isValidPairingTopic(t)}}async isValidProposalId(t){if(!function(t){return"number"==typeof t}(t)){const{message:e}=bs("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(e)}if(!this.client.proposal.keys.includes(t)){const{message:e}=bs("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(e)}if(J(this.client.proposal.get(t).expiryTimestamp)){await this.deleteProposal(t);const{message:e}=bs("EXPIRED",`proposal id: ${t}`);throw new Error(e)}}}class Ch extends Uc{constructor(t,e){super(t,e,"proposal",uh),this.core=t,this.logger=e}}class Th extends Uc{constructor(t,e){super(t,e,"session",uh),this.core=t,this.logger=e}}class qh extends Uc{constructor(t,e){super(t,e,"request",uh,(t=>t.id)),this.core=t,this.logger=e}}class Dh extends Uc{constructor(t,e){super(t,e,"authKeys",wh,(()=>Ah)),this.core=t,this.logger=e}}class kh extends Uc{constructor(t,e){super(t,e,"pairingTopics",wh),this.core=t,this.logger=e}}class Bh extends Uc{constructor(t,e){super(t,e,"requests",wh,(t=>t.id)),this.core=t,this.logger=e}}class Uh{constructor(t,e){this.core=t,this.logger=e,this.authKeys=new Dh(this.core,this.logger),this.pairingTopics=new kh(this.core,this.logger),this.requests=new Bh(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class zh extends Ws{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=fh,this.events=new i.EventEmitter,this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.removeAllListeners=t=>this.events.removeAllListeners(t),this.connect=async t=>{try{return await this.engine.connect(t)}catch(t){throw this.logger.error(t.message),t}},this.pair=async t=>{try{return await this.engine.pair(t)}catch(t){throw this.logger.error(t.message),t}},this.approve=async t=>{try{return await this.engine.approve(t)}catch(t){throw this.logger.error(t.message),t}},this.reject=async t=>{try{return await this.engine.reject(t)}catch(t){throw this.logger.error(t.message),t}},this.update=async t=>{try{return await this.engine.update(t)}catch(t){throw this.logger.error(t.message),t}},this.extend=async t=>{try{return await this.engine.extend(t)}catch(t){throw this.logger.error(t.message),t}},this.request=async t=>{try{return await this.engine.request(t)}catch(t){throw this.logger.error(t.message),t}},this.respond=async t=>{try{return await this.engine.respond(t)}catch(t){throw this.logger.error(t.message),t}},this.ping=async t=>{try{return await this.engine.ping(t)}catch(t){throw this.logger.error(t.message),t}},this.emit=async t=>{try{return await this.engine.emit(t)}catch(t){throw this.logger.error(t.message),t}},this.disconnect=async t=>{try{return await this.engine.disconnect(t)}catch(t){throw this.logger.error(t.message),t}},this.find=t=>{try{return this.engine.find(t)}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(t){throw this.logger.error(t.message),t}},this.authenticate=async(t,e)=>{try{return await this.engine.authenticate(t,e)}catch(t){throw this.logger.error(t.message),t}},this.formatAuthMessage=t=>{try{return this.engine.formatAuthMessage(t)}catch(t){throw this.logger.error(t.message),t}},this.approveSessionAuthenticate=async t=>{try{return await this.engine.approveSessionAuthenticate(t)}catch(t){throw this.logger.error(t.message),t}},this.rejectSessionAuthenticate=async t=>{try{return await this.engine.rejectSessionAuthenticate(t)}catch(t){throw this.logger.error(t.message),t}},this.name=t?.name||fh,this.metadata=t?.metadata||B(),this.signConfig=t?.signConfig;const e=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:(0,Us.h6)((0,Us.iP)({level:t?.logger||"error"}));this.core=t?.core||new ch(t),this.logger=(0,Us.U5)(e,this.name),this.session=new Th(this.core,this.logger),this.proposal=new Ch(this.core,this.logger),this.pendingRequest=new qh(this.core,this.logger),this.engine=new Oh(this),this.auth=new Uh(this.core,this.logger)}static async init(t){const e=new zh(t);return await e.initialize(),e}get context(){return(0,Us.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}}var jh=r(90735),Lh=r.n(jh),Fh=Object.defineProperty,Kh=Object.defineProperties,Hh=Object.getOwnPropertyDescriptors,$h=Object.getOwnPropertySymbols,Vh=Object.prototype.hasOwnProperty,Jh=Object.prototype.propertyIsEnumerable,Qh=(t,e,r)=>e in t?Fh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gh=(t,e)=>{for(var r in e||(e={}))Vh.call(e,r)&&Qh(t,r,e[r]);if($h)for(var r of $h(e))Jh.call(e,r)&&Qh(t,r,e[r]);return t},Yh=(t,e)=>Kh(t,Hh(e));const Wh={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class Zh{constructor(t,e=!1){if(this.url=t,this.disableProviderPing=e,this.events=new i.EventEmitter,this.isAvailable=!1,this.registering=!1,!(0,eo.isHttpUrl)(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t){this.isAvailable||await this.register();try{const e=(0,Xs.h)(t),r=await(await Lh()(this.url,Yh(Gh({},Wh),{body:e}))).json();this.onPayload({data:r})}catch(e){this.onError(t.id,e)}}async register(t=this.url){if(!(0,eo.isHttpUrl)(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise(((t,e)=>{this.events.once("register_error",(t=>{this.resetMaxListeners(),e(t)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return e(new Error("HTTP connection is missing or invalid"));t()}))}))}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const e=(0,Xs.h)({id:1,jsonrpc:"2.0",method:"test",params:[]});await Lh()(t,Yh(Gh({},Wh),{body:e}))}this.onOpen()}catch(t){const e=this.parseError(t);throw this.events.emit("register_error",e),this.onClose(),e}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(t){if(typeof t.data>"u")return;const e="string"==typeof t.data?(0,Xs.j)(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const r=this.parseError(e),i=r.message||r.toString(),n=(0,eo.formatJsonRpcError)(t,i);this.events.emit("payload",n)}parseError(t,e=this.url){return(0,eo.parseConnectionError)(t,e,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}const Xh="error",tu="wc@2:universal_provider:",eu="https://rpc.walletconnect.org/v1/",ru="generic",iu=`${eu}bundler`,nu="default_chain_changed";var su,ou,au=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof r.g<"u"?r.g:typeof self<"u"?self:{},cu={exports:{}};su=cu,ou=cu.exports,function(){var t,e="Expected a function",r="__lodash_hash_undefined__",i="__lodash_placeholder__",n=32,s=128,o=1/0,a=9007199254740991,c=NaN,h=4294967295,u=h-1,f=h>>>1,d=[["ary",s],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",n],["partialRight",64],["rearg",256]],l="[object Arguments]",p="[object Array]",g="[object Boolean]",m="[object Date]",b="[object Error]",v="[object Function]",y="[object GeneratorFunction]",w="[object Map]",A="[object Number]",_="[object Object]",M="[object Promise]",I="[object RegExp]",E="[object Set]",S="[object String]",P="[object Symbol]",x="[object WeakMap]",R="[object ArrayBuffer]",N="[object DataView]",O="[object Float32Array]",C="[object Float64Array]",T="[object Int8Array]",q="[object Int16Array]",D="[object Int32Array]",k="[object Uint8Array]",B="[object Uint8ClampedArray]",U="[object Uint16Array]",z="[object Uint32Array]",j=/\b__p \+= '';/g,L=/\b(__p \+=) '' \+/g,F=/(__e\(.*?\)|\b__t\)) \+\n'';/g,K=/&(?:amp|lt|gt|quot|#39);/g,H=/[&<>"']/g,$=RegExp(K.source),V=RegExp(H.source),J=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,G=/<%=([\s\S]+?)%>/g,Y=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,W=/^\w*$/,Z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,X=/[\\^$.*+?()[\]{}|]/g,tt=RegExp(X.source),et=/^\s+/,rt=/\s/,it=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,nt=/\{\n\/\* \[wrapped with (.+)\] \*/,st=/,? & /,ot=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,at=/[()=,{}\[\]\/\s]/,ct=/\\(\\)?/g,ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ut=/\w*$/,ft=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,lt=/^\[object .+?Constructor\]$/,pt=/^0o[0-7]+$/i,gt=/^(?:0|[1-9]\d*)$/,mt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,bt=/($^)/,vt=/['\n\r\u2028\u2029\\]/g,yt="\\ud800-\\udfff",wt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",At="\\u2700-\\u27bf",_t="a-z\\xdf-\\xf6\\xf8-\\xff",Mt="A-Z\\xc0-\\xd6\\xd8-\\xde",It="\\ufe0e\\ufe0f",Et="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",St="["+yt+"]",Pt="["+Et+"]",xt="["+wt+"]",Rt="\\d+",Nt="["+At+"]",Ot="["+_t+"]",Ct="[^"+yt+Et+Rt+At+_t+Mt+"]",Tt="\\ud83c[\\udffb-\\udfff]",qt="[^"+yt+"]",Dt="(?:\\ud83c[\\udde6-\\uddff]){2}",kt="[\\ud800-\\udbff][\\udc00-\\udfff]",Bt="["+Mt+"]",Ut="\\u200d",zt="(?:"+Ot+"|"+Ct+")",jt="(?:"+Bt+"|"+Ct+")",Lt="(?:['’](?:d|ll|m|re|s|t|ve))?",Ft="(?:['’](?:D|LL|M|RE|S|T|VE))?",Kt="(?:"+xt+"|"+Tt+")?",Ht="["+It+"]?",$t=Ht+Kt+"(?:"+Ut+"(?:"+[qt,Dt,kt].join("|")+")"+Ht+Kt+")*",Vt="(?:"+[Nt,Dt,kt].join("|")+")"+$t,Jt="(?:"+[qt+xt+"?",xt,Dt,kt,St].join("|")+")",Qt=RegExp("['’]","g"),Gt=RegExp(xt,"g"),Yt=RegExp(Tt+"(?="+Tt+")|"+Jt+$t,"g"),Wt=RegExp([Bt+"?"+Ot+"+"+Lt+"(?="+[Pt,Bt,"$"].join("|")+")",jt+"+"+Ft+"(?="+[Pt,Bt+zt,"$"].join("|")+")",Bt+"?"+zt+"+"+Lt,Bt+"+"+Ft,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Rt,Vt].join("|"),"g"),Zt=RegExp("["+Ut+yt+wt+It+"]"),Xt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,te=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ee=-1,re={};re[O]=re[C]=re[T]=re[q]=re[D]=re[k]=re[B]=re[U]=re[z]=!0,re[l]=re[p]=re[R]=re[g]=re[N]=re[m]=re[b]=re[v]=re[w]=re[A]=re[_]=re[I]=re[E]=re[S]=re[x]=!1;var ie={};ie[l]=ie[p]=ie[R]=ie[N]=ie[g]=ie[m]=ie[O]=ie[C]=ie[T]=ie[q]=ie[D]=ie[w]=ie[A]=ie[_]=ie[I]=ie[E]=ie[S]=ie[P]=ie[k]=ie[B]=ie[U]=ie[z]=!0,ie[b]=ie[v]=ie[x]=!1;var ne={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},se=parseFloat,oe=parseInt,ae="object"==typeof au&&au&&au.Object===Object&&au,ce="object"==typeof self&&self&&self.Object===Object&&self,he=ae||ce||Function("return this")(),ue=ou&&!ou.nodeType&&ou,fe=ue&&su&&!su.nodeType&&su,de=fe&&fe.exports===ue,le=de&&ae.process,pe=function(){try{return fe&&fe.require&&fe.require("util").types||le&&le.binding&&le.binding("util")}catch{}}(),ge=pe&&pe.isArrayBuffer,me=pe&&pe.isDate,be=pe&&pe.isMap,ve=pe&&pe.isRegExp,ye=pe&&pe.isSet,we=pe&&pe.isTypedArray;function Ae(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function _e(t,e,r,i){for(var n=-1,s=null==t?0:t.length;++n<s;){var o=t[n];e(i,o,r(o),t)}return i}function Me(t,e){for(var r=-1,i=null==t?0:t.length;++r<i&&!1!==e(t[r],r,t););return t}function Ie(t,e){for(var r=null==t?0:t.length;r--&&!1!==e(t[r],r,t););return t}function Ee(t,e){for(var r=-1,i=null==t?0:t.length;++r<i;)if(!e(t[r],r,t))return!1;return!0}function Se(t,e){for(var r=-1,i=null==t?0:t.length,n=0,s=[];++r<i;){var o=t[r];e(o,r,t)&&(s[n++]=o)}return s}function Pe(t,e){return!(null==t||!t.length)&&Be(t,e,0)>-1}function xe(t,e,r){for(var i=-1,n=null==t?0:t.length;++i<n;)if(r(e,t[i]))return!0;return!1}function Re(t,e){for(var r=-1,i=null==t?0:t.length,n=Array(i);++r<i;)n[r]=e(t[r],r,t);return n}function Ne(t,e){for(var r=-1,i=e.length,n=t.length;++r<i;)t[n+r]=e[r];return t}function Oe(t,e,r,i){var n=-1,s=null==t?0:t.length;for(i&&s&&(r=t[++n]);++n<s;)r=e(r,t[n],n,t);return r}function Ce(t,e,r,i){var n=null==t?0:t.length;for(i&&n&&(r=t[--n]);n--;)r=e(r,t[n],n,t);return r}function Te(t,e){for(var r=-1,i=null==t?0:t.length;++r<i;)if(e(t[r],r,t))return!0;return!1}var qe=Le("length");function De(t,e,r){var i;return r(t,(function(t,r,n){if(e(t,r,n))return i=r,!1})),i}function ke(t,e,r,i){for(var n=t.length,s=r+(i?1:-1);i?s--:++s<n;)if(e(t[s],s,t))return s;return-1}function Be(t,e,r){return e==e?function(t,e,r){for(var i=r-1,n=t.length;++i<n;)if(t[i]===e)return i;return-1}(t,e,r):ke(t,ze,r)}function Ue(t,e,r,i){for(var n=r-1,s=t.length;++n<s;)if(i(t[n],e))return n;return-1}function ze(t){return t!=t}function je(t,e){var r=null==t?0:t.length;return r?He(t,e)/r:c}function Le(e){return function(r){return null==r?t:r[e]}}function Fe(e){return function(r){return null==e?t:e[r]}}function Ke(t,e,r,i,n){return n(t,(function(t,n,s){r=i?(i=!1,t):e(r,t,n,s)})),r}function He(e,r){for(var i,n=-1,s=e.length;++n<s;){var o=r(e[n]);o!==t&&(i=i===t?o:i+o)}return i}function $e(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}function Ve(t){return t&&t.slice(0,cr(t)+1).replace(et,"")}function Je(t){return function(e){return t(e)}}function Qe(t,e){return Re(e,(function(e){return t[e]}))}function Ge(t,e){return t.has(e)}function Ye(t,e){for(var r=-1,i=t.length;++r<i&&Be(e,t[r],0)>-1;);return r}function We(t,e){for(var r=t.length;r--&&Be(e,t[r],0)>-1;);return r}var Ze=Fe({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Xe=Fe({"&":"&","<":"<",">":">",'"':""","'":"'"});function tr(t){return"\\"+ne[t]}function er(t){return Zt.test(t)}function rr(t){var e=-1,r=Array(t.size);return t.forEach((function(t,i){r[++e]=[i,t]})),r}function ir(t,e){return function(r){return t(e(r))}}function nr(t,e){for(var r=-1,n=t.length,s=0,o=[];++r<n;){var a=t[r];(a===e||a===i)&&(t[r]=i,o[s++]=r)}return o}function sr(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}function or(t){return er(t)?function(t){for(var e=Yt.lastIndex=0;Yt.test(t);)++e;return e}(t):qe(t)}function ar(t){return er(t)?function(t){return t.match(Yt)||[]}(t):function(t){return t.split("")}(t)}function cr(t){for(var e=t.length;e--&&rt.test(t.charAt(e)););return e}var hr=Fe({"&":"&","<":"<",">":">",""":'"',"'":"'"}),ur=function rt(yt){var wt,At=(yt=null==yt?he:ur.defaults(he.Object(),yt,ur.pick(he,te))).Array,_t=yt.Date,Mt=yt.Error,It=yt.Function,Et=yt.Math,St=yt.Object,Pt=yt.RegExp,xt=yt.String,Rt=yt.TypeError,Nt=At.prototype,Ot=It.prototype,Ct=St.prototype,Tt=yt["__core-js_shared__"],qt=Ot.toString,Dt=Ct.hasOwnProperty,kt=0,Bt=(wt=/[^.]+$/.exec(Tt&&Tt.keys&&Tt.keys.IE_PROTO||""))?"Symbol(src)_1."+wt:"",Ut=Ct.toString,zt=qt.call(St),jt=he._,Lt=Pt("^"+qt.call(Dt).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ft=de?yt.Buffer:t,Kt=yt.Symbol,Ht=yt.Uint8Array,$t=Ft?Ft.allocUnsafe:t,Vt=ir(St.getPrototypeOf,St),Jt=St.create,Yt=Ct.propertyIsEnumerable,Zt=Nt.splice,ne=Kt?Kt.isConcatSpreadable:t,ae=Kt?Kt.iterator:t,ce=Kt?Kt.toStringTag:t,ue=function(){try{var t=hs(St,"defineProperty");return t({},"",{}),t}catch{}}(),fe=yt.clearTimeout!==he.clearTimeout&&yt.clearTimeout,le=_t&&_t.now!==he.Date.now&&_t.now,pe=yt.setTimeout!==he.setTimeout&&yt.setTimeout,qe=Et.ceil,Fe=Et.floor,fr=St.getOwnPropertySymbols,dr=Ft?Ft.isBuffer:t,lr=yt.isFinite,pr=Nt.join,gr=ir(St.keys,St),mr=Et.max,br=Et.min,vr=_t.now,yr=yt.parseInt,wr=Et.random,Ar=Nt.reverse,_r=hs(yt,"DataView"),Mr=hs(yt,"Map"),Ir=hs(yt,"Promise"),Er=hs(yt,"Set"),Sr=hs(yt,"WeakMap"),Pr=hs(St,"create"),xr=Sr&&new Sr,Rr={},Nr=Ds(_r),Or=Ds(Mr),Cr=Ds(Ir),Tr=Ds(Er),qr=Ds(Sr),Dr=Kt?Kt.prototype:t,kr=Dr?Dr.valueOf:t,Br=Dr?Dr.toString:t;function Ur(t){if(Xo(t)&&!Fo(t)&&!(t instanceof Fr)){if(t instanceof Lr)return t;if(Dt.call(t,"__wrapped__"))return ks(t)}return new Lr(t)}var zr=function(){function e(){}return function(r){if(!Zo(r))return{};if(Jt)return Jt(r);e.prototype=r;var i=new e;return e.prototype=t,i}}();function jr(){}function Lr(e,r){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!r,this.__index__=0,this.__values__=t}function Fr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=h,this.__views__=[]}function Kr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}function Hr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}function $r(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}function Vr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new $r;++e<r;)this.add(t[e])}function Jr(t){var e=this.__data__=new Hr(t);this.size=e.size}function Qr(t,e){var r=Fo(t),i=!r&&Lo(t),n=!r&&!i&&Vo(t),s=!r&&!i&&!n&&aa(t),o=r||i||n||s,a=o?$e(t.length,xt):[],c=a.length;for(var h in t)(e||Dt.call(t,h))&&(!o||!("length"==h||n&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ms(h,c)))&&a.push(h);return a}function Gr(e){var r=e.length;return r?e[$i(0,r-1)]:t}function Yr(t,e){return Cs(Pn(t),si(e,0,t.length))}function Wr(t){return Cs(Pn(t))}function Zr(e,r,i){(i!==t&&!Uo(e[r],i)||i===t&&!(r in e))&&ii(e,r,i)}function Xr(e,r,i){var n=e[r];(!Dt.call(e,r)||!Uo(n,i)||i===t&&!(r in e))&&ii(e,r,i)}function ti(t,e){for(var r=t.length;r--;)if(Uo(t[r][0],e))return r;return-1}function ei(t,e,r,i){return ui(t,(function(t,n,s){e(i,t,r(t),s)})),i}function ri(t,e){return t&&xn(e,Ra(e),t)}function ii(t,e,r){"__proto__"==e&&ue?ue(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function ni(e,r){for(var i=-1,n=r.length,s=At(n),o=null==e;++i<n;)s[i]=o?t:Ia(e,r[i]);return s}function si(e,r,i){return e==e&&(i!==t&&(e=e<=i?e:i),r!==t&&(e=e>=r?e:r)),e}function oi(e,r,i,n,s,o){var a,c=1&r,h=2&r,u=4&r;if(i&&(a=s?i(e,n,s,o):i(e)),a!==t)return a;if(!Zo(e))return e;var f=Fo(e);if(f){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Dt.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(e),!c)return Pn(e,a)}else{var d=ds(e),p=d==v||d==y;if(Vo(e))return An(e,c);if(d==_||d==l||p&&!s){if(a=h||p?{}:ps(e),!c)return h?function(t,e){return xn(t,fs(t),e)}(e,function(t,e){return t&&xn(e,Na(e),t)}(a,e)):function(t,e){return xn(t,us(t),e)}(e,ri(a,e))}else{if(!ie[d])return s?e:{};a=function(t,e,r){var i=t.constructor;switch(e){case R:return _n(t);case g:case m:return new i(+t);case N:return function(t,e){var r=e?_n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case O:case C:case T:case q:case D:case k:case B:case U:case z:return Mn(t,r);case w:return new i;case A:case S:return new i(t);case I:return function(t){var e=new t.constructor(t.source,ut.exec(t));return e.lastIndex=t.lastIndex,e}(t);case E:return new i;case P:return function(t){return kr?St(kr.call(t)):{}}(t)}}(e,d,c)}}o||(o=new Jr);var b=o.get(e);if(b)return b;o.set(e,a),na(e)?e.forEach((function(t){a.add(oi(t,r,i,t,e,o))})):ta(e)&&e.forEach((function(t,n){a.set(n,oi(t,r,i,n,e,o))}));var M=f?t:(u?h?rs:es:h?Na:Ra)(e);return Me(M||e,(function(t,n){M&&(t=e[n=t]),Xr(a,n,oi(t,r,i,n,e,o))})),a}function ai(e,r,i){var n=i.length;if(null==e)return!n;for(e=St(e);n--;){var s=i[n],o=r[s],a=e[s];if(a===t&&!(s in e)||!o(a))return!1}return!0}function ci(r,i,n){if("function"!=typeof r)throw new Rt(e);return xs((function(){r.apply(t,n)}),i)}function hi(t,e,r,i){var n=-1,s=Pe,o=!0,a=t.length,c=[],h=e.length;if(!a)return c;r&&(e=Re(e,Je(r))),i?(s=xe,o=!1):e.length>=200&&(s=Ge,o=!1,e=new Vr(e));t:for(;++n<a;){var u=t[n],f=null==r?u:r(u);if(u=i||0!==u?u:0,o&&f==f){for(var d=h;d--;)if(e[d]===f)continue t;c.push(u)}else s(e,f,i)||c.push(u)}return c}Ur.templateSettings={escape:J,evaluate:Q,interpolate:G,variable:"",imports:{_:Ur}},Ur.prototype=jr.prototype,Ur.prototype.constructor=Ur,Lr.prototype=zr(jr.prototype),Lr.prototype.constructor=Lr,Fr.prototype=zr(jr.prototype),Fr.prototype.constructor=Fr,Kr.prototype.clear=function(){this.__data__=Pr?Pr(null):{},this.size=0},Kr.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Kr.prototype.get=function(e){var i=this.__data__;if(Pr){var n=i[e];return n===r?t:n}return Dt.call(i,e)?i[e]:t},Kr.prototype.has=function(e){var r=this.__data__;return Pr?r[e]!==t:Dt.call(r,e)},Kr.prototype.set=function(e,i){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Pr&&i===t?r:i,this},Hr.prototype.clear=function(){this.__data__=[],this.size=0},Hr.prototype.delete=function(t){var e=this.__data__,r=ti(e,t);return!(r<0||(r==e.length-1?e.pop():Zt.call(e,r,1),--this.size,0))},Hr.prototype.get=function(e){var r=this.__data__,i=ti(r,e);return i<0?t:r[i][1]},Hr.prototype.has=function(t){return ti(this.__data__,t)>-1},Hr.prototype.set=function(t,e){var r=this.__data__,i=ti(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this},$r.prototype.clear=function(){this.size=0,this.__data__={hash:new Kr,map:new(Mr||Hr),string:new Kr}},$r.prototype.delete=function(t){var e=as(this,t).delete(t);return this.size-=e?1:0,e},$r.prototype.get=function(t){return as(this,t).get(t)},$r.prototype.has=function(t){return as(this,t).has(t)},$r.prototype.set=function(t,e){var r=as(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this},Vr.prototype.add=Vr.prototype.push=function(t){return this.__data__.set(t,r),this},Vr.prototype.has=function(t){return this.__data__.has(t)},Jr.prototype.clear=function(){this.__data__=new Hr,this.size=0},Jr.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Jr.prototype.get=function(t){return this.__data__.get(t)},Jr.prototype.has=function(t){return this.__data__.has(t)},Jr.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Hr){var i=r.__data__;if(!Mr||i.length<199)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new $r(i)}return r.set(t,e),this.size=r.size,this};var ui=On(vi),fi=On(yi,!0);function di(t,e){var r=!0;return ui(t,(function(t,i,n){return r=!!e(t,i,n)})),r}function li(e,r,i){for(var n=-1,s=e.length;++n<s;){var o=e[n],a=r(o);if(null!=a&&(c===t?a==a&&!oa(a):i(a,c)))var c=a,h=o}return h}function pi(t,e){var r=[];return ui(t,(function(t,i,n){e(t,i,n)&&r.push(t)})),r}function gi(t,e,r,i,n){var s=-1,o=t.length;for(r||(r=gs),n||(n=[]);++s<o;){var a=t[s];e>0&&r(a)?e>1?gi(a,e-1,r,i,n):Ne(n,a):i||(n[n.length]=a)}return n}var mi=Cn(),bi=Cn(!0);function vi(t,e){return t&&mi(t,e,Ra)}function yi(t,e){return t&&bi(t,e,Ra)}function wi(t,e){return Se(e,(function(e){return Go(t[e])}))}function Ai(e,r){for(var i=0,n=(r=bn(r,e)).length;null!=e&&i<n;)e=e[qs(r[i++])];return i&&i==n?e:t}function _i(t,e,r){var i=e(t);return Fo(t)?i:Ne(i,r(t))}function Mi(e){return null==e?e===t?"[object Undefined]":"[object Null]":ce&&ce in St(e)?function(e){var r=Dt.call(e,ce),i=e[ce];try{e[ce]=t;var n=!0}catch{}var s=Ut.call(e);return n&&(r?e[ce]=i:delete e[ce]),s}(e):function(t){return Ut.call(t)}(e)}function Ii(t,e){return t>e}function Ei(t,e){return null!=t&&Dt.call(t,e)}function Si(t,e){return null!=t&&e in St(t)}function Pi(e,r,i){for(var n=i?xe:Pe,s=e[0].length,o=e.length,a=o,c=At(o),h=1/0,u=[];a--;){var f=e[a];a&&r&&(f=Re(f,Je(r))),h=br(f.length,h),c[a]=!i&&(r||s>=120&&f.length>=120)?new Vr(a&&f):t}f=e[0];var d=-1,l=c[0];t:for(;++d<s&&u.length<h;){var p=f[d],g=r?r(p):p;if(p=i||0!==p?p:0,!(l?Ge(l,g):n(u,g,i))){for(a=o;--a;){var m=c[a];if(!(m?Ge(m,g):n(e[a],g,i)))continue t}l&&l.push(g),u.push(p)}}return u}function xi(e,r,i){var n=null==(e=Es(e,r=bn(r,e)))?e:e[qs(Js(r))];return null==n?t:Ae(n,e,i)}function Ri(t){return Xo(t)&&Mi(t)==l}function Ni(e,r,i,n,s){return e===r||(null==e||null==r||!Xo(e)&&!Xo(r)?e!=e&&r!=r:function(e,r,i,n,s,o){var a=Fo(e),c=Fo(r),h=a?p:ds(e),u=c?p:ds(r),f=(h=h==l?_:h)==_,d=(u=u==l?_:u)==_,v=h==u;if(v&&Vo(e)){if(!Vo(r))return!1;a=!0,f=!1}if(v&&!f)return o||(o=new Jr),a||aa(e)?Xn(e,r,i,n,s,o):function(t,e,r,i,n,s,o){switch(r){case N:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case R:return!(t.byteLength!=e.byteLength||!s(new Ht(t),new Ht(e)));case g:case m:case A:return Uo(+t,+e);case b:return t.name==e.name&&t.message==e.message;case I:case S:return t==e+"";case w:var a=rr;case E:var c=1&i;if(a||(a=sr),t.size!=e.size&&!c)return!1;var h=o.get(t);if(h)return h==e;i|=2,o.set(t,e);var u=Xn(a(t),a(e),i,n,s,o);return o.delete(t),u;case P:if(kr)return kr.call(t)==kr.call(e)}return!1}(e,r,h,i,n,s,o);if(!(1&i)){var y=f&&Dt.call(e,"__wrapped__"),M=d&&Dt.call(r,"__wrapped__");if(y||M){var x=y?e.value():e,O=M?r.value():r;return o||(o=new Jr),s(x,O,i,n,o)}}return!!v&&(o||(o=new Jr),function(e,r,i,n,s,o){var a=1&i,c=es(e),h=c.length;if(h!=es(r).length&&!a)return!1;for(var u=h;u--;){var f=c[u];if(!(a?f in r:Dt.call(r,f)))return!1}var d=o.get(e),l=o.get(r);if(d&&l)return d==r&&l==e;var p=!0;o.set(e,r),o.set(r,e);for(var g=a;++u<h;){var m=e[f=c[u]],b=r[f];if(n)var v=a?n(b,m,f,r,e,o):n(m,b,f,e,r,o);if(!(v===t?m===b||s(m,b,i,n,o):v)){p=!1;break}g||(g="constructor"==f)}if(p&&!g){var y=e.constructor,w=r.constructor;y!=w&&"constructor"in e&&"constructor"in r&&!("function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w)&&(p=!1)}return o.delete(e),o.delete(r),p}(e,r,i,n,s,o))}(e,r,i,n,Ni,s))}function Oi(e,r,i,n){var s=i.length,o=s,a=!n;if(null==e)return!o;for(e=St(e);s--;){var c=i[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var h=(c=i[s])[0],u=e[h],f=c[1];if(a&&c[2]){if(u===t&&!(h in e))return!1}else{var d=new Jr;if(n)var l=n(u,f,h,e,r,d);if(!(l===t?Ni(f,u,3,n,d):l))return!1}}return!0}function Ci(t){return!(!Zo(t)||function(t){return!!Bt&&Bt in t}(t))&&(Go(t)?Lt:lt).test(Ds(t))}function Ti(t){return"function"==typeof t?t:null==t?ec:"object"==typeof t?Fo(t)?Ui(t[0],t[1]):Bi(t):uc(t)}function qi(t){if(!As(t))return gr(t);var e=[];for(var r in St(t))Dt.call(t,r)&&"constructor"!=r&&e.push(r);return e}function Di(t,e){return t<e}function ki(t,e){var r=-1,i=Ho(t)?At(t.length):[];return ui(t,(function(t,n,s){i[++r]=e(t,n,s)})),i}function Bi(t){var e=cs(t);return 1==e.length&&e[0][2]?Ms(e[0][0],e[0][1]):function(r){return r===t||Oi(r,t,e)}}function Ui(e,r){return vs(e)&&_s(r)?Ms(qs(e),r):function(i){var n=Ia(i,e);return n===t&&n===r?Ea(i,e):Ni(r,n,3)}}function zi(e,r,i,n,s){e!==r&&mi(r,(function(o,a){if(s||(s=new Jr),Zo(o))!function(e,r,i,n,s,o,a){var c=Ss(e,i),h=Ss(r,i),u=a.get(h);if(u)Zr(e,i,u);else{var f=o?o(c,h,i+"",e,r,a):t,d=f===t;if(d){var l=Fo(h),p=!l&&Vo(h),g=!l&&!p&&aa(h);f=h,l||p||g?Fo(c)?f=c:$o(c)?f=Pn(c):p?(d=!1,f=An(h,!0)):g?(d=!1,f=Mn(h,!0)):f=[]:ra(h)||Lo(h)?(f=c,Lo(c)?f=ga(c):(!Zo(c)||Go(c))&&(f=ps(h))):d=!1}d&&(a.set(h,f),s(f,h,n,o,a),a.delete(h)),Zr(e,i,f)}}(e,r,a,i,zi,n,s);else{var c=n?n(Ss(e,a),o,a+"",e,r,s):t;c===t&&(c=o),Zr(e,a,c)}}),Na)}function ji(e,r){var i=e.length;if(i)return ms(r+=r<0?i:0,i)?e[r]:t}function Li(t,e,r){e=e.length?Re(e,(function(t){return Fo(t)?function(e){return Ai(e,1===t.length?t[0]:t)}:t})):[ec];var i=-1;e=Re(e,Je(os()));var n=ki(t,(function(t,r,n){var s=Re(e,(function(e){return e(t)}));return{criteria:s,index:++i,value:t}}));return function(t){var e=t.length;for(t.sort((function(t,e){return function(t,e,r){for(var i=-1,n=t.criteria,s=e.criteria,o=n.length,a=r.length;++i<o;){var c=In(n[i],s[i]);if(c)return i>=a?c:c*("desc"==r[i]?-1:1)}return t.index-e.index}(t,e,r)}));e--;)t[e]=t[e].value;return t}(n)}function Fi(t,e,r){for(var i=-1,n=e.length,s={};++i<n;){var o=e[i],a=Ai(t,o);r(a,o)&&Yi(s,bn(o,t),a)}return s}function Ki(t,e,r,i){var n=i?Ue:Be,s=-1,o=e.length,a=t;for(t===e&&(e=Pn(e)),r&&(a=Re(t,Je(r)));++s<o;)for(var c=0,h=e[s],u=r?r(h):h;(c=n(a,u,c,i))>-1;)a!==t&&Zt.call(a,c,1),Zt.call(t,c,1);return t}function Hi(t,e){for(var r=t?e.length:0,i=r-1;r--;){var n=e[r];if(r==i||n!==s){var s=n;ms(n)?Zt.call(t,n,1):hn(t,n)}}return t}function $i(t,e){return t+Fe(wr()*(e-t+1))}function Vi(t,e){var r="";if(!t||e<1||e>a)return r;do{e%2&&(r+=t),(e=Fe(e/2))&&(t+=t)}while(e);return r}function Ji(t,e){return Rs(Is(t,e,ec),t+"")}function Qi(t){return Gr(Ua(t))}function Gi(t,e){var r=Ua(t);return Cs(r,si(e,0,r.length))}function Yi(e,r,i,n){if(!Zo(e))return e;for(var s=-1,o=(r=bn(r,e)).length,a=o-1,c=e;null!=c&&++s<o;){var h=qs(r[s]),u=i;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(s!=a){var f=c[h];(u=n?n(f,h,c):t)===t&&(u=Zo(f)?f:ms(r[s+1])?[]:{})}Xr(c,h,u),c=c[h]}return e}var Wi=xr?function(t,e){return xr.set(t,e),t}:ec,Zi=ue?function(t,e){return ue(t,"toString",{configurable:!0,enumerable:!1,value:Za(e),writable:!0})}:ec;function Xi(t){return Cs(Ua(t))}function tn(t,e,r){var i=-1,n=t.length;e<0&&(e=-e>n?0:n+e),(r=r>n?n:r)<0&&(r+=n),n=e>r?0:r-e>>>0,e>>>=0;for(var s=At(n);++i<n;)s[i]=t[i+e];return s}function en(t,e){var r;return ui(t,(function(t,i,n){return!(r=e(t,i,n))})),!!r}function rn(t,e,r){var i=0,n=null==t?i:t.length;if("number"==typeof e&&e==e&&n<=f){for(;i<n;){var s=i+n>>>1,o=t[s];null!==o&&!oa(o)&&(r?o<=e:o<e)?i=s+1:n=s}return n}return nn(t,e,ec,r)}function nn(e,r,i,n){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(r=i(r))!=r,c=null===r,h=oa(r),f=r===t;s<o;){var d=Fe((s+o)/2),l=i(e[d]),p=l!==t,g=null===l,m=l==l,b=oa(l);if(a)var v=n||m;else v=f?m&&(n||p):c?m&&p&&(n||!g):h?m&&p&&!g&&(n||!b):!g&&!b&&(n?l<=r:l<r);v?s=d+1:o=d}return br(o,u)}function sn(t,e){for(var r=-1,i=t.length,n=0,s=[];++r<i;){var o=t[r],a=e?e(o):o;if(!r||!Uo(a,c)){var c=a;s[n++]=0===o?0:o}}return s}function on(t){return"number"==typeof t?t:oa(t)?c:+t}function an(t){if("string"==typeof t)return t;if(Fo(t))return Re(t,an)+"";if(oa(t))return Br?Br.call(t):"";var e=t+"";return"0"==e&&1/t==-o?"-0":e}function cn(t,e,r){var i=-1,n=Pe,s=t.length,o=!0,a=[],c=a;if(r)o=!1,n=xe;else if(s>=200){var h=e?null:Jn(t);if(h)return sr(h);o=!1,n=Ge,c=new Vr}else c=e?[]:a;t:for(;++i<s;){var u=t[i],f=e?e(u):u;if(u=r||0!==u?u:0,o&&f==f){for(var d=c.length;d--;)if(c[d]===f)continue t;e&&c.push(f),a.push(u)}else n(c,f,r)||(c!==a&&c.push(f),a.push(u))}return a}function hn(t,e){return null==(t=Es(t,e=bn(e,t)))||delete t[qs(Js(e))]}function un(t,e,r,i){return Yi(t,e,r(Ai(t,e)),i)}function fn(t,e,r,i){for(var n=t.length,s=i?n:-1;(i?s--:++s<n)&&e(t[s],s,t););return r?tn(t,i?0:s,i?s+1:n):tn(t,i?s+1:0,i?n:s)}function dn(t,e){var r=t;return r instanceof Fr&&(r=r.value()),Oe(e,(function(t,e){return e.func.apply(e.thisArg,Ne([t],e.args))}),r)}function ln(t,e,r){var i=t.length;if(i<2)return i?cn(t[0]):[];for(var n=-1,s=At(i);++n<i;)for(var o=t[n],a=-1;++a<i;)a!=n&&(s[n]=hi(s[n]||o,t[a],e,r));return cn(gi(s,1),e,r)}function pn(e,r,i){for(var n=-1,s=e.length,o=r.length,a={};++n<s;){var c=n<o?r[n]:t;i(a,e[n],c)}return a}function gn(t){return $o(t)?t:[]}function mn(t){return"function"==typeof t?t:ec}function bn(t,e){return Fo(t)?t:vs(t,e)?[t]:Ts(ma(t))}var vn=Ji;function yn(e,r,i){var n=e.length;return i=i===t?n:i,!r&&i>=n?e:tn(e,r,i)}var wn=fe||function(t){return he.clearTimeout(t)};function An(t,e){if(e)return t.slice();var r=t.length,i=$t?$t(r):new t.constructor(r);return t.copy(i),i}function _n(t){var e=new t.constructor(t.byteLength);return new Ht(e).set(new Ht(t)),e}function Mn(t,e){var r=e?_n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function In(e,r){if(e!==r){var i=e!==t,n=null===e,s=e==e,o=oa(e),a=r!==t,c=null===r,h=r==r,u=oa(r);if(!c&&!u&&!o&&e>r||o&&a&&h&&!c&&!u||n&&a&&h||!i&&h||!s)return 1;if(!n&&!o&&!u&&e<r||u&&i&&s&&!n&&!o||c&&i&&s||!a&&s||!h)return-1}return 0}function En(t,e,r,i){for(var n=-1,s=t.length,o=r.length,a=-1,c=e.length,h=mr(s-o,0),u=At(c+h),f=!i;++a<c;)u[a]=e[a];for(;++n<o;)(f||n<s)&&(u[r[n]]=t[n]);for(;h--;)u[a++]=t[n++];return u}function Sn(t,e,r,i){for(var n=-1,s=t.length,o=-1,a=r.length,c=-1,h=e.length,u=mr(s-a,0),f=At(u+h),d=!i;++n<u;)f[n]=t[n];for(var l=n;++c<h;)f[l+c]=e[c];for(;++o<a;)(d||n<s)&&(f[l+r[o]]=t[n++]);return f}function Pn(t,e){var r=-1,i=t.length;for(e||(e=At(i));++r<i;)e[r]=t[r];return e}function xn(e,r,i,n){var s=!i;i||(i={});for(var o=-1,a=r.length;++o<a;){var c=r[o],h=n?n(i[c],e[c],c,i,e):t;h===t&&(h=e[c]),s?ii(i,c,h):Xr(i,c,h)}return i}function Rn(t,e){return function(r,i){var n=Fo(r)?_e:ei,s=e?e():{};return n(r,t,os(i,2),s)}}function Nn(e){return Ji((function(r,i){var n=-1,s=i.length,o=s>1?i[s-1]:t,a=s>2?i[2]:t;for(o=e.length>3&&"function"==typeof o?(s--,o):t,a&&bs(i[0],i[1],a)&&(o=s<3?t:o,s=1),r=St(r);++n<s;){var c=i[n];c&&e(r,c,n,o)}return r}))}function On(t,e){return function(r,i){if(null==r)return r;if(!Ho(r))return t(r,i);for(var n=r.length,s=e?n:-1,o=St(r);(e?s--:++s<n)&&!1!==i(o[s],s,o););return r}}function Cn(t){return function(e,r,i){for(var n=-1,s=St(e),o=i(e),a=o.length;a--;){var c=o[t?a:++n];if(!1===r(s[c],c,s))break}return e}}function Tn(e){return function(r){var i=er(r=ma(r))?ar(r):t,n=i?i[0]:r.charAt(0),s=i?yn(i,1).join(""):r.slice(1);return n[e]()+s}}function qn(t){return function(e){return Oe(Ga(La(e).replace(Qt,"")),t,"")}}function Dn(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var r=zr(t.prototype),i=t.apply(r,e);return Zo(i)?i:r}}function kn(e){return function(r,i,n){var s=St(r);if(!Ho(r)){var o=os(i,3);r=Ra(r),i=function(t){return o(s[t],t,s)}}var a=e(r,i,n);return a>-1?s[o?r[a]:a]:t}}function Bn(r){return ts((function(i){var n=i.length,s=n,o=Lr.prototype.thru;for(r&&i.reverse();s--;){var a=i[s];if("function"!=typeof a)throw new Rt(e);if(o&&!c&&"wrapper"==ns(a))var c=new Lr([],!0)}for(s=c?s:n;++s<n;){var h=ns(a=i[s]),u="wrapper"==h?is(a):t;c=u&&ys(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[ns(u[0])].apply(c,u[3]):1==a.length&&ys(a)?c[h]():c.thru(a)}return function(){var t=arguments,e=t[0];if(c&&1==t.length&&Fo(e))return c.plant(e).value();for(var r=0,s=n?i[r].apply(this,t):e;++r<n;)s=i[r].call(this,s);return s}}))}function Un(e,r,i,n,o,a,c,h,u,f){var d=r&s,l=1&r,p=2&r,g=24&r,m=512&r,b=p?t:Dn(e);return function s(){for(var v=arguments.length,y=At(v),w=v;w--;)y[w]=arguments[w];if(g)var A=ss(s),_=function(t,e){for(var r=t.length,i=0;r--;)t[r]===e&&++i;return i}(y,A);if(n&&(y=En(y,n,o,g)),a&&(y=Sn(y,a,c,g)),v-=_,g&&v<f){var M=nr(y,A);return $n(e,r,Un,s.placeholder,i,y,M,h,u,f-v)}var I=l?i:this,E=p?I[e]:e;return v=y.length,h?y=function(e,r){for(var i=e.length,n=br(r.length,i),s=Pn(e);n--;){var o=r[n];e[n]=ms(o,i)?s[o]:t}return e}(y,h):m&&v>1&&y.reverse(),d&&u<v&&(y.length=u),this&&this!==he&&this instanceof s&&(E=b||Dn(E)),E.apply(I,y)}}function zn(t,e){return function(r,i){return function(t,e,r,i){return vi(t,(function(t,n,s){e(i,r(t),n,s)})),i}(r,t,e(i),{})}}function jn(e,r){return function(i,n){var s;if(i===t&&n===t)return r;if(i!==t&&(s=i),n!==t){if(s===t)return n;"string"==typeof i||"string"==typeof n?(i=an(i),n=an(n)):(i=on(i),n=on(n)),s=e(i,n)}return s}}function Ln(t){return ts((function(e){return e=Re(e,Je(os())),Ji((function(r){var i=this;return t(e,(function(t){return Ae(t,i,r)}))}))}))}function Fn(e,r){var i=(r=r===t?" ":an(r)).length;if(i<2)return i?Vi(r,e):r;var n=Vi(r,qe(e/or(r)));return er(r)?yn(ar(n),0,e).join(""):n.slice(0,e)}function Kn(e){return function(r,i,n){return n&&"number"!=typeof n&&bs(r,i,n)&&(i=n=t),r=fa(r),i===t?(i=r,r=0):i=fa(i),function(t,e,r,i){for(var n=-1,s=mr(qe((e-t)/(r||1)),0),o=At(s);s--;)o[i?s:++n]=t,t+=r;return o}(r,i,n=n===t?r<i?1:-1:fa(n),e)}}function Hn(t){return function(e,r){return"string"==typeof e&&"string"==typeof r||(e=pa(e),r=pa(r)),t(e,r)}}function $n(e,r,i,s,o,a,c,h,u,f){var d=8&r;r|=d?n:64,4&(r&=~(d?64:n))||(r&=-4);var l=[e,r,o,d?a:t,d?c:t,d?t:a,d?t:c,h,u,f],p=i.apply(t,l);return ys(e)&&Ps(p,l),p.placeholder=s,Ns(p,e,r)}function Vn(t){var e=Et[t];return function(t,r){if(t=pa(t),(r=null==r?0:br(da(r),292))&&lr(t)){var i=(ma(t)+"e").split("e");return+((i=(ma(e(i[0]+"e"+(+i[1]+r)))+"e").split("e"))[0]+"e"+(+i[1]-r))}return e(t)}}var Jn=Er&&1/sr(new Er([,-0]))[1]==o?function(t){return new Er(t)}:oc;function Qn(t){return function(e){var r=ds(e);return r==w?rr(e):r==E?function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=[t,t]})),r}(e):function(t,e){return Re(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Gn(r,o,a,c,h,u,f,d){var l=2&o;if(!l&&"function"!=typeof r)throw new Rt(e);var p=c?c.length:0;if(p||(o&=-97,c=h=t),f=f===t?f:mr(da(f),0),d=d===t?d:da(d),p-=h?h.length:0,64&o){var g=c,m=h;c=h=t}var b=l?t:is(r),v=[r,o,a,c,h,g,m,u,f,d];if(b&&function(t,e){var r=t[1],n=e[1],o=r|n,a=o<131,c=n==s&&8==r||n==s&&256==r&&t[7].length<=e[8]||384==n&&e[7].length<=e[8]&&8==r;if(!a&&!c)return t;1&n&&(t[2]=e[2],o|=1&r?0:4);var h=e[3];if(h){var u=t[3];t[3]=u?En(u,h,e[4]):h,t[4]=u?nr(t[3],i):e[4]}(h=e[5])&&(u=t[5],t[5]=u?Sn(u,h,e[6]):h,t[6]=u?nr(t[5],i):e[6]),(h=e[7])&&(t[7]=h),n&s&&(t[8]=null==t[8]?e[8]:br(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=o}(v,b),r=v[0],o=v[1],a=v[2],c=v[3],h=v[4],!(d=v[9]=v[9]===t?l?0:r.length:mr(v[9]-p,0))&&24&o&&(o&=-25),o&&1!=o)y=8==o||16==o?function(e,r,i){var n=Dn(e);return function s(){for(var o=arguments.length,a=At(o),c=o,h=ss(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==h&&a[o-1]!==h?[]:nr(a,h);return(o-=u.length)<i?$n(e,r,Un,s.placeholder,t,a,u,t,t,i-o):Ae(this&&this!==he&&this instanceof s?n:e,this,a)}}(r,o,d):o!=n&&33!=o||h.length?Un.apply(t,v):function(t,e,r,i){var n=1&e,s=Dn(t);return function e(){for(var o=-1,a=arguments.length,c=-1,h=i.length,u=At(h+a),f=this&&this!==he&&this instanceof e?s:t;++c<h;)u[c]=i[c];for(;a--;)u[c++]=arguments[++o];return Ae(f,n?r:this,u)}}(r,o,a,c);else var y=function(t,e,r){var i=1&e,n=Dn(t);return function e(){return(this&&this!==he&&this instanceof e?n:t).apply(i?r:this,arguments)}}(r,o,a);return Ns((b?Wi:Ps)(y,v),r,o)}function Yn(e,r,i,n){return e===t||Uo(e,Ct[i])&&!Dt.call(n,i)?r:e}function Wn(e,r,i,n,s,o){return Zo(e)&&Zo(r)&&(o.set(r,e),zi(e,r,t,Wn,o),o.delete(r)),e}function Zn(e){return ra(e)?t:e}function Xn(e,r,i,n,s,o){var a=1&i,c=e.length,h=r.length;if(c!=h&&!(a&&h>c))return!1;var u=o.get(e),f=o.get(r);if(u&&f)return u==r&&f==e;var d=-1,l=!0,p=2&i?new Vr:t;for(o.set(e,r),o.set(r,e);++d<c;){var g=e[d],m=r[d];if(n)var b=a?n(m,g,d,r,e,o):n(g,m,d,e,r,o);if(b!==t){if(b)continue;l=!1;break}if(p){if(!Te(r,(function(t,e){if(!Ge(p,e)&&(g===t||s(g,t,i,n,o)))return p.push(e)}))){l=!1;break}}else if(g!==m&&!s(g,m,i,n,o)){l=!1;break}}return o.delete(e),o.delete(r),l}function ts(e){return Rs(Is(e,t,Fs),e+"")}function es(t){return _i(t,Ra,us)}function rs(t){return _i(t,Na,fs)}var is=xr?function(t){return xr.get(t)}:oc;function ns(t){for(var e=t.name+"",r=Rr[e],i=Dt.call(Rr,e)?r.length:0;i--;){var n=r[i],s=n.func;if(null==s||s==t)return n.name}return e}function ss(t){return(Dt.call(Ur,"placeholder")?Ur:t).placeholder}function os(){var t=Ur.iteratee||rc;return t=t===rc?Ti:t,arguments.length?t(arguments[0],arguments[1]):t}function as(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function cs(t){for(var e=Ra(t),r=e.length;r--;){var i=e[r],n=t[i];e[r]=[i,n,_s(n)]}return e}function hs(e,r){var i=function(e,r){return null==e?t:e[r]}(e,r);return Ci(i)?i:t}var us=fr?function(t){return null==t?[]:(t=St(t),Se(fr(t),(function(e){return Yt.call(t,e)})))}:lc,fs=fr?function(t){for(var e=[];t;)Ne(e,us(t)),t=Vt(t);return e}:lc,ds=Mi;function ls(t,e,r){for(var i=-1,n=(e=bn(e,t)).length,s=!1;++i<n;){var o=qs(e[i]);if(!(s=null!=t&&r(t,o)))break;t=t[o]}return s||++i!=n?s:!!(n=null==t?0:t.length)&&Wo(n)&&ms(o,n)&&(Fo(t)||Lo(t))}function ps(t){return"function"!=typeof t.constructor||As(t)?{}:zr(Vt(t))}function gs(t){return Fo(t)||Lo(t)||!!(ne&&t&&t[ne])}function ms(t,e){var r=typeof t;return!!(e=e??a)&&("number"==r||"symbol"!=r&>.test(t))&&t>-1&&t%1==0&&t<e}function bs(t,e,r){if(!Zo(r))return!1;var i=typeof e;return!!("number"==i?Ho(r)&&ms(e,r.length):"string"==i&&e in r)&&Uo(r[e],t)}function vs(t,e){if(Fo(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!oa(t))||W.test(t)||!Y.test(t)||null!=e&&t in St(e)}function ys(t){var e=ns(t),r=Ur[e];if("function"!=typeof r||!(e in Fr.prototype))return!1;if(t===r)return!0;var i=is(r);return!!i&&t===i[0]}(_r&&ds(new _r(new ArrayBuffer(1)))!=N||Mr&&ds(new Mr)!=w||Ir&&ds(Ir.resolve())!=M||Er&&ds(new Er)!=E||Sr&&ds(new Sr)!=x)&&(ds=function(e){var r=Mi(e),i=r==_?e.constructor:t,n=i?Ds(i):"";if(n)switch(n){case Nr:return N;case Or:return w;case Cr:return M;case Tr:return E;case qr:return x}return r});var ws=Tt?Go:pc;function As(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ct)}function _s(t){return t==t&&!Zo(t)}function Ms(e,r){return function(i){return null!=i&&i[e]===r&&(r!==t||e in St(i))}}function Is(e,r,i){return r=mr(r===t?e.length-1:r,0),function(){for(var t=arguments,n=-1,s=mr(t.length-r,0),o=At(s);++n<s;)o[n]=t[r+n];n=-1;for(var a=At(r+1);++n<r;)a[n]=t[n];return a[r]=i(o),Ae(e,this,a)}}function Es(t,e){return e.length<2?t:Ai(t,tn(e,0,-1))}function Ss(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ps=Os(Wi),xs=pe||function(t,e){return he.setTimeout(t,e)},Rs=Os(Zi);function Ns(t,e,r){var i=e+"";return Rs(t,function(t,e){var r=e.length;if(!r)return t;var i=r-1;return e[i]=(r>1?"& ":"")+e[i],e=e.join(r>2?", ":" "),t.replace(it,"{\n/* [wrapped with "+e+"] */\n")}(i,function(t,e){return Me(d,(function(r){var i="_."+r[0];e&r[1]&&!Pe(t,i)&&t.push(i)})),t.sort()}(function(t){var e=t.match(nt);return e?e[1].split(st):[]}(i),r)))}function Os(e){var r=0,i=0;return function(){var n=vr(),s=16-(n-i);if(i=n,s>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(t,arguments)}}function Cs(e,r){var i=-1,n=e.length,s=n-1;for(r=r===t?n:r;++i<r;){var o=$i(i,s),a=e[o];e[o]=e[i],e[i]=a}return e.length=r,e}var Ts=function(){var t=Co((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Z,(function(t,r,i,n){e.push(i?n.replace(ct,"$1"):r||t)})),e}),(function(t){return 500===e.size&&e.clear(),t})),e=t.cache;return t}();function qs(t){if("string"==typeof t||oa(t))return t;var e=t+"";return"0"==e&&1/t==-o?"-0":e}function Ds(t){if(null!=t){try{return qt.call(t)}catch{}try{return t+""}catch{}}return""}function ks(t){if(t instanceof Fr)return t.clone();var e=new Lr(t.__wrapped__,t.__chain__);return e.__actions__=Pn(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var Bs=Ji((function(t,e){return $o(t)?hi(t,gi(e,1,$o,!0)):[]})),Us=Ji((function(e,r){var i=Js(r);return $o(i)&&(i=t),$o(e)?hi(e,gi(r,1,$o,!0),os(i,2)):[]})),zs=Ji((function(e,r){var i=Js(r);return $o(i)&&(i=t),$o(e)?hi(e,gi(r,1,$o,!0),t,i):[]}));function js(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var n=null==r?0:da(r);return n<0&&(n=mr(i+n,0)),ke(t,os(e,3),n)}function Ls(e,r,i){var n=null==e?0:e.length;if(!n)return-1;var s=n-1;return i!==t&&(s=da(i),s=i<0?mr(n+s,0):br(s,n-1)),ke(e,os(r,3),s,!0)}function Fs(t){return null!=t&&t.length?gi(t,1):[]}function Ks(e){return e&&e.length?e[0]:t}var Hs=Ji((function(t){var e=Re(t,gn);return e.length&&e[0]===t[0]?Pi(e):[]})),$s=Ji((function(e){var r=Js(e),i=Re(e,gn);return r===Js(i)?r=t:i.pop(),i.length&&i[0]===e[0]?Pi(i,os(r,2)):[]})),Vs=Ji((function(e){var r=Js(e),i=Re(e,gn);return(r="function"==typeof r?r:t)&&i.pop(),i.length&&i[0]===e[0]?Pi(i,t,r):[]}));function Js(e){var r=null==e?0:e.length;return r?e[r-1]:t}var Qs=Ji(Gs);function Gs(t,e){return t&&t.length&&e&&e.length?Ki(t,e):t}var Ys=ts((function(t,e){var r=null==t?0:t.length,i=ni(t,e);return Hi(t,Re(e,(function(t){return ms(t,r)?+t:t})).sort(In)),i}));function Ws(t){return null==t?t:Ar.call(t)}var Zs=Ji((function(t){return cn(gi(t,1,$o,!0))})),Xs=Ji((function(e){var r=Js(e);return $o(r)&&(r=t),cn(gi(e,1,$o,!0),os(r,2))})),to=Ji((function(e){var r=Js(e);return r="function"==typeof r?r:t,cn(gi(e,1,$o,!0),t,r)}));function eo(t){if(!t||!t.length)return[];var e=0;return t=Se(t,(function(t){if($o(t))return e=mr(t.length,e),!0})),$e(e,(function(e){return Re(t,Le(e))}))}function ro(e,r){if(!e||!e.length)return[];var i=eo(e);return null==r?i:Re(i,(function(e){return Ae(r,t,e)}))}var io=Ji((function(t,e){return $o(t)?hi(t,e):[]})),no=Ji((function(t){return ln(Se(t,$o))})),so=Ji((function(e){var r=Js(e);return $o(r)&&(r=t),ln(Se(e,$o),os(r,2))})),oo=Ji((function(e){var r=Js(e);return r="function"==typeof r?r:t,ln(Se(e,$o),t,r)})),ao=Ji(eo),co=Ji((function(e){var r=e.length,i=r>1?e[r-1]:t;return i="function"==typeof i?(e.pop(),i):t,ro(e,i)}));function ho(t){var e=Ur(t);return e.__chain__=!0,e}function uo(t,e){return e(t)}var fo=ts((function(e){var r=e.length,i=r?e[0]:0,n=this.__wrapped__,s=function(t){return ni(t,e)};return!(r>1||this.__actions__.length)&&n instanceof Fr&&ms(i)?((n=n.slice(i,+i+(r?1:0))).__actions__.push({func:uo,args:[s],thisArg:t}),new Lr(n,this.__chain__).thru((function(e){return r&&!e.length&&e.push(t),e}))):this.thru(s)})),lo=Rn((function(t,e,r){Dt.call(t,r)?++t[r]:ii(t,r,1)})),po=kn(js),go=kn(Ls);function mo(t,e){return(Fo(t)?Me:ui)(t,os(e,3))}function bo(t,e){return(Fo(t)?Ie:fi)(t,os(e,3))}var vo=Rn((function(t,e,r){Dt.call(t,r)?t[r].push(e):ii(t,r,[e])})),yo=Ji((function(t,e,r){var i=-1,n="function"==typeof e,s=Ho(t)?At(t.length):[];return ui(t,(function(t){s[++i]=n?Ae(e,t,r):xi(t,e,r)})),s})),wo=Rn((function(t,e,r){ii(t,r,e)}));function Ao(t,e){return(Fo(t)?Re:ki)(t,os(e,3))}var _o=Rn((function(t,e,r){t[r?0:1].push(e)}),(function(){return[[],[]]})),Mo=Ji((function(t,e){if(null==t)return[];var r=e.length;return r>1&&bs(t,e[0],e[1])?e=[]:r>2&&bs(e[0],e[1],e[2])&&(e=[e[0]]),Li(t,gi(e,1),[])})),Io=le||function(){return he.Date.now()};function Eo(e,r,i){return r=i?t:r,r=e&&null==r?e.length:r,Gn(e,s,t,t,t,t,r)}function So(r,i){var n;if("function"!=typeof i)throw new Rt(e);return r=da(r),function(){return--r>0&&(n=i.apply(this,arguments)),r<=1&&(i=t),n}}var Po=Ji((function(t,e,r){var i=1;if(r.length){var s=nr(r,ss(Po));i|=n}return Gn(t,i,e,r,s)})),xo=Ji((function(t,e,r){var i=3;if(r.length){var s=nr(r,ss(xo));i|=n}return Gn(e,i,t,r,s)}));function Ro(r,i,n){var s,o,a,c,h,u,f=0,d=!1,l=!1,p=!0;if("function"!=typeof r)throw new Rt(e);function g(e){var i=s,n=o;return s=o=t,f=e,c=r.apply(n,i)}function m(e){var r=e-u;return u===t||r>=i||r<0||l&&e-f>=a}function b(){var t=Io();if(m(t))return v(t);h=xs(b,function(t){var e=i-(t-u);return l?br(e,a-(t-f)):e}(t))}function v(e){return h=t,p&&s?g(e):(s=o=t,c)}function y(){var e=Io(),r=m(e);if(s=arguments,o=this,u=e,r){if(h===t)return function(t){return f=t,h=xs(b,i),d?g(t):c}(u);if(l)return wn(h),h=xs(b,i),g(u)}return h===t&&(h=xs(b,i)),c}return i=pa(i)||0,Zo(n)&&(d=!!n.leading,a=(l="maxWait"in n)?mr(pa(n.maxWait)||0,i):a,p="trailing"in n?!!n.trailing:p),y.cancel=function(){h!==t&&wn(h),f=0,s=u=o=h=t},y.flush=function(){return h===t?c:v(Io())},y}var No=Ji((function(t,e){return ci(t,1,e)})),Oo=Ji((function(t,e,r){return ci(t,pa(e)||0,r)}));function Co(t,r){if("function"!=typeof t||null!=r&&"function"!=typeof r)throw new Rt(e);var i=function(){var e=arguments,n=r?r.apply(this,e):e[0],s=i.cache;if(s.has(n))return s.get(n);var o=t.apply(this,e);return i.cache=s.set(n,o)||s,o};return i.cache=new(Co.Cache||$r),i}function To(t){if("function"!=typeof t)throw new Rt(e);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Co.Cache=$r;var qo=vn((function(t,e){var r=(e=1==e.length&&Fo(e[0])?Re(e[0],Je(os())):Re(gi(e,1),Je(os()))).length;return Ji((function(i){for(var n=-1,s=br(i.length,r);++n<s;)i[n]=e[n].call(this,i[n]);return Ae(t,this,i)}))})),Do=Ji((function(e,r){var i=nr(r,ss(Do));return Gn(e,n,t,r,i)})),ko=Ji((function(e,r){var i=nr(r,ss(ko));return Gn(e,64,t,r,i)})),Bo=ts((function(e,r){return Gn(e,256,t,t,t,r)}));function Uo(t,e){return t===e||t!=t&&e!=e}var zo=Hn(Ii),jo=Hn((function(t,e){return t>=e})),Lo=Ri(function(){return arguments}())?Ri:function(t){return Xo(t)&&Dt.call(t,"callee")&&!Yt.call(t,"callee")},Fo=At.isArray,Ko=ge?Je(ge):function(t){return Xo(t)&&Mi(t)==R};function Ho(t){return null!=t&&Wo(t.length)&&!Go(t)}function $o(t){return Xo(t)&&Ho(t)}var Vo=dr||pc,Jo=me?Je(me):function(t){return Xo(t)&&Mi(t)==m};function Qo(t){if(!Xo(t))return!1;var e=Mi(t);return e==b||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ra(t)}function Go(t){if(!Zo(t))return!1;var e=Mi(t);return e==v||e==y||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Yo(t){return"number"==typeof t&&t==da(t)}function Wo(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=a}function Zo(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Xo(t){return null!=t&&"object"==typeof t}var ta=be?Je(be):function(t){return Xo(t)&&ds(t)==w};function ea(t){return"number"==typeof t||Xo(t)&&Mi(t)==A}function ra(t){if(!Xo(t)||Mi(t)!=_)return!1;var e=Vt(t);if(null===e)return!0;var r=Dt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&qt.call(r)==zt}var ia=ve?Je(ve):function(t){return Xo(t)&&Mi(t)==I},na=ye?Je(ye):function(t){return Xo(t)&&ds(t)==E};function sa(t){return"string"==typeof t||!Fo(t)&&Xo(t)&&Mi(t)==S}function oa(t){return"symbol"==typeof t||Xo(t)&&Mi(t)==P}var aa=we?Je(we):function(t){return Xo(t)&&Wo(t.length)&&!!re[Mi(t)]},ca=Hn(Di),ha=Hn((function(t,e){return t<=e}));function ua(t){if(!t)return[];if(Ho(t))return sa(t)?ar(t):Pn(t);if(ae&&t[ae])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[ae]());var e=ds(t);return(e==w?rr:e==E?sr:Ua)(t)}function fa(t){return t?(t=pa(t))===o||t===-o?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function da(t){var e=fa(t),r=e%1;return e==e?r?e-r:e:0}function la(t){return t?si(da(t),0,h):0}function pa(t){if("number"==typeof t)return t;if(oa(t))return c;if(Zo(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Zo(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ve(t);var r=dt.test(t);return r||pt.test(t)?oe(t.slice(2),r?2:8):ft.test(t)?c:+t}function ga(t){return xn(t,Na(t))}function ma(t){return null==t?"":an(t)}var ba=Nn((function(t,e){if(As(e)||Ho(e))xn(e,Ra(e),t);else for(var r in e)Dt.call(e,r)&&Xr(t,r,e[r])})),va=Nn((function(t,e){xn(e,Na(e),t)})),ya=Nn((function(t,e,r,i){xn(e,Na(e),t,i)})),wa=Nn((function(t,e,r,i){xn(e,Ra(e),t,i)})),Aa=ts(ni),_a=Ji((function(e,r){e=St(e);var i=-1,n=r.length,s=n>2?r[2]:t;for(s&&bs(r[0],r[1],s)&&(n=1);++i<n;)for(var o=r[i],a=Na(o),c=-1,h=a.length;++c<h;){var u=a[c],f=e[u];(f===t||Uo(f,Ct[u])&&!Dt.call(e,u))&&(e[u]=o[u])}return e})),Ma=Ji((function(e){return e.push(t,Wn),Ae(Ca,t,e)}));function Ia(e,r,i){var n=null==e?t:Ai(e,r);return n===t?i:n}function Ea(t,e){return null!=t&&ls(t,e,Si)}var Sa=zn((function(t,e,r){null!=e&&"function"!=typeof e.toString&&(e=Ut.call(e)),t[e]=r}),Za(ec)),Pa=zn((function(t,e,r){null!=e&&"function"!=typeof e.toString&&(e=Ut.call(e)),Dt.call(t,e)?t[e].push(r):t[e]=[r]}),os),xa=Ji(xi);function Ra(t){return Ho(t)?Qr(t):qi(t)}function Na(t){return Ho(t)?Qr(t,!0):function(t){if(!Zo(t))return function(t){var e=[];if(null!=t)for(var r in St(t))e.push(r);return e}(t);var e=As(t),r=[];for(var i in t)"constructor"==i&&(e||!Dt.call(t,i))||r.push(i);return r}(t)}var Oa=Nn((function(t,e,r){zi(t,e,r)})),Ca=Nn((function(t,e,r,i){zi(t,e,r,i)})),Ta=ts((function(t,e){var r={};if(null==t)return r;var i=!1;e=Re(e,(function(e){return e=bn(e,t),i||(i=e.length>1),e})),xn(t,rs(t),r),i&&(r=oi(r,7,Zn));for(var n=e.length;n--;)hn(r,e[n]);return r})),qa=ts((function(t,e){return null==t?{}:function(t,e){return Fi(t,e,(function(e,r){return Ea(t,r)}))}(t,e)}));function Da(t,e){if(null==t)return{};var r=Re(rs(t),(function(t){return[t]}));return e=os(e),Fi(t,r,(function(t,r){return e(t,r[0])}))}var ka=Qn(Ra),Ba=Qn(Na);function Ua(t){return null==t?[]:Qe(t,Ra(t))}var za=qn((function(t,e,r){return e=e.toLowerCase(),t+(r?ja(e):e)}));function ja(t){return Qa(ma(t).toLowerCase())}function La(t){return(t=ma(t))&&t.replace(mt,Ze).replace(Gt,"")}var Fa=qn((function(t,e,r){return t+(r?"-":"")+e.toLowerCase()})),Ka=qn((function(t,e,r){return t+(r?" ":"")+e.toLowerCase()})),Ha=Tn("toLowerCase"),$a=qn((function(t,e,r){return t+(r?"_":"")+e.toLowerCase()})),Va=qn((function(t,e,r){return t+(r?" ":"")+Qa(e)})),Ja=qn((function(t,e,r){return t+(r?" ":"")+e.toUpperCase()})),Qa=Tn("toUpperCase");function Ga(e,r,i){return e=ma(e),(r=i?t:r)===t?function(t){return Xt.test(t)}(e)?function(t){return t.match(Wt)||[]}(e):function(t){return t.match(ot)||[]}(e):e.match(r)||[]}var Ya=Ji((function(e,r){try{return Ae(e,t,r)}catch(t){return Qo(t)?t:new Mt(t)}})),Wa=ts((function(t,e){return Me(e,(function(e){e=qs(e),ii(t,e,Po(t[e],t))})),t}));function Za(t){return function(){return t}}var Xa=Bn(),tc=Bn(!0);function ec(t){return t}function rc(t){return Ti("function"==typeof t?t:oi(t,1))}var ic=Ji((function(t,e){return function(r){return xi(r,t,e)}})),nc=Ji((function(t,e){return function(r){return xi(t,r,e)}}));function sc(t,e,r){var i=Ra(e),n=wi(e,i);null==r&&(!Zo(e)||!n.length&&i.length)&&(r=e,e=t,t=this,n=wi(e,Ra(e)));var s=!(Zo(r)&&"chain"in r&&!r.chain),o=Go(t);return Me(n,(function(r){var i=e[r];t[r]=i,o&&(t.prototype[r]=function(){var e=this.__chain__;if(s||e){var r=t(this.__wrapped__);return(r.__actions__=Pn(this.__actions__)).push({func:i,args:arguments,thisArg:t}),r.__chain__=e,r}return i.apply(t,Ne([this.value()],arguments))})})),t}function oc(){}var ac=Ln(Re),cc=Ln(Ee),hc=Ln(Te);function uc(t){return vs(t)?Le(qs(t)):function(t){return function(e){return Ai(e,t)}}(t)}var fc=Kn(),dc=Kn(!0);function lc(){return[]}function pc(){return!1}var gc=jn((function(t,e){return t+e}),0),mc=Vn("ceil"),bc=jn((function(t,e){return t/e}),1),vc=Vn("floor"),yc=jn((function(t,e){return t*e}),1),wc=Vn("round"),Ac=jn((function(t,e){return t-e}),0);return Ur.after=function(t,r){if("function"!=typeof r)throw new Rt(e);return t=da(t),function(){if(--t<1)return r.apply(this,arguments)}},Ur.ary=Eo,Ur.assign=ba,Ur.assignIn=va,Ur.assignInWith=ya,Ur.assignWith=wa,Ur.at=Aa,Ur.before=So,Ur.bind=Po,Ur.bindAll=Wa,Ur.bindKey=xo,Ur.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Fo(t)?t:[t]},Ur.chain=ho,Ur.chunk=function(e,r,i){r=(i?bs(e,r,i):r===t)?1:mr(da(r),0);var n=null==e?0:e.length;if(!n||r<1)return[];for(var s=0,o=0,a=At(qe(n/r));s<n;)a[o++]=tn(e,s,s+=r);return a},Ur.compact=function(t){for(var e=-1,r=null==t?0:t.length,i=0,n=[];++e<r;){var s=t[e];s&&(n[i++]=s)}return n},Ur.concat=function(){var t=arguments.length;if(!t)return[];for(var e=At(t-1),r=arguments[0],i=t;i--;)e[i-1]=arguments[i];return Ne(Fo(r)?Pn(r):[r],gi(e,1))},Ur.cond=function(t){var r=null==t?0:t.length,i=os();return t=r?Re(t,(function(t){if("function"!=typeof t[1])throw new Rt(e);return[i(t[0]),t[1]]})):[],Ji((function(e){for(var i=-1;++i<r;){var n=t[i];if(Ae(n[0],this,e))return Ae(n[1],this,e)}}))},Ur.conforms=function(t){return function(t){var e=Ra(t);return function(r){return ai(r,t,e)}}(oi(t,1))},Ur.constant=Za,Ur.countBy=lo,Ur.create=function(t,e){var r=zr(t);return null==e?r:ri(r,e)},Ur.curry=function e(r,i,n){var s=Gn(r,8,t,t,t,t,t,i=n?t:i);return s.placeholder=e.placeholder,s},Ur.curryRight=function e(r,i,n){var s=Gn(r,16,t,t,t,t,t,i=n?t:i);return s.placeholder=e.placeholder,s},Ur.debounce=Ro,Ur.defaults=_a,Ur.defaultsDeep=Ma,Ur.defer=No,Ur.delay=Oo,Ur.difference=Bs,Ur.differenceBy=Us,Ur.differenceWith=zs,Ur.drop=function(e,r,i){var n=null==e?0:e.length;return n?tn(e,(r=i||r===t?1:da(r))<0?0:r,n):[]},Ur.dropRight=function(e,r,i){var n=null==e?0:e.length;return n?tn(e,0,(r=n-(r=i||r===t?1:da(r)))<0?0:r):[]},Ur.dropRightWhile=function(t,e){return t&&t.length?fn(t,os(e,3),!0,!0):[]},Ur.dropWhile=function(t,e){return t&&t.length?fn(t,os(e,3),!0):[]},Ur.fill=function(e,r,i,n){var s=null==e?0:e.length;return s?(i&&"number"!=typeof i&&bs(e,r,i)&&(i=0,n=s),function(e,r,i,n){var s=e.length;for((i=da(i))<0&&(i=-i>s?0:s+i),(n=n===t||n>s?s:da(n))<0&&(n+=s),n=i>n?0:la(n);i<n;)e[i++]=r;return e}(e,r,i,n)):[]},Ur.filter=function(t,e){return(Fo(t)?Se:pi)(t,os(e,3))},Ur.flatMap=function(t,e){return gi(Ao(t,e),1)},Ur.flatMapDeep=function(t,e){return gi(Ao(t,e),o)},Ur.flatMapDepth=function(e,r,i){return i=i===t?1:da(i),gi(Ao(e,r),i)},Ur.flatten=Fs,Ur.flattenDeep=function(t){return null!=t&&t.length?gi(t,o):[]},Ur.flattenDepth=function(e,r){return null!=e&&e.length?gi(e,r=r===t?1:da(r)):[]},Ur.flip=function(t){return Gn(t,512)},Ur.flow=Xa,Ur.flowRight=tc,Ur.fromPairs=function(t){for(var e=-1,r=null==t?0:t.length,i={};++e<r;){var n=t[e];i[n[0]]=n[1]}return i},Ur.functions=function(t){return null==t?[]:wi(t,Ra(t))},Ur.functionsIn=function(t){return null==t?[]:wi(t,Na(t))},Ur.groupBy=vo,Ur.initial=function(t){return null!=t&&t.length?tn(t,0,-1):[]},Ur.intersection=Hs,Ur.intersectionBy=$s,Ur.intersectionWith=Vs,Ur.invert=Sa,Ur.invertBy=Pa,Ur.invokeMap=yo,Ur.iteratee=rc,Ur.keyBy=wo,Ur.keys=Ra,Ur.keysIn=Na,Ur.map=Ao,Ur.mapKeys=function(t,e){var r={};return e=os(e,3),vi(t,(function(t,i,n){ii(r,e(t,i,n),t)})),r},Ur.mapValues=function(t,e){var r={};return e=os(e,3),vi(t,(function(t,i,n){ii(r,i,e(t,i,n))})),r},Ur.matches=function(t){return Bi(oi(t,1))},Ur.matchesProperty=function(t,e){return Ui(t,oi(e,1))},Ur.memoize=Co,Ur.merge=Oa,Ur.mergeWith=Ca,Ur.method=ic,Ur.methodOf=nc,Ur.mixin=sc,Ur.negate=To,Ur.nthArg=function(t){return t=da(t),Ji((function(e){return ji(e,t)}))},Ur.omit=Ta,Ur.omitBy=function(t,e){return Da(t,To(os(e)))},Ur.once=function(t){return So(2,t)},Ur.orderBy=function(e,r,i,n){return null==e?[]:(Fo(r)||(r=null==r?[]:[r]),Fo(i=n?t:i)||(i=null==i?[]:[i]),Li(e,r,i))},Ur.over=ac,Ur.overArgs=qo,Ur.overEvery=cc,Ur.overSome=hc,Ur.partial=Do,Ur.partialRight=ko,Ur.partition=_o,Ur.pick=qa,Ur.pickBy=Da,Ur.property=uc,Ur.propertyOf=function(e){return function(r){return null==e?t:Ai(e,r)}},Ur.pull=Qs,Ur.pullAll=Gs,Ur.pullAllBy=function(t,e,r){return t&&t.length&&e&&e.length?Ki(t,e,os(r,2)):t},Ur.pullAllWith=function(e,r,i){return e&&e.length&&r&&r.length?Ki(e,r,t,i):e},Ur.pullAt=Ys,Ur.range=fc,Ur.rangeRight=dc,Ur.rearg=Bo,Ur.reject=function(t,e){return(Fo(t)?Se:pi)(t,To(os(e,3)))},Ur.remove=function(t,e){var r=[];if(!t||!t.length)return r;var i=-1,n=[],s=t.length;for(e=os(e,3);++i<s;){var o=t[i];e(o,i,t)&&(r.push(o),n.push(i))}return Hi(t,n),r},Ur.rest=function(r,i){if("function"!=typeof r)throw new Rt(e);return Ji(r,i=i===t?i:da(i))},Ur.reverse=Ws,Ur.sampleSize=function(e,r,i){return r=(i?bs(e,r,i):r===t)?1:da(r),(Fo(e)?Yr:Gi)(e,r)},Ur.set=function(t,e,r){return null==t?t:Yi(t,e,r)},Ur.setWith=function(e,r,i,n){return n="function"==typeof n?n:t,null==e?e:Yi(e,r,i,n)},Ur.shuffle=function(t){return(Fo(t)?Wr:Xi)(t)},Ur.slice=function(e,r,i){var n=null==e?0:e.length;return n?(i&&"number"!=typeof i&&bs(e,r,i)?(r=0,i=n):(r=null==r?0:da(r),i=i===t?n:da(i)),tn(e,r,i)):[]},Ur.sortBy=Mo,Ur.sortedUniq=function(t){return t&&t.length?sn(t):[]},Ur.sortedUniqBy=function(t,e){return t&&t.length?sn(t,os(e,2)):[]},Ur.split=function(e,r,i){return i&&"number"!=typeof i&&bs(e,r,i)&&(r=i=t),(i=i===t?h:i>>>0)?(e=ma(e))&&("string"==typeof r||null!=r&&!ia(r))&&!(r=an(r))&&er(e)?yn(ar(e),0,i):e.split(r,i):[]},Ur.spread=function(t,r){if("function"!=typeof t)throw new Rt(e);return r=null==r?0:mr(da(r),0),Ji((function(e){var i=e[r],n=yn(e,0,r);return i&&Ne(n,i),Ae(t,this,n)}))},Ur.tail=function(t){var e=null==t?0:t.length;return e?tn(t,1,e):[]},Ur.take=function(e,r,i){return e&&e.length?tn(e,0,(r=i||r===t?1:da(r))<0?0:r):[]},Ur.takeRight=function(e,r,i){var n=null==e?0:e.length;return n?tn(e,(r=n-(r=i||r===t?1:da(r)))<0?0:r,n):[]},Ur.takeRightWhile=function(t,e){return t&&t.length?fn(t,os(e,3),!1,!0):[]},Ur.takeWhile=function(t,e){return t&&t.length?fn(t,os(e,3)):[]},Ur.tap=function(t,e){return e(t),t},Ur.throttle=function(t,r,i){var n=!0,s=!0;if("function"!=typeof t)throw new Rt(e);return Zo(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),Ro(t,r,{leading:n,maxWait:r,trailing:s})},Ur.thru=uo,Ur.toArray=ua,Ur.toPairs=ka,Ur.toPairsIn=Ba,Ur.toPath=function(t){return Fo(t)?Re(t,qs):oa(t)?[t]:Pn(Ts(ma(t)))},Ur.toPlainObject=ga,Ur.transform=function(t,e,r){var i=Fo(t),n=i||Vo(t)||aa(t);if(e=os(e,4),null==r){var s=t&&t.constructor;r=n?i?new s:[]:Zo(t)&&Go(s)?zr(Vt(t)):{}}return(n?Me:vi)(t,(function(t,i,n){return e(r,t,i,n)})),r},Ur.unary=function(t){return Eo(t,1)},Ur.union=Zs,Ur.unionBy=Xs,Ur.unionWith=to,Ur.uniq=function(t){return t&&t.length?cn(t):[]},Ur.uniqBy=function(t,e){return t&&t.length?cn(t,os(e,2)):[]},Ur.uniqWith=function(e,r){return r="function"==typeof r?r:t,e&&e.length?cn(e,t,r):[]},Ur.unset=function(t,e){return null==t||hn(t,e)},Ur.unzip=eo,Ur.unzipWith=ro,Ur.update=function(t,e,r){return null==t?t:un(t,e,mn(r))},Ur.updateWith=function(e,r,i,n){return n="function"==typeof n?n:t,null==e?e:un(e,r,mn(i),n)},Ur.values=Ua,Ur.valuesIn=function(t){return null==t?[]:Qe(t,Na(t))},Ur.without=io,Ur.words=Ga,Ur.wrap=function(t,e){return Do(mn(e),t)},Ur.xor=no,Ur.xorBy=so,Ur.xorWith=oo,Ur.zip=ao,Ur.zipObject=function(t,e){return pn(t||[],e||[],Xr)},Ur.zipObjectDeep=function(t,e){return pn(t||[],e||[],Yi)},Ur.zipWith=co,Ur.entries=ka,Ur.entriesIn=Ba,Ur.extend=va,Ur.extendWith=ya,sc(Ur,Ur),Ur.add=gc,Ur.attempt=Ya,Ur.camelCase=za,Ur.capitalize=ja,Ur.ceil=mc,Ur.clamp=function(e,r,i){return i===t&&(i=r,r=t),i!==t&&(i=(i=pa(i))==i?i:0),r!==t&&(r=(r=pa(r))==r?r:0),si(pa(e),r,i)},Ur.clone=function(t){return oi(t,4)},Ur.cloneDeep=function(t){return oi(t,5)},Ur.cloneDeepWith=function(e,r){return oi(e,5,r="function"==typeof r?r:t)},Ur.cloneWith=function(e,r){return oi(e,4,r="function"==typeof r?r:t)},Ur.conformsTo=function(t,e){return null==e||ai(t,e,Ra(e))},Ur.deburr=La,Ur.defaultTo=function(t,e){return null==t||t!=t?e:t},Ur.divide=bc,Ur.endsWith=function(e,r,i){e=ma(e),r=an(r);var n=e.length,s=i=i===t?n:si(da(i),0,n);return(i-=r.length)>=0&&e.slice(i,s)==r},Ur.eq=Uo,Ur.escape=function(t){return(t=ma(t))&&V.test(t)?t.replace(H,Xe):t},Ur.escapeRegExp=function(t){return(t=ma(t))&&tt.test(t)?t.replace(X,"\\$&"):t},Ur.every=function(e,r,i){var n=Fo(e)?Ee:di;return i&&bs(e,r,i)&&(r=t),n(e,os(r,3))},Ur.find=po,Ur.findIndex=js,Ur.findKey=function(t,e){return De(t,os(e,3),vi)},Ur.findLast=go,Ur.findLastIndex=Ls,Ur.findLastKey=function(t,e){return De(t,os(e,3),yi)},Ur.floor=vc,Ur.forEach=mo,Ur.forEachRight=bo,Ur.forIn=function(t,e){return null==t?t:mi(t,os(e,3),Na)},Ur.forInRight=function(t,e){return null==t?t:bi(t,os(e,3),Na)},Ur.forOwn=function(t,e){return t&&vi(t,os(e,3))},Ur.forOwnRight=function(t,e){return t&&yi(t,os(e,3))},Ur.get=Ia,Ur.gt=zo,Ur.gte=jo,Ur.has=function(t,e){return null!=t&&ls(t,e,Ei)},Ur.hasIn=Ea,Ur.head=Ks,Ur.identity=ec,Ur.includes=function(t,e,r,i){t=Ho(t)?t:Ua(t),r=r&&!i?da(r):0;var n=t.length;return r<0&&(r=mr(n+r,0)),sa(t)?r<=n&&t.indexOf(e,r)>-1:!!n&&Be(t,e,r)>-1},Ur.indexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var n=null==r?0:da(r);return n<0&&(n=mr(i+n,0)),Be(t,e,n)},Ur.inRange=function(e,r,i){return r=fa(r),i===t?(i=r,r=0):i=fa(i),function(t,e,r){return t>=br(e,r)&&t<mr(e,r)}(e=pa(e),r,i)},Ur.invoke=xa,Ur.isArguments=Lo,Ur.isArray=Fo,Ur.isArrayBuffer=Ko,Ur.isArrayLike=Ho,Ur.isArrayLikeObject=$o,Ur.isBoolean=function(t){return!0===t||!1===t||Xo(t)&&Mi(t)==g},Ur.isBuffer=Vo,Ur.isDate=Jo,Ur.isElement=function(t){return Xo(t)&&1===t.nodeType&&!ra(t)},Ur.isEmpty=function(t){if(null==t)return!0;if(Ho(t)&&(Fo(t)||"string"==typeof t||"function"==typeof t.splice||Vo(t)||aa(t)||Lo(t)))return!t.length;var e=ds(t);if(e==w||e==E)return!t.size;if(As(t))return!qi(t).length;for(var r in t)if(Dt.call(t,r))return!1;return!0},Ur.isEqual=function(t,e){return Ni(t,e)},Ur.isEqualWith=function(e,r,i){var n=(i="function"==typeof i?i:t)?i(e,r):t;return n===t?Ni(e,r,t,i):!!n},Ur.isError=Qo,Ur.isFinite=function(t){return"number"==typeof t&&lr(t)},Ur.isFunction=Go,Ur.isInteger=Yo,Ur.isLength=Wo,Ur.isMap=ta,Ur.isMatch=function(t,e){return t===e||Oi(t,e,cs(e))},Ur.isMatchWith=function(e,r,i){return i="function"==typeof i?i:t,Oi(e,r,cs(r),i)},Ur.isNaN=function(t){return ea(t)&&t!=+t},Ur.isNative=function(t){if(ws(t))throw new Mt("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Ci(t)},Ur.isNil=function(t){return null==t},Ur.isNull=function(t){return null===t},Ur.isNumber=ea,Ur.isObject=Zo,Ur.isObjectLike=Xo,Ur.isPlainObject=ra,Ur.isRegExp=ia,Ur.isSafeInteger=function(t){return Yo(t)&&t>=-a&&t<=a},Ur.isSet=na,Ur.isString=sa,Ur.isSymbol=oa,Ur.isTypedArray=aa,Ur.isUndefined=function(e){return e===t},Ur.isWeakMap=function(t){return Xo(t)&&ds(t)==x},Ur.isWeakSet=function(t){return Xo(t)&&"[object WeakSet]"==Mi(t)},Ur.join=function(t,e){return null==t?"":pr.call(t,e)},Ur.kebabCase=Fa,Ur.last=Js,Ur.lastIndexOf=function(e,r,i){var n=null==e?0:e.length;if(!n)return-1;var s=n;return i!==t&&(s=(s=da(i))<0?mr(n+s,0):br(s,n-1)),r==r?function(t,e,r){for(var i=r+1;i--;)if(t[i]===e)return i;return i}(e,r,s):ke(e,ze,s,!0)},Ur.lowerCase=Ka,Ur.lowerFirst=Ha,Ur.lt=ca,Ur.lte=ha,Ur.max=function(e){return e&&e.length?li(e,ec,Ii):t},Ur.maxBy=function(e,r){return e&&e.length?li(e,os(r,2),Ii):t},Ur.mean=function(t){return je(t,ec)},Ur.meanBy=function(t,e){return je(t,os(e,2))},Ur.min=function(e){return e&&e.length?li(e,ec,Di):t},Ur.minBy=function(e,r){return e&&e.length?li(e,os(r,2),Di):t},Ur.stubArray=lc,Ur.stubFalse=pc,Ur.stubObject=function(){return{}},Ur.stubString=function(){return""},Ur.stubTrue=function(){return!0},Ur.multiply=yc,Ur.nth=function(e,r){return e&&e.length?ji(e,da(r)):t},Ur.noConflict=function(){return he._===this&&(he._=jt),this},Ur.noop=oc,Ur.now=Io,Ur.pad=function(t,e,r){t=ma(t);var i=(e=da(e))?or(t):0;if(!e||i>=e)return t;var n=(e-i)/2;return Fn(Fe(n),r)+t+Fn(qe(n),r)},Ur.padEnd=function(t,e,r){t=ma(t);var i=(e=da(e))?or(t):0;return e&&i<e?t+Fn(e-i,r):t},Ur.padStart=function(t,e,r){t=ma(t);var i=(e=da(e))?or(t):0;return e&&i<e?Fn(e-i,r)+t:t},Ur.parseInt=function(t,e,r){return r||null==e?e=0:e&&(e=+e),yr(ma(t).replace(et,""),e||0)},Ur.random=function(e,r,i){if(i&&"boolean"!=typeof i&&bs(e,r,i)&&(r=i=t),i===t&&("boolean"==typeof r?(i=r,r=t):"boolean"==typeof e&&(i=e,e=t)),e===t&&r===t?(e=0,r=1):(e=fa(e),r===t?(r=e,e=0):r=fa(r)),e>r){var n=e;e=r,r=n}if(i||e%1||r%1){var s=wr();return br(e+s*(r-e+se("1e-"+((s+"").length-1))),r)}return $i(e,r)},Ur.reduce=function(t,e,r){var i=Fo(t)?Oe:Ke,n=arguments.length<3;return i(t,os(e,4),r,n,ui)},Ur.reduceRight=function(t,e,r){var i=Fo(t)?Ce:Ke,n=arguments.length<3;return i(t,os(e,4),r,n,fi)},Ur.repeat=function(e,r,i){return r=(i?bs(e,r,i):r===t)?1:da(r),Vi(ma(e),r)},Ur.replace=function(){var t=arguments,e=ma(t[0]);return t.length<3?e:e.replace(t[1],t[2])},Ur.result=function(e,r,i){var n=-1,s=(r=bn(r,e)).length;for(s||(s=1,e=t);++n<s;){var o=null==e?t:e[qs(r[n])];o===t&&(n=s,o=i),e=Go(o)?o.call(e):o}return e},Ur.round=wc,Ur.runInContext=rt,Ur.sample=function(t){return(Fo(t)?Gr:Qi)(t)},Ur.size=function(t){if(null==t)return 0;if(Ho(t))return sa(t)?or(t):t.length;var e=ds(t);return e==w||e==E?t.size:qi(t).length},Ur.snakeCase=$a,Ur.some=function(e,r,i){var n=Fo(e)?Te:en;return i&&bs(e,r,i)&&(r=t),n(e,os(r,3))},Ur.sortedIndex=function(t,e){return rn(t,e)},Ur.sortedIndexBy=function(t,e,r){return nn(t,e,os(r,2))},Ur.sortedIndexOf=function(t,e){var r=null==t?0:t.length;if(r){var i=rn(t,e);if(i<r&&Uo(t[i],e))return i}return-1},Ur.sortedLastIndex=function(t,e){return rn(t,e,!0)},Ur.sortedLastIndexBy=function(t,e,r){return nn(t,e,os(r,2),!0)},Ur.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var r=rn(t,e,!0)-1;if(Uo(t[r],e))return r}return-1},Ur.startCase=Va,Ur.startsWith=function(t,e,r){return t=ma(t),r=null==r?0:si(da(r),0,t.length),e=an(e),t.slice(r,r+e.length)==e},Ur.subtract=Ac,Ur.sum=function(t){return t&&t.length?He(t,ec):0},Ur.sumBy=function(t,e){return t&&t.length?He(t,os(e,2)):0},Ur.template=function(e,r,i){var n=Ur.templateSettings;i&&bs(e,r,i)&&(r=t),e=ma(e),r=ya({},r,n,Yn);var s,o,a=ya({},r.imports,n.imports,Yn),c=Ra(a),h=Qe(a,c),u=0,f=r.interpolate||bt,d="__p += '",l=Pt((r.escape||bt).source+"|"+f.source+"|"+(f===G?ht:bt).source+"|"+(r.evaluate||bt).source+"|$","g"),p="//# sourceURL="+(Dt.call(r,"sourceURL")?(r.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ee+"]")+"\n";e.replace(l,(function(t,r,i,n,a,c){return i||(i=n),d+=e.slice(u,c).replace(vt,tr),r&&(s=!0,d+="' +\n__e("+r+") +\n'"),a&&(o=!0,d+="';\n"+a+";\n__p += '"),i&&(d+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),d+="';\n";var g=Dt.call(r,"variable")&&r.variable;if(g){if(at.test(g))throw new Mt("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(o?d.replace(j,""):d).replace(L,"$1").replace(F,"$1;"),d="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var m=Ya((function(){return It(c,p+"return "+d).apply(t,h)}));if(m.source=d,Qo(m))throw m;return m},Ur.times=function(t,e){if((t=da(t))<1||t>a)return[];var r=h,i=br(t,h);e=os(e),t-=h;for(var n=$e(i,e);++r<t;)e(r);return n},Ur.toFinite=fa,Ur.toInteger=da,Ur.toLength=la,Ur.toLower=function(t){return ma(t).toLowerCase()},Ur.toNumber=pa,Ur.toSafeInteger=function(t){return t?si(da(t),-a,a):0===t?t:0},Ur.toString=ma,Ur.toUpper=function(t){return ma(t).toUpperCase()},Ur.trim=function(e,r,i){if((e=ma(e))&&(i||r===t))return Ve(e);if(!e||!(r=an(r)))return e;var n=ar(e),s=ar(r);return yn(n,Ye(n,s),We(n,s)+1).join("")},Ur.trimEnd=function(e,r,i){if((e=ma(e))&&(i||r===t))return e.slice(0,cr(e)+1);if(!e||!(r=an(r)))return e;var n=ar(e);return yn(n,0,We(n,ar(r))+1).join("")},Ur.trimStart=function(e,r,i){if((e=ma(e))&&(i||r===t))return e.replace(et,"");if(!e||!(r=an(r)))return e;var n=ar(e);return yn(n,Ye(n,ar(r))).join("")},Ur.truncate=function(e,r){var i=30,n="...";if(Zo(r)){var s="separator"in r?r.separator:s;i="length"in r?da(r.length):i,n="omission"in r?an(r.omission):n}var o=(e=ma(e)).length;if(er(e)){var a=ar(e);o=a.length}if(i>=o)return e;var c=i-or(n);if(c<1)return n;var h=a?yn(a,0,c).join(""):e.slice(0,c);if(s===t)return h+n;if(a&&(c+=h.length-c),ia(s)){if(e.slice(c).search(s)){var u,f=h;for(s.global||(s=Pt(s.source,ma(ut.exec(s))+"g")),s.lastIndex=0;u=s.exec(f);)var d=u.index;h=h.slice(0,d===t?c:d)}}else if(e.indexOf(an(s),c)!=c){var l=h.lastIndexOf(s);l>-1&&(h=h.slice(0,l))}return h+n},Ur.unescape=function(t){return(t=ma(t))&&$.test(t)?t.replace(K,hr):t},Ur.uniqueId=function(t){var e=++kt;return ma(t)+e},Ur.upperCase=Ja,Ur.upperFirst=Qa,Ur.each=mo,Ur.eachRight=bo,Ur.first=Ks,sc(Ur,function(){var t={};return vi(Ur,(function(e,r){Dt.call(Ur.prototype,r)||(t[r]=e)})),t}(),{chain:!1}),Ur.VERSION="4.17.21",Me(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Ur[t].placeholder=Ur})),Me(["drop","take"],(function(e,r){Fr.prototype[e]=function(i){i=i===t?1:mr(da(i),0);var n=this.__filtered__&&!r?new Fr(this):this.clone();return n.__filtered__?n.__takeCount__=br(i,n.__takeCount__):n.__views__.push({size:br(i,h),type:e+(n.__dir__<0?"Right":"")}),n},Fr.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Me(["filter","map","takeWhile"],(function(t,e){var r=e+1,i=1==r||3==r;Fr.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:os(t,3),type:r}),e.__filtered__=e.__filtered__||i,e}})),Me(["head","last"],(function(t,e){var r="take"+(e?"Right":"");Fr.prototype[t]=function(){return this[r](1).value()[0]}})),Me(["initial","tail"],(function(t,e){var r="drop"+(e?"":"Right");Fr.prototype[t]=function(){return this.__filtered__?new Fr(this):this[r](1)}})),Fr.prototype.compact=function(){return this.filter(ec)},Fr.prototype.find=function(t){return this.filter(t).head()},Fr.prototype.findLast=function(t){return this.reverse().find(t)},Fr.prototype.invokeMap=Ji((function(t,e){return"function"==typeof t?new Fr(this):this.map((function(r){return xi(r,t,e)}))})),Fr.prototype.reject=function(t){return this.filter(To(os(t)))},Fr.prototype.slice=function(e,r){e=da(e);var i=this;return i.__filtered__&&(e>0||r<0)?new Fr(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),r!==t&&(i=(r=da(r))<0?i.dropRight(-r):i.take(r-e)),i)},Fr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Fr.prototype.toArray=function(){return this.take(h)},vi(Fr.prototype,(function(e,r){var i=/^(?:filter|find|map|reject)|While$/.test(r),n=/^(?:head|last)$/.test(r),s=Ur[n?"take"+("last"==r?"Right":""):r],o=n||/^find/.test(r);s&&(Ur.prototype[r]=function(){var r=this.__wrapped__,a=n?[1]:arguments,c=r instanceof Fr,h=a[0],u=c||Fo(r),f=function(t){var e=s.apply(Ur,Ne([t],a));return n&&d?e[0]:e};u&&i&&"function"==typeof h&&1!=h.length&&(c=u=!1);var d=this.__chain__,l=!!this.__actions__.length,p=o&&!d,g=c&&!l;if(!o&&u){r=g?r:new Fr(this);var m=e.apply(r,a);return m.__actions__.push({func:uo,args:[f],thisArg:t}),new Lr(m,d)}return p&&g?e.apply(this,a):(m=this.thru(f),p?n?m.value()[0]:m.value():m)})})),Me(["pop","push","shift","sort","splice","unshift"],(function(t){var e=Nt[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:pop|shift)$/.test(t);Ur.prototype[t]=function(){var t=arguments;if(i&&!this.__chain__){var n=this.value();return e.apply(Fo(n)?n:[],t)}return this[r]((function(r){return e.apply(Fo(r)?r:[],t)}))}})),vi(Fr.prototype,(function(t,e){var r=Ur[e];if(r){var i=r.name+"";Dt.call(Rr,i)||(Rr[i]=[]),Rr[i].push({name:e,func:r})}})),Rr[Un(t,2).name]=[{name:"wrapper",func:t}],Fr.prototype.clone=function(){var t=new Fr(this.__wrapped__);return t.__actions__=Pn(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Pn(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Pn(this.__views__),t},Fr.prototype.reverse=function(){if(this.__filtered__){var t=new Fr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Fr.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Fo(t),i=e<0,n=r?t.length:0,s=function(t,e,r){for(var i=-1,n=r.length;++i<n;){var s=r[i],o=s.size;switch(s.type){case"drop":t+=o;break;case"dropRight":e-=o;break;case"take":e=br(e,t+o);break;case"takeRight":t=mr(t,e-o)}}return{start:t,end:e}}(0,n,this.__views__),o=s.start,a=s.end,c=a-o,h=i?a:o-1,u=this.__iteratees__,f=u.length,d=0,l=br(c,this.__takeCount__);if(!r||!i&&n==c&&l==c)return dn(t,this.__actions__);var p=[];t:for(;c--&&d<l;){for(var g=-1,m=t[h+=e];++g<f;){var b=u[g],v=b.iteratee,y=b.type,w=v(m);if(2==y)m=w;else if(!w){if(1==y)continue t;break t}}p[d++]=m}return p},Ur.prototype.at=fo,Ur.prototype.chain=function(){return ho(this)},Ur.prototype.commit=function(){return new Lr(this.value(),this.__chain__)},Ur.prototype.next=function(){this.__values__===t&&(this.__values__=ua(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?t:this.__values__[this.__index__++]}},Ur.prototype.plant=function(e){for(var r,i=this;i instanceof jr;){var n=ks(i);n.__index__=0,n.__values__=t,r?s.__wrapped__=n:r=n;var s=n;i=i.__wrapped__}return s.__wrapped__=e,r},Ur.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Fr){var r=e;return this.__actions__.length&&(r=new Fr(this)),(r=r.reverse()).__actions__.push({func:uo,args:[Ws],thisArg:t}),new Lr(r,this.__chain__)}return this.thru(Ws)},Ur.prototype.toJSON=Ur.prototype.valueOf=Ur.prototype.value=function(){return dn(this.__wrapped__,this.__actions__)},Ur.prototype.first=Ur.prototype.head,ae&&(Ur.prototype[ae]=function(){return this}),Ur}();fe?((fe.exports=ur)._=ur,ue._=ur):he._=ur}.call(au);var hu=Object.defineProperty,uu=Object.defineProperties,fu=Object.getOwnPropertyDescriptors,du=Object.getOwnPropertySymbols,lu=Object.prototype.hasOwnProperty,pu=Object.prototype.propertyIsEnumerable,gu=(t,e,r)=>e in t?hu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mu=(t,e)=>{for(var r in e||(e={}))lu.call(e,r)&&gu(t,r,e[r]);if(du)for(var r of du(e))pu.call(e,r)&&gu(t,r,e[r]);return t},bu=(t,e)=>uu(t,fu(e));function vu(t,e,r){var i;const n=A(t);return(null==(i=e.rpcMap)?void 0:i[n.reference])||`${eu}?chainId=${n.namespace}:${n.reference}&projectId=${r}`}function yu(t){return t.includes(":")?t.split(":")[1]:t}function wu(t){return t.map((t=>`${t.split(":")[0]}:${t.split(":")[1]}`))}function Au(t={},e={}){const r=_u(t),i=_u(e);return cu.exports.merge(r,i)}function _u(t){var e,r,i,n;const s={};if(!ws(t))return s;for(const[o,a]of Object.entries(t)){const t=ds(o)?[o]:a.chains,c=a.methods||[],h=a.events||[],u=a.rpcMap||{},f=ls(o);s[f]=bu(mu(mu({},s[f]),a),{chains:G(t,null==(e=s[f])?void 0:e.chains),methods:G(c,null==(r=s[f])?void 0:r.methods),events:G(h,null==(i=s[f])?void 0:i.events),rpcMap:mu(mu({},u),null==(n=s[f])?void 0:n.rpcMap)})}return s}function Mu(t){return t.includes(":")?t.split(":")[2]:t}function Iu(t){const e={};for(const[r,i]of Object.entries(t)){const t=i.methods||[],n=i.events||[],s=i.accounts||[],o=ds(r)?[r]:i.chains?i.chains:wu(i.accounts);e[r]={chains:o,methods:t,events:n,accounts:s}}return e}function Eu(t){return"number"==typeof t?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const Su={},Pu=t=>Su[t],xu=(t,e)=>{Su[t]=e};class Ru{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(nu,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t&&t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2]))||[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const i=yu(e);t[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}}var Nu=Object.defineProperty,Ou=Object.defineProperties,Cu=Object.getOwnPropertyDescriptors,Tu=Object.getOwnPropertySymbols,qu=Object.prototype.hasOwnProperty,Du=Object.prototype.propertyIsEnumerable,ku=(t,e,r)=>e in t?Nu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bu=(t,e)=>{for(var r in e||(e={}))qu.call(e,r)&&ku(t,r,e[r]);if(Tu)for(var r of Tu(e))Du.call(e,r)&&ku(t,r,e[r]);return t},Uu=(t,e)=>Ou(t,Cu(e));class zu{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(t);case"wallet_getCallsStatus":return await this.getCallStatus(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(nu,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const r=e||vu(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const i=parseInt(yu(e));t[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,r;let i=t.request.params?null==(e=t.request.params[0])?void 0:e.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const n=parseInt(i,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:i}]},chainId:null==(r=this.namespace.chains)?void 0:r[0]}),this.setDefaultChain(`${n}`)}return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,r,i;const n=null==(r=null==(e=t.request)?void 0:e.params)?void 0:r[0];if(!n)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const s=this.client.session.get(t.topic),o=(null==(i=s?.sessionProperties)?void 0:i.capabilities)||{};if(null!=o&&o[n])return o?.[n];const a=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:Uu(Bu({},s.sessionProperties||{}),{capabilities:Uu(Bu({},o||{}),{[n]:a})})})}catch(t){console.warn("Failed to update session with capabilities",t)}return a}async getCallStatus(t){var e,r;const i=this.client.session.get(t.topic),n=null==(e=i.sessionProperties)?void 0:e.bundler_name;if(n){const e=this.getBundlerUrl(t.chainId,n);try{return await this.getUserOperationReceipt(e,t)}catch(t){console.warn("Failed to fetch call status from bundler",t,e)}}const s=null==(r=i.sessionProperties)?void 0:r.bundler_url;if(s)try{return await this.getUserOperationReceipt(s,t)}catch(t){console.warn("Failed to fetch call status from custom bundler",t,s)}if(this.namespace.methods.includes(t.request.method))return await this.client.request(t);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(t,e){var r;const i=new URL(t),n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,eo.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(r=e.request.params)?void 0:r[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(t,e){return`${iu}?projectId=${this.client.core.projectId}&chainId=${t}&bundler=${e}`}}class ju{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(nu,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const i=yu(e);t[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}}class Lu{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(nu,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const i=yu(e);t[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}}class Fu{constructor(t){this.name="algorand",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const r=e||vu(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,r)}this.chainId=t,this.events.emit(nu,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;t[e]=this.createHttpProvider(e,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new to.F(new Zh(r,Pu("disableProviderPing")))}}class Ku{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(nu,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{const r=this.getCardanoRPCUrl(e),i=yu(e);t[i]=this.createHttpProvider(i,r)})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||this.getCardanoRPCUrl(t);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}}class Hu{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(nu,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const i=yu(e);t[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}}class $u{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(nu,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const i=yu(e);t[i]=this.createHttpProvider(i,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}}class Vu{constructor(t){this.name="near",this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const r=e||vu(`${this.name}:${t}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,r)}this.events.emit(nu,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t&&t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2]))||[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;t[e]=this.createHttpProvider(e,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace);return typeof r>"u"?void 0:new to.F(new Zh(r,Pu("disableProviderPing")))}}class Ju{constructor(t){this.name=ru,this.namespace=t.namespace,this.events=Pu("events"),this.client=Pu("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(t.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(t.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(t.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(t.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider(t.chainId).request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(nu,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){var t,e;const r={};return null==(e=null==(t=this.namespace)?void 0:t.accounts)||e.forEach((t=>{const e=A(t);r[`${e.namespace}:${e.reference}`]=this.createHttpProvider(t)})),r}getHttpProvider(t){const e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||vu(t,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${t}`);return new to.F(new Zh(r,Pu("disableProviderPing")))}}var Qu=Object.defineProperty,Gu=Object.defineProperties,Yu=Object.getOwnPropertyDescriptors,Wu=Object.getOwnPropertySymbols,Zu=Object.prototype.hasOwnProperty,Xu=Object.prototype.propertyIsEnumerable,tf=(t,e,r)=>e in t?Qu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ef=(t,e)=>{for(var r in e||(e={}))Zu.call(e,r)&&tf(t,r,e[r]);if(Wu)for(var r of Wu(e))Xu.call(e,r)&&tf(t,r,e[r]);return t},rf=(t,e)=>Gu(t,Yu(e));class nf{constructor(t){this.events=new(n()),this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:(0,Us.h6)((0,Us.iP)({level:t?.logger||Xh})),this.disableProviderPing=t?.disableProviderPing||!1}static async init(t){const e=new nf(t);return await e.initialize(),e}async request(t,e,r){const[i,n]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:ef({},t),chainId:`${i}:${n}`,topic:this.session.topic,expiry:r})}sendAsync(t,e,r,i){const n=(new Date).getTime();this.request(t,r,i).then((t=>e(null,(0,eo.formatJsonRpcResult)(n,t)))).catch((t=>e(t,void 0)))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(t=this.session)?void 0:t.topic,reason:vs("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t,e){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:r,response:i}=await this.client.authenticate(t,e);r&&(this.uri=r,this.events.emit("display_uri",r));const n=await i();if(this.session=n.session,this.session){const t=Iu(this.session.namespaces);this.namespaces=Au(this.namespaces,t),this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:r,approval:i}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});r&&(this.uri=r,this.events.emit("display_uri",r)),await i().then((t=>{this.session=t;const e=Iu(t.namespaces);this.namespaces=Au(this.namespaces,e),this.persist("namespaces",this.namespaces)})).catch((t=>{if(t.message!==lh)throw t;e++}))}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[r,i]=this.validateChain(t),n=this.getProvider(r);n.name===ru?n.setDefaultChain(`${r}:${i}`,e):n.setDefaultChain(i,e)}catch(t){if(!/Please call connect/.test(t.message))throw t}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(ys(e)){for(const r of e)t.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await zh.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Xh,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map((t=>ls(t))))];xu("client",this.client),xu("events",this.events),xu("disableProviderPing",this.disableProviderPing),t.forEach((t=>{if(!this.session)return;const e=function(t,e){const r=Object.keys(e.namespaces).filter((e=>e.includes(t)));if(!r.length)return[];const i=[];return r.forEach((t=>{const r=e.namespaces[t].accounts;i.push(...r)})),i}(t,this.session),r=wu(e),i=Au(this.namespaces,this.optionalNamespaces),n=rf(ef({},i[t]),{accounts:e,chains:r});switch(t){case"eip155":this.rpcProviders[t]=new zu({namespace:n});break;case"algorand":this.rpcProviders[t]=new Fu({namespace:n});break;case"solana":this.rpcProviders[t]=new ju({namespace:n});break;case"cosmos":this.rpcProviders[t]=new Lu({namespace:n});break;case"polkadot":this.rpcProviders[t]=new Ru({namespace:n});break;case"cip34":this.rpcProviders[t]=new Ku({namespace:n});break;case"elrond":this.rpcProviders[t]=new Hu({namespace:n});break;case"multiversx":this.rpcProviders[t]=new $u({namespace:n});break;case"near":this.rpcProviders[t]=new Vu({namespace:n});break;default:this.rpcProviders[ru]?this.rpcProviders[ru].updateNamespace(n):this.rpcProviders[ru]=new Ju({namespace:n})}}))}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",(t=>{this.events.emit("session_ping",t)})),this.client.on("session_event",(t=>{const{params:e}=t,{event:r}=e;if("accountsChanged"===r.name){const t=r.data;t&&ys(t)&&this.events.emit("accountsChanged",t.map(Mu))}else if("chainChanged"===r.name){const t=e.chainId,r=e.event.data,i=ls(t),n=Eu(t)!==Eu(r)?`${i}:${Eu(r)}`:t;this.onChainChanged(n)}else this.events.emit(r.name,r.data);this.events.emit("session_event",t)})),this.client.on("session_update",(({topic:t,params:e})=>{var r;const{namespaces:i}=e,n=null==(r=this.client)?void 0:r.session.get(t);this.session=rf(ef({},n),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})})),this.client.on("session_delete",(async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",rf(ef({},vs("USER_DISCONNECTED")),{data:t.topic}))})),this.on(nu,(t=>{this.onChainChanged(t,!0)}))}getProvider(t){return this.rpcProviders[t]||this.rpcProviders[ru]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach((t=>{var e;this.getProvider(t).updateNamespace(null==(e=this.session)?void 0:e.namespaces[t])}))}setNamespaces(t){const{namespaces:e,optionalNamespaces:r,sessionProperties:i}=t;e&&Object.keys(e).length&&(this.namespaces=e),r&&Object.keys(r).length&&(this.optionalNamespaces=r),this.sessionProperties=i,this.persist("namespaces",e),this.persist("optionalNamespaces",r)}validateChain(t){const[e,r]=t?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,r];if(e&&!Object.keys(this.namespaces||{}).map((t=>ls(t))).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&r)return[e,r];const i=ls(Object.keys(this.namespaces)[0]);return[i,this.rpcProviders[i].getDefaultChain()]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[r,i]=this.validateChain(t);i&&(e||this.getProvider(r).setDefaultChain(i),this.namespaces[r]?this.namespaces[r].defaultChain=i:this.namespaces[`${r}:${i}`]?this.namespaces[`${r}:${i}`].defaultChain=i:this.namespaces[`${r}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,e){this.client.core.storage.setItem(`${tu}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${tu}/${t}`)}}const sf=nf,of=["eth_sendTransaction","personal_sign"],af=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],cf=["chainChanged","accountsChanged"],hf=["chainChanged","accountsChanged","message","disconnect","connect"];var uf=Object.defineProperty,ff=Object.defineProperties,df=Object.getOwnPropertyDescriptors,lf=Object.getOwnPropertySymbols,pf=Object.prototype.hasOwnProperty,gf=Object.prototype.propertyIsEnumerable,mf=(t,e,r)=>e in t?uf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bf=(t,e)=>{for(var r in e||(e={}))pf.call(e,r)&&mf(t,r,e[r]);if(lf)for(var r of lf(e))gf.call(e,r)&&mf(t,r,e[r]);return t},vf=(t,e)=>ff(t,df(e));function yf(t){return Number(t[0].split(":")[1])}function wf(t){return`0x${t.toString(16)}`}class Af{constructor(){this.events=new i.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY="wc@2:ethereum_provider:",this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new Af;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,r){this.signer.sendAsync(t,e,this.formatChainId(this.chainId),r)}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:e,optional:r}=function(t){const{chains:e,optionalChains:r,methods:i,optionalMethods:n,events:s,optionalEvents:o,rpcMap:a}=t;if(!ys(e))throw new Error("Invalid chains");const c={chains:e,methods:i||of,events:s||cf,rpcMap:bf({},e.length?{[yf(e)]:a[yf(e)]}:{})},h=s?.filter((t=>!cf.includes(t))),u=i?.filter((t=>!of.includes(t)));if(!(r||o||n||null!=h&&h.length||null!=u&&u.length))return{required:e.length?c:void 0};const f={chains:[...new Set(h?.length&&u?.length||!r?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(null!=n&&n.length?n:af))],events:[...new Set(c.events.concat(null!=o&&o.length?o:hf))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?f:void 0}}(this.rpc);try{const i=await new Promise((async(i,n)=>{var s;this.rpc.showQrModal&&(null==(s=this.modal)||s.subscribeModal((t=>{!t.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),n(new Error("Connection request reset. Please try again.")))}))),await this.signer.connect(vf(bf({namespaces:bf({},e&&{[this.namespace]:e})},r&&{optionalNamespaces:{[this.namespace]:r}}),{pairingTopic:t?.pairingTopic})).then((t=>{i(t)})).catch((t=>{n(new Error(t.message))}))}));if(!i)return;const n=_(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:n),this.setAccounts(n),this.events.emit("connect",{chainId:wf(this.chainId)})}catch(t){throw this.signer.logger.error(t),t}finally{this.modal&&this.modal.closeModal()}}async authenticate(t,e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t?.chains});try{const r=await new Promise((async(r,i)=>{var n;this.rpc.showQrModal&&(null==(n=this.modal)||n.subscribeModal((t=>{!t.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),i(new Error("Connection request reset. Please try again.")))}))),await this.signer.authenticate(vf(bf({},t),{chains:this.rpc.chains}),e).then((t=>{r(t)})).catch((t=>{i(new Error(t.message))}))})),i=r.session;if(i){const t=_(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:t),this.setAccounts(t),this.events.emit("connect",{chainId:wf(this.chainId)})}return r}catch(t){throw this.signer.logger.error(t),t}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",(t=>{const{params:e}=t,{event:r}=e;"accountsChanged"===r.name?(this.accounts=this.parseAccounts(r.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===r.name?this.setChainId(this.formatChainId(r.data)):this.events.emit(r.name,r.data),this.events.emit("session_event",t)})),this.signer.on("chainChanged",(t=>{const e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",wf(this.chainId)),this.persist()})),this.signer.on("session_update",(t=>{this.events.emit("session_update",t)})),this.signer.on("session_delete",(t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",vf(bf({},vs("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))})),this.signer.on("display_uri",(t=>{var e,r;this.rpc.showQrModal&&(null==(e=this.modal)||e.closeModal(),null==(r=this.modal)||r.openModal({uri:t})),this.events.emit("display_uri",t)}))}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return"string"==typeof t&&t.startsWith(`${this.namespace}:`)}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const e=t.filter((t=>this.isCompatibleChainId(t))).map((t=>this.parseChainId(t)));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",wf(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,r,i]=t.split(":");return{chainId:`${e}:${r}`,address:i}}setAccounts(t){this.accounts=t.filter((t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId)).map((t=>this.parseAccountId(t).address)),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,r;const i=null!=(e=t?.chains)?e:[],n=null!=(r=t?.optionalChains)?r:[],s=i.concat(n);if(!s.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const o=i.length?t?.methods||of:[],a=i.length?t?.events||cf:[],c=t?.optionalMethods||[],h=t?.optionalEvents||[],u=t?.rpcMap||this.buildRpcMap(s,t.projectId),f=t?.qrModalOptions||void 0;return{chains:i?.map((t=>this.formatChainId(t))),optionalChains:n.map((t=>this.formatChainId(t))),methods:o,events:a,optionalMethods:c,optionalEvents:h,rpcMap:u,showQrModal:!(null==t||!t.showQrModal),qrModalOptions:f,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const r={};return t.forEach((t=>{r[t]=this.getRpcUrl(t,e)})),r}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?yf(this.rpc.chains):yf(this.rpc.optionalChains),this.signer=await sf.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions,customStoragePrefix:t.customStoragePrefix,telemetryEnabled:t.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let t;try{const{WalletConnectModal:e}=await Promise.resolve().then(r.bind(r,85577));t=e}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(bf({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(t){throw this.signer.logger.error(t),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:e,optionalChains:r,rpcMap:i}=t;e&&ys(e)&&(this.rpc.chains=e.map((t=>this.formatChainId(t))),e.forEach((t=>{this.rpc.rpcMap[t]=i?.[t]||this.getRpcUrl(t)}))),r&&ys(r)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=r?.map((t=>this.formatChainId(t))),r.forEach((t=>{this.rpc.rpcMap[t]=i?.[t]||this.getRpcUrl(t)})))}getRpcUrl(t,e){var r;return(null==(r=this.rpc.rpcMap)?void 0:r[t])||`https://rpc.walletconnect.org/v1/?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e?.accounts),this.setAccounts(e?.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch((t=>this.signer.logger.warn(t)))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return"string"==typeof t||t instanceof String?[this.parseAccount(t)]:t.map((t=>this.parseAccount(t)))}}const _f=Af},90735:function(t,e){var r="undefined"!=typeof self?self:this,i=function(){function t(){this.fetch=!1,this.DOMException=r.DOMException}return t.prototype=r,new t}();!function(t){!function(e){var r="URLSearchParams"in t,i="Symbol"in t&&"iterator"in Symbol,n="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),s="FormData"in t,o="ArrayBuffer"in t;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=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 u(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return i&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?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 l(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 g(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function m(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:n&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o&&n&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=m(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(t)||c(t))?this._bodyArrayBuffer=m(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"))},n&&(this.blob=function(){var t=l(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?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var t,e,r,i=l(this);if(i)return i;if(this._bodyBlob)return t=this._bodyBlob,r=p(e=new FileReader),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,e){t=h(t),e=u(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},d.prototype.delete=function(t){delete this.map[h(t)]},d.prototype.get=function(t){return t=h(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(h(t))},d.prototype.set=function(t,e){this.map[h(t)]=u(e)},d.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},i&&(d.prototype[Symbol.iterator]=d.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var r,i,n=(e=e||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=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 d(e.headers)),this.method=(i=(r=e.method||this.method||"GET").toUpperCase(),v.indexOf(i)>-1?i:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function w(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}})),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 d(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},b.call(y.prototype),b.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(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(i,s){var o=new y(t,r);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();e.append(i,n)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new A(n,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new e.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&n&&(a.responseType="blob"),o.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}M.polyfill=!0,t.fetch||(t.fetch=M,t.Headers=d,t.Request=y,t.Response=A),e.Headers=d,e.Request=y,e.Response=A,e.fetch=M,Object.defineProperty(e,"__esModule",{value:!0})}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=i;(e=n.fetch).default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e},79188:function(t,e,r){!function(t,e){function i(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 s(t,e,r){if(s.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=s:e.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(3205).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function c(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,r):(this._parseBase(t,e,n),"le"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){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):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(i("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 n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if("be"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,s=0,o=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=c(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=c(t,e,i)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,o=s%i,a=Math.min(s,s-o)+r,c=0,u=r;u<a;u+=i)c=h(t,u,u+i,e),this.imuln(n),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==o){var f=1;for(c=h(t,u,t.length,e),u=0;u<o;u++)f*=e;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},s.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},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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];function l(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var h=1;h<i;h++){for(var u=c>>>26,f=67108863&c,d=Math.min(h,e.length-1),l=Math.max(0,h-t.length+1);l<=d;l++){var p=h-l|0;u+=(o=(n=0|t.words[p])*(s=0|e.words[l])+f)/67108864|0,f=67108863&o}r.words[h]=0|f,c=0|u}return 0!==c?r.words[h]=0|c:r.length--,r.strip()}s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],c=(16777215&(a<<n|s)).toString(16);r=0!=(s=a>>>24-n&16777215)||o!==this.length-1?u[6-c.length]+c+r:c+r,(n+=2)>=26&&(n-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var h=f[t],l=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(l).toString(t);r=(p=p.idivn(l)).isZero()?g+r:u[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.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&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return i(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===e,h=new t(s),u=this.clone();if(c){for(a=0;!u.isZero();a++)o=u.andln(255),u.iushrn(8),h[a]=o;for(;a<s;a++)h[a]=0}else{for(a=0;a<s-n;a++)h[a]=0;for(a=0;!u.isZero();a++)o=u.andln(255),u.iushrn(8),h[s-a-1]=o}return h},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.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},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.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},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.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()},s.prototype.ior=function(t){return i(!(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.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()},s.prototype.iand=function(t){return i(!(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},s.prototype.ixor=function(t){return i(!(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},s.prototype.iadd=function(t){var e,r,i;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,i=t):(r=t,i=this);for(var n=0,s=0;s<i.length;s++)e=(0|r.words[s])+(0|i.words[s])+n,this.words[s]=67108863&e,n=e>>>26;for(;0!==n&&s<r.length;s++)e=(0|r.words[s])+n,this.words[s]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.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)},s.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,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|r.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,s,o=t.words,a=e.words,c=r.words,h=0,u=0|o[0],f=8191&u,d=u>>>13,l=0|o[1],p=8191&l,g=l>>>13,m=0|o[2],b=8191&m,v=m>>>13,y=0|o[3],w=8191&y,A=y>>>13,_=0|o[4],M=8191&_,I=_>>>13,E=0|o[5],S=8191&E,P=E>>>13,x=0|o[6],R=8191&x,N=x>>>13,O=0|o[7],C=8191&O,T=O>>>13,q=0|o[8],D=8191&q,k=q>>>13,B=0|o[9],U=8191&B,z=B>>>13,j=0|a[0],L=8191&j,F=j>>>13,K=0|a[1],H=8191&K,$=K>>>13,V=0|a[2],J=8191&V,Q=V>>>13,G=0|a[3],Y=8191&G,W=G>>>13,Z=0|a[4],X=8191&Z,tt=Z>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ct=8191&at,ht=at>>>13,ut=0|a[8],ft=8191&ut,dt=ut>>>13,lt=0|a[9],pt=8191<,gt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(h+(i=Math.imul(f,L))|0)+((8191&(n=(n=Math.imul(f,F))+Math.imul(d,L)|0))<<13)|0;h=((s=Math.imul(d,F))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(p,L),n=(n=Math.imul(p,F))+Math.imul(g,L)|0,s=Math.imul(g,F);var bt=(h+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,$)|0)+Math.imul(d,H)|0))<<13)|0;h=((s=s+Math.imul(d,$)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(b,L),n=(n=Math.imul(b,F))+Math.imul(v,L)|0,s=Math.imul(v,F),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(g,H)|0,s=s+Math.imul(g,$)|0;var vt=(h+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(d,J)|0))<<13)|0;h=((s=s+Math.imul(d,Q)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,L),n=(n=Math.imul(w,F))+Math.imul(A,L)|0,s=Math.imul(A,F),i=i+Math.imul(b,H)|0,n=(n=n+Math.imul(b,$)|0)+Math.imul(v,H)|0,s=s+Math.imul(v,$)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(g,J)|0,s=s+Math.imul(g,Q)|0;var yt=(h+(i=i+Math.imul(f,Y)|0)|0)+((8191&(n=(n=n+Math.imul(f,W)|0)+Math.imul(d,Y)|0))<<13)|0;h=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(M,L),n=(n=Math.imul(M,F))+Math.imul(I,L)|0,s=Math.imul(I,F),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,$)|0)+Math.imul(A,H)|0,s=s+Math.imul(A,$)|0,i=i+Math.imul(b,J)|0,n=(n=n+Math.imul(b,Q)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,Q)|0,i=i+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,Y)|0,s=s+Math.imul(g,W)|0;var wt=(h+(i=i+Math.imul(f,X)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(d,X)|0))<<13)|0;h=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(S,L),n=(n=Math.imul(S,F))+Math.imul(P,L)|0,s=Math.imul(P,F),i=i+Math.imul(M,H)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(I,H)|0,s=s+Math.imul(I,$)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(A,J)|0,s=s+Math.imul(A,Q)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,W)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,X)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,X)|0,s=s+Math.imul(g,tt)|0;var At=(h+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(d,rt)|0))<<13)|0;h=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(R,L),n=(n=Math.imul(R,F))+Math.imul(N,L)|0,s=Math.imul(N,F),i=i+Math.imul(S,H)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(P,H)|0,s=s+Math.imul(P,$)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,Q)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,Q)|0,i=i+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,W)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,W)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(v,X)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(g,rt)|0,s=s+Math.imul(g,it)|0;var _t=(h+(i=i+Math.imul(f,st)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(d,st)|0))<<13)|0;h=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(C,L),n=(n=Math.imul(C,F))+Math.imul(T,L)|0,s=Math.imul(T,F),i=i+Math.imul(R,H)|0,n=(n=n+Math.imul(R,$)|0)+Math.imul(N,H)|0,s=s+Math.imul(N,$)|0,i=i+Math.imul(S,J)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,Q)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(w,X)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(A,X)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(g,st)|0,s=s+Math.imul(g,ot)|0;var Mt=(h+(i=i+Math.imul(f,ct)|0)|0)+((8191&(n=(n=n+Math.imul(f,ht)|0)+Math.imul(d,ct)|0))<<13)|0;h=((s=s+Math.imul(d,ht)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(D,L),n=(n=Math.imul(D,F))+Math.imul(k,L)|0,s=Math.imul(k,F),i=i+Math.imul(C,H)|0,n=(n=n+Math.imul(C,$)|0)+Math.imul(T,H)|0,s=s+Math.imul(T,$)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,Q)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,W)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(M,X)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(A,rt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(b,st)|0,n=(n=n+Math.imul(b,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,i=i+Math.imul(p,ct)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(g,ct)|0,s=s+Math.imul(g,ht)|0;var It=(h+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,dt)|0)+Math.imul(d,ft)|0))<<13)|0;h=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(U,L),n=(n=Math.imul(U,F))+Math.imul(z,L)|0,s=Math.imul(z,F),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,$)|0)+Math.imul(k,H)|0,s=s+Math.imul(k,$)|0,i=i+Math.imul(C,J)|0,n=(n=n+Math.imul(C,Q)|0)+Math.imul(T,J)|0,s=s+Math.imul(T,Q)|0,i=i+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(S,X)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(P,X)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ht)|0)+Math.imul(v,ct)|0,s=s+Math.imul(v,ht)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(g,ft)|0,s=s+Math.imul(g,dt)|0;var Et=(h+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,gt)|0)+Math.imul(d,pt)|0))<<13)|0;h=((s=s+Math.imul(d,gt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(U,H),n=(n=Math.imul(U,$))+Math.imul(z,H)|0,s=Math.imul(z,$),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(k,J)|0,s=s+Math.imul(k,Q)|0,i=i+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,W)|0)+Math.imul(T,Y)|0,s=s+Math.imul(T,W)|0,i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,i=i+Math.imul(w,ct)|0,n=(n=n+Math.imul(w,ht)|0)+Math.imul(A,ct)|0,s=s+Math.imul(A,ht)|0,i=i+Math.imul(b,ft)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(v,ft)|0,s=s+Math.imul(v,dt)|0;var St=(h+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;h=((s=s+Math.imul(g,gt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(U,J),n=(n=Math.imul(U,Q))+Math.imul(z,J)|0,s=Math.imul(z,Q),i=i+Math.imul(D,Y)|0,n=(n=n+Math.imul(D,W)|0)+Math.imul(k,Y)|0,s=s+Math.imul(k,W)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(T,X)|0,s=s+Math.imul(T,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,i=i+Math.imul(M,ct)|0,n=(n=n+Math.imul(M,ht)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ht)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(A,ft)|0,s=s+Math.imul(A,dt)|0;var Pt=(h+(i=i+Math.imul(b,pt)|0)|0)+((8191&(n=(n=n+Math.imul(b,gt)|0)+Math.imul(v,pt)|0))<<13)|0;h=((s=s+Math.imul(v,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(U,Y),n=(n=Math.imul(U,W))+Math.imul(z,Y)|0,s=Math.imul(z,W),i=i+Math.imul(D,X)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(T,rt)|0,s=s+Math.imul(T,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,i=i+Math.imul(S,ct)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(P,ct)|0,s=s+Math.imul(P,ht)|0,i=i+Math.imul(M,ft)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ft)|0,s=s+Math.imul(I,dt)|0;var xt=(h+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,gt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((s=s+Math.imul(A,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(U,X),n=(n=Math.imul(U,tt))+Math.imul(z,X)|0,s=Math.imul(z,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(k,rt)|0,s=s+Math.imul(k,it)|0,i=i+Math.imul(C,st)|0,n=(n=n+Math.imul(C,ot)|0)+Math.imul(T,st)|0,s=s+Math.imul(T,ot)|0,i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(N,ct)|0,s=s+Math.imul(N,ht)|0,i=i+Math.imul(S,ft)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(P,ft)|0,s=s+Math.imul(P,dt)|0;var Rt=(h+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(I,pt)|0))<<13)|0;h=((s=s+Math.imul(I,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(U,rt),n=(n=Math.imul(U,it))+Math.imul(z,rt)|0,s=Math.imul(z,it),i=i+Math.imul(D,st)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ht)|0)+Math.imul(T,ct)|0,s=s+Math.imul(T,ht)|0,i=i+Math.imul(R,ft)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,dt)|0;var Nt=(h+(i=i+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,gt)|0)+Math.imul(P,pt)|0))<<13)|0;h=((s=s+Math.imul(P,gt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(U,st),n=(n=Math.imul(U,ot))+Math.imul(z,st)|0,s=Math.imul(z,ot),i=i+Math.imul(D,ct)|0,n=(n=n+Math.imul(D,ht)|0)+Math.imul(k,ct)|0,s=s+Math.imul(k,ht)|0,i=i+Math.imul(C,ft)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(T,ft)|0,s=s+Math.imul(T,dt)|0;var Ot=(h+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,gt)|0)+Math.imul(N,pt)|0))<<13)|0;h=((s=s+Math.imul(N,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(U,ct),n=(n=Math.imul(U,ht))+Math.imul(z,ct)|0,s=Math.imul(z,ht),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,dt)|0)+Math.imul(k,ft)|0,s=s+Math.imul(k,dt)|0;var Ct=(h+(i=i+Math.imul(C,pt)|0)|0)+((8191&(n=(n=n+Math.imul(C,gt)|0)+Math.imul(T,pt)|0))<<13)|0;h=((s=s+Math.imul(T,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(U,ft),n=(n=Math.imul(U,dt))+Math.imul(z,ft)|0,s=Math.imul(z,dt);var Tt=(h+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,gt)|0)+Math.imul(k,pt)|0))<<13)|0;h=((s=s+Math.imul(k,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var qt=(h+(i=Math.imul(U,pt))|0)+((8191&(n=(n=Math.imul(U,gt))+Math.imul(z,pt)|0))<<13)|0;return h=((s=Math.imul(z,gt))+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,c[0]=mt,c[1]=bt,c[2]=vt,c[3]=yt,c[4]=wt,c[5]=At,c[6]=_t,c[7]=Mt,c[8]=It,c[9]=Et,c[10]=St,c[11]=Pt,c[12]=xt,c[13]=Rt,c[14]=Nt,c[15]=Ot,c[16]=Ct,c[17]=Tt,c[18]=qt,0!==h&&(c[19]=h,r.length++),r};function g(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(p=l),s.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):i<63?l(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s<r.length-1;s++){var o=n;n=0;for(var a=67108863&i,c=Math.min(s,e.length-1),h=Math.max(0,s-t.length+1);h<=c;h++){var u=s-h,f=(0|t.words[u])*(0|e.words[h]),d=67108863&f;a=67108863&(d=d+a|0),n+=(o=(o=o+(f/67108864|0)|0)+(d>>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):g(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},m.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var o=0;o<s;o++)i[o]=e[t[o]],n[o]=r[t[o]]},m.prototype.transform=function(t,e,r,i,n,s){this.permute(s,t,e,r,i,n);for(var o=1;o<n;o<<=1)for(var a=o<<1,c=Math.cos(2*Math.PI/a),h=Math.sin(2*Math.PI/a),u=0;u<n;u+=a)for(var f=c,d=h,l=0;l<o;l++){var p=r[u+l],g=i[u+l],m=r[u+l+o],b=i[u+l+o],v=f*m-d*b;b=f*b+d*m,m=v,r[u+l]=p+m,i[u+l]=g+b,r[u+l+o]=p-m,i[u+l+o]=g-b,l!==a&&(v=c*f-h*d,d=c*d+h*f,f=v)}},m.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},m.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},m.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},m.prototype.convert13b=function(t,e,r,n){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<n;++o)r[o]=0;i(0===s),i(!(-8192&s))},m.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},m.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),c=new Array(i),h=new Array(i),u=new Array(i),f=new Array(i),d=r.words;d.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,h,i),this.transform(o,s,a,c,i,n),this.transform(h,s,u,f,i,n);for(var l=0;l<i;l++){var p=a[l]*u[l]-c[l]*f[l];c[l]=a[l]*f[l]+c[l]*u[l],a[l]=p}return this.conjugate(a,c,i),this.transform(a,c,d,s,i,n),this.conjugate(d,s,i),this.normalize13b(d,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),g(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){i("number"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,s=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=s>>>26,this.words[r]=67108863&s}return 0!==e&&(this.words[r]=e,this.length++),this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new s(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},s.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,c=(0|this.words[e])-a<<r;this.words[e]=c|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var n;i("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,c=r;if(n-=o,n=Math.max(0,n),c){for(var h=0;h<o;h++)c.words[h]=this.words[h];c.length=o}if(0===o);else if(this.length>o)for(this.length-=o,h=0;h<this.length;h++)this.words[h]=this.words[h+o];else this.words[0]=0,this.length=1;var u=0;for(h=this.length-1;h>=0&&(0!==u||h>=n);h--){var f=0|this.words[h];this.words[h]=u<<26-s|f>>>s,u=f&a}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r||!(this.words[r]&n))},s.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i("number"==typeof t),i(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)},s.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},s.prototype.isubn=function(t){if(i("number"==typeof t),i(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()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var c=(0|t.words[n])*e;a=((s-=67108863&c)>>26)-(c/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,c=i.length-n.length;if("mod"!==e){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var u=i.clone()._ishlnsubmul(n,1,c);0===u.negative&&(i=u,a&&(a.words[c]=1));for(var f=c-1;f>=0;f--){var d=67108864*(0|i.words[n.length+f])+(0|i.words[n.length+f-1]);for(d=Math.min(d/o|0,67108863),i._ishlnsubmul(n,d,f);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(n,1,f),i.isZero()||(i.negative^=1);a&&(a.words[f]=d)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):this.negative&t.negative?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.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,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},s.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new s(1),o=new s(0),a=new s(0),c=new s(1),h=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++h;for(var u=r.clone(),f=e.clone();!e.isZero();){for(var d=0,l=1;!(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(u),o.isub(f)),n.iushrn(1),o.iushrn(1);for(var p=0,g=1;!(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(u),c.isub(f)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),o.isub(c)):(r.isub(e),a.isub(n),c.isub(o))}return{a,b:c,gcd:r.iushln(h)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,o=new s(1),a=new s(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var h=0,u=1;!(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var f=0,d=1;!(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(n=0===e.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(t),n},s.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 i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},s.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},s.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 i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new M(t)},s.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var b={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(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)}v.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.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 i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(y,v),y.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},y.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 i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,v),n(A,v),n(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(b[t])return b[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new w;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return b[t]=e,e},M.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){i(!(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.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)},M.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},M.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)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),c=a.redNeg(),h=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new s(2*u*u).toRed(this);0!==this.pow(u,h).cmp(c);)u.redIAdd(c);for(var f=this.pow(u,n),d=this.pow(t,n.addn(1).iushrn(1)),l=this.pow(t,n),p=o;0!==l.cmp(a);){for(var g=l,m=0;0!==g.cmp(a);m++)g=g.redSqr();i(m<p);var b=this.pow(f,new s(1).iushln(p-m-1));d=d.redMul(b),f=b.redSqr(),l=l.redMul(f),p=m}return d},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,c=e.bitLength()%26;for(0===c&&(c=26),i=e.length-1;i>=0;i--){for(var h=e.words[i],u=c-1;u>=0;u--){var f=h>>u&1;n!==r[0]&&(n=this.sqr(n)),0!==f||0!==o?(o<<=1,o|=f,(4==++a||0===i&&0===u)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}c=26}return n},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new I(t)},n(I,M),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},57729:(t,e,r)=>{var i=e;i.version=r(72716).rE,i.utils=r(49899),i.rand=r(47048),i.curve=r(67942),i.curves=r(70392),i.ec=r(799),i.eddsa=r(43730)},74893:(t,e,r)=>{var i=r(79188),n=r(49899),s=n.getNAF,o=n.getJSF,a=n.assert;function c(t,e){this.type=t,this.p=new i(e.p,16),this.red=e.prime?i.red(e.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=e.n&&new i(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function h(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),i=s(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var o,c,h=[];for(o=0;o<i.length;o+=r.step){c=0;for(var u=o+r.step-1;u>=o;u--)c=(c<<1)+i[u];h.push(c)}for(var f=this.jpoint(null,null,null),d=this.jpoint(null,null,null),l=n;l>0;l--){for(o=0;o<h.length;o++)(c=h[o])===l?d=d.mixedAdd(r.points[o]):c===-l&&(d=d.mixedAdd(r.points[o].neg()));f=f.add(d)}return f.toP()},c.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,o=s(e,r,this._bitLength),c=this.jpoint(null,null,null),h=o.length-1;h>=0;h--){for(var u=0;h>=0&&0===o[h];h--)u++;if(h>=0&&u++,c=c.dblp(u),h<0)break;var f=o[h];a(0!==f),c="affine"===t.type?f>0?c.mixedAdd(n[f-1>>1]):c.mixedAdd(n[-f-1>>1].neg()):f>0?c.add(n[f-1>>1]):c.add(n[-f-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,i,n){var a,c,h,u=this._wnafT1,f=this._wnafT2,d=this._wnafT3,l=0;for(a=0;a<i;a++){var p=(h=e[a])._getNAFPoints(t);u[a]=p.wnd,f[a]=p.points}for(a=i-1;a>=1;a-=2){var g=a-1,m=a;if(1===u[g]&&1===u[m]){var b=[e[g],null,null,e[m]];0===e[g].y.cmp(e[m].y)?(b[1]=e[g].add(e[m]),b[2]=e[g].toJ().mixedAdd(e[m].neg())):0===e[g].y.cmp(e[m].y.redNeg())?(b[1]=e[g].toJ().mixedAdd(e[m]),b[2]=e[g].add(e[m].neg())):(b[1]=e[g].toJ().mixedAdd(e[m]),b[2]=e[g].toJ().mixedAdd(e[m].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],y=o(r[g],r[m]);for(l=Math.max(y[0].length,l),d[g]=new Array(l),d[m]=new Array(l),c=0;c<l;c++){var w=0|y[0][c],A=0|y[1][c];d[g][c]=v[3*(w+1)+(A+1)],d[m][c]=0,f[g]=b}}else d[g]=s(r[g],u[g],this._bitLength),d[m]=s(r[m],u[m],this._bitLength),l=Math.max(d[g].length,l),l=Math.max(d[m].length,l)}var _=this.jpoint(null,null,null),M=this._wnafT4;for(a=l;a>=0;a--){for(var I=0;a>=0;){var E=!0;for(c=0;c<i;c++)M[c]=0|d[c][a],0!==M[c]&&(E=!1);if(!E)break;I++,a--}if(a>=0&&I++,_=_.dblp(I),a<0)break;for(c=0;c<i;c++){var S=M[c];0!==S&&(S>0?h=f[c][S-1>>1]:S<0&&(h=f[c][-S-1>>1].neg()),_="affine"===h.type?_.mixedAdd(h):_.add(h))}}for(a=0;a<i;a++)f[a]=null;return n?_:_.toP()},c.BasePoint=h,h.prototype.eq=function(){throw new Error("Not implemented")},h.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(t,e){t=n.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?a(t[t.length-1]%2==0):7===t[0]&&a(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},h.prototype.encodeCompressed=function(t){return this.encode(t,!0)},h.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},h.prototype.encode=function(t,e){return n.encode(this._encode(e),t)},h.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},h.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},h.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var s=0;s<t;s++)i=i.dbl();r.push(i)}return{step:t,points:r}},h.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},h.prototype._getBeta=function(){return null},h.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}},858:(t,e,r)=>{var i=r(49899),n=r(79188),s=r(35615),o=r(74893),a=i.assert;function c(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,o.call(this,"edwards",t),this.a=new n(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new n(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new n(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function h(t,e,r,i,s){o.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===i?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new n(e,16),this.y=new n(r,16),this.z=i?new n(i,16):this.curve.one,this.t=s&&new n(s,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(c,o),t.exports=c,c.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},c.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},c.prototype.jpoint=function(t,e,r,i){return this.point(t,e,r,i)},c.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=i.redMul(s.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(e&&!c||!e&&c)&&(a=a.redNeg()),this.point(t,a)},c.prototype.pointFromY=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=i.redMul(s.redInvm());if(0===o.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},c.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),i=e.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===i.cmp(n)},s(h,o.BasePoint),c.prototype.pointFromJSON=function(t){return h.fromJSON(this,t)},c.prototype.point=function(t,e,r,i){return new h(this,t,e,r,i)},h.fromJSON=function(t,e){return new h(t,e[0],e[1],e[2])},h.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},h.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},h.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=i.redAdd(e),o=s.redSub(r),a=i.redSub(e),c=n.redMul(o),h=s.redMul(a),u=n.redMul(a),f=o.redMul(s);return this.curve.point(c,h,f,u)},h.prototype._projDbl=function(){var t,e,r,i,n,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var h=(i=this.curve._mulA(a)).redAdd(c);this.zOne?(t=o.redSub(a).redSub(c).redMul(h.redSub(this.curve.two)),e=h.redMul(i.redSub(c)),r=h.redSqr().redSub(h).redSub(h)):(n=this.z.redSqr(),s=h.redSub(n).redISub(n),t=o.redSub(a).redISub(c).redMul(s),e=h.redMul(i.redSub(c)),r=h.redMul(s))}else i=a.redAdd(c),n=this.curve._mulC(this.z).redSqr(),s=i.redSub(n).redSub(n),t=this.curve._mulC(o.redISub(i)).redMul(s),e=this.curve._mulC(i).redMul(a.redISub(c)),r=i.redMul(s);return this.curve.point(t,e,r)},h.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},h.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(e),o=n.redSub(i),a=n.redAdd(i),c=r.redAdd(e),h=s.redMul(o),u=a.redMul(c),f=s.redMul(c),d=o.redMul(a);return this.curve.point(h,u,d,f)},h.prototype._projAdd=function(t){var e,r,i=this.z.redMul(t.z),n=i.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),c=n.redSub(a),h=n.redAdd(a),u=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),f=i.redMul(c).redMul(u);return this.curve.twisted?(e=i.redMul(h).redMul(o.redSub(this.curve._mulA(s))),r=c.redMul(h)):(e=i.redMul(h).redMul(o.redSub(s)),r=this.curve._mulC(c).redMul(h)),this.curve.point(f,e,r)},h.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},h.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},h.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},h.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},h.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()},h.prototype.getY=function(){return this.normalize(),this.y.fromRed()},h.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},h.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(i),0===this.x.cmp(e))return!0}},h.prototype.toP=h.prototype.normalize,h.prototype.mixedAdd=h.prototype.add},67942:(t,e,r)=>{var i=e;i.base=r(74893),i.short=r(85580),i.mont=r(25882),i.edwards=r(858)},25882:(t,e,r)=>{var i=r(79188),n=r(35615),s=r(74893),o=r(49899);function a(t){s.call(this,"mont",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(t,e,r){s.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(e,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}n(a,s),t.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),i=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===i.redSqrt().redSqr().cmp(i)},n(c,s.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(o.toArray(t,e),1)},a.prototype.point=function(t,e){return new c(this,t,e)},a.prototype.pointFromJSON=function(t){return c.fromJSON(this,t)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(t,e){return new c(t,e[0],e[1]||t.one)},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),i=t.redMul(e),n=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(r),o=n.redMul(i),a=e.z.redMul(s.redAdd(o).redSqr()),c=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(t){for(var e=t.clone(),r=this,i=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},85580:(t,e,r)=>{var i=r(49899),n=r(79188),s=r(35615),o=r(74893),a=i.assert;function c(t){o.call(this,"short",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function h(t,e,r,i){o.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new n(e,16),this.y=new n(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(t,e,r,i){o.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new n(0)):(this.x=new n(e,16),this.y=new n(r,16),this.z=new n(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(c,o),t.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new n(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=(e=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(t.lambda)r=new n(t.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(e))?r=s[0]:(r=s[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new n(t.a,16),b:new n(t.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:n.mont(t),r=new n(2).toRed(e).redInvm(),i=r.redNeg(),s=new n(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(s).fromRed(),i.redSub(s).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,i,s,o,a,c,h,u,f=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,l=this.n.clone(),p=new n(1),g=new n(0),m=new n(0),b=new n(1),v=0;0!==d.cmpn(0);){var y=l.div(d);h=l.sub(y.mul(d)),u=m.sub(y.mul(p));var w=b.sub(y.mul(g));if(!i&&h.cmp(f)<0)e=c.neg(),r=p,i=h.neg(),s=u;else if(i&&2==++v)break;c=h,l=d,d=h,m=p,p=u,b=g,g=w}o=h.neg(),a=u;var A=i.sqr().add(s.sqr());return o.sqr().add(a.sqr()).cmp(A)>=0&&(o=e,a=r),i.negative&&(i=i.neg(),s=s.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:s},{a:o,b:a}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),c=n.mul(r.b),h=s.mul(i.b);return{k1:t.sub(o).sub(a),k2:c.add(h).neg()}},c.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var s=i.fromRed().isOdd();return(e&&!s||!e&&s)&&(i=i.redNeg()),this.point(t,i)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s<t.length;s++){var o=this._endoSplit(e[s]),a=t[s],c=a._getBeta();o.k1.negative&&(o.k1.ineg(),a=a.neg(!0)),o.k2.negative&&(o.k2.ineg(),c=c.neg(!0)),i[2*s]=a,i[2*s+1]=c,n[2*s]=o.k1,n[2*s+1]=o.k2}for(var h=this._wnafMulAdd(1,i,n,2*s,r),u=0;u<2*s;u++)i[u]=null,n[u]=null;return h},s(h,o.BasePoint),c.prototype.point=function(t,e,r){return new h(this,t,e,r)},c.prototype.pointFromJSON=function(t,e){return h.fromJSON(this,t,e)},h.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},h.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},h.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(e){return t.point(e[0],e[1],r)}var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},h.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},h.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(t){return t=new n(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},h.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},h.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},h.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(u,o.BasePoint),c.prototype.jpoint=function(t,e,r){return new u(this,t,e,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),u=h.redMul(a),f=i.redMul(h),d=c.redSqr().redIAdd(u).redISub(f).redISub(f),l=c.redMul(f.redISub(d)).redISub(s.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,l,p)},u.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),h=c.redMul(o),u=r.redMul(c),f=a.redSqr().redIAdd(h).redISub(u).redISub(u),d=a.redMul(u.redISub(f)).redISub(n.redMul(h)),l=this.z.redMul(o);return this.curve.jpoint(f,d,l)},u.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,s=this.x,o=this.y,a=this.z,c=a.redSqr().redSqr(),h=o.redAdd(o);for(e=0;e<t;e++){var u=s.redSqr(),f=h.redSqr(),d=f.redSqr(),l=u.redAdd(u).redIAdd(u).redIAdd(i.redMul(c)),p=s.redMul(f),g=l.redSqr().redISub(p.redAdd(p)),m=p.redISub(g),b=l.redMul(m);b=b.redIAdd(b).redISub(d);var v=h.redMul(a);e+1<t&&(c=c.redMul(d)),s=g,a=v,h=b}return this.curve.jpoint(s,h.redMul(n),a)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},u.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var a=i.redAdd(i).redIAdd(i),c=a.redSqr().redISub(o).redISub(o),h=s.redIAdd(s);h=(h=h.redIAdd(h)).redIAdd(h),t=c,e=a.redMul(o.redISub(c)).redISub(h),r=this.y.redAdd(this.y)}else{var u=this.x.redSqr(),f=this.y.redSqr(),d=f.redSqr(),l=this.x.redAdd(f).redSqr().redISub(u).redISub(d);l=l.redIAdd(l);var p=u.redAdd(u).redIAdd(u),g=p.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),t=g.redISub(l).redISub(l),e=p.redMul(l.redISub(t)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},u.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var a=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),c=a.redSqr().redISub(o).redISub(o);t=c;var h=s.redIAdd(s);h=(h=h.redIAdd(h)).redIAdd(h),e=a.redMul(o.redISub(c)).redISub(h),r=this.y.redAdd(this.y)}else{var u=this.z.redSqr(),f=this.y.redSqr(),d=this.x.redMul(f),l=this.x.redSub(u).redMul(this.x.redAdd(u));l=l.redAdd(l).redIAdd(l);var p=d.redIAdd(d),g=(p=p.redIAdd(p)).redAdd(p);t=l.redSqr().redISub(g),r=this.y.redAdd(this.z).redSqr().redISub(f).redISub(u);var m=f.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),e=l.redMul(p.redISub(t)).redISub(m)}return this.curve.jpoint(t,e,r)},u.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),a=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(n)),c=e.redAdd(e),h=(c=c.redIAdd(c)).redMul(o),u=a.redSqr().redISub(h.redAdd(h)),f=h.redISub(u),d=o.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=a.redMul(f).redISub(d),p=r.redAdd(r).redMul(i);return this.curve.jpoint(u,l,p)},u.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),s=n.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(i),a=(o=(o=(o=o.redIAdd(o)).redAdd(o).redIAdd(o)).redISub(s)).redSqr(),c=i.redIAdd(i);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var h=n.redIAdd(o).redSqr().redISub(s).redISub(a).redISub(c),u=e.redMul(h);u=(u=u.redIAdd(u)).redIAdd(u);var f=this.x.redMul(a).redISub(u);f=(f=f.redIAdd(f)).redIAdd(f);var d=this.y.redMul(h.redMul(c.redISub(h)).redISub(o.redMul(a)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=this.z.redAdd(o).redSqr().redISub(r).redISub(a);return this.curve.jpoint(f,d,l)},u.prototype.mul=function(t,e){return t=new n(t,e),this.curve._wnafMul(this,t)},u.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return 0===this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)},u.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},70392:(t,e,r)=>{var i,n=e,s=r(99499),o=r(67942),a=r(49899).assert;function c(t){"short"===t.type?this.curve=new o.short(t):"edwards"===t.type?this.curve=new o.edwards(t):this.curve=new o.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function h(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=c,h("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:s.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),h("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:s.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),h("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:s.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),h("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:s.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),h("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:s.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),h("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["9"]}),h("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=r(88483)}catch(t){i=void 0}h("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:s.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},799:(t,e,r)=>{var i=r(79188),n=r(84742),s=r(49899),o=r(70392),a=r(47048),c=s.assert,h=r(23e3),u=r(75625);function f(t){if(!(this instanceof f))return new f(t);"string"==typeof t&&(c(Object.prototype.hasOwnProperty.call(o,t),"Unknown curve "+t),t=o[t]),t instanceof o.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}t.exports=f,f.prototype.keyPair=function(t){return new h(this,t)},f.prototype.keyFromPrivate=function(t,e){return h.fromPrivate(this,t,e)},f.prototype.keyFromPublic=function(t,e){return h.fromPublic(this,t,e)},f.prototype.genKeyPair=function(t){t||(t={});for(var e=new n({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),s=this.n.sub(new i(2));;){var o=new i(e.generate(r));if(!(o.cmp(s)>0))return o.iaddn(1),this.keyFromPrivate(o)}},f.prototype._truncateToN=function(t,e,r){var n;if(i.isBN(t)||"number"==typeof t)n=(t=new i(t,16)).byteLength();else if("object"==typeof t)n=t.length,t=new i(t,16);else{var s=t.toString();n=s.length+1>>>1,t=new i(s,16)}"number"!=typeof r&&(r=8*n);var o=r-this.n.bitLength();return o>0&&(t=t.ushrn(o)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},f.prototype.sign=function(t,e,r,s){if("object"==typeof r&&(s=r,r=null),s||(s={}),"string"!=typeof t&&"number"!=typeof t&&!i.isBN(t)){c("object"==typeof t&&t&&"number"==typeof t.length,"Expected message to be an array-like, a hex string, or a BN instance"),c(t.length>>>0===t.length);for(var o=0;o<t.length;o++)c((255&t[o])===t[o])}e=this.keyFromPrivate(e,r),t=this._truncateToN(t,!1,s.msgBitLength),c(!t.isNeg(),"Can not sign a negative message");var a=this.n.byteLength(),h=e.getPrivate().toArray("be",a),f=t.toArray("be",a);c(new i(f).eq(t),"Can not sign message");for(var d=new n({hash:this.hash,entropy:h,nonce:f,pers:s.pers,persEnc:s.persEnc||"utf8"}),l=this.n.sub(new i(1)),p=0;;p++){var g=s.k?s.k(p):new i(d.generate(this.n.byteLength()));if(!((g=this._truncateToN(g,!0)).cmpn(1)<=0||g.cmp(l)>=0)){var m=this.g.mul(g);if(!m.isInfinity()){var b=m.getX(),v=b.umod(this.n);if(0!==v.cmpn(0)){var y=g.invm(this.n).mul(v.mul(e.getPrivate()).iadd(t));if(0!==(y=y.umod(this.n)).cmpn(0)){var w=(m.getY().isOdd()?1:0)|(0!==b.cmp(v)?2:0);return s.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),w^=1),new u({r:v,s:y,recoveryParam:w})}}}}}},f.prototype.verify=function(t,e,r,i,n){n||(n={}),t=this._truncateToN(t,!1,n.msgBitLength),r=this.keyFromPublic(r,i);var s=(e=new u(e,"hex")).r,o=e.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,c=o.invm(this.n),h=c.mul(t).umod(this.n),f=c.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(h,r.getPublic(),f)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(h,r.getPublic(),f)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},f.prototype.recoverPubKey=function(t,e,r,n){c((3&r)===r,"The recovery param is more than two bits"),e=new u(e,n);var s=this.n,o=new i(t),a=e.r,h=e.s,f=1&r,d=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");a=d?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=e.r.invm(s),p=s.sub(o).mul(l).umod(s),g=h.mul(l).umod(s);return this.g.mulAdd(p,a,g)},f.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new u(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch(t){continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},23e3:(t,e,r)=>{var i=r(79188),n=r(49899).assert;function s(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}t.exports=s,s.fromPublic=function(t,e,r){return e instanceof s?e:new s(t,{pub:e,pubEnc:r})},s.fromPrivate=function(t,e,r){return e instanceof s?e:new s(t,{priv:e,privEnc:r})},s.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},s.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},s.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},s.prototype._importPrivate=function(t,e){this.priv=new i(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},s.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?n(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||n(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},s.prototype.derive=function(t){return t.validate()||n(t.validate(),"public point not validated"),t.mul(this.priv).getX()},s.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},s.prototype.verify=function(t,e,r){return this.ec.verify(t,e,this,void 0,r)},s.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},75625:(t,e,r)=>{var i=r(79188),n=r(49899),s=n.assert;function o(t,e){if(t instanceof o)return t;this._importDER(t,e)||(s(t.r&&t.s,"Signature without r or s"),this.r=new i(t.r,16),this.s=new i(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function c(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;if(0===t[e.place])return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return!(n<=127)&&(e.place=o,n)}function h(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function u(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=o,o.prototype._importDER=function(t,e){t=n.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;var s=c(t,r);if(!1===s)return!1;if(s+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var o=c(t,r);if(!1===o)return!1;if(128&t[r.place])return!1;var h=t.slice(r.place,o+r.place);if(r.place+=o,2!==t[r.place++])return!1;var u=c(t,r);if(!1===u)return!1;if(t.length!==u+r.place)return!1;if(128&t[r.place])return!1;var f=t.slice(r.place,u+r.place);if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new i(h),this.s=new i(f),this.recoveryParam=null,!0},o.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=h(e),r=h(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];u(i,e.length),(i=i.concat(e)).push(2),u(i,r.length);var s=i.concat(r),o=[48];return u(o,s.length),o=o.concat(s),n.encode(o,t)}},43730:(t,e,r)=>{var i=r(99499),n=r(70392),s=r(49899),o=s.assert,a=s.parseBytes,c=r(54077),h=r(53604);function u(t){if(o("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof u))return new u(t);t=n[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=i.sha512}t.exports=u,u.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),i=this.hashInt(r.messagePrefix(),t),n=this.g.mul(i),s=this.encodePoint(n),o=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),c=i.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:c,Rencoded:s})},u.prototype.verify=function(t,e,r){if(t=a(t),(e=this.makeSignature(e)).S().gte(e.eddsa.curve.n)||e.S().isNeg())return!1;var i=this.keyFromPublic(r),n=this.hashInt(e.Rencoded(),i.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(i.pub().mul(n)).eq(s)},u.prototype.hashInt=function(){for(var t=this.hash(),e=0;e<arguments.length;e++)t.update(arguments[e]);return s.intFromLE(t.digest()).umod(this.curve.n)},u.prototype.keyFromPublic=function(t){return c.fromPublic(this,t)},u.prototype.keyFromSecret=function(t){return c.fromSecret(this,t)},u.prototype.makeSignature=function(t){return t instanceof h?t:new h(this,t)},u.prototype.encodePoint=function(t){var e=t.getY().toArray("le",this.encodingLength);return e[this.encodingLength-1]|=t.getX().isOdd()?128:0,e},u.prototype.decodePoint=function(t){var e=(t=s.parseBytes(t)).length-1,r=t.slice(0,e).concat(-129&t[e]),i=!!(128&t[e]),n=s.intFromLE(r);return this.curve.pointFromY(n,i)},u.prototype.encodeInt=function(t){return t.toArray("le",this.encodingLength)},u.prototype.decodeInt=function(t){return s.intFromLE(t)},u.prototype.isPoint=function(t){return t instanceof this.pointClass}},54077:(t,e,r)=>{var i=r(49899),n=i.assert,s=i.parseBytes,o=i.cachedProperty;function a(t,e){this.eddsa=t,this._secret=s(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=s(e.pub)}a.fromPublic=function(t,e){return e instanceof a?e:new a(t,{pub:e})},a.fromSecret=function(t,e){return e instanceof a?e:new a(t,{secret:e})},a.prototype.secret=function(){return this._secret},o(a,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),o(a,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),o(a,"privBytes",(function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,i=e.slice(0,t.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i})),o(a,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),o(a,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),o(a,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),a.prototype.sign=function(t){return n(this._secret,"KeyPair can only verify"),this.eddsa.sign(t,this)},a.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},a.prototype.getSecret=function(t){return n(this._secret,"KeyPair is public only"),i.encode(this.secret(),t)},a.prototype.getPublic=function(t){return i.encode(this.pubBytes(),t)},t.exports=a},53604:(t,e,r)=>{var i=r(79188),n=r(49899),s=n.assert,o=n.cachedProperty,a=n.parseBytes;function c(t,e){this.eddsa=t,"object"!=typeof e&&(e=a(e)),Array.isArray(e)&&(s(e.length===2*t.encodingLength,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),s(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof i&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}o(c,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),o(c,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),o(c,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),o(c,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return n.encode(this.toBytes(),"hex").toUpperCase()},t.exports=c},88483:t=>{t.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},49899:(t,e,r)=>{var i=e,n=r(79188),s=r(7784),o=r(89042);i.assert=s,i.toArray=o.toArray,i.zero2=o.zero2,i.toHex=o.toHex,i.encode=o.encode,i.getNAF=function(t,e,r){var i,n=new Array(Math.max(t.bitLength(),r)+1);for(i=0;i<n.length;i+=1)n[i]=0;var s=1<<e+1,o=t.clone();for(i=0;i<n.length;i++){var a,c=o.andln(s-1);o.isOdd()?(a=c>(s>>1)-1?(s>>1)-c:c,o.isubn(a)):a=0,n[i]=a,o.iushrn(1)}return n},i.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,c=t.andln(3)+n&3,h=e.andln(3)+s&3;3===c&&(c=-1),3===h&&(h=-1),o=1&c?3!=(i=t.andln(7)+n&7)&&5!==i||2!==h?c:-c:0,r[0].push(o),a=1&h?3!=(i=e.andln(7)+s&7)&&5!==i||2!==c?h:-h:0,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r},i.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(t){return"string"==typeof t?i.toArray(t,"hex"):t},i.intFromLE=function(t){return new n(t,"hex","le")}},72716:t=>{t.exports={rE:"6.6.1"}}};
|