metahunt/Assets/WebGLTemplates/Web3GL-2020x/assets/index-8679f448.js
2024-02-11 13:53:18 +05:30

2 lines
202 KiB
JavaScript

import{a as K,t as Ln,k as Qt,c as be,h as Q,L as x,b as ke,B as O,d as Dt,e as R,f as le,g as Wt,i as fn,s as Ct,j as Bt,l as ue,r as Lt,D as Dn,m as qn,n as Fn,o as se,p as sr,q as Ee,u as Wr,v as Xr,Z as Un,w as Ht,x as Fe,y as Gn,z as or,A as zn,C as ar,E as ki,F as pe,G as Jn}from"./index-c4efa424.js";const Kn="0x0000000000000000000000000000000000000000",Hn="0x0000000000000000000000000000000000000000000000000000000000000000",ln="hash/5.7.0";function un(s){s=atob(s);const t=[];for(let e=0;e<s.length;e++)t.push(s.charCodeAt(e));return K(t)}function hn(s){s=K(s);let t="";for(let e=0;e<s.length;e++)t+=String.fromCharCode(s[e]);return btoa(t)}function cn(s,t){t==null&&(t=1);const e=[],r=e.forEach,n=function(i,a){r.call(i,function(u){a>0&&Array.isArray(u)?n(u,a-1):e.push(u)})};return n(s,t),e}function Qn(s){const t={};for(let e=0;e<s.length;e++){const r=s[e];t[r[0]]=r[1]}return t}function jn(s){let t=0;function e(){return s[t++]<<8|s[t++]}let r=e(),n=1,i=[0,1];for(let F=1;F<r;F++)i.push(n+=e());let a=e(),u=t;t+=a;let h=0,d=0;function p(){return h==0&&(d=d<<8|s[t++],h=8),d>>--h&1}const A=31,M=Math.pow(2,A),E=M>>>1,_=E>>1,I=M-1;let T=0;for(let F=0;F<A;F++)T=T<<1|p();let P=[],S=0,G=M;for(;;){let F=Math.floor(((T-S+1)*n-1)/G),z=0,Vt=r;for(;Vt-z>1;){let we=z+Vt>>>1;F<i[we]?Vt=we:z=we}if(z==0)break;P.push(z);let Kt=S+Math.floor(G*i[z]/n),Ft=S+Math.floor(G*i[z+1]/n)-1;for(;!((Kt^Ft)&E);)T=T<<1&I|p(),Kt=Kt<<1&I,Ft=Ft<<1&I|1;for(;Kt&~Ft&_;)T=T&E|T<<1&I>>>1|p(),Kt=Kt<<1^E,Ft=(Ft^E)<<1|E|1;S=Kt,G=1+Ft-Kt}let J=r-4;return P.map(F=>{switch(F-J){case 3:return J+65792+(s[u++]<<16|s[u++]<<8|s[u++]);case 2:return J+256+(s[u++]<<8|s[u++]);case 1:return J+s[u++];default:return F-1}})}function Yn(s){let t=0;return()=>s[t++]}function Wn(s){return Yn(jn(s))}function Xn(s){return s&1?~s>>1:s>>1}function Vn(s,t){let e=Array(s);for(let r=0;r<s;r++)e[r]=1+t();return e}function Ei(s,t){let e=Array(s);for(let r=0,n=-1;r<s;r++)e[r]=n+=1+t();return e}function Zn(s,t){let e=Array(s);for(let r=0,n=0;r<s;r++)e[r]=n+=Xn(t());return e}function tr(s,t){let e=Ei(s(),s),r=s(),n=Ei(r,s),i=Vn(r,s);for(let a=0;a<r;a++)for(let u=0;u<i[a];u++)e.push(n[a]+u);return t?e.map(a=>t[a]):e}function $n(s){let t=[];for(;;){let e=s();if(e==0)break;t.push(es(e,s))}for(;;){let e=s()-1;if(e<0)break;t.push(rs(e,s))}return Qn(cn(t))}function ts(s){let t=[];for(;;){let e=s();if(e==0)break;t.push(e)}return t}function dn(s,t,e){let r=Array(s).fill(void 0).map(()=>[]);for(let n=0;n<t;n++)Zn(s,e).forEach((i,a)=>r[a].push(i));return r}function es(s,t){let e=1+t(),r=t(),n=ts(t),i=dn(n.length,1+s,t);return cn(i.map((a,u)=>{const h=a[0],d=a.slice(1);return Array(n[u]).fill(void 0).map((p,A)=>{let M=A*r;return[h+A*e,d.map(E=>E+M)]})}))}function rs(s,t){let e=1+t();return dn(e,1+s,t).map(n=>[n[0],n.slice(1)])}function is(s){let t=tr(s).sort((r,n)=>r-n);return e();function e(){let r=[];for(;;){let d=tr(s,t);if(d.length==0)break;r.push({set:new Set(d),node:e()})}r.sort((d,p)=>p.set.size-d.set.size);let n=s(),i=n%3;n=n/3|0;let a=!!(n&1);n>>=1;let u=n==1,h=n==2;return{branches:r,valid:i,fe0f:a,save:u,check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YdcUcE2zcXq4vaIvW2/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=="))}const fr=ns(),ss=new Set(tr(fr)),os=new Set(tr(fr)),as=$n(fr),fs=is(fr),xi=45,Mi=95;function pn(s){return Ln(s)}function ls(s){return s.filter(t=>t!=65039)}function gn(s){for(let t of s.split(".")){let e=pn(t);try{for(let r=e.lastIndexOf(Mi)-1;r>=0;r--)if(e[r]!==Mi)throw new Error("underscore only allowed at start");if(e.length>=4&&e.every(r=>r<128)&&e[2]===xi&&e[3]===xi)throw new Error("invalid label extension")}catch(r){throw new Error(`Invalid label "${t}": ${r.message}`)}}return s}function us(s){return gn(hs(s,ls))}function hs(s,t){let e=pn(s).reverse(),r=[];for(;e.length;){let n=ds(e);if(n){r.push(...t(n));continue}let i=e.pop();if(ss.has(i)){r.push(i);continue}if(os.has(i))continue;let a=as[i];if(a){r.push(...a);continue}throw new Error(`Disallowed codepoint: 0x${i.toString(16).toUpperCase()}`)}return gn(cs(String.fromCodePoint(...r)))}function cs(s){return s.normalize("NFC")}function ds(s,t){var e;let r=fs,n,i,a=[],u=s.length;for(t&&(t.length=0);u;){let h=s[--u];if(r=(e=r.branches.find(d=>d.set.has(h)))===null||e===void 0?void 0:e.node,!r)break;if(r.save)i=h;else if(r.check&&h===i)break;a.push(h),r.fe0f&&(a.push(65039),u>0&&s[u-1]==65039&&u--),r.valid&&(n=a.slice(),r.valid==2&&n.splice(1,1),t&&t.push(...s.slice(u).reverse()),s.length=u)}return n}const ps=new x(ln),mn=new Uint8Array(32);mn.fill(0);function _i(s){if(s.length===0)throw new Error("invalid ENS name; empty component");return s}function vn(s){const t=ke(us(s)),e=[];if(s.length===0)return e;let r=0;for(let n=0;n<t.length;n++)t[n]===46&&(e.push(_i(t.slice(r,n))),r=n+1);if(r>=t.length)throw new Error("invalid ENS name; empty component");return e.push(_i(t.slice(r))),e}function Ye(s){typeof s!="string"&&ps.throwArgumentError("invalid ENS name; not a string","name",s);let t=mn;const e=vn(s);for(;e.length;)t=Qt(be([t,Qt(e.pop())]));return Q(t)}function gs(s){return Q(be(vn(s).map(t=>{if(t.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const e=new Uint8Array(t.length+1);return e.set(t,1),e[0]=e.length-1,e})))+"00"}var ms=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const Y=new x(ln),wn=new Uint8Array(32);wn.fill(0);const vs=O.from(-1),yn=O.from(0),An=O.from(1),ws=O.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function ys(s){const t=K(s),e=t.length%32;return e?Wt([t,wn.slice(e)]):Q(t)}const As=Dt(An.toHexString(),32),bs=Dt(yn.toHexString(),32),Ii={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Tr=["name","version","chainId","verifyingContract","salt"];function Pi(s){return function(t){return typeof t!="string"&&Y.throwArgumentError(`invalid domain value for ${JSON.stringify(s)}`,`domain.${s}`,t),t}}const ks={name:Pi("name"),version:Pi("version"),chainId:function(s){try{return O.from(s).toString()}catch{}return Y.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",s)},verifyingContract:function(s){try{return ue(s).toLowerCase()}catch{}return Y.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",s)},salt:function(s){try{const t=K(s);if(t.length!==32)throw new Error("bad length");return Q(t)}catch{}return Y.throwArgumentError('invalid domain value "salt"',"domain.salt",s)}};function Br(s){{const t=s.match(/^(u?)int(\d*)$/);if(t){const e=t[1]==="",r=parseInt(t[2]||"256");(r%8!==0||r>256||t[2]&&t[2]!==String(r))&&Y.throwArgumentError("invalid numeric width","type",s);const n=ws.mask(e?r-1:r),i=e?n.add(An).mul(vs):yn;return function(a){const u=O.from(a);return(u.lt(i)||u.gt(n))&&Y.throwArgumentError(`value out-of-bounds for ${s}`,"value",a),Dt(u.toTwos(256).toHexString(),32)}}}{const t=s.match(/^bytes(\d+)$/);if(t){const e=parseInt(t[1]);return(e===0||e>32||t[1]!==String(e))&&Y.throwArgumentError("invalid bytes width","type",s),function(r){return K(r).length!==e&&Y.throwArgumentError(`invalid length for ${s}`,"value",r),ys(r)}}}switch(s){case"address":return function(t){return Dt(ue(t),32)};case"bool":return function(t){return t?As:bs};case"bytes":return function(t){return Qt(t)};case"string":return function(t){return fn(t)}}return null}function Ni(s,t){return`${s}(${t.map(({name:e,type:r})=>r+" "+e).join(",")})`}class jt{constructor(t){R(this,"types",Object.freeze(le(t))),R(this,"_encoderCache",{}),R(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach(u=>{e[u]={},r[u]=[],n[u]={}});for(const u in t){const h={};t[u].forEach(d=>{h[d.name]&&Y.throwArgumentError(`duplicate variable name ${JSON.stringify(d.name)} in ${JSON.stringify(u)}`,"types",t),h[d.name]=!0;const p=d.type.match(/^([^\x5b]*)(\x5b|$)/)[1];p===u&&Y.throwArgumentError(`circular type reference to ${JSON.stringify(p)}`,"types",t),!Br(p)&&(r[p]||Y.throwArgumentError(`unknown type ${JSON.stringify(p)}`,"types",t),r[p].push(u),e[u][p]=!0)})}const i=Object.keys(r).filter(u=>r[u].length===0);i.length===0?Y.throwArgumentError("missing primary type","types",t):i.length>1&&Y.throwArgumentError(`ambiguous primary types or unused types: ${i.map(u=>JSON.stringify(u)).join(", ")}`,"types",t),R(this,"primaryType",i[0]);function a(u,h){h[u]&&Y.throwArgumentError(`circular type reference to ${JSON.stringify(u)}`,"types",t),h[u]=!0,Object.keys(e[u]).forEach(d=>{r[d]&&(a(d,h),Object.keys(h).forEach(p=>{n[p][d]=!0}))}),delete h[u]}a(this.primaryType,{});for(const u in n){const h=Object.keys(n[u]);h.sort(),this._types[u]=Ni(u,t[u])+h.map(d=>Ni(d,t[d])).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const n=Br(t);if(n)return n}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const n=e[1],i=this.getEncoder(n),a=parseInt(e[3]);return u=>{a>=0&&u.length!==a&&Y.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",u);let h=u.map(i);return this._types[n]&&(h=h.map(Qt)),Qt(Wt(h))}}const r=this.types[t];if(r){const n=fn(this._types[t]);return i=>{const a=r.map(({name:u,type:h})=>{const d=this.getEncoder(h)(i[u]);return this._types[h]?Qt(d):d});return a.unshift(n),Wt(a)}}return Y.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||Y.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Qt(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(Br(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const a=n[1],u=parseInt(n[3]);return u>=0&&e.length!==u&&Y.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map(h=>this._visit(a,h,r))}const i=this.types[t];return i?i.reduce((a,{name:u,type:h})=>(a[u]=this._visit(h,e[u],r),a),{}):Y.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new jt(t)}static getPrimaryType(t){return jt.from(t).primaryType}static hashStruct(t,e,r){return jt.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=Ii[r];n||Y.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort((r,n)=>Tr.indexOf(r.name)-Tr.indexOf(n.name)),jt.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return Wt(["0x1901",jt.hashDomain(t),jt.from(e).hash(r)])}static hash(t,e,r){return Qt(jt.encode(t,e,r))}static resolveNames(t,e,r,n){return ms(this,void 0,void 0,function*(){t=Ct(t);const i={};t.verifyingContract&&!Bt(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const a=jt.from(e);a.visit(r,(u,h)=>(u==="address"&&!Bt(h,20)&&(i[h]="0x"),h));for(const u in i)i[u]=yield n(u);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=a.visit(r,(u,h)=>u==="address"&&i[h]?i[h]:h),{domain:t,value:r}})}static getPayload(t,e,r){jt.hashDomain(t);const n={},i=[];Tr.forEach(h=>{const d=t[h];d!=null&&(n[h]=ks[h](d),i.push({name:h,type:Ii[h]}))});const a=jt.from(e),u=Ct(e);return u.EIP712Domain?Y.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):u.EIP712Domain=i,a.encode(r),{types:u,domain:n,primaryType:a.primaryType,message:a.visit(r,(h,d)=>{if(h.match(/^bytes(\d*)/))return Q(K(d));if(h.match(/^u?int/))return O.from(d).toString();switch(h){case"address":return d.toLowerCase();case"bool":return!!d;case"string":return typeof d!="string"&&Y.throwArgumentError("invalid string","value",d),d}return Y.throwArgumentError("unsupported type","type",h)})}}}const Es="abstract-provider/5.7.0";var xs=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const Ms=new x(Es);class _s extends Dn{static isForkEvent(t){return!!(t&&t._isForkEvent)}}class lr{constructor(){Ms.checkAbstract(new.target,lr),R(this,"_isProvider",!0)}getFeeData(){return xs(this,void 0,void 0,function*(){const{block:t,gasPrice:e}=yield Lt({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(a=>null)});let r=null,n=null,i=null;return t&&t.baseFeePerGas&&(r=t.baseFeePerGas,i=O.from("1500000000"),n=t.baseFeePerGas.mul(2).add(i)),{lastBaseFeePerGas:r,maxFeePerGas:n,maxPriorityFeePerGas:i,gasPrice:e}})}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}static isProvider(t){return!!(t&&t._isProvider)}}const Is="abstract-signer/5.7.0";var ee=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const re=new x(Is),Ps=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],Ns=[x.errors.INSUFFICIENT_FUNDS,x.errors.NONCE_EXPIRED,x.errors.REPLACEMENT_UNDERPRICED];class Vr{constructor(){re.checkAbstract(new.target,Vr),R(this,"_isSigner",!0)}getBalance(t){return ee(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)})}getTransactionCount(t){return ee(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)})}estimateGas(t){return ee(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const e=yield Lt(this.checkTransaction(t));return yield this.provider.estimateGas(e)})}call(t,e){return ee(this,void 0,void 0,function*(){this._checkProvider("call");const r=yield Lt(this.checkTransaction(t));return yield this.provider.call(r,e)})}sendTransaction(t){return ee(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const e=yield this.populateTransaction(t),r=yield this.signTransaction(e);return yield this.provider.sendTransaction(r)})}getChainId(){return ee(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return ee(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return ee(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(t){return ee(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)})}checkTransaction(t){for(const r in t)Ps.indexOf(r)===-1&&re.throwArgumentError("invalid transaction key: "+r,"transaction",t);const e=Ct(t);return e.from==null?e.from=this.getAddress():e.from=Promise.all([Promise.resolve(e.from),this.getAddress()]).then(r=>(r[0].toLowerCase()!==r[1].toLowerCase()&&re.throwArgumentError("from address mismatch","transaction",t),r[0])),e}populateTransaction(t){return ee(this,void 0,void 0,function*(){const e=yield Lt(this.checkTransaction(t));e.to!=null&&(e.to=Promise.resolve(e.to).then(n=>ee(this,void 0,void 0,function*(){if(n==null)return null;const i=yield this.resolveName(n);return i==null&&re.throwArgumentError("provided ENS name resolves to null","tx.to",n),i})),e.to.catch(n=>{}));const r=e.maxFeePerGas!=null||e.maxPriorityFeePerGas!=null;if(e.gasPrice!=null&&(e.type===2||r)?re.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t):(e.type===0||e.type===1)&&r&&re.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t),(e.type===2||e.type==null)&&e.maxFeePerGas!=null&&e.maxPriorityFeePerGas!=null)e.type=2;else if(e.type===0||e.type===1)e.gasPrice==null&&(e.gasPrice=this.getGasPrice());else{const n=yield this.getFeeData();if(e.type==null)if(n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)if(e.type=2,e.gasPrice!=null){const i=e.gasPrice;delete e.gasPrice,e.maxFeePerGas=i,e.maxPriorityFeePerGas=i}else e.maxFeePerGas==null&&(e.maxFeePerGas=n.maxFeePerGas),e.maxPriorityFeePerGas==null&&(e.maxPriorityFeePerGas=n.maxPriorityFeePerGas);else n.gasPrice!=null?(r&&re.throwError("network does not support EIP-1559",x.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),e.gasPrice==null&&(e.gasPrice=n.gasPrice),e.type=0):re.throwError("failed to get consistent fee data",x.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else e.type===2&&(e.maxFeePerGas==null&&(e.maxFeePerGas=n.maxFeePerGas),e.maxPriorityFeePerGas==null&&(e.maxPriorityFeePerGas=n.maxPriorityFeePerGas))}return e.nonce==null&&(e.nonce=this.getTransactionCount("pending")),e.gasLimit==null&&(e.gasLimit=this.estimateGas(e).catch(n=>{if(Ns.indexOf(n.code)>=0)throw n;return re.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",x.errors.UNPREDICTABLE_GAS_LIMIT,{error:n,tx:e})})),e.chainId==null?e.chainId=this.getChainId():e.chainId=Promise.all([Promise.resolve(e.chainId),this.getChainId()]).then(n=>(n[1]!==0&&n[0]!==n[1]&&re.throwArgumentError("chainId address mismatch","transaction",t),n[0])),yield Lt(e)})}_checkProvider(t){this.provider||re.throwError("missing provider",x.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!!(t&&t._isSigner)}}var Kr={},Ss={get exports(){return Kr},set exports(s){Kr=s}};(function(s){(function(t,e){function r(y,o){if(!y)throw new Error(o||"Assertion failed")}function n(y,o){y.super_=o;var l=function(){};l.prototype=o.prototype,y.prototype=new l,y.prototype.constructor=y}function i(y,o,l){if(i.isBN(y))return y;this.negative=0,this.words=null,this.length=0,this.red=null,y!==null&&((o==="le"||o==="be")&&(l=o,o=10),this._init(y||0,o||10,l||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var a;try{typeof window<"u"&&typeof window.Buffer<"u"?a=window.Buffer:a=qn.Buffer}catch{}i.isBN=function(o){return o instanceof i?!0:o!==null&&typeof o=="object"&&o.constructor.wordSize===i.wordSize&&Array.isArray(o.words)},i.max=function(o,l){return o.cmp(l)>0?o:l},i.min=function(o,l){return o.cmp(l)<0?o:l},i.prototype._init=function(o,l,c){if(typeof o=="number")return this._initNumber(o,l,c);if(typeof o=="object")return this._initArray(o,l,c);l==="hex"&&(l=16),r(l===(l|0)&&l>=2&&l<=36),o=o.toString().replace(/\s+/g,"");var m=0;o[0]==="-"&&(m++,this.negative=1),m<o.length&&(l===16?this._parseHex(o,m,c):(this._parseBase(o,l,m),c==="le"&&this._initArray(this.toArray(),l,c)))},i.prototype._initNumber=function(o,l,c){o<0&&(this.negative=1,o=-o),o<67108864?(this.words=[o&67108863],this.length=1):o<4503599627370496?(this.words=[o&67108863,o/67108864&67108863],this.length=2):(r(o<9007199254740992),this.words=[o&67108863,o/67108864&67108863,1],this.length=3),c==="le"&&this._initArray(this.toArray(),l,c)},i.prototype._initArray=function(o,l,c){if(r(typeof o.length=="number"),o.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(o.length/3),this.words=new Array(this.length);for(var m=0;m<this.length;m++)this.words[m]=0;var w,b,k=0;if(c==="be")for(m=o.length-1,w=0;m>=0;m-=3)b=o[m]|o[m-1]<<8|o[m-2]<<16,this.words[w]|=b<<k&67108863,this.words[w+1]=b>>>26-k&67108863,k+=24,k>=26&&(k-=26,w++);else if(c==="le")for(m=0,w=0;m<o.length;m+=3)b=o[m]|o[m+1]<<8|o[m+2]<<16,this.words[w]|=b<<k&67108863,this.words[w+1]=b>>>26-k&67108863,k+=24,k>=26&&(k-=26,w++);return this._strip()};function u(y,o){var l=y.charCodeAt(o);if(l>=48&&l<=57)return l-48;if(l>=65&&l<=70)return l-55;if(l>=97&&l<=102)return l-87;r(!1,"Invalid character in "+y)}function h(y,o,l){var c=u(y,l);return l-1>=o&&(c|=u(y,l-1)<<4),c}i.prototype._parseHex=function(o,l,c){this.length=Math.ceil((o.length-l)/6),this.words=new Array(this.length);for(var m=0;m<this.length;m++)this.words[m]=0;var w=0,b=0,k;if(c==="be")for(m=o.length-1;m>=l;m-=2)k=h(o,l,m)<<w,this.words[b]|=k&67108863,w>=18?(w-=18,b+=1,this.words[b]|=k>>>26):w+=8;else{var g=o.length-l;for(m=g%2===0?l+1:l;m<o.length;m+=2)k=h(o,l,m)<<w,this.words[b]|=k&67108863,w>=18?(w-=18,b+=1,this.words[b]|=k>>>26):w+=8}this._strip()};function d(y,o,l,c){for(var m=0,w=0,b=Math.min(y.length,l),k=o;k<b;k++){var g=y.charCodeAt(k)-48;m*=c,g>=49?w=g-49+10:g>=17?w=g-17+10:w=g,r(g>=0&&w<c,"Invalid character"),m+=w}return m}i.prototype._parseBase=function(o,l,c){this.words=[0],this.length=1;for(var m=0,w=1;w<=67108863;w*=l)m++;m--,w=w/l|0;for(var b=o.length-c,k=b%m,g=Math.min(b,b-k)+c,f=0,v=c;v<g;v+=m)f=d(o,v,v+m,l),this.imuln(w),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(k!==0){var C=1;for(f=d(o,v,o.length,l),v=0;v<k;v++)C*=l;this.imuln(C),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},i.prototype.copy=function(o){o.words=new Array(this.length);for(var l=0;l<this.length;l++)o.words[l]=this.words[l];o.length=this.length,o.negative=this.negative,o.red=this.red};function p(y,o){y.words=o.words,y.length=o.length,y.negative=o.negative,y.red=o.red}if(i.prototype._move=function(o){p(o,this)},i.prototype.clone=function(){var o=new i(null);return this.copy(o),o},i.prototype._expand=function(o){for(;this.length<o;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=A}catch{i.prototype.inspect=A}else i.prototype.inspect=A;function A(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var M=["","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"],E=[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],_=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(o,l){o=o||10,l=l|0||1;var c;if(o===16||o==="hex"){c="";for(var m=0,w=0,b=0;b<this.length;b++){var k=this.words[b],g=((k<<m|w)&16777215).toString(16);w=k>>>24-m&16777215,m+=2,m>=26&&(m-=26,b--),w!==0||b!==this.length-1?c=M[6-g.length]+g+c:c=g+c}for(w!==0&&(c=w.toString(16)+c);c.length%l!==0;)c="0"+c;return this.negative!==0&&(c="-"+c),c}if(o===(o|0)&&o>=2&&o<=36){var f=E[o],v=_[o];c="";var C=this.clone();for(C.negative=0;!C.isZero();){var B=C.modrn(v).toString(o);C=C.idivn(v),C.isZero()?c=B+c:c=M[f-B.length]+B+c}for(this.isZero()&&(c="0"+c);c.length%l!==0;)c="0"+c;return this.negative!==0&&(c="-"+c),c}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var o=this.words[0];return this.length===2?o+=this.words[1]*67108864:this.length===3&&this.words[2]===1?o+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-o:o},i.prototype.toJSON=function(){return this.toString(16,2)},a&&(i.prototype.toBuffer=function(o,l){return this.toArrayLike(a,o,l)}),i.prototype.toArray=function(o,l){return this.toArrayLike(Array,o,l)};var I=function(o,l){return o.allocUnsafe?o.allocUnsafe(l):new o(l)};i.prototype.toArrayLike=function(o,l,c){this._strip();var m=this.byteLength(),w=c||Math.max(1,m);r(m<=w,"byte array longer than desired length"),r(w>0,"Requested array length <= 0");var b=I(o,w),k=l==="le"?"LE":"BE";return this["_toArrayLike"+k](b,m),b},i.prototype._toArrayLikeLE=function(o,l){for(var c=0,m=0,w=0,b=0;w<this.length;w++){var k=this.words[w]<<b|m;o[c++]=k&255,c<o.length&&(o[c++]=k>>8&255),c<o.length&&(o[c++]=k>>16&255),b===6?(c<o.length&&(o[c++]=k>>24&255),m=0,b=0):(m=k>>>24,b+=2)}if(c<o.length)for(o[c++]=m;c<o.length;)o[c++]=0},i.prototype._toArrayLikeBE=function(o,l){for(var c=o.length-1,m=0,w=0,b=0;w<this.length;w++){var k=this.words[w]<<b|m;o[c--]=k&255,c>=0&&(o[c--]=k>>8&255),c>=0&&(o[c--]=k>>16&255),b===6?(c>=0&&(o[c--]=k>>24&255),m=0,b=0):(m=k>>>24,b+=2)}if(c>=0)for(o[c--]=m;c>=0;)o[c--]=0},Math.clz32?i.prototype._countBits=function(o){return 32-Math.clz32(o)}:i.prototype._countBits=function(o){var l=o,c=0;return l>=4096&&(c+=13,l>>>=13),l>=64&&(c+=7,l>>>=7),l>=8&&(c+=4,l>>>=4),l>=2&&(c+=2,l>>>=2),c+l},i.prototype._zeroBits=function(o){if(o===0)return 26;var l=o,c=0;return l&8191||(c+=13,l>>>=13),l&127||(c+=7,l>>>=7),l&15||(c+=4,l>>>=4),l&3||(c+=2,l>>>=2),l&1||c++,c},i.prototype.bitLength=function(){var o=this.words[this.length-1],l=this._countBits(o);return(this.length-1)*26+l};function T(y){for(var o=new Array(y.bitLength()),l=0;l<o.length;l++){var c=l/26|0,m=l%26;o[l]=y.words[c]>>>m&1}return o}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var o=0,l=0;l<this.length;l++){var c=this._zeroBits(this.words[l]);if(o+=c,c!==26)break}return o},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(o){return this.negative!==0?this.abs().inotn(o).iaddn(1):this.clone()},i.prototype.fromTwos=function(o){return this.testn(o-1)?this.notn(o).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(o){for(;this.length<o.length;)this.words[this.length++]=0;for(var l=0;l<o.length;l++)this.words[l]=this.words[l]|o.words[l];return this._strip()},i.prototype.ior=function(o){return r((this.negative|o.negative)===0),this.iuor(o)},i.prototype.or=function(o){return this.length>o.length?this.clone().ior(o):o.clone().ior(this)},i.prototype.uor=function(o){return this.length>o.length?this.clone().iuor(o):o.clone().iuor(this)},i.prototype.iuand=function(o){var l;this.length>o.length?l=o:l=this;for(var c=0;c<l.length;c++)this.words[c]=this.words[c]&o.words[c];return this.length=l.length,this._strip()},i.prototype.iand=function(o){return r((this.negative|o.negative)===0),this.iuand(o)},i.prototype.and=function(o){return this.length>o.length?this.clone().iand(o):o.clone().iand(this)},i.prototype.uand=function(o){return this.length>o.length?this.clone().iuand(o):o.clone().iuand(this)},i.prototype.iuxor=function(o){var l,c;this.length>o.length?(l=this,c=o):(l=o,c=this);for(var m=0;m<c.length;m++)this.words[m]=l.words[m]^c.words[m];if(this!==l)for(;m<l.length;m++)this.words[m]=l.words[m];return this.length=l.length,this._strip()},i.prototype.ixor=function(o){return r((this.negative|o.negative)===0),this.iuxor(o)},i.prototype.xor=function(o){return this.length>o.length?this.clone().ixor(o):o.clone().ixor(this)},i.prototype.uxor=function(o){return this.length>o.length?this.clone().iuxor(o):o.clone().iuxor(this)},i.prototype.inotn=function(o){r(typeof o=="number"&&o>=0);var l=Math.ceil(o/26)|0,c=o%26;this._expand(l),c>0&&l--;for(var m=0;m<l;m++)this.words[m]=~this.words[m]&67108863;return c>0&&(this.words[m]=~this.words[m]&67108863>>26-c),this._strip()},i.prototype.notn=function(o){return this.clone().inotn(o)},i.prototype.setn=function(o,l){r(typeof o=="number"&&o>=0);var c=o/26|0,m=o%26;return this._expand(c+1),l?this.words[c]=this.words[c]|1<<m:this.words[c]=this.words[c]&~(1<<m),this._strip()},i.prototype.iadd=function(o){var l;if(this.negative!==0&&o.negative===0)return this.negative=0,l=this.isub(o),this.negative^=1,this._normSign();if(this.negative===0&&o.negative!==0)return o.negative=0,l=this.isub(o),o.negative=1,l._normSign();var c,m;this.length>o.length?(c=this,m=o):(c=o,m=this);for(var w=0,b=0;b<m.length;b++)l=(c.words[b]|0)+(m.words[b]|0)+w,this.words[b]=l&67108863,w=l>>>26;for(;w!==0&&b<c.length;b++)l=(c.words[b]|0)+w,this.words[b]=l&67108863,w=l>>>26;if(this.length=c.length,w!==0)this.words[this.length]=w,this.length++;else if(c!==this)for(;b<c.length;b++)this.words[b]=c.words[b];return this},i.prototype.add=function(o){var l;return o.negative!==0&&this.negative===0?(o.negative=0,l=this.sub(o),o.negative^=1,l):o.negative===0&&this.negative!==0?(this.negative=0,l=o.sub(this),this.negative=1,l):this.length>o.length?this.clone().iadd(o):o.clone().iadd(this)},i.prototype.isub=function(o){if(o.negative!==0){o.negative=0;var l=this.iadd(o);return o.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(o),this.negative=1,this._normSign();var c=this.cmp(o);if(c===0)return this.negative=0,this.length=1,this.words[0]=0,this;var m,w;c>0?(m=this,w=o):(m=o,w=this);for(var b=0,k=0;k<w.length;k++)l=(m.words[k]|0)-(w.words[k]|0)+b,b=l>>26,this.words[k]=l&67108863;for(;b!==0&&k<m.length;k++)l=(m.words[k]|0)+b,b=l>>26,this.words[k]=l&67108863;if(b===0&&k<m.length&&m!==this)for(;k<m.length;k++)this.words[k]=m.words[k];return this.length=Math.max(this.length,k),m!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(o){return this.clone().isub(o)};function P(y,o,l){l.negative=o.negative^y.negative;var c=y.length+o.length|0;l.length=c,c=c-1|0;var m=y.words[0]|0,w=o.words[0]|0,b=m*w,k=b&67108863,g=b/67108864|0;l.words[0]=k;for(var f=1;f<c;f++){for(var v=g>>>26,C=g&67108863,B=Math.min(f,o.length-1),L=Math.max(0,f-y.length+1);L<=B;L++){var Ut=f-L|0;m=y.words[Ut]|0,w=o.words[L]|0,b=m*w+C,v+=b/67108864|0,C=b&67108863}l.words[f]=C|0,g=v|0}return g!==0?l.words[f]=g|0:l.length--,l._strip()}var S=function(o,l,c){var m=o.words,w=l.words,b=c.words,k=0,g,f,v,C=m[0]|0,B=C&8191,L=C>>>13,Ut=m[1]|0,H=Ut&8191,j=Ut>>>13,ni=m[2]|0,X=ni&8191,V=ni>>>13,si=m[3]|0,Z=si&8191,$=si>>>13,oi=m[4]|0,tt=oi&8191,et=oi>>>13,ai=m[5]|0,rt=ai&8191,it=ai>>>13,fi=m[6]|0,nt=fi&8191,st=fi>>>13,li=m[7]|0,ot=li&8191,at=li>>>13,ui=m[8]|0,ft=ui&8191,lt=ui>>>13,hi=m[9]|0,ut=hi&8191,ht=hi>>>13,ci=w[0]|0,ct=ci&8191,dt=ci>>>13,di=w[1]|0,pt=di&8191,gt=di>>>13,pi=w[2]|0,mt=pi&8191,vt=pi>>>13,gi=w[3]|0,wt=gi&8191,yt=gi>>>13,mi=w[4]|0,At=mi&8191,bt=mi>>>13,vi=w[5]|0,kt=vi&8191,Et=vi>>>13,wi=w[6]|0,xt=wi&8191,Mt=wi>>>13,yi=w[7]|0,_t=yi&8191,It=yi>>>13,Ai=w[8]|0,Pt=Ai&8191,Nt=Ai>>>13,bi=w[9]|0,St=bi&8191,Rt=bi>>>13;c.negative=o.negative^l.negative,c.length=19,g=Math.imul(B,ct),f=Math.imul(B,dt),f=f+Math.imul(L,ct)|0,v=Math.imul(L,dt);var dr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(dr>>>26)|0,dr&=67108863,g=Math.imul(H,ct),f=Math.imul(H,dt),f=f+Math.imul(j,ct)|0,v=Math.imul(j,dt),g=g+Math.imul(B,pt)|0,f=f+Math.imul(B,gt)|0,f=f+Math.imul(L,pt)|0,v=v+Math.imul(L,gt)|0;var pr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(pr>>>26)|0,pr&=67108863,g=Math.imul(X,ct),f=Math.imul(X,dt),f=f+Math.imul(V,ct)|0,v=Math.imul(V,dt),g=g+Math.imul(H,pt)|0,f=f+Math.imul(H,gt)|0,f=f+Math.imul(j,pt)|0,v=v+Math.imul(j,gt)|0,g=g+Math.imul(B,mt)|0,f=f+Math.imul(B,vt)|0,f=f+Math.imul(L,mt)|0,v=v+Math.imul(L,vt)|0;var gr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(gr>>>26)|0,gr&=67108863,g=Math.imul(Z,ct),f=Math.imul(Z,dt),f=f+Math.imul($,ct)|0,v=Math.imul($,dt),g=g+Math.imul(X,pt)|0,f=f+Math.imul(X,gt)|0,f=f+Math.imul(V,pt)|0,v=v+Math.imul(V,gt)|0,g=g+Math.imul(H,mt)|0,f=f+Math.imul(H,vt)|0,f=f+Math.imul(j,mt)|0,v=v+Math.imul(j,vt)|0,g=g+Math.imul(B,wt)|0,f=f+Math.imul(B,yt)|0,f=f+Math.imul(L,wt)|0,v=v+Math.imul(L,yt)|0;var mr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(mr>>>26)|0,mr&=67108863,g=Math.imul(tt,ct),f=Math.imul(tt,dt),f=f+Math.imul(et,ct)|0,v=Math.imul(et,dt),g=g+Math.imul(Z,pt)|0,f=f+Math.imul(Z,gt)|0,f=f+Math.imul($,pt)|0,v=v+Math.imul($,gt)|0,g=g+Math.imul(X,mt)|0,f=f+Math.imul(X,vt)|0,f=f+Math.imul(V,mt)|0,v=v+Math.imul(V,vt)|0,g=g+Math.imul(H,wt)|0,f=f+Math.imul(H,yt)|0,f=f+Math.imul(j,wt)|0,v=v+Math.imul(j,yt)|0,g=g+Math.imul(B,At)|0,f=f+Math.imul(B,bt)|0,f=f+Math.imul(L,At)|0,v=v+Math.imul(L,bt)|0;var vr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(vr>>>26)|0,vr&=67108863,g=Math.imul(rt,ct),f=Math.imul(rt,dt),f=f+Math.imul(it,ct)|0,v=Math.imul(it,dt),g=g+Math.imul(tt,pt)|0,f=f+Math.imul(tt,gt)|0,f=f+Math.imul(et,pt)|0,v=v+Math.imul(et,gt)|0,g=g+Math.imul(Z,mt)|0,f=f+Math.imul(Z,vt)|0,f=f+Math.imul($,mt)|0,v=v+Math.imul($,vt)|0,g=g+Math.imul(X,wt)|0,f=f+Math.imul(X,yt)|0,f=f+Math.imul(V,wt)|0,v=v+Math.imul(V,yt)|0,g=g+Math.imul(H,At)|0,f=f+Math.imul(H,bt)|0,f=f+Math.imul(j,At)|0,v=v+Math.imul(j,bt)|0,g=g+Math.imul(B,kt)|0,f=f+Math.imul(B,Et)|0,f=f+Math.imul(L,kt)|0,v=v+Math.imul(L,Et)|0;var wr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(wr>>>26)|0,wr&=67108863,g=Math.imul(nt,ct),f=Math.imul(nt,dt),f=f+Math.imul(st,ct)|0,v=Math.imul(st,dt),g=g+Math.imul(rt,pt)|0,f=f+Math.imul(rt,gt)|0,f=f+Math.imul(it,pt)|0,v=v+Math.imul(it,gt)|0,g=g+Math.imul(tt,mt)|0,f=f+Math.imul(tt,vt)|0,f=f+Math.imul(et,mt)|0,v=v+Math.imul(et,vt)|0,g=g+Math.imul(Z,wt)|0,f=f+Math.imul(Z,yt)|0,f=f+Math.imul($,wt)|0,v=v+Math.imul($,yt)|0,g=g+Math.imul(X,At)|0,f=f+Math.imul(X,bt)|0,f=f+Math.imul(V,At)|0,v=v+Math.imul(V,bt)|0,g=g+Math.imul(H,kt)|0,f=f+Math.imul(H,Et)|0,f=f+Math.imul(j,kt)|0,v=v+Math.imul(j,Et)|0,g=g+Math.imul(B,xt)|0,f=f+Math.imul(B,Mt)|0,f=f+Math.imul(L,xt)|0,v=v+Math.imul(L,Mt)|0;var yr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(yr>>>26)|0,yr&=67108863,g=Math.imul(ot,ct),f=Math.imul(ot,dt),f=f+Math.imul(at,ct)|0,v=Math.imul(at,dt),g=g+Math.imul(nt,pt)|0,f=f+Math.imul(nt,gt)|0,f=f+Math.imul(st,pt)|0,v=v+Math.imul(st,gt)|0,g=g+Math.imul(rt,mt)|0,f=f+Math.imul(rt,vt)|0,f=f+Math.imul(it,mt)|0,v=v+Math.imul(it,vt)|0,g=g+Math.imul(tt,wt)|0,f=f+Math.imul(tt,yt)|0,f=f+Math.imul(et,wt)|0,v=v+Math.imul(et,yt)|0,g=g+Math.imul(Z,At)|0,f=f+Math.imul(Z,bt)|0,f=f+Math.imul($,At)|0,v=v+Math.imul($,bt)|0,g=g+Math.imul(X,kt)|0,f=f+Math.imul(X,Et)|0,f=f+Math.imul(V,kt)|0,v=v+Math.imul(V,Et)|0,g=g+Math.imul(H,xt)|0,f=f+Math.imul(H,Mt)|0,f=f+Math.imul(j,xt)|0,v=v+Math.imul(j,Mt)|0,g=g+Math.imul(B,_t)|0,f=f+Math.imul(B,It)|0,f=f+Math.imul(L,_t)|0,v=v+Math.imul(L,It)|0;var Ar=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(Ar>>>26)|0,Ar&=67108863,g=Math.imul(ft,ct),f=Math.imul(ft,dt),f=f+Math.imul(lt,ct)|0,v=Math.imul(lt,dt),g=g+Math.imul(ot,pt)|0,f=f+Math.imul(ot,gt)|0,f=f+Math.imul(at,pt)|0,v=v+Math.imul(at,gt)|0,g=g+Math.imul(nt,mt)|0,f=f+Math.imul(nt,vt)|0,f=f+Math.imul(st,mt)|0,v=v+Math.imul(st,vt)|0,g=g+Math.imul(rt,wt)|0,f=f+Math.imul(rt,yt)|0,f=f+Math.imul(it,wt)|0,v=v+Math.imul(it,yt)|0,g=g+Math.imul(tt,At)|0,f=f+Math.imul(tt,bt)|0,f=f+Math.imul(et,At)|0,v=v+Math.imul(et,bt)|0,g=g+Math.imul(Z,kt)|0,f=f+Math.imul(Z,Et)|0,f=f+Math.imul($,kt)|0,v=v+Math.imul($,Et)|0,g=g+Math.imul(X,xt)|0,f=f+Math.imul(X,Mt)|0,f=f+Math.imul(V,xt)|0,v=v+Math.imul(V,Mt)|0,g=g+Math.imul(H,_t)|0,f=f+Math.imul(H,It)|0,f=f+Math.imul(j,_t)|0,v=v+Math.imul(j,It)|0,g=g+Math.imul(B,Pt)|0,f=f+Math.imul(B,Nt)|0,f=f+Math.imul(L,Pt)|0,v=v+Math.imul(L,Nt)|0;var br=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(br>>>26)|0,br&=67108863,g=Math.imul(ut,ct),f=Math.imul(ut,dt),f=f+Math.imul(ht,ct)|0,v=Math.imul(ht,dt),g=g+Math.imul(ft,pt)|0,f=f+Math.imul(ft,gt)|0,f=f+Math.imul(lt,pt)|0,v=v+Math.imul(lt,gt)|0,g=g+Math.imul(ot,mt)|0,f=f+Math.imul(ot,vt)|0,f=f+Math.imul(at,mt)|0,v=v+Math.imul(at,vt)|0,g=g+Math.imul(nt,wt)|0,f=f+Math.imul(nt,yt)|0,f=f+Math.imul(st,wt)|0,v=v+Math.imul(st,yt)|0,g=g+Math.imul(rt,At)|0,f=f+Math.imul(rt,bt)|0,f=f+Math.imul(it,At)|0,v=v+Math.imul(it,bt)|0,g=g+Math.imul(tt,kt)|0,f=f+Math.imul(tt,Et)|0,f=f+Math.imul(et,kt)|0,v=v+Math.imul(et,Et)|0,g=g+Math.imul(Z,xt)|0,f=f+Math.imul(Z,Mt)|0,f=f+Math.imul($,xt)|0,v=v+Math.imul($,Mt)|0,g=g+Math.imul(X,_t)|0,f=f+Math.imul(X,It)|0,f=f+Math.imul(V,_t)|0,v=v+Math.imul(V,It)|0,g=g+Math.imul(H,Pt)|0,f=f+Math.imul(H,Nt)|0,f=f+Math.imul(j,Pt)|0,v=v+Math.imul(j,Nt)|0,g=g+Math.imul(B,St)|0,f=f+Math.imul(B,Rt)|0,f=f+Math.imul(L,St)|0,v=v+Math.imul(L,Rt)|0;var kr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(kr>>>26)|0,kr&=67108863,g=Math.imul(ut,pt),f=Math.imul(ut,gt),f=f+Math.imul(ht,pt)|0,v=Math.imul(ht,gt),g=g+Math.imul(ft,mt)|0,f=f+Math.imul(ft,vt)|0,f=f+Math.imul(lt,mt)|0,v=v+Math.imul(lt,vt)|0,g=g+Math.imul(ot,wt)|0,f=f+Math.imul(ot,yt)|0,f=f+Math.imul(at,wt)|0,v=v+Math.imul(at,yt)|0,g=g+Math.imul(nt,At)|0,f=f+Math.imul(nt,bt)|0,f=f+Math.imul(st,At)|0,v=v+Math.imul(st,bt)|0,g=g+Math.imul(rt,kt)|0,f=f+Math.imul(rt,Et)|0,f=f+Math.imul(it,kt)|0,v=v+Math.imul(it,Et)|0,g=g+Math.imul(tt,xt)|0,f=f+Math.imul(tt,Mt)|0,f=f+Math.imul(et,xt)|0,v=v+Math.imul(et,Mt)|0,g=g+Math.imul(Z,_t)|0,f=f+Math.imul(Z,It)|0,f=f+Math.imul($,_t)|0,v=v+Math.imul($,It)|0,g=g+Math.imul(X,Pt)|0,f=f+Math.imul(X,Nt)|0,f=f+Math.imul(V,Pt)|0,v=v+Math.imul(V,Nt)|0,g=g+Math.imul(H,St)|0,f=f+Math.imul(H,Rt)|0,f=f+Math.imul(j,St)|0,v=v+Math.imul(j,Rt)|0;var Er=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(Er>>>26)|0,Er&=67108863,g=Math.imul(ut,mt),f=Math.imul(ut,vt),f=f+Math.imul(ht,mt)|0,v=Math.imul(ht,vt),g=g+Math.imul(ft,wt)|0,f=f+Math.imul(ft,yt)|0,f=f+Math.imul(lt,wt)|0,v=v+Math.imul(lt,yt)|0,g=g+Math.imul(ot,At)|0,f=f+Math.imul(ot,bt)|0,f=f+Math.imul(at,At)|0,v=v+Math.imul(at,bt)|0,g=g+Math.imul(nt,kt)|0,f=f+Math.imul(nt,Et)|0,f=f+Math.imul(st,kt)|0,v=v+Math.imul(st,Et)|0,g=g+Math.imul(rt,xt)|0,f=f+Math.imul(rt,Mt)|0,f=f+Math.imul(it,xt)|0,v=v+Math.imul(it,Mt)|0,g=g+Math.imul(tt,_t)|0,f=f+Math.imul(tt,It)|0,f=f+Math.imul(et,_t)|0,v=v+Math.imul(et,It)|0,g=g+Math.imul(Z,Pt)|0,f=f+Math.imul(Z,Nt)|0,f=f+Math.imul($,Pt)|0,v=v+Math.imul($,Nt)|0,g=g+Math.imul(X,St)|0,f=f+Math.imul(X,Rt)|0,f=f+Math.imul(V,St)|0,v=v+Math.imul(V,Rt)|0;var xr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(xr>>>26)|0,xr&=67108863,g=Math.imul(ut,wt),f=Math.imul(ut,yt),f=f+Math.imul(ht,wt)|0,v=Math.imul(ht,yt),g=g+Math.imul(ft,At)|0,f=f+Math.imul(ft,bt)|0,f=f+Math.imul(lt,At)|0,v=v+Math.imul(lt,bt)|0,g=g+Math.imul(ot,kt)|0,f=f+Math.imul(ot,Et)|0,f=f+Math.imul(at,kt)|0,v=v+Math.imul(at,Et)|0,g=g+Math.imul(nt,xt)|0,f=f+Math.imul(nt,Mt)|0,f=f+Math.imul(st,xt)|0,v=v+Math.imul(st,Mt)|0,g=g+Math.imul(rt,_t)|0,f=f+Math.imul(rt,It)|0,f=f+Math.imul(it,_t)|0,v=v+Math.imul(it,It)|0,g=g+Math.imul(tt,Pt)|0,f=f+Math.imul(tt,Nt)|0,f=f+Math.imul(et,Pt)|0,v=v+Math.imul(et,Nt)|0,g=g+Math.imul(Z,St)|0,f=f+Math.imul(Z,Rt)|0,f=f+Math.imul($,St)|0,v=v+Math.imul($,Rt)|0;var Mr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(Mr>>>26)|0,Mr&=67108863,g=Math.imul(ut,At),f=Math.imul(ut,bt),f=f+Math.imul(ht,At)|0,v=Math.imul(ht,bt),g=g+Math.imul(ft,kt)|0,f=f+Math.imul(ft,Et)|0,f=f+Math.imul(lt,kt)|0,v=v+Math.imul(lt,Et)|0,g=g+Math.imul(ot,xt)|0,f=f+Math.imul(ot,Mt)|0,f=f+Math.imul(at,xt)|0,v=v+Math.imul(at,Mt)|0,g=g+Math.imul(nt,_t)|0,f=f+Math.imul(nt,It)|0,f=f+Math.imul(st,_t)|0,v=v+Math.imul(st,It)|0,g=g+Math.imul(rt,Pt)|0,f=f+Math.imul(rt,Nt)|0,f=f+Math.imul(it,Pt)|0,v=v+Math.imul(it,Nt)|0,g=g+Math.imul(tt,St)|0,f=f+Math.imul(tt,Rt)|0,f=f+Math.imul(et,St)|0,v=v+Math.imul(et,Rt)|0;var _r=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(_r>>>26)|0,_r&=67108863,g=Math.imul(ut,kt),f=Math.imul(ut,Et),f=f+Math.imul(ht,kt)|0,v=Math.imul(ht,Et),g=g+Math.imul(ft,xt)|0,f=f+Math.imul(ft,Mt)|0,f=f+Math.imul(lt,xt)|0,v=v+Math.imul(lt,Mt)|0,g=g+Math.imul(ot,_t)|0,f=f+Math.imul(ot,It)|0,f=f+Math.imul(at,_t)|0,v=v+Math.imul(at,It)|0,g=g+Math.imul(nt,Pt)|0,f=f+Math.imul(nt,Nt)|0,f=f+Math.imul(st,Pt)|0,v=v+Math.imul(st,Nt)|0,g=g+Math.imul(rt,St)|0,f=f+Math.imul(rt,Rt)|0,f=f+Math.imul(it,St)|0,v=v+Math.imul(it,Rt)|0;var Ir=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(Ir>>>26)|0,Ir&=67108863,g=Math.imul(ut,xt),f=Math.imul(ut,Mt),f=f+Math.imul(ht,xt)|0,v=Math.imul(ht,Mt),g=g+Math.imul(ft,_t)|0,f=f+Math.imul(ft,It)|0,f=f+Math.imul(lt,_t)|0,v=v+Math.imul(lt,It)|0,g=g+Math.imul(ot,Pt)|0,f=f+Math.imul(ot,Nt)|0,f=f+Math.imul(at,Pt)|0,v=v+Math.imul(at,Nt)|0,g=g+Math.imul(nt,St)|0,f=f+Math.imul(nt,Rt)|0,f=f+Math.imul(st,St)|0,v=v+Math.imul(st,Rt)|0;var Pr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,g=Math.imul(ut,_t),f=Math.imul(ut,It),f=f+Math.imul(ht,_t)|0,v=Math.imul(ht,It),g=g+Math.imul(ft,Pt)|0,f=f+Math.imul(ft,Nt)|0,f=f+Math.imul(lt,Pt)|0,v=v+Math.imul(lt,Nt)|0,g=g+Math.imul(ot,St)|0,f=f+Math.imul(ot,Rt)|0,f=f+Math.imul(at,St)|0,v=v+Math.imul(at,Rt)|0;var Nr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,g=Math.imul(ut,Pt),f=Math.imul(ut,Nt),f=f+Math.imul(ht,Pt)|0,v=Math.imul(ht,Nt),g=g+Math.imul(ft,St)|0,f=f+Math.imul(ft,Rt)|0,f=f+Math.imul(lt,St)|0,v=v+Math.imul(lt,Rt)|0;var Sr=(k+g|0)+((f&8191)<<13)|0;k=(v+(f>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,g=Math.imul(ut,St),f=Math.imul(ut,Rt),f=f+Math.imul(ht,St)|0,v=Math.imul(ht,Rt);var Rr=(k+g|0)+((f&8191)<<13)|0;return k=(v+(f>>>13)|0)+(Rr>>>26)|0,Rr&=67108863,b[0]=dr,b[1]=pr,b[2]=gr,b[3]=mr,b[4]=vr,b[5]=wr,b[6]=yr,b[7]=Ar,b[8]=br,b[9]=kr,b[10]=Er,b[11]=xr,b[12]=Mr,b[13]=_r,b[14]=Ir,b[15]=Pr,b[16]=Nr,b[17]=Sr,b[18]=Rr,k!==0&&(b[19]=k,c.length++),c};Math.imul||(S=P);function G(y,o,l){l.negative=o.negative^y.negative,l.length=y.length+o.length;for(var c=0,m=0,w=0;w<l.length-1;w++){var b=m;m=0;for(var k=c&67108863,g=Math.min(w,o.length-1),f=Math.max(0,w-y.length+1);f<=g;f++){var v=w-f,C=y.words[v]|0,B=o.words[f]|0,L=C*B,Ut=L&67108863;b=b+(L/67108864|0)|0,Ut=Ut+k|0,k=Ut&67108863,b=b+(Ut>>>26)|0,m+=b>>>26,b&=67108863}l.words[w]=k,c=b,b=m}return c!==0?l.words[w]=c:l.length--,l._strip()}function J(y,o,l){return G(y,o,l)}i.prototype.mulTo=function(o,l){var c,m=this.length+o.length;return this.length===10&&o.length===10?c=S(this,o,l):m<63?c=P(this,o,l):m<1024?c=G(this,o,l):c=J(this,o,l),c},i.prototype.mul=function(o){var l=new i(null);return l.words=new Array(this.length+o.length),this.mulTo(o,l)},i.prototype.mulf=function(o){var l=new i(null);return l.words=new Array(this.length+o.length),J(this,o,l)},i.prototype.imul=function(o){return this.clone().mulTo(o,this)},i.prototype.imuln=function(o){var l=o<0;l&&(o=-o),r(typeof o=="number"),r(o<67108864);for(var c=0,m=0;m<this.length;m++){var w=(this.words[m]|0)*o,b=(w&67108863)+(c&67108863);c>>=26,c+=w/67108864|0,c+=b>>>26,this.words[m]=b&67108863}return c!==0&&(this.words[m]=c,this.length++),l?this.ineg():this},i.prototype.muln=function(o){return this.clone().imuln(o)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(o){var l=T(o);if(l.length===0)return new i(1);for(var c=this,m=0;m<l.length&&l[m]===0;m++,c=c.sqr());if(++m<l.length)for(var w=c.sqr();m<l.length;m++,w=w.sqr())l[m]!==0&&(c=c.mul(w));return c},i.prototype.iushln=function(o){r(typeof o=="number"&&o>=0);var l=o%26,c=(o-l)/26,m=67108863>>>26-l<<26-l,w;if(l!==0){var b=0;for(w=0;w<this.length;w++){var k=this.words[w]&m,g=(this.words[w]|0)-k<<l;this.words[w]=g|b,b=k>>>26-l}b&&(this.words[w]=b,this.length++)}if(c!==0){for(w=this.length-1;w>=0;w--)this.words[w+c]=this.words[w];for(w=0;w<c;w++)this.words[w]=0;this.length+=c}return this._strip()},i.prototype.ishln=function(o){return r(this.negative===0),this.iushln(o)},i.prototype.iushrn=function(o,l,c){r(typeof o=="number"&&o>=0);var m;l?m=(l-l%26)/26:m=0;var w=o%26,b=Math.min((o-w)/26,this.length),k=67108863^67108863>>>w<<w,g=c;if(m-=b,m=Math.max(0,m),g){for(var f=0;f<b;f++)g.words[f]=this.words[f];g.length=b}if(b!==0)if(this.length>b)for(this.length-=b,f=0;f<this.length;f++)this.words[f]=this.words[f+b];else this.words[0]=0,this.length=1;var v=0;for(f=this.length-1;f>=0&&(v!==0||f>=m);f--){var C=this.words[f]|0;this.words[f]=v<<26-w|C>>>w,v=C&k}return g&&v!==0&&(g.words[g.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(o,l,c){return r(this.negative===0),this.iushrn(o,l,c)},i.prototype.shln=function(o){return this.clone().ishln(o)},i.prototype.ushln=function(o){return this.clone().iushln(o)},i.prototype.shrn=function(o){return this.clone().ishrn(o)},i.prototype.ushrn=function(o){return this.clone().iushrn(o)},i.prototype.testn=function(o){r(typeof o=="number"&&o>=0);var l=o%26,c=(o-l)/26,m=1<<l;if(this.length<=c)return!1;var w=this.words[c];return!!(w&m)},i.prototype.imaskn=function(o){r(typeof o=="number"&&o>=0);var l=o%26,c=(o-l)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=c)return this;if(l!==0&&c++,this.length=Math.min(c,this.length),l!==0){var m=67108863^67108863>>>l<<l;this.words[this.length-1]&=m}return this._strip()},i.prototype.maskn=function(o){return this.clone().imaskn(o)},i.prototype.iaddn=function(o){return r(typeof o=="number"),r(o<67108864),o<0?this.isubn(-o):this.negative!==0?this.length===1&&(this.words[0]|0)<=o?(this.words[0]=o-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(o),this.negative=1,this):this._iaddn(o)},i.prototype._iaddn=function(o){this.words[0]+=o;for(var l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},i.prototype.isubn=function(o){if(r(typeof o=="number"),r(o<67108864),o<0)return this.iaddn(-o);if(this.negative!==0)return this.negative=0,this.iaddn(o),this.negative=1,this;if(this.words[0]-=o,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+1]-=1;return this._strip()},i.prototype.addn=function(o){return this.clone().iaddn(o)},i.prototype.subn=function(o){return this.clone().isubn(o)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(o,l,c){var m=o.length+c,w;this._expand(m);var b,k=0;for(w=0;w<o.length;w++){b=(this.words[w+c]|0)+k;var g=(o.words[w]|0)*l;b-=g&67108863,k=(b>>26)-(g/67108864|0),this.words[w+c]=b&67108863}for(;w<this.length-c;w++)b=(this.words[w+c]|0)+k,k=b>>26,this.words[w+c]=b&67108863;if(k===0)return this._strip();for(r(k===-1),k=0,w=0;w<this.length;w++)b=-(this.words[w]|0)+k,k=b>>26,this.words[w]=b&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(o,l){var c=this.length-o.length,m=this.clone(),w=o,b=w.words[w.length-1]|0,k=this._countBits(b);c=26-k,c!==0&&(w=w.ushln(c),m.iushln(c),b=w.words[w.length-1]|0);var g=m.length-w.length,f;if(l!=="mod"){f=new i(null),f.length=g+1,f.words=new Array(f.length);for(var v=0;v<f.length;v++)f.words[v]=0}var C=m.clone()._ishlnsubmul(w,1,g);C.negative===0&&(m=C,f&&(f.words[g]=1));for(var B=g-1;B>=0;B--){var L=(m.words[w.length+B]|0)*67108864+(m.words[w.length+B-1]|0);for(L=Math.min(L/b|0,67108863),m._ishlnsubmul(w,L,B);m.negative!==0;)L--,m.negative=0,m._ishlnsubmul(w,1,B),m.isZero()||(m.negative^=1);f&&(f.words[B]=L)}return f&&f._strip(),m._strip(),l!=="div"&&c!==0&&m.iushrn(c),{div:f||null,mod:m}},i.prototype.divmod=function(o,l,c){if(r(!o.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var m,w,b;return this.negative!==0&&o.negative===0?(b=this.neg().divmod(o,l),l!=="mod"&&(m=b.div.neg()),l!=="div"&&(w=b.mod.neg(),c&&w.negative!==0&&w.iadd(o)),{div:m,mod:w}):this.negative===0&&o.negative!==0?(b=this.divmod(o.neg(),l),l!=="mod"&&(m=b.div.neg()),{div:m,mod:b.mod}):this.negative&o.negative?(b=this.neg().divmod(o.neg(),l),l!=="div"&&(w=b.mod.neg(),c&&w.negative!==0&&w.isub(o)),{div:b.div,mod:w}):o.length>this.length||this.cmp(o)<0?{div:new i(0),mod:this}:o.length===1?l==="div"?{div:this.divn(o.words[0]),mod:null}:l==="mod"?{div:null,mod:new i(this.modrn(o.words[0]))}:{div:this.divn(o.words[0]),mod:new i(this.modrn(o.words[0]))}:this._wordDiv(o,l)},i.prototype.div=function(o){return this.divmod(o,"div",!1).div},i.prototype.mod=function(o){return this.divmod(o,"mod",!1).mod},i.prototype.umod=function(o){return this.divmod(o,"mod",!0).mod},i.prototype.divRound=function(o){var l=this.divmod(o);if(l.mod.isZero())return l.div;var c=l.div.negative!==0?l.mod.isub(o):l.mod,m=o.ushrn(1),w=o.andln(1),b=c.cmp(m);return b<0||w===1&&b===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},i.prototype.modrn=function(o){var l=o<0;l&&(o=-o),r(o<=67108863);for(var c=(1<<26)%o,m=0,w=this.length-1;w>=0;w--)m=(c*m+(this.words[w]|0))%o;return l?-m:m},i.prototype.modn=function(o){return this.modrn(o)},i.prototype.idivn=function(o){var l=o<0;l&&(o=-o),r(o<=67108863);for(var c=0,m=this.length-1;m>=0;m--){var w=(this.words[m]|0)+c*67108864;this.words[m]=w/o|0,c=w%o}return this._strip(),l?this.ineg():this},i.prototype.divn=function(o){return this.clone().idivn(o)},i.prototype.egcd=function(o){r(o.negative===0),r(!o.isZero());var l=this,c=o.clone();l.negative!==0?l=l.umod(o):l=l.clone();for(var m=new i(1),w=new i(0),b=new i(0),k=new i(1),g=0;l.isEven()&&c.isEven();)l.iushrn(1),c.iushrn(1),++g;for(var f=c.clone(),v=l.clone();!l.isZero();){for(var C=0,B=1;!(l.words[0]&B)&&C<26;++C,B<<=1);if(C>0)for(l.iushrn(C);C-- >0;)(m.isOdd()||w.isOdd())&&(m.iadd(f),w.isub(v)),m.iushrn(1),w.iushrn(1);for(var L=0,Ut=1;!(c.words[0]&Ut)&&L<26;++L,Ut<<=1);if(L>0)for(c.iushrn(L);L-- >0;)(b.isOdd()||k.isOdd())&&(b.iadd(f),k.isub(v)),b.iushrn(1),k.iushrn(1);l.cmp(c)>=0?(l.isub(c),m.isub(b),w.isub(k)):(c.isub(l),b.isub(m),k.isub(w))}return{a:b,b:k,gcd:c.iushln(g)}},i.prototype._invmp=function(o){r(o.negative===0),r(!o.isZero());var l=this,c=o.clone();l.negative!==0?l=l.umod(o):l=l.clone();for(var m=new i(1),w=new i(0),b=c.clone();l.cmpn(1)>0&&c.cmpn(1)>0;){for(var k=0,g=1;!(l.words[0]&g)&&k<26;++k,g<<=1);if(k>0)for(l.iushrn(k);k-- >0;)m.isOdd()&&m.iadd(b),m.iushrn(1);for(var f=0,v=1;!(c.words[0]&v)&&f<26;++f,v<<=1);if(f>0)for(c.iushrn(f);f-- >0;)w.isOdd()&&w.iadd(b),w.iushrn(1);l.cmp(c)>=0?(l.isub(c),m.isub(w)):(c.isub(l),w.isub(m))}var C;return l.cmpn(1)===0?C=m:C=w,C.cmpn(0)<0&&C.iadd(o),C},i.prototype.gcd=function(o){if(this.isZero())return o.abs();if(o.isZero())return this.abs();var l=this.clone(),c=o.clone();l.negative=0,c.negative=0;for(var m=0;l.isEven()&&c.isEven();m++)l.iushrn(1),c.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;c.isEven();)c.iushrn(1);var w=l.cmp(c);if(w<0){var b=l;l=c,c=b}else if(w===0||c.cmpn(1)===0)break;l.isub(c)}while(!0);return c.iushln(m)},i.prototype.invm=function(o){return this.egcd(o).a.umod(o)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(o){return this.words[0]&o},i.prototype.bincn=function(o){r(typeof o=="number");var l=o%26,c=(o-l)/26,m=1<<l;if(this.length<=c)return this._expand(c+1),this.words[c]|=m,this;for(var w=m,b=c;w!==0&&b<this.length;b++){var k=this.words[b]|0;k+=w,w=k>>>26,k&=67108863,this.words[b]=k}return w!==0&&(this.words[b]=w,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(o){var l=o<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this._strip();var c;if(this.length>1)c=1;else{l&&(o=-o),r(o<=67108863,"Number is too big");var m=this.words[0]|0;c=m===o?0:m<o?-1:1}return this.negative!==0?-c|0:c},i.prototype.cmp=function(o){if(this.negative!==0&&o.negative===0)return-1;if(this.negative===0&&o.negative!==0)return 1;var l=this.ucmp(o);return this.negative!==0?-l|0:l},i.prototype.ucmp=function(o){if(this.length>o.length)return 1;if(this.length<o.length)return-1;for(var l=0,c=this.length-1;c>=0;c--){var m=this.words[c]|0,w=o.words[c]|0;if(m!==w){m<w?l=-1:m>w&&(l=1);break}}return l},i.prototype.gtn=function(o){return this.cmpn(o)===1},i.prototype.gt=function(o){return this.cmp(o)===1},i.prototype.gten=function(o){return this.cmpn(o)>=0},i.prototype.gte=function(o){return this.cmp(o)>=0},i.prototype.ltn=function(o){return this.cmpn(o)===-1},i.prototype.lt=function(o){return this.cmp(o)===-1},i.prototype.lten=function(o){return this.cmpn(o)<=0},i.prototype.lte=function(o){return this.cmp(o)<=0},i.prototype.eqn=function(o){return this.cmpn(o)===0},i.prototype.eq=function(o){return this.cmp(o)===0},i.red=function(o){return new W(o)},i.prototype.toRed=function(o){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),o.convertTo(this)._forceRed(o)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(o){return this.red=o,this},i.prototype.forceRed=function(o){return r(!this.red,"Already a number in reduction context"),this._forceRed(o)},i.prototype.redAdd=function(o){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,o)},i.prototype.redIAdd=function(o){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,o)},i.prototype.redSub=function(o){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,o)},i.prototype.redISub=function(o){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,o)},i.prototype.redShl=function(o){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,o)},i.prototype.redMul=function(o){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.mul(this,o)},i.prototype.redIMul=function(o){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.imul(this,o)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(o){return r(this.red&&!o.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,o)};var F={k256:null,p224:null,p192:null,p25519:null};function z(y,o){this.name=y,this.p=new i(o,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var o=new i(null);return o.words=new Array(Math.ceil(this.n/13)),o},z.prototype.ireduce=function(o){var l=o,c;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),c=l.bitLength();while(c>this.n);var m=c<this.n?-1:l.ucmp(this.p);return m===0?(l.words[0]=0,l.length=1):m>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},z.prototype.split=function(o,l){o.iushrn(this.n,0,l)},z.prototype.imulK=function(o){return o.imul(this.k)};function Vt(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Vt,z),Vt.prototype.split=function(o,l){for(var c=4194303,m=Math.min(o.length,9),w=0;w<m;w++)l.words[w]=o.words[w];if(l.length=m,o.length<=9){o.words[0]=0,o.length=1;return}var b=o.words[9];for(l.words[l.length++]=b&c,w=10;w<o.length;w++){var k=o.words[w]|0;o.words[w-10]=(k&c)<<4|b>>>22,b=k}b>>>=22,o.words[w-10]=b,b===0&&o.length>10?o.length-=10:o.length-=9},Vt.prototype.imulK=function(o){o.words[o.length]=0,o.words[o.length+1]=0,o.length+=2;for(var l=0,c=0;c<o.length;c++){var m=o.words[c]|0;l+=m*977,o.words[c]=l&67108863,l=m*64+(l/67108864|0)}return o.words[o.length-1]===0&&(o.length--,o.words[o.length-1]===0&&o.length--),o};function Kt(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(Kt,z);function Ft(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(Ft,z);function we(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(we,z),we.prototype.imulK=function(o){for(var l=0,c=0;c<o.length;c++){var m=(o.words[c]|0)*19+l,w=m&67108863;m>>>=26,o.words[c]=w,l=m}return l!==0&&(o.words[o.length++]=l),o},i._prime=function(o){if(F[o])return F[o];var l;if(o==="k256")l=new Vt;else if(o==="p224")l=new Kt;else if(o==="p192")l=new Ft;else if(o==="p25519")l=new we;else throw new Error("Unknown prime "+o);return F[o]=l,l};function W(y){if(typeof y=="string"){var o=i._prime(y);this.m=o.p,this.prime=o}else r(y.gtn(1),"modulus must be greater than 1"),this.m=y,this.prime=null}W.prototype._verify1=function(o){r(o.negative===0,"red works only with positives"),r(o.red,"red works only with red numbers")},W.prototype._verify2=function(o,l){r((o.negative|l.negative)===0,"red works only with positives"),r(o.red&&o.red===l.red,"red works only with red numbers")},W.prototype.imod=function(o){return this.prime?this.prime.ireduce(o)._forceRed(this):(p(o,o.umod(this.m)._forceRed(this)),o)},W.prototype.neg=function(o){return o.isZero()?o.clone():this.m.sub(o)._forceRed(this)},W.prototype.add=function(o,l){this._verify2(o,l);var c=o.add(l);return c.cmp(this.m)>=0&&c.isub(this.m),c._forceRed(this)},W.prototype.iadd=function(o,l){this._verify2(o,l);var c=o.iadd(l);return c.cmp(this.m)>=0&&c.isub(this.m),c},W.prototype.sub=function(o,l){this._verify2(o,l);var c=o.sub(l);return c.cmpn(0)<0&&c.iadd(this.m),c._forceRed(this)},W.prototype.isub=function(o,l){this._verify2(o,l);var c=o.isub(l);return c.cmpn(0)<0&&c.iadd(this.m),c},W.prototype.shl=function(o,l){return this._verify1(o),this.imod(o.ushln(l))},W.prototype.imul=function(o,l){return this._verify2(o,l),this.imod(o.imul(l))},W.prototype.mul=function(o,l){return this._verify2(o,l),this.imod(o.mul(l))},W.prototype.isqr=function(o){return this.imul(o,o.clone())},W.prototype.sqr=function(o){return this.mul(o,o)},W.prototype.sqrt=function(o){if(o.isZero())return o.clone();var l=this.m.andln(3);if(r(l%2===1),l===3){var c=this.m.add(new i(1)).iushrn(2);return this.pow(o,c)}for(var m=this.m.subn(1),w=0;!m.isZero()&&m.andln(1)===0;)w++,m.iushrn(1);r(!m.isZero());var b=new i(1).toRed(this),k=b.redNeg(),g=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);this.pow(f,g).cmp(k)!==0;)f.redIAdd(k);for(var v=this.pow(f,m),C=this.pow(o,m.addn(1).iushrn(1)),B=this.pow(o,m),L=w;B.cmp(b)!==0;){for(var Ut=B,H=0;Ut.cmp(b)!==0;H++)Ut=Ut.redSqr();r(H<L);var j=this.pow(v,new i(1).iushln(L-H-1));C=C.redMul(j),v=j.redSqr(),B=B.redMul(v),L=H}return C},W.prototype.invm=function(o){var l=o._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},W.prototype.pow=function(o,l){if(l.isZero())return new i(1).toRed(this);if(l.cmpn(1)===0)return o.clone();var c=4,m=new Array(1<<c);m[0]=new i(1).toRed(this),m[1]=o;for(var w=2;w<m.length;w++)m[w]=this.mul(m[w-1],o);var b=m[0],k=0,g=0,f=l.bitLength()%26;for(f===0&&(f=26),w=l.length-1;w>=0;w--){for(var v=l.words[w],C=f-1;C>=0;C--){var B=v>>C&1;if(b!==m[0]&&(b=this.sqr(b)),B===0&&k===0){g=0;continue}k<<=1,k|=B,g++,!(g!==c&&(w!==0||C!==0))&&(b=this.mul(b,m[k]),g=0,k=0)}f=26}return b},W.prototype.convertTo=function(o){var l=o.umod(this.m);return l===o?l.clone():l},W.prototype.convertFrom=function(o){var l=o.clone();return l.red=null,l},i.mont=function(o){return new ye(o)};function ye(y){W.call(this,y),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(ye,W),ye.prototype.convertTo=function(o){return this.imod(o.ushln(this.shift))},ye.prototype.convertFrom=function(o){var l=this.imod(o.mul(this.rinv));return l.red=null,l},ye.prototype.imul=function(o,l){if(o.isZero()||l.isZero())return o.words[0]=0,o.length=1,o;var c=o.imul(l),m=c.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=c.isub(m).iushrn(this.shift),b=w;return w.cmp(this.m)>=0?b=w.isub(this.m):w.cmpn(0)<0&&(b=w.iadd(this.m)),b._forceRed(this)},ye.prototype.mul=function(o,l){if(o.isZero()||l.isZero())return new i(0)._forceRed(this);var c=o.mul(l),m=c.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=c.isub(m).iushrn(this.shift),b=w;return w.cmp(this.m)>=0?b=w.isub(this.m):w.cmpn(0)<0&&(b=w.iadd(this.m)),b._forceRed(this)},ye.prototype.invm=function(o){var l=this.imod(o._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(s,Fn)})(Ss);const q=Kr;function Ne(s,t,e){return e={path:t,exports:{},require:function(r,n){return Rs(r,n??e.path)}},s(e,e.exports),e.exports}function Rs(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Zr=bn;function bn(s,t){if(!s)throw new Error(t||"Assertion failed")}bn.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var ne=Ne(function(s,t){var e=t;function r(a,u){if(Array.isArray(a))return a.slice();if(!a)return[];var h=[];if(typeof a!="string"){for(var d=0;d<a.length;d++)h[d]=a[d]|0;return h}if(u==="hex"){a=a.replace(/[^a-z0-9]+/ig,""),a.length%2!==0&&(a="0"+a);for(var d=0;d<a.length;d+=2)h.push(parseInt(a[d]+a[d+1],16))}else for(var d=0;d<a.length;d++){var p=a.charCodeAt(d),A=p>>8,M=p&255;A?h.push(A,M):h.push(M)}return h}e.toArray=r;function n(a){return a.length===1?"0"+a:a}e.zero2=n;function i(a){for(var u="",h=0;h<a.length;h++)u+=n(a[h].toString(16));return u}e.toHex=i,e.encode=function(u,h){return h==="hex"?i(u):u}}),Xt=Ne(function(s,t){var e=t;e.assert=Zr,e.toArray=ne.toArray,e.zero2=ne.zero2,e.toHex=ne.toHex,e.encode=ne.encode;function r(h,d,p){var A=new Array(Math.max(h.bitLength(),p)+1);A.fill(0);for(var M=1<<d+1,E=h.clone(),_=0;_<A.length;_++){var I,T=E.andln(M-1);E.isOdd()?(T>(M>>1)-1?I=(M>>1)-T:I=T,E.isubn(I)):I=0,A[_]=I,E.iushrn(1)}return A}e.getNAF=r;function n(h,d){var p=[[],[]];h=h.clone(),d=d.clone();for(var A=0,M=0,E;h.cmpn(-A)>0||d.cmpn(-M)>0;){var _=h.andln(3)+A&3,I=d.andln(3)+M&3;_===3&&(_=-1),I===3&&(I=-1);var T;_&1?(E=h.andln(7)+A&7,(E===3||E===5)&&I===2?T=-_:T=_):T=0,p[0].push(T);var P;I&1?(E=d.andln(7)+M&7,(E===3||E===5)&&_===2?P=-I:P=I):P=0,p[1].push(P),2*A===T+1&&(A=1-A),2*M===P+1&&(M=1-M),h.iushrn(1),d.iushrn(1)}return p}e.getJSF=n;function i(h,d,p){var A="_"+d;h.prototype[d]=function(){return this[A]!==void 0?this[A]:this[A]=p.call(this)}}e.cachedProperty=i;function a(h){return typeof h=="string"?e.toArray(h,"hex"):h}e.parseBytes=a;function u(h){return new q(h,"hex","le")}e.intFromLE=u}),er=Xt.getNAF,Ts=Xt.getJSF,rr=Xt.assert;function me(s,t){this.type=s,this.p=new q(t.p,16),this.red=t.prime?q.red(t.prime):q.mont(this.p),this.zero=new q(0).toRed(this.red),this.one=new q(1).toRed(this.red),this.two=new q(2).toRed(this.red),this.n=t.n&&new q(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.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 e=this.n&&this.p.div(this.n);!e||e.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xe=me;me.prototype.point=function(){throw new Error("Not implemented")};me.prototype.validate=function(){throw new Error("Not implemented")};me.prototype._fixedNafMul=function(t,e){rr(t.precomputed);var r=t._getDoubles(),n=er(e,1,this._bitLength),i=(1<<r.step+1)-(r.step%2===0?2:1);i/=3;var a=[],u,h;for(u=0;u<n.length;u+=r.step){h=0;for(var d=u+r.step-1;d>=u;d--)h=(h<<1)+n[d];a.push(h)}for(var p=this.jpoint(null,null,null),A=this.jpoint(null,null,null),M=i;M>0;M--){for(u=0;u<a.length;u++)h=a[u],h===M?A=A.mixedAdd(r.points[u]):h===-M&&(A=A.mixedAdd(r.points[u].neg()));p=p.add(A)}return p.toP()};me.prototype._wnafMul=function(t,e){var r=4,n=t._getNAFPoints(r);r=n.wnd;for(var i=n.points,a=er(e,r,this._bitLength),u=this.jpoint(null,null,null),h=a.length-1;h>=0;h--){for(var d=0;h>=0&&a[h]===0;h--)d++;if(h>=0&&d++,u=u.dblp(d),h<0)break;var p=a[h];rr(p!==0),t.type==="affine"?p>0?u=u.mixedAdd(i[p-1>>1]):u=u.mixedAdd(i[-p-1>>1].neg()):p>0?u=u.add(i[p-1>>1]):u=u.add(i[-p-1>>1].neg())}return t.type==="affine"?u.toP():u};me.prototype._wnafMulAdd=function(t,e,r,n,i){var a=this._wnafT1,u=this._wnafT2,h=this._wnafT3,d=0,p,A,M;for(p=0;p<n;p++){M=e[p];var E=M._getNAFPoints(t);a[p]=E.wnd,u[p]=E.points}for(p=n-1;p>=1;p-=2){var _=p-1,I=p;if(a[_]!==1||a[I]!==1){h[_]=er(r[_],a[_],this._bitLength),h[I]=er(r[I],a[I],this._bitLength),d=Math.max(h[_].length,d),d=Math.max(h[I].length,d);continue}var T=[e[_],null,null,e[I]];e[_].y.cmp(e[I].y)===0?(T[1]=e[_].add(e[I]),T[2]=e[_].toJ().mixedAdd(e[I].neg())):e[_].y.cmp(e[I].y.redNeg())===0?(T[1]=e[_].toJ().mixedAdd(e[I]),T[2]=e[_].add(e[I].neg())):(T[1]=e[_].toJ().mixedAdd(e[I]),T[2]=e[_].toJ().mixedAdd(e[I].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],S=Ts(r[_],r[I]);for(d=Math.max(S[0].length,d),h[_]=new Array(d),h[I]=new Array(d),A=0;A<d;A++){var G=S[0][A]|0,J=S[1][A]|0;h[_][A]=P[(G+1)*3+(J+1)],h[I][A]=0,u[_]=T}}var F=this.jpoint(null,null,null),z=this._wnafT4;for(p=d;p>=0;p--){for(var Vt=0;p>=0;){var Kt=!0;for(A=0;A<n;A++)z[A]=h[A][p]|0,z[A]!==0&&(Kt=!1);if(!Kt)break;Vt++,p--}if(p>=0&&Vt++,F=F.dblp(Vt),p<0)break;for(A=0;A<n;A++){var Ft=z[A];Ft!==0&&(Ft>0?M=u[A][Ft-1>>1]:Ft<0&&(M=u[A][-Ft-1>>1].neg()),M.type==="affine"?F=F.mixedAdd(M):F=F.add(M))}}for(p=0;p<n;p++)u[p]=null;return i?F:F.toP()};function $t(s,t){this.curve=s,this.type=t,this.precomputed=null}me.BasePoint=$t;$t.prototype.eq=function(){throw new Error("Not implemented")};$t.prototype.validate=function(){return this.curve.validate(this)};me.prototype.decodePoint=function(t,e){t=Xt.toArray(t,e);var r=this.p.byteLength();if((t[0]===4||t[0]===6||t[0]===7)&&t.length-1===2*r){t[0]===6?rr(t[t.length-1]%2===0):t[0]===7&&rr(t[t.length-1]%2===1);var n=this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));return n}else if((t[0]===2||t[0]===3)&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),t[0]===3);throw new Error("Unknown point format")};$t.prototype.encodeCompressed=function(t){return this.encode(t,!0)};$t.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))};$t.prototype.encode=function(t,e){return Xt.encode(this._encode(e),t)};$t.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};$t.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):!1};$t.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<e;i+=t){for(var a=0;a<t;a++)n=n.dbl();r.push(n)}return{step:t,points:r}};$t.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,n=r===1?null:this.dbl(),i=1;i<r;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}};$t.prototype._getBeta=function(){return null};$t.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var $r=Ne(function(s){typeof Object.create=="function"?s.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:s.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}}),Bs=Xt.assert;function te(s){xe.call(this,"short",s),this.a=new q(s.a,16).toRed(this.red),this.b=new q(s.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(s),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}$r(te,xe);var Cs=te;te.prototype._getEndomorphism=function(t){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var e,r;if(t.beta)e=new q(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=n[0].cmp(n[1])<0?n[0]:n[1],e=e.toRed(this.red)}if(t.lambda)r=new q(t.lambda,16);else{var i=this._getEndoRoots(this.n);this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))===0?r=i[0]:(r=i[1],Bs(this.g.mul(r).x.cmp(this.g.x.redMul(e))===0))}var a;return t.basis?a=t.basis.map(function(u){return{a:new q(u.a,16),b:new q(u.b,16)}}):a=this._getEndoBasis(r),{beta:e,lambda:r,basis:a}}};te.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:q.mont(t),r=new q(2).toRed(e).redInvm(),n=r.redNeg(),i=new q(3).toRed(e).redNeg().redSqrt().redMul(r),a=n.redAdd(i).fromRed(),u=n.redSub(i).fromRed();return[a,u]};te.prototype._getEndoBasis=function(t){for(var e=this.n.ushrn(Math.floor(this.n.bitLength()/2)),r=t,n=this.n.clone(),i=new q(1),a=new q(0),u=new q(0),h=new q(1),d,p,A,M,E,_,I,T=0,P,S;r.cmpn(0)!==0;){var G=n.div(r);P=n.sub(G.mul(r)),S=u.sub(G.mul(i));var J=h.sub(G.mul(a));if(!A&&P.cmp(e)<0)d=I.neg(),p=i,A=P.neg(),M=S;else if(A&&++T===2)break;I=P,n=r,r=P,u=i,i=S,h=a,a=J}E=P.neg(),_=S;var F=A.sqr().add(M.sqr()),z=E.sqr().add(_.sqr());return z.cmp(F)>=0&&(E=d,_=p),A.negative&&(A=A.neg(),M=M.neg()),E.negative&&(E=E.neg(),_=_.neg()),[{a:A,b:M},{a:E,b:_}]};te.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),a=r.b.neg().mul(t).divRound(this.n),u=i.mul(r.a),h=a.mul(n.a),d=i.mul(r.b),p=a.mul(n.b),A=t.sub(u).sub(h),M=d.add(p).neg();return{k1:A,k2:M}};te.prototype.pointFromX=function(t,e){t=new q(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(n.redSqr().redSub(r).cmp(this.zero)!==0)throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)};te.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return r.redSqr().redISub(i).cmpn(0)===0};te.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,a=0;a<t.length;a++){var u=this._endoSplit(e[a]),h=t[a],d=h._getBeta();u.k1.negative&&(u.k1.ineg(),h=h.neg(!0)),u.k2.negative&&(u.k2.ineg(),d=d.neg(!0)),n[a*2]=h,n[a*2+1]=d,i[a*2]=u.k1,i[a*2+1]=u.k2}for(var p=this._wnafMulAdd(1,n,i,a*2,r),A=0;A<a*2;A++)n[A]=null,i[A]=null;return p};function Ot(s,t,e,r){xe.BasePoint.call(this,s,"affine"),t===null&&e===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new q(t,16),this.y=new q(e,16),r&&(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)}$r(Ot,xe.BasePoint);te.prototype.point=function(t,e,r){return new Ot(this,t,e,r)};te.prototype.pointFromJSON=function(t,e){return Ot.fromJSON(this,t,e)};Ot.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,n=function(i){return r.point(i.x.redMul(r.endo.beta),i.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}};Ot.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]};Ot.fromJSON=function(t,e,r){typeof e=="string"&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(u){return t.point(u[0],u[1],r)}var a=e[2];return n.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[n].concat(a.doubles.points.map(i))},naf:a.naf&&{wnd:a.naf.wnd,points:[n].concat(a.naf.points.map(i))}},n};Ot.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)+">"};Ot.prototype.isInfinity=function(){return this.inf};Ot.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(this.x.cmp(t.x)===0)return this.curve.point(null,null);var e=this.y.redSub(t.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)};Ot.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(t.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),a=i.redSqr().redISub(this.x.redAdd(this.x)),u=i.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,u)};Ot.prototype.getX=function(){return this.x.fromRed()};Ot.prototype.getY=function(){return this.y.fromRed()};Ot.prototype.mul=function(t){return t=new q(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)};Ot.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)};Ot.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)};Ot.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||this.x.cmp(t.x)===0&&this.y.cmp(t.y)===0)};Ot.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,n=function(i){return i.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e};Ot.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t};function qt(s,t,e,r){xe.BasePoint.call(this,s,"jacobian"),t===null&&e===null&&r===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new q(0)):(this.x=new q(t,16),this.y=new q(e,16),this.z=new q(r,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}$r(qt,xe.BasePoint);te.prototype.jpoint=function(t,e,r){return new qt(this,t,e,r)};qt.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),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)};qt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};qt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),a=this.y.redMul(e.redMul(t.z)),u=t.y.redMul(r.redMul(this.z)),h=n.redSub(i),d=a.redSub(u);if(h.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var p=h.redSqr(),A=p.redMul(h),M=n.redMul(p),E=d.redSqr().redIAdd(A).redISub(M).redISub(M),_=d.redMul(M.redISub(E)).redISub(a.redMul(A)),I=this.z.redMul(t.z).redMul(h);return this.curve.jpoint(E,_,I)};qt.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,a=t.y.redMul(e).redMul(this.z),u=r.redSub(n),h=i.redSub(a);if(u.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=u.redSqr(),p=d.redMul(u),A=r.redMul(d),M=h.redSqr().redIAdd(p).redISub(A).redISub(A),E=h.redMul(A.redISub(M)).redISub(i.redMul(p)),_=this.z.redMul(u);return this.curve.jpoint(M,E,_)};qt.prototype.dblp=function(t){if(t===0)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 n=this.curve.a,i=this.curve.tinv,a=this.x,u=this.y,h=this.z,d=h.redSqr().redSqr(),p=u.redAdd(u);for(e=0;e<t;e++){var A=a.redSqr(),M=p.redSqr(),E=M.redSqr(),_=A.redAdd(A).redIAdd(A).redIAdd(n.redMul(d)),I=a.redMul(M),T=_.redSqr().redISub(I.redAdd(I)),P=I.redISub(T),S=_.redMul(P);S=S.redIAdd(S).redISub(E);var G=p.redMul(h);e+1<t&&(d=d.redMul(E)),a=T,h=G,p=S}return this.curve.jpoint(a,p.redMul(i),h)};qt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};qt.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),a=i.redSqr(),u=this.x.redAdd(i).redSqr().redISub(n).redISub(a);u=u.redIAdd(u);var h=n.redAdd(n).redIAdd(n),d=h.redSqr().redISub(u).redISub(u),p=a.redIAdd(a);p=p.redIAdd(p),p=p.redIAdd(p),t=d,e=h.redMul(u.redISub(d)).redISub(p),r=this.y.redAdd(this.y)}else{var A=this.x.redSqr(),M=this.y.redSqr(),E=M.redSqr(),_=this.x.redAdd(M).redSqr().redISub(A).redISub(E);_=_.redIAdd(_);var I=A.redAdd(A).redIAdd(A),T=I.redSqr(),P=E.redIAdd(E);P=P.redIAdd(P),P=P.redIAdd(P),t=T.redISub(_).redISub(_),e=I.redMul(_.redISub(t)).redISub(P),r=this.y.redMul(this.z),r=r.redIAdd(r)}return this.curve.jpoint(t,e,r)};qt.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),a=i.redSqr(),u=this.x.redAdd(i).redSqr().redISub(n).redISub(a);u=u.redIAdd(u);var h=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),d=h.redSqr().redISub(u).redISub(u);t=d;var p=a.redIAdd(a);p=p.redIAdd(p),p=p.redIAdd(p),e=h.redMul(u.redISub(d)).redISub(p),r=this.y.redAdd(this.y)}else{var A=this.z.redSqr(),M=this.y.redSqr(),E=this.x.redMul(M),_=this.x.redSub(A).redMul(this.x.redAdd(A));_=_.redAdd(_).redIAdd(_);var I=E.redIAdd(E);I=I.redIAdd(I);var T=I.redAdd(I);t=_.redSqr().redISub(T),r=this.y.redAdd(this.z).redSqr().redISub(M).redISub(A);var P=M.redSqr();P=P.redIAdd(P),P=P.redIAdd(P),P=P.redIAdd(P),e=_.redMul(I.redISub(t)).redISub(P)}return this.curve.jpoint(t,e,r)};qt.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),a=e.redSqr(),u=r.redSqr(),h=a.redAdd(a).redIAdd(a).redIAdd(t.redMul(i)),d=e.redAdd(e);d=d.redIAdd(d);var p=d.redMul(u),A=h.redSqr().redISub(p.redAdd(p)),M=p.redISub(A),E=u.redSqr();E=E.redIAdd(E),E=E.redIAdd(E),E=E.redIAdd(E);var _=h.redMul(M).redISub(E),I=r.redAdd(r).redMul(n);return this.curve.jpoint(A,_,I)};qt.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(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),a=i.redSqr(),u=this.x.redAdd(e).redSqr().redISub(t).redISub(n);u=u.redIAdd(u),u=u.redAdd(u).redIAdd(u),u=u.redISub(a);var h=u.redSqr(),d=n.redIAdd(n);d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var p=i.redIAdd(u).redSqr().redISub(a).redISub(h).redISub(d),A=e.redMul(p);A=A.redIAdd(A),A=A.redIAdd(A);var M=this.x.redMul(h).redISub(A);M=M.redIAdd(M),M=M.redIAdd(M);var E=this.y.redMul(p.redMul(d.redISub(p)).redISub(u.redMul(h)));E=E.redIAdd(E),E=E.redIAdd(E),E=E.redIAdd(E);var _=this.z.redAdd(u).redSqr().redISub(r).redISub(h);return this.curve.jpoint(M,E,_)};qt.prototype.mul=function(t,e){return t=new q(t,e),this.curve._wnafMul(this,t)};qt.prototype.eq=function(t){if(t.type==="affine")return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0)!==0)return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)===0};qt.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(this.x.cmp(r)===0)return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),this.x.cmp(r)===0)return!0}};qt.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)+">"};qt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var We=Ne(function(s,t){var e=t;e.base=xe,e.short=Cs,e.mont=null,e.edwards=null}),Xe=Ne(function(s,t){var e=t,r=Xt.assert;function n(u){u.type==="short"?this.curve=new We.short(u):u.type==="edwards"?this.curve=new We.edwards(u):this.curve=new We.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,r(this.g.validate(),"Invalid curve"),r(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=n;function i(u,h){Object.defineProperty(e,u,{configurable:!0,enumerable:!0,get:function(){var d=new n(h);return Object.defineProperty(e,u,{configurable:!0,enumerable:!0,value:d}),d}})}i("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:se.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),i("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:se.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),i("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:se.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),i("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:se.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"]}),i("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:se.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"]}),i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:se.sha256,gRed:!1,g:["9"]}),i("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:se.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var a;try{a=null.crash()}catch{a=void 0}i("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:se.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})});function ge(s){if(!(this instanceof ge))return new ge(s);this.hash=s.hash,this.predResist=!!s.predResist,this.outLen=this.hash.outSize,this.minEntropy=s.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=ne.toArray(s.entropy,s.entropyEnc||"hex"),e=ne.toArray(s.nonce,s.nonceEnc||"hex"),r=ne.toArray(s.pers,s.persEnc||"hex");Zr(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,e,r)}var kn=ge;ge.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656};ge.prototype._hmac=function(){return new se.hmac(this.hash,this.K)};ge.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())};ge.prototype.reseed=function(t,e,r,n){typeof e!="string"&&(n=r,r=e,e=null),t=ne.toArray(t,e),r=ne.toArray(r,n),Zr(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1};ge.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(n=r,r=e,e=null),r&&(r=ne.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length<t;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var a=i.slice(0,t);return this._update(r),this._reseed++,ne.encode(a,e)};var Hr=Xt.assert;function zt(s,t){this.ec=s,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var ti=zt;zt.fromPublic=function(t,e,r){return e instanceof zt?e:new zt(t,{pub:e,pubEnc:r})};zt.fromPrivate=function(t,e,r){return e instanceof zt?e:new zt(t,{priv:e,privEnc:r})};zt.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"}};zt.prototype.getPublic=function(t,e){return typeof t=="string"&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub};zt.prototype.getPrivate=function(t){return t==="hex"?this.priv.toString(16,2):this.priv};zt.prototype._importPrivate=function(t,e){this.priv=new q(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)};zt.prototype._importPublic=function(t,e){if(t.x||t.y){this.ec.curve.type==="mont"?Hr(t.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Hr(t.x&&t.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(t.x,t.y);return}this.pub=this.ec.curve.decodePoint(t,e)};zt.prototype.derive=function(t){return t.validate()||Hr(t.validate(),"public point not validated"),t.mul(this.priv).getX()};zt.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)};zt.prototype.verify=function(t,e){return this.ec.verify(t,e,this)};zt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Os=Xt.assert;function ur(s,t){if(s instanceof ur)return s;this._importDER(s,t)||(Os(s.r&&s.s,"Signature without r or s"),this.r=new q(s.r,16),this.s=new q(s.s,16),s.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=s.recoveryParam)}var hr=ur;function Ls(){this.place=0}function Cr(s,t){var e=s[t.place++];if(!(e&128))return e;var r=e&15;if(r===0||r>4)return!1;for(var n=0,i=0,a=t.place;i<r;i++,a++)n<<=8,n|=s[a],n>>>=0;return n<=127?!1:(t.place=a,n)}function Si(s){for(var t=0,e=s.length-1;!s[t]&&!(s[t+1]&128)&&t<e;)t++;return t===0?s:s.slice(t)}ur.prototype._importDER=function(t,e){t=Xt.toArray(t,e);var r=new Ls;if(t[r.place++]!==48)return!1;var n=Cr(t,r);if(n===!1||n+r.place!==t.length||t[r.place++]!==2)return!1;var i=Cr(t,r);if(i===!1)return!1;var a=t.slice(r.place,i+r.place);if(r.place+=i,t[r.place++]!==2)return!1;var u=Cr(t,r);if(u===!1||t.length!==u+r.place)return!1;var h=t.slice(r.place,u+r.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(h[0]===0)if(h[1]&128)h=h.slice(1);else return!1;return this.r=new q(a),this.s=new q(h),this.recoveryParam=null,!0};function Or(s,t){if(t<128){s.push(t);return}var e=1+(Math.log(t)/Math.LN2>>>3);for(s.push(e|128);--e;)s.push(t>>>(e<<3)&255);s.push(t)}ur.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),r[0]&128&&(r=[0].concat(r)),e=Si(e),r=Si(r);!r[0]&&!(r[1]&128);)r=r.slice(1);var n=[2];Or(n,e.length),n=n.concat(e),n.push(2),Or(n,r.length);var i=n.concat(r),a=[48];return Or(a,i.length),a=a.concat(i),Xt.encode(a,t)};var Ds=function(){throw new Error("unsupported")},En=Xt.assert;function Zt(s){if(!(this instanceof Zt))return new Zt(s);typeof s=="string"&&(En(Object.prototype.hasOwnProperty.call(Xe,s),"Unknown curve "+s),s=Xe[s]),s instanceof Xe.PresetCurve&&(s={curve:s}),this.curve=s.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=s.curve.g,this.g.precompute(s.curve.n.bitLength()+1),this.hash=s.hash||s.curve.hash}var qs=Zt;Zt.prototype.keyPair=function(t){return new ti(this,t)};Zt.prototype.keyFromPrivate=function(t,e){return ti.fromPrivate(this,t,e)};Zt.prototype.keyFromPublic=function(t,e){return ti.fromPublic(this,t,e)};Zt.prototype.genKeyPair=function(t){t||(t={});for(var e=new kn({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Ds(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new q(2));;){var i=new q(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}};Zt.prototype._truncateToN=function(t,e){var r=t.byteLength()*8-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t};Zt.prototype.sign=function(t,e,r,n){typeof r=="object"&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new q(t,16));for(var i=this.n.byteLength(),a=e.getPrivate().toArray("be",i),u=t.toArray("be",i),h=new kn({hash:this.hash,entropy:a,nonce:u,pers:n.pers,persEnc:n.persEnc||"utf8"}),d=this.n.sub(new q(1)),p=0;;p++){var A=n.k?n.k(p):new q(h.generate(this.n.byteLength()));if(A=this._truncateToN(A,!0),!(A.cmpn(1)<=0||A.cmp(d)>=0)){var M=this.g.mul(A);if(!M.isInfinity()){var E=M.getX(),_=E.umod(this.n);if(_.cmpn(0)!==0){var I=A.invm(this.n).mul(_.mul(e.getPrivate()).iadd(t));if(I=I.umod(this.n),I.cmpn(0)!==0){var T=(M.getY().isOdd()?1:0)|(E.cmp(_)!==0?2:0);return n.canonical&&I.cmp(this.nh)>0&&(I=this.n.sub(I),T^=1),new hr({r:_,s:I,recoveryParam:T})}}}}}};Zt.prototype.verify=function(t,e,r,n){t=this._truncateToN(new q(t,16)),r=this.keyFromPublic(r,n),e=new hr(e,"hex");var i=e.r,a=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var u=a.invm(this.n),h=u.mul(t).umod(this.n),d=u.mul(i).umod(this.n),p;return this.curve._maxwellTrick?(p=this.g.jmulAdd(h,r.getPublic(),d),p.isInfinity()?!1:p.eqXToP(i)):(p=this.g.mulAdd(h,r.getPublic(),d),p.isInfinity()?!1:p.getX().umod(this.n).cmp(i)===0)};Zt.prototype.recoverPubKey=function(s,t,e,r){En((3&e)===e,"The recovery param is more than two bits"),t=new hr(t,r);var n=this.n,i=new q(s),a=t.r,u=t.s,h=e&1,d=e>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");d?a=this.curve.pointFromX(a.add(this.curve.n),h):a=this.curve.pointFromX(a,h);var p=t.r.invm(n),A=n.sub(i).mul(p).umod(n),M=u.mul(p).umod(n);return this.g.mulAdd(A,a,M)};Zt.prototype.getKeyRecoveryParam=function(s,t,e,r){if(t=new hr(t,r),t.recoveryParam!==null)return t.recoveryParam;for(var n=0;n<4;n++){var i;try{i=this.recoverPubKey(s,t,n)}catch{continue}if(i.eq(e))return n}throw new Error("Unable to find valid recovery factor")};var Fs=Ne(function(s,t){var e=t;e.version="6.5.4",e.utils=Xt,e.rand=function(){throw new Error("unsupported")},e.curve=We,e.curves=Xe,e.ec=qs,e.eddsa=null}),Us=Fs.ec;const Gs="signing-key/5.7.0",Qr=new x(Gs);let Lr=null;function oe(){return Lr||(Lr=new Us("secp256k1")),Lr}class zs{constructor(t){R(this,"curve","secp256k1"),R(this,"privateKey",Q(t)),Ee(this.privateKey)!==32&&Qr.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=oe().keyFromPrivate(K(this.privateKey));R(this,"publicKey","0x"+e.getPublic(!1,"hex")),R(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),R(this,"_isSigningKey",!0)}_addPoint(t){const e=oe().keyFromPublic(K(this.publicKey)),r=oe().keyFromPublic(K(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=oe().keyFromPrivate(K(this.privateKey)),r=K(t);r.length!==32&&Qr.throwArgumentError("bad digest length","digest",t);const n=e.sign(r,{canonical:!0});return sr({recoveryParam:n.recoveryParam,r:Dt("0x"+n.r.toString(16),32),s:Dt("0x"+n.s.toString(16),32)})}computeSharedSecret(t){const e=oe().keyFromPrivate(K(this.privateKey)),r=oe().keyFromPublic(K(xn(t)));return Dt("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function Js(s,t){const e=sr(t),r={r:K(e.r),s:K(e.s)};return"0x"+oe().recoverPubKey(K(s),r,e.recoveryParam).encode("hex",!1)}function xn(s,t){const e=K(s);if(e.length===32){const r=new zs(e);return t?"0x"+oe().keyFromPrivate(e).getPublic(!0,"hex"):r.publicKey}else{if(e.length===33)return t?Q(e):"0x"+oe().keyFromPublic(e).getPublic(!1,"hex");if(e.length===65)return t?"0x"+oe().keyFromPublic(e).getPublic(!0,"hex"):Q(e)}return Qr.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Ks="transactions/5.7.0",he=new x(Ks);var Ri;(function(s){s[s.legacy=0]="legacy",s[s.eip2930=1]="eip2930",s[s.eip1559=2]="eip1559"})(Ri||(Ri={}));function ei(s){return s==="0x"?null:ue(s)}function Gt(s){return s==="0x"?Un:O.from(s)}function Hs(s){const t=xn(s);return ue(Ht(Qt(Ht(t,1)),12))}function Mn(s,t){return Hs(Js(K(s),t))}function Yt(s,t){const e=Fe(O.from(s).toHexString());return e.length>32&&he.throwArgumentError("invalid length for "+t,"transaction:"+t,s),e}function Dr(s,t){return{address:ue(s),storageKeys:(t||[]).map((e,r)=>(Ee(e)!==32&&he.throwArgumentError("invalid access list storageKey",`accessList[${s}:${r}]`,e),e.toLowerCase()))}}function Se(s){if(Array.isArray(s))return s.map((e,r)=>Array.isArray(e)?(e.length>2&&he.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${r}]`,e),Dr(e[0],e[1])):Dr(e.address,e.storageKeys));const t=Object.keys(s).map(e=>{const r=s[e].reduce((n,i)=>(n[i]=!0,n),{});return Dr(e,Object.keys(r).sort())});return t.sort((e,r)=>e.address.localeCompare(r.address)),t}function _n(s){return Se(s).map(t=>[t.address,t.storageKeys])}function Qs(s,t){if(s.gasPrice!=null){const r=O.from(s.gasPrice),n=O.from(s.maxFeePerGas||0);r.eq(n)||he.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:r,maxFeePerGas:n})}const e=[Yt(s.chainId||0,"chainId"),Yt(s.nonce||0,"nonce"),Yt(s.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Yt(s.maxFeePerGas||0,"maxFeePerGas"),Yt(s.gasLimit||0,"gasLimit"),s.to!=null?ue(s.to):"0x",Yt(s.value||0,"value"),s.data||"0x",_n(s.accessList||[])];if(t){const r=sr(t);e.push(Yt(r.recoveryParam,"recoveryParam")),e.push(Fe(r.r)),e.push(Fe(r.s))}return Wt(["0x02",Xr(e)])}function js(s,t){const e=[Yt(s.chainId||0,"chainId"),Yt(s.nonce||0,"nonce"),Yt(s.gasPrice||0,"gasPrice"),Yt(s.gasLimit||0,"gasLimit"),s.to!=null?ue(s.to):"0x",Yt(s.value||0,"value"),s.data||"0x",_n(s.accessList||[])];if(t){const r=sr(t);e.push(Yt(r.recoveryParam,"recoveryParam")),e.push(Fe(r.r)),e.push(Fe(r.s))}return Wt(["0x01",Xr(e)])}function In(s,t,e){try{const r=Gt(t[0]).toNumber();if(r!==0&&r!==1)throw new Error("bad recid");s.v=r}catch{he.throwArgumentError("invalid v for transaction type: 1","v",t[0])}s.r=Dt(t[1],32),s.s=Dt(t[2],32);try{const r=Qt(e(s));s.from=Mn(r,{r:s.r,s:s.s,recoveryParam:s.v})}catch{}}function Ys(s){const t=Wr(s.slice(1));t.length!==9&&t.length!==12&&he.throwArgumentError("invalid component count for transaction type: 2","payload",Q(s));const e=Gt(t[2]),r=Gt(t[3]),n={type:2,chainId:Gt(t[0]).toNumber(),nonce:Gt(t[1]).toNumber(),maxPriorityFeePerGas:e,maxFeePerGas:r,gasPrice:null,gasLimit:Gt(t[4]),to:ei(t[5]),value:Gt(t[6]),data:t[7],accessList:Se(t[8])};return t.length===9||(n.hash=Qt(s),In(n,t.slice(9),Qs)),n}function Ws(s){const t=Wr(s.slice(1));t.length!==8&&t.length!==11&&he.throwArgumentError("invalid component count for transaction type: 1","payload",Q(s));const e={type:1,chainId:Gt(t[0]).toNumber(),nonce:Gt(t[1]).toNumber(),gasPrice:Gt(t[2]),gasLimit:Gt(t[3]),to:ei(t[4]),value:Gt(t[5]),data:t[6],accessList:Se(t[7])};return t.length===8||(e.hash=Qt(s),In(e,t.slice(8),js)),e}function Xs(s){const t=Wr(s);t.length!==9&&t.length!==6&&he.throwArgumentError("invalid raw transaction","rawTransaction",s);const e={nonce:Gt(t[0]).toNumber(),gasPrice:Gt(t[1]),gasLimit:Gt(t[2]),to:ei(t[3]),value:Gt(t[4]),data:t[5],chainId:0};if(t.length===6)return e;try{e.v=O.from(t[6]).toNumber()}catch{return e}if(e.r=Dt(t[7],32),e.s=Dt(t[8],32),O.from(e.r).isZero()&&O.from(e.s).isZero())e.chainId=e.v,e.v=0;else{e.chainId=Math.floor((e.v-35)/2),e.chainId<0&&(e.chainId=0);let r=e.v-27;const n=t.slice(0,6);e.chainId!==0&&(n.push(Q(e.chainId)),n.push("0x"),n.push("0x"),r-=e.chainId*2+8);const i=Qt(Xr(n));try{e.from=Mn(i,{r:Q(e.r),s:Q(e.s),recoveryParam:r})}catch{}e.hash=Qt(s)}return e.type=null,e}function Vs(s){const t=K(s);if(t[0]>127)return Xs(t);switch(t[0]){case 1:return Ws(t);case 2:return Ys(t)}return he.throwError(`unsupported transaction type: ${t[0]}`,x.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:t[0]})}class Pn{constructor(t){R(this,"alphabet",t),R(this,"base",t.length),R(this,"_alphabetMap",{}),R(this,"_leader",t.charAt(0));for(let e=0;e<t.length;e++)this._alphabetMap[t.charAt(e)]=e}encode(t){let e=K(t);if(e.length===0)return"";let r=[0];for(let i=0;i<e.length;++i){let a=e[i];for(let u=0;u<r.length;++u)a+=r[u]<<8,r[u]=a%this.base,a=a/this.base|0;for(;a>0;)r.push(a%this.base),a=a/this.base|0}let n="";for(let i=0;e[i]===0&&i<e.length-1;++i)n+=this._leader;for(let i=r.length-1;i>=0;--i)n+=this.alphabet[r[i]];return n}decode(t){if(typeof t!="string")throw new TypeError("Expected String");let e=[];if(t.length===0)return new Uint8Array(e);e.push(0);for(let r=0;r<t.length;r++){let n=this._alphabetMap[t[r]];if(n===void 0)throw new Error("Non-base"+this.base+" character");let i=n;for(let a=0;a<e.length;++a)i+=e[a]*this.base,e[a]=i&255,i>>=8;for(;i>0;)e.push(i&255),i>>=8}for(let r=0;t[r]===this._leader&&r<t.length-1;++r)e.push(0);return K(new Uint8Array(e.reverse()))}}new Pn("abcdefghijklmnopqrstuvwxyz234567");const jr=new Pn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function Ti(s){return"0x"+se.sha256().update(K(s)).digest("hex")}function Zs(s){s=s.slice();for(let t=s.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1)),r=s[t];s[t]=s[e],s[e]=r}return s}const $s="networks/5.7.1",Bi=new x($s);function to(s){return s&&typeof s.renetwork=="function"}function fe(s){const t=function(e,r){r==null&&(r={});const n=[];if(e.InfuraProvider&&r.infura!=="-")try{n.push(new e.InfuraProvider(s,r.infura))}catch{}if(e.EtherscanProvider&&r.etherscan!=="-")try{n.push(new e.EtherscanProvider(s,r.etherscan))}catch{}if(e.AlchemyProvider&&r.alchemy!=="-")try{n.push(new e.AlchemyProvider(s,r.alchemy))}catch{}if(e.PocketProvider&&r.pocket!=="-"){const i=["goerli","ropsten","rinkeby","sepolia"];try{const a=new e.PocketProvider(s,r.pocket);a.network&&i.indexOf(a.network.name)===-1&&n.push(a)}catch{}}if(e.CloudflareProvider&&r.cloudflare!=="-")try{n.push(new e.CloudflareProvider(s))}catch{}if(e.AnkrProvider&&r.ankr!=="-")try{const i=["ropsten"],a=new e.AnkrProvider(s,r.ankr);a.network&&i.indexOf(a.network.name)===-1&&n.push(a)}catch{}if(n.length===0)return null;if(e.FallbackProvider){let i=1;return r.quorum!=null?i=r.quorum:s==="homestead"&&(i=2),new e.FallbackProvider(n,i)}return n[0]};return t.renetwork=function(e){return fe(e)},t}function ir(s,t){const e=function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(s,t):null};return e.renetwork=function(r){return ir(s,r)},e}const Ci={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:fe("homestead")},Oi={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:fe("ropsten")},Li={chainId:63,name:"classicMordor",_defaultProvider:ir("https://www.ethercluster.com/mordor","classicMordor")},ze={unspecified:{chainId:0,name:"unspecified"},homestead:Ci,mainnet:Ci,morden:{chainId:2,name:"morden"},ropsten:Oi,testnet:Oi,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:fe("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:fe("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:fe("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:fe("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:ir("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:Li,classicTestnet:Li,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:ir("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:fe("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:fe("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function Nn(s){if(s==null)return null;if(typeof s=="number"){for(const r in ze){const n=ze[r];if(n.chainId===s)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:s,name:"unknown"}}if(typeof s=="string"){const r=ze[s];return r==null?null:{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress,_defaultProvider:r._defaultProvider||null}}const t=ze[s.name];if(!t)return typeof s.chainId!="number"&&Bi.throwArgumentError("invalid network chainId","network",s),s;s.chainId!==0&&s.chainId!==t.chainId&&Bi.throwArgumentError("network chainId mismatch","network",s);let e=s._defaultProvider||null;return e==null&&t._defaultProvider&&(to(t._defaultProvider)?e=t._defaultProvider.renetwork(s):e=t._defaultProvider),{name:s.name,chainId:t.chainId,ensAddress:s.ensAddress||t.ensAddress||null,_defaultProvider:e}}const eo="web/5.7.1";var ro=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};function io(s,t){return ro(this,void 0,void 0,function*(){t==null&&(t={});const e={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};if(t.skipFetchSetup!==!0&&(e.mode="cors",e.cache="no-cache",e.credentials="same-origin",e.redirect="follow",e.referrer="client"),t.fetchOptions!=null){const a=t.fetchOptions;a.mode&&(e.mode=a.mode),a.cache&&(e.cache=a.cache),a.credentials&&(e.credentials=a.credentials),a.redirect&&(e.redirect=a.redirect),a.referrer&&(e.referrer=a.referrer)}const r=yield fetch(s,e),n=yield r.arrayBuffer(),i={};return r.headers.forEach?r.headers.forEach((a,u)=>{i[u.toLowerCase()]=a}):r.headers.keys().forEach(a=>{i[a.toLowerCase()]=r.headers.get(a)}),{headers:i,statusCode:r.status,statusMessage:r.statusText,body:K(new Uint8Array(n))}})}var no=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const ie=new x(eo);function Di(s){return new Promise(t=>{setTimeout(t,s)})}function ce(s,t){if(s==null)return null;if(typeof s=="string")return s;if(Gn(s)){if(t&&(t.split("/")[0]==="text"||t.split(";")[0].trim()==="application/json"))try{return or(s)}catch{}return Q(s)}return s}function so(s){return ke(s.replace(/%([0-9a-f][0-9a-f])/gi,(t,e)=>String.fromCharCode(parseInt(e,16))))}function oo(s,t,e){const r=typeof s=="object"&&s.throttleLimit!=null?s.throttleLimit:12;ie.assertArgument(r>0&&r%1===0,"invalid connection throttle limit","connection.throttleLimit",r);const n=typeof s=="object"?s.throttleCallback:null,i=typeof s=="object"&&typeof s.throttleSlotInterval=="number"?s.throttleSlotInterval:100;ie.assertArgument(i>0&&i%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",i);const a=typeof s=="object"?!!s.errorPassThrough:!1,u={};let h=null;const d={method:"GET"};let p=!1,A=2*60*1e3;if(typeof s=="string")h=s;else if(typeof s=="object"){if((s==null||s.url==null)&&ie.throwArgumentError("missing URL","connection.url",s),h=s.url,typeof s.timeout=="number"&&s.timeout>0&&(A=s.timeout),s.headers)for(const P in s.headers)u[P.toLowerCase()]={key:P,value:String(s.headers[P])},["if-none-match","if-modified-since"].indexOf(P.toLowerCase())>=0&&(p=!0);if(d.allowGzip=!!s.allowGzip,s.user!=null&&s.password!=null){h.substring(0,6)!=="https:"&&s.allowInsecureAuthentication!==!0&&ie.throwError("basic authentication requires a secure https url",x.errors.INVALID_ARGUMENT,{argument:"url",url:h,user:s.user,password:"[REDACTED]"});const P=s.user+":"+s.password;u.authorization={key:"Authorization",value:"Basic "+hn(ke(P))}}s.skipFetchSetup!=null&&(d.skipFetchSetup=!!s.skipFetchSetup),s.fetchOptions!=null&&(d.fetchOptions=Ct(s.fetchOptions))}const M=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),E=h?h.match(M):null;if(E)try{const P={statusCode:200,statusMessage:"OK",headers:{"content-type":E[1]||"text/plain"},body:E[2]?un(E[3]):so(E[3])};let S=P.body;return e&&(S=e(P.body,P)),Promise.resolve(S)}catch(P){ie.throwError("processing response error",x.errors.SERVER_ERROR,{body:ce(E[1],E[2]),error:P,requestBody:null,requestMethod:"GET",url:h})}t&&(d.method="POST",d.body=t,u["content-type"]==null&&(u["content-type"]={key:"Content-Type",value:"application/octet-stream"}),u["content-length"]==null&&(u["content-length"]={key:"Content-Length",value:String(t.length)}));const _={};Object.keys(u).forEach(P=>{const S=u[P];_[S.key]=S.value}),d.headers=_;const I=function(){let P=null;return{promise:new Promise(function(J,F){A&&(P=setTimeout(()=>{P!=null&&(P=null,F(ie.makeError("timeout",x.errors.TIMEOUT,{requestBody:ce(d.body,_["content-type"]),requestMethod:d.method,timeout:A,url:h})))},A))}),cancel:function(){P!=null&&(clearTimeout(P),P=null)}}}(),T=function(){return no(this,void 0,void 0,function*(){for(let P=0;P<r;P++){let S=null;try{if(S=yield io(h,d),P<r){if(S.statusCode===301||S.statusCode===302){const J=S.headers.location||"";if(d.method==="GET"&&J.match(/^https:/)){h=S.headers.location;continue}}else if(S.statusCode===429){let J=!0;if(n&&(J=yield n(P,h)),J){let F=0;const z=S.headers["retry-after"];typeof z=="string"&&z.match(/^[1-9][0-9]*$/)?F=parseInt(z)*1e3:F=i*parseInt(String(Math.random()*Math.pow(2,P))),yield Di(F);continue}}}}catch(J){S=J.response,S==null&&(I.cancel(),ie.throwError("missing response",x.errors.SERVER_ERROR,{requestBody:ce(d.body,_["content-type"]),requestMethod:d.method,serverError:J,url:h}))}let G=S.body;if(p&&S.statusCode===304?G=null:!a&&(S.statusCode<200||S.statusCode>=300)&&(I.cancel(),ie.throwError("bad response",x.errors.SERVER_ERROR,{status:S.statusCode,headers:S.headers,body:ce(G,S.headers?S.headers["content-type"]:null),requestBody:ce(d.body,_["content-type"]),requestMethod:d.method,url:h})),e)try{const J=yield e(G,S);return I.cancel(),J}catch(J){if(J.throttleRetry&&P<r){let F=!0;if(n&&(F=yield n(P,h)),F){const z=i*parseInt(String(Math.random()*Math.pow(2,P)));yield Di(z);continue}}I.cancel(),ie.throwError("processing response error",x.errors.SERVER_ERROR,{body:ce(G,S.headers?S.headers["content-type"]:null),error:J,requestBody:ce(d.body,_["content-type"]),requestMethod:d.method,url:h})}return I.cancel(),G}return ie.throwError("failed response",x.errors.SERVER_ERROR,{requestBody:ce(d.body,_["content-type"]),requestMethod:d.method,url:h})})}();return Promise.race([I.promise,T])}function Ge(s,t,e){let r=(i,a)=>{let u=null;if(i!=null)try{u=JSON.parse(or(i))}catch(h){ie.throwError("invalid JSON",x.errors.SERVER_ERROR,{body:i,error:h})}return e&&(u=e(u,a)),u},n=null;if(t!=null){n=ke(t);const i=typeof s=="string"?{url:s}:Ct(s);i.headers?Object.keys(i.headers).filter(u=>u.toLowerCase()==="content-type").length!==0||(i.headers=Ct(i.headers),i.headers["content-type"]="application/json"):i.headers={"content-type":"application/json"},s=i}return oo(s,n,r)}function _e(s,t){return t||(t={}),t=Ct(t),t.floor==null&&(t.floor=0),t.ceiling==null&&(t.ceiling=1e4),t.interval==null&&(t.interval=250),new Promise(function(e,r){let n=null,i=!1;const a=()=>i?!1:(i=!0,n&&clearTimeout(n),!0);t.timeout&&(n=setTimeout(()=>{a()&&r(new Error("timeout"))},t.timeout));const u=t.retryLimit;let h=0;function d(){return s().then(function(p){if(p!==void 0)a()&&e(p);else if(t.oncePoll)t.oncePoll.once("poll",d);else if(t.onceBlock)t.onceBlock.once("block",d);else if(!i){if(h++,h>u){a()&&r(new Error("retry limit reached"));return}let A=t.interval*parseInt(String(Math.random()*Math.pow(2,h)));A<t.floor&&(A=t.floor),A>t.ceiling&&(A=t.ceiling),setTimeout(d,A)}return null},function(p){a()&&r(p)})}d()})}const Jt="providers/5.7.2",Re=new x(Jt);class N{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),a=this.hash.bind(this),u=this.hex.bind(this),h=this.number.bind(this),d=this.type.bind(this),p=A=>this.data(A,!0);return t.transaction={hash:a,type:d,accessList:N.allowNull(this.accessList.bind(this),null),blockHash:N.allowNull(a,null),blockNumber:N.allowNull(h,null),transactionIndex:N.allowNull(h,null),confirmations:N.allowNull(h,null),from:e,gasPrice:N.allowNull(r),maxPriorityFeePerGas:N.allowNull(r),maxFeePerGas:N.allowNull(r),gasLimit:r,to:N.allowNull(e,null),value:r,nonce:h,data:i,r:N.allowNull(this.uint256),s:N.allowNull(this.uint256),v:N.allowNull(h),creates:N.allowNull(e,null),raw:N.allowNull(i)},t.transactionRequest={from:N.allowNull(e),nonce:N.allowNull(h),gasLimit:N.allowNull(r),gasPrice:N.allowNull(r),maxPriorityFeePerGas:N.allowNull(r),maxFeePerGas:N.allowNull(r),to:N.allowNull(e),value:N.allowNull(r),data:N.allowNull(p),type:N.allowNull(h),accessList:N.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:h,blockNumber:h,transactionHash:a,address:e,topics:N.arrayOf(a),data:i,logIndex:h,blockHash:a},t.receipt={to:N.allowNull(this.address,null),from:N.allowNull(this.address,null),contractAddress:N.allowNull(e,null),transactionIndex:h,root:N.allowNull(u),gasUsed:r,logsBloom:N.allowNull(i),blockHash:a,transactionHash:a,logs:N.arrayOf(this.receiptLog.bind(this)),blockNumber:h,confirmations:N.allowNull(h,null),cumulativeGasUsed:r,effectiveGasPrice:N.allowNull(r),status:N.allowNull(h),type:d},t.block={hash:N.allowNull(a),parentHash:a,number:h,timestamp:h,nonce:N.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:N.allowNull(e),extraData:i,transactions:N.allowNull(N.arrayOf(a)),baseFeePerGas:N.allowNull(r)},t.blockWithTransactions=Ct(t.block),t.blockWithTransactions.transactions=N.allowNull(N.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:N.allowNull(n,void 0),toBlock:N.allowNull(n,void 0),blockHash:N.allowNull(a,void 0),address:N.allowNull(e,void 0),topics:N.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:N.allowNull(h),blockHash:N.allowNull(a),transactionIndex:h,removed:N.allowNull(this.boolean.bind(this)),address:e,data:N.allowFalsish(i,"0x"),topics:N.arrayOf(a),transactionHash:a,logIndex:h},t}accessList(t){return Se(t||[])}number(t){return t==="0x"?0:O.from(t).toNumber()}type(t){return t==="0x"||t==null?0:O.from(t).toNumber()}bigNumber(t){return O.from(t)}boolean(t){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t=t.toLowerCase(),t==="true")return!0;if(t==="false")return!1}throw new Error("invalid boolean - "+t)}hex(t,e){return typeof t=="string"&&(!e&&t.substring(0,2)!=="0x"&&(t="0x"+t),Bt(t))?t.toLowerCase():Re.throwArgumentError("invalid hash","value",t)}data(t,e){const r=this.hex(t,e);if(r.length%2!==0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return ue(t)}callAddress(t){if(!Bt(t,32))return null;const e=ue(Ht(t,12));return e===Kn?null:e}contractAddress(t){return zn(t)}blockTag(t){if(t==null)return"latest";if(t==="earliest")return"0x0";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(typeof t=="number"||Bt(t))return ar(t);throw new Error("invalid blockTag")}hash(t,e){const r=this.hex(t,e);return Ee(r)!==32?Re.throwArgumentError("invalid hash","value",t):r}difficulty(t){if(t==null)return null;const e=O.from(t);try{return e.toNumber()}catch{}return null}uint256(t){if(!Bt(t))throw new Error("invalid uint256");return Dt(t,32)}_block(t,e){t.author!=null&&t.miner==null&&(t.miner=t.author);const r=t._difficulty!=null?t._difficulty:t.difficulty,n=N.check(e,t);return n._difficulty=r==null?null:O.from(r),n}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return N.check(this.formats.transactionRequest,t)}transactionResponse(t){t.gas!=null&&t.gasLimit==null&&(t.gasLimit=t.gas),t.to&&O.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),t.input!=null&&t.data==null&&(t.data=t.input),t.to==null&&t.creates==null&&(t.creates=this.contractAddress(t)),(t.type===1||t.type===2)&&t.accessList==null&&(t.accessList=[]);const e=N.check(this.formats.transaction,t);if(t.chainId!=null){let r=t.chainId;Bt(r)&&(r=O.from(r).toNumber()),e.chainId=r}else{let r=t.networkId;r==null&&e.v==null&&(r=t.chainId),Bt(r)&&(r=O.from(r).toNumber()),typeof r!="number"&&e.v!=null&&(r=(e.v-35)/2,r<0&&(r=0),r=parseInt(r)),typeof r!="number"&&(r=0),e.chainId=r}return e.blockHash&&e.blockHash.replace(/0/g,"")==="x"&&(e.blockHash=null),e}transaction(t){return Vs(t)}receiptLog(t){return N.check(this.formats.receiptLog,t)}receipt(t){const e=N.check(this.formats.receipt,t);if(e.root!=null)if(e.root.length<=4){const r=O.from(e.root).toNumber();r===0||r===1?(e.status!=null&&e.status!==r&&Re.throwArgumentError("alt-root-status/status mismatch","value",{root:e.root,status:e.status}),e.status=r,delete e.root):Re.throwArgumentError("invalid alt-root-status","value.root",e.root)}else e.root.length!==66&&Re.throwArgumentError("invalid root hash","value.root",e.root);return e.status!=null&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(e=>this.topics(e)):t!=null?this.hash(t,!0):null}filter(t){return N.check(this.formats.filter,t)}filterLog(t){return N.check(this.formats.filterLog,t)}static check(t,e){const r={};for(const n in t)try{const i=t[n](e[n]);i!==void 0&&(r[n]=i)}catch(i){throw i.checkKey=n,i.checkValue=e[n],i}return r}static allowNull(t,e){return function(r){return r==null?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");const r=[];return e.forEach(function(n){r.push(t(n))}),r}}}function ao(s){return s&&typeof s.isCommunityResource=="function"}function qi(s){return ao(s)&&s.isCommunityResource()}let Fi=!1;function cr(){Fi||(Fi=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var D=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const U=new x(Jt),fo=10;function Ui(s){return s==null?"null":(Ee(s)!==32&&U.throwArgumentError("invalid topic","topic",s),s.toLowerCase())}function Gi(s){for(s=s.slice();s.length>0&&s[s.length-1]==null;)s.pop();return s.map(t=>{if(Array.isArray(t)){const e={};t.forEach(n=>{e[Ui(n)]=!0});const r=Object.keys(e);return r.sort(),r.join("|")}else return Ui(t)}).join("&")}function lo(s){return s===""?[]:s.split(/&/g).map(t=>{if(t==="")return[];const e=t.split("|").map(r=>r==="null"?null:r);return e.length===1?e[0]:e})}function Me(s){if(typeof s=="string"){if(s=s.toLowerCase(),Ee(s)===32)return"tx:"+s;if(s.indexOf(":")===-1)return s}else{if(Array.isArray(s))return"filter:*:"+Gi(s);if(_s.isForkEvent(s))throw U.warn("not implemented"),new Error("not implemented");if(s&&typeof s=="object")return"filter:"+(s.address||"*")+":"+Gi(s.topics||[])}throw new Error("invalid event - "+s)}function Te(){return new Date().getTime()}function zi(s){return new Promise(t=>{setTimeout(t,s)})}const uo=["block","network","pending","poll"];class ho{constructor(t,e,r){R(this,"tag",t),R(this,"listener",e),R(this,"once",r),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const t=this.tag.split(":");return t[0]!=="tx"?null:t[1]}get filter(){const t=this.tag.split(":");if(t[0]!=="filter")return null;const e=t[1],r=lo(t[2]),n={};return r.length>0&&(n.topics=r),e&&e!=="*"&&(n.address=e),n}pollable(){return this.tag.indexOf(":")>=0||uo.indexOf(this.tag)>=0}}const co={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function qr(s){return Dt(O.from(s).toHexString(),32)}function Ji(s){return jr.encode(be([s,Ht(Ti(Ti(s)),0,4)]))}const Sn=new RegExp("^(ipfs)://(.*)$","i"),Ki=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Sn,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Ve(s,t){try{return or(Ue(s,t))}catch{}return null}function Ue(s,t){if(s==="0x")return null;const e=O.from(Ht(s,t,t+32)).toNumber(),r=O.from(Ht(s,e,e+32)).toNumber();return Ht(s,e+32,e+32+r)}function Fr(s){return s.match(/^ipfs:\/\/ipfs\//i)?s=s.substring(12):s.match(/^ipfs:\/\//i)?s=s.substring(7):U.throwArgumentError("unsupported IPFS format","link",s),`https://gateway.ipfs.io/ipfs/${s}`}function Hi(s){const t=K(s);if(t.length>32)throw new Error("internal; should not happen");const e=new Uint8Array(32);return e.set(t,32-t.length),e}function po(s){if(s.length%32===0)return s;const t=new Uint8Array(Math.ceil(s.length/32)*32);return t.set(s),t}function Rn(s){const t=[];let e=0;for(let r=0;r<s.length;r++)t.push(null),e+=32;for(let r=0;r<s.length;r++){const n=K(s[r]);t[r]=Hi(e),t.push(Hi(n.length)),t.push(po(n)),e+=32+Math.ceil(n.length/32)*32}return Wt(t)}class Qi{constructor(t,e,r,n){R(this,"provider",t),R(this,"name",r),R(this,"address",t.formatter.address(e)),R(this,"_resolvedAddress",n)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(t=>O.from(t).eq(1)).catch(t=>{if(t.code===x.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,t})),this._supportsEip2544}_fetch(t,e){return D(this,void 0,void 0,function*(){const r={to:this.address,ccipReadEnabled:!0,data:Wt([t,Ye(this.name),e||"0x"])};let n=!1;(yield this.supportsWildcard())&&(n=!0,r.data=Wt(["0x9061b923",Rn([gs(this.name),r.data])]));try{let i=yield this.provider.call(r);return K(i).length%32===4&&U.throwError("resolver threw error",x.errors.CALL_EXCEPTION,{transaction:r,data:i}),n&&(i=Ue(i,0)),i}catch(i){if(i.code===x.errors.CALL_EXCEPTION)return null;throw i}})}_fetchBytes(t,e){return D(this,void 0,void 0,function*(){const r=yield this._fetch(t,e);return r!=null?Ue(r,0):null})}_getAddress(t,e){const r=co[String(t)];if(r==null&&U.throwError(`unsupported coin type: ${t}`,x.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),r.ilk==="eth")return this.provider.formatter.address(e);const n=K(e);if(r.p2pkh!=null){const i=e.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(i){const a=parseInt(i[1],16);if(i[2].length===a*2&&a>=1&&a<=75)return Ji(be([[r.p2pkh],"0x"+i[2]]))}}if(r.p2sh!=null){const i=e.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(i){const a=parseInt(i[1],16);if(i[2].length===a*2&&a>=1&&a<=75)return Ji(be([[r.p2sh],"0x"+i[2]]))}}if(r.prefix!=null){const i=n[1];let a=n[0];if(a===0?i!==20&&i!==32&&(a=-1):a=-1,a>=0&&n.length===2+i&&i>=1&&i<=75){const u=ki.toWords(n.slice(2));return u.unshift(a),ki.encode(r.prefix,u)}}return null}getAddress(t){return D(this,void 0,void 0,function*(){if(t==null&&(t=60),t===60)try{const n=yield this._fetch("0x3b3b57de");return n==="0x"||n===Hn?null:this.provider.formatter.callAddress(n)}catch(n){if(n.code===x.errors.CALL_EXCEPTION)return null;throw n}const e=yield this._fetchBytes("0xf1cb7e06",qr(t));if(e==null||e==="0x")return null;const r=this._getAddress(t,e);return r==null&&U.throwError("invalid or unsupported coin data",x.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:e}),r})}getAvatar(){return D(this,void 0,void 0,function*(){const t=[{type:"name",content:this.name}];try{const e=yield this.getText("avatar");if(e==null)return null;for(let r=0;r<Ki.length;r++){const n=e.match(Ki[r]);if(n==null)continue;const i=n[1].toLowerCase();switch(i){case"https":return t.push({type:"url",content:e}),{linkage:t,url:e};case"data":return t.push({type:"data",content:e}),{linkage:t,url:e};case"ipfs":return t.push({type:"ipfs",content:e}),{linkage:t,url:Fr(e)};case"erc721":case"erc1155":{const a=i==="erc721"?"0xc87b56dd":"0x0e89341c";t.push({type:i,content:e});const u=this._resolvedAddress||(yield this.getAddress()),h=(n[2]||"").split("/");if(h.length!==2)return null;const d=yield this.provider.formatter.address(h[0]),p=Dt(O.from(h[1]).toHexString(),32);if(i==="erc721"){const I=this.provider.formatter.callAddress(yield this.provider.call({to:d,data:Wt(["0x6352211e",p])}));if(u!==I)return null;t.push({type:"owner",content:I})}else if(i==="erc1155"){const I=O.from(yield this.provider.call({to:d,data:Wt(["0x00fdd58e",Dt(u,32),p])}));if(I.isZero())return null;t.push({type:"balance",content:I.toString()})}const A={to:this.provider.formatter.address(h[0]),data:Wt([a,p])};let M=Ve(yield this.provider.call(A),0);if(M==null)return null;t.push({type:"metadata-url-base",content:M}),i==="erc1155"&&(M=M.replace("{id}",p.substring(2)),t.push({type:"metadata-url-expanded",content:M})),M.match(/^ipfs:/i)&&(M=Fr(M)),t.push({type:"metadata-url",content:M});const E=yield Ge(M);if(!E)return null;t.push({type:"metadata",content:JSON.stringify(E)});let _=E.image;if(typeof _!="string")return null;if(!_.match(/^(https:\/\/|data:)/i)){if(_.match(Sn)==null)return null;t.push({type:"url-ipfs",content:_}),_=Fr(_)}return t.push({type:"url",content:_}),{linkage:t,url:_}}}}}catch{}return null})}getContentHash(){return D(this,void 0,void 0,function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(t==null||t==="0x")return null;const e=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const a=parseInt(e[3],16);if(e[4].length===a*2)return"ipfs://"+jr.encode("0x"+e[1])}const r=t.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(r){const a=parseInt(r[3],16);if(r[4].length===a*2)return"ipns://"+jr.encode("0x"+r[1])}const n=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===32*2)return"bzz://"+n[1];const i=t.match(/^0x90b2c605([0-9a-f]*)$/);if(i&&i[1].length===34*2){const a={"=":"","+":"-","/":"_"};return"sia://"+hn("0x"+i[1]).replace(/[=+\/]/g,h=>a[h])}return U.throwError("invalid or unsupported content hash data",x.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})})}getText(t){return D(this,void 0,void 0,function*(){let e=ke(t);e=be([qr(64),qr(e.length),e]),e.length%32!==0&&(e=be([e,Dt("0x",32-t.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",Q(e));return r==null||r==="0x"?null:or(r)})}}let Ur=null,go=1;class ri extends lr{constructor(t){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),R(this,"anyNetwork",t==="any"),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(e=>{}),this._ready().catch(e=>{});else{const e=pe(new.target,"getNetwork")(t);e?(R(this,"_network",e),this.emit("network",e,null)):U.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return D(this,void 0,void 0,function*(){if(this._network==null){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch{}t==null&&(t=yield this.detectNetwork()),t||U.throwError("no network detected",x.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=t:R(this,"_network",t),this.emit("network",t,null))}return this._network})}get ready(){return _e(()=>this._ready().then(t=>t,t=>{if(!(t.code===x.errors.NETWORK_ERROR&&t.event==="noNetwork"))throw t}))}static getFormatter(){return Ur==null&&(Ur=new N),Ur}static getNetwork(t){return Nn(t??"homestead")}ccipReadFetch(t,e,r){return D(this,void 0,void 0,function*(){if(this.disableCcipRead||r.length===0)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),a=[];for(let u=0;u<r.length;u++){const h=r[u],d=h.replace("{sender}",n).replace("{data}",i),p=h.indexOf("{data}")>=0?null:JSON.stringify({data:i,sender:n}),A=yield Ge({url:d,errorPassThrough:!0},p,(E,_)=>(E.status=_.statusCode,E));if(A.data)return A.data;const M=A.message||"unknown error";if(A.status>=400&&A.status<500)return U.throwError(`response not found during CCIP fetch: ${M}`,x.errors.SERVER_ERROR,{url:h,errorMessage:M});a.push(M)}return U.throwError(`error encountered during CCIP fetch: ${a.map(u=>JSON.stringify(u)).join(", ")}`,x.errors.SERVER_ERROR,{urls:r,errorMessages:a})})}_getInternalBlockNumber(t){return D(this,void 0,void 0,function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const n=this._internalBlockNumber;try{const i=yield n;if(Te()-i.respTime<=t)return i.blockNumber;break}catch{if(this._internalBlockNumber===n)break}}const e=Te(),r=Lt({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(n=>null,n=>n)}).then(({blockNumber:n,networkError:i})=>{if(i)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),i;const a=Te();return n=O.from(n).toNumber(),n<this._maxInternalBlockNumber&&(n=this._maxInternalBlockNumber),this._maxInternalBlockNumber=n,this._setFastBlockNumber(n),{blockNumber:n,reqTime:e,respTime:a}});return this._internalBlockNumber=r,r.catch(n=>{this._internalBlockNumber===r&&(this._internalBlockNumber=null)}),(yield r).blockNumber})}poll(){return D(this,void 0,void 0,function*(){const t=go++,e=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(n){this.emit("error",n);return}if(this._setFastBlockNumber(r),this.emit("poll",t,r),r===this._lastBlockNumber){this.emit("didPoll",t);return}if(this._emitted.block===-2&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)U.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",U.makeError("network block skew detected",x.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let n=this._emitted.block+1;n<=r;n++)this.emit("block",n);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach(n=>{if(n==="block")return;const i=this._emitted[n];i!=="pending"&&r-i>12&&delete this._emitted[n]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=r-1),this._events.forEach(n=>{switch(n.type){case"tx":{const i=n.hash;let a=this.getTransactionReceipt(i).then(u=>(!u||u.blockNumber==null||(this._emitted["t:"+i]=u.blockNumber,this.emit(i,u)),null)).catch(u=>{this.emit("error",u)});e.push(a);break}case"filter":{if(!n._inflight){n._inflight=!0,n._lastBlockNumber===-2&&(n._lastBlockNumber=r-1);const i=n.filter;i.fromBlock=n._lastBlockNumber+1,i.toBlock=r;const a=i.toBlock-this._maxFilterBlockRange;a>i.fromBlock&&(i.fromBlock=a),i.fromBlock<0&&(i.fromBlock=0);const u=this.getLogs(i).then(h=>{n._inflight=!1,h.length!==0&&h.forEach(d=>{d.blockNumber>n._lastBlockNumber&&(n._lastBlockNumber=d.blockNumber),this._emitted["b:"+d.blockHash]=d.blockNumber,this._emitted["t:"+d.transactionHash]=d.blockNumber,this.emit(i,d)})}).catch(h=>{this.emit("error",h),n._inflight=!1});e.push(u)}break}}}),this._lastBlockNumber=r,Promise.all(e).then(()=>{this.emit("didPoll",t)}).catch(n=>{this.emit("error",n)})})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return D(this,void 0,void 0,function*(){return U.throwError("provider does not support network detection",x.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return D(this,void 0,void 0,function*(){const t=yield this._ready(),e=yield this.detectNetwork();if(t.chainId!==e.chainId){if(this.anyNetwork)return this._network=e,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",e,t),yield zi(0),this._network;const r=U.makeError("underlying network changed",x.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:e});throw this.emit("error",r),r}return t})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(t){t&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if(typeof t!="number"||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=Te();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(e=>((this._fastBlockNumber==null||e>this._fastBlockNumber)&&(this._fastBlockNumber=e),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){this._fastBlockNumber!=null&&t<this._fastBlockNumber||(this._fastQueryDate=Te(),(this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e,r){return D(this,void 0,void 0,function*(){return this._waitForTransaction(t,e??1,r||0,null)})}_waitForTransaction(t,e,r,n){return D(this,void 0,void 0,function*(){const i=yield this.getTransactionReceipt(t);return(i?i.confirmations:0)>=e?i:new Promise((a,u)=>{const h=[];let d=!1;const p=function(){return d?!0:(d=!0,h.forEach(M=>{M()}),!1)},A=M=>{M.confirmations<e||p()||a(M)};if(this.on(t,A),h.push(()=>{this.removeListener(t,A)}),n){let M=n.startBlock,E=null;const _=I=>D(this,void 0,void 0,function*(){d||(yield zi(1e3),this.getTransactionCount(n.from).then(T=>D(this,void 0,void 0,function*(){if(!d){if(T<=n.nonce)M=I;else{{const P=yield this.getTransaction(t);if(P&&P.blockNumber!=null)return}for(E==null&&(E=M-3,E<n.startBlock&&(E=n.startBlock));E<=I;){if(d)return;const P=yield this.getBlockWithTransactions(E);for(let S=0;S<P.transactions.length;S++){const G=P.transactions[S];if(G.hash===t)return;if(G.from===n.from&&G.nonce===n.nonce){if(d)return;const J=yield this.waitForTransaction(G.hash,e);if(p())return;let F="replaced";G.data===n.data&&G.to===n.to&&G.value.eq(n.value)?F="repriced":G.data==="0x"&&G.from===G.to&&G.value.isZero()&&(F="cancelled"),u(U.makeError("transaction was replaced",x.errors.TRANSACTION_REPLACED,{cancelled:F==="replaced"||F==="cancelled",reason:F,replacement:this._wrapTransaction(G),hash:t,receipt:J}));return}}E++}}d||this.once("block",_)}}),T=>{d||this.once("block",_)}))});if(d)return;this.once("block",_),h.push(()=>{this.removeListener("block",_)})}if(typeof r=="number"&&r>0){const M=setTimeout(()=>{p()||u(U.makeError("timeout exceeded",x.errors.TIMEOUT,{timeout:r}))},r);M.unref&&M.unref(),h.push(()=>{clearTimeout(M)})}})})}getBlockNumber(){return D(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return D(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return O.from(t)}catch(e){return U.throwError("bad result from backend",x.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:e})}})}getBalance(t,e){return D(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield Lt({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getBalance",r);try{return O.from(n)}catch(i){return U.throwError("bad result from backend",x.errors.SERVER_ERROR,{method:"getBalance",params:r,result:n,error:i})}})}getTransactionCount(t,e){return D(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield Lt({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getTransactionCount",r);try{return O.from(n).toNumber()}catch(i){return U.throwError("bad result from backend",x.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:n,error:i})}})}getCode(t,e){return D(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield Lt({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getCode",r);try{return Q(n)}catch(i){return U.throwError("bad result from backend",x.errors.SERVER_ERROR,{method:"getCode",params:r,result:n,error:i})}})}getStorageAt(t,e,r){return D(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield Lt({address:this._getAddress(t),blockTag:this._getBlockTag(r),position:Promise.resolve(e).then(a=>ar(a))}),i=yield this.perform("getStorageAt",n);try{return Q(i)}catch(a){return U.throwError("bad result from backend",x.errors.SERVER_ERROR,{method:"getStorageAt",params:n,result:i,error:a})}})}_wrapTransaction(t,e,r){if(e!=null&&Ee(e)!==32)throw new Error("invalid response - sendTransaction");const n=t;return e!=null&&t.hash!==e&&U.throwError("Transaction hash mismatch from Provider.sendTransaction.",x.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),n.wait=(i,a)=>D(this,void 0,void 0,function*(){i==null&&(i=1),a==null&&(a=0);let u;i!==0&&r!=null&&(u={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:r});const h=yield this._waitForTransaction(t.hash,i,a,u);return h==null&&i===0?null:(this._emitted["t:"+t.hash]=h.blockNumber,h.status===0&&U.throwError("transaction failed",x.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:h}),h)}),n}sendTransaction(t){return D(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield Promise.resolve(t).then(i=>Q(i)),r=this.formatter.transaction(t);r.confirmations==null&&(r.confirmations=0);const n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const i=yield this.perform("sendTransaction",{signedTransaction:e});return this._wrapTransaction(r,i,n)}catch(i){throw i.transaction=r,i.transactionHash=r.hash,i}})}_getTransactionRequest(t){return D(this,void 0,void 0,function*(){const e=yield t,r={};return["from","to"].forEach(n=>{e[n]!=null&&(r[n]=Promise.resolve(e[n]).then(i=>i?this._getAddress(i):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(n=>{e[n]!=null&&(r[n]=Promise.resolve(e[n]).then(i=>i?O.from(i):null))}),["type"].forEach(n=>{e[n]!=null&&(r[n]=Promise.resolve(e[n]).then(i=>i??null))}),e.accessList&&(r.accessList=this.formatter.accessList(e.accessList)),["data"].forEach(n=>{e[n]!=null&&(r[n]=Promise.resolve(e[n]).then(i=>i?Q(i):null))}),this.formatter.transactionRequest(yield Lt(r))})}_getFilter(t){return D(this,void 0,void 0,function*(){t=yield t;const e={};return t.address!=null&&(e.address=this._getAddress(t.address)),["blockHash","topics"].forEach(r=>{t[r]!=null&&(e[r]=t[r])}),["fromBlock","toBlock"].forEach(r=>{t[r]!=null&&(e[r]=this._getBlockTag(t[r]))}),this.formatter.filter(yield Lt(e))})}_call(t,e,r){return D(this,void 0,void 0,function*(){r>=fo&&U.throwError("CCIP read exceeded maximum redirections",x.errors.SERVER_ERROR,{redirects:r,transaction:t});const n=t.to,i=yield this.perform("call",{transaction:t,blockTag:e});if(r>=0&&e==="latest"&&n!=null&&i.substring(0,10)==="0x556f1830"&&Ee(i)%32===4)try{const a=Ht(i,4),u=Ht(a,0,32);O.from(u).eq(n)||U.throwError("CCIP Read sender did not match",x.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:i});const h=[],d=O.from(Ht(a,32,64)).toNumber(),p=O.from(Ht(a,d,d+32)).toNumber(),A=Ht(a,d+32);for(let P=0;P<p;P++){const S=Ve(A,P*32);S==null&&U.throwError("CCIP Read contained corrupt URL string",x.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:i}),h.push(S)}const M=Ue(a,64);O.from(Ht(a,100,128)).isZero()||U.throwError("CCIP Read callback selector included junk",x.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:i});const E=Ht(a,96,100),_=Ue(a,128),I=yield this.ccipReadFetch(t,M,h);I==null&&U.throwError("CCIP Read disabled or provided no URLs",x.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:i});const T={to:n,data:Wt([E,Rn([I,_])])};return this._call(T,e,r+1)}catch(a){if(a.code===x.errors.SERVER_ERROR)throw a}try{return Q(i)}catch(a){return U.throwError("bad result from backend",x.errors.SERVER_ERROR,{method:"call",params:{transaction:t,blockTag:e},result:i,error:a})}})}call(t,e){return D(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield Lt({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(e),ccipReadEnabled:Promise.resolve(t.ccipReadEnabled)});return this._call(r.transaction,r.blockTag,r.ccipReadEnabled?0:-1)})}estimateGas(t){return D(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield Lt({transaction:this._getTransactionRequest(t)}),r=yield this.perform("estimateGas",e);try{return O.from(r)}catch(n){return U.throwError("bad result from backend",x.errors.SERVER_ERROR,{method:"estimateGas",params:e,result:r,error:n})}})}_getAddress(t){return D(this,void 0,void 0,function*(){t=yield t,typeof t!="string"&&U.throwArgumentError("invalid address or ENS name","name",t);const e=yield this.resolveName(t);return e==null&&U.throwError("ENS name not configured",x.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e})}_getBlock(t,e){return D(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;let r=-128;const n={includeTransactions:!!e};if(Bt(t,32))n.blockHash=t;else try{n.blockTag=yield this._getBlockTag(t),Bt(n.blockTag)&&(r=parseInt(n.blockTag.substring(2),16))}catch{U.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return _e(()=>D(this,void 0,void 0,function*(){const i=yield this.perform("getBlock",n);if(i==null)return n.blockHash!=null&&this._emitted["b:"+n.blockHash]==null||n.blockTag!=null&&r>this._emitted.block?null:void 0;if(e){let a=null;for(let h=0;h<i.transactions.length;h++){const d=i.transactions[h];if(d.blockNumber==null)d.confirmations=0;else if(d.confirmations==null){a==null&&(a=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let p=a-d.blockNumber+1;p<=0&&(p=1),d.confirmations=p}}const u=this.formatter.blockWithTransactions(i);return u.transactions=u.transactions.map(h=>this._wrapTransaction(h)),u}return this.formatter.block(i)}),{oncePoll:this})})}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return D(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const e={transactionHash:this.formatter.hash(t,!0)};return _e(()=>D(this,void 0,void 0,function*(){const r=yield this.perform("getTransaction",e);if(r==null)return this._emitted["t:"+t]==null?null:void 0;const n=this.formatter.transactionResponse(r);if(n.blockNumber==null)n.confirmations=0;else if(n.confirmations==null){let a=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;a<=0&&(a=1),n.confirmations=a}return this._wrapTransaction(n)}),{oncePoll:this})})}getTransactionReceipt(t){return D(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const e={transactionHash:this.formatter.hash(t,!0)};return _e(()=>D(this,void 0,void 0,function*(){const r=yield this.perform("getTransactionReceipt",e);if(r==null)return this._emitted["t:"+t]==null?null:void 0;if(r.blockHash==null)return;const n=this.formatter.receipt(r);if(n.blockNumber==null)n.confirmations=0;else if(n.confirmations==null){let a=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;a<=0&&(a=1),n.confirmations=a}return n}),{oncePoll:this})})}getLogs(t){return D(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield Lt({filter:this._getFilter(t)}),r=yield this.perform("getLogs",e);return r.forEach(n=>{n.removed==null&&(n.removed=!1)}),N.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)})}getEtherPrice(){return D(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(t){return D(this,void 0,void 0,function*(){if(t=yield t,typeof t=="number"&&t<0){t%1&&U.throwArgumentError("invalid BlockTag","blockTag",t);let e=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return e+=t,e<0&&(e=0),this.formatter.blockTag(e)}return this.formatter.blockTag(t)})}getResolver(t){return D(this,void 0,void 0,function*(){let e=t;for(;;){if(e===""||e==="."||t!=="eth"&&e==="eth")return null;const r=yield this._getResolver(e,"getResolver");if(r!=null){const n=new Qi(this,r,t);return e!==t&&!(yield n.supportsWildcard())?null:n}e=e.split(".").slice(1).join(".")}})}_getResolver(t,e){return D(this,void 0,void 0,function*(){e==null&&(e="ENS");const r=yield this.getNetwork();r.ensAddress||U.throwError("network does not support ENS",x.errors.UNSUPPORTED_OPERATION,{operation:e,network:r.name});try{const n=yield this.call({to:r.ensAddress,data:"0x0178b8bf"+Ye(t).substring(2)});return this.formatter.callAddress(n)}catch{}return null})}resolveName(t){return D(this,void 0,void 0,function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(r){if(Bt(t))throw r}typeof t!="string"&&U.throwArgumentError("invalid ENS name","name",t);const e=yield this.getResolver(t);return e?yield e.getAddress():null})}lookupAddress(t){return D(this,void 0,void 0,function*(){t=yield t,t=this.formatter.address(t);const e=t.substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(e,"lookupAddress");if(r==null)return null;const n=Ve(yield this.call({to:r,data:"0x691f3431"+Ye(e).substring(2)}),0);return(yield this.resolveName(n))!=t?null:n})}getAvatar(t){return D(this,void 0,void 0,function*(){let e=null;if(Bt(t)){const i=this.formatter.address(t).substring(2).toLowerCase()+".addr.reverse",a=yield this._getResolver(i,"getAvatar");if(!a)return null;e=new Qi(this,a,i);try{const u=yield e.getAvatar();if(u)return u.url}catch(u){if(u.code!==x.errors.CALL_EXCEPTION)throw u}try{const u=Ve(yield this.call({to:a,data:"0x691f3431"+Ye(i).substring(2)}),0);e=yield this.getResolver(u)}catch(u){if(u.code!==x.errors.CALL_EXCEPTION)throw u;return null}}else if(e=yield this.getResolver(t),!e)return null;const r=yield e.getAvatar();return r==null?null:r.url})}perform(t,e){return U.throwError(t+" not implemented",x.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(e=>e.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(e=>e.pollable()).length>0}_addEventListener(t,e,r){const n=new ho(Me(t),e,r);return this._events.push(n),this._startEvent(n),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=[],i=Me(t);return this._events=this._events.filter(a=>a.tag!==i?!0:(setTimeout(()=>{a.listener.apply(this,e)},0),r=!0,a.once?(n.push(a),!1):!0)),n.forEach(a=>{this._stopEvent(a)}),r}listenerCount(t){if(!t)return this._events.length;let e=Me(t);return this._events.filter(r=>r.tag===e).length}listeners(t){if(t==null)return this._events.map(r=>r.listener);let e=Me(t);return this._events.filter(r=>r.tag===e).map(r=>r.listener)}off(t,e){if(e==null)return this.removeAllListeners(t);const r=[];let n=!1,i=Me(t);return this._events=this._events.filter(a=>a.tag!==i||a.listener!=e||n?!0:(n=!0,r.push(a),!1)),r.forEach(a=>{this._stopEvent(a)}),this}removeAllListeners(t){let e=[];if(t==null)e=this._events,this._events=[];else{const r=Me(t);this._events=this._events.filter(n=>n.tag!==r?!0:(e.push(n),!1))}return e.forEach(r=>{this._stopEvent(r)}),this}}var ae=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const Tt=new x(Jt),mo=["call","estimateGas"];function De(s,t){if(s==null)return null;if(typeof s.message=="string"&&s.message.match("reverted")){const e=Bt(s.data)?s.data:null;if(!t||e)return{message:s.message,data:e}}if(typeof s=="object"){for(const e in s){const r=De(s[e],t);if(r)return r}return null}if(typeof s=="string")try{return De(JSON.parse(s),t)}catch{}return null}function Tn(s,t,e){const r=e.transaction||e.signedTransaction;if(s==="call"){const i=De(t,!0);if(i)return i.data;Tt.throwError("missing revert data in call exception; Transaction reverted without a reason string",x.errors.CALL_EXCEPTION,{data:"0x",transaction:r,error:t})}if(s==="estimateGas"){let i=De(t.body,!1);i==null&&(i=De(t,!1)),i&&Tt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",x.errors.UNPREDICTABLE_GAS_LIMIT,{reason:i.message,method:s,transaction:r,error:t})}let n=t.message;throw t.code===x.errors.SERVER_ERROR&&t.error&&typeof t.error.message=="string"?n=t.error.message:typeof t.body=="string"?n=t.body:typeof t.responseText=="string"&&(n=t.responseText),n=(n||"").toLowerCase(),n.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&Tt.throwError("insufficient funds for intrinsic transaction cost",x.errors.INSUFFICIENT_FUNDS,{error:t,method:s,transaction:r}),n.match(/nonce (is )?too low/i)&&Tt.throwError("nonce has already been used",x.errors.NONCE_EXPIRED,{error:t,method:s,transaction:r}),n.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&Tt.throwError("replacement fee too low",x.errors.REPLACEMENT_UNDERPRICED,{error:t,method:s,transaction:r}),n.match(/only replay-protected/i)&&Tt.throwError("legacy pre-eip-155 transactions not supported",x.errors.UNSUPPORTED_OPERATION,{error:t,method:s,transaction:r}),mo.indexOf(s)>=0&&n.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&Tt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",x.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:s,transaction:r}),t}function ji(s){return new Promise(function(t){setTimeout(t,s)})}function vo(s){if(s.error){const t=new Error(s.error.message);throw t.code=s.error.code,t.data=s.error.data,t}return s.result}function Be(s){return s&&s.toLowerCase()}const Yr={};class Bn extends Vr{constructor(t,e,r){if(super(),t!==Yr)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");R(this,"provider",e),r==null&&(r=0),typeof r=="string"?(R(this,"_address",this.provider.formatter.address(r)),R(this,"_index",null)):typeof r=="number"?(R(this,"_index",r),R(this,"_address",null)):Tt.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return Tt.throwError("cannot alter JSON-RPC Signer connection",x.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new wo(Yr,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&Tt.throwError("unknown account #"+this._index,x.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=Ct(t);const e=this.getAddress().then(r=>(r&&(r=r.toLowerCase()),r));if(t.gasLimit==null){const r=Ct(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return t.to!=null&&(t.to=Promise.resolve(t.to).then(r=>ae(this,void 0,void 0,function*(){if(r==null)return null;const n=yield this.provider.resolveName(r);return n==null&&Tt.throwArgumentError("provided ENS name resolves to null","tx.to",r),n}))),Lt({tx:Lt(t),sender:e}).then(({tx:r,sender:n})=>{r.from!=null?r.from.toLowerCase()!==n&&Tt.throwArgumentError("from address mismatch","transaction",t):r.from=n;const i=this.provider.constructor.hexlifyTransaction(r,{from:!0});return this.provider.send("eth_sendTransaction",[i]).then(a=>a,a=>(typeof a.message=="string"&&a.message.match(/user denied/i)&&Tt.throwError("user rejected transaction",x.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:r}),Tn("sendTransaction",a,i)))})}signTransaction(t){return Tt.throwError("signing transactions is unsupported",x.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return ae(this,void 0,void 0,function*(){const e=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(t);try{return yield _e(()=>ae(this,void 0,void 0,function*(){const n=yield this.provider.getTransaction(r);if(n!==null)return this.provider._wrapTransaction(n,r,e)}),{oncePoll:this.provider})}catch(n){throw n.transactionHash=r,n}})}signMessage(t){return ae(this,void 0,void 0,function*(){const e=typeof t=="string"?ke(t):t,r=yield this.getAddress();try{return yield this.provider.send("personal_sign",[Q(e),r.toLowerCase()])}catch(n){throw typeof n.message=="string"&&n.message.match(/user denied/i)&&Tt.throwError("user rejected signing",x.errors.ACTION_REJECTED,{action:"signMessage",from:r,messageData:t}),n}})}_legacySignMessage(t){return ae(this,void 0,void 0,function*(){const e=typeof t=="string"?ke(t):t,r=yield this.getAddress();try{return yield this.provider.send("eth_sign",[r.toLowerCase(),Q(e)])}catch(n){throw typeof n.message=="string"&&n.message.match(/user denied/i)&&Tt.throwError("user rejected signing",x.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:r,messageData:t}),n}})}_signTypedData(t,e,r){return ae(this,void 0,void 0,function*(){const n=yield jt.resolveNames(t,e,r,a=>this.provider.resolveName(a)),i=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[i.toLowerCase(),JSON.stringify(jt.getPayload(n.domain,e,n.value))])}catch(a){throw typeof a.message=="string"&&a.message.match(/user denied/i)&&Tt.throwError("user rejected signing",x.errors.ACTION_REJECTED,{action:"_signTypedData",from:i,messageData:{domain:n.domain,types:e,value:n.value}}),a}})}unlock(t){return ae(this,void 0,void 0,function*(){const e=this.provider,r=yield this.getAddress();return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class wo extends Bn{sendTransaction(t){return this.sendUncheckedTransaction(t).then(e=>({hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:r=>this.provider.waitForTransaction(e,r)}))}}const yo={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class Pe extends ri{constructor(t,e){let r=e;r==null&&(r=new Promise((n,i)=>{setTimeout(()=>{this.detectNetwork().then(a=>{n(a)},a=>{i(a)})},0)})),super(r),t||(t=pe(this.constructor,"defaultUrl")()),typeof t=="string"?R(this,"connection",Object.freeze({url:t})):R(this,"connection",Object.freeze(Ct(t))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return ae(this,void 0,void 0,function*(){yield ji(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch{try{t=yield this.send("net_version",[])}catch{}}if(t!=null){const e=pe(this.constructor,"getNetwork");try{return e(O.from(t).toNumber())}catch(r){return Tt.throwError("could not detect network",x.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:r})}}return Tt.throwError("could not detect network",x.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(t){return new Bn(Yr,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(e=>this.formatter.address(e)))}send(t,e){const r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:le(r),provider:this});const n=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(n&&this._cache[t])return this._cache[t];const i=Ge(this.connection,JSON.stringify(r),vo).then(a=>(this.emit("debug",{action:"response",request:r,response:a,provider:this}),a),a=>{throw this.emit("debug",{action:"response",error:a,request:r,provider:this}),a});return n&&(this._cache[t]=i,setTimeout(()=>{this._cache[t]=null},0)),i}prepareRequest(t,e){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[Be(e.address),e.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[Be(e.address),e.blockTag]];case"getCode":return["eth_getCode",[Be(e.address),e.blockTag]];case"getStorageAt":return["eth_getStorageAt",[Be(e.address),Dt(e.position,32),e.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[e.signedTransaction]];case"getBlock":return e.blockTag?["eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]]:e.blockHash?["eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[e.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[e.transactionHash]];case"call":return["eth_call",[pe(this.constructor,"hexlifyTransaction")(e.transaction,{from:!0}),e.blockTag]];case"estimateGas":return["eth_estimateGas",[pe(this.constructor,"hexlifyTransaction")(e.transaction,{from:!0})]];case"getLogs":return e.filter&&e.filter.address!=null&&(e.filter.address=Be(e.filter.address)),["eth_getLogs",[e.filter]]}return null}perform(t,e){return ae(this,void 0,void 0,function*(){if(t==="call"||t==="estimateGas"){const n=e.transaction;if(n&&n.type!=null&&O.from(n.type).isZero()&&n.maxFeePerGas==null&&n.maxPriorityFeePerGas==null){const i=yield this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(e=Ct(e),e.transaction=Ct(n),delete e.transaction.type)}}const r=this.prepareRequest(t,e);r==null&&Tt.throwError(t+" not implemented",x.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(r[0],r[1])}catch(n){return Tn(t,n,e)}})}_startEvent(t){t.tag==="pending"&&this._startPending(),super._startEvent(t)}_startPending(){if(this._pendingFilter!=null)return;const t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){function n(){t.send("eth_getFilterChanges",[r]).then(function(i){if(t._pendingFilter!=e)return null;let a=Promise.resolve();return i.forEach(function(u){t._emitted["t:"+u.toLowerCase()]="pending",a=a.then(function(){return t.getTransaction(u).then(function(h){return t.emit("pending",h),null})})}),a.then(function(){return ji(1e3)})}).then(function(){if(t._pendingFilter!=e){t.send("eth_uninstallFilter",[r]);return}return setTimeout(function(){n()},0),null}).catch(i=>{})}return n(),r}).catch(r=>{})}_stopEvent(t){t.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,e){const r=Ct(yo);if(e)for(const i in e)e[i]&&(r[i]=!0);Jn(t,r);const n={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(i){if(t[i]==null)return;const a=ar(O.from(t[i]));i==="gasLimit"&&(i="gas"),n[i]=a}),["from","to","data"].forEach(function(i){t[i]!=null&&(n[i]=Q(t[i]))}),t.accessList&&(n.accessList=Se(t.accessList)),n}}let qe=null;try{if(qe=WebSocket,qe==null)throw new Error("inject please")}catch{const t=new x(Jt);qe=function(){t.throwError("WebSockets not supported in this environment",x.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var Gr=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const Je=new x(Jt);let Ao=1;class ii extends Pe{constructor(t,e){e==="any"&&Je.throwError("WebSocketProvider does not support 'any' network yet",x.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),typeof t=="string"?super(t,e):super("_websocket",e),this._pollingInterval=-1,this._wsReady=!1,typeof t=="string"?R(this,"_websocket",new qe(this.connection.url)):R(this,"_websocket",t),R(this,"_requests",{}),R(this,"_subs",{}),R(this,"_subIds",{}),R(this,"_detectNetwork",super.detectNetwork()),this.websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach(n=>{this.websocket.send(this._requests[n].payload)})},this.websocket.onmessage=n=>{const i=n.data,a=JSON.parse(i);if(a.id!=null){const u=String(a.id),h=this._requests[u];if(delete this._requests[u],a.result!==void 0)h.callback(null,a.result),this.emit("debug",{action:"response",request:JSON.parse(h.payload),response:a.result,provider:this});else{let d=null;a.error?(d=new Error(a.error.message||"unknown error"),R(d,"code",a.error.code||null),R(d,"response",i)):d=new Error("unknown error"),h.callback(d,void 0),this.emit("debug",{action:"response",error:d,request:JSON.parse(h.payload),provider:this})}}else if(a.method==="eth_subscription"){const u=this._subs[a.params.subscription];u&&u.processFunc(a.params.result)}else console.warn("this should not happen")};const r=setInterval(()=>{this.emit("poll")},1e3);r.unref&&r.unref()}get websocket(){return this._websocket}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(t){Je.throwError("cannot reset events block on WebSocketProvider",x.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(t){Je.throwError("cannot set polling interval on WebSocketProvider",x.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return Gr(this,void 0,void 0,function*(){return null})}set polling(t){t&&Je.throwError("cannot set polling on WebSocketProvider",x.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(t,e){const r=Ao++;return new Promise((n,i)=>{function a(h,d){return h?i(h):n(d)}const u=JSON.stringify({method:t,params:e,id:r,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(u),provider:this}),this._requests[String(r)]={callback:a,payload:u},this._wsReady&&this.websocket.send(u)})}static defaultUrl(){return"ws://localhost:8546"}_subscribe(t,e,r){return Gr(this,void 0,void 0,function*(){let n=this._subIds[t];n==null&&(n=Promise.all(e).then(a=>this.send("eth_subscribe",a)),this._subIds[t]=n);const i=yield n;this._subs[i]={tag:t,processFunc:r}})}_startEvent(t){switch(t.type){case"block":this._subscribe("block",["newHeads"],e=>{const r=O.from(e.number).toNumber();this._emitted.block=r,this.emit("block",r)});break;case"pending":this._subscribe("pending",["newPendingTransactions"],e=>{this.emit("pending",e)});break;case"filter":this._subscribe(t.tag,["logs",this._getFilter(t.filter)],e=>{e.removed==null&&(e.removed=!1),this.emit(t.filter,this.formatter.filterLog(e))});break;case"tx":{const e=r=>{const n=r.hash;this.getTransactionReceipt(n).then(i=>{i&&this.emit(n,i)})};e(t),this._subscribe("tx",["newHeads"],r=>{this._events.filter(n=>n.type==="tx").forEach(e)});break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",t);break}}_stopEvent(t){let e=t.tag;if(t.type==="tx"){if(this._events.filter(n=>n.type==="tx").length)return;e="tx"}else if(this.listenerCount(t.event))return;const r=this._subIds[e];r&&(delete this._subIds[e],r.then(n=>{this._subs[n]&&(delete this._subs[n],this.send("eth_unsubscribe",[n]))}))}destroy(){return Gr(this,void 0,void 0,function*(){this.websocket.readyState===qe.CONNECTING&&(yield new Promise(t=>{this.websocket.onopen=function(){t(!0)},this.websocket.onerror=function(){t(!1)}})),this.websocket.close(1e3)})}}var bo=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const Oe=new x(Jt);class ko extends Pe{detectNetwork(){const t=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return bo(this,void 0,void 0,function*(){let e=this.network;return e==null&&(e=yield t.detectNetwork.call(this),e||Oe.throwError("no network detected",x.errors.UNKNOWN_ERROR,{}),this._network==null&&(R(this,"_network",e),this.emit("network",e,null))),e})}}class ve extends ko{constructor(t,e){Oe.checkAbstract(new.target,ve),t=pe(new.target,"getNetwork")(t),e=pe(new.target,"getApiKey")(e);const r=pe(new.target,"getUrl")(t,e);super(r,t),typeof e=="string"?R(this,"apiKey",e):e!=null&&Object.keys(e).forEach(n=>{R(this,n,e[n])})}_startPending(){Oe.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(t){return Oe.throwError("API provider does not support signing",x.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(t){return t}static getUrl(t,e){return Oe.throwError("not implemented; sub-classes must override getUrl",x.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const Yi=new x(Jt),Ze="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class Eo extends ii{constructor(t,e){const r=new Cn(t,e),n=r.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi.");super(n,r.network),R(this,"apiKey",r.apiKey)}isCommunityResource(){return this.apiKey===Ze}}class Cn extends ve{static getWebSocketProvider(t,e){return new Eo(t,e)}static getApiKey(t){return t==null?Ze:(t&&typeof t!="string"&&Yi.throwArgumentError("invalid apiKey","apiKey",t),t)}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/v2/";break;case"goerli":r="eth-goerli.g.alchemy.com/v2/";break;case"matic":r="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":r="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":r="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-goerli":r="arb-goerli.g.alchemy.com/v2/";break;case"optimism":r="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-goerli":r="opt-goerli.g.alchemy.com/v2/";break;default:Yi.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+r+e,throttleCallback:(n,i)=>(e===Ze&&cr(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===Ze}}const xo=new x(Jt),Ke="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function Mo(s){switch(s){case"homestead":return"rpc.ankr.com/eth/";case"ropsten":return"rpc.ankr.com/eth_ropsten/";case"rinkeby":return"rpc.ankr.com/eth_rinkeby/";case"goerli":return"rpc.ankr.com/eth_goerli/";case"matic":return"rpc.ankr.com/polygon/";case"arbitrum":return"rpc.ankr.com/arbitrum/"}return xo.throwArgumentError("unsupported network","name",s)}class _o extends ve{isCommunityResource(){return this.apiKey===Ke}static getApiKey(t){return t??Ke}static getUrl(t,e){e==null&&(e=Ke);const r={allowGzip:!0,url:"https://"+Mo(t.name)+e,throttleCallback:(n,i)=>(e.apiKey===Ke&&cr(),Promise.resolve(!0))};return e.projectSecret!=null&&(r.user="",r.password=e.projectSecret),r}}var Io=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const Wi=new x(Jt);class Po extends ve{static getApiKey(t){return t!=null&&Wi.throwArgumentError("apiKey not supported for cloudflare","apiKey",t),null}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Wi.throwArgumentError("unsupported network","network",arguments[0])}return r}perform(t,e){const r=Object.create(null,{perform:{get:()=>super.perform}});return Io(this,void 0,void 0,function*(){return t==="getBlockNumber"?(yield r.perform.call(this,"getBlock",{blockTag:"latest"})).number:r.perform.call(this,t,e)})}}var He=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const de=new x(Jt);function Xi(s){const t={};for(let e in s){if(s[e]==null)continue;let r=s[e];e==="type"&&r===0||({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[e]?r=ar(Q(r)):e==="accessList"?r="["+Se(r).map(n=>`{address:"${n.address}",storageKeys:["${n.storageKeys.join('","')}"]}`).join(",")+"]":r=Q(r),t[e]=r)}return t}function No(s){if(s.status==0&&(s.message==="No records found"||s.message==="No transactions found"))return s.result;if(s.status!=1||typeof s.message!="string"||!s.message.match(/^OK/)){const t=new Error("invalid response");throw t.result=JSON.stringify(s),(s.result||"").toLowerCase().indexOf("rate limit")>=0&&(t.throttleRetry=!0),t}return s.result}function Vi(s){if(s&&s.status==0&&s.message=="NOTOK"&&(s.result||"").toLowerCase().indexOf("rate limit")>=0){const t=new Error("throttled response");throw t.result=JSON.stringify(s),t.throttleRetry=!0,t}if(s.jsonrpc!="2.0"){const t=new Error("invalid response");throw t.result=JSON.stringify(s),t}if(s.error){const t=new Error(s.error.message||"unknown error");throw s.error.code&&(t.code=s.error.code),s.error.data&&(t.data=s.error.data),t}return s.result}function Zi(s){if(s==="pending")throw new Error("pending not supported");return s==="latest"?s:parseInt(s.substring(2),16)}function zr(s,t,e){if(s==="call"&&t.code===x.errors.SERVER_ERROR){const n=t.error;if(n&&(n.message.match(/reverted/i)||n.message.match(/VM execution error/i))){let i=n.data;if(i&&(i="0x"+i.replace(/^.*0x/i,"")),Bt(i))return i;de.throwError("missing revert data in call exception",x.errors.CALL_EXCEPTION,{error:t,data:"0x"})}}let r=t.message;throw t.code===x.errors.SERVER_ERROR&&(t.error&&typeof t.error.message=="string"?r=t.error.message:typeof t.body=="string"?r=t.body:typeof t.responseText=="string"&&(r=t.responseText)),r=(r||"").toLowerCase(),r.match(/insufficient funds/)&&de.throwError("insufficient funds for intrinsic transaction cost",x.errors.INSUFFICIENT_FUNDS,{error:t,method:s,transaction:e}),r.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&de.throwError("nonce has already been used",x.errors.NONCE_EXPIRED,{error:t,method:s,transaction:e}),r.match(/another transaction with same nonce/)&&de.throwError("replacement fee too low",x.errors.REPLACEMENT_UNDERPRICED,{error:t,method:s,transaction:e}),r.match(/execution failed due to an exception|execution reverted/)&&de.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",x.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:s,transaction:e}),t}class So extends ri{constructor(t,e){super(t),R(this,"baseUrl",this.getBaseUrl()),R(this,"apiKey",e||null)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"matic":return"https://api.polygonscan.com";case"maticmum":return"https://api-testnet.polygonscan.com";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}return de.throwArgumentError("unsupported network","network",this.network.name)}getUrl(t,e){const r=Object.keys(e).reduce((i,a)=>{const u=e[a];return u!=null&&(i+=`&${a}=${u}`),i},""),n=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${t}${r}${n}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(t,e){return e.module=t,e.apikey=this.apiKey,e}fetch(t,e,r){return He(this,void 0,void 0,function*(){const n=r?this.getPostUrl():this.getUrl(t,e),i=r?this.getPostData(t,e):null,a=t==="proxy"?Vi:No;this.emit("debug",{action:"request",request:n,provider:this});const u={url:n,throttleSlotInterval:1e3,throttleCallback:(p,A)=>(this.isCommunityResource()&&cr(),Promise.resolve(!0))};let h=null;i&&(u.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},h=Object.keys(i).map(p=>`${p}=${i[p]}`).join("&"));const d=yield Ge(u,h,a||Vi);return this.emit("debug",{action:"response",request:n,response:le(d),provider:this}),d})}detectNetwork(){return He(this,void 0,void 0,function*(){return this.network})}perform(t,e){const r=Object.create(null,{perform:{get:()=>super.perform}});return He(this,void 0,void 0,function*(){switch(t){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:e.address,tag:e.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:e.address,tag:e.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:e.address,tag:e.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:e.address,position:e.position,tag:e.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:e.signedTransaction},!0).catch(n=>zr("sendTransaction",n,e.signedTransaction));case"getBlock":if(e.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:e.blockTag,boolean:e.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:e.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:e.transactionHash});case"call":{if(e.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const n=Xi(e.transaction);n.module="proxy",n.action="eth_call";try{return yield this.fetch("proxy",n,!0)}catch(i){return zr("call",i,e.transaction)}}case"estimateGas":{const n=Xi(e.transaction);n.module="proxy",n.action="eth_estimateGas";try{return yield this.fetch("proxy",n,!0)}catch(i){return zr("estimateGas",i,e.transaction)}}case"getLogs":{const n={action:"getLogs"};if(e.filter.fromBlock&&(n.fromBlock=Zi(e.filter.fromBlock)),e.filter.toBlock&&(n.toBlock=Zi(e.filter.toBlock)),e.filter.address&&(n.address=e.filter.address),e.filter.topics&&e.filter.topics.length>0&&(e.filter.topics.length>1&&de.throwError("unsupported topic count",x.errors.UNSUPPORTED_OPERATION,{topics:e.filter.topics}),e.filter.topics.length===1)){const u=e.filter.topics[0];(typeof u!="string"||u.length!==66)&&de.throwError("unsupported topic format",x.errors.UNSUPPORTED_OPERATION,{topic0:u}),n.topic0=u}const i=yield this.fetch("logs",n);let a={};for(let u=0;u<i.length;u++){const h=i[u];if(h.blockHash==null){if(a[h.blockNumber]==null){const d=yield this.getBlock(h.blockNumber);d&&(a[h.blockNumber]=d.hash)}h.blockHash=a[h.blockNumber]}}return i}case"getEtherPrice":return this.network.name!=="homestead"?0:parseFloat((yield this.fetch("stats",{action:"ethprice"})).ethusd)}return r.perform.call(this,t,e)})}getHistory(t,e,r){return He(this,void 0,void 0,function*(){const n={action:"txlist",address:yield this.resolveName(t),startblock:e??0,endblock:r??99999999,sort:"asc"};return(yield this.fetch("account",n)).map(a=>{["contractAddress","to"].forEach(function(h){a[h]==""&&delete a[h]}),a.creates==null&&a.contractAddress!=null&&(a.creates=a.contractAddress);const u=this.formatter.transactionResponse(a);return a.timeStamp&&(u.timestamp=parseInt(a.timeStamp)),u})})}isCommunityResource(){return this.apiKey==null}}var nr=globalThis&&globalThis.__awaiter||function(s,t,e,r){function n(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(p){try{d(r.next(p))}catch(A){a(A)}}function h(p){try{d(r.throw(p))}catch(A){a(A)}}function d(p){p.done?i(p.value):n(p.value).then(u,h)}d((r=r.apply(s,t||[])).next())})};const Ae=new x(Jt);function Qe(){return new Date().getTime()}function $i(s){let t=null;for(let e=0;e<s.length;e++){const r=s[e];if(r==null)return null;t?t.name===r.name&&t.chainId===r.chainId&&(t.ensAddress===r.ensAddress||t.ensAddress==null&&r.ensAddress==null)||Ae.throwArgumentError("provider mismatch","networks",s):t=r}return t}function tn(s,t){s=s.slice().sort();const e=Math.floor(s.length/2);if(s.length%2)return s[e];const r=s[e-1],n=s[e];return t!=null&&Math.abs(r-n)>t?null:(r+n)/2}function Ie(s){if(s===null)return"null";if(typeof s=="number"||typeof s=="boolean")return JSON.stringify(s);if(typeof s=="string")return s;if(O.isBigNumber(s))return s.toString();if(Array.isArray(s))return JSON.stringify(s.map(t=>Ie(t)));if(typeof s=="object"){const t=Object.keys(s);return t.sort(),"{"+t.map(e=>{let r=s[e];return typeof r=="function"?r="[function]":r=Ie(r),JSON.stringify(e)+":"+r}).join(",")+"}"}throw new Error("unknown value type: "+typeof s)}let Ro=1;function en(s){let t=null,e=null,r=new Promise(a=>{t=function(){e&&(clearTimeout(e),e=null),a()},e=setTimeout(t,s)});const n=a=>(r=r.then(a),r);function i(){return r}return{cancel:t,getPromise:i,wait:n}}const To=[x.errors.CALL_EXCEPTION,x.errors.INSUFFICIENT_FUNDS,x.errors.NONCE_EXPIRED,x.errors.REPLACEMENT_UNDERPRICED,x.errors.UNPREDICTABLE_GAS_LIMIT],Bo=["address","args","errorArgs","errorSignature","method","transaction"];function je(s,t){const e={weight:s.weight};return Object.defineProperty(e,"provider",{get:()=>s.provider}),s.start&&(e.start=s.start),t&&(e.duration=t-s.start),s.done&&(s.error?e.error=s.error:e.result=s.result||null),e}function Co(s,t){return function(e){const r={};e.forEach(i=>{const a=s(i.result);r[a]||(r[a]={count:0,result:i.result}),r[a].count++});const n=Object.keys(r);for(let i=0;i<n.length;i++){const a=r[n[i]];if(a.count>=t)return a.result}}}function Oo(s,t,e){let r=Ie;switch(t){case"getBlockNumber":return function(n){const i=n.map(u=>u.result);let a=tn(n.map(u=>u.result),2);if(a!=null)return a=Math.ceil(a),i.indexOf(a+1)>=0&&a++,a>=s._highestBlockNumber&&(s._highestBlockNumber=a),s._highestBlockNumber};case"getGasPrice":return function(n){const i=n.map(a=>a.result);return i.sort(),i[Math.floor(i.length/2)]};case"getEtherPrice":return function(n){return tn(n.map(i=>i.result))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":r=function(n){return n==null?null:(n=Ct(n),n.confirmations=-1,Ie(n))};break;case"getBlock":e.includeTransactions?r=function(n){return n==null?null:(n=Ct(n),n.transactions=n.transactions.map(i=>(i=Ct(i),i.confirmations=-1,i)),Ie(n))}:r=function(n){return n==null?null:Ie(n)};break;default:throw new Error("unknown method: "+t)}return Co(r,s.quorum)}function Ce(s,t){return nr(this,void 0,void 0,function*(){const e=s.provider;return e.blockNumber!=null&&e.blockNumber>=t||t===-1?e:_e(()=>new Promise((r,n)=>{setTimeout(function(){return e.blockNumber>=t?r(e):s.cancelled?r(null):r(void 0)},0)}),{oncePoll:e})})}function Lo(s,t,e,r){return nr(this,void 0,void 0,function*(){let n=s.provider;switch(e){case"getBlockNumber":case"getGasPrice":return n[e]();case"getEtherPrice":if(n.getEtherPrice)return n.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return r.blockTag&&Bt(r.blockTag)&&(n=yield Ce(s,t)),n[e](r.address,r.blockTag||"latest");case"getStorageAt":return r.blockTag&&Bt(r.blockTag)&&(n=yield Ce(s,t)),n.getStorageAt(r.address,r.position,r.blockTag||"latest");case"getBlock":return r.blockTag&&Bt(r.blockTag)&&(n=yield Ce(s,t)),n[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return r.blockTag&&Bt(r.blockTag)&&(n=yield Ce(s,t)),e==="call"&&r.blockTag?n[e](r.transaction,r.blockTag):n[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return n[e](r.transactionHash);case"getLogs":{let i=r.filter;return(i.fromBlock&&Bt(i.fromBlock)||i.toBlock&&Bt(i.toBlock))&&(n=yield Ce(s,t)),n.getLogs(i)}}return Ae.throwError("unknown method error",x.errors.UNKNOWN_ERROR,{method:e,params:r})})}class Do extends ri{constructor(t,e){t.length===0&&Ae.throwArgumentError("missing providers","providers",t);const r=t.map((a,u)=>{if(lr.isProvider(a)){const p=qi(a)?2e3:750;return Object.freeze({provider:a,weight:1,stallTimeout:p,priority:1})}const h=Ct(a);h.priority==null&&(h.priority=1),h.stallTimeout==null&&(h.stallTimeout=qi(a)?2e3:750),h.weight==null&&(h.weight=1);const d=h.weight;return(d%1||d>512||d<1)&&Ae.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${u}].weight`,d),Object.freeze(h)}),n=r.reduce((a,u)=>a+u.weight,0);e==null?e=n/2:e>n&&Ae.throwArgumentError("quorum will always fail; larger than total weight","quorum",e);let i=$i(r.map(a=>a.provider.network));i==null&&(i=new Promise((a,u)=>{setTimeout(()=>{this.detectNetwork().then(a,u)},0)})),super(i),R(this,"providerConfigs",Object.freeze(r)),R(this,"quorum",e),this._highestBlockNumber=-1}detectNetwork(){return nr(this,void 0,void 0,function*(){const t=yield Promise.all(this.providerConfigs.map(e=>e.provider.getNetwork()));return $i(t)})}perform(t,e){return nr(this,void 0,void 0,function*(){if(t==="sendTransaction"){const h=yield Promise.all(this.providerConfigs.map(d=>d.provider.sendTransaction(e.signedTransaction).then(p=>p.hash,p=>p)));for(let d=0;d<h.length;d++){const p=h[d];if(typeof p=="string")return p}throw h[0]}this._highestBlockNumber===-1&&t!=="getBlockNumber"&&(yield this.getBlockNumber());const r=Oo(this,t,e),n=Zs(this.providerConfigs.map(Ct));n.sort((h,d)=>h.priority-d.priority);const i=this._highestBlockNumber;let a=0,u=!0;for(;;){const h=Qe();let d=n.filter(E=>E.runner&&h-E.start<E.stallTimeout).reduce((E,_)=>E+_.weight,0);for(;d<this.quorum&&a<n.length;){const E=n[a++],_=Ro++;E.start=Qe(),E.staller=en(E.stallTimeout),E.staller.wait(()=>{E.staller=null}),E.runner=Lo(E,i,t,e).then(I=>{E.done=!0,E.result=I,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:_,backend:je(E,Qe()),request:{method:t,params:le(e)},provider:this})},I=>{E.done=!0,E.error=I,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:_,backend:je(E,Qe()),request:{method:t,params:le(e)},provider:this})}),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:_,backend:je(E,null),request:{method:t,params:le(e)},provider:this}),d+=E.weight}const p=[];n.forEach(E=>{E.done||!E.runner||(p.push(E.runner),E.staller&&p.push(E.staller.getPromise()))}),p.length&&(yield Promise.race(p));const A=n.filter(E=>E.done&&E.error==null);if(A.length>=this.quorum){const E=r(A);if(E!==void 0)return n.forEach(_=>{_.staller&&_.staller.cancel(),_.cancelled=!0}),E;u||(yield en(100).getPromise()),u=!1}const M=n.reduce((E,_)=>{if(!_.done||_.error==null)return E;const I=_.error.code;return To.indexOf(I)>=0&&(E[I]||(E[I]={error:_.error,weight:0}),E[I].weight+=_.weight),E},{});if(Object.keys(M).forEach(E=>{const _=M[E];if(_.weight<this.quorum)return;n.forEach(P=>{P.staller&&P.staller.cancel(),P.cancelled=!0});const I=_.error,T={};Bo.forEach(P=>{I[P]!=null&&(T[P]=I[P])}),Ae.throwError(I.reason||I.message,E,T)}),n.filter(E=>!E.done).length===0)break}return n.forEach(h=>{h.staller&&h.staller.cancel(),h.cancelled=!0}),Ae.throwError("failed to meet quorum",x.errors.SERVER_ERROR,{method:t,params:e,results:n.map(h=>je(h)),provider:this})})}}const qo=null,$e=new x(Jt),Le="84842078b09946638c03157f83405213";class Fo extends ii{constructor(t,e){const r=new On(t,e),n=r.connection;n.password&&$e.throwError("INFURA WebSocket project secrets unsupported",x.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});const i=n.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(i,t),R(this,"apiKey",r.projectId),R(this,"projectId",r.projectId),R(this,"projectSecret",r.projectSecret)}isCommunityResource(){return this.projectId===Le}}class On extends ve{static getWebSocketProvider(t,e){return new Fo(t,e)}static getApiKey(t){const e={apiKey:Le,projectId:Le,projectSecret:null};return t==null||(typeof t=="string"?e.projectId=t:t.projectSecret!=null?($e.assertArgument(typeof t.projectId=="string","projectSecret requires a projectId","projectId",t.projectId),$e.assertArgument(typeof t.projectSecret=="string","invalid projectSecret","projectSecret","[REDACTED]"),e.projectId=t.projectId,e.projectSecret=t.projectSecret):t.projectId&&(e.projectId=t.projectId),e.apiKey=e.projectId),e}static getUrl(t,e){let r=null;switch(t?t.name:"unknown"){case"homestead":r="mainnet.infura.io";break;case"goerli":r="goerli.infura.io";break;case"sepolia":r="sepolia.infura.io";break;case"matic":r="polygon-mainnet.infura.io";break;case"maticmum":r="polygon-mumbai.infura.io";break;case"optimism":r="optimism-mainnet.infura.io";break;case"optimism-goerli":r="optimism-goerli.infura.io";break;case"arbitrum":r="arbitrum-mainnet.infura.io";break;case"arbitrum-goerli":r="arbitrum-goerli.infura.io";break;default:$e.throwError("unsupported network",x.errors.INVALID_ARGUMENT,{argument:"network",value:t})}const n={allowGzip:!0,url:"https://"+r+"/v3/"+e.projectId,throttleCallback:(i,a)=>(e.projectId===Le&&cr(),Promise.resolve(!0))};return e.projectSecret!=null&&(n.user="",n.password=e.projectSecret),n}isCommunityResource(){return this.projectId===Le}}class jo extends Pe{send(t,e){const r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};this._pendingBatch==null&&(this._pendingBatch=[]);const n={request:r,resolve:null,reject:null},i=new Promise((a,u)=>{n.resolve=a,n.reject=u});return this._pendingBatch.push(n),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout(()=>{const a=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;const u=a.map(h=>h.request);return this.emit("debug",{action:"requestBatch",request:le(u),provider:this}),Ge(this.connection,JSON.stringify(u)).then(h=>{this.emit("debug",{action:"response",request:u,response:h,provider:this}),a.forEach((d,p)=>{const A=h[p];if(A.error){const M=new Error(A.error.message);M.code=A.error.code,M.data=A.error.data,d.reject(M)}else d.resolve(A.result)})},h=>{this.emit("debug",{action:"response",error:h,request:u,provider:this}),a.forEach(d=>{d.reject(h)})})},10)),i}}const Jr=new x(Jt),Uo="ETHERS_JS_SHARED";class Go extends ve{static getApiKey(t){return t&&typeof t!="string"&&Jr.throwArgumentError("invalid apiKey","apiKey",t),t||Uo}static getUrl(t,e){Jr.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:Jr.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}}const rn=new x(Jt),nn="62e1ad51b37b8e00394bda3b";class zo extends ve{static getApiKey(t){const e={applicationId:null,loadBalancer:!0,applicationSecretKey:null};return t==null?e.applicationId=nn:typeof t=="string"?e.applicationId=t:t.applicationSecretKey!=null?(e.applicationId=t.applicationId,e.applicationSecretKey=t.applicationSecretKey):t.applicationId?e.applicationId=t.applicationId:rn.throwArgumentError("unsupported PocketProvider apiKey","apiKey",t),e}static getUrl(t,e){let r=null;switch(t?t.name:"unknown"){case"goerli":r="eth-goerli.gateway.pokt.network";break;case"homestead":r="eth-mainnet.gateway.pokt.network";break;case"kovan":r="poa-kovan.gateway.pokt.network";break;case"matic":r="poly-mainnet.gateway.pokt.network";break;case"maticmum":r="polygon-mumbai-rpc.gateway.pokt.network";break;case"rinkeby":r="eth-rinkeby.gateway.pokt.network";break;case"ropsten":r="eth-ropsten.gateway.pokt.network";break;default:rn.throwError("unsupported network",x.errors.INVALID_ARGUMENT,{argument:"network",value:t})}const n=`https://${r}/v1/lb/${e.applicationId}`,i={headers:{},url:n};return e.applicationSecretKey!=null&&(i.user="",i.password=e.applicationSecretKey),i}isCommunityResource(){return this.applicationId===nn}}const sn=new x(Jt);let Jo=1;function on(s,t){const e="Web3LegacyFetcher";return function(r,n){const i={method:r,params:n,id:Jo++,jsonrpc:"2.0"};return new Promise((a,u)=>{this.emit("debug",{action:"request",fetcher:e,request:le(i),provider:this}),t(i,(h,d)=>{if(h)return this.emit("debug",{action:"response",fetcher:e,error:h,request:i,provider:this}),u(h);if(this.emit("debug",{action:"response",fetcher:e,request:i,response:d,provider:this}),d.error){const p=new Error(d.error.message);return p.code=d.error.code,p.data=d.error.data,u(p)}a(d.result)})})}}function Ko(s){return function(t,e){e==null&&(e=[]);const r={method:t,params:e};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:le(r),provider:this}),s.request(r).then(n=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:r,response:n,provider:this}),n),n=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:r,error:n,provider:this}),n})}}class Ho extends Pe{constructor(t,e){t==null&&sn.throwArgumentError("missing provider","provider",t);let r=null,n=null,i=null;typeof t=="function"?(r="unknown:",n=t):(r=t.host||t.path||"",!r&&t.isMetaMask&&(r="metamask"),i=t,t.request?(r===""&&(r="eip-1193:"),n=Ko(t)):t.sendAsync?n=on(t,t.sendAsync.bind(t)):t.send?n=on(t,t.send.bind(t)):sn.throwArgumentError("unsupported provider","provider",t),r||(r="unknown:")),super(r,e),R(this,"jsonRpcFetchFunc",n),R(this,"provider",i)}send(t,e){return this.jsonRpcFetchFunc(t,e)}}const an=new x(Jt);function Yo(s,t){if(s==null&&(s="homestead"),typeof s=="string"){const r=s.match(/^(ws|http)s?:/i);if(r)switch(r[1].toLowerCase()){case"http":case"https":return new Pe(s);case"ws":case"wss":return new ii(s);default:an.throwArgumentError("unsupported URL scheme","network",s)}}const e=Nn(s);return(!e||!e._defaultProvider)&&an.throwError("unsupported getDefaultProvider network",x.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:s}),e._defaultProvider({FallbackProvider:Do,AlchemyProvider:Cn,AnkrProvider:_o,CloudflareProvider:Po,EtherscanProvider:So,InfuraProvider:On,JsonRpcProvider:Pe,NodesmithProvider:Go,PocketProvider:zo,Web3Provider:Ho,IpcProvider:qo},t)}export{Cn as AlchemyProvider,Eo as AlchemyWebSocketProvider,_o as AnkrProvider,ri as BaseProvider,Po as CloudflareProvider,So as EtherscanProvider,Do as FallbackProvider,N as Formatter,On as InfuraProvider,Fo as InfuraWebSocketProvider,qo as IpcProvider,jo as JsonRpcBatchProvider,Pe as JsonRpcProvider,Bn as JsonRpcSigner,Go as NodesmithProvider,zo as PocketProvider,lr as Provider,Qi as Resolver,ko as StaticJsonRpcProvider,ve as UrlJsonRpcProvider,Ho as Web3Provider,ii as WebSocketProvider,Yo as getDefaultProvider,Nn as getNetwork,ao as isCommunityResourcable,qi as isCommunityResource,cr as showThrottleMessage};