@reown/appkit-cdn 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ethers.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var yp=Object.defineProperty;var wp=(r,e,t)=>e in r?yp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var E=(r,e,t)=>(wp(r,typeof e!="symbol"?e+"":e,t),t),wc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var u=(r,e,t)=>(wc(r,e,"read from private field"),t?t.call(r):e.get(r)),A=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},p=(r,e,t,n)=>(wc(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var Ti=(r,e,t,n)=>({set _(s){p(r,e,s,t)},get _(){return u(r,e,n)}}),N=(r,e,t)=>(wc(r,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./W3MFrameProviderSingleton-C56DqhGz.cjs"),Es=require("./hooks.module-COfcimjS.cjs"),bc={WALLET_ID:"@w3m/wallet_id",WALLET_NAME:"@w3m/wallet_name",ACTIVE_CAIPNETWORK:"@w3m/active_caipnetwork",ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3},ur={getCaipDefaultChain(r){if(r)return{id:`${b.ConstantsUtil.EIP155}:${r.chainId}`,name:r.name,imageId:b.PresetsUtil.NetworkImageIds[r.chainId],chainNamespace:b.ConstantsUtil$1.CHAIN.EVM}},hexStringToNumber(r){const e=r.startsWith("0x")?r.slice(2):r;return parseInt(e,16)},numberToHexString(r){return`0x${r.toString(16)}`},async getUserInfo(r){const[e,t]=await Promise.all([ur.getAddresses(r),ur.getChainId(r)]);return{chainId:t,addresses:e}},async getChainId(r){const e=await r.request({method:"eth_chainId"});return Number(e)},async getAddress(r){const[e]=await r.request({method:"eth_accounts"});return e},async getAddresses(r){return await r.request({method:"eth_accounts"})},async addEthereumChain(r,e){await r.request({method:"wallet_addEthereumChain",params:[{chainId:ur.numberToHexString(e.chainId),rpcUrls:[e.rpcUrl],chainName:e.name,nativeCurrency:{name:e.currency,decimals:18,symbol:e.currency},blockExplorerUrls:[e.explorerUrl],iconUrls:[b.PresetsUtil.NetworkImageIds[e.chainId]]}]})}},bp="6.13.0";function Ap(r,e,t){const n=e.split("|").map(i=>i.trim());for(let i=0;i<n.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof r===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=r,s}async function Te(r){const e=Object.keys(r);return(await Promise.all(e.map(n=>Promise.resolve(r[n])))).reduce((n,s,i)=>(n[e[i]]=s,n),{})}function F(r,e,t){for(let n in e){let s=e[n];const i=t?t[n]:null;i&&Ap(s,i,n),Object.defineProperty(r,n,{enumerable:!0,value:s,writable:!1})}}function fs(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(fs).join(", ")+" ]";if(r instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let n=0;n<r.length;n++)t+=e[r[n]>>4],t+=e[r[n]&15];return t}if(typeof r=="object"&&typeof r.toJSON=="function")return fs(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const e=Object.keys(r);return e.sort(),"{ "+e.map(t=>`${fs(t)}: ${fs(r[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ke(r,e){return r&&r.code===e}function kl(r){return ke(r,"CALL_EXCEPTION")}function ne(r,e,t){let n=r;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${fs(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+fs(a))}}i.push(`code=${e}`),i.push(`version=${bp}`),i.length&&(r+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(r);break;default:s=new Error(r)}return F(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&F(s,{shortMessage:n}),s}function I(r,e,t,n){if(!r)throw ne(e,t,n)}function y(r,e,t,n){I(r,e,"INVALID_ARGUMENT",{argument:t,value:n})}function Wh(r,e,t){t==null&&(t=""),t&&(t=": "+t),I(r>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:r,expectedCount:e}),I(r<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((r,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");r.push(e)}catch{}return r},[]);function xo(r,e,t){if(t==null&&(t=""),r!==e){let n=t,s="new";t&&(n+=".",s+=" "+t),I(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function Vh(r,e,t){if(r instanceof Uint8Array)return t?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let s=2;for(let i=0;i<n.length;i++)n[i]=parseInt(r.substring(s,s+2),16),s+=2;return n}y(!1,"invalid BytesLike value",e||"value",r)}function V(r,e){return Vh(r,e,!1)}function _e(r,e){return Vh(r,e,!0)}function X(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&r.length!==2+2*e||e===!0&&r.length%2!==0)}function xl(r){return X(r,!0)||r instanceof Uint8Array}const lu="0123456789abcdef";function T(r){const e=V(r);let t="0x";for(let n=0;n<e.length;n++){const s=e[n];t+=lu[(s&240)>>4]+lu[s&15]}return t}function le(r){return"0x"+r.map(e=>T(e).substring(2)).join("")}function Cs(r){return X(r,!0)?(r.length-2)/2:V(r).length}function se(r,e,t){const n=V(r);return t!=null&&t>n.length&&I(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:t}),T(n.slice(e??0,t??n.length))}function Qh(r,e,t){const n=V(r);I(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(n,e-n.length):s.set(n,0),T(s)}function Kr(r,e){return Qh(r,e,!0)}function Ep(r,e){return Qh(r,e,!1)}const Ua=BigInt(0),Ct=BigInt(1),ps=9007199254740991;function da(r,e){const t=Ma(r,"value"),n=BigInt(H(e,"width"));if(I(t>>n===Ua,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),t>>n-Ct){const s=(Ct<<n)-Ct;return-((~t&s)+Ct)}return t}function zh(r,e){let t=_(r,"value");const n=BigInt(H(e,"width")),s=Ct<<n-Ct;if(t<Ua){t=-t,I(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});const i=(Ct<<n)-Ct;return(~t&i)+Ct}else I(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});return t}function hr(r,e){const t=Ma(r,"value"),n=BigInt(H(e,"bits"));return t&(Ct<<n)-Ct}function _(r,e){switch(typeof r){case"bigint":return r;case"number":return y(Number.isInteger(r),"underflow",e||"value",r),y(r>=-ps&&r<=ps,"overflow",e||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(t){y(!1,`invalid BigNumberish string: ${t.message}`,e||"value",r)}}y(!1,"invalid BigNumberish value",e||"value",r)}function Ma(r,e){const t=_(r,e);return I(t>=Ua,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),t}const uu="0123456789abcdef";function Da(r){if(r instanceof Uint8Array){let e="0x0";for(const t of r)e+=uu[t>>4],e+=uu[t&15];return BigInt(e)}return _(r)}function H(r,e){switch(typeof r){case"bigint":return y(r>=-ps&&r<=ps,"overflow",e||"value",r),Number(r);case"number":return y(Number.isInteger(r),"underflow",e||"value",r),y(r>=-ps&&r<=ps,"overflow",e||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return H(BigInt(r),e)}catch(t){y(!1,`invalid numeric string: ${t.message}`,e||"value",r)}}y(!1,"invalid numeric value",e||"value",r)}function Cp(r){return H(Da(r))}function Xn(r,e){let n=Ma(r,"value").toString(16);if(e==null)n.length%2&&(n="0"+n);else{const s=H(e,"width");for(I(s*2>=n.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length<s*2;)n="0"+n}return"0x"+n}function Le(r){const e=Ma(r,"value");if(e===Ua)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const n=new Uint8Array(t.length/2);for(let s=0;s<n.length;s++){const i=s*2;n[s]=parseInt(t.substring(i,i+2),16)}return n}function gs(r){let e=T(xl(r)?r:Le(r)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const hu="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const du=BigInt(58);function vp(r){const e=V(r);let t=Da(e),n="";for(;t;)n=hu[Number(t%du)]+n,t/=du;for(let s=0;s<e.length&&!e[s];s++)n=hu[0]+n;return n}function Ip(r){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return V(e)}function Np(r){const e=V(r);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var Ps;class Jh{constructor(e,t,n){E(this,"filter");E(this,"emitter");A(this,Ps,void 0);p(this,Ps,t),F(this,{emitter:e,filter:n})}async removeListener(){u(this,Ps)!=null&&await this.emitter.off(this.filter,u(this,Ps))}}Ps=new WeakMap;function Sp(r,e,t,n,s){y(!1,`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function qh(r,e,t,n,s){if(r==="BAD_PREFIX"||r==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return r==="OVERRUN"?t.length-e-1:0}function kp(r,e,t,n,s){return r==="OVERLONG"?(y(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),qh(r,e,t))}const xp=Object.freeze({error:Sp,ignore:qh,replace:kp});function Pp(r,e){e==null&&(e=xp.error);const t=V(r,"bytes"),n=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){n.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,n):s+=e("BAD_PREFIX",s-1,t,n);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,n);continue}let c=i&(1<<8-o-1)-1;for(let l=0;l<o;l++){let h=t[s];if((h&192)!=128){s+=e("MISSING_CONTINUE",s,t,n),c=null;break}c=c<<6|h&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,n,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,n,c);continue}if(c<=a){s+=e("OVERLONG",s-1-o,t,n,c);continue}n.push(c)}}return n}function jt(r,e){y(typeof r=="string","invalid string value","str",r);let t=[];for(let n=0;n<r.length;n++){const s=r.charCodeAt(n);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){n++;const i=r.charCodeAt(n);y(n<r.length&&(i&64512)===56320,"invalid surrogate pair","str",r);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function Rp(r){return r.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function fa(r,e){return Rp(Pp(r,e))}function Zh(r){async function e(t,n){I(n==null||!n.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();I(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),I(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=ne("request timeout","TIMEOUT"),o.abort()},t.timeout);n&&n.addListener(()=>{i=ne("request cancelled","CANCELLED"),o.abort()});const c={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let l;try{l=await fetch(t.url,c)}catch(g){throw clearTimeout(a),i||g}clearTimeout(a);const h={};l.headers.forEach((g,w)=>{h[w.toLowerCase()]=g});const d=await l.arrayBuffer(),f=d==null?null:new Uint8Array(d);return{statusCode:l.status,statusMessage:l.statusText,headers:h,body:f}}return e}const Op=12,Tp=250;let fu=Zh();const Bp=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),_p=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Ac=!1;async function $h(r,e){try{const t=r.match(Bp);if(!t)throw new Error("invalid data");return new Yn(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?Ip(t[3]):Up(t[3]))}catch{return new Yn(599,"BAD REQUEST (invalid data: URI)",{},null,new Qt(r))}}function Yh(r){async function e(t,n){try{const s=t.match(_p);if(!s)throw new Error("invalid link");return new Qt(`${r}${s[2]}`)}catch{return new Yn(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Qt(t))}}return e}const Fo={data:$h,ipfs:Yh("https://gateway.ipfs.io/ipfs/")},Xh=new WeakMap;var gr,Tn;class Lp{constructor(e){A(this,gr,void 0);A(this,Tn,void 0);p(this,gr,[]),p(this,Tn,!1),Xh.set(e,()=>{if(!u(this,Tn)){p(this,Tn,!0);for(const t of u(this,gr))setTimeout(()=>{t()},0);p(this,gr,[])}})}addListener(e){I(!u(this,Tn),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),u(this,gr).push(e)}get cancelled(){return u(this,Tn)}checkSignal(){I(!this.cancelled,"cancelled","CANCELLED",{})}}gr=new WeakMap,Tn=new WeakMap;function Ho(r){if(r==null)throw new Error("missing signal; should not happen");return r.checkSignal(),r}var Rs,Os,gt,nn,Ts,Bs,ge,Je,rn,mr,yr,wr,Ot,mt,Bn,br,Mi;const xa=class xa{constructor(e){A(this,br);A(this,Rs,void 0);A(this,Os,void 0);A(this,gt,void 0);A(this,nn,void 0);A(this,Ts,void 0);A(this,Bs,void 0);A(this,ge,void 0);A(this,Je,void 0);A(this,rn,void 0);A(this,mr,void 0);A(this,yr,void 0);A(this,wr,void 0);A(this,Ot,void 0);A(this,mt,void 0);A(this,Bn,void 0);p(this,Bs,String(e)),p(this,Rs,!1),p(this,Os,!0),p(this,gt,{}),p(this,nn,""),p(this,Ts,3e5),p(this,mt,{slotInterval:Tp,maxAttempts:Op}),p(this,Bn,null)}get url(){return u(this,Bs)}set url(e){p(this,Bs,String(e))}get body(){return u(this,ge)==null?null:new Uint8Array(u(this,ge))}set body(e){if(e==null)p(this,ge,void 0),p(this,Je,void 0);else if(typeof e=="string")p(this,ge,jt(e)),p(this,Je,"text/plain");else if(e instanceof Uint8Array)p(this,ge,e),p(this,Je,"application/octet-stream");else if(typeof e=="object")p(this,ge,jt(JSON.stringify(e))),p(this,Je,"application/json");else throw new Error("invalid body")}hasBody(){return u(this,ge)!=null}get method(){return u(this,nn)?u(this,nn):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),p(this,nn,String(e).toUpperCase())}get headers(){const e=Object.assign({},u(this,gt));return u(this,rn)&&(e.authorization=`Basic ${Np(jt(u(this,rn)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&u(this,Je)&&(e["content-type"]=u(this,Je)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){u(this,gt)[String(e).toLowerCase()]=String(t)}clearHeaders(){p(this,gt,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return u(this,rn)||null}setCredentials(e,t){y(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),p(this,rn,`${e}:${t}`)}get allowGzip(){return u(this,Os)}set allowGzip(e){p(this,Os,!!e)}get allowInsecureAuthentication(){return!!u(this,Rs)}set allowInsecureAuthentication(e){p(this,Rs,!!e)}get timeout(){return u(this,Ts)}set timeout(e){y(e>=0,"timeout must be non-zero","timeout",e),p(this,Ts,e)}get preflightFunc(){return u(this,mr)||null}set preflightFunc(e){p(this,mr,e)}get processFunc(){return u(this,yr)||null}set processFunc(e){p(this,yr,e)}get retryFunc(){return u(this,wr)||null}set retryFunc(e){p(this,wr,e)}get getUrlFunc(){return u(this,Bn)||fu}set getUrlFunc(e){p(this,Bn,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${u(this,ge)?T(u(this,ge)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(u(this,mt).slotInterval=e.slotInterval),e.maxAttempts!=null&&(u(this,mt).maxAttempts=e.maxAttempts)}send(){return I(u(this,Ot)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),p(this,Ot,new Lp(this)),N(this,br,Mi).call(this,0,pu()+this.timeout,0,this,new Yn(0,"",{},null,this))}cancel(){I(u(this,Ot)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=Xh.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();I(this.method==="GET"&&(t!=="https"||n!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new xa(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,p(s,gt,Object.assign({},u(this,gt))),u(this,ge)&&p(s,ge,new Uint8Array(u(this,ge))),p(s,Je,u(this,Je)),s}clone(){const e=new xa(this.url);return p(e,nn,u(this,nn)),u(this,ge)&&p(e,ge,u(this,ge)),p(e,Je,u(this,Je)),p(e,gt,Object.assign({},u(this,gt))),p(e,rn,u(this,rn)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),p(e,mr,u(this,mr)),p(e,yr,u(this,yr)),p(e,wr,u(this,wr)),p(e,mt,Object.assign({},u(this,mt))),p(e,Bn,u(this,Bn)),e}static lockConfig(){Ac=!0}static getGateway(e){return Fo[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Ac)throw new Error("gateways locked");Fo[e]=t}static registerGetUrl(e){if(Ac)throw new Error("gateways locked");fu=e}static createGetUrlFunc(e){return Zh()}static createDataGateway(){return $h}static createIpfsGatewayFunc(e){return Yh(e)}};Rs=new WeakMap,Os=new WeakMap,gt=new WeakMap,nn=new WeakMap,Ts=new WeakMap,Bs=new WeakMap,ge=new WeakMap,Je=new WeakMap,rn=new WeakMap,mr=new WeakMap,yr=new WeakMap,wr=new WeakMap,Ot=new WeakMap,mt=new WeakMap,Bn=new WeakMap,br=new WeakSet,Mi=async function(e,t,n,s,i){var h,d,f;if(e>=u(this,mt).maxAttempts)return i.makeServerError("exceeded maximum retry limit");I(pu()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),n>0&&await Mp(n);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Fo){const g=await Fo[a](o.url,Ho(u(s,Ot)));if(g instanceof Yn){let w=g;if(this.processFunc){Ho(u(s,Ot));try{w=await this.processFunc(o,w)}catch(m){(m.throttle==null||typeof m.stall!="number")&&w.makeServerError("error in post-processing function",m).assertOk()}}return w}o=g}this.preflightFunc&&(o=await this.preflightFunc(o));const c=await this.getUrlFunc(o,Ho(u(s,Ot)));let l=new Yn(c.statusCode,c.statusMessage,c.headers,c.body,s);if(l.statusCode===301||l.statusCode===302){try{const g=l.headers.location||"";return N(h=o.redirect(g),br,Mi).call(h,e+1,t,0,s,l)}catch{}return l}else if(l.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,l,e))){const g=l.headers["retry-after"];let w=u(this,mt).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof g=="string"&&g.match(/^[1-9][0-9]*$/)&&(w=parseInt(g)),N(d=o.clone(),br,Mi).call(d,e+1,t,w,s,l)}if(this.processFunc){Ho(u(s,Ot));try{l=await this.processFunc(o,l)}catch(g){(g.throttle==null||typeof g.stall!="number")&&l.makeServerError("error in post-processing function",g).assertOk();let w=u(this,mt).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return g.stall>=0&&(w=g.stall),N(f=o.clone(),br,Mi).call(f,e+1,t,w,s,l)}}return l};let Qt=xa;var ro,so,io,qe,_s,Ar;const ru=class ru{constructor(e,t,n,s,i){A(this,ro,void 0);A(this,so,void 0);A(this,io,void 0);A(this,qe,void 0);A(this,_s,void 0);A(this,Ar,void 0);p(this,ro,e),p(this,so,t),p(this,io,Object.keys(n).reduce((o,a)=>(o[a.toLowerCase()]=String(n[a]),o),{})),p(this,qe,s==null?null:new Uint8Array(s)),p(this,_s,i||null),p(this,Ar,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${u(this,qe)?T(u(this,qe)):"null"}>`}get statusCode(){return u(this,ro)}get statusMessage(){return u(this,so)}get headers(){return Object.assign({},u(this,io))}get body(){return u(this,qe)==null?null:new Uint8Array(u(this,qe))}get bodyText(){try{return u(this,qe)==null?"":fa(u(this,qe))}catch{I(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{I(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let n;e?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new ru(599,n,this.headers,this.body,u(this,_s)||void 0);return p(s,Ar,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:y(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw F(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return u(this,qe)!=null}get request(){return u(this,_s)}ok(){return u(this,Ar).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=u(this,Ar);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let s=null;try{u(this,qe)&&(s=fa(u(this,qe)))}catch{}I(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};ro=new WeakMap,so=new WeakMap,io=new WeakMap,qe=new WeakMap,_s=new WeakMap,Ar=new WeakMap;let Yn=ru;function pu(){return new Date().getTime()}function Up(r){return jt(r.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function Mp(r){return new Promise(e=>setTimeout(e,r))}const Dp=BigInt(-1),dt=BigInt(0),ms=BigInt(1),Fp=BigInt(5),ns={};let vs="0000";for(;vs.length<80;)vs+=vs;function nr(r){let e=vs;for(;e.length<r;)e+=e;return BigInt("1"+e.substring(0,r))}function Bi(r,e,t){const n=BigInt(e.width);if(e.signed){const s=ms<<n-ms;I(t==null||r>=-s&&r<s,"overflow","NUMERIC_FAULT",{operation:t,fault:"overflow",value:r}),r>dt?r=da(hr(r,n),n):r=-da(hr(-r,n),n)}else{const s=ms<<n;I(t==null||r>=0&&r<s,"overflow","NUMERIC_FAULT",{operation:t,fault:"overflow",value:r}),r=(r%s+s)%s&s-ms}return r}function Ec(r){typeof r=="number"&&(r=`fixed128x${r}`);let e=!0,t=128,n=18;if(typeof r=="string"){if(r!=="fixed")if(r==="ufixed")e=!1;else{const i=r.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);y(i,"invalid fixed format","format",r),e=i[1]!=="u",t=parseInt(i[2]),n=parseInt(i[3])}}else if(r){const i=r,o=(a,c,l)=>i[a]==null?l:(y(typeof i[a]===c,"invalid fixed format ("+a+" not "+c+")","format."+a,i[a]),i[a]);e=o("signed","boolean",e),t=o("width","number",t),n=o("decimals","number",n)}y(t%8===0,"invalid FixedNumber width (not byte aligned)","format.width",t),y(n<=80,"invalid FixedNumber decimals (too large)","format.decimals",n);const s=(e?"":"u")+"fixed"+String(t)+"x"+String(n);return{signed:e,width:t,decimals:n,name:s}}function Hp(r,e){let t="";r<dt&&(t="-",r*=Dp);let n=r.toString();if(e===0)return t+n;for(;n.length<=e;)n=vs+n;const s=n.length-e;for(n=n.substring(0,s)+"."+n.substring(s);n[0]==="0"&&n[1]!==".";)n=n.substring(1);for(;n[n.length-1]==="0"&&n[n.length-2]!==".";)n=n.substring(0,n.length-1);return t+n}var yt,Z,Pe,sn,rr,wt,Zt,oo,Vc,ao,Qc,co,zc,lo,Jc;const On=class On{constructor(e,t,n){A(this,sn);A(this,wt);A(this,oo);A(this,ao);A(this,co);A(this,lo);E(this,"format");A(this,yt,void 0);A(this,Z,void 0);A(this,Pe,void 0);E(this,"_value");xo(e,ns,"FixedNumber"),p(this,Z,t),p(this,yt,n);const s=Hp(t,n.decimals);F(this,{format:n.name,_value:s}),p(this,Pe,nr(n.decimals))}get signed(){return u(this,yt).signed}get width(){return u(this,yt).width}get decimals(){return u(this,yt).decimals}get value(){return u(this,Z)}addUnsafe(e){return N(this,oo,Vc).call(this,e)}add(e){return N(this,oo,Vc).call(this,e,"add")}subUnsafe(e){return N(this,ao,Qc).call(this,e)}sub(e){return N(this,ao,Qc).call(this,e,"sub")}mulUnsafe(e){return N(this,co,zc).call(this,e)}mul(e){return N(this,co,zc).call(this,e,"mul")}mulSignal(e){N(this,sn,rr).call(this,e);const t=u(this,Z)*u(e,Z);return I(t%u(this,Pe)===dt,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),N(this,wt,Zt).call(this,t/u(this,Pe),"mulSignal")}divUnsafe(e){return N(this,lo,Jc).call(this,e)}div(e){return N(this,lo,Jc).call(this,e,"div")}divSignal(e){I(u(e,Z)!==dt,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),N(this,sn,rr).call(this,e);const t=u(this,Z)*u(this,Pe);return I(t%u(e,Z)===dt,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),N(this,wt,Zt).call(this,t/u(e,Z),"divSignal")}cmp(e){let t=this.value,n=e.value;const s=this.decimals-e.decimals;return s>0?n*=nr(s):s<0&&(t*=nr(-s)),t<n?-1:t>n?1:0}eq(e){return this.cmp(e)===0}lt(e){return this.cmp(e)<0}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)>0}gte(e){return this.cmp(e)>=0}floor(){let e=u(this,Z);return u(this,Z)<dt&&(e-=u(this,Pe)-ms),e=u(this,Z)/u(this,Pe)*u(this,Pe),N(this,wt,Zt).call(this,e,"floor")}ceiling(){let e=u(this,Z);return u(this,Z)>dt&&(e+=u(this,Pe)-ms),e=u(this,Z)/u(this,Pe)*u(this,Pe),N(this,wt,Zt).call(this,e,"ceiling")}round(e){if(e==null&&(e=0),e>=this.decimals)return this;const t=this.decimals-e,n=Fp*nr(t-1);let s=this.value+n;const i=nr(t);return s=s/i*i,Bi(s,u(this,yt),"round"),new On(ns,s,u(this,yt))}isZero(){return u(this,Z)===dt}isNegative(){return u(this,Z)<dt}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return On.fromString(this.toString(),e)}static fromValue(e,t,n){const s=t==null?0:H(t),i=Ec(n);let o=_(e,"value");const a=s-i.decimals;if(a>0){const c=nr(a);I(o%c===dt,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),o/=c}else a<0&&(o*=nr(-a));return Bi(o,i,"fromValue"),new On(ns,o,i)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);y(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const s=Ec(t);let i=n[2]||"0",o=n[3]||"";for(;o.length<s.decimals;)o+=vs;I(o.substring(s.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),o=o.substring(0,s.decimals);const a=BigInt(n[1]+i+o);return Bi(a,s,"fromString"),new On(ns,a,s)}static fromBytes(e,t){let n=Da(V(e,"value"));const s=Ec(t);return s.signed&&(n=da(n,s.width)),Bi(n,s,"fromBytes"),new On(ns,n,s)}};yt=new WeakMap,Z=new WeakMap,Pe=new WeakMap,sn=new WeakSet,rr=function(e){y(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)},wt=new WeakSet,Zt=function(e,t){return e=Bi(e,u(this,yt),t),new On(ns,e,u(this,yt))},oo=new WeakSet,Vc=function(e,t){return N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)+u(e,Z),t)},ao=new WeakSet,Qc=function(e,t){return N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)-u(e,Z),t)},co=new WeakSet,zc=function(e,t){return N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)*u(e,Z)/u(this,Pe),t)},lo=new WeakSet,Jc=function(e,t){return I(u(e,Z)!==dt,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)*u(this,Pe)/u(e,Z),t)};let pa=On;function Gp(r){let e=r.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function gu(r,e,t){let n=0;for(let s=0;s<t;s++)n=n*256+r[e+s];return n}function mu(r,e,t,n){const s=[];for(;t<e+1+n;){const i=ed(r,t);s.push(i.result),t+=i.consumed,I(t<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:r,length:n,offset:e})}return{consumed:1+n,result:s}}function ed(r,e){I(r.length!==0,"data too short","BUFFER_OVERRUN",{buffer:r,length:0,offset:1});const t=n=>{I(n<=r.length,"data short segment too short","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n})};if(r[e]>=248){const n=r[e]-247;t(e+1+n);const s=gu(r,e+1,n);return t(e+1+n+s),mu(r,e,e+1+n,n+s)}else if(r[e]>=192){const n=r[e]-192;return t(e+1+n),mu(r,e,e+1,n)}else if(r[e]>=184){const n=r[e]-183;t(e+1+n);const s=gu(r,e+1,n);t(e+1+n+s);const i=T(r.slice(e+1+n,e+1+n+s));return{consumed:1+n+s,result:i}}else if(r[e]>=128){const n=r[e]-128;t(e+1+n);const s=T(r.slice(e+1,e+1+n));return{consumed:1+n,result:s}}return{consumed:1,result:Gp(r[e])}}function Fa(r){const e=V(r,"data"),t=ed(e,0);return y(t.consumed===e.length,"unexpected junk after rlp payload","data",r),t.result}function yu(r){const e=[];for(;r;)e.unshift(r&255),r>>=8;return e}function td(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(i){n=n.concat(td(i))}),n.length<=55)return n.unshift(192+n.length),n;const s=yu(n.length);return s.unshift(247+s.length),s.concat(n)}const e=Array.prototype.slice.call(V(r,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=yu(e.length);return t.unshift(183+t.length),t.concat(e)}const wu="0123456789abcdef";function jr(r){let e="0x";for(const t of td(r))e+=wu[t>>4],e+=wu[t&15];return e}const nd=["wei","kwei","mwei","gwei","szabo","finney","ether"];function rd(r,e){let t=18;if(typeof e=="string"){const n=nd.indexOf(e);y(n>=0,"invalid unit","unit",e),t=3*n}else e!=null&&(t=H(e,"unit"));return pa.fromValue(r,t,{decimals:t,width:512}).toString()}function Kp(r,e){y(typeof r=="string","value must be a string","value",r);let t=18;if(typeof e=="string"){const n=nd.indexOf(e);y(n>=0,"invalid unit","unit",e),t=3*n}else e!=null&&(t=H(e,"unit"));return pa.fromString(r,{decimals:t,width:512}).value}function jp(r){return rd(r,18)}const Ue=32,qc=new Uint8Array(Ue),Wp=["then"],Go={},sd=new WeakMap;function ir(r){return sd.get(r)}function bu(r,e){sd.set(r,e)}function _i(r,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw t.error=e,t}function Zc(r,e,t){return r.indexOf(null)>=0?e.map((n,s)=>n instanceof bi?Zc(ir(n),n,t):n):r.reduce((n,s,i)=>{let o=e.getValue(s);return s in n||(t&&o instanceof bi&&(o=Zc(ir(o),o,t)),n[s]=o),n},{})}var Ls;const ws=class ws extends Array{constructor(...t){const n=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;n!==Go&&(s=t,i=[],o=!1);super(s.length);A(this,Ls,void 0);s.forEach((l,h)=>{this[h]=l});const a=i.reduce((l,h)=>(typeof h=="string"&&l.set(h,(l.get(h)||0)+1),l),new Map);if(bu(this,Object.freeze(s.map((l,h)=>{const d=i[h];return d!=null&&a.get(d)===1?d:null}))),p(this,Ls,[]),u(this,Ls)==null&&u(this,Ls),!o)return;Object.freeze(this);const c=new Proxy(this,{get:(l,h,d)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const g=H(h,"%index");if(g<0||g>=this.length)throw new RangeError("out of result range");const w=l[g];return w instanceof Error&&_i(`index ${g}`,w),w}if(Wp.indexOf(h)>=0)return Reflect.get(l,h,d);const f=l[h];if(f instanceof Function)return function(...g){return f.apply(this===d?l:this,g)};if(!(h in l))return l.getValue.apply(this===d?l:this,[h])}return Reflect.get(l,h,d)}});return bu(c,ir(this)),c}toArray(t){const n=[];return this.forEach((s,i)=>{s instanceof Error&&_i(`index ${i}`,s),t&&s instanceof ws&&(s=s.toArray(t)),n.push(s)}),n}toObject(t){const n=ir(this);return n.reduce((s,i,o)=>(I(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Zc(n,this,t)),{})}slice(t,n){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),n==null&&(n=this.length),n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);const s=ir(this),i=[],o=[];for(let a=t;a<n;a++)i.push(this[a]),o.push(s[a]);return new ws(Go,i,o)}filter(t,n){const s=ir(this),i=[],o=[];for(let a=0;a<this.length;a++){const c=this[a];c instanceof Error&&_i(`index ${a}`,c),t.call(n,c,a,this)&&(i.push(c),o.push(s[a]))}return new ws(Go,i,o)}map(t,n){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&_i(`index ${i}`,o),s.push(t.call(n,o,i,this))}return s}getValue(t){const n=ir(this).indexOf(t);if(n===-1)return;const s=this[n];return s instanceof Error&&_i(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,n){return new ws(Go,t,n)}};Ls=new WeakMap;let bi=ws;function Au(r){let e=Le(r);return I(e.length<=Ue,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Ue,offset:e.length}),e.length!==Ue&&(e=_e(le([qc.slice(e.length%Ue),e]))),e}class En{constructor(e,t,n,s){E(this,"name");E(this,"type");E(this,"localName");E(this,"dynamic");F(this,{name:e,type:t,localName:n,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){y(!1,e,this.localName,t)}}var on,Er,Us,ta;class $c{constructor(){A(this,Us);A(this,on,void 0);A(this,Er,void 0);p(this,on,[]),p(this,Er,0)}get data(){return le(u(this,on))}get length(){return u(this,Er)}appendWriter(e){return N(this,Us,ta).call(this,_e(e.data))}writeBytes(e){let t=_e(e);const n=t.length%Ue;return n&&(t=_e(le([t,qc.slice(n)]))),N(this,Us,ta).call(this,t)}writeValue(e){return N(this,Us,ta).call(this,Au(e))}writeUpdatableValue(){const e=u(this,on).length;return u(this,on).push(qc),p(this,Er,u(this,Er)+Ue),t=>{u(this,on)[e]=Au(t)}}}on=new WeakMap,Er=new WeakMap,Us=new WeakSet,ta=function(e){return u(this,on).push(e),p(this,Er,u(this,Er)+e.length),e.length};var Fe,Ze,Cr,vr,_n,uo,Xc,Pa,id;const su=class su{constructor(e,t,n){A(this,uo);A(this,Pa);E(this,"allowLoose");A(this,Fe,void 0);A(this,Ze,void 0);A(this,Cr,void 0);A(this,vr,void 0);A(this,_n,void 0);F(this,{allowLoose:!!t}),p(this,Fe,_e(e)),p(this,Cr,0),p(this,vr,null),p(this,_n,n??1024),p(this,Ze,0)}get data(){return T(u(this,Fe))}get dataLength(){return u(this,Fe).length}get consumed(){return u(this,Ze)}get bytes(){return new Uint8Array(u(this,Fe))}subReader(e){const t=new su(u(this,Fe).slice(u(this,Ze)+e),this.allowLoose,u(this,_n));return p(t,vr,this),t}readBytes(e,t){let n=N(this,Pa,id).call(this,0,e,!!t);return N(this,uo,Xc).call(this,e),p(this,Ze,u(this,Ze)+n.length),n.slice(0,e)}readValue(){return Da(this.readBytes(Ue))}readIndex(){return Cp(this.readBytes(Ue))}};Fe=new WeakMap,Ze=new WeakMap,Cr=new WeakMap,vr=new WeakMap,_n=new WeakMap,uo=new WeakSet,Xc=function(e){var t;if(u(this,vr))return N(t=u(this,vr),uo,Xc).call(t,e);p(this,Cr,u(this,Cr)+e),I(u(this,_n)<1||u(this,Cr)<=u(this,_n)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${u(this,_n)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:_e(u(this,Fe)),offset:u(this,Ze),length:e,info:{bytesRead:u(this,Cr),dataLength:this.dataLength}})},Pa=new WeakSet,id=function(e,t,n){let s=Math.ceil(t/Ue)*Ue;return u(this,Ze)+s>u(this,Fe).length&&(this.allowLoose&&n&&u(this,Ze)+t<=u(this,Fe).length?s=t:I(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:_e(u(this,Fe)),length:u(this,Fe).length,offset:u(this,Ze)+s})),u(this,Fe).slice(u(this,Ze),u(this,Ze)+s)};let Yc=su;function ga(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Pl(r,...e){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function Vp(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ga(r.outputLen),ga(r.blockLen)}function Ai(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function od(r,e){Pl(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Cc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ad=r=>r instanceof Uint8Array,Qp=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),vc=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),xt=(r,e)=>r<<32-e|r>>>e,zp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!zp)throw new Error("Non little-endian hardware is not supported");function Jp(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ha(r){if(typeof r=="string"&&(r=Jp(r)),!ad(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function qp(...r){const e=new Uint8Array(r.reduce((n,s)=>n+s.length,0));let t=0;return r.forEach(n=>{if(!ad(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class Rl{clone(){return this._cloneInto()}}function Ol(r){const e=n=>r().update(Ha(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Zp(r=32){if(Cc&&typeof Cc.getRandomValues=="function")return Cc.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}class cd extends Rl{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Vp(e);const n=Ha(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Ai(this),this.iHash.update(e),this}digestInto(e){Ai(this),Pl(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ld=(r,e,t)=>new cd(r,e).update(t).digest();ld.create=(r,e)=>new cd(r,e);function $p(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),c=n?4:0,l=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+l,a,n)}class ud extends Rl{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=vc(this.buffer)}update(e){Ai(this);const{view:t,buffer:n,blockLen:s}=this;e=Ha(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const c=vc(e);for(;s<=i-o;o+=s)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ai(this),od(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(n,0),o=0);for(let d=o;d<s;d++)t[d]=0;$p(n,s-8,BigInt(this.length*8),i),this.process(n,0);const a=vc(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,h[d],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(n),e}}const Yp=(r,e,t)=>r&e^~r&t,Xp=(r,e,t)=>r&e^r&t^e&t,eg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Nn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Sn=new Uint32Array(64);class tg extends ud{constructor(){super(64,32,8,!1),this.A=Nn[0]|0,this.B=Nn[1]|0,this.C=Nn[2]|0,this.D=Nn[3]|0,this.E=Nn[4]|0,this.F=Nn[5]|0,this.G=Nn[6]|0,this.H=Nn[7]|0}get(){const{A:e,B:t,C:n,D:s,E:i,F:o,G:a,H:c}=this;return[e,t,n,s,i,o,a,c]}set(e,t,n,s,i,o,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let d=0;d<16;d++,t+=4)Sn[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){const f=Sn[d-15],g=Sn[d-2],w=xt(f,7)^xt(f,18)^f>>>3,m=xt(g,17)^xt(g,19)^g>>>10;Sn[d]=m+Sn[d-7]+w+Sn[d-16]|0}let{A:n,B:s,C:i,D:o,E:a,F:c,G:l,H:h}=this;for(let d=0;d<64;d++){const f=xt(a,6)^xt(a,11)^xt(a,25),g=h+f+Yp(a,c,l)+eg[d]+Sn[d]|0,m=(xt(n,2)^xt(n,13)^xt(n,22))+Xp(n,s,i)|0;h=l,l=c,c=a,a=o+g|0,o=i,i=s,s=n,n=g+m|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,s,i,o,a,c,l,h)}roundClean(){Sn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const hd=Ol(()=>new tg),Ko=BigInt(2**32-1),el=BigInt(32);function dd(r,e=!1){return e?{h:Number(r&Ko),l:Number(r>>el&Ko)}:{h:Number(r>>el&Ko)|0,l:Number(r&Ko)|0}}function fd(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){const{h:i,l:o}=dd(r[s],e);[t[s],n[s]]=[i,o]}return[t,n]}const ng=(r,e)=>BigInt(r>>>0)<<el|BigInt(e>>>0),rg=(r,e,t)=>r>>>t,sg=(r,e,t)=>r<<32-t|e>>>t,ig=(r,e,t)=>r>>>t|e<<32-t,og=(r,e,t)=>r<<32-t|e>>>t,ag=(r,e,t)=>r<<64-t|e>>>t-32,cg=(r,e,t)=>r>>>t-32|e<<64-t,lg=(r,e)=>e,ug=(r,e)=>r,pd=(r,e,t)=>r<<t|e>>>32-t,gd=(r,e,t)=>e<<t|r>>>32-t,md=(r,e,t)=>e<<t-32|r>>>64-t,yd=(r,e,t)=>r<<t-32|e>>>64-t;function hg(r,e,t,n){const s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}const dg=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),fg=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,pg=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),gg=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,mg=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),yg=(r,e,t,n,s,i)=>e+t+n+s+i+(r/2**32|0)|0,G={fromBig:dd,split:fd,toBig:ng,shrSH:rg,shrSL:sg,rotrSH:ig,rotrSL:og,rotrBH:ag,rotrBL:cg,rotr32H:lg,rotr32L:ug,rotlSH:pd,rotlSL:gd,rotlBH:md,rotlBL:yd,add:hg,add3L:dg,add3H:fg,add4L:pg,add4H:gg,add5H:yg,add5L:mg},[wg,bg]=G.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),kn=new Uint32Array(80),xn=new Uint32Array(80);class Ag extends ud{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:s,Ch:i,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:d,Fl:f,Gh:g,Gl:w,Hh:m,Hl:C}=this;return[e,t,n,s,i,o,a,c,l,h,d,f,g,w,m,C]}set(e,t,n,s,i,o,a,c,l,h,d,f,g,w,m,C){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=d|0,this.Fl=f|0,this.Gh=g|0,this.Gl=w|0,this.Hh=m|0,this.Hl=C|0}process(e,t){for(let S=0;S<16;S++,t+=4)kn[S]=e.getUint32(t),xn[S]=e.getUint32(t+=4);for(let S=16;S<80;S++){const B=kn[S-15]|0,P=xn[S-15]|0,R=G.rotrSH(B,P,1)^G.rotrSH(B,P,8)^G.shrSH(B,P,7),M=G.rotrSL(B,P,1)^G.rotrSL(B,P,8)^G.shrSL(B,P,7),D=kn[S-2]|0,q=xn[S-2]|0,Q=G.rotrSH(D,q,19)^G.rotrBH(D,q,61)^G.shrSH(D,q,6),z=G.rotrSL(D,q,19)^G.rotrBL(D,q,61)^G.shrSL(D,q,6),de=G.add4L(M,z,xn[S-7],xn[S-16]),we=G.add4H(de,R,Q,kn[S-7],kn[S-16]);kn[S]=we|0,xn[S]=de|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:d,El:f,Fh:g,Fl:w,Gh:m,Gl:C,Hh:v,Hl:k}=this;for(let S=0;S<80;S++){const B=G.rotrSH(d,f,14)^G.rotrSH(d,f,18)^G.rotrBH(d,f,41),P=G.rotrSL(d,f,14)^G.rotrSL(d,f,18)^G.rotrBL(d,f,41),R=d&g^~d&m,M=f&w^~f&C,D=G.add5L(k,P,M,bg[S],xn[S]),q=G.add5H(D,v,B,R,wg[S],kn[S]),Q=D|0,z=G.rotrSH(n,s,28)^G.rotrBH(n,s,34)^G.rotrBH(n,s,39),de=G.rotrSL(n,s,28)^G.rotrBL(n,s,34)^G.rotrBL(n,s,39),we=n&i^n&a^i&a,kt=s&o^s&c^o&c;v=m|0,k=C|0,m=g|0,C=w|0,g=d|0,w=f|0,{h:d,l:f}=G.add(l|0,h|0,q|0,Q|0),l=a|0,h=c|0,a=i|0,c=o|0,i=n|0,o=s|0;const x=G.add3L(Q,de,kt);n=G.add3H(x,q,z,we),s=x|0}({h:n,l:s}=G.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=G.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=G.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=G.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:d,l:f}=G.add(this.Eh|0,this.El|0,d|0,f|0),{h:g,l:w}=G.add(this.Fh|0,this.Fl|0,g|0,w|0),{h:m,l:C}=G.add(this.Gh|0,this.Gl|0,m|0,C|0),{h:v,l:k}=G.add(this.Hh|0,this.Hl|0,v|0,k|0),this.set(n,s,i,o,a,c,l,h,d,f,g,w,m,C,v,k)}roundClean(){kn.fill(0),xn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Eg=Ol(()=>new Ag);function Cg(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof b.global<"u")return b.global;throw new Error("unable to locate global object")}const Eu=Cg();Eu.crypto||Eu.msCrypto;function vg(r){switch(r){case"sha256":return hd.create();case"sha512":return Eg.create()}y(!1,"invalid hashing algorithm name","algorithm",r)}const[wd,bd,Ad]=[[],[],[]],Ig=BigInt(0),Li=BigInt(1),Ng=BigInt(2),Sg=BigInt(7),kg=BigInt(256),xg=BigInt(113);for(let r=0,e=Li,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],wd.push(2*(5*n+t)),bd.push((r+1)*(r+2)/2%64);let s=Ig;for(let i=0;i<7;i++)e=(e<<Li^(e>>Sg)*xg)%kg,e&Ng&&(s^=Li<<(Li<<BigInt(i))-Li);Ad.push(s)}const[Pg,Rg]=fd(Ad,!0),Cu=(r,e,t)=>t>32?md(r,e,t):pd(r,e,t),vu=(r,e,t)=>t>32?yd(r,e,t):gd(r,e,t);function Og(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Cu(l,h,1)^t[a],f=vu(l,h,1)^t[a+1];for(let g=0;g<50;g+=10)r[o+g]^=d,r[o+g+1]^=f}let s=r[2],i=r[3];for(let o=0;o<24;o++){const a=bd[o],c=Cu(s,i,a),l=vu(s,i,a),h=wd[o];s=r[h],i=r[h+1],r[h]=c,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=Pg[n],r[1]^=Rg[n]}t.fill(0)}class Tl extends Rl{constructor(e,t,n,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ga(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Qp(this.state)}keccak(){Og(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Ai(this);const{blockLen:t,state:n}=this;e=Ha(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,t&128&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ai(this,!1),Pl(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,i=e.length;s<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ga(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(od(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Tl(t,n,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Tg=(r,e,t)=>Ol(()=>new Tl(e,r,t)),Bg=Tg(1,136,256/8);let Ed=!1;const Cd=function(r){return Bg(r)};let vd=Cd;function ue(r){const e=V(r,"data");return T(vd(e))}ue._=Cd;ue.lock=function(){Ed=!0};ue.register=function(r){if(Ed)throw new TypeError("keccak256 is locked");vd=r};Object.freeze(ue);const Id=function(r){return vg("sha256").update(r).digest()};let Nd=Id,Sd=!1;function Pi(r){const e=V(r,"data");return T(Nd(e))}Pi._=Id;Pi.lock=function(){Sd=!0};Pi.register=function(r){if(Sd)throw new Error("sha256 is locked");Nd=r};Object.freeze(Pi);Object.freeze(Pi);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kd=BigInt(0),Ga=BigInt(1),_g=BigInt(2),Ka=r=>r instanceof Uint8Array,Lg=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ei(r){if(!Ka(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Lg[r[t]];return e}function xd(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function Bl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Ci(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const s=n*2,i=r.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[n]=o}return t}function Hr(r){return Bl(Ei(r))}function _l(r){if(!Ka(r))throw new Error("Uint8Array expected");return Bl(Ei(Uint8Array.from(r).reverse()))}function vi(r,e){return Ci(r.toString(16).padStart(e*2,"0"))}function Ll(r,e){return vi(r,e).reverse()}function Ug(r){return Ci(xd(r))}function pt(r,e,t){let n;if(typeof e=="string")try{n=Ci(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Ka(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);const s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function Qi(...r){const e=new Uint8Array(r.reduce((n,s)=>n+s.length,0));let t=0;return r.forEach(n=>{if(!Ka(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function Mg(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function Dg(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Fg(r){let e;for(e=0;r>kd;r>>=Ga,e+=1);return e}function Hg(r,e){return r>>BigInt(e)&Ga}const Gg=(r,e,t)=>r|(t?Ga:kd)<<BigInt(e),Ul=r=>(_g<<BigInt(r-1))-Ga,Ic=r=>new Uint8Array(r),Iu=r=>Uint8Array.from(r);function Pd(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Ic(r),s=Ic(r),i=0;const o=()=>{n.fill(1),s.fill(0),i=0},a=(...d)=>t(s,n,...d),c=(d=Ic())=>{s=a(Iu([0]),d),n=a(),d.length!==0&&(s=a(Iu([1]),d),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const f=[];for(;d<e;){n=a();const g=n.slice();f.push(g),d+=n.length}return Qi(...f)};return(d,f)=>{o(),c(d);let g;for(;!(g=f(l()));)c();return o(),g}}const Kg={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Po(r,e,t={}){const n=(s,i,o)=>{const a=Kg[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=r[s];if(!(o&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${i}`)};for(const[s,i]of Object.entries(e))n(s,i,!1);for(const[s,i]of Object.entries(t))n(s,i,!0);return r}const jg=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Hg,bitLen:Fg,bitMask:Ul,bitSet:Gg,bytesToHex:Ei,bytesToNumberBE:Hr,bytesToNumberLE:_l,concatBytes:Qi,createHmacDrbg:Pd,ensureBytes:pt,equalBytes:Mg,hexToBytes:Ci,hexToNumber:Bl,numberToBytesBE:vi,numberToBytesLE:Ll,numberToHexUnpadded:xd,numberToVarBytesBE:Ug,utf8ToBytes:Dg,validateObject:Po},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ye=BigInt(0),ae=BigInt(1),or=BigInt(2),Wg=BigInt(3),tl=BigInt(4),Nu=BigInt(5),Su=BigInt(8);BigInt(9);BigInt(16);function Ge(r,e){const t=r%e;return t>=ye?t:e+t}function Vg(r,e,t){if(t<=ye||e<ye)throw new Error("Expected power/modulo > 0");if(t===ae)return ye;let n=ae;for(;e>ye;)e&ae&&(n=n*r%t),r=r*r%t,e>>=ae;return n}function Xe(r,e,t){let n=r;for(;e-- >ye;)n*=n,n%=t;return n}function nl(r,e){if(r===ye||e<=ye)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Ge(r,e),n=e,s=ye,i=ae;for(;t!==ye;){const a=n/t,c=n%t,l=s-i*a;n=t,t=c,s=i,i=l}if(n!==ae)throw new Error("invert: does not exist");return Ge(s,e)}function Qg(r){const e=(r-ae)/or;let t,n,s;for(t=r-ae,n=0;t%or===ye;t/=or,n++);for(s=or;s<r&&Vg(s,e,r)!==r-ae;s++);if(n===1){const o=(r+ae)/tl;return function(c,l){const h=c.pow(l,o);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}const i=(t+ae)/or;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,s),t),d=a.pow(c,i),f=a.pow(c,t);for(;!a.eql(f,a.ONE);){if(a.eql(f,a.ZERO))return a.ZERO;let g=1;for(let m=a.sqr(f);g<l&&!a.eql(m,a.ONE);g++)m=a.sqr(m);const w=a.pow(h,ae<<BigInt(l-g-1));h=a.sqr(w),d=a.mul(d,w),f=a.mul(f,h),l=g}return d}}function zg(r){if(r%tl===Wg){const e=(r+ae)/tl;return function(n,s){const i=n.pow(s,e);if(!n.eql(n.sqr(i),s))throw new Error("Cannot find square root");return i}}if(r%Su===Nu){const e=(r-Nu)/Su;return function(n,s){const i=n.mul(s,or),o=n.pow(i,e),a=n.mul(s,o),c=n.mul(n.mul(a,or),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return Qg(r)}const Jg=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qg(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Jg.reduce((n,s)=>(n[s]="function",n),e);return Po(r,t)}function Zg(r,e,t){if(t<ye)throw new Error("Expected power > 0");if(t===ye)return r.ONE;if(t===ae)return e;let n=r.ONE,s=e;for(;t>ye;)t&ae&&(n=r.mul(n,s)),s=r.sqr(s),t>>=ae;return n}function $g(r,e){const t=new Array(e.length),n=e.reduce((i,o,a)=>r.is0(o)?i:(t[a]=i,r.mul(i,o)),r.ONE),s=r.inv(n);return e.reduceRight((i,o,a)=>r.is0(o)?i:(t[a]=r.mul(i,t[a]),r.mul(i,o)),s),t}function Rd(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Yg(r,e,t=!1,n={}){if(r<=ye)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:s,nByteLength:i}=Rd(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=zg(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:i,MASK:Ul(s),ZERO:ye,ONE:ae,create:c=>Ge(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ye<=c&&c<r},is0:c=>c===ye,isOdd:c=>(c&ae)===ae,neg:c=>Ge(-c,r),eql:(c,l)=>c===l,sqr:c=>Ge(c*c,r),add:(c,l)=>Ge(c+l,r),sub:(c,l)=>Ge(c-l,r),mul:(c,l)=>Ge(c*l,r),pow:(c,l)=>Zg(a,c,l),div:(c,l)=>Ge(c*nl(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>nl(c,r),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>$g(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>t?Ll(c,i):vi(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?_l(c):Hr(c)}});return Object.freeze(a)}function Od(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function Td(r){const e=Od(r);return e+Math.ceil(e/2)}function Xg(r,e,t=!1){const n=r.length,s=Od(e),i=Td(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);const o=t?Hr(r):_l(r),a=Ge(o,e-ae)+ae;return t?Ll(a,s):vi(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const e0=BigInt(0),Nc=BigInt(1);function t0(r,e){const t=(s,i)=>{const o=i.negate();return s?o:i},n=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=r.ZERO,a=s;for(;i>e0;)i&Nc&&(o=o.add(a)),a=a.double(),i>>=Nc;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=n(i),c=[];let l=s,h=l;for(let d=0;d<o;d++){h=l,c.push(h);for(let f=1;f<a;f++)h=h.add(l),c.push(h);l=h.double()}return c},wNAF(s,i,o){const{windows:a,windowSize:c}=n(s);let l=r.ZERO,h=r.BASE;const d=BigInt(2**s-1),f=2**s,g=BigInt(s);for(let w=0;w<a;w++){const m=w*c;let C=Number(o&d);o>>=g,C>c&&(C-=f,o+=Nc);const v=m,k=m+Math.abs(C)-1,S=w%2!==0,B=C<0;C===0?h=h.add(t(S,i[v])):l=l.add(t(B,i[k]))}return{p:l,f:h}},wNAFCached(s,i,o,a){const c=s._WINDOW_SIZE||1;let l=i.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&i.set(s,a(l))),this.wNAF(c,l,o)}}}function Bd(r){return qg(r.Fp),Po(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Rd(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function n0(r){const e=Bd(r);Po(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:r0,hexToBytes:s0}=jg,dr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=dr;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");const t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:r0(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=dr,t=typeof r=="string"?s0(r):r;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=dr._parseInt(t.subarray(2)),{d:o,l:a}=dr._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(r){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,t=l=>{const h=l.toString(16);return h.length&1?`0${h}`:h},n=e(t(r.s)),s=e(t(r.r)),i=n.length/2,o=s.length/2,a=t(i),c=t(o);return`30${t(o+i+4)}02${c}${s}02${a}${n}`}},mn=BigInt(0),at=BigInt(1);BigInt(2);const ku=BigInt(3);BigInt(4);function i0(r){const e=n0(r),{Fp:t}=e,n=e.toBytes||((w,m,C)=>{const v=m.toAffine();return Qi(Uint8Array.from([4]),t.toBytes(v.x),t.toBytes(v.y))}),s=e.fromBytes||(w=>{const m=w.subarray(1),C=t.fromBytes(m.subarray(0,t.BYTES)),v=t.fromBytes(m.subarray(t.BYTES,2*t.BYTES));return{x:C,y:v}});function i(w){const{a:m,b:C}=e,v=t.sqr(w),k=t.mul(v,w);return t.add(t.add(k,t.mul(w,m)),C)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(w){return typeof w=="bigint"&&mn<w&&w<e.n}function a(w){if(!o(w))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(w){const{allowedPrivateKeyLengths:m,nByteLength:C,wrapPrivateKey:v,n:k}=e;if(m&&typeof w!="bigint"){if(w instanceof Uint8Array&&(w=Ei(w)),typeof w!="string"||!m.includes(w.length))throw new Error("Invalid key");w=w.padStart(C*2,"0")}let S;try{S=typeof w=="bigint"?w:Hr(pt("private key",w,C))}catch{throw new Error(`private key must be ${C} bytes, hex or bigint, not ${typeof w}`)}return v&&(S=Ge(S,k)),a(S),S}const l=new Map;function h(w){if(!(w instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(m,C,v){if(this.px=m,this.py=C,this.pz=v,m==null||!t.isValid(m))throw new Error("x required");if(C==null||!t.isValid(C))throw new Error("y required");if(v==null||!t.isValid(v))throw new Error("z required")}static fromAffine(m){const{x:C,y:v}=m||{};if(!m||!t.isValid(C)||!t.isValid(v))throw new Error("invalid affine point");if(m instanceof d)throw new Error("projective point not allowed");const k=S=>t.eql(S,t.ZERO);return k(C)&&k(v)?d.ZERO:new d(C,v,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const C=t.invertBatch(m.map(v=>v.pz));return m.map((v,k)=>v.toAffine(C[k])).map(d.fromAffine)}static fromHex(m){const C=d.fromAffine(s(pt("pointHex",m)));return C.assertValidity(),C}static fromPrivateKey(m){return d.BASE.multiply(c(m))}_setWindowSize(m){this._WINDOW_SIZE=m,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:m,y:C}=this.toAffine();if(!t.isValid(m)||!t.isValid(C))throw new Error("bad point: x or y not FE");const v=t.sqr(C),k=i(m);if(!t.eql(v,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:m}=this.toAffine();if(t.isOdd)return!t.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){h(m);const{px:C,py:v,pz:k}=this,{px:S,py:B,pz:P}=m,R=t.eql(t.mul(C,P),t.mul(S,k)),M=t.eql(t.mul(v,P),t.mul(B,k));return R&&M}negate(){return new d(this.px,t.neg(this.py),this.pz)}double(){const{a:m,b:C}=e,v=t.mul(C,ku),{px:k,py:S,pz:B}=this;let P=t.ZERO,R=t.ZERO,M=t.ZERO,D=t.mul(k,k),q=t.mul(S,S),Q=t.mul(B,B),z=t.mul(k,S);return z=t.add(z,z),M=t.mul(k,B),M=t.add(M,M),P=t.mul(m,M),R=t.mul(v,Q),R=t.add(P,R),P=t.sub(q,R),R=t.add(q,R),R=t.mul(P,R),P=t.mul(z,P),M=t.mul(v,M),Q=t.mul(m,Q),z=t.sub(D,Q),z=t.mul(m,z),z=t.add(z,M),M=t.add(D,D),D=t.add(M,D),D=t.add(D,Q),D=t.mul(D,z),R=t.add(R,D),Q=t.mul(S,B),Q=t.add(Q,Q),D=t.mul(Q,z),P=t.sub(P,D),M=t.mul(Q,q),M=t.add(M,M),M=t.add(M,M),new d(P,R,M)}add(m){h(m);const{px:C,py:v,pz:k}=this,{px:S,py:B,pz:P}=m;let R=t.ZERO,M=t.ZERO,D=t.ZERO;const q=e.a,Q=t.mul(e.b,ku);let z=t.mul(C,S),de=t.mul(v,B),we=t.mul(k,P),kt=t.add(C,v),x=t.add(S,B);kt=t.mul(kt,x),x=t.add(z,de),kt=t.sub(kt,x),x=t.add(C,k);let L=t.add(S,P);return x=t.mul(x,L),L=t.add(z,we),x=t.sub(x,L),L=t.add(v,k),R=t.add(B,P),L=t.mul(L,R),R=t.add(de,we),L=t.sub(L,R),D=t.mul(q,x),R=t.mul(Q,we),D=t.add(R,D),R=t.sub(de,D),D=t.add(de,D),M=t.mul(R,D),de=t.add(z,z),de=t.add(de,z),we=t.mul(q,we),x=t.mul(Q,x),de=t.add(de,we),we=t.sub(z,we),we=t.mul(q,we),x=t.add(x,we),z=t.mul(de,x),M=t.add(M,z),z=t.mul(L,x),R=t.mul(kt,R),R=t.sub(R,z),z=t.mul(kt,de),D=t.mul(L,D),D=t.add(D,z),new d(R,M,D)}subtract(m){return this.add(m.negate())}is0(){return this.equals(d.ZERO)}wNAF(m){return g.wNAFCached(this,l,m,C=>{const v=t.invertBatch(C.map(k=>k.pz));return C.map((k,S)=>k.toAffine(v[S])).map(d.fromAffine)})}multiplyUnsafe(m){const C=d.ZERO;if(m===mn)return C;if(a(m),m===at)return this;const{endo:v}=e;if(!v)return g.unsafeLadder(this,m);let{k1neg:k,k1:S,k2neg:B,k2:P}=v.splitScalar(m),R=C,M=C,D=this;for(;S>mn||P>mn;)S&at&&(R=R.add(D)),P&at&&(M=M.add(D)),D=D.double(),S>>=at,P>>=at;return k&&(R=R.negate()),B&&(M=M.negate()),M=new d(t.mul(M.px,v.beta),M.py,M.pz),R.add(M)}multiply(m){a(m);let C=m,v,k;const{endo:S}=e;if(S){const{k1neg:B,k1:P,k2neg:R,k2:M}=S.splitScalar(C);let{p:D,f:q}=this.wNAF(P),{p:Q,f:z}=this.wNAF(M);D=g.constTimeNegate(B,D),Q=g.constTimeNegate(R,Q),Q=new d(t.mul(Q.px,S.beta),Q.py,Q.pz),v=D.add(Q),k=q.add(z)}else{const{p:B,f:P}=this.wNAF(C);v=B,k=P}return d.normalizeZ([v,k])[0]}multiplyAndAddUnsafe(m,C,v){const k=d.BASE,S=(P,R)=>R===mn||R===at||!P.equals(k)?P.multiplyUnsafe(R):P.multiply(R),B=S(this,C).add(S(m,v));return B.is0()?void 0:B}toAffine(m){const{px:C,py:v,pz:k}=this,S=this.is0();m==null&&(m=S?t.ONE:t.inv(k));const B=t.mul(C,m),P=t.mul(v,m),R=t.mul(k,m);if(S)return{x:t.ZERO,y:t.ZERO};if(!t.eql(R,t.ONE))throw new Error("invZ was invalid");return{x:B,y:P}}isTorsionFree(){const{h:m,isTorsionFree:C}=e;if(m===at)return!0;if(C)return C(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:C}=e;return m===at?this:C?C(d,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return this.assertValidity(),n(d,this,m)}toHex(m=!0){return Ei(this.toRawBytes(m))}}d.BASE=new d(e.Gx,e.Gy,t.ONE),d.ZERO=new d(t.ZERO,t.ONE,t.ZERO);const f=e.nBitLength,g=t0(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:o}}function o0(r){const e=Bd(r);return Po(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function a0(r){const e=o0(r),{Fp:t,n}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(x){return mn<x&&x<t.ORDER}function a(x){return Ge(x,n)}function c(x){return nl(x,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:d,isWithinCurveOrder:f}=i0({...e,toBytes(x,L,K){const ee=L.toAffine(),Y=t.toBytes(ee.x),fe=Qi;return K?fe(Uint8Array.from([L.hasEvenY()?2:3]),Y):fe(Uint8Array.from([4]),Y,t.toBytes(ee.y))},fromBytes(x){const L=x.length,K=x[0],ee=x.subarray(1);if(L===s&&(K===2||K===3)){const Y=Hr(ee);if(!o(Y))throw new Error("Point is not on curve");const fe=d(Y);let We=t.sqrt(fe);const Ve=(We&at)===at;return(K&1)===1!==Ve&&(We=t.neg(We)),{x:Y,y:We}}else if(L===i&&K===4){const Y=t.fromBytes(ee.subarray(0,t.BYTES)),fe=t.fromBytes(ee.subarray(t.BYTES,2*t.BYTES));return{x:Y,y:fe}}else throw new Error(`Point of length ${L} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),g=x=>Ei(vi(x,e.nByteLength));function w(x){const L=n>>at;return x>L}function m(x){return w(x)?a(-x):x}const C=(x,L,K)=>Hr(x.slice(L,K));class v{constructor(L,K,ee){this.r=L,this.s=K,this.recovery=ee,this.assertValidity()}static fromCompact(L){const K=e.nByteLength;return L=pt("compactSignature",L,K*2),new v(C(L,0,K),C(L,K,2*K))}static fromDER(L){const{r:K,s:ee}=dr.toSig(pt("DER",L));return new v(K,ee)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(L){return new v(this.r,this.s,L)}recoverPublicKey(L){const{r:K,s:ee,recovery:Y}=this,fe=M(pt("msgHash",L));if(Y==null||![0,1,2,3].includes(Y))throw new Error("recovery id invalid");const We=Y===2||Y===3?K+e.n:K;if(We>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Ve=Y&1?"03":"02",Cn=l.fromHex(Ve+g(We)),vn=c(We),Yr=a(-fe*vn),Oi=a(ee*vn),In=l.BASE.multiplyAndAddUnsafe(Cn,Yr,Oi);if(!In)throw new Error("point at infinify");return In.assertValidity(),In}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Ci(this.toDERHex())}toDERHex(){return dr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ci(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const k={isValidPrivateKey(x){try{return h(x),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const x=Td(e.n);return Xg(e.randomBytes(x),e.n)},precompute(x=8,L=l.BASE){return L._setWindowSize(x),L.multiply(BigInt(3)),L}};function S(x,L=!0){return l.fromPrivateKey(x).toRawBytes(L)}function B(x){const L=x instanceof Uint8Array,K=typeof x=="string",ee=(L||K)&&x.length;return L?ee===s||ee===i:K?ee===2*s||ee===2*i:x instanceof l}function P(x,L,K=!0){if(B(x))throw new Error("first arg must be private key");if(!B(L))throw new Error("second arg must be public key");return l.fromHex(L).multiply(h(x)).toRawBytes(K)}const R=e.bits2int||function(x){const L=Hr(x),K=x.length*8-e.nBitLength;return K>0?L>>BigInt(K):L},M=e.bits2int_modN||function(x){return a(R(x))},D=Ul(e.nBitLength);function q(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(mn<=x&&x<D))throw new Error(`bigint expected < 2^${e.nBitLength}`);return vi(x,e.nByteLength)}function Q(x,L,K=z){if(["recovered","canonical"].some(tr=>tr in K))throw new Error("sign() legacy options not supported");const{hash:ee,randomBytes:Y}=e;let{lowS:fe,prehash:We,extraEntropy:Ve}=K;fe==null&&(fe=!0),x=pt("msgHash",x),We&&(x=pt("prehashed msgHash",ee(x)));const Cn=M(x),vn=h(L),Yr=[q(vn),q(Cn)];if(Ve!=null){const tr=Ve===!0?Y(t.BYTES):Ve;Yr.push(pt("extraEntropy",tr))}const Oi=Qi(...Yr),In=Cn;function yc(tr){const Xr=R(tr);if(!f(Xr))return;const ou=c(Xr),es=l.BASE.multiply(Xr).toAffine(),ut=a(es.x);if(ut===mn)return;const ts=a(ou*a(In+ut*vn));if(ts===mn)return;let au=(es.x===ut?0:2)|Number(es.y&at),cu=ts;return fe&&w(ts)&&(cu=m(ts),au^=1),new v(ut,cu,au)}return{seed:Oi,k2sig:yc}}const z={lowS:e.lowS,prehash:!1},de={lowS:e.lowS,prehash:!1};function we(x,L,K=z){const{seed:ee,k2sig:Y}=Q(x,L,K),fe=e;return Pd(fe.hash.outputLen,fe.nByteLength,fe.hmac)(ee,Y)}l.BASE._setWindowSize(8);function kt(x,L,K,ee=de){var es;const Y=x;if(L=pt("msgHash",L),K=pt("publicKey",K),"strict"in ee)throw new Error("options.strict was renamed to lowS");const{lowS:fe,prehash:We}=ee;let Ve,Cn;try{if(typeof Y=="string"||Y instanceof Uint8Array)try{Ve=v.fromDER(Y)}catch(ut){if(!(ut instanceof dr.Err))throw ut;Ve=v.fromCompact(Y)}else if(typeof Y=="object"&&typeof Y.r=="bigint"&&typeof Y.s=="bigint"){const{r:ut,s:ts}=Y;Ve=new v(ut,ts)}else throw new Error("PARSE");Cn=l.fromHex(K)}catch(ut){if(ut.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(fe&&Ve.hasHighS())return!1;We&&(L=e.hash(L));const{r:vn,s:Yr}=Ve,Oi=M(L),In=c(Yr),yc=a(Oi*In),tr=a(vn*In),Xr=(es=l.BASE.multiplyAndAddUnsafe(Cn,yc,tr))==null?void 0:es.toAffine();return Xr?a(Xr.x)===vn:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:P,sign:we,verify:kt,ProjectivePoint:l,Signature:v,utils:k}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function c0(r){return{hash:r,hmac:(e,...t)=>ld(r,e,qp(...t)),randomBytes:Zp}}function l0(r,e){const t=n=>a0({...r,...c0(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _d=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),u0=BigInt(1),rl=BigInt(2),Pu=(r,e)=>(r+e/rl)/e;function h0(r){const e=_d,t=BigInt(3),n=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%e,h=l*l*r%e,d=Xe(h,t,e)*h%e,f=Xe(d,t,e)*h%e,g=Xe(f,rl,e)*l%e,w=Xe(g,s,e)*g%e,m=Xe(w,i,e)*w%e,C=Xe(m,a,e)*m%e,v=Xe(C,c,e)*C%e,k=Xe(v,a,e)*m%e,S=Xe(k,t,e)*h%e,B=Xe(S,o,e)*w%e,P=Xe(B,n,e)*l%e,R=Xe(P,rl,e);if(!sl.eql(sl.sqr(R),r))throw new Error("Cannot find square root");return R}const sl=Yg(_d,void 0,void 0,{sqrt:h0}),Rn=l0({a:BigInt(0),b:BigInt(7),Fp:sl,n:xu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=xu,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-u0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=Pu(i*r,e),c=Pu(-n*r,e);let l=Ge(r-a*t-c*s,e),h=Ge(-a*n-c*i,e);const d=l>o,f=h>o;if(d&&(l=e-l),f&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:d,k1:l,k2neg:f,k2:h}}}},hd);BigInt(0);Rn.ProjectivePoint;const zi="0x0000000000000000000000000000000000000000",Ru="0x0000000000000000000000000000000000000000000000000000000000000000",Ou=BigInt(0),Tu=BigInt(1),Bu=BigInt(2),_u=BigInt(27),Lu=BigInt(28),jo=BigInt(35),rs={};function Uu(r){return Kr(Le(r),32)}var Ms,Ds,Fs,Ir;const ft=class ft{constructor(e,t,n,s){A(this,Ms,void 0);A(this,Ds,void 0);A(this,Fs,void 0);A(this,Ir,void 0);xo(e,rs,"Signature"),p(this,Ms,t),p(this,Ds,n),p(this,Fs,s),p(this,Ir,null)}get r(){return u(this,Ms)}set r(e){y(Cs(e)===32,"invalid r","value",e),p(this,Ms,T(e))}get s(){return u(this,Ds)}set s(e){y(Cs(e)===32,"invalid s","value",e);const t=T(e);y(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),p(this,Ds,t)}get v(){return u(this,Fs)}set v(e){const t=H(e,"value");y(t===27||t===28,"invalid v","v",e),p(this,Fs,t)}get networkV(){return u(this,Ir)}get legacyChainId(){const e=this.networkV;return e==null?null:ft.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=V(this.s);return this.yParity&&(e[0]|=128),T(e)}get compactSerialized(){return le([this.r,this.yParityAndS])}get serialized(){return le([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new ft(rs,this.r,this.s,this.v);return this.networkV&&p(e,Ir,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=_(e,"v");return t==_u||t==Lu?Ou:(y(t>=jo,"invalid EIP-155 v","v",e),(t-jo)/Bu)}static getChainIdV(e,t){return _(e)*Bu+BigInt(35+t-27)}static getNormalizedV(e){const t=_(e);return t===Ou||t===_u?27:t===Tu||t===Lu?28:(y(t>=jo,"invalid v","v",e),t&Tu?27:28)}static from(e){function t(l,h){y(l,h,"signature",e)}if(e==null)return new ft(rs,Ru,Ru,27);if(typeof e=="string"){const l=V(e,"signature");if(l.length===64){const h=T(l.slice(0,32)),d=l.slice(32,64),f=d[0]&128?28:27;return d[0]&=127,new ft(rs,h,T(d),f)}if(l.length===65){const h=T(l.slice(0,32)),d=l.slice(32,64);t((d[0]&128)===0,"non-canonical s");const f=ft.getNormalizedV(l[64]);return new ft(rs,h,T(d),f)}t(!1,"invalid raw signature length")}if(e instanceof ft)return e.clone();const n=e.r;t(n!=null,"missing r");const s=Uu(n),i=function(l,h){if(l!=null)return Uu(l);if(h!=null){t(X(h,32),"invalid yParityAndS");const d=V(h);return d[0]&=127,T(d)}t(!1,"missing s")}(e.s,e.yParityAndS);t((V(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(l,h,d){if(l!=null){const f=_(l);return{networkV:f>=jo?f:void 0,v:ft.getNormalizedV(f)}}if(h!=null)return t(X(h,32),"invalid yParityAndS"),{v:V(h)[0]&128?28:27};if(d!=null){switch(H(d,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),c=new ft(rs,s,i,a);return o&&p(c,Ir,o),t(e.yParity==null||H(e.yParity,"sig.yParity")===c.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===c.yParityAndS,"yParityAndS mismatch"),c}};Ms=new WeakMap,Ds=new WeakMap,Fs=new WeakMap,Ir=new WeakMap;let It=ft;var an;const cr=class cr{constructor(e){A(this,an,void 0);y(Cs(e)===32,"invalid private key","privateKey","[REDACTED]"),p(this,an,T(e))}get privateKey(){return u(this,an)}get publicKey(){return cr.computePublicKey(u(this,an))}get compressedPublicKey(){return cr.computePublicKey(u(this,an),!0)}sign(e){y(Cs(e)===32,"invalid digest length","digest",e);const t=Rn.sign(_e(e),_e(u(this,an)),{lowS:!0});return It.from({r:Xn(t.r,32),s:Xn(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=cr.computePublicKey(e);return T(Rn.getSharedSecret(_e(u(this,an)),V(t),!1))}static computePublicKey(e,t){let n=V(e,"key");if(n.length===32){const i=Rn.getPublicKey(n,!!t);return T(i)}if(n.length===64){const i=new Uint8Array(65);i[0]=4,i.set(n,1),n=i}const s=Rn.ProjectivePoint.fromHex(n);return T(s.toRawBytes(t))}static recoverPublicKey(e,t){y(Cs(e)===32,"invalid digest length","digest",e);const n=It.from(t);let s=Rn.Signature.fromCompact(_e(le([n.r,n.s])));s=s.addRecoveryBit(n.yParity);const i=s.recoverPublicKey(_e(e));return y(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,n){const s=Rn.ProjectivePoint.fromHex(cr.computePublicKey(e).substring(2)),i=Rn.ProjectivePoint.fromHex(cr.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!n)}};an=new WeakMap;let Ji=cr;const d0=BigInt(0),f0=BigInt(36);function Mu(r){r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const n=V(ue(t));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(n[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const Ml={};for(let r=0;r<10;r++)Ml[String(r)]=String(r);for(let r=0;r<26;r++)Ml[String.fromCharCode(65+r)]=String(10+r);const Du=15;function p0(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(n=>Ml[n]).join("");for(;e.length>=Du;){let n=e.substring(0,Du);e=parseInt(n,10)%97+e.substring(n.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const g0=function(){const r={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];r[t]=BigInt(e)}return r}();function m0(r){r=r.toLowerCase();let e=d0;for(let t=0;t<r.length;t++)e=e*f0+g0[r[t]];return e}function $(r){if(y(typeof r=="string","invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/)){r.startsWith("0x")||(r="0x"+r);const e=Mu(r);return y(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===r,"bad address checksum","address",r),e}if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){y(r.substring(2,4)===p0(r),"bad icap checksum","address",r);let e=m0(r.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Mu("0x"+e)}y(!1,"invalid address","address",r)}function y0(r){const e=$(r.from);let n=_(r.nonce,"tx.nonce").toString(16);return n==="0"?n="0x":n.length%2?n="0x0"+n:n="0x"+n,$(se(ue(jr([e,n])),12))}function Ld(r){return r&&typeof r.getAddress=="function"}async function Sc(r,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(I(typeof r!="string","unconfigured name","UNCONFIGURED_NAME",{value:r}),y(!1,"invalid AddressLike value; did not resolve to a value address","target",r)),$(t)}function Me(r,e){if(typeof r=="string")return r.match(/^0x[0-9a-f]{40}$/i)?$(r):(I(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Sc(r,e.resolveName(r)));if(Ld(r))return Sc(r,r.getAddress());if(r&&typeof r.then=="function")return Sc(r,r);y(!1,"unsupported addressable value","target",r)}const $t={};function O(r,e){let t=!1;return e<0&&(t=!0,e*=-1),new xe($t,`${t?"":"u"}int${e}`,r,{signed:t,width:e})}function J(r,e){return new xe($t,`bytes${e||""}`,r,{size:e})}const Fu=Symbol.for("_ethers_typed");var Nr;const Yt=class Yt{constructor(e,t,n,s){E(this,"type");E(this,"value");A(this,Nr,void 0);E(this,"_typedSymbol");s==null&&(s=null),xo($t,e,"Typed"),F(this,{_typedSymbol:Fu,type:t,value:n}),p(this,Nr,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return u(this,Nr)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return u(this,Nr)===!0?-1:u(this,Nr)===!1?this.value.length:null}static from(e,t){return new Yt($t,e,t)}static uint8(e){return O(e,8)}static uint16(e){return O(e,16)}static uint24(e){return O(e,24)}static uint32(e){return O(e,32)}static uint40(e){return O(e,40)}static uint48(e){return O(e,48)}static uint56(e){return O(e,56)}static uint64(e){return O(e,64)}static uint72(e){return O(e,72)}static uint80(e){return O(e,80)}static uint88(e){return O(e,88)}static uint96(e){return O(e,96)}static uint104(e){return O(e,104)}static uint112(e){return O(e,112)}static uint120(e){return O(e,120)}static uint128(e){return O(e,128)}static uint136(e){return O(e,136)}static uint144(e){return O(e,144)}static uint152(e){return O(e,152)}static uint160(e){return O(e,160)}static uint168(e){return O(e,168)}static uint176(e){return O(e,176)}static uint184(e){return O(e,184)}static uint192(e){return O(e,192)}static uint200(e){return O(e,200)}static uint208(e){return O(e,208)}static uint216(e){return O(e,216)}static uint224(e){return O(e,224)}static uint232(e){return O(e,232)}static uint240(e){return O(e,240)}static uint248(e){return O(e,248)}static uint256(e){return O(e,256)}static uint(e){return O(e,256)}static int8(e){return O(e,-8)}static int16(e){return O(e,-16)}static int24(e){return O(e,-24)}static int32(e){return O(e,-32)}static int40(e){return O(e,-40)}static int48(e){return O(e,-48)}static int56(e){return O(e,-56)}static int64(e){return O(e,-64)}static int72(e){return O(e,-72)}static int80(e){return O(e,-80)}static int88(e){return O(e,-88)}static int96(e){return O(e,-96)}static int104(e){return O(e,-104)}static int112(e){return O(e,-112)}static int120(e){return O(e,-120)}static int128(e){return O(e,-128)}static int136(e){return O(e,-136)}static int144(e){return O(e,-144)}static int152(e){return O(e,-152)}static int160(e){return O(e,-160)}static int168(e){return O(e,-168)}static int176(e){return O(e,-176)}static int184(e){return O(e,-184)}static int192(e){return O(e,-192)}static int200(e){return O(e,-200)}static int208(e){return O(e,-208)}static int216(e){return O(e,-216)}static int224(e){return O(e,-224)}static int232(e){return O(e,-232)}static int240(e){return O(e,-240)}static int248(e){return O(e,-248)}static int256(e){return O(e,-256)}static int(e){return O(e,-256)}static bytes1(e){return J(e,1)}static bytes2(e){return J(e,2)}static bytes3(e){return J(e,3)}static bytes4(e){return J(e,4)}static bytes5(e){return J(e,5)}static bytes6(e){return J(e,6)}static bytes7(e){return J(e,7)}static bytes8(e){return J(e,8)}static bytes9(e){return J(e,9)}static bytes10(e){return J(e,10)}static bytes11(e){return J(e,11)}static bytes12(e){return J(e,12)}static bytes13(e){return J(e,13)}static bytes14(e){return J(e,14)}static bytes15(e){return J(e,15)}static bytes16(e){return J(e,16)}static bytes17(e){return J(e,17)}static bytes18(e){return J(e,18)}static bytes19(e){return J(e,19)}static bytes20(e){return J(e,20)}static bytes21(e){return J(e,21)}static bytes22(e){return J(e,22)}static bytes23(e){return J(e,23)}static bytes24(e){return J(e,24)}static bytes25(e){return J(e,25)}static bytes26(e){return J(e,26)}static bytes27(e){return J(e,27)}static bytes28(e){return J(e,28)}static bytes29(e){return J(e,29)}static bytes30(e){return J(e,30)}static bytes31(e){return J(e,31)}static bytes32(e){return J(e,32)}static address(e){return new Yt($t,"address",e)}static bool(e){return new Yt($t,"bool",!!e)}static bytes(e){return new Yt($t,"bytes",e)}static string(e){return new Yt($t,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Yt($t,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===Fu}static dereference(e,t){if(Yt.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};Nr=new WeakMap;let xe=Yt;class w0 extends En{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=xe.dereference(t,"string");try{n=$(n)}catch(s){return this._throwError(s.message,t)}return e.writeValue(n)}decode(e){return $(Xn(e.readValue(),20))}}class b0 extends En{constructor(t){super(t.name,t.type,"_",t.dynamic);E(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,n){return this.coder.encode(t,n)}decode(t){return this.coder.decode(t)}}function Ud(r,e,t){let n=[];if(Array.isArray(t))n=t;else if(t&&typeof t=="object"){let c={};n=e.map(l=>{const h=l.localName;return I(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),I(!c[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),c[h]=!0,t[h]})}else y(!1,"invalid tuple value","tuple",t);y(e.length===n.length,"types/value length mismatch","tuple",t);let s=new $c,i=new $c,o=[];e.forEach((c,l)=>{let h=n[l];if(c.dynamic){let d=i.length;c.encode(i,h);let f=s.writeUpdatableValue();o.push(g=>{f(g+d)})}else c.encode(s,h)}),o.forEach(c=>{c(s.length)});let a=r.appendWriter(s);return a+=r.appendWriter(i),a}function Md(r,e){let t=[],n=[],s=r.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=r.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(l){if(ke(l,"BUFFER_OVERRUN"))throw l;o=l,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(r)}catch(a){if(ke(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),n.push(i.localName||null)}),bi.fromItems(t,n)}class A0 extends En{constructor(t,n,s){const i=t.type+"["+(n>=0?n:"")+"]",o=n===-1||t.dynamic;super("array",i,s,o);E(this,"coder");E(this,"length");F(this,{coder:t,length:n})}defaultValue(){const t=this.coder.defaultValue(),n=[];for(let s=0;s<this.length;s++)n.push(t);return n}encode(t,n){const s=xe.dereference(n,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),Wh(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return Ud(t,o,s)}decode(t){let n=this.length;n===-1&&(n=t.readIndex(),I(n*Ue<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:n*Ue,length:t.dataLength}));let s=[];for(let i=0;i<n;i++)s.push(new b0(this.coder));return Md(t,s)}}class E0 extends En{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=xe.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class Dd extends En{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=_e(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class C0 extends Dd{constructor(e){super("bytes",e)}decode(e){return T(super.decode(e))}}class v0 extends En{constructor(t,n){let s="bytes"+String(t);super(s,s,n,!1);E(this,"size");F(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,n){let s=_e(xe.dereference(n,this.type));return s.length!==this.size&&this._throwError("incorrect data length",n),t.writeBytes(s)}decode(t){return T(t.readBytes(this.size))}}const I0=new Uint8Array([]);class N0 extends En{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(I0)}decode(e){return e.readBytes(0),null}}const S0=BigInt(0),k0=BigInt(1),x0=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class P0 extends En{constructor(t,n,s){const i=(n?"int":"uint")+t*8;super(i,i,s,!1);E(this,"size");E(this,"signed");F(this,{size:t,signed:n},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,n){let s=_(xe.dereference(n,this.type)),i=hr(x0,Ue*8);if(this.signed){let o=hr(i,this.size*8-1);(s>o||s<-(o+k0))&&this._throwError("value out-of-bounds",n),s=zh(s,8*Ue)}else(s<S0||s>hr(i,this.size*8))&&this._throwError("value out-of-bounds",n);return t.writeValue(s)}decode(t){let n=hr(t.readValue(),this.size*8);return this.signed&&(n=da(n,this.size*8)),n}}class R0 extends Dd{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,jt(xe.dereference(t,"string")))}decode(e){return fa(super.decode(e))}}class Wo extends En{constructor(t,n){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,n,s);E(this,"coders");F(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const n=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||n[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,n){const s=xe.dereference(n,"tuple");return Ud(t,this.coders,s)}decode(t){return Md(t,this.coders)}}function Wr(r){return ue(jt(r))}var O0="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJb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zkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const Hu=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Gu=4;function T0(r){let e=0;function t(){return r[e++]<<8|r[e++]}let n=t(),s=1,i=[0,1];for(let P=1;P<n;P++)i.push(s+=t());let o=t(),a=e;e+=o;let c=0,l=0;function h(){return c==0&&(l=l<<8|r[e++],c=8),l>>--c&1}const d=31,f=2**d,g=f>>>1,w=g>>1,m=f-1;let C=0;for(let P=0;P<d;P++)C=C<<1|h();let v=[],k=0,S=f;for(;;){let P=Math.floor(((C-k+1)*s-1)/S),R=0,M=n;for(;M-R>1;){let Q=R+M>>>1;P<i[Q]?M=Q:R=Q}if(R==0)break;v.push(R);let D=k+Math.floor(S*i[R]/s),q=k+Math.floor(S*i[R+1]/s)-1;for(;!((D^q)&g);)C=C<<1&m|h(),D=D<<1&m,q=q<<1&m|1;for(;D&~q&w;)C=C&g|C<<1&m>>>1|h(),D=D<<1^g,q=(q^g)<<1|g|1;k=D,S=1+q-D}let B=n-4;return v.map(P=>{switch(P-B){case 3:return B+65792+(r[a++]<<16|r[a++]<<8|r[a++]);case 2:return B+256+(r[a++]<<8|r[a++]);case 1:return B+r[a++];default:return P-1}})}function B0(r){let e=0;return()=>r[e++]}function Fd(r){return B0(T0(_0(r)))}function _0(r){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=r.length,n=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[r.charCodeAt(s)],o+=6,o>=8&&(n[i++]=a>>(o-=8));return n}function L0(r){return r&1?~r>>1:r>>1}function U0(r,e){let t=Array(r);for(let n=0,s=0;n<r;n++)t[n]=s+=L0(e());return t}function qi(r,e=0){let t=[];for(;;){let n=r(),s=r();if(!s)break;e+=n;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function Hd(r){return Zi(()=>{let e=qi(r);if(e.length)return e})}function Gd(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(M0(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(D0(t,r))}return e.flat()}function Zi(r){let e=[];for(;;){let t=r(e.length);if(!t)break;e.push(t)}return e}function Kd(r,e,t){let n=Array(r).fill().map(()=>[]);for(let s=0;s<e;s++)U0(r,t).forEach((i,o)=>n[o].push(i));return n}function M0(r,e){let t=1+e(),n=e(),s=Zi(e);return Kd(s.length,1+r,e).flatMap((o,a)=>{let[c,...l]=o;return Array(s[a]).fill().map((h,d)=>{let f=d*n;return[c+d*t,l.map(g=>g+f)]})})}function D0(r,e){let t=1+e();return Kd(t,1+r,e).map(s=>[s[0],s.slice(1)])}function F0(r){let e=[],t=qi(r);return s(n([]),[]),e;function n(i){let o=r(),a=Zi(()=>{let c=qi(r).map(l=>t[l]);if(c.length)return n(c)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,c){if(!(i&4&&c===a[a.length-1])){i&2&&(c=a[a.length-1]),i&1&&e.push(a);for(let l of o)for(let h of l.Q)s(l,[...a,h],c)}}}function H0(r){return r.toString(16).toUpperCase().padStart(2,"0")}function jd(r){return`{${H0(r)}}`}function G0(r){let e=[];for(let t=0,n=r.length;t<n;){let s=r.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function Ii(r){let t=r.length;if(t<4096)return String.fromCodePoint(...r);let n=[];for(let s=0;s<t;)n.push(String.fromCodePoint(...r.slice(s,s+=4096)));return n.join("")}function K0(r,e){let t=r.length,n=t-e.length;for(let s=0;n==0&&s<t;s++)n=r[s]-e[s];return n}var j0="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8Ff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V0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const $i=44032,ma=4352,ya=4449,wa=4519,Wd=19,Vd=21,Ni=28,ba=Vd*Ni,W0=Wd*ba,V0=$i+W0,Q0=ma+Wd,z0=ya+Vd,J0=wa+Ni;function Di(r){return r>>24&255}function Qd(r){return r&16777215}let il,Ku,ol,na;function q0(){let r=Fd(j0);il=new Map(Hd(r).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),Ku=new Set(qi(r)),ol=new Map,na=new Map;for(let[e,t]of Gd(r)){if(!Ku.has(e)&&t.length==2){let[n,s]=t,i=na.get(n);i||(i=new Map,na.set(n,i)),i.set(s,e)}ol.set(e,t.reverse())}}function zd(r){return r>=$i&&r<V0}function Z0(r,e){if(r>=ma&&r<Q0&&e>=ya&&e<z0)return $i+(r-ma)*ba+(e-ya)*Ni;if(zd(r)&&e>wa&&e<J0&&(r-$i)%Ni==0)return r+(e-wa);{let t=na.get(r);return t&&(t=t.get(e),t)?t:-1}}function Jd(r){il||q0();let e=[],t=[],n=!1;function s(i){let o=il.get(i);o&&(n=!0,i|=o),e.push(i)}for(let i of r)for(;;){if(i<128)e.push(i);else if(zd(i)){let o=i-$i,a=o/ba|0,c=o%ba/Ni|0,l=o%Ni;s(ma+a),s(ya+c),l>0&&s(wa+l)}else{let o=ol.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(n&&e.length>1){let i=Di(e[0]);for(let o=1;o<e.length;o++){let a=Di(e[o]);if(a==0||i<=a){i=a;continue}let c=o-1;for(;;){let l=e[c+1];if(e[c+1]=e[c],e[c]=l,!c||(i=Di(e[--c]),i<=a))break}i=Di(e[o])}}return e}function $0(r){let e=[],t=[],n=-1,s=0;for(let i of r){let o=Di(i),a=Qd(i);if(n==-1)o==0?n=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(n,...t),t.length=0,n=a):t.push(a),s=o;else{let c=Z0(n,a);c>=0?n=c:s==0&&o==0?(e.push(n),n=a):(t.push(a),s=o)}}return n>=0&&e.push(n,...t),e}function qd(r){return Jd(r).map(Qd)}function Y0(r){return $0(Jd(r))}const ju=45,Zd=".",$d=65039,Yd=1,Aa=r=>Array.from(r);function Yi(r,e){return r.P.has(e)||r.Q.has(e)}class X0 extends Array{get is_emoji(){return!0}}let al,Xd,fr,cl,ef,Is,kc,us,sr,Wu,ll;function Dl(){if(al)return;let r=Fd(O0);const e=()=>qi(r),t=()=>new Set(e()),n=(h,d)=>d.forEach(f=>h.add(f));al=new Map(Gd(r)),Xd=t(),fr=e(),cl=new Set(e().map(h=>fr[h])),fr=new Set(fr),ef=t(),t();let s=Hd(r),i=r();const o=()=>{let h=new Set;return e().forEach(d=>n(h,s[d])),n(h,e()),h};Is=Zi(h=>{let d=Zi(r).map(f=>f+96);if(d.length){let f=h>=i;d[0]-=32,d=Ii(d),f&&(d=`Restricted[${d}]`);let g=o(),w=o(),m=!r();return{N:d,P:g,Q:w,M:m,R:f}}}),kc=t(),us=new Map;let a=e().concat(Aa(kc)).sort((h,d)=>h-d);a.forEach((h,d)=>{let f=r(),g=a[d]=f?a[d-f]:{V:[],M:new Map};g.V.push(h),kc.has(h)||us.set(h,g)});for(let{V:h,M:d}of new Set(us.values())){let f=[];for(let w of h){let m=Is.filter(v=>Yi(v,w)),C=f.find(({G:v})=>m.some(k=>v.has(k)));C||(C={G:new Set,V:[]},f.push(C)),C.V.push(w),n(C.G,m)}let g=f.flatMap(w=>Aa(w.G));for(let{G:w,V:m}of f){let C=new Set(g.filter(v=>!w.has(v)));for(let v of m)d.set(v,C)}}sr=new Set;let c=new Set;const l=h=>sr.has(h)?c.add(h):sr.add(h);for(let h of Is){for(let d of h.P)l(d);for(let d of h.Q)l(d)}for(let h of sr)!us.has(h)&&!c.has(h)&&us.set(h,Yd);n(sr,qd(sr)),Wu=F0(r).map(h=>X0.from(h)).sort(K0),ll=new Map;for(let h of Wu){let d=[ll];for(let f of h){let g=d.map(w=>{let m=w.get(f);return m||(m=new Map,w.set(f,m)),m});f===$d?d.push(...g):d=g}for(let f of d)f.V=h}}function Fl(r){return(tf(r)?"":`${Hl(ja([r]))} `)+jd(r)}function Hl(r){return`"${r}"‎`}function em(r){if(r.length>=4&&r[2]==ju&&r[3]==ju)throw new Error(`invalid label extension: "${Ii(r.slice(0,4))}"`)}function tm(r){for(let t=r.lastIndexOf(95);t>0;)if(r[--t]!==95)throw new Error("underscore allowed only at start")}function nm(r){let e=r[0],t=Hu.get(e);if(t)throw ji(`leading ${t}`);let n=r.length,s=-1;for(let i=1;i<n;i++){e=r[i];let o=Hu.get(e);if(o){if(s==i)throw ji(`${t} + ${o}`);s=i+1,t=o}}if(s==n)throw ji(`trailing ${t}`)}function ja(r,e=1/0,t=jd){let n=[];rm(r[0])&&n.push("◌"),r.length>e&&(e>>=1,r=[...r.slice(0,e),8230,...r.slice(-e)]);let s=0,i=r.length;for(let o=0;o<i;o++){let a=r[o];tf(a)&&(n.push(Ii(r.slice(s,o))),n.push(t(a)),s=o+1)}return n.push(Ii(r.slice(s,i))),n.join("")}function rm(r){return Dl(),fr.has(r)}function tf(r){return Dl(),ef.has(r)}function sm(r){return cm(im(r,Y0,hm))}function im(r,e,t){if(!r)return[];Dl();let n=0;return r.split(Zd).map(s=>{let i=G0(s),o={input:i,offset:n};n+=i.length+1;try{let a=o.tokens=um(i,e,t),c=a.length,l;if(!c)throw new Error("empty label");let h=o.output=a.flat();if(tm(h),!(o.emoji=c>1||a[0].is_emoji)&&h.every(f=>f<128))em(h),l="ASCII";else{let f=a.flatMap(g=>g.is_emoji?[]:g);if(!f.length)l="Emoji";else{if(fr.has(h[0]))throw ji("leading combining mark");for(let m=1;m<c;m++){let C=a[m];if(!C.is_emoji&&fr.has(C[0]))throw ji(`emoji + combining mark: "${Ii(a[m-1])} + ${ja([C[0]])}"`)}nm(h);let g=Aa(new Set(f)),[w]=am(g);lm(w,f),om(w,g),l=w.N}}o.type=l}catch(a){o.error=a}return o})}function om(r,e){let t,n=[];for(let s of e){let i=us.get(s);if(i===Yd)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):Aa(o),!t.length)return}else n.push(s)}if(t){for(let s of t)if(n.every(i=>Yi(s,i)))throw new Error(`whole-script confusable: ${r.N}/${s.N}`)}}function am(r){let e=Is;for(let t of r){let n=e.filter(s=>Yi(s,t));if(!n.length)throw Is.some(s=>Yi(s,t))?rf(e[0],t):nf(t);if(e=n,n.length==1)break}return e}function cm(r){return r.map(({input:e,error:t,output:n})=>{if(t){let s=t.message;throw new Error(r.length==1?s:`Invalid label ${Hl(ja(e,63))}: ${s}`)}return Ii(n)}).join(Zd)}function nf(r){return new Error(`disallowed character: ${Fl(r)}`)}function rf(r,e){let t=Fl(e),n=Is.find(s=>s.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${r.N} + ${t}`)}function ji(r){return new Error(`illegal placement: ${r}`)}function lm(r,e){for(let t of e)if(!Yi(r,t))throw rf(r,t);if(r.M){let t=qd(e);for(let n=1,s=t.length;n<s;n++)if(cl.has(t[n])){let i=n+1;for(let o;i<s&&cl.has(o=t[i]);i++)for(let a=n;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${Fl(o)}`);if(i-n>Gu)throw new Error(`excessive non-spacing marks: ${Hl(ja(t.slice(n-1,i)))} (${i-n}/${Gu})`);n=i}}}function um(r,e,t){let n=[],s=[];for(r=r.slice().reverse();r.length;){let i=dm(r);if(i)s.length&&(n.push(e(s)),s=[]),n.push(t(i));else{let o=r.pop();if(sr.has(o))s.push(o);else{let a=al.get(o);if(a)s.push(...a);else if(!Xd.has(o))throw nf(o)}}}return s.length&&n.push(e(s)),n}function hm(r){return r.filter(e=>e!=$d)}function dm(r,e){let t=ll,n,s=r.length;for(;s&&(t=t.get(r[--s]),!!t);){let{V:i}=t;i&&(n=i,r.length=s)}return n}const sf=new Uint8Array(32);sf.fill(0);function Vu(r){return y(r.length!==0,"invalid ENS name; empty component","comp",r),r}function of(r){const e=jt(fm(r)),t=[];if(r.length===0)return t;let n=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(Vu(e.slice(n,s))),n=s+1);return y(n<e.length,"invalid ENS name; empty component","name",r),t.push(Vu(e.slice(n))),t}function fm(r){try{if(r.length===0)throw new Error("empty label");return sm(r)}catch(e){y(!1,`invalid ENS name (${e.message})`,"name",r)}}function ul(r){y(typeof r=="string","invalid ENS name; not a string","name",r),y(r.length,"invalid ENS name (empty label)","name",r);let e=sf;const t=of(r);for(;t.length;)e=ue(le([e,ue(t.pop())]));return T(e)}function pm(r,e){const t=e;return y(t<=255,"DNS encoded label cannot exceed 255","length",t),T(le(of(r).map(n=>{y(n.length<=t,`label ${JSON.stringify(r)} exceeds ${t} bytes`,"name",r);const s=new Uint8Array(n.length+1);return s.set(n,1),s[0]=s.length-1,s})))+"00"}function xc(r,e){return{address:$(r),storageKeys:e.map((t,n)=>(y(X(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function qr(r){if(Array.isArray(r))return r.map((t,n)=>Array.isArray(t)?(y(t.length===2,"invalid slot set",`value[${n}]`,t),xc(t[0],t[1])):(y(t!=null&&typeof t=="object","invalid address-slot set","value",r),xc(t.address,t.storageKeys)));y(r!=null&&typeof r=="object","invalid access list","value",r);const e=Object.keys(r).map(t=>{const n=r[t].reduce((s,i)=>(s[i]=!0,s),{});return xc(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function gm(r){let e;return typeof r=="string"?e=Ji.computePublicKey(r,!1):e=r.publicKey,$(ue("0x"+e.substring(4)).substring(26))}function mm(r,e){return gm(Ji.recoverPublicKey(r,e))}const me=BigInt(0),ym=BigInt(2),wm=BigInt(27),bm=BigInt(28),Am=BigInt(35),Em=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Pc=4096*32;function Qu(r,e){let t=r.toString(16);for(;t.length<2;)t="0"+t;return t+=Pi(e).substring(4),"0x"+t}function Wa(r){return r==="0x"?null:$(r)}function Gl(r,e){try{return qr(r)}catch(t){y(!1,t.message,e,r)}}function Ro(r,e){return r==="0x"?0:H(r,e)}function ce(r,e){if(r==="0x")return me;const t=_(r,e);return y(t<=Em,"value exceeds uint size",e,t),t}function te(r,e){const t=_(r,"value"),n=Le(t);return y(n.length<=32,"value too large",`tx.${e}`,t),n}function Kl(r){return qr(r).map(e=>[e.address,e.storageKeys])}function Cm(r,e){y(Array.isArray(r),`invalid ${e}`,"value",r);for(let t=0;t<r.length;t++)y(X(r[t],32),"invalid ${ param } hash",`value[${t}]`,r[t]);return r}function vm(r){const e=Fa(r);y(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",r);const t={type:0,nonce:Ro(e[0],"nonce"),gasPrice:ce(e[1],"gasPrice"),gasLimit:ce(e[2],"gasLimit"),to:Wa(e[3]),value:ce(e[4],"value"),data:T(e[5]),chainId:me};if(e.length===6)return t;const n=ce(e[6],"v"),s=ce(e[7],"r"),i=ce(e[8],"s");if(s===me&&i===me)t.chainId=n;else{let o=(n-Am)/ym;o<me&&(o=me),t.chainId=o,y(o!==me||n===wm||n===bm,"non-canonical legacy v","v",e[6]),t.signature=It.from({r:Kr(e[7],32),s:Kr(e[8],32),v:n})}return t}function Im(r,e){const t=[te(r.nonce,"nonce"),te(r.gasPrice||0,"gasPrice"),te(r.gasLimit,"gasLimit"),r.to||"0x",te(r.value,"value"),r.data];let n=me;if(r.chainId!=me)n=_(r.chainId,"tx.chainId"),y(!e||e.networkV==null||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(r.signature){const i=r.signature.legacyChainId;i!=null&&(n=i)}if(!e)return n!==me&&(t.push(Le(n)),t.push("0x"),t.push("0x")),jr(t);let s=BigInt(27+e.yParity);return n!==me?s=It.getChainIdV(n,e.v):BigInt(e.v)!==s&&y(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(Le(s)),t.push(Le(e.r)),t.push(Le(e.s)),jr(t)}function jl(r,e){let t;try{if(t=Ro(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{y(!1,"invalid yParity","yParity",e[0])}const n=Kr(e[1],32),s=Kr(e[2],32),i=It.from({r:n,s,yParity:t});r.signature=i}function Nm(r){const e=Fa(V(r).slice(1));y(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",T(r));const t={type:2,chainId:ce(e[0],"chainId"),nonce:Ro(e[1],"nonce"),maxPriorityFeePerGas:ce(e[2],"maxPriorityFeePerGas"),maxFeePerGas:ce(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:ce(e[4],"gasLimit"),to:Wa(e[5]),value:ce(e[6],"value"),data:T(e[7]),accessList:Gl(e[8],"accessList")};return e.length===9||jl(t,e.slice(9)),t}function Sm(r,e){const t=[te(r.chainId,"chainId"),te(r.nonce,"nonce"),te(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),te(r.maxFeePerGas||0,"maxFeePerGas"),te(r.gasLimit,"gasLimit"),r.to||"0x",te(r.value,"value"),r.data,Kl(r.accessList||[])];return e&&(t.push(te(e.yParity,"yParity")),t.push(Le(e.r)),t.push(Le(e.s))),le(["0x02",jr(t)])}function km(r){const e=Fa(V(r).slice(1));y(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",T(r));const t={type:1,chainId:ce(e[0],"chainId"),nonce:Ro(e[1],"nonce"),gasPrice:ce(e[2],"gasPrice"),gasLimit:ce(e[3],"gasLimit"),to:Wa(e[4]),value:ce(e[5],"value"),data:T(e[6]),accessList:Gl(e[7],"accessList")};return e.length===8||jl(t,e.slice(8)),t}function xm(r,e){const t=[te(r.chainId,"chainId"),te(r.nonce,"nonce"),te(r.gasPrice||0,"gasPrice"),te(r.gasLimit,"gasLimit"),r.to||"0x",te(r.value,"value"),r.data,Kl(r.accessList||[])];return e&&(t.push(te(e.yParity,"recoveryParam")),t.push(Le(e.r)),t.push(Le(e.s))),le(["0x01",jr(t)])}function Pm(r){let e=Fa(V(r).slice(1)),t="3",n=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];y(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),y(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),y(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),y(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),y(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let c=0;c<e[1].length;c++)n.push({data:i[c],commitment:o[c],proof:a[c]});e=e[0]}y(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",T(r));const s={type:3,chainId:ce(e[0],"chainId"),nonce:Ro(e[1],"nonce"),maxPriorityFeePerGas:ce(e[2],"maxPriorityFeePerGas"),maxFeePerGas:ce(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:ce(e[4],"gasLimit"),to:Wa(e[5]),value:ce(e[6],"value"),data:T(e[7]),accessList:Gl(e[8],"accessList"),maxFeePerBlobGas:ce(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(s.blobs=n),y(s.to!=null,`invalid address for transaction type: ${t}`,"data",r),y(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",r);for(let i=0;i<s.blobVersionedHashes.length;i++)y(X(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",r);return e.length===11||jl(s,e.slice(11)),s}function Rm(r,e,t){const n=[te(r.chainId,"chainId"),te(r.nonce,"nonce"),te(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),te(r.maxFeePerGas||0,"maxFeePerGas"),te(r.gasLimit,"gasLimit"),r.to||zi,te(r.value,"value"),r.data,Kl(r.accessList||[]),te(r.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Cm(r.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(te(e.yParity,"yParity")),n.push(Le(e.r)),n.push(Le(e.s)),t)?le(["0x03",jr([n,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):le(["0x03",jr(n)])}var Tt,Hs,Gs,Ks,js,Ws,Vs,Qs,zs,Js,qs,Zs,Sr,Ln,cn,Un,$s,ra;const Xt=class Xt{constructor(){A(this,$s);A(this,Tt,void 0);A(this,Hs,void 0);A(this,Gs,void 0);A(this,Ks,void 0);A(this,js,void 0);A(this,Ws,void 0);A(this,Vs,void 0);A(this,Qs,void 0);A(this,zs,void 0);A(this,Js,void 0);A(this,qs,void 0);A(this,Zs,void 0);A(this,Sr,void 0);A(this,Ln,void 0);A(this,cn,void 0);A(this,Un,void 0);p(this,Tt,null),p(this,Hs,null),p(this,Ks,0),p(this,js,me),p(this,Ws,null),p(this,Vs,null),p(this,Qs,null),p(this,Gs,"0x"),p(this,zs,me),p(this,Js,me),p(this,qs,null),p(this,Zs,null),p(this,Sr,null),p(this,Ln,null),p(this,Un,null),p(this,cn,null)}get type(){return u(this,Tt)}set type(e){switch(e){case null:p(this,Tt,null);break;case 0:case"legacy":p(this,Tt,0);break;case 1:case"berlin":case"eip-2930":p(this,Tt,1);break;case 2:case"london":case"eip-1559":p(this,Tt,2);break;case 3:case"cancun":case"eip-4844":p(this,Tt,3);break;default:y(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=u(this,Hs);return e==null&&this.type===3?zi:e}set to(e){p(this,Hs,e==null?null:$(e))}get nonce(){return u(this,Ks)}set nonce(e){p(this,Ks,H(e,"value"))}get gasLimit(){return u(this,js)}set gasLimit(e){p(this,js,_(e))}get gasPrice(){const e=u(this,Ws);return e==null&&(this.type===0||this.type===1)?me:e}set gasPrice(e){p(this,Ws,e==null?null:_(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=u(this,Vs);return e??(this.type===2||this.type===3?me:null)}set maxPriorityFeePerGas(e){p(this,Vs,e==null?null:_(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=u(this,Qs);return e??(this.type===2||this.type===3?me:null)}set maxFeePerGas(e){p(this,Qs,e==null?null:_(e,"maxFeePerGas"))}get data(){return u(this,Gs)}set data(e){p(this,Gs,T(e))}get value(){return u(this,zs)}set value(e){p(this,zs,_(e,"value"))}get chainId(){return u(this,Js)}set chainId(e){p(this,Js,_(e))}get signature(){return u(this,qs)||null}set signature(e){p(this,qs,e==null?null:It.from(e))}get accessList(){const e=u(this,Zs)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){p(this,Zs,e==null?null:qr(e))}get maxFeePerBlobGas(){const e=u(this,Sr);return e==null&&this.type===3?me:e}set maxFeePerBlobGas(e){p(this,Sr,e==null?null:_(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=u(this,Ln);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){y(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)y(X(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}p(this,Ln,e)}get blobs(){return u(this,Un)==null?null:u(this,Un).map(e=>Object.assign({},e))}set blobs(e){if(e==null){p(this,Un,null);return}const t=[],n=[];for(let s=0;s<e.length;s++){const i=e[s];if(xl(i)){I(u(this,cn),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=V(i);if(y(o.length<=Pc,"blob is too large",`blobs[${s}]`,i),o.length!==Pc){const l=new Uint8Array(Pc);l.set(o),o=l}const a=u(this,cn).blobToKzgCommitment(o),c=T(u(this,cn).computeBlobKzgProof(o,a));t.push({data:T(o),commitment:T(a),proof:c}),n.push(Qu(1,a))}else{const o=T(i.commitment);t.push({data:T(i.data),commitment:o,proof:T(i.proof)}),n.push(Qu(1,o))}}p(this,Un,t),p(this,Ln,n)}get kzg(){return u(this,cn)}set kzg(e){p(this,cn,e)}get hash(){return this.signature==null?null:ue(N(this,$s,ra).call(this,!0,!1))}get unsignedHash(){return ue(this.unsignedSerialized)}get from(){return this.signature==null?null:mm(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:Ji.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return N(this,$s,ra).call(this,!0,!0)}get unsignedSerialized(){return N(this,$s,ra).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,s=u(this,Sr)!=null||u(this,Ln);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&I(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),I(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),I(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Xt.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Xt;if(typeof e=="string"){const n=V(e);if(n[0]>=127)return Xt.from(vm(n));switch(n[0]){case 1:return Xt.from(km(n));case 2:return Xt.from(Nm(n));case 3:return Xt.from(Pm(n))}I(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Xt;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=It.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(y(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),y(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(y(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),y(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Tt=new WeakMap,Hs=new WeakMap,Gs=new WeakMap,Ks=new WeakMap,js=new WeakMap,Ws=new WeakMap,Vs=new WeakMap,Qs=new WeakMap,zs=new WeakMap,Js=new WeakMap,qs=new WeakMap,Zs=new WeakMap,Sr=new WeakMap,Ln=new WeakMap,cn=new WeakMap,Un=new WeakMap,$s=new WeakSet,ra=function(e,t){I(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=e?this.signature:null;switch(this.inferType()){case 0:return Im(this,n);case 1:return xm(this,n);case 2:return Sm(this,n);case 3:return Rm(this,n,t?this.blobs:null)}I(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Ea=Xt;const af=new Uint8Array(32);af.fill(0);const Om=BigInt(-1),cf=BigInt(0),lf=BigInt(1),Tm=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function Bm(r){const e=V(r),t=e.length%32;return t?le([e,af.slice(t)]):T(e)}const _m=Xn(lf,32),Lm=Xn(cf,32),zu={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Rc=["name","version","chainId","verifyingContract","salt"];function Ju(r){return function(e){return y(typeof e=="string",`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,e),e}}const Um={name:Ju("name"),version:Ju("version"),chainId:function(r){const e=_(r,"domain.chainId");return y(e>=0,"invalid chain ID","domain.chainId",r),Number.isSafeInteger(e)?Number(e):gs(e)},verifyingContract:function(r){try{return $(r).toLowerCase()}catch{}y(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",r)},salt:function(r){const e=V(r,"domain.salt");return y(e.length===32,'invalid domain value "salt"',"domain.salt",r),T(e)}};function Oc(r){{const e=r.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",n=parseInt(e[2]);y(n%8===0&&n!==0&&n<=256&&e[2]===String(n),"invalid numeric width","type",r);const s=hr(Tm,t?n-1:n),i=t?(s+lf)*Om:cf;return function(o){const a=_(o,"value");return y(a>=i&&a<=s,`value out-of-bounds for ${r}`,"value",a),Xn(t?zh(a,256):a,32)}}}{const e=r.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return y(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",r),function(n){const s=V(n);return y(s.length===t,`invalid length for ${r}`,"value",n),Bm(n)}}}switch(r){case"address":return function(e){return Kr($(e),32)};case"bool":return function(e){return e?_m:Lm};case"bytes":return function(e){return ue(e)};case"string":return function(e){return Wr(e)}}return null}function qu(r,e){return`${r}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function Vo(r){const e=r.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:r}}var ho,ln,Ys,Ra,uf;const tt=class tt{constructor(e){A(this,Ra);E(this,"primaryType");A(this,ho,void 0);A(this,ln,void 0);A(this,Ys,void 0);p(this,ln,new Map),p(this,Ys,new Map);const t=new Map,n=new Map,s=new Map,i={};Object.keys(e).forEach(c=>{i[c]=e[c].map(({name:l,type:h})=>{let{base:d,index:f}=Vo(h);return d==="int"&&!e.int&&(d="int256"),d==="uint"&&!e.uint&&(d="uint256"),{name:l,type:d+(f||"")}}),t.set(c,new Set),n.set(c,[]),s.set(c,new Set)}),p(this,ho,JSON.stringify(i));for(const c in i){const l=new Set;for(const h of i[c]){y(!l.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(c)}`,"types",e),l.add(h.name);const d=Vo(h.type).base;y(d!==c,`circular type reference to ${JSON.stringify(d)}`,"types",e),!Oc(d)&&(y(n.has(d),`unknown type ${JSON.stringify(d)}`,"types",e),n.get(d).push(c),t.get(c).add(d))}}const o=Array.from(n.keys()).filter(c=>n.get(c).length===0);y(o.length!==0,"missing primary type","types",e),y(o.length===1,`ambiguous primary types or unused types: ${o.map(c=>JSON.stringify(c)).join(", ")}`,"types",e),F(this,{primaryType:o[0]});function a(c,l){y(!l.has(c),`circular type reference to ${JSON.stringify(c)}`,"types",e),l.add(c);for(const h of t.get(c))if(n.has(h)){a(h,l);for(const d of l)s.get(d).add(h)}l.delete(c)}a(this.primaryType,new Set);for(const[c,l]of s){const h=Array.from(l);h.sort(),u(this,ln).set(c,qu(c,i[c])+h.map(d=>qu(d,i[d])).join(""))}}get types(){return JSON.parse(u(this,ho))}getEncoder(e){let t=u(this,Ys).get(e);return t||(t=N(this,Ra,uf).call(this,e),u(this,Ys).set(e,t)),t}encodeType(e){const t=u(this,ln).get(e);return y(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return ue(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(Oc(e))return n(e,t);const s=Vo(e).array;if(s)return y(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,n));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:c})=>(o[a]=this._visit(c,t[a],n),o),{});y(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new tt(e)}static getPrimaryType(e){return tt.from(e).primaryType}static hashStruct(e,t,n){return tt.from(t).hashStruct(e,n)}static hashDomain(e){const t=[];for(const n in e){if(e[n]==null)continue;const s=zu[n];y(s,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:s})}return t.sort((n,s)=>Rc.indexOf(n.name)-Rc.indexOf(s.name)),tt.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return le(["0x1901",tt.hashDomain(e),tt.from(t).hash(n)])}static hash(e,t,n){return ue(tt.encode(e,t,n))}static async resolveNames(e,t,n,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!X(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=tt.from(t);o.visit(n,(a,c)=>(a==="address"&&!X(c,20)&&(i[c]="0x"),c));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),n=o.visit(n,(a,c)=>a==="address"&&i[c]?i[c]:c),{domain:e,value:n}}static getPayload(e,t,n){tt.hashDomain(e);const s={},i=[];Rc.forEach(c=>{const l=e[c];l!=null&&(s[c]=Um[c](l),i.push({name:c,type:zu[c]}))});const o=tt.from(t);t=o.types;const a=Object.assign({},t);return y(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(n),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(n,(c,l)=>{if(c.match(/^bytes(\d*)/))return T(V(l));if(c.match(/^u?int/))return _(l).toString();switch(c){case"address":return l.toLowerCase();case"bool":return!!l;case"string":return y(typeof l=="string","invalid string","value",l),l}y(!1,"unsupported type","type",c)})}}};ho=new WeakMap,ln=new WeakMap,Ys=new WeakMap,Ra=new WeakSet,uf=function(e){{const s=Oc(e);if(s)return s}const t=Vo(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{y(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return u(this,ln).has(s)&&(a=a.map(ue)),ue(le(a))}}const n=this.types[e];if(n){const s=Wr(u(this,ln).get(e));return i=>{const o=n.map(({name:a,type:c})=>{const l=this.getEncoder(c)(i[a]);return u(this,ln).has(c)?ue(l):l});return o.unshift(s),le(o)}}y(!1,`unknown type: ${e}`,"type",e)};let Ca=tt;function De(r){const e=new Set;return r.forEach(t=>e.add(t)),Object.freeze(e)}const Mm="external public payable override",Dm=De(Mm.split(" ")),hf="constant external internal payable private public pure view override",Fm=De(hf.split(" ")),df="constructor error event fallback function receive struct",ff=De(df.split(" ")),pf="calldata memory storage payable indexed",Hm=De(pf.split(" ")),Gm="tuple returns",Km=[df,pf,Gm,hf].join(" "),jm=De(Km.split(" ")),Wm={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Vm=new RegExp("^(\\s*)"),Qm=new RegExp("^([0-9]+)"),zm=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),gf=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),mf=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var Ae,bt,fo,hl;const Oa=class Oa{constructor(e){A(this,fo);A(this,Ae,void 0);A(this,bt,void 0);p(this,Ae,0),p(this,bt,e.slice())}get offset(){return u(this,Ae)}get length(){return u(this,bt).length-u(this,Ae)}clone(){return new Oa(u(this,bt))}reset(){p(this,Ae,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=N(this,fo,hl).call(this,u(this,Ae)+1,e.match+1);return p(this,Ae,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;u(this,Ae)<e.match-1;){const n=this.peek().linkNext;t.push(N(this,fo,hl).call(this,u(this,Ae)+1,n)),p(this,Ae,n)}return p(this,Ae,e.match+1),t}peek(){if(u(this,Ae)>=u(this,bt).length)throw new Error("out-of-bounds");return u(this,bt)[u(this,Ae)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Ti(this,Ae)._++,e}toString(){const e=[];for(let t=u(this,Ae);t<u(this,bt).length;t++){const n=u(this,bt)[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}};Ae=new WeakMap,bt=new WeakMap,fo=new WeakSet,hl=function(e=0,t=0){return new Oa(u(this,bt).slice(e,t).map(n=>Object.freeze(Object.assign({},n,{match:n.match-e,linkBack:n.linkBack-e,linkNext:n.linkNext-e}))))};let Nt=Oa;function er(r){const e=[],t=o=>{const a=i<r.length?JSON.stringify(r[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let n=[],s=[],i=0;for(;i<r.length;){let o=r.substring(i),a=o.match(Vm);a&&(i+=a[1].length,o=r.substring(i));const c={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(c);let l=Wm[o[0]]||"";if(l){if(c.type=l,c.text=o[0],i++,l==="OPEN_PAREN")n.push(e.length-1),s.push(e.length-1);else if(l=="CLOSE_PAREN")n.length===0&&t("no matching open bracket"),c.match=n.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(l==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(l==="OPEN_BRACKET")c.type="BRACKET";else if(l==="CLOSE_BRACKET"){let h=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const d=e.pop().text;h=d+h,e[e.length-1].value=H(d)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=h}continue}if(a=o.match(zm),a){if(c.text=a[1],i+=c.text.length,jm.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(mf)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(Qm),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new Nt(e.map(o=>Object.freeze(o)))}function Zu(r,e){let t=[];for(const n in e.keys())r.has(n)&&t.push(n);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function Va(r,e){if(e.peekKeyword(ff)){const t=e.pop().text;if(t!==r)throw new Error(`expected ${r}, got ${t}`)}return e.popType("ID")}function bn(r,e){const t=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||e&&!e.has(n))break;if(r.pop(),t.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);t.add(n)}return Object.freeze(t)}function yf(r){let e=bn(r,Fm);return Zu(e,De("constant payable nonpayable".split(" "))),Zu(e,De("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function wn(r,e){return r.popParams().map(t=>Ce.from(t,e))}function wf(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return _(r.pop().text);throw new Error("invalid gas")}return null}function Vr(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const Jm=new RegExp(/^(.*)\[([0-9]*)\]$/);function $u(r){const e=r.match(mf);if(y(e,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(e[2]){const t=parseInt(e[2]);y(t!==0&&t<=32,"invalid bytes length","type",r)}else if(e[3]){const t=parseInt(e[3]);y(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",r)}return r}const re={},je=Symbol.for("_ethers_internal"),Yu="_ParamTypeInternal",Xu="_ErrorInternal",eh="_EventInternal",th="_ConstructorInternal",nh="_FallbackInternal",rh="_FunctionInternal",sh="_StructInternal";var Xs,sa;const nt=class nt{constructor(e,t,n,s,i,o,a,c){A(this,Xs);E(this,"name");E(this,"type");E(this,"baseType");E(this,"indexed");E(this,"components");E(this,"arrayLength");E(this,"arrayChildren");if(xo(e,re,"ParamType"),Object.defineProperty(this,je,{value:Yu}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");F(this,{name:t,type:n,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){const n=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=n,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(n=>n.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return e.map(s=>n.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map((s,i)=>n.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const n=[],s=[e];return N(this,Xs,sa).call(this,n,e,t,i=>{s[0]=i}),n.length&&await Promise.all(n),s[0]}static from(e,t){if(nt.isParamType(e))return e;if(typeof e=="string")try{return nt.from(er(e),t)}catch{y(!1,"invalid param type","obj",e)}else if(e instanceof Nt){let a="",c="",l=null;bn(e,De(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",l=e.popParams().map(m=>nt.from(m)),a=`tuple(${l.map(m=>m.format()).join(",")})`):(a=$u(e.popType("TYPE")),c=a);let h=null,d=null;for(;e.length&&e.peekType("BRACKET");){const m=e.pop();h=new nt(re,"",a,c,null,l,d,h),d=m.value,a+=m.text,c="array",l=null}let f=null;if(bn(e,Hm).has("indexed")){if(!t)throw new Error("");f=!0}const w=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new nt(re,w,a,c,f,l,d,h)}const n=e.name;y(!n||typeof n=="string"&&n.match(gf),"invalid name","obj.name",n);let s=e.indexed;s!=null&&(y(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(Jm);if(o){const a=parseInt(o[2]||"-1"),c=nt.from({type:o[1],components:e.components});return new nt(re,n||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(l=>nt.from(l)):null;return new nt(re,n||"",i,"tuple",s,a,null,null)}return i=$u(e.type),new nt(re,n||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[je]===Yu}};Xs=new WeakSet,sa=function(e,t,n,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((c,l)=>{var h;N(h=o,Xs,sa).call(h,e,c,n,d=>{a[l]=d})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,l)=>{var h;N(h=o[l],Xs,sa).call(h,e,c,n,d=>{a[l]=d})}),s(a);return}const i=n(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let Ce=nt;class Qr{constructor(e,t,n){E(this,"type");E(this,"inputs");xo(e,re,"Fragment"),n=Object.freeze(n.slice()),F(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{Qr.from(JSON.parse(e))}catch{}return Qr.from(er(e))}if(e instanceof Nt)switch(e.peekKeyword(ff)){case"constructor":return yn.from(e);case"error":return Ke.from(e);case"event":return Ht.from(e);case"fallback":case"receive":return en.from(e);case"function":return Gt.from(e);case"struct":return Gr.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return yn.from(e);case"error":return Ke.from(e);case"event":return Ht.from(e);case"fallback":case"receive":return en.from(e);case"function":return Gt.from(e);case"struct":return Gr.from(e)}I(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}y(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return yn.isFragment(e)}static isError(e){return Ke.isFragment(e)}static isEvent(e){return Ht.isFragment(e)}static isFunction(e){return Gt.isFragment(e)}static isStruct(e){return Gr.isFragment(e)}}class Qa extends Qr{constructor(t,n,s,i){super(t,n,i);E(this,"name");y(typeof s=="string"&&s.match(gf),"invalid identifier","name",s),i=Object.freeze(i.slice()),F(this,{name:s})}}function Xi(r,e){return"("+e.map(t=>t.format(r)).join(r==="full"?", ":",")+")"}class Ke extends Qa{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,je,{value:Xu})}get selector(){return Wr(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Xi(e,this.inputs)),t.join(" ")}static from(e){if(Ke.isFragment(e))return e;if(typeof e=="string")return Ke.from(er(e));if(e instanceof Nt){const t=Va("error",e),n=wn(e);return Vr(e),new Ke(re,t,n)}return new Ke(re,e.name,e.inputs?e.inputs.map(Ce.from):[])}static isFragment(e){return e&&e[je]===Xu}}class Ht extends Qa{constructor(t,n,s,i){super(t,"event",n,s);E(this,"anonymous");Object.defineProperty(this,je,{value:eh}),F(this,{anonymous:i})}get topicHash(){return Wr(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const n=[];return t!=="sighash"&&n.push("event"),n.push(this.name+Xi(t,this.inputs)),t!=="sighash"&&this.anonymous&&n.push("anonymous"),n.join(" ")}static getTopicHash(t,n){return n=(n||[]).map(i=>Ce.from(i)),new Ht(re,t,n,!1).topicHash}static from(t){if(Ht.isFragment(t))return t;if(typeof t=="string")try{return Ht.from(er(t))}catch{y(!1,"invalid event fragment","obj",t)}else if(t instanceof Nt){const n=Va("event",t),s=wn(t,!0),i=!!bn(t,De(["anonymous"])).has("anonymous");return Vr(t),new Ht(re,n,s,i)}return new Ht(re,t.name,t.inputs?t.inputs.map(n=>Ce.from(n,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[je]===eh}}class yn extends Qr{constructor(t,n,s,i,o){super(t,n,s);E(this,"payable");E(this,"gas");Object.defineProperty(this,je,{value:th}),F(this,{payable:i,gas:o})}format(t){if(I(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const n=[`constructor${Xi(t,this.inputs)}`];return this.payable&&n.push("payable"),this.gas!=null&&n.push(`@${this.gas.toString()}`),n.join(" ")}static from(t){if(yn.isFragment(t))return t;if(typeof t=="string")try{return yn.from(er(t))}catch{y(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Nt){bn(t,De(["constructor"]));const n=wn(t),s=!!bn(t,Dm).has("payable"),i=wf(t);return Vr(t),new yn(re,"constructor",n,s,i)}return new yn(re,"constructor",t.inputs?t.inputs.map(Ce.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[je]===th}}class en extends Qr{constructor(t,n,s){super(t,"fallback",n);E(this,"payable");Object.defineProperty(this,je,{value:nh}),F(this,{payable:s})}format(t){const n=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:n,stateMutability:s})}return`${n}()${this.payable?" payable":""}`}static from(t){if(en.isFragment(t))return t;if(typeof t=="string")try{return en.from(er(t))}catch{y(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Nt){const n=t.toString(),s=t.peekKeyword(De(["fallback","receive"]));if(y(s,"type must be fallback or receive","obj",n),t.popKeyword(De(["fallback","receive"]))==="receive"){const c=wn(t);return y(c.length===0,"receive cannot have arguments","obj.inputs",c),bn(t,De(["payable"])),Vr(t),new en(re,[],!0)}let o=wn(t);o.length?y(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[Ce.from("bytes")];const a=yf(t);if(y(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),bn(t,De(["returns"])).has("returns")){const c=wn(t);y(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(l=>l.format("minimal")).join(", "))}return Vr(t),new en(re,o,a==="payable")}if(t.type==="receive")return new en(re,[],!0);if(t.type==="fallback"){const n=[Ce.from("bytes")],s=t.stateMutability==="payable";return new en(re,n,s)}y(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[je]===nh}}class Gt extends Qa{constructor(t,n,s,i,o,a){super(t,"function",n,i);E(this,"constant");E(this,"outputs");E(this,"stateMutability");E(this,"payable");E(this,"gas");Object.defineProperty(this,je,{value:rh}),o=Object.freeze(o.slice()),F(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return Wr(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const n=[];return t!=="sighash"&&n.push("function"),n.push(this.name+Xi(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(Xi(t,this.outputs))),this.gas!=null&&n.push(`@${this.gas.toString()}`)),n.join(" ")}static getSelector(t,n){return n=(n||[]).map(i=>Ce.from(i)),new Gt(re,t,"view",n,[],null).selector}static from(t){if(Gt.isFragment(t))return t;if(typeof t=="string")try{return Gt.from(er(t))}catch{y(!1,"invalid function fragment","obj",t)}else if(t instanceof Nt){const s=Va("function",t),i=wn(t),o=yf(t);let a=[];bn(t,De(["returns"])).has("returns")&&(a=wn(t));const c=wf(t);return Vr(t),new Gt(re,s,o,i,a,c)}let n=t.stateMutability;return n==null&&(n="payable",typeof t.constant=="boolean"?(n="view",t.constant||(n="payable",typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable")),new Gt(re,t.name,n,t.inputs?t.inputs.map(Ce.from):[],t.outputs?t.outputs.map(Ce.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[je]===rh}}class Gr extends Qa{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,je,{value:sh})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Gr.from(er(e))}catch{y(!1,"invalid struct fragment","obj",e)}else if(e instanceof Nt){const t=Va("struct",e),n=wn(e);return Vr(e),new Gr(re,t,n)}return new Gr(re,e.name,e.inputs?e.inputs.map(Ce.from):[])}static isFragment(e){return e&&e[je]===sh}}const St=new Map;St.set(0,"GENERIC_PANIC");St.set(1,"ASSERT_FALSE");St.set(17,"OVERFLOW");St.set(18,"DIVIDE_BY_ZERO");St.set(33,"ENUM_RANGE_ERROR");St.set(34,"BAD_STORAGE_DATA");St.set(49,"STACK_UNDERFLOW");St.set(50,"ARRAY_RANGE_ERROR");St.set(65,"OUT_OF_MEMORY");St.set(81,"UNINITIALIZED_FUNCTION_CALL");const qm=new RegExp(/^bytes([0-9]*)$/),Zm=new RegExp(/^(u?int)([0-9]*)$/);let Tc=null,ih=1024;function $m(r,e,t,n){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const l=V(t);if(t=T(t),l.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(l.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(T(l.slice(0,4))==="0x08c379a0")try{i=n.decode(["string"],l.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(T(l.slice(0,4))==="0x4e487b71")try{const h=Number(n.decode(["uint256"],l.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[h]},i=`Panic due to ${St.get(h)||"UNKNOWN"}(${h})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?$(e.to):null,data:e.data||"0x"};return e.from&&(c.from=$(e.from)),ne(s,"CALL_EXCEPTION",{action:r,data:t,reason:i,transaction:c,invocation:o,revert:a})}var Mn,hs;const Ta=class Ta{constructor(){A(this,Mn)}getDefaultValue(e){const t=e.map(s=>N(this,Mn,hs).call(this,Ce.from(s)));return new Wo(t,"_").defaultValue()}encode(e,t){Wh(t.length,e.length,"types/values length mismatch");const n=e.map(o=>N(this,Mn,hs).call(this,Ce.from(o))),s=new Wo(n,"_"),i=new $c;return s.encode(i,t),i.data}decode(e,t,n){const s=e.map(o=>N(this,Mn,hs).call(this,Ce.from(o)));return new Wo(s,"_").decode(new Yc(t,n,ih))}static _setDefaultMaxInflation(e){y(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),ih=e}static defaultAbiCoder(){return Tc==null&&(Tc=new Ta),Tc}static getBuiltinCallException(e,t,n){return $m(e,t,n,Ta.defaultAbiCoder())}};Mn=new WeakSet,hs=function(e){if(e.isArray())return new A0(N(this,Mn,hs).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Wo(e.components.map(n=>N(this,Mn,hs).call(this,n)),e.name);switch(e.baseType){case"address":return new w0(e.name);case"bool":return new E0(e.name);case"string":return new R0(e.name);case"bytes":return new C0(e.name);case"":return new N0(e.name)}let t=e.type.match(Zm);if(t){let n=parseInt(t[2]||"256");return y(n!==0&&n<=256&&n%8===0,"invalid "+t[1]+" bit length","param",e),new P0(n/8,t[1]==="int",e.name)}if(t=e.type.match(qm),t){let n=parseInt(t[1]);return y(n!==0&&n<=32,"invalid bytes length","param",e),new v0(n,e.name)}y(!1,"invalid type","type",e.type)};let eo=Ta;class Ym{constructor(e,t,n){E(this,"fragment");E(this,"name");E(this,"signature");E(this,"topic");E(this,"args");const s=e.name,i=e.format();F(this,{fragment:e,name:s,signature:i,topic:t,args:n})}}class Xm{constructor(e,t,n,s){E(this,"fragment");E(this,"name");E(this,"args");E(this,"signature");E(this,"selector");E(this,"value");const i=e.name,o=e.format();F(this,{fragment:e,name:i,args:n,signature:o,selector:t,value:s})}}class ey{constructor(e,t,n){E(this,"fragment");E(this,"name");E(this,"args");E(this,"signature");E(this,"selector");const s=e.name,i=e.format();F(this,{fragment:e,name:s,args:n,signature:i,selector:t})}}class oh{constructor(e){E(this,"hash");E(this,"_isIndexed");F(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const ah={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},ch={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let e="unknown panic code";return r>=0&&r<=255&&ah[r.toString()]&&(e=ah[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${e})`}}};var Bt,_t,Lt,ve,ei,ia,ti,oa;const lr=class lr{constructor(e){A(this,ei);A(this,ti);E(this,"fragments");E(this,"deploy");E(this,"fallback");E(this,"receive");A(this,Bt,void 0);A(this,_t,void 0);A(this,Lt,void 0);A(this,ve,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,p(this,Lt,new Map),p(this,Bt,new Map),p(this,_t,new Map);const n=[];for(const o of t)try{n.push(Qr.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}F(this,{fragments:Object.freeze(n)});let s=null,i=!1;p(this,ve,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}F(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(y(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=u(this,Lt);break;case"event":c=u(this,_t);break;case"error":c=u(this,Bt);break;default:return}const l=o.format();c.has(l)||c.set(l,o)}),this.deploy||F(this,{deploy:yn.from("constructor()")}),F(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return eo.defaultAbiCoder()}getFunctionName(e){const t=N(this,ei,ia).call(this,e,null,!1);return y(t,"no matching function","key",e),t.name}hasFunction(e){return!!N(this,ei,ia).call(this,e,null,!1)}getFunction(e,t){return N(this,ei,ia).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(u(this,Lt).keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(u(this,Lt).get(s),n)}}getEventName(e){const t=N(this,ti,oa).call(this,e,null,!1);return y(t,"no matching event","key",e),t.name}hasEvent(e){return!!N(this,ti,oa).call(this,e,null,!1)}getEvent(e,t){return N(this,ti,oa).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(u(this,_t).keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(u(this,_t).get(s),n)}}getError(e,t){if(X(e)){const s=e.toLowerCase();if(ch[s])return Ke.from(ch[s].signature);for(const i of u(this,Bt).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of u(this,Bt))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Ke.from("error Error(string)"):e==="Panic"?Ke.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");y(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Ke.from(e).format(),e==="Error(string)")return Ke.from("error Error(string)");if(e==="Panic(uint256)")return Ke.from("error Panic(uint256)");const n=u(this,Bt).get(e);return n||null}forEachError(e){const t=Array.from(u(this,Bt).keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(u(this,Bt).get(s),n)}}_decodeParams(e,t){return u(this,ve).decode(e,t)}_encodeParams(e,t){return u(this,ve).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);y(n,"unknown error","fragment",e),e=n}return y(se(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,se(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);y(n,"unknown error","fragment",e),e=n}return le([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);y(n,"unknown function","fragment",e),e=n}return y(se(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,se(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);y(n,"unknown function","fragment",e),e=n}return le([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);y(i,"unknown function","fragment",e),e=i}let n="invalid length for result data";const s=_e(t);if(s.length%32===0)try{return u(this,ve).decode(e.outputs,s)}catch{n="could not decode result data"}I(!1,n,"BAD_DATA",{value:T(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=V(e,"data"),s=eo.getBuiltinCallException("call",t,n);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=T(n.slice(0,4)),c=this.getError(a);if(c)try{const l=u(this,ve).decode(c.inputs,n.slice(4));s.revert={name:c.name,signature:c.format(),args:l},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const n=this.getFunction(e);y(n,"unknown function","fragment",e),e=n}return T(u(this,ve).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);y(i,"unknown event","eventFragment",e),e=i}I(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const s=(i,o)=>i.type==="string"?Wr(o):i.type==="bytes"?ue(T(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=Xn(o):i.type.match(/^bytes/)?o=Ep(o,32):i.type==="address"&&u(this,ve).encode(["address"],[o]),Kr(T(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){y(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?y(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?n.push(i.map(c=>s(a,c))):n.push(s(a,i))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);y(o,"unknown event","eventFragment",e),e=o}const n=[],s=[],i=[];return e.anonymous||n.push(e.topicHash),y(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const c=t[a];if(o.indexed)if(o.type==="string")n.push(Wr(c));else if(o.type==="bytes")n.push(ue(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(u(this,ve).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:u(this,ve).encode(s,i),topics:n}}decodeEventLog(e,t,n){if(typeof e=="string"){const g=this.getEvent(e);y(g,"unknown event","eventFragment",e),e=g}if(n!=null&&!e.anonymous){const g=e.topicHash;y(X(n[0],32)&&n[0].toLowerCase()===g,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((g,w)=>{g.indexed?g.type==="string"||g.type==="bytes"||g.baseType==="tuple"||g.baseType==="array"?(s.push(Ce.from({type:"bytes32",name:g.name})),o.push(!0)):(s.push(g),o.push(!1)):(i.push(g),o.push(!1))});const a=n!=null?u(this,ve).decode(s,le(n)):null,c=u(this,ve).decode(i,t,!0),l=[],h=[];let d=0,f=0;return e.inputs.forEach((g,w)=>{let m=null;if(g.indexed)if(a==null)m=new oh(null);else if(o[w])m=new oh(a[f++]);else try{m=a[f++]}catch(C){m=C}else try{m=c[d++]}catch(C){m=C}l.push(m),h.push(g.name||null)}),bi.fromItems(l,h)}parseTransaction(e){const t=V(e.data,"tx.data"),n=_(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(T(t.slice(0,4)));if(!s)return null;const i=u(this,ve).decode(s.inputs,t.slice(4));return new Xm(s,s.selector,i,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new Ym(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=T(e),n=this.getError(se(t,0,4));if(!n)return null;const s=u(this,ve).decode(n.inputs,se(t,4));return new ey(n,n.selector,s)}static from(e){return e instanceof lr?e:typeof e=="string"?new lr(JSON.parse(e)):typeof e.formatJson=="function"?new lr(e.formatJson()):typeof e.format=="function"?new lr(e.format("json")):new lr(e)}};Bt=new WeakMap,_t=new WeakMap,Lt=new WeakMap,ve=new WeakMap,ei=new WeakSet,ia=function(e,t,n){if(X(e)){const i=e.toLowerCase();for(const o of u(this,Lt).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of u(this,Lt))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,c=!0;xe.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let l=i.length-1;l>=0;l--){const h=i[l].inputs.length;h!==a&&(!c||h!==a-1)&&i.splice(l,1)}for(let l=i.length-1;l>=0;l--){const h=i[l].inputs;for(let d=0;d<t.length;d++)if(xe.isTyped(t[d])){if(d>=h.length){if(t[d].type==="overrides")continue;i.splice(l,1);break}if(t[d].type!==h[d].baseType){i.splice(l,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");y(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=u(this,Lt).get(Gt.from(e).format());return s||null},ti=new WeakSet,oa=function(e,t,n){if(X(e)){const i=e.toLowerCase();for(const o of u(this,_t).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of u(this,_t))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<t.length;c++)if(xe.isTyped(t[c])&&t[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");y(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=u(this,_t).get(Ht.from(e).format());return s||null};let dl=lr;const bf=BigInt(0);function Ns(r){return r??null}function oe(r){return r==null?null:r.toString()}class lh{constructor(e,t,n){E(this,"gasPrice");E(this,"maxFeePerGas");E(this,"maxPriorityFeePerGas");F(this,{gasPrice:Ns(e),maxFeePerGas:Ns(t),maxPriorityFeePerGas:Ns(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:oe(e),maxFeePerGas:oe(t),maxPriorityFeePerGas:oe(n)}}}function va(r){const e={};r.to&&(e.to=r.to),r.from&&(e.from=r.from),r.data&&(e.data=T(r.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in r)||r[s]==null||(e[s]=_(r[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)!(s in r)||r[s]==null||(e[s]=H(r[s],`request.${s}`));return r.accessList&&(e.accessList=qr(r.accessList)),"blockTag"in r&&(e.blockTag=r.blockTag),"enableCcipRead"in r&&(e.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(e.customData=r.customData),"blobVersionedHashes"in r&&r.blobVersionedHashes&&(e.blobVersionedHashes=r.blobVersionedHashes.slice()),"kzg"in r&&(e.kzg=r.kzg),"blobs"in r&&r.blobs&&(e.blobs=r.blobs.map(s=>xl(s)?T(s):Object.assign({},s))),e}var un;class ty{constructor(e,t){E(this,"provider");E(this,"number");E(this,"hash");E(this,"timestamp");E(this,"parentHash");E(this,"parentBeaconBlockRoot");E(this,"nonce");E(this,"difficulty");E(this,"gasLimit");E(this,"gasUsed");E(this,"stateRoot");E(this,"receiptsRoot");E(this,"blobGasUsed");E(this,"excessBlobGas");E(this,"miner");E(this,"prevRandao");E(this,"extraData");E(this,"baseFeePerGas");A(this,un,void 0);p(this,un,e.transactions.map(n=>typeof n!="string"?new to(n,t):n)),F(this,{provider:t,hash:Ns(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Ns(e.prevRandao),extraData:e.extraData,baseFeePerGas:Ns(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return u(this,un).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=u(this,un).slice();return e.length===0?[]:(I(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:c,nonce:l,number:h,parentHash:d,parentBeaconBlockRoot:f,stateRoot:g,receiptsRoot:w,timestamp:m,transactions:C}=this;return{_type:"Block",baseFeePerGas:oe(e),difficulty:oe(t),extraData:n,gasLimit:oe(s),gasUsed:oe(i),blobGasUsed:oe(this.blobGasUsed),excessBlobGas:oe(this.excessBlobGas),hash:o,miner:a,prevRandao:c,nonce:l,number:h,parentHash:d,timestamp:m,parentBeaconBlockRoot:f,stateRoot:g,receiptsRoot:w,transactions:C}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return u(this,un).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=u(this,un)[e];else{const n=e.toLowerCase();for(const s of u(this,un))if(typeof s=="string"){if(s!==n)continue;t=s;break}else{if(s.hash===n)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const n of t)if(n.hash===e)return n;y(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return ny(this)}}un=new WeakMap;class Oo{constructor(e,t){E(this,"provider");E(this,"transactionHash");E(this,"blockHash");E(this,"blockNumber");E(this,"removed");E(this,"address");E(this,"data");E(this,"topics");E(this,"index");E(this,"transactionIndex");this.provider=t;const n=Object.freeze(e.topics.slice());F(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:l}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return I(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return I(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return I(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return ry(this)}}var po;class Af{constructor(e,t){E(this,"provider");E(this,"to");E(this,"from");E(this,"contractAddress");E(this,"hash");E(this,"index");E(this,"blockHash");E(this,"blockNumber");E(this,"logsBloom");E(this,"gasUsed");E(this,"blobGasUsed");E(this,"cumulativeGasUsed");E(this,"gasPrice");E(this,"blobGasPrice");E(this,"type");E(this,"status");E(this,"root");A(this,po,void 0);p(this,po,Object.freeze(e.logs.map(s=>new Oo(s,t))));let n=bf;e.effectiveGasPrice!=null?n=e.effectiveGasPrice:e.gasPrice!=null&&(n=e.gasPrice),F(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return u(this,po)}toJSON(){const{to:e,from:t,contractAddress:n,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:l,status:h,root:d}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:n,cumulativeGasUsed:oe(this.cumulativeGasUsed),from:t,gasPrice:oe(this.gasPrice),blobGasUsed:oe(this.blobGasUsed),blobGasPrice:oe(this.blobGasPrice),gasUsed:oe(this.gasUsed),hash:s,index:i,logs:l,logsBloom:c,root:d,status:h,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Cf(this)}reorderedEvent(e){return I(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Ef(this,e)}}po=new WeakMap;var Dn;const iu=class iu{constructor(e,t){E(this,"provider");E(this,"blockNumber");E(this,"blockHash");E(this,"index");E(this,"hash");E(this,"type");E(this,"to");E(this,"from");E(this,"nonce");E(this,"gasLimit");E(this,"gasPrice");E(this,"maxPriorityFeePerGas");E(this,"maxFeePerGas");E(this,"maxFeePerBlobGas");E(this,"data");E(this,"value");E(this,"chainId");E(this,"signature");E(this,"accessList");E(this,"blobVersionedHashes");A(this,Dn,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,p(this,Dn,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:s,type:i,to:o,from:a,nonce:c,data:l,signature:h,accessList:d,blobVersionedHashes:f}=this;return{_type:"TransactionResponse",accessList:d,blockNumber:e,blockHash:t,blobVersionedHashes:f,chainId:oe(this.chainId),data:l,from:a,gasLimit:oe(this.gasLimit),gasPrice:oe(this.gasPrice),hash:s,maxFeePerGas:oe(this.maxFeePerGas),maxPriorityFeePerGas:oe(this.maxPriorityFeePerGas),maxFeePerBlobGas:oe(this.maxFeePerBlobGas),nonce:c,signature:h,to:o,index:n,type:i,value:oe(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const n=await this.getTransaction();n&&(e=n.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:n}=await Te({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:n-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const n=e??1,s=t??0;let i=u(this,Dn),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:f,nonce:g}=await Te({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(g<this.nonce){i=f;return}if(a)return null;const w=await this.getTransaction();if(!(w&&w.blockNumber!=null))for(o===-1&&(o=i-3,o<u(this,Dn)&&(o=u(this,Dn)));o<=f;){if(a)return null;const m=await this.provider.getBlock(o,!0);if(m==null)return;for(const C of m)if(C===this.hash)return;for(let C=0;C<m.length;C++){const v=await m.getTransaction(C);if(v.from===this.from&&v.nonce===this.nonce){if(a)return null;const k=await this.provider.getTransactionReceipt(v.hash);if(k==null||f-k.blockNumber+1<n)return;let S="replaced";v.data===this.data&&v.to===this.to&&v.value===this.value?S="repriced":v.data==="0x"&&v.from===v.to&&v.value===bf&&(S="cancelled"),I(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:S==="replaced"||S==="cancelled",reason:S,replacement:v.replaceableTransaction(i),hash:v.hash,receipt:k})}}o++}},l=f=>{if(f==null||f.status!==0)return f;I(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:f.to,from:f.from,data:""},receipt:f})},h=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(h);if(h){if(await h.confirmations()>=n)return l(h)}else if(await c(),n===0)return null;return await new Promise((f,g)=>{const w=[],m=()=>{w.forEach(v=>v())};if(w.push(()=>{a=!0}),s>0){const v=setTimeout(()=>{m(),g(ne("wait for transaction timeout","TIMEOUT"))},s);w.push(()=>{clearTimeout(v)})}const C=async v=>{if(await v.confirmations()>=n){m();try{f(l(v))}catch(k){g(k)}}};if(w.push(()=>{this.provider.off(this.hash,C)}),this.provider.on(this.hash,C),i>=0){const v=async()=>{try{await c()}catch(k){if(ke(k,"TRANSACTION_REPLACED")){m(),g(k);return}}a||this.provider.once("block",v)};w.push(()=>{this.provider.off("block",v)}),this.provider.once("block",v)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return I(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Cf(this)}reorderedEvent(e){return I(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),I(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ef(this,e)}replaceableTransaction(e){y(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new iu(this,this.provider);return p(t,Dn,e),t}};Dn=new WeakMap;let to=iu;function ny(r){return{orphan:"drop-block",hash:r.hash,number:r.number}}function Ef(r,e){return{orphan:"reorder-transaction",tx:r,other:e}}function Cf(r){return{orphan:"drop-transaction",tx:r}}function ry(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class Wl extends Oo{constructor(t,n,s){super(t,t.provider);E(this,"interface");E(this,"fragment");E(this,"args");const i=n.decodeEventLog(s,t.data,t.topics);F(this,{args:i,fragment:s,interface:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class vf extends Oo{constructor(t,n){super(t,t.provider);E(this,"error");F(this,{error:n})}}var ni;class sy extends Af{constructor(t,n,s){super(s,n);A(this,ni,void 0);p(this,ni,t)}get logs(){return super.logs.map(t=>{const n=t.topics.length?u(this,ni).getEvent(t.topics[0]):null;if(n)try{return new Wl(t,u(this,ni),n)}catch(s){return new vf(t,s)}return t})}}ni=new WeakMap;var go;class Vl extends to{constructor(t,n,s){super(s,n);A(this,go,void 0);p(this,go,t)}async wait(t,n){const s=await super.wait(t,n);return s==null?null:new sy(u(this,go),this.provider,s)}}go=new WeakMap;class If extends Jh{constructor(t,n,s,i){super(t,n,s);E(this,"log");F(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class iy extends If{constructor(e,t,n,s,i){super(e,t,n,new Wl(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);F(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const uh=BigInt(0);function Nf(r){return r&&typeof r.call=="function"}function Sf(r){return r&&typeof r.estimateGas=="function"}function za(r){return r&&typeof r.resolveName=="function"}function kf(r){return r&&typeof r.sendTransaction=="function"}function xf(r){if(r!=null){if(za(r))return r;if(r.provider)return r.provider}}var mo;class oy{constructor(e,t,n){A(this,mo,void 0);E(this,"fragment");if(F(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const s=zr(e.runner,"resolveName"),i=za(s)?s:null;p(this,mo,async function(){const o=await Promise.all(t.inputs.map((a,c)=>n[c]==null?null:a.walkAsync(n[c],(h,d)=>h==="address"?Array.isArray(d)?Promise.all(d.map(f=>Me(f,i))):Me(d,i):d)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return u(this,mo)}}mo=new WeakMap;function zr(r,e){return r==null?null:typeof r[e]=="function"?r:r.provider&&typeof r.provider[e]=="function"?r.provider:null}function pr(r){return r==null?null:r.provider||null}async function Pf(r,e){const t=xe.dereference(r,"overrides");y(typeof t=="object","invalid overrides parameter","overrides",r);const n=va(t);return y(n.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),y(n.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function ay(r,e,t){const n=zr(r,"resolveName"),s=za(n)?n:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,c)=>(c=xe.dereference(c,a),a==="address"?Me(c,s):c))))}function cy(r){const e=async function(o){const a=await Pf(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await Me(a.from,xf(r.runner)));const c=r.interface,l=_(a.value||uh,"overrides.value")===uh,h=(a.data||"0x")==="0x";c.fallback&&!c.fallback.payable&&c.receive&&!h&&!l&&y(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),y(c.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data);const d=c.receive||c.fallback&&c.fallback.payable;return y(d||l,"cannot send value to non-payable fallback","overrides.value",a.value),y(c.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=zr(r.runner,"call");I(Nf(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const c=await e(o);try{return await a.call(c)}catch(l){throw kl(l)&&l.data?r.interface.makeError(l.data,c):l}},n=async function(o){const a=r.runner;I(kf(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const c=await a.sendTransaction(await e(o)),l=pr(r.runner);return new Vl(r.interface,l,c)},s=async function(o){const a=zr(r.runner,"estimateGas");return I(Sf(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await n(o);return F(i,{_contract:r,estimateGas:s,populateTransaction:e,send:n,staticCall:t}),i}function ly(r,e){const t=function(...l){const h=r.interface.getFunction(e,l);return I(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:l}}),h},n=async function(...l){const h=t(...l);let d={};if(h.inputs.length+1===l.length&&(d=await Pf(l.pop()),d.from&&(d.from=await Me(d.from,xf(r.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const f=await ay(r.runner,h.inputs,l);return Object.assign({},d,await Te({to:r.getAddress(),data:r.interface.encodeFunctionData(h,f)}))},s=async function(...l){const h=await a(...l);return h.length===1?h[0]:h},i=async function(...l){const h=r.runner;I(kf(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const d=await h.sendTransaction(await n(...l)),f=pr(r.runner);return new Vl(r.interface,f,d)},o=async function(...l){const h=zr(r.runner,"estimateGas");return I(Sf(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},a=async function(...l){const h=zr(r.runner,"call");I(Nf(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const d=await n(...l);let f="0x";try{f=await h.call(d)}catch(w){throw kl(w)&&w.data?r.interface.makeError(w.data,d):w}const g=t(...l);return r.interface.decodeFunctionResult(g,f)},c=async(...l)=>t(...l).constant?await s(...l):await i(...l);return F(c,{name:r.interface.getFunctionName(e),_contract:r,_key:e,getFragment:t,estimateGas:o,populateTransaction:n,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(c,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=r.interface.getFunction(e);return I(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),l}}),c}function uy(r,e){const t=function(...s){const i=r.interface.getEvent(e,s);return I(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},n=function(...s){return new oy(r,t(...s),s)};return F(n,{name:r.interface.getEventName(e),_contract:r,_key:e,getFragment:t}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=r.interface.getEvent(e);return I(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),n}const Ia=Symbol.for("_ethersInternal_contract"),Rf=new WeakMap;function hy(r,e){Rf.set(r[Ia],e)}function ze(r){return Rf.get(r[Ia])}function dy(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function Ql(r,e){let t,n=null;if(Array.isArray(e)){const i=function(o){if(X(o,32))return o;const a=r.interface.getEvent(o);return y(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?X(e,32)?t=[e]:(n=r.interface.getEvent(e),y(n,"unknown fragment","event",e),t=[n.topicHash]):dy(e)?t=await e.getTopicFilter():"fragment"in e?(n=e.fragment,t=[n.topicHash]):y(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:n,tag:s,topics:t}}async function Fi(r,e){const{subs:t}=ze(r);return t.get((await Ql(r,e)).tag)||null}async function hh(r,e,t){const n=pr(r.runner);I(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Ql(r,t),{addr:a,subs:c}=ze(r);let l=c.get(i);if(!l){const d={address:a||r,topics:o},f=C=>{let v=s;if(v==null)try{v=r.interface.getEvent(C.topics[0])}catch{}if(v){const k=v,S=s?r.interface.decodeEventLog(s,C.data,C.topics):[];pl(r,t,S,B=>new iy(r,B,t,k,C))}else pl(r,t,[],k=>new If(r,k,t,C))};let g=[];l={tag:i,listeners:[],start:()=>{g.length||g.push(n.on(d,f))},stop:async()=>{if(g.length==0)return;let C=g;g=[],await Promise.all(C),n.off(d,f)}},c.set(i,l)}return l}let fl=Promise.resolve();async function fy(r,e,t,n){await fl;const s=await Fi(r,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(t);n&&c.push(n(a?null:o));try{o.call(r,...c)}catch{}return!a}),s.listeners.length===0&&(s.stop(),ze(r).subs.delete(s.tag)),i>0}async function pl(r,e,t,n){try{await fl}catch{}const s=fy(r,e,t,n);return fl=s,await s}const Qo=["then"];var Z1;const Vi=class Vi{constructor(e,t,n,s){E(this,"target");E(this,"interface");E(this,"runner");E(this,"filters");E(this,Z1);E(this,"fallback");y(typeof e=="string"||Ld(e),"invalid value for Contract target","target",e),n==null&&(n=null);const i=dl.from(t);F(this,{target:e,runner:n,interface:i}),Object.defineProperty(this,Ia,{value:{}});let o,a=null,c=null;if(s){const d=pr(n);c=new Vl(this.interface,d,s)}let l=new Map;if(typeof e=="string")if(X(e))a=e,o=Promise.resolve(e);else{const d=zr(n,"resolveName");if(!za(d))throw ne("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=d.resolveName(e).then(f=>{if(f==null)throw ne("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return ze(this).addr=f,f})}else o=e.getAddress().then(d=>{if(d==null)throw new Error("TODO");return ze(this).addr=d,d});hy(this,{addrPromise:o,addr:a,deployTx:c,subs:l});const h=new Proxy({},{get:(d,f,g)=>{if(typeof f=="symbol"||Qo.indexOf(f)>=0)return Reflect.get(d,f,g);try{return this.getEvent(f)}catch(w){if(!ke(w,"INVALID_ARGUMENT")||w.argument!=="key")throw w}},has:(d,f)=>Qo.indexOf(f)>=0?Reflect.has(d,f):Reflect.has(d,f)||this.interface.hasEvent(String(f))});return F(this,{filters:h}),F(this,{fallback:i.receive||i.fallback?cy(this):null}),new Proxy(this,{get:(d,f,g)=>{if(typeof f=="symbol"||f in d||Qo.indexOf(f)>=0)return Reflect.get(d,f,g);try{return d.getFunction(f)}catch(w){if(!ke(w,"INVALID_ARGUMENT")||w.argument!=="key")throw w}},has:(d,f)=>typeof f=="symbol"||f in d||Qo.indexOf(f)>=0?Reflect.has(d,f):d.interface.hasFunction(f)})}connect(e){return new Vi(this.target,this.interface,e)}attach(e){return new Vi(e,this.interface,this.runner)}async getAddress(){return await ze(this).addrPromise}async getDeployedCode(){const e=pr(this.runner);I(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=pr(this.runner);return I(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);n.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return ze(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),ly(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),uy(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,n){t==null&&(t=0),n==null&&(n="latest");const{addr:s,addrPromise:i}=ze(this),o=s||await i,{fragment:a,topics:c}=await Ql(this,e),l={address:o,topics:c,fromBlock:t,toBlock:n},h=pr(this.runner);return I(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(l)).map(d=>{let f=a;if(f==null)try{f=this.interface.getEvent(d.topics[0])}catch{}if(f)try{return new Wl(d,this.interface,f)}catch(g){return new vf(d,g)}return new Oo(d,h)})}async on(e,t){const n=await hh(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await hh(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await pl(this,e,t,null)}async listenerCount(e){if(e){const s=await Fi(this,e);return s?s.listeners.length:0}const{subs:t}=ze(this);let n=0;for(const{listeners:s}of t.values())n+=s.length;return n}async listeners(e){if(e){const s=await Fi(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=ze(this);let n=[];for(const{listeners:s}of t.values())n=n.concat(s.map(({listener:i})=>i));return n}async off(e,t){const n=await Fi(this,e);if(!n)return this;if(t){const s=n.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(t==null||n.listeners.length===0)&&(n.stop(),ze(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await Fi(this,e);if(!t)return this;t.stop(),ze(this).subs.delete(t.tag)}else{const{subs:t}=ze(this);for(const{tag:n,stop:s}of t.values())s(),t.delete(n)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Vi{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,n){return n==null&&(n=null),new this(e,t,n)}};Z1=Ia;let gl=Vi;function py(){return gl}class Ss extends py(){}function Bc(r){return r.match(/^ipfs:\/\/ipfs\//i)?r=r.substring(12):r.match(/^ipfs:\/\//i)?r=r.substring(7):y(!1,"unsupported IPFS format","link",r),`https://gateway.ipfs.io/ipfs/${r}`}class gy{constructor(e){E(this,"name");F(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const Of=new RegExp("^(ipfs)://(.*)$","i"),dh=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Of,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];var Fn,kr,Hn,ds,Ba,Tf;const bs=class bs{constructor(e,t,n){A(this,Hn);E(this,"provider");E(this,"address");E(this,"name");A(this,Fn,void 0);A(this,kr,void 0);F(this,{provider:e,address:t,name:n}),p(this,Fn,null),p(this,kr,new Ss(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return u(this,Fn)==null&&p(this,Fn,(async()=>{try{return await u(this,kr).supportsInterface("0x9061b923")}catch(e){if(ke(e,"CALL_EXCEPTION"))return!1;throw p(this,Fn,null),e}})()),await u(this,Fn)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await N(this,Hn,ds).call(this,"addr(bytes32)");return i==null||i===zi?null:i}catch(i){if(ke(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await N(this,Hn,ds).call(this,"addr(bytes32,uint)",[i]);if(X(o,20))return $(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof gy&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const n=await N(this,Hn,ds).call(this,"addr(bytes32,uint)",[e]);if(n==null||n==="0x")return null;const s=await t.decodeAddress(e,n);if(s!=null)return s;I(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){const t=await N(this,Hn,ds).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await N(this,Hn,ds).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${vp("0x"+t[2])}`}const n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;I(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let n=0;n<dh.length;n++){const s=t.match(dh[n]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=Bc(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const c=(s[2]||"").split("/");if(c.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const l=c[1],h=new Ss(c[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const m=await h.ownerOf(l);if(a!==m)return e.push({type:"!owner",value:m}),{url:null,linkage:e};e.push({type:"owner",value:m})}else if(i==="erc1155"){const m=await h.balanceOf(a,l);if(!m)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:m.toString()})}let d=await h[o](l);if(d==null||d==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:d}),i==="erc1155"&&(d=d.replace("{id}",Xn(l,32).substring(2)),e.push({type:"metadata-url-expanded",value:d})),d.match(/^ipfs:/i)&&(d=Bc(d)),e.push({type:"metadata-url",value:d});let f={};const g=await new Qt(d).send();g.assertOk();try{f=g.bodyJson}catch{try{e.push({type:"!metadata",value:g.bodyText})}catch{const v=g.body;return v&&e.push({type:"!metadata",value:T(v)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!f)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(f)});let w=f.image;if(typeof w!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!w.match(/^(https:\/\/|data:)/i)){if(w.match(Of)==null)return e.push({type:"!imageUrl-ipfs",value:w}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:w}),w=Bc(w)}return e.push({type:"url",value:w}),{linkage:e,url:w}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),n=t.getPlugin("org.ethers.plugins.network.Ens");return I(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),n.address}static async fromName(e,t){var s;let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const i=await N(s=bs,Ba,Tf).call(s,e,n);if(i!=null){const o=new bs(e,i,t);return n!==t&&!await o.supportsWildcard()?null:o}n=n.split(".").slice(1).join(".")}}};Fn=new WeakMap,kr=new WeakMap,Hn=new WeakSet,ds=async function(e,t){t=(t||[]).slice();const n=u(this,kr).interface;t.unshift(ul(this.name));let s=null;await this.supportsWildcard()&&(s=n.getFunction(e),I(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[pm(this.name,255),n.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await u(this,kr)[e](...t);return s?n.decodeFunctionResult(s,i)[0]:i}catch(i){if(!ke(i,"CALL_EXCEPTION"))throw i}return null},Ba=new WeakSet,Tf=async function(e,t){const n=await bs.getEnsAddress(e);try{const i=await new Ss(n,["function resolver(bytes32) view returns (address)"],e).resolver(ul(t),{enableCcipRead:!0});return i===zi?null:i}catch(s){throw s}return null},A(bs,Ba);let Na=bs;const fh=BigInt(0);function W(r,e){return function(t){return t==null?e:r(t)}}function Ja(r,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(n=>r(n))}}function To(r,e){return t=>{const n={};for(const s in r){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=r[s](t[i]);o!==void 0&&(n[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";I(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return n}}function my(r){switch(r){case!0:case"true":return!0;case!1:case"false":return!1}y(!1,`invalid boolean; ${JSON.stringify(r)}`,"value",r)}function Si(r){return y(X(r,!0),"invalid data","value",r),r}function Ee(r){return y(X(r,32),"invalid hash","value",r),r}const yy=To({address:$,blockHash:Ee,blockNumber:H,data:Si,index:H,removed:W(my,!1),topics:Ja(Ee),transactionHash:Ee,transactionIndex:H},{index:["logIndex"]});function wy(r){return yy(r)}const by=To({hash:W(Ee),parentHash:Ee,parentBeaconBlockRoot:W(Ee,null),number:H,timestamp:H,nonce:W(Si),difficulty:_,gasLimit:_,gasUsed:_,stateRoot:W(Ee,null),receiptsRoot:W(Ee,null),blobGasUsed:W(_,null),excessBlobGas:W(_,null),miner:W($),prevRandao:W(Ee,null),extraData:Si,baseFeePerGas:W(_)},{prevRandao:["mixHash"]});function Ay(r){const e=by(r);return e.transactions=r.transactions.map(t=>typeof t=="string"?t:Bf(t)),e}const Ey=To({transactionIndex:H,blockNumber:H,transactionHash:Ee,address:$,topics:Ja(Ee),data:Si,index:H,blockHash:Ee},{index:["logIndex"]});function Cy(r){return Ey(r)}const vy=To({to:W($,null),from:W($,null),contractAddress:W($,null),index:H,root:W(T),gasUsed:_,blobGasUsed:W(_,null),logsBloom:W(Si),blockHash:Ee,hash:Ee,logs:Ja(Cy),blockNumber:H,cumulativeGasUsed:_,effectiveGasPrice:W(_),blobGasPrice:W(_,null),status:W(H),type:W(H,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function Iy(r){return vy(r)}function Bf(r){r.to&&_(r.to)===fh&&(r.to="0x0000000000000000000000000000000000000000");const e=To({hash:Ee,index:W(H,void 0),type:t=>t==="0x"||t==null?0:H(t),accessList:W(qr,null),blobVersionedHashes:W(Ja(Ee,!0),null),blockHash:W(Ee,null),blockNumber:W(H,null),transactionIndex:W(H,null),from:$,gasPrice:W(_),maxPriorityFeePerGas:W(_),maxFeePerGas:W(_),maxFeePerBlobGas:W(_,null),gasLimit:_,to:W($,null),value:_,nonce:H,data:Si,creates:W($,null),chainId:W(_,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(r);if(e.to==null&&e.creates==null&&(e.creates=y0(e)),(r.type===1||r.type===2)&&r.accessList==null&&(e.accessList=[]),r.signature?e.signature=It.from(r.signature):e.signature=It.from(r),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&_(e.blockHash)===fh&&(e.blockHash=null),e}const Ny="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Bo{constructor(e){E(this,"name");F(this,{name:e})}clone(){return new Bo(this.name)}}class qa extends Bo{constructor(t,n){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);E(this,"effectiveBlock");E(this,"txBase");E(this,"txCreate");E(this,"txDataZero");E(this,"txDataNonzero");E(this,"txAccessListStorageKey");E(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let c=(n||{})[o];c==null&&(c=a),y(typeof c=="number",`invalud value for ${o}`,"costs",n),s[o]=c}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),F(this,s)}clone(){return new qa(this.effectiveBlock,this)}}class Za extends Bo{constructor(t,n){super("org.ethers.plugins.network.Ens");E(this,"address");E(this,"targetNetwork");F(this,{address:t||Ny,targetNetwork:n??1})}clone(){return new Za(this.address,this.targetNetwork)}}var yo,wo;class Sy extends Bo{constructor(t,n){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");A(this,yo,void 0);A(this,wo,void 0);p(this,yo,t),p(this,wo,n)}get url(){return u(this,yo)}get processFunc(){return u(this,wo)}clone(){return this}}yo=new WeakMap,wo=new WeakMap;const _c=new Map;var ri,si,Gn;const As=class As{constructor(e,t){A(this,ri,void 0);A(this,si,void 0);A(this,Gn,void 0);p(this,ri,e),p(this,si,_(t)),p(this,Gn,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return u(this,ri)}set name(e){p(this,ri,e)}get chainId(){return u(this,si)}set chainId(e){p(this,si,_(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===_(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===_(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===_(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(u(this,Gn).values())}attachPlugin(e){if(u(this,Gn).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return u(this,Gn).set(e.name,e.clone()),this}getPlugin(e){return u(this,Gn).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new As(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new qa;let n=t.txBase;if(e.to==null&&(n+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){const s=qr(e.accessList);for(const i in s)n+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return n}static from(e){if(ky(),e==null)return As.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=_c.get(e);if(t)return t();if(typeof e=="bigint")return new As("unknown",e);y(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){y(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new As(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Za(e.ensAddress,e.ensNetwork)),t}y(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=_c.get(e);n&&y(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),_c.set(e,t)}};ri=new WeakMap,si=new WeakMap,Gn=new WeakMap;let vt=As;function ph(r,e){const t=String(r);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${r}`);const n=t.split(".");if(n.length===1&&n.push(""),n.length!==2)throw new Error(`invalid gwei value: ${r}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let s=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||s++,n[1]=s.toString()}return BigInt(n[0]+n[1])}function gh(r){return new Sy(r,async(e,t,n)=>{n.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([n.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:ph(a.maxFee,9),maxPriorityFeePerGas:ph(a.maxPriorityFee,9)}}catch(i){I(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:s,error:i})}})}let mh=!1;function ky(){if(mh)return;mh=!0;function r(e,t,n){const s=function(){const i=new vt(e,t);return n.ensNetwork!=null&&i.attachPlugin(new Za(null,n.ensNetwork)),i.attachPlugin(new qa),(n.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};vt.register(e,s),vt.register(t,s),n.altNames&&n.altNames.forEach(i=>{vt.register(i,s)})}r("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),r("ropsten",3,{ensNetwork:3}),r("rinkeby",4,{ensNetwork:4}),r("goerli",5,{ensNetwork:5}),r("kovan",42,{ensNetwork:42}),r("sepolia",11155111,{ensNetwork:11155111}),r("holesky",17e3,{ensNetwork:17e3}),r("classic",61,{}),r("classicKotti",6,{}),r("arbitrum",42161,{ensNetwork:1}),r("arbitrum-goerli",421613,{}),r("arbitrum-sepolia",421614,{}),r("base",8453,{ensNetwork:1}),r("base-goerli",84531,{}),r("base-sepolia",84532,{}),r("bnb",56,{ensNetwork:1}),r("bnbt",97,{}),r("linea",59144,{ensNetwork:1}),r("linea-goerli",59140,{}),r("linea-sepolia",59141,{}),r("matic",137,{ensNetwork:1,plugins:[gh("https://gasstation.polygon.technology/v2")]}),r("matic-amoy",80002,{}),r("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[gh("https://gasstation-testnet.polygon.technology/v2")]}),r("optimism",10,{ensNetwork:1,plugins:[]}),r("optimism-goerli",420,{}),r("optimism-sepolia",11155420,{}),r("xdai",100,{ensNetwork:1})}function ml(r){return JSON.parse(JSON.stringify(r))}var hn,rt,Kn,Ut,ii,aa;class xy{constructor(e){A(this,ii);A(this,hn,void 0);A(this,rt,void 0);A(this,Kn,void 0);A(this,Ut,void 0);p(this,hn,e),p(this,rt,null),p(this,Kn,4e3),p(this,Ut,-2)}get pollingInterval(){return u(this,Kn)}set pollingInterval(e){p(this,Kn,e)}start(){u(this,rt)||(p(this,rt,u(this,hn)._setTimeout(N(this,ii,aa).bind(this),u(this,Kn))),N(this,ii,aa).call(this))}stop(){u(this,rt)&&(u(this,hn)._clearTimeout(u(this,rt)),p(this,rt,null))}pause(e){this.stop(),e&&p(this,Ut,-2)}resume(){this.start()}}hn=new WeakMap,rt=new WeakMap,Kn=new WeakMap,Ut=new WeakMap,ii=new WeakSet,aa=async function(){try{const e=await u(this,hn).getBlockNumber();if(u(this,Ut)===-2){p(this,Ut,e);return}if(e!==u(this,Ut)){for(let t=u(this,Ut)+1;t<=e;t++){if(u(this,rt)==null)return;await u(this,hn).emit("block",t)}p(this,Ut,e)}}catch{}u(this,rt)!=null&&p(this,rt,u(this,hn)._setTimeout(N(this,ii,aa).bind(this),u(this,Kn)))};var xr,Pr,jn;class zl{constructor(e){A(this,xr,void 0);A(this,Pr,void 0);A(this,jn,void 0);p(this,xr,e),p(this,jn,!1),p(this,Pr,t=>{this._poll(t,u(this,xr))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){u(this,jn)||(p(this,jn,!0),u(this,Pr).call(this,-2),u(this,xr).on("block",u(this,Pr)))}stop(){u(this,jn)&&(p(this,jn,!1),u(this,xr).off("block",u(this,Pr)))}pause(e){this.stop()}resume(){this.start()}}xr=new WeakMap,Pr=new WeakMap,jn=new WeakMap;var oi,dn;class Py extends zl{constructor(t,n){super(t);A(this,oi,void 0);A(this,dn,void 0);p(this,oi,n),p(this,dn,-2)}pause(t){t&&p(this,dn,-2),super.pause(t)}async _poll(t,n){const s=await n.getBlock(u(this,oi));s!=null&&(u(this,dn)===-2?p(this,dn,s.number):s.number>u(this,dn)&&(n.emit(u(this,oi),s.number),p(this,dn,s.number)))}}oi=new WeakMap,dn=new WeakMap;var _a;class Ry extends zl{constructor(t,n){super(t);A(this,_a,void 0);p(this,_a,ml(n))}async _poll(t,n){throw new Error("@TODO")}}_a=new WeakMap;var ai;class Oy extends zl{constructor(t,n){super(t);A(this,ai,void 0);p(this,ai,n)}async _poll(t,n){const s=await n.getTransactionReceipt(u(this,ai));s&&n.emit(u(this,ai),s)}}ai=new WeakMap;var fn,ci,li,Wn,st,La,_f;class Jl{constructor(e,t){A(this,La);A(this,fn,void 0);A(this,ci,void 0);A(this,li,void 0);A(this,Wn,void 0);A(this,st,void 0);p(this,fn,e),p(this,ci,ml(t)),p(this,li,N(this,La,_f).bind(this)),p(this,Wn,!1),p(this,st,-2)}start(){u(this,Wn)||(p(this,Wn,!0),u(this,st)===-2&&u(this,fn).getBlockNumber().then(e=>{p(this,st,e)}),u(this,fn).on("block",u(this,li)))}stop(){u(this,Wn)&&(p(this,Wn,!1),u(this,fn).off("block",u(this,li)))}pause(e){this.stop(),e&&p(this,st,-2)}resume(){this.start()}}fn=new WeakMap,ci=new WeakMap,li=new WeakMap,Wn=new WeakMap,st=new WeakMap,La=new WeakSet,_f=async function(e){if(u(this,st)===-2)return;const t=ml(u(this,ci));t.fromBlock=u(this,st)+1,t.toBlock=e;const n=await u(this,fn).getLogs(t);if(n.length===0){u(this,st)<e-60&&p(this,st,e-60);return}for(const s of n)u(this,fn).emit(u(this,ci),s),p(this,st,s.blockNumber)};const Ty=BigInt(2),By=10;function zo(r){return r&&typeof r.then=="function"}function ca(r,e){return r+":"+JSON.stringify(e,(t,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const s=Object.keys(n);return s.sort(),s.reduce((i,o)=>(i[o]=n[o],i),{})}return n})}class Sa{constructor(e){E(this,"name");F(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function _y(r){return JSON.parse(JSON.stringify(r))}function yl(r){return r=Array.from(new Set(r).values()),r.sort(),r}async function Lc(r,e){if(r==null)throw new Error("invalid event");if(Array.isArray(r)&&(r={topics:r}),typeof r=="string")switch(r){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:r,tag:r}}if(X(r,32)){const t=r.toLowerCase();return{type:"transaction",tag:ca("tx",{hash:t}),hash:t}}if(r.orphan){const t=r;return{type:"orphan",tag:ca("orphan",t),filter:_y(t)}}if(r.address||r.topics){const t=r,n={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?yl(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{X(a)?s.push(a):i.push((async()=>{s.push(await Me(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),n.address=yl(s.map(a=>a.toLowerCase()))}return{filter:n,tag:ca("event",n),type:"event"}}y(!1,"unknown ProviderEvent","event",r)}function Uc(){return new Date().getTime()}const Ly={cacheTimeout:250,pollingInterval:4e3};var Ie,Vn,Ne,ui,$e,Rr,Qn,pn,bo,it,hi,di,Re,Qe,Ao,wl,Eo,bl,Or,Hi,Co,Al,Tr,Gi,fi,la;class Uy{constructor(e,t){A(this,Re);A(this,Ao);A(this,Eo);A(this,Or);A(this,Co);A(this,Tr);A(this,fi);A(this,Ie,void 0);A(this,Vn,void 0);A(this,Ne,void 0);A(this,ui,void 0);A(this,$e,void 0);A(this,Rr,void 0);A(this,Qn,void 0);A(this,pn,void 0);A(this,bo,void 0);A(this,it,void 0);A(this,hi,void 0);A(this,di,void 0);if(p(this,di,Object.assign({},Ly,t||{})),e==="any")p(this,Rr,!0),p(this,$e,null);else if(e){const n=vt.from(e);p(this,Rr,!1),p(this,$e,Promise.resolve(n)),setTimeout(()=>{this.emit("network",n,null)},0)}else p(this,Rr,!1),p(this,$e,null);p(this,pn,-1),p(this,Qn,new Map),p(this,Ie,new Map),p(this,Vn,new Map),p(this,Ne,null),p(this,ui,!1),p(this,bo,1),p(this,it,new Map),p(this,hi,!1)}get pollingInterval(){return u(this,di).pollingInterval}get provider(){return this}get plugins(){return Array.from(u(this,Vn).values())}attachPlugin(e){if(u(this,Vn).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return u(this,Vn).set(e.name,e.connect(this)),this}getPlugin(e){return u(this,Vn).get(e)||null}get disableCcipRead(){return u(this,hi)}set disableCcipRead(e){p(this,hi,!!e)}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<n.length;a++){const c=n[a],l=c.replace("{sender}",s).replace("{data}",i),h=new Qt(l);c.indexOf("{data}")===-1&&(h.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:a,urls:n});let d="unknown error";const f=await h.send();try{const g=f.bodyJson;if(g.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:g}),g.data;g.message&&(d=g.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:g})}catch{}I(f.statusCode<400||f.statusCode>=500,`response not found during CCIP fetch: ${d}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:c,errorMessage:d}}),o.push(d)}I(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:n,errorMessages:o}})}_wrapBlock(e,t){return new ty(Ay(e),this)}_wrapLog(e,t){return new Oo(wy(e),this)}_wrapTransactionReceipt(e,t){return new Af(Iy(e),this)}_wrapTransactionResponse(e,t){return new to(Bf(e),this)}_detectNetwork(){I(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){I(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=H(await N(this,Re,Qe).call(this,{method:"getBlockNumber"}),"%response");return u(this,pn)>=0&&p(this,pn,e),e}_getAddress(e){return Me(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(X(e))return X(e,32)?e:gs(e);if(typeof e=="bigint"&&(e=H(e,"blockTag")),typeof e=="number")return e>=0?gs(e):u(this,pn)>=0?gs(u(this,pn)+e):this.getBlockNumber().then(t=>gs(t+e));y(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(c=>c==null?null:Array.isArray(c)?yl(c.map(l=>l.toLowerCase())):c.toLowerCase()),n="blockHash"in e?e.blockHash:void 0,s=(c,l,h)=>{let d;switch(c.length){case 0:break;case 1:d=c[0];break;default:c.sort(),d=c}if(n&&(l!=null||h!=null))throw new Error("invalid filter");const f={};return d&&(f.address=d),t.length&&(f.topics=t),l&&(f.fromBlock=l),h&&(f.toBlock=h),n&&(f.blockHash=n),f};let i=[];if(e.address)if(Array.isArray(e.address))for(const c of e.address)i.push(this._getAddress(c));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(c=>typeof c!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(c=>s(c[0],c[1],c[2])):s(i,o,a)}_getTransactionRequest(e){const t=va(e),n=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Me(t[s],this);zo(i)?n.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);zo(s)?n.push(async function(){t.blockTag=await s}()):t.blockTag=s}return n.length?async function(){return await Promise.all(n),t}():t}async getNetwork(){if(u(this,$e)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw u(this,$e)===s&&p(this,$e,null),i}})();return p(this,$e,s),(await s).clone()}const e=u(this,$e),[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(u(this,Rr)?(this.emit("network",n,t),u(this,$e)===e&&p(this,$e,Promise.resolve(n))):I(!1,`network changed: ${t.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await Te({_block:N(this,Co,Al).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await N(this,Re,Qe).call(this,{method:"getGasPrice"});return _(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await N(this,Re,Qe).call(this,{method:"getPriorityFee"});return _(h,"%response")}catch{}return null})()});let a=null,c=null;const l=this._wrapBlock(s,e);return l&&l.baseFeePerGas&&(c=o??BigInt("1000000000"),a=l.baseFeePerGas*Ty+c),new lh(i,a,c)},n=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const s=new Qt(n.url),i=await n.processFunc(t,this,s);return new lh(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return zo(t)&&(t=await t),_(await N(this,Re,Qe).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:n}=await Te({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await N(this,Eo,bl).call(this,N(this,Ao,wl).call(this,t,n,e.enableCcipRead?0:-1))}async getBalance(e,t){return _(await N(this,Or,Hi).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return H(await N(this,Or,Hi).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return T(await N(this,Or,Hi).call(this,{method:"getCode"},e,t))}async getStorage(e,t,n){const s=_(t,"position");return T(await N(this,Or,Hi).call(this,{method:"getStorage",position:s},e,n))}async broadcastTransaction(e){const{blockNumber:t,hash:n,network:s}=await Te({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=Ea.from(e);if(i.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:n,params:s}=await Te({network:this.getNetwork(),params:N(this,Co,Al).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,n)}async getTransaction(e){const{network:t,params:n}=await Te({network:this.getNetwork(),params:N(this,Re,Qe).call(this,{method:"getTransaction",hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){const{network:t,params:n}=await Te({network:this.getNetwork(),params:N(this,Re,Qe).call(this,{method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const s=await N(this,Re,Qe).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){const{result:t}=await Te({network:this.getNetwork(),result:N(this,Re,Qe).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:T(t)}async getLogs(e){let t=this._getFilter(e);zo(t)&&(t=await t);const{network:n,params:s}=await Te({network:this.getNetwork(),params:N(this,Re,Qe).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,n))}_getProvider(e){I(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Na.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=$(e);const t=ul(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await Na.getEnsAddress(this),i=await new Ss(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===zi)return null;const a=await new Ss(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(n){if(ke(n,"BAD_DATA")&&n.value==="0x"||ke(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(e,t,n){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const c=async l=>{try{const h=await this.getTransactionReceipt(e);if(h!=null&&l-h.blockNumber+1>=s){i(h),a&&(clearTimeout(a),a=null);return}}catch(h){console.log("EEE",h)}this.once("block",c)};n!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",c),o(ne("timeout","TIMEOUT",{reason:"timeout"})))},n)),c(await this.getBlockNumber())})}async waitForBlock(e){I(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=u(this,it).get(e);t&&(t.timer&&clearTimeout(t.timer),u(this,it).delete(e))}_setTimeout(e,t){t==null&&(t=0);const n=Ti(this,bo)._++,s=()=>{u(this,it).delete(n),e()};if(this.paused)u(this,it).set(n,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);u(this,it).set(n,{timer:i,func:s,time:Uc()})}return n}_forEachSubscriber(e){for(const t of u(this,Ie).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Sa(e.type);case"block":{const t=new xy(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Py(this,e.type);case"event":return new Jl(this,e.filter);case"transaction":return new Oy(this,e.hash);case"orphan":return new Ry(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const n of u(this,Ie).values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),u(this,Ne)!=null&&t.pause(u(this,Ne));break}}async on(e,t){const n=await N(this,fi,la).call(this,e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,u(this,Ne)!=null&&n.subscriber.pause(u(this,Ne))),this}async once(e,t){const n=await N(this,fi,la).call(this,e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,u(this,Ne)!=null&&n.subscriber.pause(u(this,Ne))),this}async emit(e,...t){const n=await N(this,Tr,Gi).call(this,e,t);if(!n||n.listeners.length===0)return!1;const s=n.listeners.length;return n.listeners=n.listeners.filter(({listener:i,once:o})=>{const a=new Jh(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),u(this,Ie).delete(n.tag)),s>0}async listenerCount(e){if(e){const n=await N(this,Tr,Gi).call(this,e);return n?n.listeners.length:0}let t=0;for(const{listeners:n}of u(this,Ie).values())t+=n.length;return t}async listeners(e){if(e){const n=await N(this,Tr,Gi).call(this,e);return n?n.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:n}of u(this,Ie).values())t=t.concat(n.map(({listener:s})=>s));return t}async off(e,t){const n=await N(this,Tr,Gi).call(this,e);if(!n)return this;if(t){const s=n.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),u(this,Ie).delete(n.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:n,subscriber:s}=await N(this,fi,la).call(this,e);n&&s.stop(),u(this,Ie).delete(t)}else for(const[t,{started:n,subscriber:s}]of u(this,Ie))n&&s.stop(),u(this,Ie).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return u(this,ui)}destroy(){this.removeAllListeners();for(const e of u(this,it).keys())this._clearTimeout(e);p(this,ui,!0)}get paused(){return u(this,Ne)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(p(this,pn,-1),u(this,Ne)!=null){if(u(this,Ne)==!!e)return;I(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),p(this,Ne,!!e);for(const t of u(this,it).values())t.timer&&clearTimeout(t.timer),t.time=Uc()-t.time}resume(){if(u(this,Ne)!=null){this._forEachSubscriber(e=>e.resume()),p(this,Ne,null);for(const e of u(this,it).values()){let t=e.time;t<0&&(t=0),e.time=Uc(),setTimeout(e.func,t)}}}}Ie=new WeakMap,Vn=new WeakMap,Ne=new WeakMap,ui=new WeakMap,$e=new WeakMap,Rr=new WeakMap,Qn=new WeakMap,pn=new WeakMap,bo=new WeakMap,it=new WeakMap,hi=new WeakMap,di=new WeakMap,Re=new WeakSet,Qe=async function(e){const t=u(this,di).cacheTimeout;if(t<0)return await this._perform(e);const n=ca(e.method,e);let s=u(this,Qn).get(n);return s||(s=this._perform(e),u(this,Qn).set(n,s),setTimeout(()=>{u(this,Qn).get(n)===s&&u(this,Qn).delete(n)},t)),await s},Ao=new WeakSet,wl=async function(e,t,n){I(n<By,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=va(e);try{return T(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&kl(i)&&i.data&&n>=0&&t==="latest"&&s.to!=null&&se(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Me(s.to,this);let c;try{c=Gy(se(i.data,4))}catch(d){I(!1,d.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}I(c.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:c.errorArgs}});const l=await this.ccipReadFetch(s,c.calldata,c.urls);I(l!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:c.errorArgs}});const h={to:a,data:le([c.selector,Hy([l,c.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const d=await N(this,Ao,wl).call(this,h,t,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:d}),d}catch(d){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:d}),d}}throw i}},Eo=new WeakSet,bl=async function(e){const{value:t}=await Te({network:this.getNetwork(),value:e});return t},Or=new WeakSet,Hi=async function(e,t,n){let s=this._getAddress(t),i=this._getBlockTag(n);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await N(this,Eo,bl).call(this,N(this,Re,Qe).call(this,Object.assign(e,{address:s,blockTag:i})))},Co=new WeakSet,Al=async function(e,t){if(X(e,32))return await N(this,Re,Qe).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await N(this,Re,Qe).call(this,{method:"getBlock",blockTag:n,includeTransactions:t})},Tr=new WeakSet,Gi=async function(e,t){let n=await Lc(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await Lc({orphan:"drop-log",log:t[0]},this)),u(this,Ie).get(n.tag)||null},fi=new WeakSet,la=async function(e){const t=await Lc(e,this),n=t.tag;let s=u(this,Ie).get(n);return s||(s={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},u(this,Ie).set(n,s)),s};function My(r,e){try{const t=El(r,e);if(t)return fa(t)}catch{}return null}function El(r,e){if(r==="0x")return null;try{const t=H(se(r,e,e+32)),n=H(se(r,t,t+32));return se(r,t+32,t+32+n)}catch{}return null}function yh(r){const e=Le(r);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function Dy(r){if(r.length%32===0)return r;const e=new Uint8Array(Math.ceil(r.length/32)*32);return e.set(r),e}const Fy=new Uint8Array([]);function Hy(r){const e=[];let t=0;for(let n=0;n<r.length;n++)e.push(Fy),t+=32;for(let n=0;n<r.length;n++){const s=V(r[n]);e[n]=yh(t),e.push(yh(s.length)),e.push(Dy(s)),t+=32+Math.ceil(s.length/32)*32}return le(e)}const wh="0x0000000000000000000000000000000000000000000000000000000000000000";function Gy(r){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};I(Cs(r)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=se(r,0,32);I(se(t,0,12)===se(wh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=se(t,12);try{const n=[],s=H(se(r,32,64)),i=H(se(r,s,s+32)),o=se(r,s+32);for(let a=0;a<i;a++){const c=My(o,a*32);if(c==null)throw new Error("abort");n.push(c)}e.urls=n}catch{I(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=El(r,64);if(n==null)throw new Error("abort");e.calldata=n}catch{I(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}I(se(r,100,128)===se(wh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=se(r,96,100);try{const n=El(r,128);if(n==null)throw new Error("abort");e.extraData=n}catch{I(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(n=>e[n]),e}function ss(r,e){if(r.provider)return r.provider;I(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function bh(r,e){let t=va(e);if(t.to!=null&&(t.to=Me(t.to,r)),t.from!=null){const n=t.from;t.from=Promise.all([r.getAddress(),Me(n,r)]).then(([s,i])=>(y(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=r.getAddress();return await Te(t)}class Ky{constructor(e){E(this,"provider");F(this,{provider:e||null})}async getNonce(e){return ss(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await bh(this,e)}async populateTransaction(e){const t=ss(this,"populateTransaction"),n=await bh(this,e);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const s=await this.provider.getNetwork();if(n.chainId!=null){const o=_(n.chainId);y(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else n.chainId=s.chainId;const i=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||i)?y(!1,"eip-1559 transaction do not support gasPrice","tx",e):(n.type===0||n.type===1)&&i&&y(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const o=await t.getFeeData();I(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(n.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(n.type=2,n.gasPrice!=null){const a=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=a,n.maxPriorityFeePerGas=a}else n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(I(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice),n.type=0):I(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(n.type===2||n.type===3)&&(n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await Te(n)}async estimateGas(e){return ss(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return ss(this,"call").call(await this.populateCall(e))}async resolveName(e){return await ss(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=ss(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const s=Ea.from(n);return await t.broadcastTransaction(await this.signTransaction(s))}}const Ah=new Set;function jy(r){Ah.has(r)||(Ah.add(r),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${r} (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.org/api-keys/"),console.log("=========================="))}function Wy(r){return JSON.parse(JSON.stringify(r))}var Oe,Mt,Br,zn,_r,pi,vo,Cl,Io,vl;class Lf{constructor(e){A(this,vo);A(this,Io);A(this,Oe,void 0);A(this,Mt,void 0);A(this,Br,void 0);A(this,zn,void 0);A(this,_r,void 0);A(this,pi,void 0);p(this,Oe,e),p(this,Mt,null),p(this,Br,N(this,vo,Cl).bind(this)),p(this,zn,!1),p(this,_r,null),p(this,pi,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){u(this,zn)||(p(this,zn,!0),N(this,vo,Cl).call(this,-2))}stop(){u(this,zn)&&(p(this,zn,!1),p(this,pi,!0),N(this,Io,vl).call(this),u(this,Oe).off("block",u(this,Br)))}pause(e){e&&N(this,Io,vl).call(this),u(this,Oe).off("block",u(this,Br))}resume(){this.start()}}Oe=new WeakMap,Mt=new WeakMap,Br=new WeakMap,zn=new WeakMap,_r=new WeakMap,pi=new WeakMap,vo=new WeakSet,Cl=async function(e){try{u(this,Mt)==null&&p(this,Mt,this._subscribe(u(this,Oe)));let t=null;try{t=await u(this,Mt)}catch(i){if(!ke(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){p(this,Mt,null),u(this,Oe)._recoverSubscriber(this,this._recover(u(this,Oe)));return}const n=await u(this,Oe).getNetwork();if(u(this,_r)||p(this,_r,n),u(this,_r).chainId!==n.chainId)throw new Error("chaid changed");if(u(this,pi))return;const s=await u(this,Oe).send("eth_getFilterChanges",[t]);await this._emitResults(u(this,Oe),s)}catch(t){console.log("@TODO",t)}u(this,Oe).once("block",u(this,Br))},Io=new WeakSet,vl=function(){const e=u(this,Mt);e&&(p(this,Mt,null),e.then(t=>{u(this,Oe).destroyed||u(this,Oe).send("eth_uninstallFilter",[t])}))};var Lr;class Vy extends Lf{constructor(t,n){super(t);A(this,Lr,void 0);p(this,Lr,Wy(n))}_recover(t){return new Jl(t,u(this,Lr))}async _subscribe(t){return await t.send("eth_newFilter",[u(this,Lr)])}async _emitResults(t,n){for(const s of n)t.emit(u(this,Lr),t._wrapLog(s,t._network))}}Lr=new WeakMap;class Qy extends Lf{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const zy="bigint,boolean,function,number,string,symbol".split(/,/g);function ua(r){if(r==null||zy.indexOf(typeof r)>=0||typeof r.getAddress=="function")return r;if(Array.isArray(r))return r.map(ua);if(typeof r=="object")return Object.keys(r).reduce((e,t)=>(e[t]=r[t],e),{});throw new Error(`should not happen: ${r} (${typeof r})`)}function Jy(r){return new Promise(e=>{setTimeout(e,r)})}function is(r){return r&&r.toLowerCase()}function Eh(r){return r&&typeof r.pollingInterval=="number"}const Uf={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class ks extends Ky{constructor(t,n){super(t);E(this,"address");n=$(n),F(this,{address:n})}connect(t){I(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const n=ua(t),s=[];if(n.from){const o=n.from;s.push((async()=>{const a=await Me(o,this.provider);y(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=a})())}else n.from=this.address;if(n.gasLimit==null&&s.push((async()=>{n.gasLimit=await this.provider.estimateGas({...n,from:this.address})})()),n.to!=null){const o=n.to;s.push((async()=>{n.to=await Me(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(n);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const n=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let c=0;const l=async()=>{try{const h=await this.provider.getTransaction(s);if(h!=null){i(h.replaceableTransaction(n));return}}catch(h){if(ke(h,"CANCELLED")||ke(h,"BAD_DATA")||ke(h,"NETWORK_ERROR")){h.info==null&&(h.info={}),h.info.sendTransactionHash=s,o(h);return}if(ke(h,"INVALID_ARGUMENT")&&(c++,h.info==null&&(h.info={}),h.info.sendTransactionHash=s,c>10)){o(h);return}this.provider.emit("error",ne("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{l()},a.pop()||4e3)};l()})}async signTransaction(t){const n=ua(t);if(n.from){const i=await Me(n.from,this.provider);y(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=i}else n.from=this.address;const s=this.provider.getRpcTransaction(n);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const n=typeof t=="string"?jt(t):t;return await this.provider.send("personal_sign",[T(n),this.address.toLowerCase()])}async signTypedData(t,n,s){const i=ua(s),o=await Ca.resolveNames(t,n,i,async a=>{const c=await Me(a);return y(c!=null,"TypedData does not support null address","value",a),c});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Ca.getPayload(o.domain,n,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const n=typeof t=="string"?jt(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),T(n)])}}var Ur,gi,gn,Dt,At,ot,He,No,Il;class Mf extends Uy{constructor(t,n){super(t,n);A(this,No);A(this,Ur,void 0);A(this,gi,void 0);A(this,gn,void 0);A(this,Dt,void 0);A(this,At,void 0);A(this,ot,void 0);A(this,He,void 0);p(this,gi,1),p(this,Ur,Object.assign({},Uf,n||{})),p(this,gn,[]),p(this,Dt,null),p(this,ot,null),p(this,He,null);{let i=null;const o=new Promise(a=>{i=a});p(this,At,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(y(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",n),s&&t!=null&&p(this,ot,vt.from(t))):s&&(y(t==null||s.matches(t),"staticNetwork MUST match network object","options",n),p(this,ot,s))}_getOption(t){return u(this,Ur)[t]}get _network(){return I(u(this,ot),"network is not available yet","NETWORK_ERROR"),u(this,ot)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&_(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const n=this.getRpcRequest(t);return n!=null?await this.send(n.method,n.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(u(this,ot))return u(this,ot)}else return t;return u(this,He)?await u(this,He):this.ready?(p(this,He,(async()=>{try{const n=vt.from(_(await this.send("eth_chainId",[])));return p(this,He,null),n}catch(n){throw p(this,He,null),n}})()),await u(this,He)):(p(this,He,(async()=>{const n={id:Ti(this,gi)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:n});let s;try{s=(await this._send(n))[0],p(this,He,null)}catch(i){throw p(this,He,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return vt.from(_(s.result));throw this.getRpcError(n,s)})()),await u(this,He))}_start(){u(this,At)==null||u(this,At).resolve==null||(u(this,At).resolve(),p(this,At,null),(async()=>{for(;u(this,ot)==null&&!this.destroyed;)try{p(this,ot,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",ne("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await Jy(1e3)}N(this,No,Il).call(this)})())}async _waitUntilReady(){if(u(this,At)!=null)return await u(this,At).promise}_getSubscriber(t){return t.type==="pending"?new Qy(this):t.type==="event"?this._getOption("polling")?new Jl(this,t.filter):new Vy(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Sa("orphan"):super._getSubscriber(t)}get ready(){return u(this,At)==null}getRpcTransaction(t){const n={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),n[i]=gs(_(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(n[s]=T(t[s]))}),t.accessList&&(n.accessList=qr(t.accessList)),t.blobVersionedHashes&&(n.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),n}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[is(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[is(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[is(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[is(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(is):t.filter.address=is(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,n){const{method:s}=t,{error:i}=n;if(s==="eth_estimateGas"&&i.message){const c=i.message;if(!c.match(/revert/i)&&c.match(/insufficient funds/i))return ne("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const c=Nl(i),l=eo.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],c?c.data:null);return l.info={error:i,payload:t},l}const o=JSON.stringify(qy(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return ne("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const c=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return ne("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:c,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return ne("nonce has already been used","NONCE_EXPIRED",{transaction:c,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return ne("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:c,info:{error:i}});if(o.match(/only replay-protected/i))return ne("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:c,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?ne("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):ne("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,n){if(this.destroyed)return Promise.reject(ne("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Ti(this,gi)._++,i=new Promise((o,a)=>{u(this,gn).push({resolve:o,reject:a,payload:{method:t,params:n,id:s,jsonrpc:"2.0"}})});return N(this,No,Il).call(this),i}async getSigner(t){t==null&&(t=0);const n=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await n;if(t>=i.length)throw new Error("no such account");return new ks(this,i[t])}const{accounts:s}=await Te({network:this.getNetwork(),accounts:n});t=$(t);for(const i of s)if($(i)===t)return new ks(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(n=>new ks(this,n))}destroy(){u(this,Dt)&&(clearTimeout(u(this,Dt)),p(this,Dt,null));for(const{payload:t,reject:n}of u(this,gn))n(ne("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));p(this,gn,[]),super.destroy()}}Ur=new WeakMap,gi=new WeakMap,gn=new WeakMap,Dt=new WeakMap,At=new WeakMap,ot=new WeakMap,He=new WeakMap,No=new WeakSet,Il=function(){if(u(this,Dt))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");p(this,Dt,setTimeout(()=>{p(this,Dt,null);const n=u(this,gn);for(p(this,gn,[]);n.length;){const s=[n.shift()];for(;n.length&&s.length!==u(this,Ur).batchMaxCount;)if(s.push(n.shift()),JSON.stringify(s.map(o=>o.payload)).length>u(this,Ur).batchMaxSize){n.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:c,payload:l}of s){if(this.destroyed){c(ne("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:l.method}));continue}const h=o.filter(d=>d.id===l.id)[0];if(h==null){const d=ne("missing response for request","BAD_DATA",{value:o,info:{payload:l}});this.emit("error",d),c(d);continue}if("error"in h){c(this.getRpcError(l,h));continue}a(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};var Jn;class Df extends Mf{constructor(t,n){super(t,n);A(this,Jn,void 0);let s=this._getOption("pollingInterval");s==null&&(s=Uf.pollingInterval),p(this,Jn,s)}_getSubscriber(t){const n=super._getSubscriber(t);return Eh(n)&&(n.pollingInterval=u(this,Jn)),n}get pollingInterval(){return u(this,Jn)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");p(this,Jn,t),this._forEachSubscriber(n=>{Eh(n)&&(n.pollingInterval=u(this,Jn))})}}Jn=new WeakMap;var mi;class Ff extends Df{constructor(t,n,s){t==null&&(t="http://localhost:8545");super(n,s);A(this,mi,void 0);typeof t=="string"?p(this,mi,new Qt(t)):p(this,mi,t.clone())}_getConnection(){return u(this,mi).clone()}async send(t,n){return await this._start(),await super.send(t,n)}async _send(t){const n=this._getConnection();n.body=JSON.stringify(t),n.setHeader("content-type","application/json");const s=await n.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}mi=new WeakMap;function Nl(r){if(r==null)return null;if(typeof r.message=="string"&&r.message.match(/revert/i)&&X(r.data))return{message:r.message,data:r.data};if(typeof r=="object"){for(const e in r){const t=Nl(r[e]);if(t)return t}return null}if(typeof r=="string")try{return Nl(JSON.parse(r))}catch{}return null}function Sl(r,e){if(r!=null){if(typeof r.message=="string"&&e.push(r.message),typeof r=="object")for(const t in r)Sl(r[t],e);if(typeof r=="string")try{return Sl(JSON.parse(r),e)}catch{}}}function qy(r){const e=[];return Sl(r,e),e}function Zy(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof b.global<"u")return b.global;throw new Error("unable to locate global object")}const $y=Zy().WebSocket;var Ft,So,qn,Mr,Zn;class ql{constructor(e,t){A(this,Ft,void 0);A(this,So,void 0);A(this,qn,void 0);A(this,Mr,void 0);A(this,Zn,void 0);p(this,Ft,e),p(this,So,JSON.stringify(t)),p(this,qn,null),p(this,Mr,null),p(this,Zn,null)}get filter(){return JSON.parse(u(this,So))}start(){p(this,qn,u(this,Ft).send("eth_subscribe",this.filter).then(e=>(u(this,Ft)._register(e,this),e)))}stop(){u(this,qn).then(e=>{u(this,Ft).destroyed||u(this,Ft).send("eth_unsubscribe",[e])}),p(this,qn,null)}pause(e){I(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),p(this,Mr,!!e)}resume(){p(this,Mr,null)}_handleMessage(e){if(u(this,qn)!=null&&u(this,Mr)===null){let t=u(this,Zn);t==null?t=this._emit(u(this,Ft),e):t=t.then(async()=>{await this._emit(u(this,Ft),e)}),p(this,Zn,t.then(()=>{u(this,Zn)===t&&p(this,Zn,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Ft=new WeakMap,So=new WeakMap,qn=new WeakMap,Mr=new WeakMap,Zn=new WeakMap;class Yy extends ql{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class Xy extends ql{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}var ko;class ew extends ql{constructor(t,n){super(t,["logs",n]);A(this,ko,void 0);p(this,ko,JSON.stringify(n))}get logFilter(){return JSON.parse(u(this,ko))}async _emit(t,n){t.emit(this.logFilter,t._wrapLog(n,t._network))}}ko=new WeakMap;var Dr,yi,$n;class tw extends Mf{constructor(t,n){const s=Object.assign({},n??{});y(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",n),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);A(this,Dr,void 0);A(this,yi,void 0);A(this,$n,void 0);p(this,Dr,new Map),p(this,yi,new Map),p(this,$n,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Sa("close");case"block":return new Yy(this);case"pending":return new Xy(this);case"event":return new ew(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Sa("drop-log")}return super._getSubscriber(t)}_register(t,n){u(this,yi).set(t,n);const s=u(this,$n).get(t);if(s){for(const i of s)n._handleMessage(i);u(this,$n).delete(t)}}async _send(t){y(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const n=new Promise((s,i)=>{u(this,Dr).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await n]}async _processMessage(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&"id"in n){const s=u(this,Dr).get(n.id);if(s==null){this.emit("error",ne("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:n}));return}u(this,Dr).delete(n.id),s.resolve(n)}else if(n&&n.method==="eth_subscription"){const s=n.params.subscription,i=u(this,yi).get(s);if(i)i._handleMessage(n.params.result);else{let o=u(this,$n).get(s);o==null&&(o=[],u(this,$n).set(s,o)),o.push(n.params.result)}}else{this.emit("error",ne("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:n}));return}}async _write(t){throw new Error("sub-classes must override this")}}Dr=new WeakMap,yi=new WeakMap,$n=new WeakMap;var Fr,Et;class nw extends tw{constructor(t,n,s){super(n,s);A(this,Fr,void 0);A(this,Et,void 0);typeof t=="string"?(p(this,Fr,()=>new $y(t)),p(this,Et,u(this,Fr).call(this))):typeof t=="function"?(p(this,Fr,t),p(this,Et,t())):(p(this,Fr,null),p(this,Et,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(u(this,Et)==null)throw new Error("websocket closed");return u(this,Et)}async _write(t){this.websocket.send(t)}async destroy(){u(this,Et)!=null&&(u(this,Et).close(),p(this,Et,null)),super.destroy()}}Fr=new WeakMap,Et=new WeakMap;const Ki="84842078b09946638c03157f83405213";function rw(r){switch(r){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}y(!1,"unsupported network","network",r)}class sw extends nw{constructor(t,n){const s=new Jr(t,n),i=s._getConnection();I(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);E(this,"projectId");E(this,"projectSecret");F(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===Ki}}class Jr extends Ff{constructor(t,n,s){t==null&&(t="mainnet");const i=vt.from(t);n==null&&(n=Ki),s==null&&(s=null);const o=Jr.getRequest(i,n,s);super(o,i,{staticNetwork:i});E(this,"projectId");E(this,"projectSecret");F(this,{projectId:n,projectSecret:s})}_getProvider(t){try{return new Jr(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===Ki}static getWebSocketProvider(t,n){return new sw(t,n)}static getRequest(t,n,s){n==null&&(n=Ki),s==null&&(s=null);const i=new Qt(`https://${rw(t.name)}/v3/${n}`);return i.allowGzip=!0,s&&i.setCredentials("",s),n===Ki&&(i.retryFunc=async(o,a,c)=>(jy("InfuraProvider"),!0)),i}}var wi;class Mc extends Df{constructor(t,n,s){const i=Object.assign({},s??{},{batchMaxCount:1});y(t&&t.request,"invalid EIP-1193 provider","ethereum",t);super(n,i);A(this,wi,void 0);p(this,wi,async(o,a)=>{const c={method:o,params:a};this.emit("debug",{action:"sendEip1193Request",payload:c});try{const l=await t.request(c);return this.emit("debug",{action:"receiveEip1193Result",result:l}),l}catch(l){const h=new Error(l.message);throw h.code=l.code,h.data=l.data,h.payload=c,this.emit("debug",{action:"receiveEip1193Error",error:h}),h}})}async send(t,n){return await this._start(),await super.send(t,n)}async _send(t){y(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const n=await u(this,wi).call(this,t.method,t.params||[]);return[{id:t.id,result:n}]}catch(n){return[{id:t.id,error:{code:n.code,data:n.data,message:n.message}}]}}getRpcError(t,n){switch(n=JSON.parse(JSON.stringify(n)),n.error.code||-1){case 4001:n.error.message=`ethers-user-denied: ${n.error.message}`;break;case 4200:n.error.message=`ethers-unsupported: ${n.error.message}`;break}return super.getRpcError(t,n)}async hasSigner(t){t==null&&(t=0);const n=await this.send("eth_accounts",[]);return typeof t=="number"?n.length>t:(t=t.toLowerCase(),n.filter(s=>s.toLowerCase()===t).length!==0)}async getSigner(t){if(t==null&&(t=0),!await this.hasSigner(t))try{await u(this,wi).call(this,"eth_requestAccounts",[])}catch(n){const s=n.payload;throw this.getRpcError(s,{id:s.id,error:n})}return await super.getSigner(t)}}wi=new WeakMap;const Pn={signMessage:async(r,e,t)=>{if(!e)throw new Error("signMessage - provider is undefined");const n=X(r)?r:T(jt(r));return await e.request({method:"personal_sign",params:[n,t]})},estimateGas:async(r,e,t,n)=>{if(!e)throw new Error("estimateGas - provider is undefined");if(!t)throw new Error("estimateGas - address is undefined");if(r.chainNamespace&&r.chainNamespace!=="eip155")throw new Error("estimateGas - chainNamespace is not eip155");const s={from:r.address,to:r.to,data:r.data,type:0},i=new Mc(e,n);return await new ks(i,t).estimateGas(s)},sendTransaction:async(r,e,t,n)=>{if(!e)throw new Error("sendTransaction - provider is undefined");if(!t)throw new Error("sendTransaction - address is undefined");if(r.chainNamespace&&r.chainNamespace!=="eip155")throw new Error("sendTransaction - chainNamespace is not eip155");const s={to:r.to,value:r.value,gasLimit:r.gas,gasPrice:r.gasPrice,data:r.data,type:0},i=new Mc(e,n),c=await(await new ks(i,t).sendTransaction(s)).wait();return(c==null?void 0:c.hash)||null},writeContract:async(r,e,t,n)=>{if(!e)throw new Error("writeContract - provider is undefined");if(!t)throw new Error("writeContract - address is undefined");const s=new Mc(e,n),i=new ks(s,t),o=new Ss(r.tokenAddress,r.abi,i);if(!o||!r.method)throw new Error("Contract method is undefined");const a=o[r.method];if(a)return await a(r.receiverAddress,r.tokenAmount);throw new Error("Contract method is undefined")},getEnsAddress:async(r,e)=>{var t;try{const n=Number((t=e.getCaipNetwork())==null?void 0:t.id);let s=null,i=!1;return b.isReownName(r)&&(i=await(e==null?void 0:e.resolveReownName(r))||!1),n===1&&(s=await new Jr("mainnet").resolveName(r)),s||i||!1}catch{return!1}},getEnsAvatar:async(r,e)=>e===1&&await new Jr("mainnet").getAvatar(r)||!1,parseUnits:Kp,formatUnits:rd};var Hf={},no={},$a={};Object.defineProperty($a,"__esModule",{value:!0});$a.walletLogo=void 0;const iw=(r,e)=>{let t;switch(r){case"standard":return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return t=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${t}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};$a.walletLogo=iw;var Ya={},zt={},An={};Object.defineProperty(An,"__esModule",{value:!0});An.errorValues=An.standardErrorCodes=void 0;An.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};An.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var Xa={},Zl={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.serialize=r.getErrorCode=r.isValidCode=r.getMessageFromCode=r.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=An,t="Unspecified error message.";r.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function n(f,g=t){if(f&&Number.isInteger(f)){const w=f.toString();if(h(e.errorValues,w))return e.errorValues[w].message;if(c(f))return r.JSON_RPC_SERVER_ERROR_MESSAGE}return g}r.getMessageFromCode=n;function s(f){if(!Number.isInteger(f))return!1;const g=f.toString();return!!(e.errorValues[g]||c(f))}r.isValidCode=s;function i(f){var g;if(typeof f=="number")return f;if(o(f))return(g=f.code)!==null&&g!==void 0?g:f.errorCode}r.getErrorCode=i;function o(f){return typeof f=="object"&&f!==null&&(typeof f.code=="number"||typeof f.errorCode=="number")}function a(f,{shouldIncludeStack:g=!1}={}){const w={};if(f&&typeof f=="object"&&!Array.isArray(f)&&h(f,"code")&&s(f.code)){const m=f;w.code=m.code,m.message&&typeof m.message=="string"?(w.message=m.message,h(m,"data")&&(w.data=m.data)):(w.message=n(w.code),w.data={originalError:l(f)})}else w.code=e.standardErrorCodes.rpc.internal,w.message=d(f,"message")?f.message:t,w.data={originalError:l(f)};return g&&(w.stack=d(f,"stack")?f.stack:void 0),w}r.serialize=a;function c(f){return f>=-32099&&f<=-32e3}function l(f){return f&&typeof f=="object"&&!Array.isArray(f)?Object.assign({},f):f}function h(f,g){return Object.prototype.hasOwnProperty.call(f,g)}function d(f,g){return typeof f=="object"&&f!==null&&g in f&&typeof f[g]=="string"}})(Zl);Object.defineProperty(Xa,"__esModule",{value:!0});Xa.standardErrors=void 0;const be=An,Gf=Zl;Xa.standardErrors={rpc:{parse:r=>et(be.standardErrorCodes.rpc.parse,r),invalidRequest:r=>et(be.standardErrorCodes.rpc.invalidRequest,r),invalidParams:r=>et(be.standardErrorCodes.rpc.invalidParams,r),methodNotFound:r=>et(be.standardErrorCodes.rpc.methodNotFound,r),internal:r=>et(be.standardErrorCodes.rpc.internal,r),server:r=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=r;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return et(e,r)},invalidInput:r=>et(be.standardErrorCodes.rpc.invalidInput,r),resourceNotFound:r=>et(be.standardErrorCodes.rpc.resourceNotFound,r),resourceUnavailable:r=>et(be.standardErrorCodes.rpc.resourceUnavailable,r),transactionRejected:r=>et(be.standardErrorCodes.rpc.transactionRejected,r),methodNotSupported:r=>et(be.standardErrorCodes.rpc.methodNotSupported,r),limitExceeded:r=>et(be.standardErrorCodes.rpc.limitExceeded,r)},provider:{userRejectedRequest:r=>os(be.standardErrorCodes.provider.userRejectedRequest,r),unauthorized:r=>os(be.standardErrorCodes.provider.unauthorized,r),unsupportedMethod:r=>os(be.standardErrorCodes.provider.unsupportedMethod,r),disconnected:r=>os(be.standardErrorCodes.provider.disconnected,r),chainDisconnected:r=>os(be.standardErrorCodes.provider.chainDisconnected,r),unsupportedChain:r=>os(be.standardErrorCodes.provider.unsupportedChain,r),custom:r=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:t,data:n}=r;if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string');return new Wf(e,t,n)}}};function et(r,e){const[t,n]=Kf(e);return new jf(r,t||(0,Gf.getMessageFromCode)(r),n)}function os(r,e){const[t,n]=Kf(e);return new Wf(r,t||(0,Gf.getMessageFromCode)(r),n)}function Kf(r){if(r){if(typeof r=="string")return[r];if(typeof r=="object"&&!Array.isArray(r)){const{message:e,data:t}=r;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,t]}}return[]}class jf extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string.');super(t),this.code=e,n!==void 0&&(this.data=n)}}class Wf extends jf{constructor(e,t,n){if(!ow(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}}function ow(r){return Number.isInteger(r)&&r>=1e3&&r<=4999}(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.standardErrors=r.standardErrorCodes=void 0;var e=An;Object.defineProperty(r,"standardErrorCodes",{enumerable:!0,get:function(){return e.standardErrorCodes}});var t=Xa;Object.defineProperty(r,"standardErrors",{enumerable:!0,get:function(){return t.standardErrors}})})(zt);var ec={},Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});Ri.isErrorResponse=void 0;function aw(r){return r.errorMessage!==void 0}Ri.isErrorResponse=aw;var Zr={};Object.defineProperty(Zr,"__esModule",{value:!0});Zr.LIB_VERSION=void 0;Zr.LIB_VERSION="4.0.3";Object.defineProperty(ec,"__esModule",{value:!0});ec.serializeError=void 0;const cw=Ri,lw=Zr,uw=An,hw=Zl;function dw(r,e){const t=(0,hw.serialize)(fw(r),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");n.searchParams.set("version",lw.LIB_VERSION),n.searchParams.set("code",t.code.toString());const s=pw(t.data,e);return s&&n.searchParams.set("method",s),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}ec.serializeError=dw;function fw(r){return typeof r=="string"?{message:r,code:uw.standardErrorCodes.rpc.internal}:(0,cw.isErrorResponse)(r)?Object.assign(Object.assign({},r),{message:r.errorMessage,code:r.errorCode,data:{method:r.method}}):r}function pw(r,e){const t=r==null?void 0:r.method;if(t)return t;if(e!==void 0){if(typeof e=="string")return e;if(Array.isArray(e)){if(e.length>0)return e[0].method}else return e.method}}var Se={};Object.defineProperty(Se,"__esModule",{value:!0});Se.RegExpString=Se.IntNumber=Se.BigIntString=Se.AddressString=Se.HexString=Se.OpaqueType=void 0;function _o(){return r=>r}Se.OpaqueType=_o;Se.HexString=_o();Se.AddressString=_o();Se.BigIntString=_o();function gw(r){return Math.floor(r)}Se.IntNumber=gw;Se.RegExpString=_o();var U={};Object.defineProperty(U,"__esModule",{value:!0});U.areAddressArraysEqual=U.getFavicon=U.range=U.isBigNumber=U.ensureParsedJSONObject=U.ensureBigInt=U.ensureRegExpString=U.ensureIntNumber=U.ensureBuffer=U.ensureAddressString=U.ensureEvenLengthHexString=U.ensureHexString=U.isHexString=U.prepend0x=U.strip0x=U.has0xPrefix=U.hexStringFromIntNumber=U.intNumberFromHexString=U.bigIntStringFromBigInt=U.hexStringFromBuffer=U.hexStringToUint8Array=U.uint8ArrayToHex=U.randomBytesHex=void 0;const $r=zt,lt=Se,Vf=/^[0-9]*$/,Qf=/^[a-f0-9]*$/;function mw(r){return zf(crypto.getRandomValues(new Uint8Array(r)))}U.randomBytesHex=mw;function zf(r){return[...r].map(e=>e.toString(16).padStart(2,"0")).join("")}U.uint8ArrayToHex=zf;function yw(r){return new Uint8Array(r.match(/.{1,2}/g).map(e=>parseInt(e,16)))}U.hexStringToUint8Array=yw;function ww(r,e=!1){const t=r.toString("hex");return(0,lt.HexString)(e?`0x${t}`:t)}U.hexStringFromBuffer=ww;function bw(r){return(0,lt.BigIntString)(r.toString(10))}U.bigIntStringFromBigInt=bw;function Aw(r){return(0,lt.IntNumber)(Number(BigInt(Uo(r,!0))))}U.intNumberFromHexString=Aw;function Ew(r){return(0,lt.HexString)(`0x${BigInt(r).toString(16)}`)}U.hexStringFromIntNumber=Ew;function $l(r){return r.startsWith("0x")||r.startsWith("0X")}U.has0xPrefix=$l;function tc(r){return $l(r)?r.slice(2):r}U.strip0x=tc;function Jf(r){return $l(r)?`0x${r.slice(2)}`:`0x${r}`}U.prepend0x=Jf;function Lo(r){if(typeof r!="string")return!1;const e=tc(r).toLowerCase();return Qf.test(e)}U.isHexString=Lo;function qf(r,e=!1){if(typeof r=="string"){const t=tc(r).toLowerCase();if(Qf.test(t))return(0,lt.HexString)(e?`0x${t}`:t)}throw $r.standardErrors.rpc.invalidParams(`"${String(r)}" is not a hexadecimal string`)}U.ensureHexString=qf;function Uo(r,e=!1){let t=qf(r,!1);return t.length%2===1&&(t=(0,lt.HexString)(`0${t}`)),e?(0,lt.HexString)(`0x${t}`):t}U.ensureEvenLengthHexString=Uo;function Cw(r){if(typeof r=="string"){const e=tc(r).toLowerCase();if(Lo(e)&&e.length===40)return(0,lt.AddressString)(Jf(e))}throw $r.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(r)}`)}U.ensureAddressString=Cw;function vw(r){if(b.Buffer.isBuffer(r))return r;if(typeof r=="string"){if(Lo(r)){const e=Uo(r,!1);return b.Buffer.from(e,"hex")}return b.Buffer.from(r,"utf8")}throw $r.standardErrors.rpc.invalidParams(`Not binary data: ${String(r)}`)}U.ensureBuffer=vw;function Zf(r){if(typeof r=="number"&&Number.isInteger(r))return(0,lt.IntNumber)(r);if(typeof r=="string"){if(Vf.test(r))return(0,lt.IntNumber)(Number(r));if(Lo(r))return(0,lt.IntNumber)(Number(BigInt(Uo(r,!0))))}throw $r.standardErrors.rpc.invalidParams(`Not an integer: ${String(r)}`)}U.ensureIntNumber=Zf;function Iw(r){if(r instanceof RegExp)return(0,lt.RegExpString)(r.toString());throw $r.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(r)}`)}U.ensureRegExpString=Iw;function Nw(r){if(r!==null&&(typeof r=="bigint"||$f(r)))return BigInt(r.toString(10));if(typeof r=="number")return BigInt(Zf(r));if(typeof r=="string"){if(Vf.test(r))return BigInt(r);if(Lo(r))return BigInt(Uo(r,!0))}throw $r.standardErrors.rpc.invalidParams(`Not an integer: ${String(r)}`)}U.ensureBigInt=Nw;function Sw(r){if(typeof r=="string")return JSON.parse(r);if(typeof r=="object")return r;throw $r.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(r)}`)}U.ensureParsedJSONObject=Sw;function $f(r){if(r==null||typeof r.constructor!="function")return!1;const{constructor:e}=r;return typeof e.config=="function"&&typeof e.EUCLID=="number"}U.isBigNumber=$f;function kw(r,e){return Array.from({length:e-r},(t,n)=>r+n)}U.range=kw;function xw(){const r=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:t}=document.location,n=r?r.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${t}${n}`}U.getFavicon=xw;function Pw(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}U.areAddressArraysEqual=Pw;var Kt={},nc={},rc={},he={};Object.defineProperty(he,"__esModule",{value:!0});he.decryptContent=he.encryptContent=he.importKeyFromHexString=he.exportKeyToHexString=he.decrypt=he.encrypt=he.deriveSharedSecret=he.generateKeyPair=void 0;const Yf=U;async function Rw(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}he.generateKeyPair=Rw;async function Ow(r,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}he.deriveSharedSecret=Ow;async function Xf(r,e){const t=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},r,new TextEncoder().encode(e));return{iv:t,cipherText:n}}he.encrypt=Xf;async function ep(r,{iv:e,cipherText:t}){const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},r,t);return new TextDecoder().decode(n)}he.decrypt=ep;function tp(r){switch(r){case"public":return"spki";case"private":return"pkcs8"}}async function Tw(r,e){const t=tp(r),n=await crypto.subtle.exportKey(t,e);return(0,Yf.uint8ArrayToHex)(new Uint8Array(n))}he.exportKeyToHexString=Tw;async function Bw(r,e){const t=tp(r),n=(0,Yf.hexStringToUint8Array)(e).buffer;return await crypto.subtle.importKey(t,n,{name:"ECDH",namedCurve:"P-256"},!0,r==="private"?["deriveKey"]:[])}he.importKeyFromHexString=Bw;async function _w(r,e){const t=JSON.stringify(r,(n,s)=>{if(!(s instanceof Error))return s;const i=s;return Object.assign(Object.assign({},i.code?{code:i.code}:{}),{message:i.message})});return Xf(e,t)}he.encryptContent=_w;async function Lw(r,e){return JSON.parse(await ep(e,r))}he.decryptContent=Lw;var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.ScopedLocalStorage=void 0;class ka{constructor(e,t){this.scope=e,this.module=t}setItem(e,t){localStorage.setItem(this.scopedKey(e),t)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),t=[];for(let n=0;n<localStorage.length;n++){const s=localStorage.key(n);typeof s=="string"&&s.startsWith(e)&&t.push(s)}t.forEach(n=>localStorage.removeItem(n))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new ka("CBWSDK").clear(),new ka("walletlink").clear()}}Jt.ScopedLocalStorage=ka;Object.defineProperty(rc,"__esModule",{value:!0});rc.SCWKeyManager=void 0;const Jo=he,Uw=Jt,Dc={storageKey:"ownPrivateKey",keyType:"private"},Fc={storageKey:"ownPublicKey",keyType:"public"},Hc={storageKey:"peerPublicKey",keyType:"public"};class Mw{constructor(){this.storage=new Uw.ScopedLocalStorage("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey(Hc,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(Fc.storageKey),this.storage.removeItem(Dc.storageKey),this.storage.removeItem(Hc.storageKey)}async generateKeyPair(){const e=await(0,Jo.generateKeyPair)();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(Dc,e.privateKey),await this.storeKey(Fc,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Dc)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(Fc)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(Hc)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await(0,Jo.deriveSharedSecret)(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const t=this.storage.getItem(e.storageKey);return t?(0,Jo.importKeyFromHexString)(e.keyType,t):null}async storeKey(e,t){const n=await(0,Jo.exportKeyToHexString)(e.keyType,t);this.storage.setItem(e.storageKey,n)}}rc.SCWKeyManager=Mw;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});sc.SCWStateManager=void 0;const Dw=Jt,Ch="accounts",vh="activeChain",Ih="availableChains",Nh="walletCapabilities";class Fw{get accounts(){return this._accounts}get activeChain(){return this._activeChain}get walletCapabilities(){return this._walletCapabilities}constructor(e){var t,n;this.storage=new Dw.ScopedLocalStorage("CBWSDK","SCWStateManager"),this.updateListener=e.updateListener,this.availableChains=this.loadItemFromStorage(Ih),this._walletCapabilities=this.loadItemFromStorage(Nh);const s=this.loadItemFromStorage(Ch),i=this.loadItemFromStorage(vh);s&&this.updateListener.onAccountsUpdate({accounts:s,source:"storage"}),i&&this.updateListener.onChainUpdate({chain:i,source:"storage"}),this._accounts=s||[],this._activeChain=i||{id:(n=(t=e.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1}}updateAccounts(e){this._accounts=e,this.storeItemToStorage(Ch,e),this.updateListener.onAccountsUpdate({accounts:e,source:"wallet"})}switchChain(e){var t;const n=(t=this.availableChains)===null||t===void 0?void 0:t.find(s=>s.id===e);return n?(n===this._activeChain||(this._activeChain=n,this.storeItemToStorage(vh,n),this.updateListener.onChainUpdate({chain:n,source:"wallet"})),!0):!1}updateAvailableChains(e){if(!e||Object.keys(e).length===0)return;const t=Object.entries(e).map(([n,s])=>({id:Number(n),rpcUrl:s}));this.availableChains=t,this.storeItemToStorage(Ih,t),this.switchChain(this._activeChain.id)}updateWalletCapabilities(e){this._walletCapabilities=e,this.storeItemToStorage(Nh,e)}storeItemToStorage(e,t){this.storage.setItem(e,JSON.stringify(t))}loadItemFromStorage(e){const t=this.storage.getItem(e);return t?JSON.parse(t):void 0}clear(){this.storage.clear()}}sc.SCWStateManager=Fw;Object.defineProperty(nc,"__esModule",{value:!0});nc.SCWSigner=void 0;const Hw=rc,Gw=sc,qo=zt,Sh=U,Zo=he;class Kw{constructor(e){this.metadata=e.metadata,this.communicator=e.communicator,this.keyManager=new Hw.SCWKeyManager,this.stateManager=new Gw.SCWStateManager({appChainIds:this.metadata.appChainIds,updateListener:e.updateListener}),this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(){const e=await this.createRequestMessage({handshake:{method:"eth_requestAccounts",params:this.metadata}}),t=await this.communicator.postRequestAndWaitForResponse(e);if("failure"in t.content)throw t.content.failure;const n=await(0,Zo.importKeyFromHexString)("public",t.sender);await this.keyManager.setPeerPublicKey(n);const s=await this.decryptResponseMessage(t);this.updateInternalState({method:"eth_requestAccounts"},s);const i=s.result;if("error"in i)throw i.error;return this.stateManager.accounts}async request(e){const t=this.tryLocalHandling(e);if(t!==void 0){if(t instanceof Error)throw t;return t}await this.communicator.waitForPopupLoaded();const n=await this.sendEncryptedRequest(e),s=await this.decryptResponseMessage(n);this.updateInternalState(e,s);const i=s.result;if("error"in i)throw i.error;return i.value}async disconnect(){this.stateManager.clear(),await this.keyManager.clear()}tryLocalHandling(e){var t;switch(e.method){case"wallet_switchEthereumChain":{const n=e.params;if(!n||!(!((t=n[0])===null||t===void 0)&&t.chainId))throw qo.standardErrors.rpc.invalidParams();const s=(0,Sh.ensureIntNumber)(n[0].chainId);return this.stateManager.switchChain(s)?null:void 0}case"wallet_getCapabilities":{const n=this.stateManager.walletCapabilities;if(!n)throw qo.standardErrors.provider.unauthorized("No wallet capabilities found, please disconnect and reconnect");return n}default:return}}async sendEncryptedRequest(e){const t=await this.keyManager.getSharedSecret();if(!t)throw qo.standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await(0,Zo.encryptContent)({action:e,chainId:this.stateManager.activeChain.id},t),s=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(s)}async createRequestMessage(e){const t=await(0,Zo.exportKeyToHexString)("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:t,content:e,timestamp:new Date}}async decryptResponseMessage(e){const t=e.content;if("failure"in t)throw t.failure;const n=await this.keyManager.getSharedSecret();if(!n)throw qo.standardErrors.provider.unauthorized("Invalid session");return(0,Zo.decryptContent)(t.encrypted,n)}updateInternalState(e,t){var n,s;const i=(n=t.data)===null||n===void 0?void 0:n.chains;i&&this.stateManager.updateAvailableChains(i);const o=(s=t.data)===null||s===void 0?void 0:s.capabilities;o&&this.stateManager.updateWalletCapabilities(o);const a=t.result;if(!("error"in a))switch(e.method){case"eth_requestAccounts":{const c=a.value;this.stateManager.updateAccounts(c);break}case"wallet_switchEthereumChain":{if(a.value!==null)return;const c=e.params,l=(0,Sh.ensureIntNumber)(c[0].chainId);this.stateManager.switchChain(l);break}}}}nc.SCWSigner=Kw;var ic={};const jw=Es.js;function np(r){return b.Buffer.allocUnsafe(r).fill(0)}function Ww(r){return r.toString(2).length}function rp(r,e){let t=r.toString(16);t.length%2!==0&&(t="0"+t);const n=t.match(/.{1,2}/g).map(s=>parseInt(s,16));for(;n.length<e;)n.unshift(0);return b.Buffer.from(n)}function Vw(r,e){const t=r<0n;let n;if(t){const s=(1n<<BigInt(e))-1n;n=(~r&s)+1n}else n=r;return n&=(1n<<BigInt(e))-1n,n}function sp(r,e,t){const n=np(e);return r=oc(r),t?r.length<e?(r.copy(n),n):r.slice(0,e):r.length<e?(r.copy(n,e-r.length),n):r.slice(-e)}function Qw(r,e){return sp(r,e,!0)}function oc(r){if(!b.Buffer.isBuffer(r))if(Array.isArray(r))r=b.Buffer.from(r);else if(typeof r=="string")ip(r)?r=b.Buffer.from(qw(op(r)),"hex"):r=b.Buffer.from(r);else if(typeof r=="number")r=intToBuffer(r);else if(r==null)r=b.Buffer.allocUnsafe(0);else if(typeof r=="bigint")r=rp(r);else if(r.toArray)r=b.Buffer.from(r.toArray());else throw new Error("invalid type");return r}function zw(r){return r=oc(r),"0x"+r.toString("hex")}function Jw(r,e){return r=oc(r),e||(e=256),jw("keccak"+e).update(r).digest()}function qw(r){return r.length%2?"0"+r:r}function ip(r){return typeof r=="string"&&r.match(/^0x[0-9A-Fa-f]*$/)}function op(r){return typeof r=="string"&&r.startsWith("0x")?r.slice(2):r}var ap={zeros:np,setLength:sp,setLengthRight:Qw,isHexString:ip,stripHexPrefix:op,toBuffer:oc,bufferToHex:zw,keccak:Jw,bitLengthFromBigInt:Ww,bufferBEFromBigInt:rp,twosFromBigInt:Vw};const Be=ap;function cp(r){return r.startsWith("int[")?"int256"+r.slice(3):r==="int"?"int256":r.startsWith("uint[")?"uint256"+r.slice(4):r==="uint"?"uint256":r.startsWith("fixed[")?"fixed128x128"+r.slice(5):r==="fixed"?"fixed128x128":r.startsWith("ufixed[")?"ufixed128x128"+r.slice(6):r==="ufixed"?"ufixed128x128":r}function xs(r){return parseInt(/^\D+(\d+)$/.exec(r)[1],10)}function kh(r){var e=/^\D+(\d+)x(\d+)$/.exec(r);return[parseInt(e[1],10),parseInt(e[2],10)]}function lp(r){var e=r.match(/(.*)\[(.*?)\]$/);return e?e[2]===""?"dynamic":parseInt(e[2],10):null}function ar(r){var e=typeof r;if(e==="string"||e==="number")return BigInt(r);if(e==="bigint")return r;throw new Error("Argument is not a number")}function Pt(r,e){var t,n,s,i;if(r==="address")return Pt("uint160",ar(e));if(r==="bool")return Pt("uint8",e?1:0);if(r==="string")return Pt("bytes",new b.Buffer(e,"utf8"));if($w(r)){if(typeof e.length>"u")throw new Error("Not an array?");if(t=lp(r),t!=="dynamic"&&t!==0&&e.length>t)throw new Error("Elements exceed array size: "+t);s=[],r=r.slice(0,r.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(i in e)s.push(Pt(r,e[i]));if(t==="dynamic"){var o=Pt("uint256",e.length);s.unshift(o)}return b.Buffer.concat(s)}else{if(r==="bytes")return e=new b.Buffer(e),s=b.Buffer.concat([Pt("uint256",e.length),e]),e.length%32!==0&&(s=b.Buffer.concat([s,Be.zeros(32-e.length%32)])),s;if(r.startsWith("bytes")){if(t=xs(r),t<1||t>32)throw new Error("Invalid bytes<N> width: "+t);return Be.setLengthRight(e,32)}else if(r.startsWith("uint")){if(t=xs(r),t%8||t<8||t>256)throw new Error("Invalid uint<N> width: "+t);n=ar(e);const a=Be.bitLengthFromBigInt(n);if(a>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+a);if(n<0)throw new Error("Supplied uint is negative");return Be.bufferBEFromBigInt(n,32)}else if(r.startsWith("int")){if(t=xs(r),t%8||t<8||t>256)throw new Error("Invalid int<N> width: "+t);n=ar(e);const a=Be.bitLengthFromBigInt(n);if(a>t)throw new Error("Supplied int exceeds width: "+t+" vs "+a);const c=Be.twosFromBigInt(n,256);return Be.bufferBEFromBigInt(c,32)}else if(r.startsWith("ufixed")){if(t=kh(r),n=ar(e),n<0)throw new Error("Supplied ufixed is negative");return Pt("uint256",n*BigInt(2)**BigInt(t[1]))}else if(r.startsWith("fixed"))return t=kh(r),Pt("int256",ar(e)*BigInt(2)**BigInt(t[1]))}throw new Error("Unsupported or invalid type: "+r)}function Zw(r){return r==="string"||r==="bytes"||lp(r)==="dynamic"}function $w(r){return r.lastIndexOf("]")===r.length-1}function Yw(r,e){var t=[],n=[],s=32*r.length;for(var i in r){var o=cp(r[i]),a=e[i],c=Pt(o,a);Zw(o)?(t.push(Pt("uint256",s)),n.push(c),s+=c.length):t.push(c)}return b.Buffer.concat(t.concat(n))}function up(r,e){if(r.length!==e.length)throw new Error("Number of types are not matching the values");for(var t,n,s=[],i=0;i<r.length;i++){var o=cp(r[i]),a=e[i];if(o==="bytes")s.push(a);else if(o==="string")s.push(new b.Buffer(a,"utf8"));else if(o==="bool")s.push(new b.Buffer(a?"01":"00","hex"));else if(o==="address")s.push(Be.setLength(a,20));else if(o.startsWith("bytes")){if(t=xs(o),t<1||t>32)throw new Error("Invalid bytes<N> width: "+t);s.push(Be.setLengthRight(a,t))}else if(o.startsWith("uint")){if(t=xs(o),t%8||t<8||t>256)throw new Error("Invalid uint<N> width: "+t);n=ar(a);const c=Be.bitLengthFromBigInt(n);if(c>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+c);s.push(Be.bufferBEFromBigInt(n,t/8))}else if(o.startsWith("int")){if(t=xs(o),t%8||t<8||t>256)throw new Error("Invalid int<N> width: "+t);n=ar(a);const c=Be.bitLengthFromBigInt(n);if(c>t)throw new Error("Supplied int exceeds width: "+t+" vs "+c);const l=Be.twosFromBigInt(n,t);s.push(Be.bufferBEFromBigInt(l,t/8))}else throw new Error("Unsupported or invalid type: "+o)}return b.Buffer.concat(s)}function Xw(r,e){return Be.keccak(up(r,e))}var eb={rawEncode:Yw,solidityPack:up,soliditySHA3:Xw};const ht=ap,Wi=eb,hp={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Gc={encodeData(r,e,t,n=!0){const s=["bytes32"],i=[this.hashType(r,t)];if(n){const o=(a,c,l)=>{if(t[c]!==void 0)return["bytes32",l==null?"0x0000000000000000000000000000000000000000000000000000000000000000":ht.keccak(this.encodeData(c,l,t,n))];if(l===void 0)throw new Error(`missing value for field ${a} of type ${c}`);if(c==="bytes")return["bytes32",ht.keccak(l)];if(c==="string")return typeof l=="string"&&(l=b.Buffer.from(l,"utf8")),["bytes32",ht.keccak(l)];if(c.lastIndexOf("]")===c.length-1){const h=c.slice(0,c.lastIndexOf("[")),d=l.map(f=>o(a,h,f));return["bytes32",ht.keccak(Wi.rawEncode(d.map(([f])=>f),d.map(([,f])=>f)))]}return[c,l]};for(const a of t[r]){const[c,l]=o(a.name,a.type,e[a.name]);s.push(c),i.push(l)}}else for(const o of t[r]){let a=e[o.name];if(a!==void 0)if(o.type==="bytes")s.push("bytes32"),a=ht.keccak(a),i.push(a);else if(o.type==="string")s.push("bytes32"),typeof a=="string"&&(a=b.Buffer.from(a,"utf8")),a=ht.keccak(a),i.push(a);else if(t[o.type]!==void 0)s.push("bytes32"),a=ht.keccak(this.encodeData(o.type,a,t,n)),i.push(a);else{if(o.type.lastIndexOf("]")===o.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");s.push(o.type),i.push(a)}}return Wi.rawEncode(s,i)},encodeType(r,e){let t="",n=this.findTypeDependencies(r,e).filter(s=>s!==r);n=[r].concat(n.sort());for(const s of n){if(!e[s])throw new Error("No type definition specified: "+s);t+=s+"("+e[s].map(({name:o,type:a})=>a+" "+o).join(",")+")"}return t},findTypeDependencies(r,e,t=[]){if(r=r.match(/^\w*/)[0],t.includes(r)||e[r]===void 0)return t;t.push(r);for(const n of e[r])for(const s of this.findTypeDependencies(n.type,e,t))!t.includes(s)&&t.push(s);return t},hashStruct(r,e,t,n=!0){return ht.keccak(this.encodeData(r,e,t,n))},hashType(r,e){return ht.keccak(this.encodeType(r,e))},sanitizeData(r){const e={};for(const t in hp.properties)r[t]&&(e[t]=r[t]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(r,e=!0){const t=this.sanitizeData(r),n=[b.Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",t.domain,t.types,e)),t.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(t.primaryType,t.message,t.types,e)),ht.keccak(b.Buffer.concat(n))}};var tb={TYPED_MESSAGE_SCHEMA:hp,TypedDataUtils:Gc,hashForSignTypedDataLegacy:function(r){return nb(r.data)},hashForSignTypedData_v3:function(r){return Gc.hash(r.data,!1)},hashForSignTypedData_v4:function(r){return Gc.hash(r.data)}};function nb(r){const e=new Error("Expect argument to be non-empty array");if(typeof r!="object"||!r.length)throw e;const t=r.map(function(i){return i.type==="bytes"?ht.toBuffer(i.value):i.value}),n=r.map(function(i){return i.type}),s=r.map(function(i){if(!i.name)throw e;return i.type+" "+i.name});return Wi.soliditySHA3(["bytes32","bytes32"],[Wi.soliditySHA3(new Array(r.length).fill("string"),s),Wi.soliditySHA3(n,t)])}var Wt={};Object.defineProperty(Wt,"__esModule",{value:!0});Wt.APP_VERSION_KEY=Wt.LOCAL_STORAGE_ADDRESSES_KEY=Wt.WALLET_USER_NAME_KEY=void 0;Wt.WALLET_USER_NAME_KEY="walletUsername";Wt.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";Wt.APP_VERSION_KEY="AppVersion";var Mo={};Object.defineProperty(Mo,"__esModule",{value:!0});Mo.RelayEventManager=void 0;const rb=U;class sb{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,t=(0,rb.prepend0x)(e.toString(16));return this.callbacks.get(t)&&this.callbacks.delete(t),e}}Mo.RelayEventManager=sb;var ac={},cc={},lc={};Object.defineProperty(lc,"__esModule",{value:!0});lc.WalletLinkCipher=void 0;const $o=U;class ib{constructor(e){this.secret=e}async encrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.importKey("raw",(0,$o.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),i=new TextEncoder,o=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},s,i.encode(e)),a=16,c=o.slice(o.byteLength-a),l=o.slice(0,o.byteLength-a),h=new Uint8Array(c),d=new Uint8Array(l),f=new Uint8Array([...n,...h,...d]);return(0,$o.uint8ArrayToHex)(f)}async decrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");return new Promise((n,s)=>{(async function(){const i=await crypto.subtle.importKey("raw",(0,$o.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),o=(0,$o.hexStringToUint8Array)(e),a=o.slice(0,12),c=o.slice(12,28),l=o.slice(28),h=new Uint8Array([...l,...c]),d={name:"AES-GCM",iv:new Uint8Array(a)};try{const f=await window.crypto.subtle.decrypt(d,i,h),g=new TextDecoder;n(g.decode(f))}catch(f){s(f)}})()})}}lc.WalletLinkCipher=ib;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});uc.WalletLinkHTTP=void 0;class ob{constructor(e,t,n){this.linkAPIUrl=e,this.sessionId=t;const s=`${t}:${n}`;this.auth=`Basic ${btoa(s)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(t=>fetch(`${this.linkAPIUrl}/events/${t.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(t=>console.error("Unabled to mark event as failed:",t))}async fetchUnseenEvents(){var e;const t=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(t.ok){const{events:n,error:s}=await t.json();if(s)throw new Error(`Check unseen events failed: ${s}`);const i=(e=n==null?void 0:n.filter(o=>o.event==="Web3Response").map(o=>({type:"Event",sessionId:this.sessionId,eventId:o.id,event:o.event,data:o.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(i),i}throw new Error(`Check unseen events failed: ${t.status}`)}}uc.WalletLinkHTTP=ob;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});ki.WalletLinkWebSocket=ki.ConnectionState=void 0;var ys;(function(r){r[r.DISCONNECTED=0]="DISCONNECTED",r[r.CONNECTING=1]="CONNECTING",r[r.CONNECTED=2]="CONNECTED"})(ys||(ki.ConnectionState=ys={}));class ab{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,t=WebSocket){this.WebSocketClass=t,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,t)=>{var n;let s;try{this.webSocket=s=new this.WebSocketClass(this.url)}catch(i){t(i);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,ys.CONNECTING),s.onclose=i=>{var o;this.clearWebSocket(),t(new Error(`websocket error ${i.code}: ${i.reason}`)),(o=this.connectionStateListener)===null||o===void 0||o.call(this,ys.DISCONNECTED)},s.onopen=i=>{var o;e(),(o=this.connectionStateListener)===null||o===void 0||o.call(this,ys.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(c=>this.sendData(c)),this.pendingData=[])},s.onmessage=i=>{var o,a;if(i.data==="h")(o=this.incomingDataListener)===null||o===void 0||o.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(i.data);(a=this.incomingDataListener)===null||a===void 0||a.call(this,c)}catch{}}})}disconnect(){var e;const{webSocket:t}=this;if(t){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,ys.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{t.close()}catch{}}}sendData(e){const{webSocket:t}=this;if(!t){this.pendingData.push(e),this.connect();return}t.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}ki.WalletLinkWebSocket=ab;Object.defineProperty(cc,"__esModule",{value:!0});cc.WalletLinkConnection=void 0;const xh=Wt,cb=lc,lb=uc,Yo=ki,as=Se,Ph=1e4,ub=6e4;class hb{constructor({session:e,linkAPIUrl:t,listener:n,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,as.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=o=>{if(!o)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",c=>o.JsonRpcUrl&&this.handleChainUpdated(c,o.JsonRpcUrl)]]).forEach((c,l)=>{const h=o[l];h!==void 0&&c(h)})},this.handleDestroyed=o=>{var a;o==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async o=>{var a;{const c=await this.cipher.decrypt(o);(a=this.listener)===null||a===void 0||a.accountUpdated(c)}},this.handleMetadataUpdated=async(o,a)=>{var c;{const l=await this.cipher.decrypt(a);(c=this.listener)===null||c===void 0||c.metadataUpdated(o,l)}},this.handleWalletUsernameUpdated=async o=>{this.handleMetadataUpdated(xh.WALLET_USER_NAME_KEY,o)},this.handleAppVersionUpdated=async o=>{this.handleMetadataUpdated(xh.APP_VERSION_KEY,o)},this.handleChainUpdated=async(o,a)=>{var c;{const l=await this.cipher.decrypt(o),h=await this.cipher.decrypt(a);(c=this.listener)===null||c===void 0||c.chainUpdated(l,h)}},this.session=e,this.cipher=new cb.WalletLinkCipher(e.secret),this.listener=n;const i=new Yo.WalletLinkWebSocket(`${t}/rpc`,s);i.setConnectionStateListener(async o=>{let a=!1;switch(o){case Yo.ConnectionState.DISCONNECTED:if(!this.destroyed){const c=async()=>{await new Promise(l=>setTimeout(l,5e3)),this.destroyed||i.connect().catch(()=>{c()})};c()}break;case Yo.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),a=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},Ph),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case Yo.ConnectionState.CONNECTING:break}this.connected!==a&&(this.connected=a)}),i.setIncomingDataListener(o=>{var a;switch(o.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const c=o.type==="IsLinkedOK"?o.linked:void 0;this.linked=c||o.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(o.metadata);break}case"Event":{this.handleIncomingEvent(o);break}}o.id!==void 0&&((a=this.requestResolutions.get(o.id))===null||a===void 0||a(o))}),this.ws=i,this.http=new lb.WalletLinkHTTP(t,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}destroy(){this.destroyed=!0,this.ws.disconnect(),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(e){var t;this._connected=e,e&&((t=this.onceConnected)===null||t===void 0||t.call(this))}setOnceConnected(e){return new Promise(t=>{this.connected?e().then(t):this.onceConnected=()=>{e().then(t),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(e){var t,n;this._linked=e,e&&((t=this.onceLinked)===null||t===void 0||t.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(t=>{this.linked?e().then(t):this.onceLinked=()=>{e().then(t),this.onceLinked=void 0}})}async handleIncomingEvent(e){var t;if(!(e.type!=="Event"||e.event!=="Web3Response")){const n=await this.cipher.decrypt(e.data),s=JSON.parse(n);if(s.type!=="WEB3_RESPONSE")return;(t=this.listener)===null||t===void 0||t.handleWeb3ResponseMessage(s)}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(t=>this.handleIncomingEvent(t))}async setSessionMetadata(e,t){const n={type:"SetSessionConfig",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[e]:t}};return this.setOnceConnected(async()=>{const s=await this.makeRequest(n);if(s.type==="Fail")throw new Error(s.error||"failed to set session metadata")})}async publishEvent(e,t,n=!1){const s=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},t),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),i={type:"PublishEvent",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:e,data:s,callWebhook:n};return this.setOnceLinked(async()=>{const o=await this.makeRequest(i);if(o.type==="Fail")throw new Error(o.error||"failed to publish event");return o.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Ph*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,t=ub){const n=e.id;this.sendData(e);let s;return Promise.race([new Promise((i,o)=>{s=window.setTimeout(()=>{o(new Error(`request ${n} timed out`))},t)}),new Promise(i=>{this.requestResolutions.set(n,o=>{clearTimeout(s),i(o),this.requestResolutions.delete(n)})})])}async authenticate(){const e={type:"HostSession",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},t=await this.makeRequest(e);if(t.type==="Fail")throw new Error(t.error||"failed to authenticate")}sendIsLinked(){const e={type:"IsLinked",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}sendGetSessionConfig(){const e={type:"GetSessionConfig",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}}cc.WalletLinkConnection=hb;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});hc.WalletLinkSession=void 0;const db=b.sha_jsExports,Rh=U,Oh="session:id",Th="session:secret",Bh="session:linked";class Yl{constructor(e,t,n,s){this._storage=e,this._id=t||(0,Rh.randomBytesHex)(16),this._secret=n||(0,Rh.randomBytesHex)(32),this._key=new db.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!s}static load(e){const t=e.getItem(Oh),n=e.getItem(Bh),s=e.getItem(Th);return t&&s?new Yl(e,t,s,n==="1"):null}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this._storage.setItem(Oh,this._id),this._storage.setItem(Th,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(Bh,this._linked?"1":"0")}}hc.WalletLinkSession=Yl;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isDarkMode=Ye.isMobileWeb=Ye.getLocation=Ye.createQrUrl=void 0;function fb(r,e,t,n,s,i){const o=n?"parent-id":"id",a=new URLSearchParams({[o]:r,secret:e,server:t,v:s,chainId:i.toString()}).toString();return`${t}/#/link?${a}`}Ye.createQrUrl=fb;function pb(){try{return window.frameElement!==null}catch{return!1}}function gb(){try{return pb()&&window.top?window.top.location:window.location}catch{return window.location}}Ye.getLocation=gb;function mb(){var r;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((r=window==null?void 0:window.navigator)===null||r===void 0?void 0:r.userAgent)}Ye.isMobileWeb=mb;function yb(){var r,e;return(e=(r=window==null?void 0:window.matchMedia)===null||r===void 0?void 0:r.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}Ye.isDarkMode=yb;var dc={},Do={},Xl={};Object.defineProperty(Xl,"__esModule",{value:!0});Xl.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var wb=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Do,"__esModule",{value:!0});Do.injectCssReset=void 0;const bb=wb(Xl);function Ab(){const r=document.createElement("style");r.type="text/css",r.appendChild(document.createTextNode(bb.default)),document.documentElement.appendChild(r)}Do.injectCssReset=Ab;var eu={},tu={};Object.defineProperty(tu,"__esModule",{value:!0});tu.default=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}";(function(r){var e=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(r,"__esModule",{value:!0}),r.SnackbarInstance=r.SnackbarContainer=r.Snackbar=void 0;const t=e(Es.require$$0),n=Es.require$$1,s=Es.require$$2,i=Ye,o=e(tu),a="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZ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N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class l{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=(0,i.isDarkMode)()}attach(g){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",g.appendChild(this.root),this.render()}presentItem(g){const w=this.nextItemKey++;return this.items.set(w,g),this.render(),()=>{this.items.delete(w),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,n.render)((0,n.h)("div",null,(0,n.h)(r.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([g,w])=>(0,n.h)(r.SnackbarInstance,Object.assign({},w,{key:g}))))),this.root)}}r.Snackbar=l;const h=f=>(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-container")},(0,n.h)("style",null,o.default),(0,n.h)("div",{class:"-cbwsdk-snackbar"},f.children));r.SnackbarContainer=h;const d=({autoExpand:f,message:g,menuItems:w})=>{const[m,C]=(0,s.useState)(!0),[v,k]=(0,s.useState)(f??!1);(0,s.useEffect)(()=>{const B=[window.setTimeout(()=>{C(!1)},1),window.setTimeout(()=>{k(!0)},1e4)];return()=>{B.forEach(window.clearTimeout)}});const S=()=>{k(!v)};return(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance",m&&"-cbwsdk-snackbar-instance-hidden",v&&"-cbwsdk-snackbar-instance-expanded")},(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:S},(0,n.h)("img",{src:a,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},g),(0,n.h)("div",{class:"-gear-container"},!v&&(0,n.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,n.h)("img",{src:c,class:"-gear-icon",title:"Expand"}))),w&&w.length>0&&(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},w.map((B,P)=>(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item",B.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:B.onClick,key:P},(0,n.h)("svg",{width:B.svgWidth,height:B.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("path",{"fill-rule":B.defaultFillRule,"clip-rule":B.defaultClipRule,d:B.path,fill:"#AAAAAA"})),(0,n.h)("span",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item-info",B.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},B.info)))))};r.SnackbarInstance=d})(eu);Object.defineProperty(dc,"__esModule",{value:!0});dc.WalletLinkRelayUI=void 0;const Eb=Do,Cb=eu;class vb{constructor(){this.attached=!1,this.snackbar=new Cb.Snackbar}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,t=document.createElement("div");t.className="-cbwsdk-css-reset",e.appendChild(t),this.snackbar.attach(t),this.attached=!0,(0,Eb.injectCssReset)()}showConnecting(e){let t;return e.isUnlinkedErrorState?t={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:t={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(t)}}dc.WalletLinkRelayUI=vb;var fc={},pc={},nu={};Object.defineProperty(nu,"__esModule",{value:!0});nu.default=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";var dp=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(pc,"__esModule",{value:!0});pc.RedirectDialog=void 0;const Ib=dp(Es.require$$0),Rt=Es.require$$1,Nb=Do,Sb=eu,kb=Ye,xb=dp(nu);class Pb{constructor(){this.root=null,this.darkMode=(0,kb.isDarkMode)()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),(0,Nb.injectCssReset)()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&((0,Rt.render)(null,this.root),e&&(0,Rt.render)((0,Rt.h)(Rb,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}pc.RedirectDialog=Pb;const Rb=({title:r,buttonText:e,darkMode:t,onButtonClick:n,onDismiss:s})=>{const i=t?"dark":"light";return(0,Rt.h)(Sb.SnackbarContainer,{darkMode:t},(0,Rt.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,Rt.h)("style",null,xb.default),(0,Rt.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:s}),(0,Rt.h)("div",{class:(0,Ib.default)("-cbwsdk-redirect-dialog-box",i)},(0,Rt.h)("p",null,r),(0,Rt.h)("button",{onClick:n},e))))};var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.CBW_MOBILE_DEEPLINK_URL=Vt.WALLETLINK_URL=Vt.CB_KEYS_URL=void 0;Vt.CB_KEYS_URL="https://keys.coinbase.com/connect";Vt.WALLETLINK_URL="https://www.walletlink.org";Vt.CBW_MOBILE_DEEPLINK_URL="https://go.cb-w.com/walletlink";Object.defineProperty(fc,"__esModule",{value:!0});fc.WLMobileRelayUI=void 0;const Ob=pc,Tb=Ye,Bb=Vt;class _b{constructor(){this.attached=!1,this.redirectDialog=new Ob.RedirectDialog}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const t=new URL(Bb.CBW_MOBILE_DEEPLINK_URL);t.searchParams.append("redirect_url",(0,Tb.getLocation)().href),e&&t.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=t.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}fc.WLMobileRelayUI=_b;Object.defineProperty(ac,"__esModule",{value:!0});ac.WalletLinkRelay=void 0;const Lb=cc,Ub=Wt,Mb=Mo,Kc=hc,cs=Ri,Db=Ye,Fb=dc,_h=fc,Hb=zt,ie=U,Gb=Jt;class tn{constructor(e){this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.isMobileWeb=(0,Db.isMobileWeb)(),this.appName="",this.appLogoUrl=null,this.linkedUpdated=i=>{this.isLinked=i;const o=this.storage.getItem(Ub.LOCAL_STORAGE_ADDRESSES_KEY);if(i&&(this._session.linked=i),this.isUnlinkedErrorState=!1,o){const a=o.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";a[0]!==""&&!i&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(i,o)=>{this.storage.setItem(i,o)},this.chainUpdated=(i,o)=>{this.chainCallbackParams.chainId===i&&this.chainCallbackParams.jsonRpcUrl===o||(this.chainCallbackParams={chainId:i,jsonRpcUrl:o},this.chainCallback&&this.chainCallback(i,o))},this.accountUpdated=i=>{this.accountsCallback&&this.accountsCallback([i]),tn.accountRequestCallbackIds.size>0&&(Array.from(tn.accountRequestCallbackIds.values()).forEach(o=>{const a={type:"WEB3_RESPONSE",id:o,response:{method:"requestEthereumAccounts",result:[i]}};this.invokeCallback(Object.assign(Object.assign({},a),{id:o}))}),tn.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage;const{session:t,ui:n,connection:s}=this.subscribe();this._session=t,this.connection=s,this.relayEventManager=new Mb.RelayEventManager,this.ui=n}subscribe(){const e=Kc.WalletLinkSession.load(this.storage)||new Kc.WalletLinkSession(this.storage).save(),{linkAPIUrl:t}=this,n=new Lb.WalletLinkConnection({session:e,linkAPIUrl:t,listener:this}),s=this.isMobileWeb?new _h.WLMobileRelayUI:new Fb.WalletLinkRelayUI;return n.connect(),{session:e,ui:s,connection:n}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(e=>setTimeout(()=>e(null),1e3))]).then(()=>{this.connection.destroy();const e=Kc.WalletLinkSession.load(this.storage);(e==null?void 0:e.id)===this._session.id&&Gb.ScopedLocalStorage.clearAll(),document.location.reload()}).catch(e=>{})}setAppInfo(e,t){this.appName=e,this.appLogoUrl=t}getStorageItem(e){return this.storage.getItem(e)}setStorageItem(e,t){this.storage.setItem(e,t)}signEthereumMessage(e,t,n,s){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,ie.hexStringFromBuffer)(e,!0),address:t,addPrefix:n,typedDataJson:s||null}})}ethereumAddressFromSignedMessage(e,t,n){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,ie.hexStringFromBuffer)(e,!0),signature:(0,ie.hexStringFromBuffer)(t,!0),addPrefix:n}})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,ie.bigIntStringFromBigInt)(e.weiValue),data:(0,ie.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,gasLimit:e.gasLimit?(0,ie.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,ie.bigIntStringFromBigInt)(e.weiValue),data:(0,ie.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?(0,ie.bigIntStringFromBigInt)(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?(0,ie.bigIntStringFromBigInt)(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?(0,ie.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,t){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,ie.hexStringFromBuffer)(e,!0),chainId:t}})}scanQRCode(e){return this.sendRequest({method:"scanQRCode",params:{regExp:e}})}getWalletLinkSession(){return this._session}genericRequest(e,t){return this.sendRequest({method:"generic",params:{action:t,data:e}})}sendGenericMessage(e){return this.sendRequest(e)}sendRequest(e){let t=null;const n=(0,ie.randomBytesHex)(8),s=i=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,i),t==null||t()};return new Promise((i,o)=>{t=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:s,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,a=>{if(t==null||t(),(0,cs.isErrorResponse)(a))return o(new Error(a.errorMessage));i(a)}),this.publishWeb3RequestEvent(n,e)})}setAccountsCallback(e){this.accountsCallback=e}setChainCallback(e){this.chainCallback=e}setDappDefaultChainCallback(e){this.dappDefaultChain=e}publishWeb3RequestEvent(e,t){const n={type:"WEB3_REQUEST",id:e,request:t};this.publishEvent("Web3Request",n,!0).then(s=>{}).catch(s=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n.id,response:{method:t.method,errorMessage:s.message}})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(t.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof _h.WLMobileRelayUI)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const t={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",t,!1).then()}publishEvent(e,t,n){return this.connection.publishEvent(e,t,n)}handleWeb3ResponseMessage(e){const{response:t}=e;if(t.method==="requestEthereumAccounts"){tn.accountRequestCallbackIds.forEach(n=>this.invokeCallback(Object.assign(Object.assign({},e),{id:n}))),tn.accountRequestCallbackIds.clear();return}this.invokeCallback(e)}handleErrorResponse(e,t,n){var s;const i=(s=n==null?void 0:n.message)!==null&&s!==void 0?s:"Unspecified error message.";this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:{method:t,errorMessage:i}})}invokeCallback(e){const t=this.relayEventManager.callbacks.get(e.id);t&&(t(e.response),this.relayEventManager.callbacks.delete(e.id))}requestEthereumAccounts(){const e={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},t=(0,ie.randomBytesHex)(8);return new Promise((n,s)=>{this.relayEventManager.callbacks.set(t,i=>{if((0,cs.isErrorResponse)(i))return s(new Error(i.errorMessage));n(i)}),tn.accountRequestCallbackIds.add(t),this.publishWeb3RequestEvent(t,e)})}watchAsset(e,t,n,s,i,o){const a={method:"watchAsset",params:{type:e,options:{address:t,symbol:n,decimals:s,image:i},chainId:o}};let c=null;const l=(0,ie.randomBytesHex)(8),h=d=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,a.method,d),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((d,f)=>{this.relayEventManager.callbacks.set(l,g=>{if(c==null||c(),(0,cs.isErrorResponse)(g))return f(new Error(g.errorMessage));d(g)}),this.publishWeb3RequestEvent(l,a)})}addEthereumChain(e,t,n,s,i,o){const a={method:"addEthereumChain",params:{chainId:e,rpcUrls:t,blockExplorerUrls:s,chainName:i,iconUrls:n,nativeCurrency:o}};let c=null;const l=(0,ie.randomBytesHex)(8),h=d=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,a.method,d),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((d,f)=>{this.relayEventManager.callbacks.set(l,g=>{if(c==null||c(),(0,cs.isErrorResponse)(g))return f(new Error(g.errorMessage));d(g)}),this.publishWeb3RequestEvent(l,a)})}switchEthereumChain(e,t){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:t})},s=(0,ie.randomBytesHex)(8);return new Promise((i,o)=>{this.relayEventManager.callbacks.set(s,a=>{if((0,cs.isErrorResponse)(a)&&a.errorCode)return o(Hb.standardErrors.provider.custom({code:a.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,cs.isErrorResponse)(a))return o(new Error(a.errorMessage));i(a)}),this.publishWeb3RequestEvent(s,n)})}}ac.WalletLinkRelay=tn;tn.accountRequestCallbackIds=new Set;var Kb=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ic,"__esModule",{value:!0});ic.WalletLinkSigner=void 0;const jc=Kb(tb),Lh=Wt,jb=Mo,qt=Ri,Wb=ac,Uh=Vt,pe=zt,j=U,Vb=Jt,Wc="DefaultChainId",Mh="DefaultJsonRpcUrl";class Qb{constructor(e){var t,n;this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1;const{appName:s,appLogoUrl:i}=e.metadata;this._appName=s,this._appLogoUrl=i,this._storage=new Vb.ScopedLocalStorage("walletlink",Uh.WALLETLINK_URL),this.updateListener=e.updateListener,this._relayEventManager=new jb.RelayEventManager,this._jsonRpcUrlFromOpts="";const o=this._storage.getItem(Lh.LOCAL_STORAGE_ADDRESSES_KEY);if(o){const c=o.split(" ");c[0]!==""&&(this._addresses=c.map(l=>(0,j.ensureAddressString)(l)),(t=this.updateListener)===null||t===void 0||t.onAccountsUpdate({accounts:this._addresses,source:"storage"}))}this._storage.getItem(Wc)&&((n=this.updateListener)===null||n===void 0||n.onChainUpdate({chain:{id:this.getChainId(),rpcUrl:this.jsonRpcUrl},source:"storage"}),this.hasMadeFirstChainChangedEmission=!0),this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:t,secret:n}=e.getWalletLinkSession();return{id:t,secret:n}}async handshake(){return await this.request({method:"eth_requestAccounts"})}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(Mh))!==null&&e!==void 0?e:this._jsonRpcUrlFromOpts}set jsonRpcUrl(e){this._storage.setItem(Mh,e)}updateProviderInfo(e,t){var n;this.jsonRpcUrl=e;const s=this.getChainId();this._storage.setItem(Wc,t.toString(10)),((0,j.ensureIntNumber)(t)!==s||!this.hasMadeFirstChainChangedEmission)&&((n=this.updateListener)===null||n===void 0||n.onChainUpdate({chain:{id:t,rpcUrl:e},source:"wallet"}),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(e,t,n,s,i,o){const c=await this.initializeRelay().watchAsset(e,t,n,s,i,o==null?void 0:o.toString());return(0,qt.isErrorResponse)(c)?!1:!!c.result}async addEthereumChain(e,t,n,s,i,o){var a,c;if((0,j.ensureIntNumber)(e)===this.getChainId())return!1;const l=this.initializeRelay();this._isAuthorized()||await l.requestEthereumAccounts();const h=await l.addEthereumChain(e.toString(),t,i,n,s,o);return(0,qt.isErrorResponse)(h)?!1:(((a=h.result)===null||a===void 0?void 0:a.isApproved)===!0&&this.updateProviderInfo(t[0],e),((c=h.result)===null||c===void 0?void 0:c.isApproved)===!0)}async switchEthereumChain(e){const n=await this.initializeRelay().switchEthereumChain(e.toString(10),this.selectedAddress||void 0);if((0,qt.isErrorResponse)(n)){if(!n.errorCode)return;throw n.errorCode===pe.standardErrorCodes.provider.unsupportedChain?pe.standardErrors.provider.unsupportedChain():pe.standardErrors.provider.custom({message:n.errorMessage,code:n.errorCode})}const s=n.result;s.isApproved&&s.rpcUrl.length>0&&this.updateProviderInfo(s.rpcUrl,e)}async disconnect(){this._relay&&this._relay.resetAndReload(),this._storage.clear()}async request(e){try{return this._request(e).catch(t=>{throw t})}catch(t){return Promise.reject(t)}}async _request(e){if(!e||typeof e!="object"||Array.isArray(e))throw pe.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:e});const{method:t,params:n}=e;if(typeof t!="string"||t.length===0)throw pe.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw pe.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:e});const s=n===void 0?[]:n,i=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:t,params:s,jsonrpc:"2.0",id:i})).result}_setAddresses(e,t){var n;if(!Array.isArray(e))throw new Error("addresses is not an array");const s=e.map(i=>(0,j.ensureAddressString)(i));JSON.stringify(s)!==JSON.stringify(this._addresses)&&(this._addresses=s,(n=this.updateListener)===null||n===void 0||n.onAccountsUpdate({accounts:s,source:"wallet"}),this._storage.setItem(Lh.LOCAL_STORAGE_ADDRESSES_KEY,s.join(" ")))}_sendRequestAsync(e){return new Promise((t,n)=>{try{const s=this._handleSynchronousMethods(e);if(s!==void 0)return t({jsonrpc:"2.0",id:e.id,result:s})}catch(s){return n(s)}this._handleAsynchronousMethods(e).then(s=>s&&t(Object.assign(Object.assign({},s),{id:e.id}))).catch(s=>n(s))})}_handleSynchronousMethods(e){const{method:t}=e;switch(t){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(e){const{method:t}=e,n=e.params||[];switch(t){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(n);case"eth_ecRecover":return this._eth_ecRecover(n);case"personal_sign":return this._personal_sign(n);case"personal_ecRecover":return this._personal_ecRecover(n);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(n);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(n);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(n);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(n);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(n);case"wallet_watchAsset":return this._wallet_watchAsset(n);default:return this._throwUnsupportedMethodError()}}_isKnownAddress(e){try{const t=(0,j.ensureAddressString)(e);return this._addresses.map(s=>(0,j.ensureAddressString)(s)).includes(t)}catch{}return!1}_ensureKnownAddress(e){if(!this._isKnownAddress(e))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const t=e.from?(0,j.ensureAddressString)(e.from):this.selectedAddress;if(!t)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(t);const n=e.to?(0,j.ensureAddressString)(e.to):null,s=e.value!=null?(0,j.ensureBigInt)(e.value):BigInt(0),i=e.data?(0,j.ensureBuffer)(e.data):b.Buffer.alloc(0),o=e.nonce!=null?(0,j.ensureIntNumber)(e.nonce):null,a=e.gasPrice!=null?(0,j.ensureBigInt)(e.gasPrice):null,c=e.maxFeePerGas!=null?(0,j.ensureBigInt)(e.maxFeePerGas):null,l=e.maxPriorityFeePerGas!=null?(0,j.ensureBigInt)(e.maxPriorityFeePerGas):null,h=e.gas!=null?(0,j.ensureBigInt)(e.gas):null,d=e.chainId?(0,j.ensureIntNumber)(e.chainId):this.getChainId();return{fromAddress:t,toAddress:n,weiValue:s,data:i,nonce:o,gasPriceInWei:a,maxFeePerGas:c,maxPriorityFeePerGas:l,gasLimit:h,chainId:d}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw pe.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw pe.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(e,t,n,s){this._ensureKnownAddress(t);try{const o=await this.initializeRelay().signEthereumMessage(e,t,n,s);if((0,qt.isErrorResponse)(o))throw new Error(o.errorMessage);return{jsonrpc:"2.0",id:0,result:o.result}}catch(i){throw typeof i.message=="string"&&i.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied message signature"):i}}async _ethereumAddressFromSignedMessage(e,t,n){const i=await this.initializeRelay().ethereumAddressFromSignedMessage(e,t,n);if((0,qt.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,j.hexStringFromIntNumber)(this.getChainId())}getChainId(){const e=this._storage.getItem(Wc);if(!e)return(0,j.ensureIntNumber)(1);const t=parseInt(e,10);return(0,j.ensureIntNumber)(t)}async _eth_requestAccounts(){if(this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let e;try{if(e=await this.initializeRelay().requestEthereumAccounts(),(0,qt.isErrorResponse)(e))throw new Error(e.errorMessage)}catch(t){throw typeof t.message=="string"&&t.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied account authorization"):t}if(!e.result)throw new Error("accounts received is empty");return this._setAddresses(e.result),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(e){this._requireAuthorization();const t=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._signEthereumMessage(n,t,!1)}_eth_ecRecover(e){const t=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,n,!1)}_personal_sign(e){this._requireAuthorization();const t=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureAddressString)(e[1]);return this._signEthereumMessage(t,n,!0)}_personal_ecRecover(e){const t=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,n,!0)}async _eth_signTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signEthereumTransaction(t);if((0,qt.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_sendRawTransaction(e){const t=(0,j.ensureBuffer)(e[0]),s=await this.initializeRelay().submitEthereumTransaction(t,this.getChainId());if((0,qt.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}async _eth_sendTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signAndSubmitEthereumTransaction(t);if((0,qt.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_signTypedData_v1(e){this._requireAuthorization();const t=(0,j.ensureParsedJSONObject)(e[0]),n=(0,j.ensureAddressString)(e[1]);this._ensureKnownAddress(n);const s=jc.default.hashForSignTypedDataLegacy({data:t}),i=JSON.stringify(t,null,2);return this._signEthereumMessage(s,n,!1,i)}async _eth_signTypedData_v3(e){this._requireAuthorization();const t=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=jc.default.hashForSignTypedData_v3({data:n}),i=JSON.stringify(n,null,2);return this._signEthereumMessage(s,t,!1,i)}async _eth_signTypedData_v4(e){this._requireAuthorization();const t=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=jc.default.hashForSignTypedData_v4({data:n}),i=JSON.stringify(n,null,2);return this._signEthereumMessage(s,t,!1,i)}async _wallet_addEthereumChain(e){var t,n,s,i;const o=e[0];if(((t=o.rpcUrls)===null||t===void 0?void 0:t.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!o.chainName||o.chainName.trim()==="")throw pe.standardErrors.rpc.invalidParams("chainName is a required field");if(!o.nativeCurrency)throw pe.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const a=parseInt(o.chainId,16);return await this.addEthereumChain(a,(n=o.rpcUrls)!==null&&n!==void 0?n:[],(s=o.blockExplorerUrls)!==null&&s!==void 0?s:[],o.chainName,(i=o.iconUrls)!==null&&i!==void 0?i:[],o.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(e){const t=e[0];return await this.switchEthereumChain(parseInt(t.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(e){const t=Array.isArray(e)?e[0]:e;if(!t.type)throw pe.standardErrors.rpc.invalidParams("Type is required");if((t==null?void 0:t.type)!=="ERC20")throw pe.standardErrors.rpc.invalidParams(`Asset of type '${t.type}' is not supported`);if(!(t!=null&&t.options))throw pe.standardErrors.rpc.invalidParams("Options are required");if(!(t!=null&&t.options.address))throw pe.standardErrors.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:s,symbol:i,image:o,decimals:a}=t.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(t.type,s,i,a,o,n)}}initializeRelay(){if(!this._relay){const e=new Wb.WalletLinkRelay({linkAPIUrl:Uh.WALLETLINK_URL,storage:this._storage});e.setAppInfo(this._appName,this._appLogoUrl),e.attachUI(),e.setAccountsCallback((t,n)=>this._setAddresses(t,n)),e.setChainCallback((t,n)=>{this.updateProviderInfo(n,parseInt(t,10))}),this._relay=e}return this._relay}}ic.WalletLinkSigner=Qb;var ct={};Object.defineProperty(ct,"__esModule",{value:!0});ct.checkErrorForInvalidRequestArgs=ct.getCoinbaseInjectedProvider=ct.getCoinbaseInjectedSigner=ct.fetchRPCRequest=void 0;const zb=Zr,ha=zt;async function Jb(r,e){if(!e.rpcUrl)throw ha.standardErrors.rpc.internal("No RPC URL set for chain");const t=Object.assign(Object.assign({},r),{jsonrpc:"2.0",id:crypto.randomUUID()});return(await(await window.fetch(e.rpcUrl,{method:"POST",body:JSON.stringify(t),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":zb.LIB_VERSION}})).json()).result}ct.fetchRPCRequest=Jb;function fp(){return globalThis.coinbaseWalletSigner}ct.getCoinbaseInjectedSigner=fp;function qb({metadata:r,preference:e}){var t,n,s;const i=globalThis;if(e.options!=="smartWalletOnly"){if(fp())return;const c=i.coinbaseWalletExtension;if(c){const{appName:l,appLogoUrl:h,appChainIds:d}=r;return(t=c.setAppInfo)===null||t===void 0||t.call(c,l,h,d),c}}const o=(n=i.ethereum)!==null&&n!==void 0?n:(s=i.top)===null||s===void 0?void 0:s.ethereum;if(o!=null&&o.isCoinbaseBrowser)return o}ct.getCoinbaseInjectedProvider=qb;function Zb(r){if(!r||typeof r!="object"||Array.isArray(r))return ha.standardErrors.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:r});const{method:e,params:t}=r;if(typeof e!="string"||e.length===0)return ha.standardErrors.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:r});if(t!==void 0&&!Array.isArray(t)&&(typeof t!="object"||t===null))return ha.standardErrors.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:r})}ct.checkErrorForInvalidRequestArgs=Zb;Object.defineProperty(Kt,"__esModule",{value:!0});Kt.createSigner=Kt.fetchSignerType=Kt.storeSignerType=Kt.loadSignerType=void 0;const $b=nc,pp=ic,Yb=zt,Xb=ct,e1=Jt,gp="SignerType",mp=new e1.ScopedLocalStorage("CBWSDK","SignerConfigurator");function t1(){return mp.getItem(gp)}Kt.loadSignerType=t1;function n1(r){mp.setItem(gp,r)}Kt.storeSignerType=n1;async function r1(r){const{communicator:e,metadata:t}=r;i1(e,t).catch(()=>{});const n={id:crypto.randomUUID(),event:"selectSignerType",data:r.preference},{data:s}=await e.postRequestAndWaitForResponse(n);return s}Kt.fetchSignerType=r1;function s1(r){const{signerType:e,metadata:t,communicator:n,updateListener:s}=r;switch(e){case"scw":return new $b.SCWSigner({metadata:t,updateListener:s,communicator:n});case"walletlink":return new pp.WalletLinkSigner({metadata:t,updateListener:s});case"extension":{const i=(0,Xb.getCoinbaseInjectedSigner)();if(!i)throw Yb.standardErrors.rpc.internal("injected signer not found");return i}}}Kt.createSigner=s1;async function i1(r,e){await r.onMessage(({event:n})=>n==="WalletLinkSessionRequest");const t=new pp.WalletLinkSigner({metadata:e});r.postMessage({event:"WalletLinkUpdate",data:{session:t.getSession()}}),await t.handshake(),r.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var gc={},xi={};Object.defineProperty(xi,"__esModule",{value:!0});xi.closePopup=xi.openPopup=void 0;const o1=zt,Dh=420,Fh=540;function a1(r){const e=(window.innerWidth-Dh)/2+window.screenX,t=(window.innerHeight-Fh)/2+window.screenY,n=window.open(r,"Smart Wallet",`width=${Dh}, height=${Fh}, left=${e}, top=${t}`);if(n==null||n.focus(),!n)throw o1.standardErrors.rpc.internal("Pop up window failed to open");return n}xi.openPopup=a1;function c1(r){r&&!r.closed&&r.close()}xi.closePopup=c1;Object.defineProperty(gc,"__esModule",{value:!0});gc.Communicator=void 0;const l1=Zr,Hh=xi,u1=Vt,Gh=zt;class h1{constructor(e=u1.CB_KEYS_URL){this.popup=null,this.listeners=new Map,this.postMessage=async t=>{(await this.waitForPopupLoaded()).postMessage(t,this.url.origin)},this.postRequestAndWaitForResponse=async t=>{const n=this.onMessage(({requestId:s})=>s===t.id);return this.postMessage(t),await n},this.onMessage=async t=>new Promise((n,s)=>{const i=o=>{if(o.origin!==this.url.origin)return;const a=o.data;t(a)&&(n(a),window.removeEventListener("message",i),this.listeners.delete(i))};window.addEventListener("message",i),this.listeners.set(i,{reject:s})}),this.disconnect=()=>{(0,Hh.closePopup)(this.popup),this.popup=null,this.listeners.forEach(({reject:t},n)=>{t(Gh.standardErrors.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",n)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?this.popup:(this.popup=(0,Hh.openPopup)(this.url),this.onMessage(({event:t})=>t==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:t})=>t==="PopupLoaded").then(t=>{this.postMessage({requestId:t.id,data:{version:l1.LIB_VERSION}})}).then(()=>{if(!this.popup)throw Gh.standardErrors.rpc.internal();return this.popup})),this.url=new URL(e)}}gc.Communicator=h1;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});mc.determineMethodCategory=void 0;const Kh={handshake:["eth_requestAccounts"],sign:["eth_ecRecover","personal_sign","personal_ecRecover","eth_signTransaction","eth_sendTransaction","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","eth_signTypedData","wallet_addEthereumChain","wallet_switchEthereumChain","wallet_watchAsset","wallet_getCapabilities","wallet_sendCalls","wallet_showCallsStatus"],state:["eth_chainId","eth_accounts","eth_coinbase","net_version"],deprecated:["eth_sign","eth_signTypedData_v2"],unsupported:["eth_subscribe","eth_unsubscribe"],fetch:[]};function d1(r){for(const e in Kh){const t=e;if(Kh[t].includes(r))return t}}mc.determineMethodCategory=d1;var f1=b.commonjsGlobal&&b.commonjsGlobal.__rest||function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},p1=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ya,"__esModule",{value:!0});Ya.CoinbaseWalletProvider=void 0;const g1=p1(b.eventemitter3Exports),ls=zt,m1=ec,Xo=Se,Ui=U,ea=Kt,jh=ct,y1=gc,w1=mc,b1=Jt;class A1 extends g1.default{constructor(e){var t,n,{metadata:s}=e,i=e.preference,{keysUrl:o}=i,a=f1(i,["keysUrl"]);super(),this.accounts=[],this.handlers={handshake:async l=>{try{if(this.connected)return this.emit("connect",{chainId:(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(this.chain.id))}),this.accounts;const h=await this.requestSignerSelection(),d=this.initSigner(h),f=await d.handshake();return this.signer=d,(0,ea.storeSignerType)(h),this.emit("connect",{chainId:(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(this.chain.id))}),f}catch(h){throw this.handleUnauthorizedError(h),h}},sign:async l=>{if(!this.connected||!this.signer)throw ls.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");try{return await this.signer.request(l)}catch(h){throw this.handleUnauthorizedError(h),h}},fetch:l=>(0,jh.fetchRPCRequest)(l,this.chain),state:l=>{const h=()=>{if(this.connected)return this.accounts;throw ls.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")};switch(l.method){case"eth_chainId":return(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(this.chain.id));case"net_version":return this.chain.id;case"eth_accounts":return h();case"eth_coinbase":return h()[0];default:return this.handlers.unsupported(l)}},deprecated:({method:l})=>{throw ls.standardErrors.rpc.methodNotSupported(`Method ${l} is deprecated.`)},unsupported:({method:l})=>{throw ls.standardErrors.rpc.methodNotSupported(`Method ${l} is not supported.`)}},this.isCoinbaseWallet=!0,this.updateListener={onAccountsUpdate:({accounts:l,source:h})=>{(0,Ui.areAddressArraysEqual)(this.accounts,l)||(this.accounts=l,h!=="storage"&&this.emit("accountsChanged",this.accounts))},onChainUpdate:({chain:l,source:h})=>{l.id===this.chain.id&&l.rpcUrl===this.chain.rpcUrl||(this.chain=l,h!=="storage"&&this.emit("chainChanged",(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(l.id))))}},this.metadata=s,this.preference=a,this.communicator=new y1.Communicator(o),this.chain={id:(n=(t=s.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1};const c=(0,ea.loadSignerType)();this.signer=c?this.initSigner(c):null}get connected(){return this.accounts.length>0}async request(e){var t;try{const n=(0,jh.checkErrorForInvalidRequestArgs)(e);if(n)throw n;const s=(t=(0,w1.determineMethodCategory)(e.method))!==null&&t!==void 0?t:"fetch";return this.handlers[s](e)}catch(n){return Promise.reject((0,m1.serializeError)(n,e.method))}}handleUnauthorizedError(e){e.code===ls.standardErrorCodes.provider.unauthorized&&this.disconnect()}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),await this.request({method:"eth_requestAccounts"})}async disconnect(){this.accounts=[],this.chain={id:1},b1.ScopedLocalStorage.clearAll(),this.emit("disconnect",ls.standardErrors.provider.disconnected("User initiated disconnection"))}requestSignerSelection(){return(0,ea.fetchSignerType)({communicator:this.communicator,preference:this.preference,metadata:this.metadata})}initSigner(e){return(0,ea.createSigner)({signerType:e,metadata:this.metadata,communicator:this.communicator,updateListener:this.updateListener})}}Ya.CoinbaseWalletProvider=A1;Object.defineProperty(no,"__esModule",{value:!0});no.CoinbaseWalletSDK=void 0;const E1=$a,C1=Ya,v1=Jt,I1=Zr,N1=U,S1=ct;class k1{constructor(e){this.metadata={appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||(0,N1.getFavicon)(),appChainIds:e.appChainIds||[]},this.storeLatestVersion()}makeWeb3Provider(e={options:"all"}){var t;const n={metadata:this.metadata,preference:e};return(t=(0,S1.getCoinbaseInjectedProvider)(n))!==null&&t!==void 0?t:new C1.CoinbaseWalletProvider(n)}getCoinbaseWalletLogo(e,t=240){return(0,E1.walletLogo)(e,t)}storeLatestVersion(){new v1.ScopedLocalStorage("CBWSDK").setItem("VERSION",I1.LIB_VERSION)}}no.CoinbaseWalletSDK=k1;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.CoinbaseWalletSDK=void 0;const e=no;r.default=e.CoinbaseWalletSDK;var t=no;Object.defineProperty(r,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return t.CoinbaseWalletSDK}})})(Hf);class x1{createEthersConfig(e){if(!e.metadata)return;let t,n;function s(){if(t)return t;if(!(typeof window>"u")&&window.ethereum)return t=window.ethereum,t}function i(){var c,l,h;return n||(typeof window>"u"?void 0:(n=new Hf.CoinbaseWalletSDK({appName:(c=e==null?void 0:e.metadata)==null?void 0:c.name,appLogoUrl:(l=e==null?void 0:e.metadata)==null?void 0:l.icons[0],appChainIds:((h=e.networks)==null?void 0:h.map(d=>d.chainId))||[1,84532]}).makeWeb3Provider({options:e.coinbasePreference??"all"}),n))}const o={metadata:e.metadata};return e.enableInjected!==!1&&(o.injected=s()),e.enableCoinbase!==!1&&(o.coinbase=i()),o.EIP6963=e.enableEIP6963!==!1,o}constructor(){var e,t;this.appKit=void 0,this.EIP6963Providers=[],this.options=void 0,this.caipNetworks=[],this.chainNamespace=b.ConstantsUtil$1.CHAIN.EVM,this.siweControllerClient=(e=this.options)==null?void 0:e.siweConfig,this.tokens=b.HelpersUtil.getCaipTokens((t=this.options)==null?void 0:t.tokens),this.defaultCaipNetwork=void 0,this.adapterType="ethers",this.providerHandlers=null,b.ChainController.subscribeKey("activeCaipNetwork",n=>{var a;const s=(a=this.appKit)==null?void 0:a.getCaipAddress(this.chainNamespace),i=s==null?void 0:s.startsWith("eip155:"),o=(n==null?void 0:n.chainNamespace)===this.chainNamespace;i&&o&&s&&(this.syncBalance(b.CoreHelperUtil.getPlainAddress(s),n),this.syncAccount({address:b.CoreHelperUtil.getPlainAddress(s),caipNetwork:n}))}),b.ChainController.subscribeKey("activeCaipAddress",n=>{const s=n==null?void 0:n.startsWith("eip155:"),i=b.ChainController.state.activeCaipNetwork,o=(i==null?void 0:i.chainNamespace)===this.chainNamespace;s&&(o&&this.syncBalance(b.CoreHelperUtil.getPlainAddress(n),i),this.syncAccount({address:b.CoreHelperUtil.getPlainAddress(n)}))}),b.AccountController.subscribeKey("shouldUpdateToAddress",n=>{(n==null?void 0:n.startsWith("0x"))&&this.syncAccount({address:n})},this.chainNamespace)}construct(e,t){var i,o,a,c,l,h,d;if(!t.projectId)throw new Error("appkit:ethers-client:initialize - projectId is undefined");this.appKit=e,this.options=t,this.caipNetworks=t.networks.map(f=>({...f,rpcUrl:b.CaipNetworksUtil.extendRpcUrlWithProjectId(f.rpcUrl,t.projectId)})),this.defaultCaipNetwork=t.defaultNetwork||t.networks[0],this.tokens=b.HelpersUtil.getCaipTokens(t.tokens),this.ethersConfig=this.createEthersConfig(t),this.networkControllerClient={switchCaipNetwork:async f=>{if(f!=null&&f.chainId)try{await this.switchNetwork(f)}catch{throw new Error("networkControllerClient:switchCaipNetwork - unable to switch chain")}},getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},this.connectionControllerClient={connectWalletConnect:async f=>{var g,w,m,C;await((C=(m=(w=(g=this.appKit)==null?void 0:g.universalAdapter)==null?void 0:w.connectionControllerClient)==null?void 0:m.connectWalletConnect)==null?void 0:C.call(m,f))},connectExternal:async({id:f,info:g,provider:w})=>{var k;(k=this.appKit)==null||k.setClientId(null);const C={[b.ConstantsUtil.INJECTED_CONNECTOR_ID]:{getProvider:()=>{var S;return(S=this.ethersConfig)==null?void 0:S.injected},providerType:"injected"},[b.ConstantsUtil.EIP6963_CONNECTOR_ID]:{getProvider:()=>w,providerType:"eip6963"},[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID]:{getProvider:()=>{var S;return(S=this.ethersConfig)==null?void 0:S.coinbase},providerType:"coinbase"},[b.ConstantsUtil.AUTH_CONNECTOR_ID]:{getProvider:()=>this.authProvider,providerType:"w3mAuth"}}[f];if(!C)throw new Error(`Unsupported connector ID: ${f}`);const v=C.getProvider();if(!v)throw new Error(`Provider for connector ${f} is undefined`);try{v&&f!==b.ConstantsUtil.AUTH_CONNECTOR_ID&&await v.request({method:"eth_requestAccounts"}),await this.setProvider(v,C.providerType,g==null?void 0:g.name)}catch(S){if(f===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID)throw new Error(S.message)}},checkInstalled:f=>{var g;return f?(g=this.ethersConfig)!=null&&g.injected&&!(window!=null&&window.ethereum)?!1:f.some(w=>{var m;return!!((m=window.ethereum)!=null&&m[String(w)])}):!!window.ethereum},disconnect:async()=>{var C,v,k,S,B;const f=b.ProviderUtil.getProvider("eip155"),g=b.ProviderUtil.state.providerIds.eip155;if((C=this.appKit)==null||C.setClientId(null),(S=(k=(v=this.options)==null?void 0:v.siweConfig)==null?void 0:k.options)!=null&&S.signOutOnDisconnect){const{SIWEController:P}=await Promise.resolve().then(()=>require("./index-C0D6DuSI.cjs"));await P.signOut()}const m={[b.ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]:async()=>{var P,R,M;return await((M=(R=(P=this.appKit)==null?void 0:P.universalAdapter)==null?void 0:R.connectionControllerClient)==null?void 0:M.disconnect())},coinbaseWalletSDK:async()=>{var P,R,M;return await((M=(R=(P=this.appKit)==null?void 0:P.universalAdapter)==null?void 0:R.connectionControllerClient)==null?void 0:M.disconnect())},[b.ConstantsUtil.AUTH_CONNECTOR_ID]:async()=>{var P;await((P=this.authProvider)==null?void 0:P.disconnect())},[b.ConstantsUtil.EIP6963_CONNECTOR_ID]:async()=>{f&&await this.revokeProviderPermissions(f)},[b.ConstantsUtil.INJECTED_CONNECTOR_ID]:async()=>{f&&(f.emit("disconnect"),await this.revokeProviderPermissions(f))}}[g];m?await m():console.warn(`No disconnect function found for provider type: ${g}`),b.SafeLocalStorage.removeItem(b.SafeLocalStorageKeys.WALLET_ID),(B=this.appKit)==null||B.resetAccount(this.chainNamespace)},signMessage:async f=>{const g=b.ProviderUtil.getProvider(this.chainNamespace),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w);if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.signMessage(f,g,m)},parseUnits:Pn.parseUnits,formatUnits:Pn.formatUnits,estimateGas:async f=>{var v;if(f.chainNamespace&&f.chainNamespace!=="eip155")throw new Error(`Invalid chain namespace - Expected eip155, got ${f.chainNamespace}`);const g=b.ProviderUtil.getProvider("eip155"),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w),C=(v=this.appKit)==null?void 0:v.getCaipNetwork();if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.estimateGas(f,g,m,Number(C==null?void 0:C.chainId))},sendTransaction:async f=>{var v;if(f.chainNamespace&&f.chainNamespace!=="eip155")throw new Error(`Invalid chain namespace - Expected eip155, got ${f.chainNamespace}`);const g=b.ProviderUtil.getProvider("eip155"),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w),C=(v=this.appKit)==null?void 0:v.getCaipNetwork();if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.sendTransaction(f,g,m,Number(C==null?void 0:C.chainId))},writeContract:async f=>{var v;const g=b.ProviderUtil.getProvider("eip155"),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w),C=(v=this.appKit)==null?void 0:v.getCaipNetwork();if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.writeContract(f,g,m,Number(C==null?void 0:C.chainId))},getEnsAddress:async f=>this.appKit?await Pn.getEnsAddress(f,this.appKit):!1,getEnsAvatar:async f=>{var w;const g=(w=this.appKit)==null?void 0:w.getCaipNetwork();return await Pn.getEnsAvatar(f,Number(g==null?void 0:g.chainId))}},b.ChainController.state.chains.set(this.chainNamespace,{chainNamespace:this.chainNamespace,connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient,adapterType:this.adapterType,caipNetworks:this.caipNetworks}),this.ethersConfig&&this.syncConnectors(this.ethersConfig),typeof window<"u"&&this.listenConnectors(!0),(o=this.appKit)==null||o.setEIP6963Enabled((i=this.ethersConfig)==null?void 0:i.EIP6963);const n=((a=t.features)==null?void 0:a.email)===void 0?b.ConstantsUtil$2.DEFAULT_FEATURES.email:(c=t.features)==null?void 0:c.email,s=(l=t.features)!=null&&l.socials?((d=(h=t.features)==null?void 0:h.socials)==null?void 0:d.length)>0:b.ConstantsUtil$2.DEFAULT_FEATURES.socials;(n||s)&&this.syncAuthConnector(this.options.projectId),this.ethersConfig&&this.checkActiveProviders(this.ethersConfig),this.syncRequestedNetworks(this.caipNetworks)}subscribeState(e){var t;return(t=this.appKit)==null?void 0:t.subscribeState(n=>e(n))}async disconnect(){var e;await((e=this.connectionControllerClient)==null?void 0:e.disconnect())}async revokeProviderPermissions(e){try{(await e.request({method:"wallet_getPermissions"})).find(s=>s.parentCapability==="eth_accounts")&&await e.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]})}catch(t){console.info("Could not revoke permissions from wallet. Disconnecting...",t)}}getApprovedCaipNetworksData(){return new Promise(e=>{const t=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_ID);if(!t)throw new Error("No wallet id found to get approved networks data");const s={[b.ConstantsUtil.AUTH_CONNECTOR_ID]:{supportsAllNetworks:!0,approvedCaipNetworkIds:b.PresetsUtil.WalletConnectRpcChainIds.map(i=>`${b.ConstantsUtil.EIP155}:${i}`)}}[t];e(s||{supportsAllNetworks:!0,approvedCaipNetworkIds:[]})})}checkActiveProviders(e){var o;const t=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_ID),n=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_NAME);if(!t)return;const i={[b.ConstantsUtil.INJECTED_CONNECTOR_ID]:{provider:e.injected},[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID]:{provider:e.coinbase},[b.ConstantsUtil.EIP6963_CONNECTOR_ID]:{provider:(o=this.EIP6963Providers.find(a=>a.info.name===n))==null?void 0:o.provider}}[t];i!=null&&i.provider&&(this.setProvider(i.provider,t),this.setupProviderListeners(i.provider,t))}async setProvider(e,t,n){var s,i,o,a;if(t==="w3mAuth")this.setAuthProvider();else{const c=t;if(b.SafeLocalStorage.setItem(b.SafeLocalStorageKeys.WALLET_ID,c),n&&b.SafeLocalStorage.setItem(b.SafeLocalStorageKeys.WALLET_NAME,n),e){const{addresses:l,chainId:h}=await ur.getUserInfo(e),d=l==null?void 0:l[0],f=this.caipNetworks.find(w=>w.chainId===h),g=`${this.chainNamespace}:${h}:${d}`;d&&h&&f&&((s=this.appKit)==null||s.setCaipAddress(g,this.chainNamespace),(i=this.appKit)==null||i.setCaipNetwork(f),b.ProviderUtil.setProviderId("eip155",t),b.ProviderUtil.setProvider("eip155",e),(o=this.appKit)==null||o.setStatus("connected",this.chainNamespace),(a=this.appKit)==null||a.setAllAccounts(l.map(w=>({address:w,type:"eoa"})),this.chainNamespace))}}}async setAuthProvider(){var e,t,n,s,i,o,a,c,l,h,d,f;if(b.SafeLocalStorage.setItem(b.SafeLocalStorageKeys.WALLET_ID,b.ConstantsUtil.AUTH_CONNECTOR_ID),this.authProvider){(e=this.appKit)==null||e.setLoading(!0);const{address:g,chainId:w,smartAccountDeployed:m,preferredAccountType:C,accounts:v=[]}=await this.authProvider.connect({chainId:Number(b.NetworkUtil.caipNetworkIdToNumber((n=(t=this.appKit)==null?void 0:t.getCaipNetwork())==null?void 0:n.id)??((s=this.caipNetworks[0])==null?void 0:s.chainId))}),{smartAccountEnabledNetworks:k}=await this.authProvider.getSmartAccountEnabledNetworks();if((i=this.appKit)==null||i.setSmartAccountEnabledNetworks(k,this.chainNamespace),g&&w){(o=this.appKit)==null||o.setAllAccounts(v.length>0?v:[{address:g,type:C}],this.chainNamespace);const S=this.caipNetworks.find(B=>B.chainId===w);(a=this.appKit)==null||a.setCaipNetwork(S),(c=this.appKit)==null||c.setStatus("connected",this.chainNamespace),(l=this.appKit)==null||l.setCaipAddress(`${this.chainNamespace}:${w}:${g}`,this.chainNamespace),(h=this.appKit)==null||h.setPreferredAccountType(C,this.chainNamespace),(d=this.appKit)==null||d.setSmartAccountDeployed(!!m,this.chainNamespace),b.ProviderUtil.setProvider("eip155",this.authProvider),b.ProviderUtil.setProviderId("eip155",b.ConstantsUtil.AUTH_CONNECTOR_ID),this.setupProviderListeners(this.authProvider,"w3mAuth"),this.watchModal()}(f=this.appKit)==null||f.setLoading(!1)}}watchModal(){this.authProvider&&this.subscribeState(e=>{var t;e.open||(t=this.authProvider)==null||t.rejectRpcRequests()})}setupProviderListeners(e,t){const n=()=>{b.SafeLocalStorage.removeItem(b.SafeLocalStorageKeys.WALLET_ID),this.removeListeners(e)},s=o=>{var c,l,h,d;const a=o==null?void 0:o[0];a?((c=this.appKit)==null||c.setCaipAddress(a,this.chainNamespace),t===b.ConstantsUtil.EIP6963_CONNECTOR_ID&&((l=this.appKit)==null||l.setAllAccounts(o.map(f=>({address:f,type:"eoa"})),this.chainNamespace))):(t===b.ConstantsUtil.EIP6963_CONNECTOR_ID&&((h=this.appKit)==null||h.setAllAccounts([],this.chainNamespace)),b.SafeLocalStorage.removeItem(b.SafeLocalStorageKeys.WALLET_ID),(d=this.appKit)==null||d.resetAccount(this.chainNamespace))},i=o=>{var a;if(o){const c=typeof o=="string"?ur.hexStringToNumber(o):Number(o),l=this.caipNetworks.find(h=>h.chainId===c);(a=this.appKit)==null||a.setCaipNetwork(l)}};t===b.ConstantsUtil.AUTH_CONNECTOR_ID?this.setupAuthListeners(e):(e.on("disconnect",n),e.on("accountsChanged",s),e.on("chainChanged",i)),this.providerHandlers={disconnect:n,accountsChanged:s,chainChanged:i}}removeListeners(e){this.providerHandlers&&(e.removeListener("disconnect",this.providerHandlers.disconnect),e.removeListener("accountsChanged",this.providerHandlers.accountsChanged),e.removeListener("chainChanged",this.providerHandlers.chainChanged),this.providerHandlers=null)}setupAuthListeners(e){e.onRpcRequest(t=>{var n;b.W3mFrameHelpers.checkIfRequestExists(t)?b.W3mFrameHelpers.checkIfRequestIsSafe(t)||(n=this.appKit)==null||n.handleUnsafeRPCRequest():this.handleInvalidAuthRequest()}),e.onRpcError(()=>this.handleAuthRpcError()),e.onRpcSuccess((t,n)=>this.handleAuthRpcSuccess(t,n)),e.onNotConnected(()=>this.handleAuthNotConnected()),e.onIsConnected(({preferredAccountType:t})=>this.handleAuthIsConnected(t)),e.onSetPreferredAccount(({address:t,type:n})=>{t&&this.handleAuthSetPreferredAccount(t,n)})}handleInvalidAuthRequest(){var e;(e=this.appKit)==null||e.open(),setTimeout(()=>{var t;(t=this.appKit)==null||t.showErrorMessage(b.W3mFrameRpcConstants.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300)}handleAuthRpcError(){var e,t,n,s;(e=this.appKit)!=null&&e.isOpen()&&((t=this.appKit)!=null&&t.isTransactionStackEmpty()?(n=this.appKit)==null||n.close():(s=this.appKit)==null||s.popTransactionStack(!0))}handleAuthRpcSuccess(e,t){var s,i,o;b.W3mFrameHelpers.checkIfRequestIsSafe(t)||((s=this.appKit)!=null&&s.isTransactionStackEmpty()?(i=this.appKit)==null||i.close():(o=this.appKit)==null||o.popTransactionStack())}handleAuthNotConnected(){var e;(e=this.appKit)==null||e.setCaipAddress(void 0,this.chainNamespace)}handleAuthIsConnected(e){var n,s;((n=this.appKit)==null?void 0:n.getActiveChainNamespace())===this.chainNamespace&&((s=this.appKit)==null||s.setPreferredAccountType(e,this.chainNamespace))}handleAuthSetPreferredAccount(e,t){var i,o,a,c,l,h,d,f;if(!e)return;(i=this.appKit)==null||i.setLoading(!0);const n=b.NetworkUtil.caipNetworkIdToNumber((a=(o=this.appKit)==null?void 0:o.getCaipNetwork())==null?void 0:a.id),s=this.caipNetworks.find(g=>g.chainId===n);(c=this.appKit)==null||c.setCaipAddress(`eip155:${n}:${e}`,this.chainNamespace),(l=this.appKit)==null||l.setCaipNetwork(s),(h=this.appKit)==null||h.setStatus("connected",this.chainNamespace),(d=this.appKit)==null||d.setPreferredAccountType(t,this.chainNamespace),this.syncAccount({address:e}).then(()=>{var g;return(g=this.appKit)==null?void 0:g.setLoading(!1)}),(f=this.appKit)==null||f.setLoading(!1)}async syncReownName(e){var t,n,s,i;try{const o=await((t=this.appKit)==null?void 0:t.getReownName(e));if(o!=null&&o[0]){const a=o[0];(n=this.appKit)==null||n.setProfileName(a.name,this.chainNamespace)}else(s=this.appKit)==null||s.setProfileName(null,this.chainNamespace)}catch{(i=this.appKit)==null||i.setProfileName(null,this.chainNamespace)}}async syncAccount({address:e,caipNetwork:t}){var o,a,c,l,h,d,f,g;const n=t||((o=this.appKit)==null?void 0:o.getCaipNetwork()),s=(a=this.appKit)==null?void 0:a.getPreferredAccountType(),i=(n==null?void 0:n.chainNamespace)===b.ConstantsUtil$1.CHAIN.EVM;e?i&&((c=this.appKit)==null||c.setPreferredAccountType(s,this.chainNamespace),this.syncConnectedWalletInfo(),this.ethersConfig&&this.checkActiveProviders(this.ethersConfig),n!=null&&n.explorerUrl&&((l=this.appKit)==null||l.setAddressExplorerUrl(`${n.explorerUrl}/address/${e}`,this.chainNamespace)),await Promise.all([this.syncProfile(e),(h=this.appKit)==null?void 0:h.setApprovedCaipNetworksData(this.chainNamespace)])):((d=this.appKit)==null||d.resetWcConnection(),(f=this.appKit)==null||f.resetNetwork(),(g=this.appKit)==null||g.setAllAccounts([],this.chainNamespace))}async syncProfile(e){var n,s,i,o,a,c,l;const t=(n=this.appKit)==null?void 0:n.getCaipNetwork();try{const h=await((s=this.appKit)==null?void 0:s.fetchIdentity({address:e})),d=h==null?void 0:h.name,f=h==null?void 0:h.avatar;(i=this.appKit)==null||i.setProfileName(d,this.chainNamespace),(o=this.appKit)==null||o.setProfileImage(f,this.chainNamespace),d||await this.syncReownName(e)}catch{if((t==null?void 0:t.chainId)===1){const h=new Jr("mainnet"),d=await h.lookupAddress(e),f=await h.getAvatar(e);d?(a=this.appKit)==null||a.setProfileName(d,this.chainNamespace):await this.syncReownName(e),f&&((c=this.appKit)==null||c.setProfileImage(f,this.chainNamespace))}else await this.syncReownName(e),(l=this.appKit)==null||l.setProfileImage(null,this.chainNamespace)}}async syncBalance(e,t){var i,o;const n=(i=this.appKit)==null?void 0:i.getCaipNetworks().find(a=>a.id===t.id),s=t.chainNamespace===b.ConstantsUtil$1.CHAIN.EVM;if(t&&n&&s){const a=new Ff(t.rpcUrl,{chainId:t.chainId,name:t.name});if(a){const c=await a.getBalance(e),l=jp(c);(o=this.appKit)==null||o.setBalance(l,t.currency,this.chainNamespace)}}}syncConnectedWalletInfo(){var n,s,i,o,a,c,l;const e=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_ID),t=b.ProviderUtil.state.providerIds.eip155;if(t===b.ConstantsUtil.EIP6963_CONNECTOR_ID){if(e){const h=this.EIP6963Providers.find(d=>d.info.name===e);h&&((n=this.appKit)==null||n.setConnectedWalletInfo({...h.info},this.chainNamespace))}}else if(t===b.ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID){const h=b.ProviderUtil.getProvider("eip155");h!=null&&h.session&&((i=this.appKit)==null||i.setConnectedWalletInfo({...h.session.peer.metadata,name:h.session.peer.metadata.name,icon:(s=h.session.peer.metadata.icons)==null?void 0:s[0]},this.chainNamespace))}else if(t===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID){const h=(o=this.appKit)==null?void 0:o.getConnectors().find(d=>d.id===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID);(c=this.appKit)==null||c.setConnectedWalletInfo({name:"Coinbase Wallet",icon:(a=this.appKit)==null?void 0:a.getConnectorImage(h)},this.chainNamespace)}else e&&((l=this.appKit)==null||l.setConnectedWalletInfo({name:e},this.chainNamespace))}syncRequestedNetworks(e){[...new Set(e.map(n=>n.chainNamespace))].forEach(n=>{var s;(s=this.appKit)==null||s.setRequestedCaipNetworks(e.filter(i=>i.chainNamespace===n),n)})}async switchNetwork(e){var i,o,a,c,l,h,d,f;const t=async g=>{var w,m,C;try{await g.request({method:"wallet_switchEthereumChain",params:[{chainId:ur.numberToHexString(e.chainId)}]}),(w=this.appKit)==null||w.setCaipNetwork(e)}catch(v){if(v.code===bc.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||v.code===bc.ERROR_CODE_DEFAULT||((C=(m=v==null?void 0:v.data)==null?void 0:m.originalError)==null?void 0:C.code)===bc.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)await ur.addEthereumChain(g,e);else throw new Error("Chain is not supported")}},n=b.ProviderUtil.getProvider("eip155"),s=b.ProviderUtil.state.providerIds.eip155;if(n)switch(s){case b.ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID:(o=(i=this.appKit)==null?void 0:i.universalAdapter)==null||o.networkControllerClient.switchCaipNetwork(e);break;case b.ConstantsUtil.INJECTED_CONNECTOR_ID:case b.ConstantsUtil.EIP6963_CONNECTOR_ID:case b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID:n&&await t(n);break;case b.ConstantsUtil.AUTH_CONNECTOR_ID:if(this.authProvider)try{(a=this.appKit)==null||a.setLoading(!0);const{chainId:g}=await this.authProvider.switchNetwork(e.chainId),{address:w,preferredAccountType:m}=await this.authProvider.connect({chainId:e.chainId}),C=`${this.chainNamespace}:${g}:${w}`;(c=this.appKit)==null||c.setCaipNetwork(e),(l=this.appKit)==null||l.setCaipAddress(C,this.chainNamespace),(h=this.appKit)==null||h.setPreferredAccountType(m,this.chainNamespace),await this.syncAccount({address:w}),(d=this.appKit)==null||d.setLoading(!1)}catch{throw new Error("Switching chain failed")}finally{(f=this.appKit)==null||f.setLoading(!1)}break;default:throw new Error("Unsupported provider type")}}syncConnectors(e){var n,s,i,o,a;const t=[];if(e.injected){const c=b.PresetsUtil.ConnectorTypesMap[b.ConstantsUtil.INJECTED_CONNECTOR_ID];t.push({id:b.ConstantsUtil.INJECTED_CONNECTOR_ID,explorerId:b.PresetsUtil.ConnectorExplorerIds[b.ConstantsUtil.INJECTED_CONNECTOR_ID],imageId:b.PresetsUtil.ConnectorImageIds[b.ConstantsUtil.INJECTED_CONNECTOR_ID],imageUrl:(s=(n=this.options)==null?void 0:n.connectorImages)==null?void 0:s[b.ConstantsUtil.INJECTED_CONNECTOR_ID],name:b.PresetsUtil.ConnectorNamesMap[b.ConstantsUtil.INJECTED_CONNECTOR_ID],type:c,chain:this.chainNamespace})}e.coinbase&&t.push({id:b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID,explorerId:b.PresetsUtil.ConnectorExplorerIds[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],imageId:b.PresetsUtil.ConnectorImageIds[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],imageUrl:(o=(i=this.options)==null?void 0:i.connectorImages)==null?void 0:o[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],name:b.PresetsUtil.ConnectorNamesMap[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],type:"EXTERNAL",chain:this.chainNamespace}),(a=this.appKit)==null||a.setConnectors(t)}async syncAuthConnector(e,t=!1){var n,s,i,o;if(t||typeof window<"u"){this.authProvider=b.W3mFrameProviderSingleton.getInstance(e),(n=this.appKit)==null||n.addConnector({id:b.ConstantsUtil.AUTH_CONNECTOR_ID,type:"AUTH",name:"Auth",provider:this.authProvider,chain:this.chainNamespace}),(s=this.appKit)==null||s.setLoading(!0);const a=this.authProvider.getLoginEmailUsed();(i=this.appKit)==null||i.setLoading(a);const{isConnected:c}=await this.authProvider.isConnected();c?await this.setAuthProvider():(o=this.appKit)==null||o.setLoading(!1)}}eip6963EventHandler(e){var t,n,s,i;if(e.detail){const{info:o,provider:a}=e.detail,c=(t=this.appKit)==null?void 0:t.getConnectors(),l=c==null?void 0:c.find(f=>f.name===o.name),d=(c==null?void 0:c.find(f=>f.id===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID))&&e.detail.info.rdns===b.ConstantsUtil.CONNECTOR_RDNS_MAP[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID];if(!l&&!d){const f=b.PresetsUtil.ConnectorTypesMap[b.ConstantsUtil.EIP6963_CONNECTOR_ID];{(i=this.appKit)==null||i.addConnector({id:b.ConstantsUtil.EIP6963_CONNECTOR_ID,type:f,imageUrl:o.icon??((s=(n=this.options)==null?void 0:n.connectorImages)==null?void 0:s[b.ConstantsUtil.EIP6963_CONNECTOR_ID]),name:o.name,provider:a,info:o,chain:this.chainNamespace});const g={provider:a,info:o};this.EIP6963Providers.push(g)}}}}listenConnectors(e){if(typeof window<"u"&&e){const t=this.eip6963EventHandler.bind(this);window.addEventListener(b.ConstantsUtil.EIP6963_ANNOUNCE_EVENT,t),window.dispatchEvent(new Event(b.ConstantsUtil.EIP6963_REQUEST_EVENT))}}}const P1="@reown/appkit-ethers",R1="1.0.0",O1="module",T1="./dist/esm/exports/index.js",B1="./dist/types/exports/index.d.ts",_1=["dist","!tsconfig.tsbuildinfo"],L1={".":{types:"./dist/types/exports/index.d.ts",import:"./dist/esm/exports/index.js",default:"./dist/esm/exports/index.js"},"./react":{types:"./dist/types/exports/react.d.ts",import:"./dist/esm/exports/react.js",default:"./dist/esm/exports/react.js"},"./vue":{types:"./dist/types/exports/vue.d.ts",import:"./dist/esm/exports/vue.js",default:"./dist/esm/exports/vue.js"}},U1={"*":{react:["./dist/types/exports/react.d.ts"],vue:["./dist/types/exports/vue.d.ts"]}},M1={"build:clean":"rm -rf dist",build:"tsc --build",watch:"tsc --watch",typecheck:"tsc --noEmit",lint:"eslint . --ext .js,.jsx,.ts,.tsx"},D1={"@coinbase/wallet-sdk":"4.0.3","@walletconnect/utils":"2.16.1","@reown/appkit":"workspace:*","@reown/appkit-adapter-ethers":"workspace:*","@reown/appkit-common":"workspace:*","@reown/appkit-wallet":"workspace:*","@reown/appkit-polyfills":"workspace:*","@reown/appkit-utils":"workspace:*","@reown/appkit-siwe":"workspace:*",valtio:"1.11.2"},F1={ethers:">=6.0.0",react:">=17","react-dom":">=17",vue:">=3"},H1={react:"18.2.0","react-dom":"18.2.0",vue:"3.4.3"},G1={react:{optional:!0},"react-dom":{optional:!0},vue:{optional:!0}},K1="Reown <support@reown.com> (https://reown.com)",j1="Apache-2.0",W1="https://github.com/reown-com/appkit",V1={type:"git",url:"git+https://github.com/WalletConnect/shadow-appkit.git"},Q1={url:"https://github.com/reown-com/appkit/issues"},z1={name:P1,version:R1,type:O1,main:T1,types:B1,files:_1,exports:L1,typesVersions:U1,scripts:M1,dependencies:D1,peerDependencies:F1,devDependencies:H1,peerDependenciesMeta:G1,author:K1,license:j1,homepage:W1,repository:V1,bugs:Q1};function J1(r){const e=new x1;return new b.AppKit({...r,sdkVersion:`html-ethers-${z1.version}`,adapters:[e]})}const q1=Object.freeze(Object.defineProperty({__proto__:null,createAppKit:J1},Symbol.toStringTag,{value:"Module"}));exports.AppKit=q1;
1
+ "use strict";var yp=Object.defineProperty;var wp=(r,e,t)=>e in r?yp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var E=(r,e,t)=>(wp(r,typeof e!="symbol"?e+"":e,t),t),wc=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var u=(r,e,t)=>(wc(r,e,"read from private field"),t?t.call(r):e.get(r)),A=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},p=(r,e,t,n)=>(wc(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var Ti=(r,e,t,n)=>({set _(s){p(r,e,s,t)},get _(){return u(r,e,n)}}),N=(r,e,t)=>(wc(r,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./W3MFrameProviderSingleton-C56DqhGz.cjs"),Es=require("./hooks.module-COfcimjS.cjs"),bc={WALLET_ID:"@w3m/wallet_id",WALLET_NAME:"@w3m/wallet_name",ACTIVE_CAIPNETWORK:"@w3m/active_caipnetwork",ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3},ur={getCaipDefaultChain(r){if(r)return{id:`${b.ConstantsUtil.EIP155}:${r.chainId}`,name:r.name,imageId:b.PresetsUtil.NetworkImageIds[r.chainId],chainNamespace:b.ConstantsUtil$1.CHAIN.EVM}},hexStringToNumber(r){const e=r.startsWith("0x")?r.slice(2):r;return parseInt(e,16)},numberToHexString(r){return`0x${r.toString(16)}`},async getUserInfo(r){const[e,t]=await Promise.all([ur.getAddresses(r),ur.getChainId(r)]);return{chainId:t,addresses:e}},async getChainId(r){const e=await r.request({method:"eth_chainId"});return Number(e)},async getAddress(r){const[e]=await r.request({method:"eth_accounts"});return e},async getAddresses(r){return await r.request({method:"eth_accounts"})},async addEthereumChain(r,e){await r.request({method:"wallet_addEthereumChain",params:[{chainId:ur.numberToHexString(e.chainId),rpcUrls:[e.rpcUrl],chainName:e.name,nativeCurrency:{name:e.currency,decimals:18,symbol:e.currency},blockExplorerUrls:[e.explorerUrl],iconUrls:[b.PresetsUtil.NetworkImageIds[e.chainId]]}]})}},bp="6.13.0";function Ap(r,e,t){const n=e.split("|").map(i=>i.trim());for(let i=0;i<n.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof r===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=r,s}async function Te(r){const e=Object.keys(r);return(await Promise.all(e.map(n=>Promise.resolve(r[n])))).reduce((n,s,i)=>(n[e[i]]=s,n),{})}function F(r,e,t){for(let n in e){let s=e[n];const i=t?t[n]:null;i&&Ap(s,i,n),Object.defineProperty(r,n,{enumerable:!0,value:s,writable:!1})}}function fs(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(fs).join(", ")+" ]";if(r instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let n=0;n<r.length;n++)t+=e[r[n]>>4],t+=e[r[n]&15];return t}if(typeof r=="object"&&typeof r.toJSON=="function")return fs(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const e=Object.keys(r);return e.sort(),"{ "+e.map(t=>`${fs(t)}: ${fs(r[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ke(r,e){return r&&r.code===e}function kl(r){return ke(r,"CALL_EXCEPTION")}function ne(r,e,t){let n=r;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${fs(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+fs(a))}}i.push(`code=${e}`),i.push(`version=${bp}`),i.length&&(r+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(r);break;default:s=new Error(r)}return F(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&F(s,{shortMessage:n}),s}function I(r,e,t,n){if(!r)throw ne(e,t,n)}function y(r,e,t,n){I(r,e,"INVALID_ARGUMENT",{argument:t,value:n})}function Wh(r,e,t){t==null&&(t=""),t&&(t=": "+t),I(r>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:r,expectedCount:e}),I(r<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((r,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");r.push(e)}catch{}return r},[]);function xo(r,e,t){if(t==null&&(t=""),r!==e){let n=t,s="new";t&&(n+=".",s+=" "+t),I(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function Vh(r,e,t){if(r instanceof Uint8Array)return t?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let s=2;for(let i=0;i<n.length;i++)n[i]=parseInt(r.substring(s,s+2),16),s+=2;return n}y(!1,"invalid BytesLike value",e||"value",r)}function V(r,e){return Vh(r,e,!1)}function _e(r,e){return Vh(r,e,!0)}function X(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&r.length!==2+2*e||e===!0&&r.length%2!==0)}function xl(r){return X(r,!0)||r instanceof Uint8Array}const lu="0123456789abcdef";function T(r){const e=V(r);let t="0x";for(let n=0;n<e.length;n++){const s=e[n];t+=lu[(s&240)>>4]+lu[s&15]}return t}function le(r){return"0x"+r.map(e=>T(e).substring(2)).join("")}function Cs(r){return X(r,!0)?(r.length-2)/2:V(r).length}function se(r,e,t){const n=V(r);return t!=null&&t>n.length&&I(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:t}),T(n.slice(e??0,t??n.length))}function Qh(r,e,t){const n=V(r);I(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(n,e-n.length):s.set(n,0),T(s)}function Kr(r,e){return Qh(r,e,!0)}function Ep(r,e){return Qh(r,e,!1)}const Ua=BigInt(0),Ct=BigInt(1),ps=9007199254740991;function da(r,e){const t=Ma(r,"value"),n=BigInt(H(e,"width"));if(I(t>>n===Ua,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),t>>n-Ct){const s=(Ct<<n)-Ct;return-((~t&s)+Ct)}return t}function zh(r,e){let t=_(r,"value");const n=BigInt(H(e,"width")),s=Ct<<n-Ct;if(t<Ua){t=-t,I(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});const i=(Ct<<n)-Ct;return(~t&i)+Ct}else I(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});return t}function hr(r,e){const t=Ma(r,"value"),n=BigInt(H(e,"bits"));return t&(Ct<<n)-Ct}function _(r,e){switch(typeof r){case"bigint":return r;case"number":return y(Number.isInteger(r),"underflow",e||"value",r),y(r>=-ps&&r<=ps,"overflow",e||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(t){y(!1,`invalid BigNumberish string: ${t.message}`,e||"value",r)}}y(!1,"invalid BigNumberish value",e||"value",r)}function Ma(r,e){const t=_(r,e);return I(t>=Ua,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),t}const uu="0123456789abcdef";function Da(r){if(r instanceof Uint8Array){let e="0x0";for(const t of r)e+=uu[t>>4],e+=uu[t&15];return BigInt(e)}return _(r)}function H(r,e){switch(typeof r){case"bigint":return y(r>=-ps&&r<=ps,"overflow",e||"value",r),Number(r);case"number":return y(Number.isInteger(r),"underflow",e||"value",r),y(r>=-ps&&r<=ps,"overflow",e||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return H(BigInt(r),e)}catch(t){y(!1,`invalid numeric string: ${t.message}`,e||"value",r)}}y(!1,"invalid numeric value",e||"value",r)}function Cp(r){return H(Da(r))}function Xn(r,e){let n=Ma(r,"value").toString(16);if(e==null)n.length%2&&(n="0"+n);else{const s=H(e,"width");for(I(s*2>=n.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length<s*2;)n="0"+n}return"0x"+n}function Le(r){const e=Ma(r,"value");if(e===Ua)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const n=new Uint8Array(t.length/2);for(let s=0;s<n.length;s++){const i=s*2;n[s]=parseInt(t.substring(i,i+2),16)}return n}function gs(r){let e=T(xl(r)?r:Le(r)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const hu="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const du=BigInt(58);function vp(r){const e=V(r);let t=Da(e),n="";for(;t;)n=hu[Number(t%du)]+n,t/=du;for(let s=0;s<e.length&&!e[s];s++)n=hu[0]+n;return n}function Ip(r){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return V(e)}function Np(r){const e=V(r);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var Ps;class Jh{constructor(e,t,n){E(this,"filter");E(this,"emitter");A(this,Ps,void 0);p(this,Ps,t),F(this,{emitter:e,filter:n})}async removeListener(){u(this,Ps)!=null&&await this.emitter.off(this.filter,u(this,Ps))}}Ps=new WeakMap;function Sp(r,e,t,n,s){y(!1,`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function qh(r,e,t,n,s){if(r==="BAD_PREFIX"||r==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return r==="OVERRUN"?t.length-e-1:0}function kp(r,e,t,n,s){return r==="OVERLONG"?(y(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),qh(r,e,t))}const xp=Object.freeze({error:Sp,ignore:qh,replace:kp});function Pp(r,e){e==null&&(e=xp.error);const t=V(r,"bytes"),n=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){n.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,n):s+=e("BAD_PREFIX",s-1,t,n);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,n);continue}let c=i&(1<<8-o-1)-1;for(let l=0;l<o;l++){let h=t[s];if((h&192)!=128){s+=e("MISSING_CONTINUE",s,t,n),c=null;break}c=c<<6|h&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,n,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,n,c);continue}if(c<=a){s+=e("OVERLONG",s-1-o,t,n,c);continue}n.push(c)}}return n}function jt(r,e){y(typeof r=="string","invalid string value","str",r);let t=[];for(let n=0;n<r.length;n++){const s=r.charCodeAt(n);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){n++;const i=r.charCodeAt(n);y(n<r.length&&(i&64512)===56320,"invalid surrogate pair","str",r);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function Rp(r){return r.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function fa(r,e){return Rp(Pp(r,e))}function Zh(r){async function e(t,n){I(n==null||!n.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();I(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),I(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=ne("request timeout","TIMEOUT"),o.abort()},t.timeout);n&&n.addListener(()=>{i=ne("request cancelled","CANCELLED"),o.abort()});const c={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let l;try{l=await fetch(t.url,c)}catch(g){throw clearTimeout(a),i||g}clearTimeout(a);const h={};l.headers.forEach((g,w)=>{h[w.toLowerCase()]=g});const d=await l.arrayBuffer(),f=d==null?null:new Uint8Array(d);return{statusCode:l.status,statusMessage:l.statusText,headers:h,body:f}}return e}const Op=12,Tp=250;let fu=Zh();const Bp=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),_p=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Ac=!1;async function $h(r,e){try{const t=r.match(Bp);if(!t)throw new Error("invalid data");return new Yn(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?Ip(t[3]):Up(t[3]))}catch{return new Yn(599,"BAD REQUEST (invalid data: URI)",{},null,new Qt(r))}}function Yh(r){async function e(t,n){try{const s=t.match(_p);if(!s)throw new Error("invalid link");return new Qt(`${r}${s[2]}`)}catch{return new Yn(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Qt(t))}}return e}const Fo={data:$h,ipfs:Yh("https://gateway.ipfs.io/ipfs/")},Xh=new WeakMap;var gr,Tn;class Lp{constructor(e){A(this,gr,void 0);A(this,Tn,void 0);p(this,gr,[]),p(this,Tn,!1),Xh.set(e,()=>{if(!u(this,Tn)){p(this,Tn,!0);for(const t of u(this,gr))setTimeout(()=>{t()},0);p(this,gr,[])}})}addListener(e){I(!u(this,Tn),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),u(this,gr).push(e)}get cancelled(){return u(this,Tn)}checkSignal(){I(!this.cancelled,"cancelled","CANCELLED",{})}}gr=new WeakMap,Tn=new WeakMap;function Ho(r){if(r==null)throw new Error("missing signal; should not happen");return r.checkSignal(),r}var Rs,Os,gt,nn,Ts,Bs,ge,Je,rn,mr,yr,wr,Ot,mt,Bn,br,Mi;const xa=class xa{constructor(e){A(this,br);A(this,Rs,void 0);A(this,Os,void 0);A(this,gt,void 0);A(this,nn,void 0);A(this,Ts,void 0);A(this,Bs,void 0);A(this,ge,void 0);A(this,Je,void 0);A(this,rn,void 0);A(this,mr,void 0);A(this,yr,void 0);A(this,wr,void 0);A(this,Ot,void 0);A(this,mt,void 0);A(this,Bn,void 0);p(this,Bs,String(e)),p(this,Rs,!1),p(this,Os,!0),p(this,gt,{}),p(this,nn,""),p(this,Ts,3e5),p(this,mt,{slotInterval:Tp,maxAttempts:Op}),p(this,Bn,null)}get url(){return u(this,Bs)}set url(e){p(this,Bs,String(e))}get body(){return u(this,ge)==null?null:new Uint8Array(u(this,ge))}set body(e){if(e==null)p(this,ge,void 0),p(this,Je,void 0);else if(typeof e=="string")p(this,ge,jt(e)),p(this,Je,"text/plain");else if(e instanceof Uint8Array)p(this,ge,e),p(this,Je,"application/octet-stream");else if(typeof e=="object")p(this,ge,jt(JSON.stringify(e))),p(this,Je,"application/json");else throw new Error("invalid body")}hasBody(){return u(this,ge)!=null}get method(){return u(this,nn)?u(this,nn):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),p(this,nn,String(e).toUpperCase())}get headers(){const e=Object.assign({},u(this,gt));return u(this,rn)&&(e.authorization=`Basic ${Np(jt(u(this,rn)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&u(this,Je)&&(e["content-type"]=u(this,Je)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){u(this,gt)[String(e).toLowerCase()]=String(t)}clearHeaders(){p(this,gt,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return u(this,rn)||null}setCredentials(e,t){y(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),p(this,rn,`${e}:${t}`)}get allowGzip(){return u(this,Os)}set allowGzip(e){p(this,Os,!!e)}get allowInsecureAuthentication(){return!!u(this,Rs)}set allowInsecureAuthentication(e){p(this,Rs,!!e)}get timeout(){return u(this,Ts)}set timeout(e){y(e>=0,"timeout must be non-zero","timeout",e),p(this,Ts,e)}get preflightFunc(){return u(this,mr)||null}set preflightFunc(e){p(this,mr,e)}get processFunc(){return u(this,yr)||null}set processFunc(e){p(this,yr,e)}get retryFunc(){return u(this,wr)||null}set retryFunc(e){p(this,wr,e)}get getUrlFunc(){return u(this,Bn)||fu}set getUrlFunc(e){p(this,Bn,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${u(this,ge)?T(u(this,ge)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(u(this,mt).slotInterval=e.slotInterval),e.maxAttempts!=null&&(u(this,mt).maxAttempts=e.maxAttempts)}send(){return I(u(this,Ot)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),p(this,Ot,new Lp(this)),N(this,br,Mi).call(this,0,pu()+this.timeout,0,this,new Yn(0,"",{},null,this))}cancel(){I(u(this,Ot)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=Xh.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();I(this.method==="GET"&&(t!=="https"||n!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new xa(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,p(s,gt,Object.assign({},u(this,gt))),u(this,ge)&&p(s,ge,new Uint8Array(u(this,ge))),p(s,Je,u(this,Je)),s}clone(){const e=new xa(this.url);return p(e,nn,u(this,nn)),u(this,ge)&&p(e,ge,u(this,ge)),p(e,Je,u(this,Je)),p(e,gt,Object.assign({},u(this,gt))),p(e,rn,u(this,rn)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),p(e,mr,u(this,mr)),p(e,yr,u(this,yr)),p(e,wr,u(this,wr)),p(e,mt,Object.assign({},u(this,mt))),p(e,Bn,u(this,Bn)),e}static lockConfig(){Ac=!0}static getGateway(e){return Fo[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Ac)throw new Error("gateways locked");Fo[e]=t}static registerGetUrl(e){if(Ac)throw new Error("gateways locked");fu=e}static createGetUrlFunc(e){return Zh()}static createDataGateway(){return $h}static createIpfsGatewayFunc(e){return Yh(e)}};Rs=new WeakMap,Os=new WeakMap,gt=new WeakMap,nn=new WeakMap,Ts=new WeakMap,Bs=new WeakMap,ge=new WeakMap,Je=new WeakMap,rn=new WeakMap,mr=new WeakMap,yr=new WeakMap,wr=new WeakMap,Ot=new WeakMap,mt=new WeakMap,Bn=new WeakMap,br=new WeakSet,Mi=async function(e,t,n,s,i){var h,d,f;if(e>=u(this,mt).maxAttempts)return i.makeServerError("exceeded maximum retry limit");I(pu()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),n>0&&await Mp(n);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Fo){const g=await Fo[a](o.url,Ho(u(s,Ot)));if(g instanceof Yn){let w=g;if(this.processFunc){Ho(u(s,Ot));try{w=await this.processFunc(o,w)}catch(m){(m.throttle==null||typeof m.stall!="number")&&w.makeServerError("error in post-processing function",m).assertOk()}}return w}o=g}this.preflightFunc&&(o=await this.preflightFunc(o));const c=await this.getUrlFunc(o,Ho(u(s,Ot)));let l=new Yn(c.statusCode,c.statusMessage,c.headers,c.body,s);if(l.statusCode===301||l.statusCode===302){try{const g=l.headers.location||"";return N(h=o.redirect(g),br,Mi).call(h,e+1,t,0,s,l)}catch{}return l}else if(l.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,l,e))){const g=l.headers["retry-after"];let w=u(this,mt).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof g=="string"&&g.match(/^[1-9][0-9]*$/)&&(w=parseInt(g)),N(d=o.clone(),br,Mi).call(d,e+1,t,w,s,l)}if(this.processFunc){Ho(u(s,Ot));try{l=await this.processFunc(o,l)}catch(g){(g.throttle==null||typeof g.stall!="number")&&l.makeServerError("error in post-processing function",g).assertOk();let w=u(this,mt).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return g.stall>=0&&(w=g.stall),N(f=o.clone(),br,Mi).call(f,e+1,t,w,s,l)}}return l};let Qt=xa;var ro,so,io,qe,_s,Ar;const ru=class ru{constructor(e,t,n,s,i){A(this,ro,void 0);A(this,so,void 0);A(this,io,void 0);A(this,qe,void 0);A(this,_s,void 0);A(this,Ar,void 0);p(this,ro,e),p(this,so,t),p(this,io,Object.keys(n).reduce((o,a)=>(o[a.toLowerCase()]=String(n[a]),o),{})),p(this,qe,s==null?null:new Uint8Array(s)),p(this,_s,i||null),p(this,Ar,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${u(this,qe)?T(u(this,qe)):"null"}>`}get statusCode(){return u(this,ro)}get statusMessage(){return u(this,so)}get headers(){return Object.assign({},u(this,io))}get body(){return u(this,qe)==null?null:new Uint8Array(u(this,qe))}get bodyText(){try{return u(this,qe)==null?"":fa(u(this,qe))}catch{I(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{I(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let n;e?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new ru(599,n,this.headers,this.body,u(this,_s)||void 0);return p(s,Ar,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:y(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw F(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return u(this,qe)!=null}get request(){return u(this,_s)}ok(){return u(this,Ar).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=u(this,Ar);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let s=null;try{u(this,qe)&&(s=fa(u(this,qe)))}catch{}I(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};ro=new WeakMap,so=new WeakMap,io=new WeakMap,qe=new WeakMap,_s=new WeakMap,Ar=new WeakMap;let Yn=ru;function pu(){return new Date().getTime()}function Up(r){return jt(r.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function Mp(r){return new Promise(e=>setTimeout(e,r))}const Dp=BigInt(-1),dt=BigInt(0),ms=BigInt(1),Fp=BigInt(5),ns={};let vs="0000";for(;vs.length<80;)vs+=vs;function nr(r){let e=vs;for(;e.length<r;)e+=e;return BigInt("1"+e.substring(0,r))}function Bi(r,e,t){const n=BigInt(e.width);if(e.signed){const s=ms<<n-ms;I(t==null||r>=-s&&r<s,"overflow","NUMERIC_FAULT",{operation:t,fault:"overflow",value:r}),r>dt?r=da(hr(r,n),n):r=-da(hr(-r,n),n)}else{const s=ms<<n;I(t==null||r>=0&&r<s,"overflow","NUMERIC_FAULT",{operation:t,fault:"overflow",value:r}),r=(r%s+s)%s&s-ms}return r}function Ec(r){typeof r=="number"&&(r=`fixed128x${r}`);let e=!0,t=128,n=18;if(typeof r=="string"){if(r!=="fixed")if(r==="ufixed")e=!1;else{const i=r.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);y(i,"invalid fixed format","format",r),e=i[1]!=="u",t=parseInt(i[2]),n=parseInt(i[3])}}else if(r){const i=r,o=(a,c,l)=>i[a]==null?l:(y(typeof i[a]===c,"invalid fixed format ("+a+" not "+c+")","format."+a,i[a]),i[a]);e=o("signed","boolean",e),t=o("width","number",t),n=o("decimals","number",n)}y(t%8===0,"invalid FixedNumber width (not byte aligned)","format.width",t),y(n<=80,"invalid FixedNumber decimals (too large)","format.decimals",n);const s=(e?"":"u")+"fixed"+String(t)+"x"+String(n);return{signed:e,width:t,decimals:n,name:s}}function Hp(r,e){let t="";r<dt&&(t="-",r*=Dp);let n=r.toString();if(e===0)return t+n;for(;n.length<=e;)n=vs+n;const s=n.length-e;for(n=n.substring(0,s)+"."+n.substring(s);n[0]==="0"&&n[1]!==".";)n=n.substring(1);for(;n[n.length-1]==="0"&&n[n.length-2]!==".";)n=n.substring(0,n.length-1);return t+n}var yt,Z,Pe,sn,rr,wt,Zt,oo,Vc,ao,Qc,co,zc,lo,Jc;const On=class On{constructor(e,t,n){A(this,sn);A(this,wt);A(this,oo);A(this,ao);A(this,co);A(this,lo);E(this,"format");A(this,yt,void 0);A(this,Z,void 0);A(this,Pe,void 0);E(this,"_value");xo(e,ns,"FixedNumber"),p(this,Z,t),p(this,yt,n);const s=Hp(t,n.decimals);F(this,{format:n.name,_value:s}),p(this,Pe,nr(n.decimals))}get signed(){return u(this,yt).signed}get width(){return u(this,yt).width}get decimals(){return u(this,yt).decimals}get value(){return u(this,Z)}addUnsafe(e){return N(this,oo,Vc).call(this,e)}add(e){return N(this,oo,Vc).call(this,e,"add")}subUnsafe(e){return N(this,ao,Qc).call(this,e)}sub(e){return N(this,ao,Qc).call(this,e,"sub")}mulUnsafe(e){return N(this,co,zc).call(this,e)}mul(e){return N(this,co,zc).call(this,e,"mul")}mulSignal(e){N(this,sn,rr).call(this,e);const t=u(this,Z)*u(e,Z);return I(t%u(this,Pe)===dt,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),N(this,wt,Zt).call(this,t/u(this,Pe),"mulSignal")}divUnsafe(e){return N(this,lo,Jc).call(this,e)}div(e){return N(this,lo,Jc).call(this,e,"div")}divSignal(e){I(u(e,Z)!==dt,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),N(this,sn,rr).call(this,e);const t=u(this,Z)*u(this,Pe);return I(t%u(e,Z)===dt,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),N(this,wt,Zt).call(this,t/u(e,Z),"divSignal")}cmp(e){let t=this.value,n=e.value;const s=this.decimals-e.decimals;return s>0?n*=nr(s):s<0&&(t*=nr(-s)),t<n?-1:t>n?1:0}eq(e){return this.cmp(e)===0}lt(e){return this.cmp(e)<0}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)>0}gte(e){return this.cmp(e)>=0}floor(){let e=u(this,Z);return u(this,Z)<dt&&(e-=u(this,Pe)-ms),e=u(this,Z)/u(this,Pe)*u(this,Pe),N(this,wt,Zt).call(this,e,"floor")}ceiling(){let e=u(this,Z);return u(this,Z)>dt&&(e+=u(this,Pe)-ms),e=u(this,Z)/u(this,Pe)*u(this,Pe),N(this,wt,Zt).call(this,e,"ceiling")}round(e){if(e==null&&(e=0),e>=this.decimals)return this;const t=this.decimals-e,n=Fp*nr(t-1);let s=this.value+n;const i=nr(t);return s=s/i*i,Bi(s,u(this,yt),"round"),new On(ns,s,u(this,yt))}isZero(){return u(this,Z)===dt}isNegative(){return u(this,Z)<dt}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return On.fromString(this.toString(),e)}static fromValue(e,t,n){const s=t==null?0:H(t),i=Ec(n);let o=_(e,"value");const a=s-i.decimals;if(a>0){const c=nr(a);I(o%c===dt,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),o/=c}else a<0&&(o*=nr(-a));return Bi(o,i,"fromValue"),new On(ns,o,i)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);y(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const s=Ec(t);let i=n[2]||"0",o=n[3]||"";for(;o.length<s.decimals;)o+=vs;I(o.substring(s.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),o=o.substring(0,s.decimals);const a=BigInt(n[1]+i+o);return Bi(a,s,"fromString"),new On(ns,a,s)}static fromBytes(e,t){let n=Da(V(e,"value"));const s=Ec(t);return s.signed&&(n=da(n,s.width)),Bi(n,s,"fromBytes"),new On(ns,n,s)}};yt=new WeakMap,Z=new WeakMap,Pe=new WeakMap,sn=new WeakSet,rr=function(e){y(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)},wt=new WeakSet,Zt=function(e,t){return e=Bi(e,u(this,yt),t),new On(ns,e,u(this,yt))},oo=new WeakSet,Vc=function(e,t){return N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)+u(e,Z),t)},ao=new WeakSet,Qc=function(e,t){return N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)-u(e,Z),t)},co=new WeakSet,zc=function(e,t){return N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)*u(e,Z)/u(this,Pe),t)},lo=new WeakSet,Jc=function(e,t){return I(u(e,Z)!==dt,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),N(this,sn,rr).call(this,e),N(this,wt,Zt).call(this,u(this,Z)*u(this,Pe)/u(e,Z),t)};let pa=On;function Gp(r){let e=r.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function gu(r,e,t){let n=0;for(let s=0;s<t;s++)n=n*256+r[e+s];return n}function mu(r,e,t,n){const s=[];for(;t<e+1+n;){const i=ed(r,t);s.push(i.result),t+=i.consumed,I(t<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:r,length:n,offset:e})}return{consumed:1+n,result:s}}function ed(r,e){I(r.length!==0,"data too short","BUFFER_OVERRUN",{buffer:r,length:0,offset:1});const t=n=>{I(n<=r.length,"data short segment too short","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n})};if(r[e]>=248){const n=r[e]-247;t(e+1+n);const s=gu(r,e+1,n);return t(e+1+n+s),mu(r,e,e+1+n,n+s)}else if(r[e]>=192){const n=r[e]-192;return t(e+1+n),mu(r,e,e+1,n)}else if(r[e]>=184){const n=r[e]-183;t(e+1+n);const s=gu(r,e+1,n);t(e+1+n+s);const i=T(r.slice(e+1+n,e+1+n+s));return{consumed:1+n+s,result:i}}else if(r[e]>=128){const n=r[e]-128;t(e+1+n);const s=T(r.slice(e+1,e+1+n));return{consumed:1+n,result:s}}return{consumed:1,result:Gp(r[e])}}function Fa(r){const e=V(r,"data"),t=ed(e,0);return y(t.consumed===e.length,"unexpected junk after rlp payload","data",r),t.result}function yu(r){const e=[];for(;r;)e.unshift(r&255),r>>=8;return e}function td(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(i){n=n.concat(td(i))}),n.length<=55)return n.unshift(192+n.length),n;const s=yu(n.length);return s.unshift(247+s.length),s.concat(n)}const e=Array.prototype.slice.call(V(r,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=yu(e.length);return t.unshift(183+t.length),t.concat(e)}const wu="0123456789abcdef";function jr(r){let e="0x";for(const t of td(r))e+=wu[t>>4],e+=wu[t&15];return e}const nd=["wei","kwei","mwei","gwei","szabo","finney","ether"];function rd(r,e){let t=18;if(typeof e=="string"){const n=nd.indexOf(e);y(n>=0,"invalid unit","unit",e),t=3*n}else e!=null&&(t=H(e,"unit"));return pa.fromValue(r,t,{decimals:t,width:512}).toString()}function Kp(r,e){y(typeof r=="string","value must be a string","value",r);let t=18;if(typeof e=="string"){const n=nd.indexOf(e);y(n>=0,"invalid unit","unit",e),t=3*n}else e!=null&&(t=H(e,"unit"));return pa.fromString(r,{decimals:t,width:512}).value}function jp(r){return rd(r,18)}const Ue=32,qc=new Uint8Array(Ue),Wp=["then"],Go={},sd=new WeakMap;function ir(r){return sd.get(r)}function bu(r,e){sd.set(r,e)}function _i(r,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw t.error=e,t}function Zc(r,e,t){return r.indexOf(null)>=0?e.map((n,s)=>n instanceof bi?Zc(ir(n),n,t):n):r.reduce((n,s,i)=>{let o=e.getValue(s);return s in n||(t&&o instanceof bi&&(o=Zc(ir(o),o,t)),n[s]=o),n},{})}var Ls;const ws=class ws extends Array{constructor(...t){const n=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;n!==Go&&(s=t,i=[],o=!1);super(s.length);A(this,Ls,void 0);s.forEach((l,h)=>{this[h]=l});const a=i.reduce((l,h)=>(typeof h=="string"&&l.set(h,(l.get(h)||0)+1),l),new Map);if(bu(this,Object.freeze(s.map((l,h)=>{const d=i[h];return d!=null&&a.get(d)===1?d:null}))),p(this,Ls,[]),u(this,Ls)==null&&u(this,Ls),!o)return;Object.freeze(this);const c=new Proxy(this,{get:(l,h,d)=>{if(typeof h=="string"){if(h.match(/^[0-9]+$/)){const g=H(h,"%index");if(g<0||g>=this.length)throw new RangeError("out of result range");const w=l[g];return w instanceof Error&&_i(`index ${g}`,w),w}if(Wp.indexOf(h)>=0)return Reflect.get(l,h,d);const f=l[h];if(f instanceof Function)return function(...g){return f.apply(this===d?l:this,g)};if(!(h in l))return l.getValue.apply(this===d?l:this,[h])}return Reflect.get(l,h,d)}});return bu(c,ir(this)),c}toArray(t){const n=[];return this.forEach((s,i)=>{s instanceof Error&&_i(`index ${i}`,s),t&&s instanceof ws&&(s=s.toArray(t)),n.push(s)}),n}toObject(t){const n=ir(this);return n.reduce((s,i,o)=>(I(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Zc(n,this,t)),{})}slice(t,n){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),n==null&&(n=this.length),n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);const s=ir(this),i=[],o=[];for(let a=t;a<n;a++)i.push(this[a]),o.push(s[a]);return new ws(Go,i,o)}filter(t,n){const s=ir(this),i=[],o=[];for(let a=0;a<this.length;a++){const c=this[a];c instanceof Error&&_i(`index ${a}`,c),t.call(n,c,a,this)&&(i.push(c),o.push(s[a]))}return new ws(Go,i,o)}map(t,n){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&_i(`index ${i}`,o),s.push(t.call(n,o,i,this))}return s}getValue(t){const n=ir(this).indexOf(t);if(n===-1)return;const s=this[n];return s instanceof Error&&_i(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,n){return new ws(Go,t,n)}};Ls=new WeakMap;let bi=ws;function Au(r){let e=Le(r);return I(e.length<=Ue,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Ue,offset:e.length}),e.length!==Ue&&(e=_e(le([qc.slice(e.length%Ue),e]))),e}class En{constructor(e,t,n,s){E(this,"name");E(this,"type");E(this,"localName");E(this,"dynamic");F(this,{name:e,type:t,localName:n,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){y(!1,e,this.localName,t)}}var on,Er,Us,ta;class $c{constructor(){A(this,Us);A(this,on,void 0);A(this,Er,void 0);p(this,on,[]),p(this,Er,0)}get data(){return le(u(this,on))}get length(){return u(this,Er)}appendWriter(e){return N(this,Us,ta).call(this,_e(e.data))}writeBytes(e){let t=_e(e);const n=t.length%Ue;return n&&(t=_e(le([t,qc.slice(n)]))),N(this,Us,ta).call(this,t)}writeValue(e){return N(this,Us,ta).call(this,Au(e))}writeUpdatableValue(){const e=u(this,on).length;return u(this,on).push(qc),p(this,Er,u(this,Er)+Ue),t=>{u(this,on)[e]=Au(t)}}}on=new WeakMap,Er=new WeakMap,Us=new WeakSet,ta=function(e){return u(this,on).push(e),p(this,Er,u(this,Er)+e.length),e.length};var Fe,Ze,Cr,vr,_n,uo,Xc,Pa,id;const su=class su{constructor(e,t,n){A(this,uo);A(this,Pa);E(this,"allowLoose");A(this,Fe,void 0);A(this,Ze,void 0);A(this,Cr,void 0);A(this,vr,void 0);A(this,_n,void 0);F(this,{allowLoose:!!t}),p(this,Fe,_e(e)),p(this,Cr,0),p(this,vr,null),p(this,_n,n??1024),p(this,Ze,0)}get data(){return T(u(this,Fe))}get dataLength(){return u(this,Fe).length}get consumed(){return u(this,Ze)}get bytes(){return new Uint8Array(u(this,Fe))}subReader(e){const t=new su(u(this,Fe).slice(u(this,Ze)+e),this.allowLoose,u(this,_n));return p(t,vr,this),t}readBytes(e,t){let n=N(this,Pa,id).call(this,0,e,!!t);return N(this,uo,Xc).call(this,e),p(this,Ze,u(this,Ze)+n.length),n.slice(0,e)}readValue(){return Da(this.readBytes(Ue))}readIndex(){return Cp(this.readBytes(Ue))}};Fe=new WeakMap,Ze=new WeakMap,Cr=new WeakMap,vr=new WeakMap,_n=new WeakMap,uo=new WeakSet,Xc=function(e){var t;if(u(this,vr))return N(t=u(this,vr),uo,Xc).call(t,e);p(this,Cr,u(this,Cr)+e),I(u(this,_n)<1||u(this,Cr)<=u(this,_n)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${u(this,_n)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:_e(u(this,Fe)),offset:u(this,Ze),length:e,info:{bytesRead:u(this,Cr),dataLength:this.dataLength}})},Pa=new WeakSet,id=function(e,t,n){let s=Math.ceil(t/Ue)*Ue;return u(this,Ze)+s>u(this,Fe).length&&(this.allowLoose&&n&&u(this,Ze)+t<=u(this,Fe).length?s=t:I(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:_e(u(this,Fe)),length:u(this,Fe).length,offset:u(this,Ze)+s})),u(this,Fe).slice(u(this,Ze),u(this,Ze)+s)};let Yc=su;function ga(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Pl(r,...e){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function Vp(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ga(r.outputLen),ga(r.blockLen)}function Ai(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function od(r,e){Pl(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Cc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ad=r=>r instanceof Uint8Array,Qp=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),vc=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),xt=(r,e)=>r<<32-e|r>>>e,zp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!zp)throw new Error("Non little-endian hardware is not supported");function Jp(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ha(r){if(typeof r=="string"&&(r=Jp(r)),!ad(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function qp(...r){const e=new Uint8Array(r.reduce((n,s)=>n+s.length,0));let t=0;return r.forEach(n=>{if(!ad(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class Rl{clone(){return this._cloneInto()}}function Ol(r){const e=n=>r().update(Ha(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Zp(r=32){if(Cc&&typeof Cc.getRandomValues=="function")return Cc.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}class cd extends Rl{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Vp(e);const n=Ha(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Ai(this),this.iHash.update(e),this}digestInto(e){Ai(this),Pl(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ld=(r,e,t)=>new cd(r,e).update(t).digest();ld.create=(r,e)=>new cd(r,e);function $p(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),c=n?4:0,l=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+l,a,n)}class ud extends Rl{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=vc(this.buffer)}update(e){Ai(this);const{view:t,buffer:n,blockLen:s}=this;e=Ha(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const c=vc(e);for(;s<=i-o;o+=s)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ai(this),od(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(n,0),o=0);for(let d=o;d<s;d++)t[d]=0;$p(n,s-8,BigInt(this.length*8),i),this.process(n,0);const a=vc(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,h[d],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(n),e}}const Yp=(r,e,t)=>r&e^~r&t,Xp=(r,e,t)=>r&e^r&t^e&t,eg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Nn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Sn=new Uint32Array(64);class tg extends ud{constructor(){super(64,32,8,!1),this.A=Nn[0]|0,this.B=Nn[1]|0,this.C=Nn[2]|0,this.D=Nn[3]|0,this.E=Nn[4]|0,this.F=Nn[5]|0,this.G=Nn[6]|0,this.H=Nn[7]|0}get(){const{A:e,B:t,C:n,D:s,E:i,F:o,G:a,H:c}=this;return[e,t,n,s,i,o,a,c]}set(e,t,n,s,i,o,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let d=0;d<16;d++,t+=4)Sn[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){const f=Sn[d-15],g=Sn[d-2],w=xt(f,7)^xt(f,18)^f>>>3,m=xt(g,17)^xt(g,19)^g>>>10;Sn[d]=m+Sn[d-7]+w+Sn[d-16]|0}let{A:n,B:s,C:i,D:o,E:a,F:c,G:l,H:h}=this;for(let d=0;d<64;d++){const f=xt(a,6)^xt(a,11)^xt(a,25),g=h+f+Yp(a,c,l)+eg[d]+Sn[d]|0,m=(xt(n,2)^xt(n,13)^xt(n,22))+Xp(n,s,i)|0;h=l,l=c,c=a,a=o+g|0,o=i,i=s,s=n,n=g+m|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,s,i,o,a,c,l,h)}roundClean(){Sn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const hd=Ol(()=>new tg),Ko=BigInt(2**32-1),el=BigInt(32);function dd(r,e=!1){return e?{h:Number(r&Ko),l:Number(r>>el&Ko)}:{h:Number(r>>el&Ko)|0,l:Number(r&Ko)|0}}function fd(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){const{h:i,l:o}=dd(r[s],e);[t[s],n[s]]=[i,o]}return[t,n]}const ng=(r,e)=>BigInt(r>>>0)<<el|BigInt(e>>>0),rg=(r,e,t)=>r>>>t,sg=(r,e,t)=>r<<32-t|e>>>t,ig=(r,e,t)=>r>>>t|e<<32-t,og=(r,e,t)=>r<<32-t|e>>>t,ag=(r,e,t)=>r<<64-t|e>>>t-32,cg=(r,e,t)=>r>>>t-32|e<<64-t,lg=(r,e)=>e,ug=(r,e)=>r,pd=(r,e,t)=>r<<t|e>>>32-t,gd=(r,e,t)=>e<<t|r>>>32-t,md=(r,e,t)=>e<<t-32|r>>>64-t,yd=(r,e,t)=>r<<t-32|e>>>64-t;function hg(r,e,t,n){const s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}const dg=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),fg=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,pg=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),gg=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,mg=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),yg=(r,e,t,n,s,i)=>e+t+n+s+i+(r/2**32|0)|0,G={fromBig:dd,split:fd,toBig:ng,shrSH:rg,shrSL:sg,rotrSH:ig,rotrSL:og,rotrBH:ag,rotrBL:cg,rotr32H:lg,rotr32L:ug,rotlSH:pd,rotlSL:gd,rotlBH:md,rotlBL:yd,add:hg,add3L:dg,add3H:fg,add4L:pg,add4H:gg,add5H:yg,add5L:mg},[wg,bg]=G.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),kn=new Uint32Array(80),xn=new Uint32Array(80);class Ag extends ud{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:s,Ch:i,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:d,Fl:f,Gh:g,Gl:w,Hh:m,Hl:C}=this;return[e,t,n,s,i,o,a,c,l,h,d,f,g,w,m,C]}set(e,t,n,s,i,o,a,c,l,h,d,f,g,w,m,C){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=d|0,this.Fl=f|0,this.Gh=g|0,this.Gl=w|0,this.Hh=m|0,this.Hl=C|0}process(e,t){for(let S=0;S<16;S++,t+=4)kn[S]=e.getUint32(t),xn[S]=e.getUint32(t+=4);for(let S=16;S<80;S++){const B=kn[S-15]|0,P=xn[S-15]|0,R=G.rotrSH(B,P,1)^G.rotrSH(B,P,8)^G.shrSH(B,P,7),M=G.rotrSL(B,P,1)^G.rotrSL(B,P,8)^G.shrSL(B,P,7),D=kn[S-2]|0,q=xn[S-2]|0,Q=G.rotrSH(D,q,19)^G.rotrBH(D,q,61)^G.shrSH(D,q,6),z=G.rotrSL(D,q,19)^G.rotrBL(D,q,61)^G.shrSL(D,q,6),de=G.add4L(M,z,xn[S-7],xn[S-16]),we=G.add4H(de,R,Q,kn[S-7],kn[S-16]);kn[S]=we|0,xn[S]=de|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:d,El:f,Fh:g,Fl:w,Gh:m,Gl:C,Hh:v,Hl:k}=this;for(let S=0;S<80;S++){const B=G.rotrSH(d,f,14)^G.rotrSH(d,f,18)^G.rotrBH(d,f,41),P=G.rotrSL(d,f,14)^G.rotrSL(d,f,18)^G.rotrBL(d,f,41),R=d&g^~d&m,M=f&w^~f&C,D=G.add5L(k,P,M,bg[S],xn[S]),q=G.add5H(D,v,B,R,wg[S],kn[S]),Q=D|0,z=G.rotrSH(n,s,28)^G.rotrBH(n,s,34)^G.rotrBH(n,s,39),de=G.rotrSL(n,s,28)^G.rotrBL(n,s,34)^G.rotrBL(n,s,39),we=n&i^n&a^i&a,kt=s&o^s&c^o&c;v=m|0,k=C|0,m=g|0,C=w|0,g=d|0,w=f|0,{h:d,l:f}=G.add(l|0,h|0,q|0,Q|0),l=a|0,h=c|0,a=i|0,c=o|0,i=n|0,o=s|0;const x=G.add3L(Q,de,kt);n=G.add3H(x,q,z,we),s=x|0}({h:n,l:s}=G.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=G.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=G.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=G.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:d,l:f}=G.add(this.Eh|0,this.El|0,d|0,f|0),{h:g,l:w}=G.add(this.Fh|0,this.Fl|0,g|0,w|0),{h:m,l:C}=G.add(this.Gh|0,this.Gl|0,m|0,C|0),{h:v,l:k}=G.add(this.Hh|0,this.Hl|0,v|0,k|0),this.set(n,s,i,o,a,c,l,h,d,f,g,w,m,C,v,k)}roundClean(){kn.fill(0),xn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Eg=Ol(()=>new Ag);function Cg(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof b.global<"u")return b.global;throw new Error("unable to locate global object")}const Eu=Cg();Eu.crypto||Eu.msCrypto;function vg(r){switch(r){case"sha256":return hd.create();case"sha512":return Eg.create()}y(!1,"invalid hashing algorithm name","algorithm",r)}const[wd,bd,Ad]=[[],[],[]],Ig=BigInt(0),Li=BigInt(1),Ng=BigInt(2),Sg=BigInt(7),kg=BigInt(256),xg=BigInt(113);for(let r=0,e=Li,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],wd.push(2*(5*n+t)),bd.push((r+1)*(r+2)/2%64);let s=Ig;for(let i=0;i<7;i++)e=(e<<Li^(e>>Sg)*xg)%kg,e&Ng&&(s^=Li<<(Li<<BigInt(i))-Li);Ad.push(s)}const[Pg,Rg]=fd(Ad,!0),Cu=(r,e,t)=>t>32?md(r,e,t):pd(r,e,t),vu=(r,e,t)=>t>32?yd(r,e,t):gd(r,e,t);function Og(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],d=Cu(l,h,1)^t[a],f=vu(l,h,1)^t[a+1];for(let g=0;g<50;g+=10)r[o+g]^=d,r[o+g+1]^=f}let s=r[2],i=r[3];for(let o=0;o<24;o++){const a=bd[o],c=Cu(s,i,a),l=vu(s,i,a),h=wd[o];s=r[h],i=r[h+1],r[h]=c,r[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=Pg[n],r[1]^=Rg[n]}t.fill(0)}class Tl extends Rl{constructor(e,t,n,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ga(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Qp(this.state)}keccak(){Og(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Ai(this);const{blockLen:t,state:n}=this;e=Ha(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,t&128&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ai(this,!1),Pl(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,i=e.length;s<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ga(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(od(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Tl(t,n,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Tg=(r,e,t)=>Ol(()=>new Tl(e,r,t)),Bg=Tg(1,136,256/8);let Ed=!1;const Cd=function(r){return Bg(r)};let vd=Cd;function ue(r){const e=V(r,"data");return T(vd(e))}ue._=Cd;ue.lock=function(){Ed=!0};ue.register=function(r){if(Ed)throw new TypeError("keccak256 is locked");vd=r};Object.freeze(ue);const Id=function(r){return vg("sha256").update(r).digest()};let Nd=Id,Sd=!1;function Pi(r){const e=V(r,"data");return T(Nd(e))}Pi._=Id;Pi.lock=function(){Sd=!0};Pi.register=function(r){if(Sd)throw new Error("sha256 is locked");Nd=r};Object.freeze(Pi);Object.freeze(Pi);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kd=BigInt(0),Ga=BigInt(1),_g=BigInt(2),Ka=r=>r instanceof Uint8Array,Lg=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ei(r){if(!Ka(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Lg[r[t]];return e}function xd(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function Bl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Ci(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const s=n*2,i=r.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[n]=o}return t}function Hr(r){return Bl(Ei(r))}function _l(r){if(!Ka(r))throw new Error("Uint8Array expected");return Bl(Ei(Uint8Array.from(r).reverse()))}function vi(r,e){return Ci(r.toString(16).padStart(e*2,"0"))}function Ll(r,e){return vi(r,e).reverse()}function Ug(r){return Ci(xd(r))}function pt(r,e,t){let n;if(typeof e=="string")try{n=Ci(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Ka(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);const s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function Qi(...r){const e=new Uint8Array(r.reduce((n,s)=>n+s.length,0));let t=0;return r.forEach(n=>{if(!Ka(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function Mg(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function Dg(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Fg(r){let e;for(e=0;r>kd;r>>=Ga,e+=1);return e}function Hg(r,e){return r>>BigInt(e)&Ga}const Gg=(r,e,t)=>r|(t?Ga:kd)<<BigInt(e),Ul=r=>(_g<<BigInt(r-1))-Ga,Ic=r=>new Uint8Array(r),Iu=r=>Uint8Array.from(r);function Pd(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Ic(r),s=Ic(r),i=0;const o=()=>{n.fill(1),s.fill(0),i=0},a=(...d)=>t(s,n,...d),c=(d=Ic())=>{s=a(Iu([0]),d),n=a(),d.length!==0&&(s=a(Iu([1]),d),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const f=[];for(;d<e;){n=a();const g=n.slice();f.push(g),d+=n.length}return Qi(...f)};return(d,f)=>{o(),c(d);let g;for(;!(g=f(l()));)c();return o(),g}}const Kg={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Po(r,e,t={}){const n=(s,i,o)=>{const a=Kg[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=r[s];if(!(o&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${i}`)};for(const[s,i]of Object.entries(e))n(s,i,!1);for(const[s,i]of Object.entries(t))n(s,i,!0);return r}const jg=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Hg,bitLen:Fg,bitMask:Ul,bitSet:Gg,bytesToHex:Ei,bytesToNumberBE:Hr,bytesToNumberLE:_l,concatBytes:Qi,createHmacDrbg:Pd,ensureBytes:pt,equalBytes:Mg,hexToBytes:Ci,hexToNumber:Bl,numberToBytesBE:vi,numberToBytesLE:Ll,numberToHexUnpadded:xd,numberToVarBytesBE:Ug,utf8ToBytes:Dg,validateObject:Po},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ye=BigInt(0),ae=BigInt(1),or=BigInt(2),Wg=BigInt(3),tl=BigInt(4),Nu=BigInt(5),Su=BigInt(8);BigInt(9);BigInt(16);function Ge(r,e){const t=r%e;return t>=ye?t:e+t}function Vg(r,e,t){if(t<=ye||e<ye)throw new Error("Expected power/modulo > 0");if(t===ae)return ye;let n=ae;for(;e>ye;)e&ae&&(n=n*r%t),r=r*r%t,e>>=ae;return n}function Xe(r,e,t){let n=r;for(;e-- >ye;)n*=n,n%=t;return n}function nl(r,e){if(r===ye||e<=ye)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Ge(r,e),n=e,s=ye,i=ae;for(;t!==ye;){const a=n/t,c=n%t,l=s-i*a;n=t,t=c,s=i,i=l}if(n!==ae)throw new Error("invert: does not exist");return Ge(s,e)}function Qg(r){const e=(r-ae)/or;let t,n,s;for(t=r-ae,n=0;t%or===ye;t/=or,n++);for(s=or;s<r&&Vg(s,e,r)!==r-ae;s++);if(n===1){const o=(r+ae)/tl;return function(c,l){const h=c.pow(l,o);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}const i=(t+ae)/or;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,s),t),d=a.pow(c,i),f=a.pow(c,t);for(;!a.eql(f,a.ONE);){if(a.eql(f,a.ZERO))return a.ZERO;let g=1;for(let m=a.sqr(f);g<l&&!a.eql(m,a.ONE);g++)m=a.sqr(m);const w=a.pow(h,ae<<BigInt(l-g-1));h=a.sqr(w),d=a.mul(d,w),f=a.mul(f,h),l=g}return d}}function zg(r){if(r%tl===Wg){const e=(r+ae)/tl;return function(n,s){const i=n.pow(s,e);if(!n.eql(n.sqr(i),s))throw new Error("Cannot find square root");return i}}if(r%Su===Nu){const e=(r-Nu)/Su;return function(n,s){const i=n.mul(s,or),o=n.pow(i,e),a=n.mul(s,o),c=n.mul(n.mul(a,or),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return Qg(r)}const Jg=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qg(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Jg.reduce((n,s)=>(n[s]="function",n),e);return Po(r,t)}function Zg(r,e,t){if(t<ye)throw new Error("Expected power > 0");if(t===ye)return r.ONE;if(t===ae)return e;let n=r.ONE,s=e;for(;t>ye;)t&ae&&(n=r.mul(n,s)),s=r.sqr(s),t>>=ae;return n}function $g(r,e){const t=new Array(e.length),n=e.reduce((i,o,a)=>r.is0(o)?i:(t[a]=i,r.mul(i,o)),r.ONE),s=r.inv(n);return e.reduceRight((i,o,a)=>r.is0(o)?i:(t[a]=r.mul(i,t[a]),r.mul(i,o)),s),t}function Rd(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Yg(r,e,t=!1,n={}){if(r<=ye)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:s,nByteLength:i}=Rd(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=zg(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:i,MASK:Ul(s),ZERO:ye,ONE:ae,create:c=>Ge(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ye<=c&&c<r},is0:c=>c===ye,isOdd:c=>(c&ae)===ae,neg:c=>Ge(-c,r),eql:(c,l)=>c===l,sqr:c=>Ge(c*c,r),add:(c,l)=>Ge(c+l,r),sub:(c,l)=>Ge(c-l,r),mul:(c,l)=>Ge(c*l,r),pow:(c,l)=>Zg(a,c,l),div:(c,l)=>Ge(c*nl(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>nl(c,r),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>$g(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>t?Ll(c,i):vi(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?_l(c):Hr(c)}});return Object.freeze(a)}function Od(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function Td(r){const e=Od(r);return e+Math.ceil(e/2)}function Xg(r,e,t=!1){const n=r.length,s=Od(e),i=Td(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);const o=t?Hr(r):_l(r),a=Ge(o,e-ae)+ae;return t?Ll(a,s):vi(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const e0=BigInt(0),Nc=BigInt(1);function t0(r,e){const t=(s,i)=>{const o=i.negate();return s?o:i},n=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=r.ZERO,a=s;for(;i>e0;)i&Nc&&(o=o.add(a)),a=a.double(),i>>=Nc;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=n(i),c=[];let l=s,h=l;for(let d=0;d<o;d++){h=l,c.push(h);for(let f=1;f<a;f++)h=h.add(l),c.push(h);l=h.double()}return c},wNAF(s,i,o){const{windows:a,windowSize:c}=n(s);let l=r.ZERO,h=r.BASE;const d=BigInt(2**s-1),f=2**s,g=BigInt(s);for(let w=0;w<a;w++){const m=w*c;let C=Number(o&d);o>>=g,C>c&&(C-=f,o+=Nc);const v=m,k=m+Math.abs(C)-1,S=w%2!==0,B=C<0;C===0?h=h.add(t(S,i[v])):l=l.add(t(B,i[k]))}return{p:l,f:h}},wNAFCached(s,i,o,a){const c=s._WINDOW_SIZE||1;let l=i.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&i.set(s,a(l))),this.wNAF(c,l,o)}}}function Bd(r){return qg(r.Fp),Po(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Rd(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function n0(r){const e=Bd(r);Po(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:r0,hexToBytes:s0}=jg,dr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=dr;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");const t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:r0(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=dr,t=typeof r=="string"?s0(r):r;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=dr._parseInt(t.subarray(2)),{d:o,l:a}=dr._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(r){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,t=l=>{const h=l.toString(16);return h.length&1?`0${h}`:h},n=e(t(r.s)),s=e(t(r.r)),i=n.length/2,o=s.length/2,a=t(i),c=t(o);return`30${t(o+i+4)}02${c}${s}02${a}${n}`}},mn=BigInt(0),at=BigInt(1);BigInt(2);const ku=BigInt(3);BigInt(4);function i0(r){const e=n0(r),{Fp:t}=e,n=e.toBytes||((w,m,C)=>{const v=m.toAffine();return Qi(Uint8Array.from([4]),t.toBytes(v.x),t.toBytes(v.y))}),s=e.fromBytes||(w=>{const m=w.subarray(1),C=t.fromBytes(m.subarray(0,t.BYTES)),v=t.fromBytes(m.subarray(t.BYTES,2*t.BYTES));return{x:C,y:v}});function i(w){const{a:m,b:C}=e,v=t.sqr(w),k=t.mul(v,w);return t.add(t.add(k,t.mul(w,m)),C)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(w){return typeof w=="bigint"&&mn<w&&w<e.n}function a(w){if(!o(w))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(w){const{allowedPrivateKeyLengths:m,nByteLength:C,wrapPrivateKey:v,n:k}=e;if(m&&typeof w!="bigint"){if(w instanceof Uint8Array&&(w=Ei(w)),typeof w!="string"||!m.includes(w.length))throw new Error("Invalid key");w=w.padStart(C*2,"0")}let S;try{S=typeof w=="bigint"?w:Hr(pt("private key",w,C))}catch{throw new Error(`private key must be ${C} bytes, hex or bigint, not ${typeof w}`)}return v&&(S=Ge(S,k)),a(S),S}const l=new Map;function h(w){if(!(w instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(m,C,v){if(this.px=m,this.py=C,this.pz=v,m==null||!t.isValid(m))throw new Error("x required");if(C==null||!t.isValid(C))throw new Error("y required");if(v==null||!t.isValid(v))throw new Error("z required")}static fromAffine(m){const{x:C,y:v}=m||{};if(!m||!t.isValid(C)||!t.isValid(v))throw new Error("invalid affine point");if(m instanceof d)throw new Error("projective point not allowed");const k=S=>t.eql(S,t.ZERO);return k(C)&&k(v)?d.ZERO:new d(C,v,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const C=t.invertBatch(m.map(v=>v.pz));return m.map((v,k)=>v.toAffine(C[k])).map(d.fromAffine)}static fromHex(m){const C=d.fromAffine(s(pt("pointHex",m)));return C.assertValidity(),C}static fromPrivateKey(m){return d.BASE.multiply(c(m))}_setWindowSize(m){this._WINDOW_SIZE=m,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:m,y:C}=this.toAffine();if(!t.isValid(m)||!t.isValid(C))throw new Error("bad point: x or y not FE");const v=t.sqr(C),k=i(m);if(!t.eql(v,k))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:m}=this.toAffine();if(t.isOdd)return!t.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){h(m);const{px:C,py:v,pz:k}=this,{px:S,py:B,pz:P}=m,R=t.eql(t.mul(C,P),t.mul(S,k)),M=t.eql(t.mul(v,P),t.mul(B,k));return R&&M}negate(){return new d(this.px,t.neg(this.py),this.pz)}double(){const{a:m,b:C}=e,v=t.mul(C,ku),{px:k,py:S,pz:B}=this;let P=t.ZERO,R=t.ZERO,M=t.ZERO,D=t.mul(k,k),q=t.mul(S,S),Q=t.mul(B,B),z=t.mul(k,S);return z=t.add(z,z),M=t.mul(k,B),M=t.add(M,M),P=t.mul(m,M),R=t.mul(v,Q),R=t.add(P,R),P=t.sub(q,R),R=t.add(q,R),R=t.mul(P,R),P=t.mul(z,P),M=t.mul(v,M),Q=t.mul(m,Q),z=t.sub(D,Q),z=t.mul(m,z),z=t.add(z,M),M=t.add(D,D),D=t.add(M,D),D=t.add(D,Q),D=t.mul(D,z),R=t.add(R,D),Q=t.mul(S,B),Q=t.add(Q,Q),D=t.mul(Q,z),P=t.sub(P,D),M=t.mul(Q,q),M=t.add(M,M),M=t.add(M,M),new d(P,R,M)}add(m){h(m);const{px:C,py:v,pz:k}=this,{px:S,py:B,pz:P}=m;let R=t.ZERO,M=t.ZERO,D=t.ZERO;const q=e.a,Q=t.mul(e.b,ku);let z=t.mul(C,S),de=t.mul(v,B),we=t.mul(k,P),kt=t.add(C,v),x=t.add(S,B);kt=t.mul(kt,x),x=t.add(z,de),kt=t.sub(kt,x),x=t.add(C,k);let L=t.add(S,P);return x=t.mul(x,L),L=t.add(z,we),x=t.sub(x,L),L=t.add(v,k),R=t.add(B,P),L=t.mul(L,R),R=t.add(de,we),L=t.sub(L,R),D=t.mul(q,x),R=t.mul(Q,we),D=t.add(R,D),R=t.sub(de,D),D=t.add(de,D),M=t.mul(R,D),de=t.add(z,z),de=t.add(de,z),we=t.mul(q,we),x=t.mul(Q,x),de=t.add(de,we),we=t.sub(z,we),we=t.mul(q,we),x=t.add(x,we),z=t.mul(de,x),M=t.add(M,z),z=t.mul(L,x),R=t.mul(kt,R),R=t.sub(R,z),z=t.mul(kt,de),D=t.mul(L,D),D=t.add(D,z),new d(R,M,D)}subtract(m){return this.add(m.negate())}is0(){return this.equals(d.ZERO)}wNAF(m){return g.wNAFCached(this,l,m,C=>{const v=t.invertBatch(C.map(k=>k.pz));return C.map((k,S)=>k.toAffine(v[S])).map(d.fromAffine)})}multiplyUnsafe(m){const C=d.ZERO;if(m===mn)return C;if(a(m),m===at)return this;const{endo:v}=e;if(!v)return g.unsafeLadder(this,m);let{k1neg:k,k1:S,k2neg:B,k2:P}=v.splitScalar(m),R=C,M=C,D=this;for(;S>mn||P>mn;)S&at&&(R=R.add(D)),P&at&&(M=M.add(D)),D=D.double(),S>>=at,P>>=at;return k&&(R=R.negate()),B&&(M=M.negate()),M=new d(t.mul(M.px,v.beta),M.py,M.pz),R.add(M)}multiply(m){a(m);let C=m,v,k;const{endo:S}=e;if(S){const{k1neg:B,k1:P,k2neg:R,k2:M}=S.splitScalar(C);let{p:D,f:q}=this.wNAF(P),{p:Q,f:z}=this.wNAF(M);D=g.constTimeNegate(B,D),Q=g.constTimeNegate(R,Q),Q=new d(t.mul(Q.px,S.beta),Q.py,Q.pz),v=D.add(Q),k=q.add(z)}else{const{p:B,f:P}=this.wNAF(C);v=B,k=P}return d.normalizeZ([v,k])[0]}multiplyAndAddUnsafe(m,C,v){const k=d.BASE,S=(P,R)=>R===mn||R===at||!P.equals(k)?P.multiplyUnsafe(R):P.multiply(R),B=S(this,C).add(S(m,v));return B.is0()?void 0:B}toAffine(m){const{px:C,py:v,pz:k}=this,S=this.is0();m==null&&(m=S?t.ONE:t.inv(k));const B=t.mul(C,m),P=t.mul(v,m),R=t.mul(k,m);if(S)return{x:t.ZERO,y:t.ZERO};if(!t.eql(R,t.ONE))throw new Error("invZ was invalid");return{x:B,y:P}}isTorsionFree(){const{h:m,isTorsionFree:C}=e;if(m===at)return!0;if(C)return C(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:C}=e;return m===at?this:C?C(d,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return this.assertValidity(),n(d,this,m)}toHex(m=!0){return Ei(this.toRawBytes(m))}}d.BASE=new d(e.Gx,e.Gy,t.ONE),d.ZERO=new d(t.ZERO,t.ONE,t.ZERO);const f=e.nBitLength,g=t0(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:o}}function o0(r){const e=Bd(r);return Po(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function a0(r){const e=o0(r),{Fp:t,n}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(x){return mn<x&&x<t.ORDER}function a(x){return Ge(x,n)}function c(x){return nl(x,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:d,isWithinCurveOrder:f}=i0({...e,toBytes(x,L,K){const ee=L.toAffine(),Y=t.toBytes(ee.x),fe=Qi;return K?fe(Uint8Array.from([L.hasEvenY()?2:3]),Y):fe(Uint8Array.from([4]),Y,t.toBytes(ee.y))},fromBytes(x){const L=x.length,K=x[0],ee=x.subarray(1);if(L===s&&(K===2||K===3)){const Y=Hr(ee);if(!o(Y))throw new Error("Point is not on curve");const fe=d(Y);let We=t.sqrt(fe);const Ve=(We&at)===at;return(K&1)===1!==Ve&&(We=t.neg(We)),{x:Y,y:We}}else if(L===i&&K===4){const Y=t.fromBytes(ee.subarray(0,t.BYTES)),fe=t.fromBytes(ee.subarray(t.BYTES,2*t.BYTES));return{x:Y,y:fe}}else throw new Error(`Point of length ${L} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),g=x=>Ei(vi(x,e.nByteLength));function w(x){const L=n>>at;return x>L}function m(x){return w(x)?a(-x):x}const C=(x,L,K)=>Hr(x.slice(L,K));class v{constructor(L,K,ee){this.r=L,this.s=K,this.recovery=ee,this.assertValidity()}static fromCompact(L){const K=e.nByteLength;return L=pt("compactSignature",L,K*2),new v(C(L,0,K),C(L,K,2*K))}static fromDER(L){const{r:K,s:ee}=dr.toSig(pt("DER",L));return new v(K,ee)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(L){return new v(this.r,this.s,L)}recoverPublicKey(L){const{r:K,s:ee,recovery:Y}=this,fe=M(pt("msgHash",L));if(Y==null||![0,1,2,3].includes(Y))throw new Error("recovery id invalid");const We=Y===2||Y===3?K+e.n:K;if(We>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Ve=Y&1?"03":"02",Cn=l.fromHex(Ve+g(We)),vn=c(We),Yr=a(-fe*vn),Oi=a(ee*vn),In=l.BASE.multiplyAndAddUnsafe(Cn,Yr,Oi);if(!In)throw new Error("point at infinify");return In.assertValidity(),In}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new v(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Ci(this.toDERHex())}toDERHex(){return dr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ci(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const k={isValidPrivateKey(x){try{return h(x),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const x=Td(e.n);return Xg(e.randomBytes(x),e.n)},precompute(x=8,L=l.BASE){return L._setWindowSize(x),L.multiply(BigInt(3)),L}};function S(x,L=!0){return l.fromPrivateKey(x).toRawBytes(L)}function B(x){const L=x instanceof Uint8Array,K=typeof x=="string",ee=(L||K)&&x.length;return L?ee===s||ee===i:K?ee===2*s||ee===2*i:x instanceof l}function P(x,L,K=!0){if(B(x))throw new Error("first arg must be private key");if(!B(L))throw new Error("second arg must be public key");return l.fromHex(L).multiply(h(x)).toRawBytes(K)}const R=e.bits2int||function(x){const L=Hr(x),K=x.length*8-e.nBitLength;return K>0?L>>BigInt(K):L},M=e.bits2int_modN||function(x){return a(R(x))},D=Ul(e.nBitLength);function q(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(mn<=x&&x<D))throw new Error(`bigint expected < 2^${e.nBitLength}`);return vi(x,e.nByteLength)}function Q(x,L,K=z){if(["recovered","canonical"].some(tr=>tr in K))throw new Error("sign() legacy options not supported");const{hash:ee,randomBytes:Y}=e;let{lowS:fe,prehash:We,extraEntropy:Ve}=K;fe==null&&(fe=!0),x=pt("msgHash",x),We&&(x=pt("prehashed msgHash",ee(x)));const Cn=M(x),vn=h(L),Yr=[q(vn),q(Cn)];if(Ve!=null){const tr=Ve===!0?Y(t.BYTES):Ve;Yr.push(pt("extraEntropy",tr))}const Oi=Qi(...Yr),In=Cn;function yc(tr){const Xr=R(tr);if(!f(Xr))return;const ou=c(Xr),es=l.BASE.multiply(Xr).toAffine(),ut=a(es.x);if(ut===mn)return;const ts=a(ou*a(In+ut*vn));if(ts===mn)return;let au=(es.x===ut?0:2)|Number(es.y&at),cu=ts;return fe&&w(ts)&&(cu=m(ts),au^=1),new v(ut,cu,au)}return{seed:Oi,k2sig:yc}}const z={lowS:e.lowS,prehash:!1},de={lowS:e.lowS,prehash:!1};function we(x,L,K=z){const{seed:ee,k2sig:Y}=Q(x,L,K),fe=e;return Pd(fe.hash.outputLen,fe.nByteLength,fe.hmac)(ee,Y)}l.BASE._setWindowSize(8);function kt(x,L,K,ee=de){var es;const Y=x;if(L=pt("msgHash",L),K=pt("publicKey",K),"strict"in ee)throw new Error("options.strict was renamed to lowS");const{lowS:fe,prehash:We}=ee;let Ve,Cn;try{if(typeof Y=="string"||Y instanceof Uint8Array)try{Ve=v.fromDER(Y)}catch(ut){if(!(ut instanceof dr.Err))throw ut;Ve=v.fromCompact(Y)}else if(typeof Y=="object"&&typeof Y.r=="bigint"&&typeof Y.s=="bigint"){const{r:ut,s:ts}=Y;Ve=new v(ut,ts)}else throw new Error("PARSE");Cn=l.fromHex(K)}catch(ut){if(ut.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(fe&&Ve.hasHighS())return!1;We&&(L=e.hash(L));const{r:vn,s:Yr}=Ve,Oi=M(L),In=c(Yr),yc=a(Oi*In),tr=a(vn*In),Xr=(es=l.BASE.multiplyAndAddUnsafe(Cn,yc,tr))==null?void 0:es.toAffine();return Xr?a(Xr.x)===vn:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:P,sign:we,verify:kt,ProjectivePoint:l,Signature:v,utils:k}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function c0(r){return{hash:r,hmac:(e,...t)=>ld(r,e,qp(...t)),randomBytes:Zp}}function l0(r,e){const t=n=>a0({...r,...c0(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _d=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),u0=BigInt(1),rl=BigInt(2),Pu=(r,e)=>(r+e/rl)/e;function h0(r){const e=_d,t=BigInt(3),n=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%e,h=l*l*r%e,d=Xe(h,t,e)*h%e,f=Xe(d,t,e)*h%e,g=Xe(f,rl,e)*l%e,w=Xe(g,s,e)*g%e,m=Xe(w,i,e)*w%e,C=Xe(m,a,e)*m%e,v=Xe(C,c,e)*C%e,k=Xe(v,a,e)*m%e,S=Xe(k,t,e)*h%e,B=Xe(S,o,e)*w%e,P=Xe(B,n,e)*l%e,R=Xe(P,rl,e);if(!sl.eql(sl.sqr(R),r))throw new Error("Cannot find square root");return R}const sl=Yg(_d,void 0,void 0,{sqrt:h0}),Rn=l0({a:BigInt(0),b:BigInt(7),Fp:sl,n:xu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=xu,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-u0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=Pu(i*r,e),c=Pu(-n*r,e);let l=Ge(r-a*t-c*s,e),h=Ge(-a*n-c*i,e);const d=l>o,f=h>o;if(d&&(l=e-l),f&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:d,k1:l,k2neg:f,k2:h}}}},hd);BigInt(0);Rn.ProjectivePoint;const zi="0x0000000000000000000000000000000000000000",Ru="0x0000000000000000000000000000000000000000000000000000000000000000",Ou=BigInt(0),Tu=BigInt(1),Bu=BigInt(2),_u=BigInt(27),Lu=BigInt(28),jo=BigInt(35),rs={};function Uu(r){return Kr(Le(r),32)}var Ms,Ds,Fs,Ir;const ft=class ft{constructor(e,t,n,s){A(this,Ms,void 0);A(this,Ds,void 0);A(this,Fs,void 0);A(this,Ir,void 0);xo(e,rs,"Signature"),p(this,Ms,t),p(this,Ds,n),p(this,Fs,s),p(this,Ir,null)}get r(){return u(this,Ms)}set r(e){y(Cs(e)===32,"invalid r","value",e),p(this,Ms,T(e))}get s(){return u(this,Ds)}set s(e){y(Cs(e)===32,"invalid s","value",e);const t=T(e);y(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),p(this,Ds,t)}get v(){return u(this,Fs)}set v(e){const t=H(e,"value");y(t===27||t===28,"invalid v","v",e),p(this,Fs,t)}get networkV(){return u(this,Ir)}get legacyChainId(){const e=this.networkV;return e==null?null:ft.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=V(this.s);return this.yParity&&(e[0]|=128),T(e)}get compactSerialized(){return le([this.r,this.yParityAndS])}get serialized(){return le([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new ft(rs,this.r,this.s,this.v);return this.networkV&&p(e,Ir,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=_(e,"v");return t==_u||t==Lu?Ou:(y(t>=jo,"invalid EIP-155 v","v",e),(t-jo)/Bu)}static getChainIdV(e,t){return _(e)*Bu+BigInt(35+t-27)}static getNormalizedV(e){const t=_(e);return t===Ou||t===_u?27:t===Tu||t===Lu?28:(y(t>=jo,"invalid v","v",e),t&Tu?27:28)}static from(e){function t(l,h){y(l,h,"signature",e)}if(e==null)return new ft(rs,Ru,Ru,27);if(typeof e=="string"){const l=V(e,"signature");if(l.length===64){const h=T(l.slice(0,32)),d=l.slice(32,64),f=d[0]&128?28:27;return d[0]&=127,new ft(rs,h,T(d),f)}if(l.length===65){const h=T(l.slice(0,32)),d=l.slice(32,64);t((d[0]&128)===0,"non-canonical s");const f=ft.getNormalizedV(l[64]);return new ft(rs,h,T(d),f)}t(!1,"invalid raw signature length")}if(e instanceof ft)return e.clone();const n=e.r;t(n!=null,"missing r");const s=Uu(n),i=function(l,h){if(l!=null)return Uu(l);if(h!=null){t(X(h,32),"invalid yParityAndS");const d=V(h);return d[0]&=127,T(d)}t(!1,"missing s")}(e.s,e.yParityAndS);t((V(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(l,h,d){if(l!=null){const f=_(l);return{networkV:f>=jo?f:void 0,v:ft.getNormalizedV(f)}}if(h!=null)return t(X(h,32),"invalid yParityAndS"),{v:V(h)[0]&128?28:27};if(d!=null){switch(H(d,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),c=new ft(rs,s,i,a);return o&&p(c,Ir,o),t(e.yParity==null||H(e.yParity,"sig.yParity")===c.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===c.yParityAndS,"yParityAndS mismatch"),c}};Ms=new WeakMap,Ds=new WeakMap,Fs=new WeakMap,Ir=new WeakMap;let It=ft;var an;const cr=class cr{constructor(e){A(this,an,void 0);y(Cs(e)===32,"invalid private key","privateKey","[REDACTED]"),p(this,an,T(e))}get privateKey(){return u(this,an)}get publicKey(){return cr.computePublicKey(u(this,an))}get compressedPublicKey(){return cr.computePublicKey(u(this,an),!0)}sign(e){y(Cs(e)===32,"invalid digest length","digest",e);const t=Rn.sign(_e(e),_e(u(this,an)),{lowS:!0});return It.from({r:Xn(t.r,32),s:Xn(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=cr.computePublicKey(e);return T(Rn.getSharedSecret(_e(u(this,an)),V(t),!1))}static computePublicKey(e,t){let n=V(e,"key");if(n.length===32){const i=Rn.getPublicKey(n,!!t);return T(i)}if(n.length===64){const i=new Uint8Array(65);i[0]=4,i.set(n,1),n=i}const s=Rn.ProjectivePoint.fromHex(n);return T(s.toRawBytes(t))}static recoverPublicKey(e,t){y(Cs(e)===32,"invalid digest length","digest",e);const n=It.from(t);let s=Rn.Signature.fromCompact(_e(le([n.r,n.s])));s=s.addRecoveryBit(n.yParity);const i=s.recoverPublicKey(_e(e));return y(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,n){const s=Rn.ProjectivePoint.fromHex(cr.computePublicKey(e).substring(2)),i=Rn.ProjectivePoint.fromHex(cr.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!n)}};an=new WeakMap;let Ji=cr;const d0=BigInt(0),f0=BigInt(36);function Mu(r){r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const n=V(ue(t));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(n[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const Ml={};for(let r=0;r<10;r++)Ml[String(r)]=String(r);for(let r=0;r<26;r++)Ml[String.fromCharCode(65+r)]=String(10+r);const Du=15;function p0(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(n=>Ml[n]).join("");for(;e.length>=Du;){let n=e.substring(0,Du);e=parseInt(n,10)%97+e.substring(n.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const g0=function(){const r={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];r[t]=BigInt(e)}return r}();function m0(r){r=r.toLowerCase();let e=d0;for(let t=0;t<r.length;t++)e=e*f0+g0[r[t]];return e}function $(r){if(y(typeof r=="string","invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/)){r.startsWith("0x")||(r="0x"+r);const e=Mu(r);return y(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===r,"bad address checksum","address",r),e}if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){y(r.substring(2,4)===p0(r),"bad icap checksum","address",r);let e=m0(r.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Mu("0x"+e)}y(!1,"invalid address","address",r)}function y0(r){const e=$(r.from);let n=_(r.nonce,"tx.nonce").toString(16);return n==="0"?n="0x":n.length%2?n="0x0"+n:n="0x"+n,$(se(ue(jr([e,n])),12))}function Ld(r){return r&&typeof r.getAddress=="function"}async function Sc(r,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(I(typeof r!="string","unconfigured name","UNCONFIGURED_NAME",{value:r}),y(!1,"invalid AddressLike value; did not resolve to a value address","target",r)),$(t)}function Me(r,e){if(typeof r=="string")return r.match(/^0x[0-9a-f]{40}$/i)?$(r):(I(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Sc(r,e.resolveName(r)));if(Ld(r))return Sc(r,r.getAddress());if(r&&typeof r.then=="function")return Sc(r,r);y(!1,"unsupported addressable value","target",r)}const $t={};function O(r,e){let t=!1;return e<0&&(t=!0,e*=-1),new xe($t,`${t?"":"u"}int${e}`,r,{signed:t,width:e})}function J(r,e){return new xe($t,`bytes${e||""}`,r,{size:e})}const Fu=Symbol.for("_ethers_typed");var Nr;const Yt=class Yt{constructor(e,t,n,s){E(this,"type");E(this,"value");A(this,Nr,void 0);E(this,"_typedSymbol");s==null&&(s=null),xo($t,e,"Typed"),F(this,{_typedSymbol:Fu,type:t,value:n}),p(this,Nr,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return u(this,Nr)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return u(this,Nr)===!0?-1:u(this,Nr)===!1?this.value.length:null}static from(e,t){return new Yt($t,e,t)}static uint8(e){return O(e,8)}static uint16(e){return O(e,16)}static uint24(e){return O(e,24)}static uint32(e){return O(e,32)}static uint40(e){return O(e,40)}static uint48(e){return O(e,48)}static uint56(e){return O(e,56)}static uint64(e){return O(e,64)}static uint72(e){return O(e,72)}static uint80(e){return O(e,80)}static uint88(e){return O(e,88)}static uint96(e){return O(e,96)}static uint104(e){return O(e,104)}static uint112(e){return O(e,112)}static uint120(e){return O(e,120)}static uint128(e){return O(e,128)}static uint136(e){return O(e,136)}static uint144(e){return O(e,144)}static uint152(e){return O(e,152)}static uint160(e){return O(e,160)}static uint168(e){return O(e,168)}static uint176(e){return O(e,176)}static uint184(e){return O(e,184)}static uint192(e){return O(e,192)}static uint200(e){return O(e,200)}static uint208(e){return O(e,208)}static uint216(e){return O(e,216)}static uint224(e){return O(e,224)}static uint232(e){return O(e,232)}static uint240(e){return O(e,240)}static uint248(e){return O(e,248)}static uint256(e){return O(e,256)}static uint(e){return O(e,256)}static int8(e){return O(e,-8)}static int16(e){return O(e,-16)}static int24(e){return O(e,-24)}static int32(e){return O(e,-32)}static int40(e){return O(e,-40)}static int48(e){return O(e,-48)}static int56(e){return O(e,-56)}static int64(e){return O(e,-64)}static int72(e){return O(e,-72)}static int80(e){return O(e,-80)}static int88(e){return O(e,-88)}static int96(e){return O(e,-96)}static int104(e){return O(e,-104)}static int112(e){return O(e,-112)}static int120(e){return O(e,-120)}static int128(e){return O(e,-128)}static int136(e){return O(e,-136)}static int144(e){return O(e,-144)}static int152(e){return O(e,-152)}static int160(e){return O(e,-160)}static int168(e){return O(e,-168)}static int176(e){return O(e,-176)}static int184(e){return O(e,-184)}static int192(e){return O(e,-192)}static int200(e){return O(e,-200)}static int208(e){return O(e,-208)}static int216(e){return O(e,-216)}static int224(e){return O(e,-224)}static int232(e){return O(e,-232)}static int240(e){return O(e,-240)}static int248(e){return O(e,-248)}static int256(e){return O(e,-256)}static int(e){return O(e,-256)}static bytes1(e){return J(e,1)}static bytes2(e){return J(e,2)}static bytes3(e){return J(e,3)}static bytes4(e){return J(e,4)}static bytes5(e){return J(e,5)}static bytes6(e){return J(e,6)}static bytes7(e){return J(e,7)}static bytes8(e){return J(e,8)}static bytes9(e){return J(e,9)}static bytes10(e){return J(e,10)}static bytes11(e){return J(e,11)}static bytes12(e){return J(e,12)}static bytes13(e){return J(e,13)}static bytes14(e){return J(e,14)}static bytes15(e){return J(e,15)}static bytes16(e){return J(e,16)}static bytes17(e){return J(e,17)}static bytes18(e){return J(e,18)}static bytes19(e){return J(e,19)}static bytes20(e){return J(e,20)}static bytes21(e){return J(e,21)}static bytes22(e){return J(e,22)}static bytes23(e){return J(e,23)}static bytes24(e){return J(e,24)}static bytes25(e){return J(e,25)}static bytes26(e){return J(e,26)}static bytes27(e){return J(e,27)}static bytes28(e){return J(e,28)}static bytes29(e){return J(e,29)}static bytes30(e){return J(e,30)}static bytes31(e){return J(e,31)}static bytes32(e){return J(e,32)}static address(e){return new Yt($t,"address",e)}static bool(e){return new Yt($t,"bool",!!e)}static bytes(e){return new Yt($t,"bytes",e)}static string(e){return new Yt($t,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Yt($t,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===Fu}static dereference(e,t){if(Yt.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};Nr=new WeakMap;let xe=Yt;class w0 extends En{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=xe.dereference(t,"string");try{n=$(n)}catch(s){return this._throwError(s.message,t)}return e.writeValue(n)}decode(e){return $(Xn(e.readValue(),20))}}class b0 extends En{constructor(t){super(t.name,t.type,"_",t.dynamic);E(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,n){return this.coder.encode(t,n)}decode(t){return this.coder.decode(t)}}function Ud(r,e,t){let n=[];if(Array.isArray(t))n=t;else if(t&&typeof t=="object"){let c={};n=e.map(l=>{const h=l.localName;return I(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),I(!c[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),c[h]=!0,t[h]})}else y(!1,"invalid tuple value","tuple",t);y(e.length===n.length,"types/value length mismatch","tuple",t);let s=new $c,i=new $c,o=[];e.forEach((c,l)=>{let h=n[l];if(c.dynamic){let d=i.length;c.encode(i,h);let f=s.writeUpdatableValue();o.push(g=>{f(g+d)})}else c.encode(s,h)}),o.forEach(c=>{c(s.length)});let a=r.appendWriter(s);return a+=r.appendWriter(i),a}function Md(r,e){let t=[],n=[],s=r.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=r.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(l){if(ke(l,"BUFFER_OVERRUN"))throw l;o=l,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(r)}catch(a){if(ke(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),n.push(i.localName||null)}),bi.fromItems(t,n)}class A0 extends En{constructor(t,n,s){const i=t.type+"["+(n>=0?n:"")+"]",o=n===-1||t.dynamic;super("array",i,s,o);E(this,"coder");E(this,"length");F(this,{coder:t,length:n})}defaultValue(){const t=this.coder.defaultValue(),n=[];for(let s=0;s<this.length;s++)n.push(t);return n}encode(t,n){const s=xe.dereference(n,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),Wh(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return Ud(t,o,s)}decode(t){let n=this.length;n===-1&&(n=t.readIndex(),I(n*Ue<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:n*Ue,length:t.dataLength}));let s=[];for(let i=0;i<n;i++)s.push(new b0(this.coder));return Md(t,s)}}class E0 extends En{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=xe.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class Dd extends En{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=_e(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class C0 extends Dd{constructor(e){super("bytes",e)}decode(e){return T(super.decode(e))}}class v0 extends En{constructor(t,n){let s="bytes"+String(t);super(s,s,n,!1);E(this,"size");F(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,n){let s=_e(xe.dereference(n,this.type));return s.length!==this.size&&this._throwError("incorrect data length",n),t.writeBytes(s)}decode(t){return T(t.readBytes(this.size))}}const I0=new Uint8Array([]);class N0 extends En{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(I0)}decode(e){return e.readBytes(0),null}}const S0=BigInt(0),k0=BigInt(1),x0=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class P0 extends En{constructor(t,n,s){const i=(n?"int":"uint")+t*8;super(i,i,s,!1);E(this,"size");E(this,"signed");F(this,{size:t,signed:n},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,n){let s=_(xe.dereference(n,this.type)),i=hr(x0,Ue*8);if(this.signed){let o=hr(i,this.size*8-1);(s>o||s<-(o+k0))&&this._throwError("value out-of-bounds",n),s=zh(s,8*Ue)}else(s<S0||s>hr(i,this.size*8))&&this._throwError("value out-of-bounds",n);return t.writeValue(s)}decode(t){let n=hr(t.readValue(),this.size*8);return this.signed&&(n=da(n,this.size*8)),n}}class R0 extends Dd{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,jt(xe.dereference(t,"string")))}decode(e){return fa(super.decode(e))}}class Wo extends En{constructor(t,n){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,n,s);E(this,"coders");F(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const n=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||n[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,n){const s=xe.dereference(n,"tuple");return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vOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const Hu=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Gu=4;function T0(r){let e=0;function t(){return r[e++]<<8|r[e++]}let n=t(),s=1,i=[0,1];for(let P=1;P<n;P++)i.push(s+=t());let o=t(),a=e;e+=o;let c=0,l=0;function h(){return c==0&&(l=l<<8|r[e++],c=8),l>>--c&1}const d=31,f=2**d,g=f>>>1,w=g>>1,m=f-1;let C=0;for(let P=0;P<d;P++)C=C<<1|h();let v=[],k=0,S=f;for(;;){let P=Math.floor(((C-k+1)*s-1)/S),R=0,M=n;for(;M-R>1;){let Q=R+M>>>1;P<i[Q]?M=Q:R=Q}if(R==0)break;v.push(R);let D=k+Math.floor(S*i[R]/s),q=k+Math.floor(S*i[R+1]/s)-1;for(;!((D^q)&g);)C=C<<1&m|h(),D=D<<1&m,q=q<<1&m|1;for(;D&~q&w;)C=C&g|C<<1&m>>>1|h(),D=D<<1^g,q=(q^g)<<1|g|1;k=D,S=1+q-D}let B=n-4;return v.map(P=>{switch(P-B){case 3:return B+65792+(r[a++]<<16|r[a++]<<8|r[a++]);case 2:return B+256+(r[a++]<<8|r[a++]);case 1:return B+r[a++];default:return P-1}})}function B0(r){let e=0;return()=>r[e++]}function Fd(r){return B0(T0(_0(r)))}function _0(r){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=r.length,n=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[r.charCodeAt(s)],o+=6,o>=8&&(n[i++]=a>>(o-=8));return n}function L0(r){return r&1?~r>>1:r>>1}function U0(r,e){let t=Array(r);for(let n=0,s=0;n<r;n++)t[n]=s+=L0(e());return t}function qi(r,e=0){let t=[];for(;;){let n=r(),s=r();if(!s)break;e+=n;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function Hd(r){return Zi(()=>{let e=qi(r);if(e.length)return e})}function Gd(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(M0(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(D0(t,r))}return e.flat()}function Zi(r){let e=[];for(;;){let t=r(e.length);if(!t)break;e.push(t)}return e}function Kd(r,e,t){let n=Array(r).fill().map(()=>[]);for(let s=0;s<e;s++)U0(r,t).forEach((i,o)=>n[o].push(i));return n}function M0(r,e){let t=1+e(),n=e(),s=Zi(e);return Kd(s.length,1+r,e).flatMap((o,a)=>{let[c,...l]=o;return Array(s[a]).fill().map((h,d)=>{let f=d*n;return[c+d*t,l.map(g=>g+f)]})})}function D0(r,e){let t=1+e();return Kd(t,1+r,e).map(s=>[s[0],s.slice(1)])}function F0(r){let e=[],t=qi(r);return s(n([]),[]),e;function n(i){let o=r(),a=Zi(()=>{let c=qi(r).map(l=>t[l]);if(c.length)return n(c)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,c){if(!(i&4&&c===a[a.length-1])){i&2&&(c=a[a.length-1]),i&1&&e.push(a);for(let l of o)for(let h of l.Q)s(l,[...a,h],c)}}}function H0(r){return r.toString(16).toUpperCase().padStart(2,"0")}function jd(r){return`{${H0(r)}}`}function G0(r){let e=[];for(let t=0,n=r.length;t<n;){let s=r.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function Ii(r){let t=r.length;if(t<4096)return String.fromCodePoint(...r);let n=[];for(let s=0;s<t;)n.push(String.fromCodePoint(...r.slice(s,s+=4096)));return n.join("")}function K0(r,e){let t=r.length,n=t-e.length;for(let s=0;n==0&&s<t;s++)n=r[s]-e[s];return n}var j0="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+x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=4449,wa=4519,Wd=19,Vd=21,Ni=28,ba=Vd*Ni,W0=Wd*ba,V0=$i+W0,Q0=ma+Wd,z0=ya+Vd,J0=wa+Ni;function Di(r){return r>>24&255}function Qd(r){return r&16777215}let il,Ku,ol,na;function q0(){let r=Fd(j0);il=new Map(Hd(r).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),Ku=new Set(qi(r)),ol=new Map,na=new Map;for(let[e,t]of Gd(r)){if(!Ku.has(e)&&t.length==2){let[n,s]=t,i=na.get(n);i||(i=new Map,na.set(n,i)),i.set(s,e)}ol.set(e,t.reverse())}}function zd(r){return r>=$i&&r<V0}function Z0(r,e){if(r>=ma&&r<Q0&&e>=ya&&e<z0)return $i+(r-ma)*ba+(e-ya)*Ni;if(zd(r)&&e>wa&&e<J0&&(r-$i)%Ni==0)return r+(e-wa);{let t=na.get(r);return t&&(t=t.get(e),t)?t:-1}}function Jd(r){il||q0();let e=[],t=[],n=!1;function s(i){let o=il.get(i);o&&(n=!0,i|=o),e.push(i)}for(let i of r)for(;;){if(i<128)e.push(i);else if(zd(i)){let o=i-$i,a=o/ba|0,c=o%ba/Ni|0,l=o%Ni;s(ma+a),s(ya+c),l>0&&s(wa+l)}else{let o=ol.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(n&&e.length>1){let i=Di(e[0]);for(let o=1;o<e.length;o++){let a=Di(e[o]);if(a==0||i<=a){i=a;continue}let c=o-1;for(;;){let l=e[c+1];if(e[c+1]=e[c],e[c]=l,!c||(i=Di(e[--c]),i<=a))break}i=Di(e[o])}}return e}function $0(r){let e=[],t=[],n=-1,s=0;for(let i of r){let o=Di(i),a=Qd(i);if(n==-1)o==0?n=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(n,...t),t.length=0,n=a):t.push(a),s=o;else{let c=Z0(n,a);c>=0?n=c:s==0&&o==0?(e.push(n),n=a):(t.push(a),s=o)}}return n>=0&&e.push(n,...t),e}function qd(r){return Jd(r).map(Qd)}function Y0(r){return $0(Jd(r))}const ju=45,Zd=".",$d=65039,Yd=1,Aa=r=>Array.from(r);function Yi(r,e){return r.P.has(e)||r.Q.has(e)}class X0 extends Array{get is_emoji(){return!0}}let al,Xd,fr,cl,ef,Is,kc,us,sr,Wu,ll;function Dl(){if(al)return;let r=Fd(O0);const e=()=>qi(r),t=()=>new Set(e()),n=(h,d)=>d.forEach(f=>h.add(f));al=new Map(Gd(r)),Xd=t(),fr=e(),cl=new Set(e().map(h=>fr[h])),fr=new Set(fr),ef=t(),t();let s=Hd(r),i=r();const o=()=>{let h=new Set;return e().forEach(d=>n(h,s[d])),n(h,e()),h};Is=Zi(h=>{let d=Zi(r).map(f=>f+96);if(d.length){let f=h>=i;d[0]-=32,d=Ii(d),f&&(d=`Restricted[${d}]`);let g=o(),w=o(),m=!r();return{N:d,P:g,Q:w,M:m,R:f}}}),kc=t(),us=new Map;let a=e().concat(Aa(kc)).sort((h,d)=>h-d);a.forEach((h,d)=>{let f=r(),g=a[d]=f?a[d-f]:{V:[],M:new Map};g.V.push(h),kc.has(h)||us.set(h,g)});for(let{V:h,M:d}of new Set(us.values())){let f=[];for(let w of h){let m=Is.filter(v=>Yi(v,w)),C=f.find(({G:v})=>m.some(k=>v.has(k)));C||(C={G:new Set,V:[]},f.push(C)),C.V.push(w),n(C.G,m)}let g=f.flatMap(w=>Aa(w.G));for(let{G:w,V:m}of f){let C=new Set(g.filter(v=>!w.has(v)));for(let v of m)d.set(v,C)}}sr=new Set;let c=new Set;const l=h=>sr.has(h)?c.add(h):sr.add(h);for(let h of Is){for(let d of h.P)l(d);for(let d of h.Q)l(d)}for(let h of sr)!us.has(h)&&!c.has(h)&&us.set(h,Yd);n(sr,qd(sr)),Wu=F0(r).map(h=>X0.from(h)).sort(K0),ll=new Map;for(let h of Wu){let d=[ll];for(let f of h){let g=d.map(w=>{let m=w.get(f);return m||(m=new Map,w.set(f,m)),m});f===$d?d.push(...g):d=g}for(let f of d)f.V=h}}function Fl(r){return(tf(r)?"":`${Hl(ja([r]))} `)+jd(r)}function Hl(r){return`"${r}"‎`}function em(r){if(r.length>=4&&r[2]==ju&&r[3]==ju)throw new Error(`invalid label extension: "${Ii(r.slice(0,4))}"`)}function tm(r){for(let t=r.lastIndexOf(95);t>0;)if(r[--t]!==95)throw new Error("underscore allowed only at start")}function nm(r){let e=r[0],t=Hu.get(e);if(t)throw ji(`leading ${t}`);let n=r.length,s=-1;for(let i=1;i<n;i++){e=r[i];let o=Hu.get(e);if(o){if(s==i)throw ji(`${t} + ${o}`);s=i+1,t=o}}if(s==n)throw ji(`trailing ${t}`)}function ja(r,e=1/0,t=jd){let n=[];rm(r[0])&&n.push("◌"),r.length>e&&(e>>=1,r=[...r.slice(0,e),8230,...r.slice(-e)]);let s=0,i=r.length;for(let o=0;o<i;o++){let a=r[o];tf(a)&&(n.push(Ii(r.slice(s,o))),n.push(t(a)),s=o+1)}return n.push(Ii(r.slice(s,i))),n.join("")}function rm(r){return Dl(),fr.has(r)}function tf(r){return Dl(),ef.has(r)}function sm(r){return cm(im(r,Y0,hm))}function im(r,e,t){if(!r)return[];Dl();let n=0;return r.split(Zd).map(s=>{let i=G0(s),o={input:i,offset:n};n+=i.length+1;try{let a=o.tokens=um(i,e,t),c=a.length,l;if(!c)throw new Error("empty label");let h=o.output=a.flat();if(tm(h),!(o.emoji=c>1||a[0].is_emoji)&&h.every(f=>f<128))em(h),l="ASCII";else{let f=a.flatMap(g=>g.is_emoji?[]:g);if(!f.length)l="Emoji";else{if(fr.has(h[0]))throw ji("leading combining mark");for(let m=1;m<c;m++){let C=a[m];if(!C.is_emoji&&fr.has(C[0]))throw ji(`emoji + combining mark: "${Ii(a[m-1])} + ${ja([C[0]])}"`)}nm(h);let g=Aa(new Set(f)),[w]=am(g);lm(w,f),om(w,g),l=w.N}}o.type=l}catch(a){o.error=a}return o})}function om(r,e){let t,n=[];for(let s of e){let i=us.get(s);if(i===Yd)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):Aa(o),!t.length)return}else n.push(s)}if(t){for(let s of t)if(n.every(i=>Yi(s,i)))throw new Error(`whole-script confusable: ${r.N}/${s.N}`)}}function am(r){let e=Is;for(let t of r){let n=e.filter(s=>Yi(s,t));if(!n.length)throw Is.some(s=>Yi(s,t))?rf(e[0],t):nf(t);if(e=n,n.length==1)break}return e}function cm(r){return r.map(({input:e,error:t,output:n})=>{if(t){let s=t.message;throw new Error(r.length==1?s:`Invalid label ${Hl(ja(e,63))}: ${s}`)}return Ii(n)}).join(Zd)}function nf(r){return new Error(`disallowed character: ${Fl(r)}`)}function rf(r,e){let t=Fl(e),n=Is.find(s=>s.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${r.N} + ${t}`)}function ji(r){return new Error(`illegal placement: ${r}`)}function lm(r,e){for(let t of e)if(!Yi(r,t))throw rf(r,t);if(r.M){let t=qd(e);for(let n=1,s=t.length;n<s;n++)if(cl.has(t[n])){let i=n+1;for(let o;i<s&&cl.has(o=t[i]);i++)for(let a=n;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${Fl(o)}`);if(i-n>Gu)throw new Error(`excessive non-spacing marks: ${Hl(ja(t.slice(n-1,i)))} (${i-n}/${Gu})`);n=i}}}function um(r,e,t){let n=[],s=[];for(r=r.slice().reverse();r.length;){let i=dm(r);if(i)s.length&&(n.push(e(s)),s=[]),n.push(t(i));else{let o=r.pop();if(sr.has(o))s.push(o);else{let a=al.get(o);if(a)s.push(...a);else if(!Xd.has(o))throw nf(o)}}}return s.length&&n.push(e(s)),n}function hm(r){return r.filter(e=>e!=$d)}function dm(r,e){let t=ll,n,s=r.length;for(;s&&(t=t.get(r[--s]),!!t);){let{V:i}=t;i&&(n=i,r.length=s)}return n}const sf=new Uint8Array(32);sf.fill(0);function Vu(r){return y(r.length!==0,"invalid ENS name; empty component","comp",r),r}function of(r){const e=jt(fm(r)),t=[];if(r.length===0)return t;let n=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(Vu(e.slice(n,s))),n=s+1);return y(n<e.length,"invalid ENS name; empty component","name",r),t.push(Vu(e.slice(n))),t}function fm(r){try{if(r.length===0)throw new Error("empty label");return sm(r)}catch(e){y(!1,`invalid ENS name (${e.message})`,"name",r)}}function ul(r){y(typeof r=="string","invalid ENS name; not a string","name",r),y(r.length,"invalid ENS name (empty label)","name",r);let e=sf;const t=of(r);for(;t.length;)e=ue(le([e,ue(t.pop())]));return T(e)}function pm(r,e){const t=e;return y(t<=255,"DNS encoded label cannot exceed 255","length",t),T(le(of(r).map(n=>{y(n.length<=t,`label ${JSON.stringify(r)} exceeds ${t} bytes`,"name",r);const s=new Uint8Array(n.length+1);return s.set(n,1),s[0]=s.length-1,s})))+"00"}function xc(r,e){return{address:$(r),storageKeys:e.map((t,n)=>(y(X(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function qr(r){if(Array.isArray(r))return r.map((t,n)=>Array.isArray(t)?(y(t.length===2,"invalid slot set",`value[${n}]`,t),xc(t[0],t[1])):(y(t!=null&&typeof t=="object","invalid address-slot set","value",r),xc(t.address,t.storageKeys)));y(r!=null&&typeof r=="object","invalid access list","value",r);const e=Object.keys(r).map(t=>{const n=r[t].reduce((s,i)=>(s[i]=!0,s),{});return xc(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function gm(r){let e;return typeof r=="string"?e=Ji.computePublicKey(r,!1):e=r.publicKey,$(ue("0x"+e.substring(4)).substring(26))}function mm(r,e){return gm(Ji.recoverPublicKey(r,e))}const me=BigInt(0),ym=BigInt(2),wm=BigInt(27),bm=BigInt(28),Am=BigInt(35),Em=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Pc=4096*32;function Qu(r,e){let t=r.toString(16);for(;t.length<2;)t="0"+t;return t+=Pi(e).substring(4),"0x"+t}function Wa(r){return r==="0x"?null:$(r)}function Gl(r,e){try{return qr(r)}catch(t){y(!1,t.message,e,r)}}function Ro(r,e){return r==="0x"?0:H(r,e)}function ce(r,e){if(r==="0x")return me;const t=_(r,e);return y(t<=Em,"value exceeds uint size",e,t),t}function te(r,e){const t=_(r,"value"),n=Le(t);return y(n.length<=32,"value too large",`tx.${e}`,t),n}function Kl(r){return qr(r).map(e=>[e.address,e.storageKeys])}function Cm(r,e){y(Array.isArray(r),`invalid ${e}`,"value",r);for(let t=0;t<r.length;t++)y(X(r[t],32),"invalid ${ param } hash",`value[${t}]`,r[t]);return r}function vm(r){const e=Fa(r);y(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",r);const t={type:0,nonce:Ro(e[0],"nonce"),gasPrice:ce(e[1],"gasPrice"),gasLimit:ce(e[2],"gasLimit"),to:Wa(e[3]),value:ce(e[4],"value"),data:T(e[5]),chainId:me};if(e.length===6)return t;const n=ce(e[6],"v"),s=ce(e[7],"r"),i=ce(e[8],"s");if(s===me&&i===me)t.chainId=n;else{let o=(n-Am)/ym;o<me&&(o=me),t.chainId=o,y(o!==me||n===wm||n===bm,"non-canonical legacy v","v",e[6]),t.signature=It.from({r:Kr(e[7],32),s:Kr(e[8],32),v:n})}return t}function Im(r,e){const t=[te(r.nonce,"nonce"),te(r.gasPrice||0,"gasPrice"),te(r.gasLimit,"gasLimit"),r.to||"0x",te(r.value,"value"),r.data];let n=me;if(r.chainId!=me)n=_(r.chainId,"tx.chainId"),y(!e||e.networkV==null||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(r.signature){const i=r.signature.legacyChainId;i!=null&&(n=i)}if(!e)return n!==me&&(t.push(Le(n)),t.push("0x"),t.push("0x")),jr(t);let s=BigInt(27+e.yParity);return n!==me?s=It.getChainIdV(n,e.v):BigInt(e.v)!==s&&y(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(Le(s)),t.push(Le(e.r)),t.push(Le(e.s)),jr(t)}function jl(r,e){let t;try{if(t=Ro(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{y(!1,"invalid yParity","yParity",e[0])}const n=Kr(e[1],32),s=Kr(e[2],32),i=It.from({r:n,s,yParity:t});r.signature=i}function Nm(r){const e=Fa(V(r).slice(1));y(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",T(r));const t={type:2,chainId:ce(e[0],"chainId"),nonce:Ro(e[1],"nonce"),maxPriorityFeePerGas:ce(e[2],"maxPriorityFeePerGas"),maxFeePerGas:ce(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:ce(e[4],"gasLimit"),to:Wa(e[5]),value:ce(e[6],"value"),data:T(e[7]),accessList:Gl(e[8],"accessList")};return e.length===9||jl(t,e.slice(9)),t}function Sm(r,e){const t=[te(r.chainId,"chainId"),te(r.nonce,"nonce"),te(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),te(r.maxFeePerGas||0,"maxFeePerGas"),te(r.gasLimit,"gasLimit"),r.to||"0x",te(r.value,"value"),r.data,Kl(r.accessList||[])];return e&&(t.push(te(e.yParity,"yParity")),t.push(Le(e.r)),t.push(Le(e.s))),le(["0x02",jr(t)])}function km(r){const e=Fa(V(r).slice(1));y(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",T(r));const t={type:1,chainId:ce(e[0],"chainId"),nonce:Ro(e[1],"nonce"),gasPrice:ce(e[2],"gasPrice"),gasLimit:ce(e[3],"gasLimit"),to:Wa(e[4]),value:ce(e[5],"value"),data:T(e[6]),accessList:Gl(e[7],"accessList")};return e.length===8||jl(t,e.slice(8)),t}function xm(r,e){const t=[te(r.chainId,"chainId"),te(r.nonce,"nonce"),te(r.gasPrice||0,"gasPrice"),te(r.gasLimit,"gasLimit"),r.to||"0x",te(r.value,"value"),r.data,Kl(r.accessList||[])];return e&&(t.push(te(e.yParity,"recoveryParam")),t.push(Le(e.r)),t.push(Le(e.s))),le(["0x01",jr(t)])}function Pm(r){let e=Fa(V(r).slice(1)),t="3",n=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];y(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),y(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),y(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),y(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),y(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let c=0;c<e[1].length;c++)n.push({data:i[c],commitment:o[c],proof:a[c]});e=e[0]}y(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",T(r));const s={type:3,chainId:ce(e[0],"chainId"),nonce:Ro(e[1],"nonce"),maxPriorityFeePerGas:ce(e[2],"maxPriorityFeePerGas"),maxFeePerGas:ce(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:ce(e[4],"gasLimit"),to:Wa(e[5]),value:ce(e[6],"value"),data:T(e[7]),accessList:Gl(e[8],"accessList"),maxFeePerBlobGas:ce(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(s.blobs=n),y(s.to!=null,`invalid address for transaction type: ${t}`,"data",r),y(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",r);for(let i=0;i<s.blobVersionedHashes.length;i++)y(X(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",r);return e.length===11||jl(s,e.slice(11)),s}function Rm(r,e,t){const n=[te(r.chainId,"chainId"),te(r.nonce,"nonce"),te(r.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),te(r.maxFeePerGas||0,"maxFeePerGas"),te(r.gasLimit,"gasLimit"),r.to||zi,te(r.value,"value"),r.data,Kl(r.accessList||[]),te(r.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Cm(r.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(te(e.yParity,"yParity")),n.push(Le(e.r)),n.push(Le(e.s)),t)?le(["0x03",jr([n,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):le(["0x03",jr(n)])}var Tt,Hs,Gs,Ks,js,Ws,Vs,Qs,zs,Js,qs,Zs,Sr,Ln,cn,Un,$s,ra;const Xt=class Xt{constructor(){A(this,$s);A(this,Tt,void 0);A(this,Hs,void 0);A(this,Gs,void 0);A(this,Ks,void 0);A(this,js,void 0);A(this,Ws,void 0);A(this,Vs,void 0);A(this,Qs,void 0);A(this,zs,void 0);A(this,Js,void 0);A(this,qs,void 0);A(this,Zs,void 0);A(this,Sr,void 0);A(this,Ln,void 0);A(this,cn,void 0);A(this,Un,void 0);p(this,Tt,null),p(this,Hs,null),p(this,Ks,0),p(this,js,me),p(this,Ws,null),p(this,Vs,null),p(this,Qs,null),p(this,Gs,"0x"),p(this,zs,me),p(this,Js,me),p(this,qs,null),p(this,Zs,null),p(this,Sr,null),p(this,Ln,null),p(this,Un,null),p(this,cn,null)}get type(){return u(this,Tt)}set type(e){switch(e){case null:p(this,Tt,null);break;case 0:case"legacy":p(this,Tt,0);break;case 1:case"berlin":case"eip-2930":p(this,Tt,1);break;case 2:case"london":case"eip-1559":p(this,Tt,2);break;case 3:case"cancun":case"eip-4844":p(this,Tt,3);break;default:y(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=u(this,Hs);return e==null&&this.type===3?zi:e}set to(e){p(this,Hs,e==null?null:$(e))}get nonce(){return u(this,Ks)}set nonce(e){p(this,Ks,H(e,"value"))}get gasLimit(){return u(this,js)}set gasLimit(e){p(this,js,_(e))}get gasPrice(){const e=u(this,Ws);return e==null&&(this.type===0||this.type===1)?me:e}set gasPrice(e){p(this,Ws,e==null?null:_(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=u(this,Vs);return e??(this.type===2||this.type===3?me:null)}set maxPriorityFeePerGas(e){p(this,Vs,e==null?null:_(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=u(this,Qs);return e??(this.type===2||this.type===3?me:null)}set maxFeePerGas(e){p(this,Qs,e==null?null:_(e,"maxFeePerGas"))}get data(){return u(this,Gs)}set data(e){p(this,Gs,T(e))}get value(){return u(this,zs)}set value(e){p(this,zs,_(e,"value"))}get chainId(){return u(this,Js)}set chainId(e){p(this,Js,_(e))}get signature(){return u(this,qs)||null}set signature(e){p(this,qs,e==null?null:It.from(e))}get accessList(){const e=u(this,Zs)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){p(this,Zs,e==null?null:qr(e))}get maxFeePerBlobGas(){const e=u(this,Sr);return e==null&&this.type===3?me:e}set maxFeePerBlobGas(e){p(this,Sr,e==null?null:_(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=u(this,Ln);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){y(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)y(X(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}p(this,Ln,e)}get blobs(){return u(this,Un)==null?null:u(this,Un).map(e=>Object.assign({},e))}set blobs(e){if(e==null){p(this,Un,null);return}const t=[],n=[];for(let s=0;s<e.length;s++){const i=e[s];if(xl(i)){I(u(this,cn),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=V(i);if(y(o.length<=Pc,"blob is too large",`blobs[${s}]`,i),o.length!==Pc){const l=new Uint8Array(Pc);l.set(o),o=l}const a=u(this,cn).blobToKzgCommitment(o),c=T(u(this,cn).computeBlobKzgProof(o,a));t.push({data:T(o),commitment:T(a),proof:c}),n.push(Qu(1,a))}else{const o=T(i.commitment);t.push({data:T(i.data),commitment:o,proof:T(i.proof)}),n.push(Qu(1,o))}}p(this,Un,t),p(this,Ln,n)}get kzg(){return u(this,cn)}set kzg(e){p(this,cn,e)}get hash(){return this.signature==null?null:ue(N(this,$s,ra).call(this,!0,!1))}get unsignedHash(){return ue(this.unsignedSerialized)}get from(){return this.signature==null?null:mm(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:Ji.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return N(this,$s,ra).call(this,!0,!0)}get unsignedSerialized(){return N(this,$s,ra).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,s=u(this,Sr)!=null||u(this,Ln);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&I(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),I(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),I(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Xt.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Xt;if(typeof e=="string"){const n=V(e);if(n[0]>=127)return Xt.from(vm(n));switch(n[0]){case 1:return Xt.from(km(n));case 2:return Xt.from(Nm(n));case 3:return Xt.from(Pm(n))}I(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Xt;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=It.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(y(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),y(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(y(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),y(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Tt=new WeakMap,Hs=new WeakMap,Gs=new WeakMap,Ks=new WeakMap,js=new WeakMap,Ws=new WeakMap,Vs=new WeakMap,Qs=new WeakMap,zs=new WeakMap,Js=new WeakMap,qs=new WeakMap,Zs=new WeakMap,Sr=new WeakMap,Ln=new WeakMap,cn=new WeakMap,Un=new WeakMap,$s=new WeakSet,ra=function(e,t){I(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=e?this.signature:null;switch(this.inferType()){case 0:return Im(this,n);case 1:return xm(this,n);case 2:return Sm(this,n);case 3:return Rm(this,n,t?this.blobs:null)}I(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Ea=Xt;const af=new Uint8Array(32);af.fill(0);const Om=BigInt(-1),cf=BigInt(0),lf=BigInt(1),Tm=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function Bm(r){const e=V(r),t=e.length%32;return t?le([e,af.slice(t)]):T(e)}const _m=Xn(lf,32),Lm=Xn(cf,32),zu={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Rc=["name","version","chainId","verifyingContract","salt"];function Ju(r){return function(e){return y(typeof e=="string",`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,e),e}}const Um={name:Ju("name"),version:Ju("version"),chainId:function(r){const e=_(r,"domain.chainId");return y(e>=0,"invalid chain ID","domain.chainId",r),Number.isSafeInteger(e)?Number(e):gs(e)},verifyingContract:function(r){try{return $(r).toLowerCase()}catch{}y(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",r)},salt:function(r){const e=V(r,"domain.salt");return y(e.length===32,'invalid domain value "salt"',"domain.salt",r),T(e)}};function Oc(r){{const e=r.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",n=parseInt(e[2]);y(n%8===0&&n!==0&&n<=256&&e[2]===String(n),"invalid numeric width","type",r);const s=hr(Tm,t?n-1:n),i=t?(s+lf)*Om:cf;return function(o){const a=_(o,"value");return y(a>=i&&a<=s,`value out-of-bounds for ${r}`,"value",a),Xn(t?zh(a,256):a,32)}}}{const e=r.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return y(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",r),function(n){const s=V(n);return y(s.length===t,`invalid length for ${r}`,"value",n),Bm(n)}}}switch(r){case"address":return function(e){return Kr($(e),32)};case"bool":return function(e){return e?_m:Lm};case"bytes":return function(e){return ue(e)};case"string":return function(e){return Wr(e)}}return null}function qu(r,e){return`${r}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function Vo(r){const e=r.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:r}}var ho,ln,Ys,Ra,uf;const tt=class tt{constructor(e){A(this,Ra);E(this,"primaryType");A(this,ho,void 0);A(this,ln,void 0);A(this,Ys,void 0);p(this,ln,new Map),p(this,Ys,new Map);const t=new Map,n=new Map,s=new Map,i={};Object.keys(e).forEach(c=>{i[c]=e[c].map(({name:l,type:h})=>{let{base:d,index:f}=Vo(h);return d==="int"&&!e.int&&(d="int256"),d==="uint"&&!e.uint&&(d="uint256"),{name:l,type:d+(f||"")}}),t.set(c,new Set),n.set(c,[]),s.set(c,new Set)}),p(this,ho,JSON.stringify(i));for(const c in i){const l=new Set;for(const h of i[c]){y(!l.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(c)}`,"types",e),l.add(h.name);const d=Vo(h.type).base;y(d!==c,`circular type reference to ${JSON.stringify(d)}`,"types",e),!Oc(d)&&(y(n.has(d),`unknown type ${JSON.stringify(d)}`,"types",e),n.get(d).push(c),t.get(c).add(d))}}const o=Array.from(n.keys()).filter(c=>n.get(c).length===0);y(o.length!==0,"missing primary type","types",e),y(o.length===1,`ambiguous primary types or unused types: ${o.map(c=>JSON.stringify(c)).join(", ")}`,"types",e),F(this,{primaryType:o[0]});function a(c,l){y(!l.has(c),`circular type reference to ${JSON.stringify(c)}`,"types",e),l.add(c);for(const h of t.get(c))if(n.has(h)){a(h,l);for(const d of l)s.get(d).add(h)}l.delete(c)}a(this.primaryType,new Set);for(const[c,l]of s){const h=Array.from(l);h.sort(),u(this,ln).set(c,qu(c,i[c])+h.map(d=>qu(d,i[d])).join(""))}}get types(){return JSON.parse(u(this,ho))}getEncoder(e){let t=u(this,Ys).get(e);return t||(t=N(this,Ra,uf).call(this,e),u(this,Ys).set(e,t)),t}encodeType(e){const t=u(this,ln).get(e);return y(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return ue(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(Oc(e))return n(e,t);const s=Vo(e).array;if(s)return y(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,n));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:c})=>(o[a]=this._visit(c,t[a],n),o),{});y(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new tt(e)}static getPrimaryType(e){return tt.from(e).primaryType}static hashStruct(e,t,n){return tt.from(t).hashStruct(e,n)}static hashDomain(e){const t=[];for(const n in e){if(e[n]==null)continue;const s=zu[n];y(s,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:s})}return t.sort((n,s)=>Rc.indexOf(n.name)-Rc.indexOf(s.name)),tt.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return le(["0x1901",tt.hashDomain(e),tt.from(t).hash(n)])}static hash(e,t,n){return ue(tt.encode(e,t,n))}static async resolveNames(e,t,n,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!X(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=tt.from(t);o.visit(n,(a,c)=>(a==="address"&&!X(c,20)&&(i[c]="0x"),c));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),n=o.visit(n,(a,c)=>a==="address"&&i[c]?i[c]:c),{domain:e,value:n}}static getPayload(e,t,n){tt.hashDomain(e);const s={},i=[];Rc.forEach(c=>{const l=e[c];l!=null&&(s[c]=Um[c](l),i.push({name:c,type:zu[c]}))});const o=tt.from(t);t=o.types;const a=Object.assign({},t);return y(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(n),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(n,(c,l)=>{if(c.match(/^bytes(\d*)/))return T(V(l));if(c.match(/^u?int/))return _(l).toString();switch(c){case"address":return l.toLowerCase();case"bool":return!!l;case"string":return y(typeof l=="string","invalid string","value",l),l}y(!1,"unsupported type","type",c)})}}};ho=new WeakMap,ln=new WeakMap,Ys=new WeakMap,Ra=new WeakSet,uf=function(e){{const s=Oc(e);if(s)return s}const t=Vo(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{y(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return u(this,ln).has(s)&&(a=a.map(ue)),ue(le(a))}}const n=this.types[e];if(n){const s=Wr(u(this,ln).get(e));return i=>{const o=n.map(({name:a,type:c})=>{const l=this.getEncoder(c)(i[a]);return u(this,ln).has(c)?ue(l):l});return o.unshift(s),le(o)}}y(!1,`unknown type: ${e}`,"type",e)};let Ca=tt;function De(r){const e=new Set;return r.forEach(t=>e.add(t)),Object.freeze(e)}const Mm="external public payable override",Dm=De(Mm.split(" ")),hf="constant external internal payable private public pure view override",Fm=De(hf.split(" ")),df="constructor error event fallback function receive struct",ff=De(df.split(" ")),pf="calldata memory storage payable indexed",Hm=De(pf.split(" ")),Gm="tuple returns",Km=[df,pf,Gm,hf].join(" "),jm=De(Km.split(" ")),Wm={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Vm=new RegExp("^(\\s*)"),Qm=new RegExp("^([0-9]+)"),zm=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),gf=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),mf=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var Ae,bt,fo,hl;const Oa=class Oa{constructor(e){A(this,fo);A(this,Ae,void 0);A(this,bt,void 0);p(this,Ae,0),p(this,bt,e.slice())}get offset(){return u(this,Ae)}get length(){return u(this,bt).length-u(this,Ae)}clone(){return new Oa(u(this,bt))}reset(){p(this,Ae,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=N(this,fo,hl).call(this,u(this,Ae)+1,e.match+1);return p(this,Ae,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;u(this,Ae)<e.match-1;){const n=this.peek().linkNext;t.push(N(this,fo,hl).call(this,u(this,Ae)+1,n)),p(this,Ae,n)}return p(this,Ae,e.match+1),t}peek(){if(u(this,Ae)>=u(this,bt).length)throw new Error("out-of-bounds");return u(this,bt)[u(this,Ae)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Ti(this,Ae)._++,e}toString(){const e=[];for(let t=u(this,Ae);t<u(this,bt).length;t++){const n=u(this,bt)[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}};Ae=new WeakMap,bt=new WeakMap,fo=new WeakSet,hl=function(e=0,t=0){return new Oa(u(this,bt).slice(e,t).map(n=>Object.freeze(Object.assign({},n,{match:n.match-e,linkBack:n.linkBack-e,linkNext:n.linkNext-e}))))};let Nt=Oa;function er(r){const e=[],t=o=>{const a=i<r.length?JSON.stringify(r[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let n=[],s=[],i=0;for(;i<r.length;){let o=r.substring(i),a=o.match(Vm);a&&(i+=a[1].length,o=r.substring(i));const c={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(c);let l=Wm[o[0]]||"";if(l){if(c.type=l,c.text=o[0],i++,l==="OPEN_PAREN")n.push(e.length-1),s.push(e.length-1);else if(l=="CLOSE_PAREN")n.length===0&&t("no matching open bracket"),c.match=n.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(l==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(l==="OPEN_BRACKET")c.type="BRACKET";else if(l==="CLOSE_BRACKET"){let h=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const d=e.pop().text;h=d+h,e[e.length-1].value=H(d)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=h}continue}if(a=o.match(zm),a){if(c.text=a[1],i+=c.text.length,jm.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(mf)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(Qm),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new Nt(e.map(o=>Object.freeze(o)))}function Zu(r,e){let t=[];for(const n in e.keys())r.has(n)&&t.push(n);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function Va(r,e){if(e.peekKeyword(ff)){const t=e.pop().text;if(t!==r)throw new Error(`expected ${r}, got ${t}`)}return e.popType("ID")}function bn(r,e){const t=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||e&&!e.has(n))break;if(r.pop(),t.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);t.add(n)}return Object.freeze(t)}function yf(r){let e=bn(r,Fm);return Zu(e,De("constant payable nonpayable".split(" "))),Zu(e,De("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function wn(r,e){return r.popParams().map(t=>Ce.from(t,e))}function wf(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return _(r.pop().text);throw new Error("invalid gas")}return null}function Vr(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const Jm=new RegExp(/^(.*)\[([0-9]*)\]$/);function $u(r){const e=r.match(mf);if(y(e,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(e[2]){const t=parseInt(e[2]);y(t!==0&&t<=32,"invalid bytes length","type",r)}else if(e[3]){const t=parseInt(e[3]);y(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",r)}return r}const re={},je=Symbol.for("_ethers_internal"),Yu="_ParamTypeInternal",Xu="_ErrorInternal",eh="_EventInternal",th="_ConstructorInternal",nh="_FallbackInternal",rh="_FunctionInternal",sh="_StructInternal";var Xs,sa;const nt=class nt{constructor(e,t,n,s,i,o,a,c){A(this,Xs);E(this,"name");E(this,"type");E(this,"baseType");E(this,"indexed");E(this,"components");E(this,"arrayLength");E(this,"arrayChildren");if(xo(e,re,"ParamType"),Object.defineProperty(this,je,{value:Yu}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");F(this,{name:t,type:n,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){const n=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=n,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(n=>n.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return e.map(s=>n.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map((s,i)=>n.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const n=[],s=[e];return N(this,Xs,sa).call(this,n,e,t,i=>{s[0]=i}),n.length&&await Promise.all(n),s[0]}static from(e,t){if(nt.isParamType(e))return e;if(typeof e=="string")try{return nt.from(er(e),t)}catch{y(!1,"invalid param type","obj",e)}else if(e instanceof Nt){let a="",c="",l=null;bn(e,De(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",l=e.popParams().map(m=>nt.from(m)),a=`tuple(${l.map(m=>m.format()).join(",")})`):(a=$u(e.popType("TYPE")),c=a);let h=null,d=null;for(;e.length&&e.peekType("BRACKET");){const m=e.pop();h=new nt(re,"",a,c,null,l,d,h),d=m.value,a+=m.text,c="array",l=null}let f=null;if(bn(e,Hm).has("indexed")){if(!t)throw new Error("");f=!0}const w=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new nt(re,w,a,c,f,l,d,h)}const n=e.name;y(!n||typeof n=="string"&&n.match(gf),"invalid name","obj.name",n);let s=e.indexed;s!=null&&(y(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(Jm);if(o){const a=parseInt(o[2]||"-1"),c=nt.from({type:o[1],components:e.components});return new nt(re,n||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(l=>nt.from(l)):null;return new nt(re,n||"",i,"tuple",s,a,null,null)}return i=$u(e.type),new nt(re,n||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[je]===Yu}};Xs=new WeakSet,sa=function(e,t,n,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((c,l)=>{var h;N(h=o,Xs,sa).call(h,e,c,n,d=>{a[l]=d})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,l)=>{var h;N(h=o[l],Xs,sa).call(h,e,c,n,d=>{a[l]=d})}),s(a);return}const i=n(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let Ce=nt;class Qr{constructor(e,t,n){E(this,"type");E(this,"inputs");xo(e,re,"Fragment"),n=Object.freeze(n.slice()),F(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{Qr.from(JSON.parse(e))}catch{}return Qr.from(er(e))}if(e instanceof Nt)switch(e.peekKeyword(ff)){case"constructor":return yn.from(e);case"error":return Ke.from(e);case"event":return Ht.from(e);case"fallback":case"receive":return en.from(e);case"function":return Gt.from(e);case"struct":return Gr.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return yn.from(e);case"error":return Ke.from(e);case"event":return Ht.from(e);case"fallback":case"receive":return en.from(e);case"function":return Gt.from(e);case"struct":return Gr.from(e)}I(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}y(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return yn.isFragment(e)}static isError(e){return Ke.isFragment(e)}static isEvent(e){return Ht.isFragment(e)}static isFunction(e){return Gt.isFragment(e)}static isStruct(e){return Gr.isFragment(e)}}class Qa extends Qr{constructor(t,n,s,i){super(t,n,i);E(this,"name");y(typeof s=="string"&&s.match(gf),"invalid identifier","name",s),i=Object.freeze(i.slice()),F(this,{name:s})}}function Xi(r,e){return"("+e.map(t=>t.format(r)).join(r==="full"?", ":",")+")"}class Ke extends Qa{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,je,{value:Xu})}get selector(){return Wr(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Xi(e,this.inputs)),t.join(" ")}static from(e){if(Ke.isFragment(e))return e;if(typeof e=="string")return Ke.from(er(e));if(e instanceof Nt){const t=Va("error",e),n=wn(e);return Vr(e),new Ke(re,t,n)}return new Ke(re,e.name,e.inputs?e.inputs.map(Ce.from):[])}static isFragment(e){return e&&e[je]===Xu}}class Ht extends Qa{constructor(t,n,s,i){super(t,"event",n,s);E(this,"anonymous");Object.defineProperty(this,je,{value:eh}),F(this,{anonymous:i})}get topicHash(){return Wr(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const n=[];return t!=="sighash"&&n.push("event"),n.push(this.name+Xi(t,this.inputs)),t!=="sighash"&&this.anonymous&&n.push("anonymous"),n.join(" ")}static getTopicHash(t,n){return n=(n||[]).map(i=>Ce.from(i)),new Ht(re,t,n,!1).topicHash}static from(t){if(Ht.isFragment(t))return t;if(typeof t=="string")try{return Ht.from(er(t))}catch{y(!1,"invalid event fragment","obj",t)}else if(t instanceof Nt){const n=Va("event",t),s=wn(t,!0),i=!!bn(t,De(["anonymous"])).has("anonymous");return Vr(t),new Ht(re,n,s,i)}return new Ht(re,t.name,t.inputs?t.inputs.map(n=>Ce.from(n,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[je]===eh}}class yn extends Qr{constructor(t,n,s,i,o){super(t,n,s);E(this,"payable");E(this,"gas");Object.defineProperty(this,je,{value:th}),F(this,{payable:i,gas:o})}format(t){if(I(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const n=[`constructor${Xi(t,this.inputs)}`];return this.payable&&n.push("payable"),this.gas!=null&&n.push(`@${this.gas.toString()}`),n.join(" ")}static from(t){if(yn.isFragment(t))return t;if(typeof t=="string")try{return yn.from(er(t))}catch{y(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Nt){bn(t,De(["constructor"]));const n=wn(t),s=!!bn(t,Dm).has("payable"),i=wf(t);return Vr(t),new yn(re,"constructor",n,s,i)}return new yn(re,"constructor",t.inputs?t.inputs.map(Ce.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[je]===th}}class en extends Qr{constructor(t,n,s){super(t,"fallback",n);E(this,"payable");Object.defineProperty(this,je,{value:nh}),F(this,{payable:s})}format(t){const n=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:n,stateMutability:s})}return`${n}()${this.payable?" payable":""}`}static from(t){if(en.isFragment(t))return t;if(typeof t=="string")try{return en.from(er(t))}catch{y(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Nt){const n=t.toString(),s=t.peekKeyword(De(["fallback","receive"]));if(y(s,"type must be fallback or receive","obj",n),t.popKeyword(De(["fallback","receive"]))==="receive"){const c=wn(t);return y(c.length===0,"receive cannot have arguments","obj.inputs",c),bn(t,De(["payable"])),Vr(t),new en(re,[],!0)}let o=wn(t);o.length?y(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[Ce.from("bytes")];const a=yf(t);if(y(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),bn(t,De(["returns"])).has("returns")){const c=wn(t);y(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(l=>l.format("minimal")).join(", "))}return Vr(t),new en(re,o,a==="payable")}if(t.type==="receive")return new en(re,[],!0);if(t.type==="fallback"){const n=[Ce.from("bytes")],s=t.stateMutability==="payable";return new en(re,n,s)}y(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[je]===nh}}class Gt extends Qa{constructor(t,n,s,i,o,a){super(t,"function",n,i);E(this,"constant");E(this,"outputs");E(this,"stateMutability");E(this,"payable");E(this,"gas");Object.defineProperty(this,je,{value:rh}),o=Object.freeze(o.slice()),F(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return Wr(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const n=[];return t!=="sighash"&&n.push("function"),n.push(this.name+Xi(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(Xi(t,this.outputs))),this.gas!=null&&n.push(`@${this.gas.toString()}`)),n.join(" ")}static getSelector(t,n){return n=(n||[]).map(i=>Ce.from(i)),new Gt(re,t,"view",n,[],null).selector}static from(t){if(Gt.isFragment(t))return t;if(typeof t=="string")try{return Gt.from(er(t))}catch{y(!1,"invalid function fragment","obj",t)}else if(t instanceof Nt){const s=Va("function",t),i=wn(t),o=yf(t);let a=[];bn(t,De(["returns"])).has("returns")&&(a=wn(t));const c=wf(t);return Vr(t),new Gt(re,s,o,i,a,c)}let n=t.stateMutability;return n==null&&(n="payable",typeof t.constant=="boolean"?(n="view",t.constant||(n="payable",typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(n="nonpayable")),new Gt(re,t.name,n,t.inputs?t.inputs.map(Ce.from):[],t.outputs?t.outputs.map(Ce.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[je]===rh}}class Gr extends Qa{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,je,{value:sh})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Gr.from(er(e))}catch{y(!1,"invalid struct fragment","obj",e)}else if(e instanceof Nt){const t=Va("struct",e),n=wn(e);return Vr(e),new Gr(re,t,n)}return new Gr(re,e.name,e.inputs?e.inputs.map(Ce.from):[])}static isFragment(e){return e&&e[je]===sh}}const St=new Map;St.set(0,"GENERIC_PANIC");St.set(1,"ASSERT_FALSE");St.set(17,"OVERFLOW");St.set(18,"DIVIDE_BY_ZERO");St.set(33,"ENUM_RANGE_ERROR");St.set(34,"BAD_STORAGE_DATA");St.set(49,"STACK_UNDERFLOW");St.set(50,"ARRAY_RANGE_ERROR");St.set(65,"OUT_OF_MEMORY");St.set(81,"UNINITIALIZED_FUNCTION_CALL");const qm=new RegExp(/^bytes([0-9]*)$/),Zm=new RegExp(/^(u?int)([0-9]*)$/);let Tc=null,ih=1024;function $m(r,e,t,n){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const l=V(t);if(t=T(t),l.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(l.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(T(l.slice(0,4))==="0x08c379a0")try{i=n.decode(["string"],l.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(T(l.slice(0,4))==="0x4e487b71")try{const h=Number(n.decode(["uint256"],l.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[h]},i=`Panic due to ${St.get(h)||"UNKNOWN"}(${h})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?$(e.to):null,data:e.data||"0x"};return e.from&&(c.from=$(e.from)),ne(s,"CALL_EXCEPTION",{action:r,data:t,reason:i,transaction:c,invocation:o,revert:a})}var Mn,hs;const Ta=class Ta{constructor(){A(this,Mn)}getDefaultValue(e){const t=e.map(s=>N(this,Mn,hs).call(this,Ce.from(s)));return new Wo(t,"_").defaultValue()}encode(e,t){Wh(t.length,e.length,"types/values length mismatch");const n=e.map(o=>N(this,Mn,hs).call(this,Ce.from(o))),s=new Wo(n,"_"),i=new $c;return s.encode(i,t),i.data}decode(e,t,n){const s=e.map(o=>N(this,Mn,hs).call(this,Ce.from(o)));return new Wo(s,"_").decode(new Yc(t,n,ih))}static _setDefaultMaxInflation(e){y(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),ih=e}static defaultAbiCoder(){return Tc==null&&(Tc=new Ta),Tc}static getBuiltinCallException(e,t,n){return $m(e,t,n,Ta.defaultAbiCoder())}};Mn=new WeakSet,hs=function(e){if(e.isArray())return new A0(N(this,Mn,hs).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Wo(e.components.map(n=>N(this,Mn,hs).call(this,n)),e.name);switch(e.baseType){case"address":return new w0(e.name);case"bool":return new E0(e.name);case"string":return new R0(e.name);case"bytes":return new C0(e.name);case"":return new N0(e.name)}let t=e.type.match(Zm);if(t){let n=parseInt(t[2]||"256");return y(n!==0&&n<=256&&n%8===0,"invalid "+t[1]+" bit length","param",e),new P0(n/8,t[1]==="int",e.name)}if(t=e.type.match(qm),t){let n=parseInt(t[1]);return y(n!==0&&n<=32,"invalid bytes length","param",e),new v0(n,e.name)}y(!1,"invalid type","type",e.type)};let eo=Ta;class Ym{constructor(e,t,n){E(this,"fragment");E(this,"name");E(this,"signature");E(this,"topic");E(this,"args");const s=e.name,i=e.format();F(this,{fragment:e,name:s,signature:i,topic:t,args:n})}}class Xm{constructor(e,t,n,s){E(this,"fragment");E(this,"name");E(this,"args");E(this,"signature");E(this,"selector");E(this,"value");const i=e.name,o=e.format();F(this,{fragment:e,name:i,args:n,signature:o,selector:t,value:s})}}class ey{constructor(e,t,n){E(this,"fragment");E(this,"name");E(this,"args");E(this,"signature");E(this,"selector");const s=e.name,i=e.format();F(this,{fragment:e,name:s,args:n,signature:i,selector:t})}}class oh{constructor(e){E(this,"hash");E(this,"_isIndexed");F(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const ah={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},ch={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let e="unknown panic code";return r>=0&&r<=255&&ah[r.toString()]&&(e=ah[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${e})`}}};var Bt,_t,Lt,ve,ei,ia,ti,oa;const lr=class lr{constructor(e){A(this,ei);A(this,ti);E(this,"fragments");E(this,"deploy");E(this,"fallback");E(this,"receive");A(this,Bt,void 0);A(this,_t,void 0);A(this,Lt,void 0);A(this,ve,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,p(this,Lt,new Map),p(this,Bt,new Map),p(this,_t,new Map);const n=[];for(const o of t)try{n.push(Qr.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}F(this,{fragments:Object.freeze(n)});let s=null,i=!1;p(this,ve,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}F(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(y(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=u(this,Lt);break;case"event":c=u(this,_t);break;case"error":c=u(this,Bt);break;default:return}const l=o.format();c.has(l)||c.set(l,o)}),this.deploy||F(this,{deploy:yn.from("constructor()")}),F(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return eo.defaultAbiCoder()}getFunctionName(e){const t=N(this,ei,ia).call(this,e,null,!1);return y(t,"no matching function","key",e),t.name}hasFunction(e){return!!N(this,ei,ia).call(this,e,null,!1)}getFunction(e,t){return N(this,ei,ia).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(u(this,Lt).keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(u(this,Lt).get(s),n)}}getEventName(e){const t=N(this,ti,oa).call(this,e,null,!1);return y(t,"no matching event","key",e),t.name}hasEvent(e){return!!N(this,ti,oa).call(this,e,null,!1)}getEvent(e,t){return N(this,ti,oa).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(u(this,_t).keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(u(this,_t).get(s),n)}}getError(e,t){if(X(e)){const s=e.toLowerCase();if(ch[s])return Ke.from(ch[s].signature);for(const i of u(this,Bt).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of u(this,Bt))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Ke.from("error Error(string)"):e==="Panic"?Ke.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");y(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Ke.from(e).format(),e==="Error(string)")return Ke.from("error Error(string)");if(e==="Panic(uint256)")return Ke.from("error Panic(uint256)");const n=u(this,Bt).get(e);return n||null}forEachError(e){const t=Array.from(u(this,Bt).keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(u(this,Bt).get(s),n)}}_decodeParams(e,t){return u(this,ve).decode(e,t)}_encodeParams(e,t){return u(this,ve).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);y(n,"unknown error","fragment",e),e=n}return y(se(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,se(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);y(n,"unknown error","fragment",e),e=n}return le([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);y(n,"unknown function","fragment",e),e=n}return y(se(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,se(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);y(n,"unknown function","fragment",e),e=n}return le([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);y(i,"unknown function","fragment",e),e=i}let n="invalid length for result data";const s=_e(t);if(s.length%32===0)try{return u(this,ve).decode(e.outputs,s)}catch{n="could not decode result data"}I(!1,n,"BAD_DATA",{value:T(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=V(e,"data"),s=eo.getBuiltinCallException("call",t,n);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=T(n.slice(0,4)),c=this.getError(a);if(c)try{const l=u(this,ve).decode(c.inputs,n.slice(4));s.revert={name:c.name,signature:c.format(),args:l},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const n=this.getFunction(e);y(n,"unknown function","fragment",e),e=n}return T(u(this,ve).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);y(i,"unknown event","eventFragment",e),e=i}I(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const s=(i,o)=>i.type==="string"?Wr(o):i.type==="bytes"?ue(T(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=Xn(o):i.type.match(/^bytes/)?o=Ep(o,32):i.type==="address"&&u(this,ve).encode(["address"],[o]),Kr(T(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){y(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?y(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?n.push(i.map(c=>s(a,c))):n.push(s(a,i))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);y(o,"unknown event","eventFragment",e),e=o}const n=[],s=[],i=[];return e.anonymous||n.push(e.topicHash),y(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const c=t[a];if(o.indexed)if(o.type==="string")n.push(Wr(c));else if(o.type==="bytes")n.push(ue(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(u(this,ve).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:u(this,ve).encode(s,i),topics:n}}decodeEventLog(e,t,n){if(typeof e=="string"){const g=this.getEvent(e);y(g,"unknown event","eventFragment",e),e=g}if(n!=null&&!e.anonymous){const g=e.topicHash;y(X(n[0],32)&&n[0].toLowerCase()===g,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((g,w)=>{g.indexed?g.type==="string"||g.type==="bytes"||g.baseType==="tuple"||g.baseType==="array"?(s.push(Ce.from({type:"bytes32",name:g.name})),o.push(!0)):(s.push(g),o.push(!1)):(i.push(g),o.push(!1))});const a=n!=null?u(this,ve).decode(s,le(n)):null,c=u(this,ve).decode(i,t,!0),l=[],h=[];let d=0,f=0;return e.inputs.forEach((g,w)=>{let m=null;if(g.indexed)if(a==null)m=new oh(null);else if(o[w])m=new oh(a[f++]);else try{m=a[f++]}catch(C){m=C}else try{m=c[d++]}catch(C){m=C}l.push(m),h.push(g.name||null)}),bi.fromItems(l,h)}parseTransaction(e){const t=V(e.data,"tx.data"),n=_(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(T(t.slice(0,4)));if(!s)return null;const i=u(this,ve).decode(s.inputs,t.slice(4));return new Xm(s,s.selector,i,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new Ym(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=T(e),n=this.getError(se(t,0,4));if(!n)return null;const s=u(this,ve).decode(n.inputs,se(t,4));return new ey(n,n.selector,s)}static from(e){return e instanceof lr?e:typeof e=="string"?new lr(JSON.parse(e)):typeof e.formatJson=="function"?new lr(e.formatJson()):typeof e.format=="function"?new lr(e.format("json")):new lr(e)}};Bt=new WeakMap,_t=new WeakMap,Lt=new WeakMap,ve=new WeakMap,ei=new WeakSet,ia=function(e,t,n){if(X(e)){const i=e.toLowerCase();for(const o of u(this,Lt).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of u(this,Lt))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,c=!0;xe.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let l=i.length-1;l>=0;l--){const h=i[l].inputs.length;h!==a&&(!c||h!==a-1)&&i.splice(l,1)}for(let l=i.length-1;l>=0;l--){const h=i[l].inputs;for(let d=0;d<t.length;d++)if(xe.isTyped(t[d])){if(d>=h.length){if(t[d].type==="overrides")continue;i.splice(l,1);break}if(t[d].type!==h[d].baseType){i.splice(l,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");y(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=u(this,Lt).get(Gt.from(e).format());return s||null},ti=new WeakSet,oa=function(e,t,n){if(X(e)){const i=e.toLowerCase();for(const o of u(this,_t).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of u(this,_t))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<t.length;c++)if(xe.isTyped(t[c])&&t[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");y(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=u(this,_t).get(Ht.from(e).format());return s||null};let dl=lr;const bf=BigInt(0);function Ns(r){return r??null}function oe(r){return r==null?null:r.toString()}class lh{constructor(e,t,n){E(this,"gasPrice");E(this,"maxFeePerGas");E(this,"maxPriorityFeePerGas");F(this,{gasPrice:Ns(e),maxFeePerGas:Ns(t),maxPriorityFeePerGas:Ns(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:oe(e),maxFeePerGas:oe(t),maxPriorityFeePerGas:oe(n)}}}function va(r){const e={};r.to&&(e.to=r.to),r.from&&(e.from=r.from),r.data&&(e.data=T(r.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in r)||r[s]==null||(e[s]=_(r[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)!(s in r)||r[s]==null||(e[s]=H(r[s],`request.${s}`));return r.accessList&&(e.accessList=qr(r.accessList)),"blockTag"in r&&(e.blockTag=r.blockTag),"enableCcipRead"in r&&(e.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(e.customData=r.customData),"blobVersionedHashes"in r&&r.blobVersionedHashes&&(e.blobVersionedHashes=r.blobVersionedHashes.slice()),"kzg"in r&&(e.kzg=r.kzg),"blobs"in r&&r.blobs&&(e.blobs=r.blobs.map(s=>xl(s)?T(s):Object.assign({},s))),e}var un;class ty{constructor(e,t){E(this,"provider");E(this,"number");E(this,"hash");E(this,"timestamp");E(this,"parentHash");E(this,"parentBeaconBlockRoot");E(this,"nonce");E(this,"difficulty");E(this,"gasLimit");E(this,"gasUsed");E(this,"stateRoot");E(this,"receiptsRoot");E(this,"blobGasUsed");E(this,"excessBlobGas");E(this,"miner");E(this,"prevRandao");E(this,"extraData");E(this,"baseFeePerGas");A(this,un,void 0);p(this,un,e.transactions.map(n=>typeof n!="string"?new to(n,t):n)),F(this,{provider:t,hash:Ns(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Ns(e.prevRandao),extraData:e.extraData,baseFeePerGas:Ns(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return u(this,un).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=u(this,un).slice();return e.length===0?[]:(I(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:c,nonce:l,number:h,parentHash:d,parentBeaconBlockRoot:f,stateRoot:g,receiptsRoot:w,timestamp:m,transactions:C}=this;return{_type:"Block",baseFeePerGas:oe(e),difficulty:oe(t),extraData:n,gasLimit:oe(s),gasUsed:oe(i),blobGasUsed:oe(this.blobGasUsed),excessBlobGas:oe(this.excessBlobGas),hash:o,miner:a,prevRandao:c,nonce:l,number:h,parentHash:d,timestamp:m,parentBeaconBlockRoot:f,stateRoot:g,receiptsRoot:w,transactions:C}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return u(this,un).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=u(this,un)[e];else{const n=e.toLowerCase();for(const s of u(this,un))if(typeof s=="string"){if(s!==n)continue;t=s;break}else{if(s.hash===n)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const n of t)if(n.hash===e)return n;y(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return ny(this)}}un=new WeakMap;class Oo{constructor(e,t){E(this,"provider");E(this,"transactionHash");E(this,"blockHash");E(this,"blockNumber");E(this,"removed");E(this,"address");E(this,"data");E(this,"topics");E(this,"index");E(this,"transactionIndex");this.provider=t;const n=Object.freeze(e.topics.slice());F(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:l}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return I(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return I(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return I(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return ry(this)}}var po;class Af{constructor(e,t){E(this,"provider");E(this,"to");E(this,"from");E(this,"contractAddress");E(this,"hash");E(this,"index");E(this,"blockHash");E(this,"blockNumber");E(this,"logsBloom");E(this,"gasUsed");E(this,"blobGasUsed");E(this,"cumulativeGasUsed");E(this,"gasPrice");E(this,"blobGasPrice");E(this,"type");E(this,"status");E(this,"root");A(this,po,void 0);p(this,po,Object.freeze(e.logs.map(s=>new Oo(s,t))));let n=bf;e.effectiveGasPrice!=null?n=e.effectiveGasPrice:e.gasPrice!=null&&(n=e.gasPrice),F(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return u(this,po)}toJSON(){const{to:e,from:t,contractAddress:n,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:l,status:h,root:d}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:n,cumulativeGasUsed:oe(this.cumulativeGasUsed),from:t,gasPrice:oe(this.gasPrice),blobGasUsed:oe(this.blobGasUsed),blobGasPrice:oe(this.blobGasPrice),gasUsed:oe(this.gasUsed),hash:s,index:i,logs:l,logsBloom:c,root:d,status:h,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Cf(this)}reorderedEvent(e){return I(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Ef(this,e)}}po=new WeakMap;var Dn;const iu=class iu{constructor(e,t){E(this,"provider");E(this,"blockNumber");E(this,"blockHash");E(this,"index");E(this,"hash");E(this,"type");E(this,"to");E(this,"from");E(this,"nonce");E(this,"gasLimit");E(this,"gasPrice");E(this,"maxPriorityFeePerGas");E(this,"maxFeePerGas");E(this,"maxFeePerBlobGas");E(this,"data");E(this,"value");E(this,"chainId");E(this,"signature");E(this,"accessList");E(this,"blobVersionedHashes");A(this,Dn,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,p(this,Dn,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:s,type:i,to:o,from:a,nonce:c,data:l,signature:h,accessList:d,blobVersionedHashes:f}=this;return{_type:"TransactionResponse",accessList:d,blockNumber:e,blockHash:t,blobVersionedHashes:f,chainId:oe(this.chainId),data:l,from:a,gasLimit:oe(this.gasLimit),gasPrice:oe(this.gasPrice),hash:s,maxFeePerGas:oe(this.maxFeePerGas),maxPriorityFeePerGas:oe(this.maxPriorityFeePerGas),maxFeePerBlobGas:oe(this.maxFeePerBlobGas),nonce:c,signature:h,to:o,index:n,type:i,value:oe(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const n=await this.getTransaction();n&&(e=n.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:n}=await Te({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:n-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const n=e??1,s=t??0;let i=u(this,Dn),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:f,nonce:g}=await Te({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(g<this.nonce){i=f;return}if(a)return null;const w=await this.getTransaction();if(!(w&&w.blockNumber!=null))for(o===-1&&(o=i-3,o<u(this,Dn)&&(o=u(this,Dn)));o<=f;){if(a)return null;const m=await this.provider.getBlock(o,!0);if(m==null)return;for(const C of m)if(C===this.hash)return;for(let C=0;C<m.length;C++){const v=await m.getTransaction(C);if(v.from===this.from&&v.nonce===this.nonce){if(a)return null;const k=await this.provider.getTransactionReceipt(v.hash);if(k==null||f-k.blockNumber+1<n)return;let S="replaced";v.data===this.data&&v.to===this.to&&v.value===this.value?S="repriced":v.data==="0x"&&v.from===v.to&&v.value===bf&&(S="cancelled"),I(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:S==="replaced"||S==="cancelled",reason:S,replacement:v.replaceableTransaction(i),hash:v.hash,receipt:k})}}o++}},l=f=>{if(f==null||f.status!==0)return f;I(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:f.to,from:f.from,data:""},receipt:f})},h=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(h);if(h){if(await h.confirmations()>=n)return l(h)}else if(await c(),n===0)return null;return await new Promise((f,g)=>{const w=[],m=()=>{w.forEach(v=>v())};if(w.push(()=>{a=!0}),s>0){const v=setTimeout(()=>{m(),g(ne("wait for transaction timeout","TIMEOUT"))},s);w.push(()=>{clearTimeout(v)})}const C=async v=>{if(await v.confirmations()>=n){m();try{f(l(v))}catch(k){g(k)}}};if(w.push(()=>{this.provider.off(this.hash,C)}),this.provider.on(this.hash,C),i>=0){const v=async()=>{try{await c()}catch(k){if(ke(k,"TRANSACTION_REPLACED")){m(),g(k);return}}a||this.provider.once("block",v)};w.push(()=>{this.provider.off("block",v)}),this.provider.once("block",v)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return I(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Cf(this)}reorderedEvent(e){return I(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),I(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ef(this,e)}replaceableTransaction(e){y(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new iu(this,this.provider);return p(t,Dn,e),t}};Dn=new WeakMap;let to=iu;function ny(r){return{orphan:"drop-block",hash:r.hash,number:r.number}}function Ef(r,e){return{orphan:"reorder-transaction",tx:r,other:e}}function Cf(r){return{orphan:"drop-transaction",tx:r}}function ry(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class Wl extends Oo{constructor(t,n,s){super(t,t.provider);E(this,"interface");E(this,"fragment");E(this,"args");const i=n.decodeEventLog(s,t.data,t.topics);F(this,{args:i,fragment:s,interface:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class vf extends Oo{constructor(t,n){super(t,t.provider);E(this,"error");F(this,{error:n})}}var ni;class sy extends Af{constructor(t,n,s){super(s,n);A(this,ni,void 0);p(this,ni,t)}get logs(){return super.logs.map(t=>{const n=t.topics.length?u(this,ni).getEvent(t.topics[0]):null;if(n)try{return new Wl(t,u(this,ni),n)}catch(s){return new vf(t,s)}return t})}}ni=new WeakMap;var go;class Vl extends to{constructor(t,n,s){super(s,n);A(this,go,void 0);p(this,go,t)}async wait(t,n){const s=await super.wait(t,n);return s==null?null:new sy(u(this,go),this.provider,s)}}go=new WeakMap;class If extends Jh{constructor(t,n,s,i){super(t,n,s);E(this,"log");F(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class iy extends If{constructor(e,t,n,s,i){super(e,t,n,new Wl(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);F(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const uh=BigInt(0);function Nf(r){return r&&typeof r.call=="function"}function Sf(r){return r&&typeof r.estimateGas=="function"}function za(r){return r&&typeof r.resolveName=="function"}function kf(r){return r&&typeof r.sendTransaction=="function"}function xf(r){if(r!=null){if(za(r))return r;if(r.provider)return r.provider}}var mo;class oy{constructor(e,t,n){A(this,mo,void 0);E(this,"fragment");if(F(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const s=zr(e.runner,"resolveName"),i=za(s)?s:null;p(this,mo,async function(){const o=await Promise.all(t.inputs.map((a,c)=>n[c]==null?null:a.walkAsync(n[c],(h,d)=>h==="address"?Array.isArray(d)?Promise.all(d.map(f=>Me(f,i))):Me(d,i):d)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return u(this,mo)}}mo=new WeakMap;function zr(r,e){return r==null?null:typeof r[e]=="function"?r:r.provider&&typeof r.provider[e]=="function"?r.provider:null}function pr(r){return r==null?null:r.provider||null}async function Pf(r,e){const t=xe.dereference(r,"overrides");y(typeof t=="object","invalid overrides parameter","overrides",r);const n=va(t);return y(n.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),y(n.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function ay(r,e,t){const n=zr(r,"resolveName"),s=za(n)?n:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,c)=>(c=xe.dereference(c,a),a==="address"?Me(c,s):c))))}function cy(r){const e=async function(o){const a=await Pf(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await Me(a.from,xf(r.runner)));const c=r.interface,l=_(a.value||uh,"overrides.value")===uh,h=(a.data||"0x")==="0x";c.fallback&&!c.fallback.payable&&c.receive&&!h&&!l&&y(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),y(c.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data);const d=c.receive||c.fallback&&c.fallback.payable;return y(d||l,"cannot send value to non-payable fallback","overrides.value",a.value),y(c.fallback||h,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=zr(r.runner,"call");I(Nf(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const c=await e(o);try{return await a.call(c)}catch(l){throw kl(l)&&l.data?r.interface.makeError(l.data,c):l}},n=async function(o){const a=r.runner;I(kf(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const c=await a.sendTransaction(await e(o)),l=pr(r.runner);return new Vl(r.interface,l,c)},s=async function(o){const a=zr(r.runner,"estimateGas");return I(Sf(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await n(o);return F(i,{_contract:r,estimateGas:s,populateTransaction:e,send:n,staticCall:t}),i}function ly(r,e){const t=function(...l){const h=r.interface.getFunction(e,l);return I(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:l}}),h},n=async function(...l){const h=t(...l);let d={};if(h.inputs.length+1===l.length&&(d=await Pf(l.pop()),d.from&&(d.from=await Me(d.from,xf(r.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const f=await ay(r.runner,h.inputs,l);return Object.assign({},d,await Te({to:r.getAddress(),data:r.interface.encodeFunctionData(h,f)}))},s=async function(...l){const h=await a(...l);return h.length===1?h[0]:h},i=async function(...l){const h=r.runner;I(kf(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const d=await h.sendTransaction(await n(...l)),f=pr(r.runner);return new Vl(r.interface,f,d)},o=async function(...l){const h=zr(r.runner,"estimateGas");return I(Sf(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},a=async function(...l){const h=zr(r.runner,"call");I(Nf(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const d=await n(...l);let f="0x";try{f=await h.call(d)}catch(w){throw kl(w)&&w.data?r.interface.makeError(w.data,d):w}const g=t(...l);return r.interface.decodeFunctionResult(g,f)},c=async(...l)=>t(...l).constant?await s(...l):await i(...l);return F(c,{name:r.interface.getFunctionName(e),_contract:r,_key:e,getFragment:t,estimateGas:o,populateTransaction:n,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(c,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=r.interface.getFunction(e);return I(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),l}}),c}function uy(r,e){const t=function(...s){const i=r.interface.getEvent(e,s);return I(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},n=function(...s){return new oy(r,t(...s),s)};return F(n,{name:r.interface.getEventName(e),_contract:r,_key:e,getFragment:t}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=r.interface.getEvent(e);return I(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),n}const Ia=Symbol.for("_ethersInternal_contract"),Rf=new WeakMap;function hy(r,e){Rf.set(r[Ia],e)}function ze(r){return Rf.get(r[Ia])}function dy(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function Ql(r,e){let t,n=null;if(Array.isArray(e)){const i=function(o){if(X(o,32))return o;const a=r.interface.getEvent(o);return y(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?X(e,32)?t=[e]:(n=r.interface.getEvent(e),y(n,"unknown fragment","event",e),t=[n.topicHash]):dy(e)?t=await e.getTopicFilter():"fragment"in e?(n=e.fragment,t=[n.topicHash]):y(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:n,tag:s,topics:t}}async function Fi(r,e){const{subs:t}=ze(r);return t.get((await Ql(r,e)).tag)||null}async function hh(r,e,t){const n=pr(r.runner);I(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Ql(r,t),{addr:a,subs:c}=ze(r);let l=c.get(i);if(!l){const d={address:a||r,topics:o},f=C=>{let v=s;if(v==null)try{v=r.interface.getEvent(C.topics[0])}catch{}if(v){const k=v,S=s?r.interface.decodeEventLog(s,C.data,C.topics):[];pl(r,t,S,B=>new iy(r,B,t,k,C))}else pl(r,t,[],k=>new If(r,k,t,C))};let g=[];l={tag:i,listeners:[],start:()=>{g.length||g.push(n.on(d,f))},stop:async()=>{if(g.length==0)return;let C=g;g=[],await Promise.all(C),n.off(d,f)}},c.set(i,l)}return l}let fl=Promise.resolve();async function fy(r,e,t,n){await fl;const s=await Fi(r,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(t);n&&c.push(n(a?null:o));try{o.call(r,...c)}catch{}return!a}),s.listeners.length===0&&(s.stop(),ze(r).subs.delete(s.tag)),i>0}async function pl(r,e,t,n){try{await fl}catch{}const s=fy(r,e,t,n);return fl=s,await s}const Qo=["then"];var Z1;const Vi=class Vi{constructor(e,t,n,s){E(this,"target");E(this,"interface");E(this,"runner");E(this,"filters");E(this,Z1);E(this,"fallback");y(typeof e=="string"||Ld(e),"invalid value for Contract target","target",e),n==null&&(n=null);const i=dl.from(t);F(this,{target:e,runner:n,interface:i}),Object.defineProperty(this,Ia,{value:{}});let o,a=null,c=null;if(s){const d=pr(n);c=new Vl(this.interface,d,s)}let l=new Map;if(typeof e=="string")if(X(e))a=e,o=Promise.resolve(e);else{const d=zr(n,"resolveName");if(!za(d))throw ne("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=d.resolveName(e).then(f=>{if(f==null)throw ne("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return ze(this).addr=f,f})}else o=e.getAddress().then(d=>{if(d==null)throw new Error("TODO");return ze(this).addr=d,d});hy(this,{addrPromise:o,addr:a,deployTx:c,subs:l});const h=new Proxy({},{get:(d,f,g)=>{if(typeof f=="symbol"||Qo.indexOf(f)>=0)return Reflect.get(d,f,g);try{return this.getEvent(f)}catch(w){if(!ke(w,"INVALID_ARGUMENT")||w.argument!=="key")throw w}},has:(d,f)=>Qo.indexOf(f)>=0?Reflect.has(d,f):Reflect.has(d,f)||this.interface.hasEvent(String(f))});return F(this,{filters:h}),F(this,{fallback:i.receive||i.fallback?cy(this):null}),new Proxy(this,{get:(d,f,g)=>{if(typeof f=="symbol"||f in d||Qo.indexOf(f)>=0)return Reflect.get(d,f,g);try{return d.getFunction(f)}catch(w){if(!ke(w,"INVALID_ARGUMENT")||w.argument!=="key")throw w}},has:(d,f)=>typeof f=="symbol"||f in d||Qo.indexOf(f)>=0?Reflect.has(d,f):d.interface.hasFunction(f)})}connect(e){return new Vi(this.target,this.interface,e)}attach(e){return new Vi(e,this.interface,this.runner)}async getAddress(){return await ze(this).addrPromise}async getDeployedCode(){const e=pr(this.runner);I(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=pr(this.runner);return I(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);n.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return ze(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),ly(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),uy(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,n){t==null&&(t=0),n==null&&(n="latest");const{addr:s,addrPromise:i}=ze(this),o=s||await i,{fragment:a,topics:c}=await Ql(this,e),l={address:o,topics:c,fromBlock:t,toBlock:n},h=pr(this.runner);return I(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(l)).map(d=>{let f=a;if(f==null)try{f=this.interface.getEvent(d.topics[0])}catch{}if(f)try{return new Wl(d,this.interface,f)}catch(g){return new vf(d,g)}return new Oo(d,h)})}async on(e,t){const n=await hh(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await hh(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await pl(this,e,t,null)}async listenerCount(e){if(e){const s=await Fi(this,e);return s?s.listeners.length:0}const{subs:t}=ze(this);let n=0;for(const{listeners:s}of t.values())n+=s.length;return n}async listeners(e){if(e){const s=await Fi(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=ze(this);let n=[];for(const{listeners:s}of t.values())n=n.concat(s.map(({listener:i})=>i));return n}async off(e,t){const n=await Fi(this,e);if(!n)return this;if(t){const s=n.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(t==null||n.listeners.length===0)&&(n.stop(),ze(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await Fi(this,e);if(!t)return this;t.stop(),ze(this).subs.delete(t.tag)}else{const{subs:t}=ze(this);for(const{tag:n,stop:s}of t.values())s(),t.delete(n)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Vi{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,n){return n==null&&(n=null),new this(e,t,n)}};Z1=Ia;let gl=Vi;function py(){return gl}class Ss extends py(){}function Bc(r){return r.match(/^ipfs:\/\/ipfs\//i)?r=r.substring(12):r.match(/^ipfs:\/\//i)?r=r.substring(7):y(!1,"unsupported IPFS format","link",r),`https://gateway.ipfs.io/ipfs/${r}`}class gy{constructor(e){E(this,"name");F(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const Of=new RegExp("^(ipfs)://(.*)$","i"),dh=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Of,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];var Fn,kr,Hn,ds,Ba,Tf;const bs=class bs{constructor(e,t,n){A(this,Hn);E(this,"provider");E(this,"address");E(this,"name");A(this,Fn,void 0);A(this,kr,void 0);F(this,{provider:e,address:t,name:n}),p(this,Fn,null),p(this,kr,new Ss(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return u(this,Fn)==null&&p(this,Fn,(async()=>{try{return await u(this,kr).supportsInterface("0x9061b923")}catch(e){if(ke(e,"CALL_EXCEPTION"))return!1;throw p(this,Fn,null),e}})()),await u(this,Fn)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await N(this,Hn,ds).call(this,"addr(bytes32)");return i==null||i===zi?null:i}catch(i){if(ke(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await N(this,Hn,ds).call(this,"addr(bytes32,uint)",[i]);if(X(o,20))return $(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof gy&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const n=await N(this,Hn,ds).call(this,"addr(bytes32,uint)",[e]);if(n==null||n==="0x")return null;const s=await t.decodeAddress(e,n);if(s!=null)return s;I(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){const t=await N(this,Hn,ds).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await N(this,Hn,ds).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${vp("0x"+t[2])}`}const n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;I(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let n=0;n<dh.length;n++){const s=t.match(dh[n]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=Bc(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const c=(s[2]||"").split("/");if(c.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const l=c[1],h=new Ss(c[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const m=await h.ownerOf(l);if(a!==m)return e.push({type:"!owner",value:m}),{url:null,linkage:e};e.push({type:"owner",value:m})}else if(i==="erc1155"){const m=await h.balanceOf(a,l);if(!m)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:m.toString()})}let d=await h[o](l);if(d==null||d==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:d}),i==="erc1155"&&(d=d.replace("{id}",Xn(l,32).substring(2)),e.push({type:"metadata-url-expanded",value:d})),d.match(/^ipfs:/i)&&(d=Bc(d)),e.push({type:"metadata-url",value:d});let f={};const g=await new Qt(d).send();g.assertOk();try{f=g.bodyJson}catch{try{e.push({type:"!metadata",value:g.bodyText})}catch{const v=g.body;return v&&e.push({type:"!metadata",value:T(v)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!f)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(f)});let w=f.image;if(typeof w!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!w.match(/^(https:\/\/|data:)/i)){if(w.match(Of)==null)return e.push({type:"!imageUrl-ipfs",value:w}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:w}),w=Bc(w)}return e.push({type:"url",value:w}),{linkage:e,url:w}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),n=t.getPlugin("org.ethers.plugins.network.Ens");return I(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),n.address}static async fromName(e,t){var s;let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const i=await N(s=bs,Ba,Tf).call(s,e,n);if(i!=null){const o=new bs(e,i,t);return n!==t&&!await o.supportsWildcard()?null:o}n=n.split(".").slice(1).join(".")}}};Fn=new WeakMap,kr=new WeakMap,Hn=new WeakSet,ds=async function(e,t){t=(t||[]).slice();const n=u(this,kr).interface;t.unshift(ul(this.name));let s=null;await this.supportsWildcard()&&(s=n.getFunction(e),I(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[pm(this.name,255),n.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await u(this,kr)[e](...t);return s?n.decodeFunctionResult(s,i)[0]:i}catch(i){if(!ke(i,"CALL_EXCEPTION"))throw i}return null},Ba=new WeakSet,Tf=async function(e,t){const n=await bs.getEnsAddress(e);try{const i=await new Ss(n,["function resolver(bytes32) view returns (address)"],e).resolver(ul(t),{enableCcipRead:!0});return i===zi?null:i}catch(s){throw s}return null},A(bs,Ba);let Na=bs;const fh=BigInt(0);function W(r,e){return function(t){return t==null?e:r(t)}}function Ja(r,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(n=>r(n))}}function To(r,e){return t=>{const n={};for(const s in r){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=r[s](t[i]);o!==void 0&&(n[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";I(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return n}}function my(r){switch(r){case!0:case"true":return!0;case!1:case"false":return!1}y(!1,`invalid boolean; ${JSON.stringify(r)}`,"value",r)}function Si(r){return y(X(r,!0),"invalid data","value",r),r}function Ee(r){return y(X(r,32),"invalid hash","value",r),r}const yy=To({address:$,blockHash:Ee,blockNumber:H,data:Si,index:H,removed:W(my,!1),topics:Ja(Ee),transactionHash:Ee,transactionIndex:H},{index:["logIndex"]});function wy(r){return yy(r)}const by=To({hash:W(Ee),parentHash:Ee,parentBeaconBlockRoot:W(Ee,null),number:H,timestamp:H,nonce:W(Si),difficulty:_,gasLimit:_,gasUsed:_,stateRoot:W(Ee,null),receiptsRoot:W(Ee,null),blobGasUsed:W(_,null),excessBlobGas:W(_,null),miner:W($),prevRandao:W(Ee,null),extraData:Si,baseFeePerGas:W(_)},{prevRandao:["mixHash"]});function Ay(r){const e=by(r);return e.transactions=r.transactions.map(t=>typeof t=="string"?t:Bf(t)),e}const Ey=To({transactionIndex:H,blockNumber:H,transactionHash:Ee,address:$,topics:Ja(Ee),data:Si,index:H,blockHash:Ee},{index:["logIndex"]});function Cy(r){return Ey(r)}const vy=To({to:W($,null),from:W($,null),contractAddress:W($,null),index:H,root:W(T),gasUsed:_,blobGasUsed:W(_,null),logsBloom:W(Si),blockHash:Ee,hash:Ee,logs:Ja(Cy),blockNumber:H,cumulativeGasUsed:_,effectiveGasPrice:W(_),blobGasPrice:W(_,null),status:W(H),type:W(H,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function Iy(r){return vy(r)}function Bf(r){r.to&&_(r.to)===fh&&(r.to="0x0000000000000000000000000000000000000000");const e=To({hash:Ee,index:W(H,void 0),type:t=>t==="0x"||t==null?0:H(t),accessList:W(qr,null),blobVersionedHashes:W(Ja(Ee,!0),null),blockHash:W(Ee,null),blockNumber:W(H,null),transactionIndex:W(H,null),from:$,gasPrice:W(_),maxPriorityFeePerGas:W(_),maxFeePerGas:W(_),maxFeePerBlobGas:W(_,null),gasLimit:_,to:W($,null),value:_,nonce:H,data:Si,creates:W($,null),chainId:W(_,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(r);if(e.to==null&&e.creates==null&&(e.creates=y0(e)),(r.type===1||r.type===2)&&r.accessList==null&&(e.accessList=[]),r.signature?e.signature=It.from(r.signature):e.signature=It.from(r),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&_(e.blockHash)===fh&&(e.blockHash=null),e}const Ny="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Bo{constructor(e){E(this,"name");F(this,{name:e})}clone(){return new Bo(this.name)}}class qa extends Bo{constructor(t,n){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);E(this,"effectiveBlock");E(this,"txBase");E(this,"txCreate");E(this,"txDataZero");E(this,"txDataNonzero");E(this,"txAccessListStorageKey");E(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let c=(n||{})[o];c==null&&(c=a),y(typeof c=="number",`invalud value for ${o}`,"costs",n),s[o]=c}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),F(this,s)}clone(){return new qa(this.effectiveBlock,this)}}class Za extends Bo{constructor(t,n){super("org.ethers.plugins.network.Ens");E(this,"address");E(this,"targetNetwork");F(this,{address:t||Ny,targetNetwork:n??1})}clone(){return new Za(this.address,this.targetNetwork)}}var yo,wo;class Sy extends Bo{constructor(t,n){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");A(this,yo,void 0);A(this,wo,void 0);p(this,yo,t),p(this,wo,n)}get url(){return u(this,yo)}get processFunc(){return u(this,wo)}clone(){return this}}yo=new WeakMap,wo=new WeakMap;const _c=new Map;var ri,si,Gn;const As=class As{constructor(e,t){A(this,ri,void 0);A(this,si,void 0);A(this,Gn,void 0);p(this,ri,e),p(this,si,_(t)),p(this,Gn,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return u(this,ri)}set name(e){p(this,ri,e)}get chainId(){return u(this,si)}set chainId(e){p(this,si,_(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===_(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===_(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===_(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(u(this,Gn).values())}attachPlugin(e){if(u(this,Gn).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return u(this,Gn).set(e.name,e.clone()),this}getPlugin(e){return u(this,Gn).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new As(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new qa;let n=t.txBase;if(e.to==null&&(n+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){const s=qr(e.accessList);for(const i in s)n+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return n}static from(e){if(ky(),e==null)return As.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=_c.get(e);if(t)return t();if(typeof e=="bigint")return new As("unknown",e);y(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){y(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new As(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Za(e.ensAddress,e.ensNetwork)),t}y(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=_c.get(e);n&&y(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),_c.set(e,t)}};ri=new WeakMap,si=new WeakMap,Gn=new WeakMap;let vt=As;function ph(r,e){const t=String(r);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${r}`);const n=t.split(".");if(n.length===1&&n.push(""),n.length!==2)throw new Error(`invalid gwei value: ${r}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let s=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||s++,n[1]=s.toString()}return BigInt(n[0]+n[1])}function gh(r){return new Sy(r,async(e,t,n)=>{n.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([n.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:ph(a.maxFee,9),maxPriorityFeePerGas:ph(a.maxPriorityFee,9)}}catch(i){I(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:s,error:i})}})}let mh=!1;function ky(){if(mh)return;mh=!0;function r(e,t,n){const s=function(){const i=new vt(e,t);return n.ensNetwork!=null&&i.attachPlugin(new Za(null,n.ensNetwork)),i.attachPlugin(new qa),(n.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};vt.register(e,s),vt.register(t,s),n.altNames&&n.altNames.forEach(i=>{vt.register(i,s)})}r("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),r("ropsten",3,{ensNetwork:3}),r("rinkeby",4,{ensNetwork:4}),r("goerli",5,{ensNetwork:5}),r("kovan",42,{ensNetwork:42}),r("sepolia",11155111,{ensNetwork:11155111}),r("holesky",17e3,{ensNetwork:17e3}),r("classic",61,{}),r("classicKotti",6,{}),r("arbitrum",42161,{ensNetwork:1}),r("arbitrum-goerli",421613,{}),r("arbitrum-sepolia",421614,{}),r("base",8453,{ensNetwork:1}),r("base-goerli",84531,{}),r("base-sepolia",84532,{}),r("bnb",56,{ensNetwork:1}),r("bnbt",97,{}),r("linea",59144,{ensNetwork:1}),r("linea-goerli",59140,{}),r("linea-sepolia",59141,{}),r("matic",137,{ensNetwork:1,plugins:[gh("https://gasstation.polygon.technology/v2")]}),r("matic-amoy",80002,{}),r("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[gh("https://gasstation-testnet.polygon.technology/v2")]}),r("optimism",10,{ensNetwork:1,plugins:[]}),r("optimism-goerli",420,{}),r("optimism-sepolia",11155420,{}),r("xdai",100,{ensNetwork:1})}function ml(r){return JSON.parse(JSON.stringify(r))}var hn,rt,Kn,Ut,ii,aa;class xy{constructor(e){A(this,ii);A(this,hn,void 0);A(this,rt,void 0);A(this,Kn,void 0);A(this,Ut,void 0);p(this,hn,e),p(this,rt,null),p(this,Kn,4e3),p(this,Ut,-2)}get pollingInterval(){return u(this,Kn)}set pollingInterval(e){p(this,Kn,e)}start(){u(this,rt)||(p(this,rt,u(this,hn)._setTimeout(N(this,ii,aa).bind(this),u(this,Kn))),N(this,ii,aa).call(this))}stop(){u(this,rt)&&(u(this,hn)._clearTimeout(u(this,rt)),p(this,rt,null))}pause(e){this.stop(),e&&p(this,Ut,-2)}resume(){this.start()}}hn=new WeakMap,rt=new WeakMap,Kn=new WeakMap,Ut=new WeakMap,ii=new WeakSet,aa=async function(){try{const e=await u(this,hn).getBlockNumber();if(u(this,Ut)===-2){p(this,Ut,e);return}if(e!==u(this,Ut)){for(let t=u(this,Ut)+1;t<=e;t++){if(u(this,rt)==null)return;await u(this,hn).emit("block",t)}p(this,Ut,e)}}catch{}u(this,rt)!=null&&p(this,rt,u(this,hn)._setTimeout(N(this,ii,aa).bind(this),u(this,Kn)))};var xr,Pr,jn;class zl{constructor(e){A(this,xr,void 0);A(this,Pr,void 0);A(this,jn,void 0);p(this,xr,e),p(this,jn,!1),p(this,Pr,t=>{this._poll(t,u(this,xr))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){u(this,jn)||(p(this,jn,!0),u(this,Pr).call(this,-2),u(this,xr).on("block",u(this,Pr)))}stop(){u(this,jn)&&(p(this,jn,!1),u(this,xr).off("block",u(this,Pr)))}pause(e){this.stop()}resume(){this.start()}}xr=new WeakMap,Pr=new WeakMap,jn=new WeakMap;var oi,dn;class Py extends zl{constructor(t,n){super(t);A(this,oi,void 0);A(this,dn,void 0);p(this,oi,n),p(this,dn,-2)}pause(t){t&&p(this,dn,-2),super.pause(t)}async _poll(t,n){const s=await n.getBlock(u(this,oi));s!=null&&(u(this,dn)===-2?p(this,dn,s.number):s.number>u(this,dn)&&(n.emit(u(this,oi),s.number),p(this,dn,s.number)))}}oi=new WeakMap,dn=new WeakMap;var _a;class Ry extends zl{constructor(t,n){super(t);A(this,_a,void 0);p(this,_a,ml(n))}async _poll(t,n){throw new Error("@TODO")}}_a=new WeakMap;var ai;class Oy extends zl{constructor(t,n){super(t);A(this,ai,void 0);p(this,ai,n)}async _poll(t,n){const s=await n.getTransactionReceipt(u(this,ai));s&&n.emit(u(this,ai),s)}}ai=new WeakMap;var fn,ci,li,Wn,st,La,_f;class Jl{constructor(e,t){A(this,La);A(this,fn,void 0);A(this,ci,void 0);A(this,li,void 0);A(this,Wn,void 0);A(this,st,void 0);p(this,fn,e),p(this,ci,ml(t)),p(this,li,N(this,La,_f).bind(this)),p(this,Wn,!1),p(this,st,-2)}start(){u(this,Wn)||(p(this,Wn,!0),u(this,st)===-2&&u(this,fn).getBlockNumber().then(e=>{p(this,st,e)}),u(this,fn).on("block",u(this,li)))}stop(){u(this,Wn)&&(p(this,Wn,!1),u(this,fn).off("block",u(this,li)))}pause(e){this.stop(),e&&p(this,st,-2)}resume(){this.start()}}fn=new WeakMap,ci=new WeakMap,li=new WeakMap,Wn=new WeakMap,st=new WeakMap,La=new WeakSet,_f=async function(e){if(u(this,st)===-2)return;const t=ml(u(this,ci));t.fromBlock=u(this,st)+1,t.toBlock=e;const n=await u(this,fn).getLogs(t);if(n.length===0){u(this,st)<e-60&&p(this,st,e-60);return}for(const s of n)u(this,fn).emit(u(this,ci),s),p(this,st,s.blockNumber)};const Ty=BigInt(2),By=10;function zo(r){return r&&typeof r.then=="function"}function ca(r,e){return r+":"+JSON.stringify(e,(t,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const s=Object.keys(n);return s.sort(),s.reduce((i,o)=>(i[o]=n[o],i),{})}return n})}class Sa{constructor(e){E(this,"name");F(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function _y(r){return JSON.parse(JSON.stringify(r))}function yl(r){return r=Array.from(new Set(r).values()),r.sort(),r}async function Lc(r,e){if(r==null)throw new Error("invalid event");if(Array.isArray(r)&&(r={topics:r}),typeof r=="string")switch(r){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:r,tag:r}}if(X(r,32)){const t=r.toLowerCase();return{type:"transaction",tag:ca("tx",{hash:t}),hash:t}}if(r.orphan){const t=r;return{type:"orphan",tag:ca("orphan",t),filter:_y(t)}}if(r.address||r.topics){const t=r,n={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?yl(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{X(a)?s.push(a):i.push((async()=>{s.push(await Me(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),n.address=yl(s.map(a=>a.toLowerCase()))}return{filter:n,tag:ca("event",n),type:"event"}}y(!1,"unknown ProviderEvent","event",r)}function Uc(){return new Date().getTime()}const Ly={cacheTimeout:250,pollingInterval:4e3};var Ie,Vn,Ne,ui,$e,Rr,Qn,pn,bo,it,hi,di,Re,Qe,Ao,wl,Eo,bl,Or,Hi,Co,Al,Tr,Gi,fi,la;class Uy{constructor(e,t){A(this,Re);A(this,Ao);A(this,Eo);A(this,Or);A(this,Co);A(this,Tr);A(this,fi);A(this,Ie,void 0);A(this,Vn,void 0);A(this,Ne,void 0);A(this,ui,void 0);A(this,$e,void 0);A(this,Rr,void 0);A(this,Qn,void 0);A(this,pn,void 0);A(this,bo,void 0);A(this,it,void 0);A(this,hi,void 0);A(this,di,void 0);if(p(this,di,Object.assign({},Ly,t||{})),e==="any")p(this,Rr,!0),p(this,$e,null);else if(e){const n=vt.from(e);p(this,Rr,!1),p(this,$e,Promise.resolve(n)),setTimeout(()=>{this.emit("network",n,null)},0)}else p(this,Rr,!1),p(this,$e,null);p(this,pn,-1),p(this,Qn,new Map),p(this,Ie,new Map),p(this,Vn,new Map),p(this,Ne,null),p(this,ui,!1),p(this,bo,1),p(this,it,new Map),p(this,hi,!1)}get pollingInterval(){return u(this,di).pollingInterval}get provider(){return this}get plugins(){return Array.from(u(this,Vn).values())}attachPlugin(e){if(u(this,Vn).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return u(this,Vn).set(e.name,e.connect(this)),this}getPlugin(e){return u(this,Vn).get(e)||null}get disableCcipRead(){return u(this,hi)}set disableCcipRead(e){p(this,hi,!!e)}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<n.length;a++){const c=n[a],l=c.replace("{sender}",s).replace("{data}",i),h=new Qt(l);c.indexOf("{data}")===-1&&(h.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:a,urls:n});let d="unknown error";const f=await h.send();try{const g=f.bodyJson;if(g.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:g}),g.data;g.message&&(d=g.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:g})}catch{}I(f.statusCode<400||f.statusCode>=500,`response not found during CCIP fetch: ${d}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:c,errorMessage:d}}),o.push(d)}I(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:n,errorMessages:o}})}_wrapBlock(e,t){return new ty(Ay(e),this)}_wrapLog(e,t){return new Oo(wy(e),this)}_wrapTransactionReceipt(e,t){return new Af(Iy(e),this)}_wrapTransactionResponse(e,t){return new to(Bf(e),this)}_detectNetwork(){I(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){I(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=H(await N(this,Re,Qe).call(this,{method:"getBlockNumber"}),"%response");return u(this,pn)>=0&&p(this,pn,e),e}_getAddress(e){return Me(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(X(e))return X(e,32)?e:gs(e);if(typeof e=="bigint"&&(e=H(e,"blockTag")),typeof e=="number")return e>=0?gs(e):u(this,pn)>=0?gs(u(this,pn)+e):this.getBlockNumber().then(t=>gs(t+e));y(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(c=>c==null?null:Array.isArray(c)?yl(c.map(l=>l.toLowerCase())):c.toLowerCase()),n="blockHash"in e?e.blockHash:void 0,s=(c,l,h)=>{let d;switch(c.length){case 0:break;case 1:d=c[0];break;default:c.sort(),d=c}if(n&&(l!=null||h!=null))throw new Error("invalid filter");const f={};return d&&(f.address=d),t.length&&(f.topics=t),l&&(f.fromBlock=l),h&&(f.toBlock=h),n&&(f.blockHash=n),f};let i=[];if(e.address)if(Array.isArray(e.address))for(const c of e.address)i.push(this._getAddress(c));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(c=>typeof c!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(c=>s(c[0],c[1],c[2])):s(i,o,a)}_getTransactionRequest(e){const t=va(e),n=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Me(t[s],this);zo(i)?n.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);zo(s)?n.push(async function(){t.blockTag=await s}()):t.blockTag=s}return n.length?async function(){return await Promise.all(n),t}():t}async getNetwork(){if(u(this,$e)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw u(this,$e)===s&&p(this,$e,null),i}})();return p(this,$e,s),(await s).clone()}const e=u(this,$e),[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(u(this,Rr)?(this.emit("network",n,t),u(this,$e)===e&&p(this,$e,Promise.resolve(n))):I(!1,`network changed: ${t.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await Te({_block:N(this,Co,Al).call(this,"latest",!1),gasPrice:(async()=>{try{const h=await N(this,Re,Qe).call(this,{method:"getGasPrice"});return _(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await N(this,Re,Qe).call(this,{method:"getPriorityFee"});return _(h,"%response")}catch{}return null})()});let a=null,c=null;const l=this._wrapBlock(s,e);return l&&l.baseFeePerGas&&(c=o??BigInt("1000000000"),a=l.baseFeePerGas*Ty+c),new lh(i,a,c)},n=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const s=new Qt(n.url),i=await n.processFunc(t,this,s);return new lh(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return zo(t)&&(t=await t),_(await N(this,Re,Qe).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:n}=await Te({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await N(this,Eo,bl).call(this,N(this,Ao,wl).call(this,t,n,e.enableCcipRead?0:-1))}async getBalance(e,t){return _(await N(this,Or,Hi).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return H(await N(this,Or,Hi).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return T(await N(this,Or,Hi).call(this,{method:"getCode"},e,t))}async getStorage(e,t,n){const s=_(t,"position");return T(await N(this,Or,Hi).call(this,{method:"getStorage",position:s},e,n))}async broadcastTransaction(e){const{blockNumber:t,hash:n,network:s}=await Te({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=Ea.from(e);if(i.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:n,params:s}=await Te({network:this.getNetwork(),params:N(this,Co,Al).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,n)}async getTransaction(e){const{network:t,params:n}=await Te({network:this.getNetwork(),params:N(this,Re,Qe).call(this,{method:"getTransaction",hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){const{network:t,params:n}=await Te({network:this.getNetwork(),params:N(this,Re,Qe).call(this,{method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const s=await N(this,Re,Qe).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){const{result:t}=await Te({network:this.getNetwork(),result:N(this,Re,Qe).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:T(t)}async getLogs(e){let t=this._getFilter(e);zo(t)&&(t=await t);const{network:n,params:s}=await Te({network:this.getNetwork(),params:N(this,Re,Qe).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,n))}_getProvider(e){I(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Na.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=$(e);const t=ul(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await Na.getEnsAddress(this),i=await new Ss(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===zi)return null;const a=await new Ss(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(n){if(ke(n,"BAD_DATA")&&n.value==="0x"||ke(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(e,t,n){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const c=async l=>{try{const h=await this.getTransactionReceipt(e);if(h!=null&&l-h.blockNumber+1>=s){i(h),a&&(clearTimeout(a),a=null);return}}catch(h){console.log("EEE",h)}this.once("block",c)};n!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",c),o(ne("timeout","TIMEOUT",{reason:"timeout"})))},n)),c(await this.getBlockNumber())})}async waitForBlock(e){I(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=u(this,it).get(e);t&&(t.timer&&clearTimeout(t.timer),u(this,it).delete(e))}_setTimeout(e,t){t==null&&(t=0);const n=Ti(this,bo)._++,s=()=>{u(this,it).delete(n),e()};if(this.paused)u(this,it).set(n,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);u(this,it).set(n,{timer:i,func:s,time:Uc()})}return n}_forEachSubscriber(e){for(const t of u(this,Ie).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Sa(e.type);case"block":{const t=new xy(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Py(this,e.type);case"event":return new Jl(this,e.filter);case"transaction":return new Oy(this,e.hash);case"orphan":return new Ry(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const n of u(this,Ie).values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),u(this,Ne)!=null&&t.pause(u(this,Ne));break}}async on(e,t){const n=await N(this,fi,la).call(this,e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,u(this,Ne)!=null&&n.subscriber.pause(u(this,Ne))),this}async once(e,t){const n=await N(this,fi,la).call(this,e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,u(this,Ne)!=null&&n.subscriber.pause(u(this,Ne))),this}async emit(e,...t){const n=await N(this,Tr,Gi).call(this,e,t);if(!n||n.listeners.length===0)return!1;const s=n.listeners.length;return n.listeners=n.listeners.filter(({listener:i,once:o})=>{const a=new Jh(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),u(this,Ie).delete(n.tag)),s>0}async listenerCount(e){if(e){const n=await N(this,Tr,Gi).call(this,e);return n?n.listeners.length:0}let t=0;for(const{listeners:n}of u(this,Ie).values())t+=n.length;return t}async listeners(e){if(e){const n=await N(this,Tr,Gi).call(this,e);return n?n.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:n}of u(this,Ie).values())t=t.concat(n.map(({listener:s})=>s));return t}async off(e,t){const n=await N(this,Tr,Gi).call(this,e);if(!n)return this;if(t){const s=n.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),u(this,Ie).delete(n.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:n,subscriber:s}=await N(this,fi,la).call(this,e);n&&s.stop(),u(this,Ie).delete(t)}else for(const[t,{started:n,subscriber:s}]of u(this,Ie))n&&s.stop(),u(this,Ie).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return u(this,ui)}destroy(){this.removeAllListeners();for(const e of u(this,it).keys())this._clearTimeout(e);p(this,ui,!0)}get paused(){return u(this,Ne)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(p(this,pn,-1),u(this,Ne)!=null){if(u(this,Ne)==!!e)return;I(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),p(this,Ne,!!e);for(const t of u(this,it).values())t.timer&&clearTimeout(t.timer),t.time=Uc()-t.time}resume(){if(u(this,Ne)!=null){this._forEachSubscriber(e=>e.resume()),p(this,Ne,null);for(const e of u(this,it).values()){let t=e.time;t<0&&(t=0),e.time=Uc(),setTimeout(e.func,t)}}}}Ie=new WeakMap,Vn=new WeakMap,Ne=new WeakMap,ui=new WeakMap,$e=new WeakMap,Rr=new WeakMap,Qn=new WeakMap,pn=new WeakMap,bo=new WeakMap,it=new WeakMap,hi=new WeakMap,di=new WeakMap,Re=new WeakSet,Qe=async function(e){const t=u(this,di).cacheTimeout;if(t<0)return await this._perform(e);const n=ca(e.method,e);let s=u(this,Qn).get(n);return s||(s=this._perform(e),u(this,Qn).set(n,s),setTimeout(()=>{u(this,Qn).get(n)===s&&u(this,Qn).delete(n)},t)),await s},Ao=new WeakSet,wl=async function(e,t,n){I(n<By,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=va(e);try{return T(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&kl(i)&&i.data&&n>=0&&t==="latest"&&s.to!=null&&se(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Me(s.to,this);let c;try{c=Gy(se(i.data,4))}catch(d){I(!1,d.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}I(c.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:c.errorArgs}});const l=await this.ccipReadFetch(s,c.calldata,c.urls);I(l!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:c.errorArgs}});const h={to:a,data:le([c.selector,Hy([l,c.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const d=await N(this,Ao,wl).call(this,h,t,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:d}),d}catch(d){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:d}),d}}throw i}},Eo=new WeakSet,bl=async function(e){const{value:t}=await Te({network:this.getNetwork(),value:e});return t},Or=new WeakSet,Hi=async function(e,t,n){let s=this._getAddress(t),i=this._getBlockTag(n);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await N(this,Eo,bl).call(this,N(this,Re,Qe).call(this,Object.assign(e,{address:s,blockTag:i})))},Co=new WeakSet,Al=async function(e,t){if(X(e,32))return await N(this,Re,Qe).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await N(this,Re,Qe).call(this,{method:"getBlock",blockTag:n,includeTransactions:t})},Tr=new WeakSet,Gi=async function(e,t){let n=await Lc(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await Lc({orphan:"drop-log",log:t[0]},this)),u(this,Ie).get(n.tag)||null},fi=new WeakSet,la=async function(e){const t=await Lc(e,this),n=t.tag;let s=u(this,Ie).get(n);return s||(s={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},u(this,Ie).set(n,s)),s};function My(r,e){try{const t=El(r,e);if(t)return fa(t)}catch{}return null}function El(r,e){if(r==="0x")return null;try{const t=H(se(r,e,e+32)),n=H(se(r,t,t+32));return se(r,t+32,t+32+n)}catch{}return null}function yh(r){const e=Le(r);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function Dy(r){if(r.length%32===0)return r;const e=new Uint8Array(Math.ceil(r.length/32)*32);return e.set(r),e}const Fy=new Uint8Array([]);function Hy(r){const e=[];let t=0;for(let n=0;n<r.length;n++)e.push(Fy),t+=32;for(let n=0;n<r.length;n++){const s=V(r[n]);e[n]=yh(t),e.push(yh(s.length)),e.push(Dy(s)),t+=32+Math.ceil(s.length/32)*32}return le(e)}const wh="0x0000000000000000000000000000000000000000000000000000000000000000";function Gy(r){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};I(Cs(r)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=se(r,0,32);I(se(t,0,12)===se(wh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=se(t,12);try{const n=[],s=H(se(r,32,64)),i=H(se(r,s,s+32)),o=se(r,s+32);for(let a=0;a<i;a++){const c=My(o,a*32);if(c==null)throw new Error("abort");n.push(c)}e.urls=n}catch{I(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=El(r,64);if(n==null)throw new Error("abort");e.calldata=n}catch{I(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}I(se(r,100,128)===se(wh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=se(r,96,100);try{const n=El(r,128);if(n==null)throw new Error("abort");e.extraData=n}catch{I(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(n=>e[n]),e}function ss(r,e){if(r.provider)return r.provider;I(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function bh(r,e){let t=va(e);if(t.to!=null&&(t.to=Me(t.to,r)),t.from!=null){const n=t.from;t.from=Promise.all([r.getAddress(),Me(n,r)]).then(([s,i])=>(y(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=r.getAddress();return await Te(t)}class Ky{constructor(e){E(this,"provider");F(this,{provider:e||null})}async getNonce(e){return ss(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await bh(this,e)}async populateTransaction(e){const t=ss(this,"populateTransaction"),n=await bh(this,e);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const s=await this.provider.getNetwork();if(n.chainId!=null){const o=_(n.chainId);y(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else n.chainId=s.chainId;const i=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||i)?y(!1,"eip-1559 transaction do not support gasPrice","tx",e):(n.type===0||n.type===1)&&i&&y(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const o=await t.getFeeData();I(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(n.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(n.type=2,n.gasPrice!=null){const a=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=a,n.maxPriorityFeePerGas=a}else n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(I(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=o.gasPrice),n.type=0):I(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(n.type===2||n.type===3)&&(n.maxFeePerGas==null&&(n.maxFeePerGas=o.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await Te(n)}async estimateGas(e){return ss(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return ss(this,"call").call(await this.populateCall(e))}async resolveName(e){return await ss(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=ss(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const s=Ea.from(n);return await t.broadcastTransaction(await this.signTransaction(s))}}const Ah=new Set;function jy(r){Ah.has(r)||(Ah.add(r),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${r} (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.org/api-keys/"),console.log("=========================="))}function Wy(r){return JSON.parse(JSON.stringify(r))}var Oe,Mt,Br,zn,_r,pi,vo,Cl,Io,vl;class Lf{constructor(e){A(this,vo);A(this,Io);A(this,Oe,void 0);A(this,Mt,void 0);A(this,Br,void 0);A(this,zn,void 0);A(this,_r,void 0);A(this,pi,void 0);p(this,Oe,e),p(this,Mt,null),p(this,Br,N(this,vo,Cl).bind(this)),p(this,zn,!1),p(this,_r,null),p(this,pi,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){u(this,zn)||(p(this,zn,!0),N(this,vo,Cl).call(this,-2))}stop(){u(this,zn)&&(p(this,zn,!1),p(this,pi,!0),N(this,Io,vl).call(this),u(this,Oe).off("block",u(this,Br)))}pause(e){e&&N(this,Io,vl).call(this),u(this,Oe).off("block",u(this,Br))}resume(){this.start()}}Oe=new WeakMap,Mt=new WeakMap,Br=new WeakMap,zn=new WeakMap,_r=new WeakMap,pi=new WeakMap,vo=new WeakSet,Cl=async function(e){try{u(this,Mt)==null&&p(this,Mt,this._subscribe(u(this,Oe)));let t=null;try{t=await u(this,Mt)}catch(i){if(!ke(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){p(this,Mt,null),u(this,Oe)._recoverSubscriber(this,this._recover(u(this,Oe)));return}const n=await u(this,Oe).getNetwork();if(u(this,_r)||p(this,_r,n),u(this,_r).chainId!==n.chainId)throw new Error("chaid changed");if(u(this,pi))return;const s=await u(this,Oe).send("eth_getFilterChanges",[t]);await this._emitResults(u(this,Oe),s)}catch(t){console.log("@TODO",t)}u(this,Oe).once("block",u(this,Br))},Io=new WeakSet,vl=function(){const e=u(this,Mt);e&&(p(this,Mt,null),e.then(t=>{u(this,Oe).destroyed||u(this,Oe).send("eth_uninstallFilter",[t])}))};var Lr;class Vy extends Lf{constructor(t,n){super(t);A(this,Lr,void 0);p(this,Lr,Wy(n))}_recover(t){return new Jl(t,u(this,Lr))}async _subscribe(t){return await t.send("eth_newFilter",[u(this,Lr)])}async _emitResults(t,n){for(const s of n)t.emit(u(this,Lr),t._wrapLog(s,t._network))}}Lr=new WeakMap;class Qy extends Lf{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const zy="bigint,boolean,function,number,string,symbol".split(/,/g);function ua(r){if(r==null||zy.indexOf(typeof r)>=0||typeof r.getAddress=="function")return r;if(Array.isArray(r))return r.map(ua);if(typeof r=="object")return Object.keys(r).reduce((e,t)=>(e[t]=r[t],e),{});throw new Error(`should not happen: ${r} (${typeof r})`)}function Jy(r){return new Promise(e=>{setTimeout(e,r)})}function is(r){return r&&r.toLowerCase()}function Eh(r){return r&&typeof r.pollingInterval=="number"}const Uf={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class ks extends Ky{constructor(t,n){super(t);E(this,"address");n=$(n),F(this,{address:n})}connect(t){I(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const n=ua(t),s=[];if(n.from){const o=n.from;s.push((async()=>{const a=await Me(o,this.provider);y(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=a})())}else n.from=this.address;if(n.gasLimit==null&&s.push((async()=>{n.gasLimit=await this.provider.estimateGas({...n,from:this.address})})()),n.to!=null){const o=n.to;s.push((async()=>{n.to=await Me(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(n);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const n=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let c=0;const l=async()=>{try{const h=await this.provider.getTransaction(s);if(h!=null){i(h.replaceableTransaction(n));return}}catch(h){if(ke(h,"CANCELLED")||ke(h,"BAD_DATA")||ke(h,"NETWORK_ERROR")){h.info==null&&(h.info={}),h.info.sendTransactionHash=s,o(h);return}if(ke(h,"INVALID_ARGUMENT")&&(c++,h.info==null&&(h.info={}),h.info.sendTransactionHash=s,c>10)){o(h);return}this.provider.emit("error",ne("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:h}))}this.provider._setTimeout(()=>{l()},a.pop()||4e3)};l()})}async signTransaction(t){const n=ua(t);if(n.from){const i=await Me(n.from,this.provider);y(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),n.from=i}else n.from=this.address;const s=this.provider.getRpcTransaction(n);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const n=typeof t=="string"?jt(t):t;return await this.provider.send("personal_sign",[T(n),this.address.toLowerCase()])}async signTypedData(t,n,s){const i=ua(s),o=await Ca.resolveNames(t,n,i,async a=>{const c=await Me(a);return y(c!=null,"TypedData does not support null address","value",a),c});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Ca.getPayload(o.domain,n,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const n=typeof t=="string"?jt(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),T(n)])}}var Ur,gi,gn,Dt,At,ot,He,No,Il;class Mf extends Uy{constructor(t,n){super(t,n);A(this,No);A(this,Ur,void 0);A(this,gi,void 0);A(this,gn,void 0);A(this,Dt,void 0);A(this,At,void 0);A(this,ot,void 0);A(this,He,void 0);p(this,gi,1),p(this,Ur,Object.assign({},Uf,n||{})),p(this,gn,[]),p(this,Dt,null),p(this,ot,null),p(this,He,null);{let i=null;const o=new Promise(a=>{i=a});p(this,At,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(y(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",n),s&&t!=null&&p(this,ot,vt.from(t))):s&&(y(t==null||s.matches(t),"staticNetwork MUST match network object","options",n),p(this,ot,s))}_getOption(t){return u(this,Ur)[t]}get _network(){return I(u(this,ot),"network is not available yet","NETWORK_ERROR"),u(this,ot)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&_(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const n=this.getRpcRequest(t);return n!=null?await this.send(n.method,n.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(u(this,ot))return u(this,ot)}else return t;return u(this,He)?await u(this,He):this.ready?(p(this,He,(async()=>{try{const n=vt.from(_(await this.send("eth_chainId",[])));return p(this,He,null),n}catch(n){throw p(this,He,null),n}})()),await u(this,He)):(p(this,He,(async()=>{const n={id:Ti(this,gi)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:n});let s;try{s=(await this._send(n))[0],p(this,He,null)}catch(i){throw p(this,He,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return vt.from(_(s.result));throw this.getRpcError(n,s)})()),await u(this,He))}_start(){u(this,At)==null||u(this,At).resolve==null||(u(this,At).resolve(),p(this,At,null),(async()=>{for(;u(this,ot)==null&&!this.destroyed;)try{p(this,ot,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",ne("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await Jy(1e3)}N(this,No,Il).call(this)})())}async _waitUntilReady(){if(u(this,At)!=null)return await u(this,At).promise}_getSubscriber(t){return t.type==="pending"?new Qy(this):t.type==="event"?this._getOption("polling")?new Jl(this,t.filter):new Vy(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Sa("orphan"):super._getSubscriber(t)}get ready(){return u(this,At)==null}getRpcTransaction(t){const n={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),n[i]=gs(_(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(n[s]=T(t[s]))}),t.accessList&&(n.accessList=qr(t.accessList)),t.blobVersionedHashes&&(n.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),n}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[is(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[is(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[is(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[is(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(is):t.filter.address=is(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,n){const{method:s}=t,{error:i}=n;if(s==="eth_estimateGas"&&i.message){const c=i.message;if(!c.match(/revert/i)&&c.match(/insufficient funds/i))return ne("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const c=Nl(i),l=eo.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],c?c.data:null);return l.info={error:i,payload:t},l}const o=JSON.stringify(qy(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return ne("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const c=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return ne("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:c,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return ne("nonce has already been used","NONCE_EXPIRED",{transaction:c,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return ne("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:c,info:{error:i}});if(o.match(/only replay-protected/i))return ne("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:c,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?ne("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):ne("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,n){if(this.destroyed)return Promise.reject(ne("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Ti(this,gi)._++,i=new Promise((o,a)=>{u(this,gn).push({resolve:o,reject:a,payload:{method:t,params:n,id:s,jsonrpc:"2.0"}})});return N(this,No,Il).call(this),i}async getSigner(t){t==null&&(t=0);const n=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await n;if(t>=i.length)throw new Error("no such account");return new ks(this,i[t])}const{accounts:s}=await Te({network:this.getNetwork(),accounts:n});t=$(t);for(const i of s)if($(i)===t)return new ks(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(n=>new ks(this,n))}destroy(){u(this,Dt)&&(clearTimeout(u(this,Dt)),p(this,Dt,null));for(const{payload:t,reject:n}of u(this,gn))n(ne("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));p(this,gn,[]),super.destroy()}}Ur=new WeakMap,gi=new WeakMap,gn=new WeakMap,Dt=new WeakMap,At=new WeakMap,ot=new WeakMap,He=new WeakMap,No=new WeakSet,Il=function(){if(u(this,Dt))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");p(this,Dt,setTimeout(()=>{p(this,Dt,null);const n=u(this,gn);for(p(this,gn,[]);n.length;){const s=[n.shift()];for(;n.length&&s.length!==u(this,Ur).batchMaxCount;)if(s.push(n.shift()),JSON.stringify(s.map(o=>o.payload)).length>u(this,Ur).batchMaxSize){n.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:c,payload:l}of s){if(this.destroyed){c(ne("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:l.method}));continue}const h=o.filter(d=>d.id===l.id)[0];if(h==null){const d=ne("missing response for request","BAD_DATA",{value:o,info:{payload:l}});this.emit("error",d),c(d);continue}if("error"in h){c(this.getRpcError(l,h));continue}a(h.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};var Jn;class Df extends Mf{constructor(t,n){super(t,n);A(this,Jn,void 0);let s=this._getOption("pollingInterval");s==null&&(s=Uf.pollingInterval),p(this,Jn,s)}_getSubscriber(t){const n=super._getSubscriber(t);return Eh(n)&&(n.pollingInterval=u(this,Jn)),n}get pollingInterval(){return u(this,Jn)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");p(this,Jn,t),this._forEachSubscriber(n=>{Eh(n)&&(n.pollingInterval=u(this,Jn))})}}Jn=new WeakMap;var mi;class Ff extends Df{constructor(t,n,s){t==null&&(t="http://localhost:8545");super(n,s);A(this,mi,void 0);typeof t=="string"?p(this,mi,new Qt(t)):p(this,mi,t.clone())}_getConnection(){return u(this,mi).clone()}async send(t,n){return await this._start(),await super.send(t,n)}async _send(t){const n=this._getConnection();n.body=JSON.stringify(t),n.setHeader("content-type","application/json");const s=await n.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}mi=new WeakMap;function Nl(r){if(r==null)return null;if(typeof r.message=="string"&&r.message.match(/revert/i)&&X(r.data))return{message:r.message,data:r.data};if(typeof r=="object"){for(const e in r){const t=Nl(r[e]);if(t)return t}return null}if(typeof r=="string")try{return Nl(JSON.parse(r))}catch{}return null}function Sl(r,e){if(r!=null){if(typeof r.message=="string"&&e.push(r.message),typeof r=="object")for(const t in r)Sl(r[t],e);if(typeof r=="string")try{return Sl(JSON.parse(r),e)}catch{}}}function qy(r){const e=[];return Sl(r,e),e}function Zy(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof b.global<"u")return b.global;throw new Error("unable to locate global object")}const $y=Zy().WebSocket;var Ft,So,qn,Mr,Zn;class ql{constructor(e,t){A(this,Ft,void 0);A(this,So,void 0);A(this,qn,void 0);A(this,Mr,void 0);A(this,Zn,void 0);p(this,Ft,e),p(this,So,JSON.stringify(t)),p(this,qn,null),p(this,Mr,null),p(this,Zn,null)}get filter(){return JSON.parse(u(this,So))}start(){p(this,qn,u(this,Ft).send("eth_subscribe",this.filter).then(e=>(u(this,Ft)._register(e,this),e)))}stop(){u(this,qn).then(e=>{u(this,Ft).destroyed||u(this,Ft).send("eth_unsubscribe",[e])}),p(this,qn,null)}pause(e){I(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),p(this,Mr,!!e)}resume(){p(this,Mr,null)}_handleMessage(e){if(u(this,qn)!=null&&u(this,Mr)===null){let t=u(this,Zn);t==null?t=this._emit(u(this,Ft),e):t=t.then(async()=>{await this._emit(u(this,Ft),e)}),p(this,Zn,t.then(()=>{u(this,Zn)===t&&p(this,Zn,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Ft=new WeakMap,So=new WeakMap,qn=new WeakMap,Mr=new WeakMap,Zn=new WeakMap;class Yy extends ql{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class Xy extends ql{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}var ko;class ew extends ql{constructor(t,n){super(t,["logs",n]);A(this,ko,void 0);p(this,ko,JSON.stringify(n))}get logFilter(){return JSON.parse(u(this,ko))}async _emit(t,n){t.emit(this.logFilter,t._wrapLog(n,t._network))}}ko=new WeakMap;var Dr,yi,$n;class tw extends Mf{constructor(t,n){const s=Object.assign({},n??{});y(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",n),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);A(this,Dr,void 0);A(this,yi,void 0);A(this,$n,void 0);p(this,Dr,new Map),p(this,yi,new Map),p(this,$n,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Sa("close");case"block":return new Yy(this);case"pending":return new Xy(this);case"event":return new ew(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Sa("drop-log")}return super._getSubscriber(t)}_register(t,n){u(this,yi).set(t,n);const s=u(this,$n).get(t);if(s){for(const i of s)n._handleMessage(i);u(this,$n).delete(t)}}async _send(t){y(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const n=new Promise((s,i)=>{u(this,Dr).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await n]}async _processMessage(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&"id"in n){const s=u(this,Dr).get(n.id);if(s==null){this.emit("error",ne("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:n}));return}u(this,Dr).delete(n.id),s.resolve(n)}else if(n&&n.method==="eth_subscription"){const s=n.params.subscription,i=u(this,yi).get(s);if(i)i._handleMessage(n.params.result);else{let o=u(this,$n).get(s);o==null&&(o=[],u(this,$n).set(s,o)),o.push(n.params.result)}}else{this.emit("error",ne("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:n}));return}}async _write(t){throw new Error("sub-classes must override this")}}Dr=new WeakMap,yi=new WeakMap,$n=new WeakMap;var Fr,Et;class nw extends tw{constructor(t,n,s){super(n,s);A(this,Fr,void 0);A(this,Et,void 0);typeof t=="string"?(p(this,Fr,()=>new $y(t)),p(this,Et,u(this,Fr).call(this))):typeof t=="function"?(p(this,Fr,t),p(this,Et,t())):(p(this,Fr,null),p(this,Et,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(u(this,Et)==null)throw new Error("websocket closed");return u(this,Et)}async _write(t){this.websocket.send(t)}async destroy(){u(this,Et)!=null&&(u(this,Et).close(),p(this,Et,null)),super.destroy()}}Fr=new WeakMap,Et=new WeakMap;const Ki="84842078b09946638c03157f83405213";function rw(r){switch(r){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}y(!1,"unsupported network","network",r)}class sw extends nw{constructor(t,n){const s=new Jr(t,n),i=s._getConnection();I(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);E(this,"projectId");E(this,"projectSecret");F(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===Ki}}class Jr extends Ff{constructor(t,n,s){t==null&&(t="mainnet");const i=vt.from(t);n==null&&(n=Ki),s==null&&(s=null);const o=Jr.getRequest(i,n,s);super(o,i,{staticNetwork:i});E(this,"projectId");E(this,"projectSecret");F(this,{projectId:n,projectSecret:s})}_getProvider(t){try{return new Jr(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===Ki}static getWebSocketProvider(t,n){return new sw(t,n)}static getRequest(t,n,s){n==null&&(n=Ki),s==null&&(s=null);const i=new Qt(`https://${rw(t.name)}/v3/${n}`);return i.allowGzip=!0,s&&i.setCredentials("",s),n===Ki&&(i.retryFunc=async(o,a,c)=>(jy("InfuraProvider"),!0)),i}}var wi;class Mc extends Df{constructor(t,n,s){const i=Object.assign({},s??{},{batchMaxCount:1});y(t&&t.request,"invalid EIP-1193 provider","ethereum",t);super(n,i);A(this,wi,void 0);p(this,wi,async(o,a)=>{const c={method:o,params:a};this.emit("debug",{action:"sendEip1193Request",payload:c});try{const l=await t.request(c);return this.emit("debug",{action:"receiveEip1193Result",result:l}),l}catch(l){const h=new Error(l.message);throw h.code=l.code,h.data=l.data,h.payload=c,this.emit("debug",{action:"receiveEip1193Error",error:h}),h}})}async send(t,n){return await this._start(),await super.send(t,n)}async _send(t){y(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const n=await u(this,wi).call(this,t.method,t.params||[]);return[{id:t.id,result:n}]}catch(n){return[{id:t.id,error:{code:n.code,data:n.data,message:n.message}}]}}getRpcError(t,n){switch(n=JSON.parse(JSON.stringify(n)),n.error.code||-1){case 4001:n.error.message=`ethers-user-denied: ${n.error.message}`;break;case 4200:n.error.message=`ethers-unsupported: ${n.error.message}`;break}return super.getRpcError(t,n)}async hasSigner(t){t==null&&(t=0);const n=await this.send("eth_accounts",[]);return typeof t=="number"?n.length>t:(t=t.toLowerCase(),n.filter(s=>s.toLowerCase()===t).length!==0)}async getSigner(t){if(t==null&&(t=0),!await this.hasSigner(t))try{await u(this,wi).call(this,"eth_requestAccounts",[])}catch(n){const s=n.payload;throw this.getRpcError(s,{id:s.id,error:n})}return await super.getSigner(t)}}wi=new WeakMap;const Pn={signMessage:async(r,e,t)=>{if(!e)throw new Error("signMessage - provider is undefined");const n=X(r)?r:T(jt(r));return await e.request({method:"personal_sign",params:[n,t]})},estimateGas:async(r,e,t,n)=>{if(!e)throw new Error("estimateGas - provider is undefined");if(!t)throw new Error("estimateGas - address is undefined");if(r.chainNamespace&&r.chainNamespace!=="eip155")throw new Error("estimateGas - chainNamespace is not eip155");const s={from:r.address,to:r.to,data:r.data,type:0},i=new Mc(e,n);return await new ks(i,t).estimateGas(s)},sendTransaction:async(r,e,t,n)=>{if(!e)throw new Error("sendTransaction - provider is undefined");if(!t)throw new Error("sendTransaction - address is undefined");if(r.chainNamespace&&r.chainNamespace!=="eip155")throw new Error("sendTransaction - chainNamespace is not eip155");const s={to:r.to,value:r.value,gasLimit:r.gas,gasPrice:r.gasPrice,data:r.data,type:0},i=new Mc(e,n),c=await(await new ks(i,t).sendTransaction(s)).wait();return(c==null?void 0:c.hash)||null},writeContract:async(r,e,t,n)=>{if(!e)throw new Error("writeContract - provider is undefined");if(!t)throw new Error("writeContract - address is undefined");const s=new Mc(e,n),i=new ks(s,t),o=new Ss(r.tokenAddress,r.abi,i);if(!o||!r.method)throw new Error("Contract method is undefined");const a=o[r.method];if(a)return await a(r.receiverAddress,r.tokenAmount);throw new Error("Contract method is undefined")},getEnsAddress:async(r,e)=>{var t;try{const n=Number((t=e.getCaipNetwork())==null?void 0:t.id);let s=null,i=!1;return b.isReownName(r)&&(i=await(e==null?void 0:e.resolveReownName(r))||!1),n===1&&(s=await new Jr("mainnet").resolveName(r)),s||i||!1}catch{return!1}},getEnsAvatar:async(r,e)=>e===1&&await new Jr("mainnet").getAvatar(r)||!1,parseUnits:Kp,formatUnits:rd};var Hf={},no={},$a={};Object.defineProperty($a,"__esModule",{value:!0});$a.walletLogo=void 0;const iw=(r,e)=>{let t;switch(r){case"standard":return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return t=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${t}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return t=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return t=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${t}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return t=e,`data:image/svg+xml,%3Csvg width='${e}' height='${t}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};$a.walletLogo=iw;var Ya={},zt={},An={};Object.defineProperty(An,"__esModule",{value:!0});An.errorValues=An.standardErrorCodes=void 0;An.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};An.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var Xa={},Zl={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.serialize=r.getErrorCode=r.isValidCode=r.getMessageFromCode=r.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=An,t="Unspecified error message.";r.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function n(f,g=t){if(f&&Number.isInteger(f)){const w=f.toString();if(h(e.errorValues,w))return e.errorValues[w].message;if(c(f))return r.JSON_RPC_SERVER_ERROR_MESSAGE}return g}r.getMessageFromCode=n;function s(f){if(!Number.isInteger(f))return!1;const g=f.toString();return!!(e.errorValues[g]||c(f))}r.isValidCode=s;function i(f){var g;if(typeof f=="number")return f;if(o(f))return(g=f.code)!==null&&g!==void 0?g:f.errorCode}r.getErrorCode=i;function o(f){return typeof f=="object"&&f!==null&&(typeof f.code=="number"||typeof f.errorCode=="number")}function a(f,{shouldIncludeStack:g=!1}={}){const w={};if(f&&typeof f=="object"&&!Array.isArray(f)&&h(f,"code")&&s(f.code)){const m=f;w.code=m.code,m.message&&typeof m.message=="string"?(w.message=m.message,h(m,"data")&&(w.data=m.data)):(w.message=n(w.code),w.data={originalError:l(f)})}else w.code=e.standardErrorCodes.rpc.internal,w.message=d(f,"message")?f.message:t,w.data={originalError:l(f)};return g&&(w.stack=d(f,"stack")?f.stack:void 0),w}r.serialize=a;function c(f){return f>=-32099&&f<=-32e3}function l(f){return f&&typeof f=="object"&&!Array.isArray(f)?Object.assign({},f):f}function h(f,g){return Object.prototype.hasOwnProperty.call(f,g)}function d(f,g){return typeof f=="object"&&f!==null&&g in f&&typeof f[g]=="string"}})(Zl);Object.defineProperty(Xa,"__esModule",{value:!0});Xa.standardErrors=void 0;const be=An,Gf=Zl;Xa.standardErrors={rpc:{parse:r=>et(be.standardErrorCodes.rpc.parse,r),invalidRequest:r=>et(be.standardErrorCodes.rpc.invalidRequest,r),invalidParams:r=>et(be.standardErrorCodes.rpc.invalidParams,r),methodNotFound:r=>et(be.standardErrorCodes.rpc.methodNotFound,r),internal:r=>et(be.standardErrorCodes.rpc.internal,r),server:r=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=r;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return et(e,r)},invalidInput:r=>et(be.standardErrorCodes.rpc.invalidInput,r),resourceNotFound:r=>et(be.standardErrorCodes.rpc.resourceNotFound,r),resourceUnavailable:r=>et(be.standardErrorCodes.rpc.resourceUnavailable,r),transactionRejected:r=>et(be.standardErrorCodes.rpc.transactionRejected,r),methodNotSupported:r=>et(be.standardErrorCodes.rpc.methodNotSupported,r),limitExceeded:r=>et(be.standardErrorCodes.rpc.limitExceeded,r)},provider:{userRejectedRequest:r=>os(be.standardErrorCodes.provider.userRejectedRequest,r),unauthorized:r=>os(be.standardErrorCodes.provider.unauthorized,r),unsupportedMethod:r=>os(be.standardErrorCodes.provider.unsupportedMethod,r),disconnected:r=>os(be.standardErrorCodes.provider.disconnected,r),chainDisconnected:r=>os(be.standardErrorCodes.provider.chainDisconnected,r),unsupportedChain:r=>os(be.standardErrorCodes.provider.unsupportedChain,r),custom:r=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:t,data:n}=r;if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string');return new Wf(e,t,n)}}};function et(r,e){const[t,n]=Kf(e);return new jf(r,t||(0,Gf.getMessageFromCode)(r),n)}function os(r,e){const[t,n]=Kf(e);return new Wf(r,t||(0,Gf.getMessageFromCode)(r),n)}function Kf(r){if(r){if(typeof r=="string")return[r];if(typeof r=="object"&&!Array.isArray(r)){const{message:e,data:t}=r;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,t]}}return[]}class jf extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||typeof t!="string")throw new Error('"message" must be a nonempty string.');super(t),this.code=e,n!==void 0&&(this.data=n)}}class Wf extends jf{constructor(e,t,n){if(!ow(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}}function ow(r){return Number.isInteger(r)&&r>=1e3&&r<=4999}(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.standardErrors=r.standardErrorCodes=void 0;var e=An;Object.defineProperty(r,"standardErrorCodes",{enumerable:!0,get:function(){return e.standardErrorCodes}});var t=Xa;Object.defineProperty(r,"standardErrors",{enumerable:!0,get:function(){return t.standardErrors}})})(zt);var ec={},Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});Ri.isErrorResponse=void 0;function aw(r){return r.errorMessage!==void 0}Ri.isErrorResponse=aw;var Zr={};Object.defineProperty(Zr,"__esModule",{value:!0});Zr.LIB_VERSION=void 0;Zr.LIB_VERSION="4.0.3";Object.defineProperty(ec,"__esModule",{value:!0});ec.serializeError=void 0;const cw=Ri,lw=Zr,uw=An,hw=Zl;function dw(r,e){const t=(0,hw.serialize)(fw(r),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");n.searchParams.set("version",lw.LIB_VERSION),n.searchParams.set("code",t.code.toString());const s=pw(t.data,e);return s&&n.searchParams.set("method",s),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}ec.serializeError=dw;function fw(r){return typeof r=="string"?{message:r,code:uw.standardErrorCodes.rpc.internal}:(0,cw.isErrorResponse)(r)?Object.assign(Object.assign({},r),{message:r.errorMessage,code:r.errorCode,data:{method:r.method}}):r}function pw(r,e){const t=r==null?void 0:r.method;if(t)return t;if(e!==void 0){if(typeof e=="string")return e;if(Array.isArray(e)){if(e.length>0)return e[0].method}else return e.method}}var Se={};Object.defineProperty(Se,"__esModule",{value:!0});Se.RegExpString=Se.IntNumber=Se.BigIntString=Se.AddressString=Se.HexString=Se.OpaqueType=void 0;function _o(){return r=>r}Se.OpaqueType=_o;Se.HexString=_o();Se.AddressString=_o();Se.BigIntString=_o();function gw(r){return Math.floor(r)}Se.IntNumber=gw;Se.RegExpString=_o();var U={};Object.defineProperty(U,"__esModule",{value:!0});U.areAddressArraysEqual=U.getFavicon=U.range=U.isBigNumber=U.ensureParsedJSONObject=U.ensureBigInt=U.ensureRegExpString=U.ensureIntNumber=U.ensureBuffer=U.ensureAddressString=U.ensureEvenLengthHexString=U.ensureHexString=U.isHexString=U.prepend0x=U.strip0x=U.has0xPrefix=U.hexStringFromIntNumber=U.intNumberFromHexString=U.bigIntStringFromBigInt=U.hexStringFromBuffer=U.hexStringToUint8Array=U.uint8ArrayToHex=U.randomBytesHex=void 0;const $r=zt,lt=Se,Vf=/^[0-9]*$/,Qf=/^[a-f0-9]*$/;function mw(r){return zf(crypto.getRandomValues(new Uint8Array(r)))}U.randomBytesHex=mw;function zf(r){return[...r].map(e=>e.toString(16).padStart(2,"0")).join("")}U.uint8ArrayToHex=zf;function yw(r){return new Uint8Array(r.match(/.{1,2}/g).map(e=>parseInt(e,16)))}U.hexStringToUint8Array=yw;function ww(r,e=!1){const t=r.toString("hex");return(0,lt.HexString)(e?`0x${t}`:t)}U.hexStringFromBuffer=ww;function bw(r){return(0,lt.BigIntString)(r.toString(10))}U.bigIntStringFromBigInt=bw;function Aw(r){return(0,lt.IntNumber)(Number(BigInt(Uo(r,!0))))}U.intNumberFromHexString=Aw;function Ew(r){return(0,lt.HexString)(`0x${BigInt(r).toString(16)}`)}U.hexStringFromIntNumber=Ew;function $l(r){return r.startsWith("0x")||r.startsWith("0X")}U.has0xPrefix=$l;function tc(r){return $l(r)?r.slice(2):r}U.strip0x=tc;function Jf(r){return $l(r)?`0x${r.slice(2)}`:`0x${r}`}U.prepend0x=Jf;function Lo(r){if(typeof r!="string")return!1;const e=tc(r).toLowerCase();return Qf.test(e)}U.isHexString=Lo;function qf(r,e=!1){if(typeof r=="string"){const t=tc(r).toLowerCase();if(Qf.test(t))return(0,lt.HexString)(e?`0x${t}`:t)}throw $r.standardErrors.rpc.invalidParams(`"${String(r)}" is not a hexadecimal string`)}U.ensureHexString=qf;function Uo(r,e=!1){let t=qf(r,!1);return t.length%2===1&&(t=(0,lt.HexString)(`0${t}`)),e?(0,lt.HexString)(`0x${t}`):t}U.ensureEvenLengthHexString=Uo;function Cw(r){if(typeof r=="string"){const e=tc(r).toLowerCase();if(Lo(e)&&e.length===40)return(0,lt.AddressString)(Jf(e))}throw $r.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(r)}`)}U.ensureAddressString=Cw;function vw(r){if(b.Buffer.isBuffer(r))return r;if(typeof r=="string"){if(Lo(r)){const e=Uo(r,!1);return b.Buffer.from(e,"hex")}return b.Buffer.from(r,"utf8")}throw $r.standardErrors.rpc.invalidParams(`Not binary data: ${String(r)}`)}U.ensureBuffer=vw;function Zf(r){if(typeof r=="number"&&Number.isInteger(r))return(0,lt.IntNumber)(r);if(typeof r=="string"){if(Vf.test(r))return(0,lt.IntNumber)(Number(r));if(Lo(r))return(0,lt.IntNumber)(Number(BigInt(Uo(r,!0))))}throw $r.standardErrors.rpc.invalidParams(`Not an integer: ${String(r)}`)}U.ensureIntNumber=Zf;function Iw(r){if(r instanceof RegExp)return(0,lt.RegExpString)(r.toString());throw $r.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(r)}`)}U.ensureRegExpString=Iw;function Nw(r){if(r!==null&&(typeof r=="bigint"||$f(r)))return BigInt(r.toString(10));if(typeof r=="number")return BigInt(Zf(r));if(typeof r=="string"){if(Vf.test(r))return BigInt(r);if(Lo(r))return BigInt(Uo(r,!0))}throw $r.standardErrors.rpc.invalidParams(`Not an integer: ${String(r)}`)}U.ensureBigInt=Nw;function Sw(r){if(typeof r=="string")return JSON.parse(r);if(typeof r=="object")return r;throw $r.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(r)}`)}U.ensureParsedJSONObject=Sw;function $f(r){if(r==null||typeof r.constructor!="function")return!1;const{constructor:e}=r;return typeof e.config=="function"&&typeof e.EUCLID=="number"}U.isBigNumber=$f;function kw(r,e){return Array.from({length:e-r},(t,n)=>r+n)}U.range=kw;function xw(){const r=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:t}=document.location,n=r?r.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${t}${n}`}U.getFavicon=xw;function Pw(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}U.areAddressArraysEqual=Pw;var Kt={},nc={},rc={},he={};Object.defineProperty(he,"__esModule",{value:!0});he.decryptContent=he.encryptContent=he.importKeyFromHexString=he.exportKeyToHexString=he.decrypt=he.encrypt=he.deriveSharedSecret=he.generateKeyPair=void 0;const Yf=U;async function Rw(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}he.generateKeyPair=Rw;async function Ow(r,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}he.deriveSharedSecret=Ow;async function Xf(r,e){const t=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},r,new TextEncoder().encode(e));return{iv:t,cipherText:n}}he.encrypt=Xf;async function ep(r,{iv:e,cipherText:t}){const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},r,t);return new TextDecoder().decode(n)}he.decrypt=ep;function tp(r){switch(r){case"public":return"spki";case"private":return"pkcs8"}}async function Tw(r,e){const t=tp(r),n=await crypto.subtle.exportKey(t,e);return(0,Yf.uint8ArrayToHex)(new Uint8Array(n))}he.exportKeyToHexString=Tw;async function Bw(r,e){const t=tp(r),n=(0,Yf.hexStringToUint8Array)(e).buffer;return await crypto.subtle.importKey(t,n,{name:"ECDH",namedCurve:"P-256"},!0,r==="private"?["deriveKey"]:[])}he.importKeyFromHexString=Bw;async function _w(r,e){const t=JSON.stringify(r,(n,s)=>{if(!(s instanceof Error))return s;const i=s;return Object.assign(Object.assign({},i.code?{code:i.code}:{}),{message:i.message})});return Xf(e,t)}he.encryptContent=_w;async function Lw(r,e){return JSON.parse(await ep(e,r))}he.decryptContent=Lw;var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.ScopedLocalStorage=void 0;class ka{constructor(e,t){this.scope=e,this.module=t}setItem(e,t){localStorage.setItem(this.scopedKey(e),t)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),t=[];for(let n=0;n<localStorage.length;n++){const s=localStorage.key(n);typeof s=="string"&&s.startsWith(e)&&t.push(s)}t.forEach(n=>localStorage.removeItem(n))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new ka("CBWSDK").clear(),new ka("walletlink").clear()}}Jt.ScopedLocalStorage=ka;Object.defineProperty(rc,"__esModule",{value:!0});rc.SCWKeyManager=void 0;const Jo=he,Uw=Jt,Dc={storageKey:"ownPrivateKey",keyType:"private"},Fc={storageKey:"ownPublicKey",keyType:"public"},Hc={storageKey:"peerPublicKey",keyType:"public"};class Mw{constructor(){this.storage=new Uw.ScopedLocalStorage("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey(Hc,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(Fc.storageKey),this.storage.removeItem(Dc.storageKey),this.storage.removeItem(Hc.storageKey)}async generateKeyPair(){const e=await(0,Jo.generateKeyPair)();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(Dc,e.privateKey),await this.storeKey(Fc,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Dc)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(Fc)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(Hc)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await(0,Jo.deriveSharedSecret)(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const t=this.storage.getItem(e.storageKey);return t?(0,Jo.importKeyFromHexString)(e.keyType,t):null}async storeKey(e,t){const n=await(0,Jo.exportKeyToHexString)(e.keyType,t);this.storage.setItem(e.storageKey,n)}}rc.SCWKeyManager=Mw;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});sc.SCWStateManager=void 0;const Dw=Jt,Ch="accounts",vh="activeChain",Ih="availableChains",Nh="walletCapabilities";class Fw{get accounts(){return this._accounts}get activeChain(){return this._activeChain}get walletCapabilities(){return this._walletCapabilities}constructor(e){var t,n;this.storage=new Dw.ScopedLocalStorage("CBWSDK","SCWStateManager"),this.updateListener=e.updateListener,this.availableChains=this.loadItemFromStorage(Ih),this._walletCapabilities=this.loadItemFromStorage(Nh);const s=this.loadItemFromStorage(Ch),i=this.loadItemFromStorage(vh);s&&this.updateListener.onAccountsUpdate({accounts:s,source:"storage"}),i&&this.updateListener.onChainUpdate({chain:i,source:"storage"}),this._accounts=s||[],this._activeChain=i||{id:(n=(t=e.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1}}updateAccounts(e){this._accounts=e,this.storeItemToStorage(Ch,e),this.updateListener.onAccountsUpdate({accounts:e,source:"wallet"})}switchChain(e){var t;const n=(t=this.availableChains)===null||t===void 0?void 0:t.find(s=>s.id===e);return n?(n===this._activeChain||(this._activeChain=n,this.storeItemToStorage(vh,n),this.updateListener.onChainUpdate({chain:n,source:"wallet"})),!0):!1}updateAvailableChains(e){if(!e||Object.keys(e).length===0)return;const t=Object.entries(e).map(([n,s])=>({id:Number(n),rpcUrl:s}));this.availableChains=t,this.storeItemToStorage(Ih,t),this.switchChain(this._activeChain.id)}updateWalletCapabilities(e){this._walletCapabilities=e,this.storeItemToStorage(Nh,e)}storeItemToStorage(e,t){this.storage.setItem(e,JSON.stringify(t))}loadItemFromStorage(e){const t=this.storage.getItem(e);return t?JSON.parse(t):void 0}clear(){this.storage.clear()}}sc.SCWStateManager=Fw;Object.defineProperty(nc,"__esModule",{value:!0});nc.SCWSigner=void 0;const Hw=rc,Gw=sc,qo=zt,Sh=U,Zo=he;class Kw{constructor(e){this.metadata=e.metadata,this.communicator=e.communicator,this.keyManager=new Hw.SCWKeyManager,this.stateManager=new Gw.SCWStateManager({appChainIds:this.metadata.appChainIds,updateListener:e.updateListener}),this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(){const e=await this.createRequestMessage({handshake:{method:"eth_requestAccounts",params:this.metadata}}),t=await this.communicator.postRequestAndWaitForResponse(e);if("failure"in t.content)throw t.content.failure;const n=await(0,Zo.importKeyFromHexString)("public",t.sender);await this.keyManager.setPeerPublicKey(n);const s=await this.decryptResponseMessage(t);this.updateInternalState({method:"eth_requestAccounts"},s);const i=s.result;if("error"in i)throw i.error;return this.stateManager.accounts}async request(e){const t=this.tryLocalHandling(e);if(t!==void 0){if(t instanceof Error)throw t;return t}await this.communicator.waitForPopupLoaded();const n=await this.sendEncryptedRequest(e),s=await this.decryptResponseMessage(n);this.updateInternalState(e,s);const i=s.result;if("error"in i)throw i.error;return i.value}async disconnect(){this.stateManager.clear(),await this.keyManager.clear()}tryLocalHandling(e){var t;switch(e.method){case"wallet_switchEthereumChain":{const n=e.params;if(!n||!(!((t=n[0])===null||t===void 0)&&t.chainId))throw qo.standardErrors.rpc.invalidParams();const s=(0,Sh.ensureIntNumber)(n[0].chainId);return this.stateManager.switchChain(s)?null:void 0}case"wallet_getCapabilities":{const n=this.stateManager.walletCapabilities;if(!n)throw qo.standardErrors.provider.unauthorized("No wallet capabilities found, please disconnect and reconnect");return n}default:return}}async sendEncryptedRequest(e){const t=await this.keyManager.getSharedSecret();if(!t)throw qo.standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await(0,Zo.encryptContent)({action:e,chainId:this.stateManager.activeChain.id},t),s=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(s)}async createRequestMessage(e){const t=await(0,Zo.exportKeyToHexString)("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:t,content:e,timestamp:new Date}}async decryptResponseMessage(e){const t=e.content;if("failure"in t)throw t.failure;const n=await this.keyManager.getSharedSecret();if(!n)throw qo.standardErrors.provider.unauthorized("Invalid session");return(0,Zo.decryptContent)(t.encrypted,n)}updateInternalState(e,t){var n,s;const i=(n=t.data)===null||n===void 0?void 0:n.chains;i&&this.stateManager.updateAvailableChains(i);const o=(s=t.data)===null||s===void 0?void 0:s.capabilities;o&&this.stateManager.updateWalletCapabilities(o);const a=t.result;if(!("error"in a))switch(e.method){case"eth_requestAccounts":{const c=a.value;this.stateManager.updateAccounts(c);break}case"wallet_switchEthereumChain":{if(a.value!==null)return;const c=e.params,l=(0,Sh.ensureIntNumber)(c[0].chainId);this.stateManager.switchChain(l);break}}}}nc.SCWSigner=Kw;var ic={};const jw=Es.js;function np(r){return b.Buffer.allocUnsafe(r).fill(0)}function Ww(r){return r.toString(2).length}function rp(r,e){let t=r.toString(16);t.length%2!==0&&(t="0"+t);const n=t.match(/.{1,2}/g).map(s=>parseInt(s,16));for(;n.length<e;)n.unshift(0);return b.Buffer.from(n)}function Vw(r,e){const t=r<0n;let n;if(t){const s=(1n<<BigInt(e))-1n;n=(~r&s)+1n}else n=r;return n&=(1n<<BigInt(e))-1n,n}function sp(r,e,t){const n=np(e);return r=oc(r),t?r.length<e?(r.copy(n),n):r.slice(0,e):r.length<e?(r.copy(n,e-r.length),n):r.slice(-e)}function Qw(r,e){return sp(r,e,!0)}function oc(r){if(!b.Buffer.isBuffer(r))if(Array.isArray(r))r=b.Buffer.from(r);else if(typeof r=="string")ip(r)?r=b.Buffer.from(qw(op(r)),"hex"):r=b.Buffer.from(r);else if(typeof r=="number")r=intToBuffer(r);else if(r==null)r=b.Buffer.allocUnsafe(0);else if(typeof r=="bigint")r=rp(r);else if(r.toArray)r=b.Buffer.from(r.toArray());else throw new Error("invalid type");return r}function zw(r){return r=oc(r),"0x"+r.toString("hex")}function Jw(r,e){return r=oc(r),e||(e=256),jw("keccak"+e).update(r).digest()}function qw(r){return r.length%2?"0"+r:r}function ip(r){return typeof r=="string"&&r.match(/^0x[0-9A-Fa-f]*$/)}function op(r){return typeof r=="string"&&r.startsWith("0x")?r.slice(2):r}var ap={zeros:np,setLength:sp,setLengthRight:Qw,isHexString:ip,stripHexPrefix:op,toBuffer:oc,bufferToHex:zw,keccak:Jw,bitLengthFromBigInt:Ww,bufferBEFromBigInt:rp,twosFromBigInt:Vw};const Be=ap;function cp(r){return r.startsWith("int[")?"int256"+r.slice(3):r==="int"?"int256":r.startsWith("uint[")?"uint256"+r.slice(4):r==="uint"?"uint256":r.startsWith("fixed[")?"fixed128x128"+r.slice(5):r==="fixed"?"fixed128x128":r.startsWith("ufixed[")?"ufixed128x128"+r.slice(6):r==="ufixed"?"ufixed128x128":r}function xs(r){return parseInt(/^\D+(\d+)$/.exec(r)[1],10)}function kh(r){var e=/^\D+(\d+)x(\d+)$/.exec(r);return[parseInt(e[1],10),parseInt(e[2],10)]}function lp(r){var e=r.match(/(.*)\[(.*?)\]$/);return e?e[2]===""?"dynamic":parseInt(e[2],10):null}function ar(r){var e=typeof r;if(e==="string"||e==="number")return BigInt(r);if(e==="bigint")return r;throw new Error("Argument is not a number")}function Pt(r,e){var t,n,s,i;if(r==="address")return Pt("uint160",ar(e));if(r==="bool")return Pt("uint8",e?1:0);if(r==="string")return Pt("bytes",new b.Buffer(e,"utf8"));if($w(r)){if(typeof e.length>"u")throw new Error("Not an array?");if(t=lp(r),t!=="dynamic"&&t!==0&&e.length>t)throw new Error("Elements exceed array size: "+t);s=[],r=r.slice(0,r.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(i in e)s.push(Pt(r,e[i]));if(t==="dynamic"){var o=Pt("uint256",e.length);s.unshift(o)}return b.Buffer.concat(s)}else{if(r==="bytes")return e=new b.Buffer(e),s=b.Buffer.concat([Pt("uint256",e.length),e]),e.length%32!==0&&(s=b.Buffer.concat([s,Be.zeros(32-e.length%32)])),s;if(r.startsWith("bytes")){if(t=xs(r),t<1||t>32)throw new Error("Invalid bytes<N> width: "+t);return Be.setLengthRight(e,32)}else if(r.startsWith("uint")){if(t=xs(r),t%8||t<8||t>256)throw new Error("Invalid uint<N> width: "+t);n=ar(e);const a=Be.bitLengthFromBigInt(n);if(a>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+a);if(n<0)throw new Error("Supplied uint is negative");return Be.bufferBEFromBigInt(n,32)}else if(r.startsWith("int")){if(t=xs(r),t%8||t<8||t>256)throw new Error("Invalid int<N> width: "+t);n=ar(e);const a=Be.bitLengthFromBigInt(n);if(a>t)throw new Error("Supplied int exceeds width: "+t+" vs "+a);const c=Be.twosFromBigInt(n,256);return Be.bufferBEFromBigInt(c,32)}else if(r.startsWith("ufixed")){if(t=kh(r),n=ar(e),n<0)throw new Error("Supplied ufixed is negative");return Pt("uint256",n*BigInt(2)**BigInt(t[1]))}else if(r.startsWith("fixed"))return t=kh(r),Pt("int256",ar(e)*BigInt(2)**BigInt(t[1]))}throw new Error("Unsupported or invalid type: "+r)}function Zw(r){return r==="string"||r==="bytes"||lp(r)==="dynamic"}function $w(r){return r.lastIndexOf("]")===r.length-1}function Yw(r,e){var t=[],n=[],s=32*r.length;for(var i in r){var o=cp(r[i]),a=e[i],c=Pt(o,a);Zw(o)?(t.push(Pt("uint256",s)),n.push(c),s+=c.length):t.push(c)}return b.Buffer.concat(t.concat(n))}function up(r,e){if(r.length!==e.length)throw new Error("Number of types are not matching the values");for(var t,n,s=[],i=0;i<r.length;i++){var o=cp(r[i]),a=e[i];if(o==="bytes")s.push(a);else if(o==="string")s.push(new b.Buffer(a,"utf8"));else if(o==="bool")s.push(new b.Buffer(a?"01":"00","hex"));else if(o==="address")s.push(Be.setLength(a,20));else if(o.startsWith("bytes")){if(t=xs(o),t<1||t>32)throw new Error("Invalid bytes<N> width: "+t);s.push(Be.setLengthRight(a,t))}else if(o.startsWith("uint")){if(t=xs(o),t%8||t<8||t>256)throw new Error("Invalid uint<N> width: "+t);n=ar(a);const c=Be.bitLengthFromBigInt(n);if(c>t)throw new Error("Supplied uint exceeds width: "+t+" vs "+c);s.push(Be.bufferBEFromBigInt(n,t/8))}else if(o.startsWith("int")){if(t=xs(o),t%8||t<8||t>256)throw new Error("Invalid int<N> width: "+t);n=ar(a);const c=Be.bitLengthFromBigInt(n);if(c>t)throw new Error("Supplied int exceeds width: "+t+" vs "+c);const l=Be.twosFromBigInt(n,t);s.push(Be.bufferBEFromBigInt(l,t/8))}else throw new Error("Unsupported or invalid type: "+o)}return b.Buffer.concat(s)}function Xw(r,e){return Be.keccak(up(r,e))}var eb={rawEncode:Yw,solidityPack:up,soliditySHA3:Xw};const ht=ap,Wi=eb,hp={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Gc={encodeData(r,e,t,n=!0){const s=["bytes32"],i=[this.hashType(r,t)];if(n){const o=(a,c,l)=>{if(t[c]!==void 0)return["bytes32",l==null?"0x0000000000000000000000000000000000000000000000000000000000000000":ht.keccak(this.encodeData(c,l,t,n))];if(l===void 0)throw new Error(`missing value for field ${a} of type ${c}`);if(c==="bytes")return["bytes32",ht.keccak(l)];if(c==="string")return typeof l=="string"&&(l=b.Buffer.from(l,"utf8")),["bytes32",ht.keccak(l)];if(c.lastIndexOf("]")===c.length-1){const h=c.slice(0,c.lastIndexOf("[")),d=l.map(f=>o(a,h,f));return["bytes32",ht.keccak(Wi.rawEncode(d.map(([f])=>f),d.map(([,f])=>f)))]}return[c,l]};for(const a of t[r]){const[c,l]=o(a.name,a.type,e[a.name]);s.push(c),i.push(l)}}else for(const o of t[r]){let a=e[o.name];if(a!==void 0)if(o.type==="bytes")s.push("bytes32"),a=ht.keccak(a),i.push(a);else if(o.type==="string")s.push("bytes32"),typeof a=="string"&&(a=b.Buffer.from(a,"utf8")),a=ht.keccak(a),i.push(a);else if(t[o.type]!==void 0)s.push("bytes32"),a=ht.keccak(this.encodeData(o.type,a,t,n)),i.push(a);else{if(o.type.lastIndexOf("]")===o.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");s.push(o.type),i.push(a)}}return Wi.rawEncode(s,i)},encodeType(r,e){let t="",n=this.findTypeDependencies(r,e).filter(s=>s!==r);n=[r].concat(n.sort());for(const s of n){if(!e[s])throw new Error("No type definition specified: "+s);t+=s+"("+e[s].map(({name:o,type:a})=>a+" "+o).join(",")+")"}return t},findTypeDependencies(r,e,t=[]){if(r=r.match(/^\w*/)[0],t.includes(r)||e[r]===void 0)return t;t.push(r);for(const n of e[r])for(const s of this.findTypeDependencies(n.type,e,t))!t.includes(s)&&t.push(s);return t},hashStruct(r,e,t,n=!0){return ht.keccak(this.encodeData(r,e,t,n))},hashType(r,e){return ht.keccak(this.encodeType(r,e))},sanitizeData(r){const e={};for(const t in hp.properties)r[t]&&(e[t]=r[t]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(r,e=!0){const t=this.sanitizeData(r),n=[b.Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",t.domain,t.types,e)),t.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(t.primaryType,t.message,t.types,e)),ht.keccak(b.Buffer.concat(n))}};var tb={TYPED_MESSAGE_SCHEMA:hp,TypedDataUtils:Gc,hashForSignTypedDataLegacy:function(r){return nb(r.data)},hashForSignTypedData_v3:function(r){return Gc.hash(r.data,!1)},hashForSignTypedData_v4:function(r){return Gc.hash(r.data)}};function nb(r){const e=new Error("Expect argument to be non-empty array");if(typeof r!="object"||!r.length)throw e;const t=r.map(function(i){return i.type==="bytes"?ht.toBuffer(i.value):i.value}),n=r.map(function(i){return i.type}),s=r.map(function(i){if(!i.name)throw e;return i.type+" "+i.name});return Wi.soliditySHA3(["bytes32","bytes32"],[Wi.soliditySHA3(new Array(r.length).fill("string"),s),Wi.soliditySHA3(n,t)])}var Wt={};Object.defineProperty(Wt,"__esModule",{value:!0});Wt.APP_VERSION_KEY=Wt.LOCAL_STORAGE_ADDRESSES_KEY=Wt.WALLET_USER_NAME_KEY=void 0;Wt.WALLET_USER_NAME_KEY="walletUsername";Wt.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";Wt.APP_VERSION_KEY="AppVersion";var Mo={};Object.defineProperty(Mo,"__esModule",{value:!0});Mo.RelayEventManager=void 0;const rb=U;class sb{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,t=(0,rb.prepend0x)(e.toString(16));return this.callbacks.get(t)&&this.callbacks.delete(t),e}}Mo.RelayEventManager=sb;var ac={},cc={},lc={};Object.defineProperty(lc,"__esModule",{value:!0});lc.WalletLinkCipher=void 0;const $o=U;class ib{constructor(e){this.secret=e}async encrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.importKey("raw",(0,$o.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),i=new TextEncoder,o=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},s,i.encode(e)),a=16,c=o.slice(o.byteLength-a),l=o.slice(0,o.byteLength-a),h=new Uint8Array(c),d=new Uint8Array(l),f=new Uint8Array([...n,...h,...d]);return(0,$o.uint8ArrayToHex)(f)}async decrypt(e){const t=this.secret;if(t.length!==64)throw Error("secret must be 256 bits");return new Promise((n,s)=>{(async function(){const i=await crypto.subtle.importKey("raw",(0,$o.hexStringToUint8Array)(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),o=(0,$o.hexStringToUint8Array)(e),a=o.slice(0,12),c=o.slice(12,28),l=o.slice(28),h=new Uint8Array([...l,...c]),d={name:"AES-GCM",iv:new Uint8Array(a)};try{const f=await window.crypto.subtle.decrypt(d,i,h),g=new TextDecoder;n(g.decode(f))}catch(f){s(f)}})()})}}lc.WalletLinkCipher=ib;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});uc.WalletLinkHTTP=void 0;class ob{constructor(e,t,n){this.linkAPIUrl=e,this.sessionId=t;const s=`${t}:${n}`;this.auth=`Basic ${btoa(s)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(t=>fetch(`${this.linkAPIUrl}/events/${t.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(t=>console.error("Unabled to mark event as failed:",t))}async fetchUnseenEvents(){var e;const t=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(t.ok){const{events:n,error:s}=await t.json();if(s)throw new Error(`Check unseen events failed: ${s}`);const i=(e=n==null?void 0:n.filter(o=>o.event==="Web3Response").map(o=>({type:"Event",sessionId:this.sessionId,eventId:o.id,event:o.event,data:o.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(i),i}throw new Error(`Check unseen events failed: ${t.status}`)}}uc.WalletLinkHTTP=ob;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});ki.WalletLinkWebSocket=ki.ConnectionState=void 0;var ys;(function(r){r[r.DISCONNECTED=0]="DISCONNECTED",r[r.CONNECTING=1]="CONNECTING",r[r.CONNECTED=2]="CONNECTED"})(ys||(ki.ConnectionState=ys={}));class ab{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,t=WebSocket){this.WebSocketClass=t,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,t)=>{var n;let s;try{this.webSocket=s=new this.WebSocketClass(this.url)}catch(i){t(i);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,ys.CONNECTING),s.onclose=i=>{var o;this.clearWebSocket(),t(new Error(`websocket error ${i.code}: ${i.reason}`)),(o=this.connectionStateListener)===null||o===void 0||o.call(this,ys.DISCONNECTED)},s.onopen=i=>{var o;e(),(o=this.connectionStateListener)===null||o===void 0||o.call(this,ys.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(c=>this.sendData(c)),this.pendingData=[])},s.onmessage=i=>{var o,a;if(i.data==="h")(o=this.incomingDataListener)===null||o===void 0||o.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(i.data);(a=this.incomingDataListener)===null||a===void 0||a.call(this,c)}catch{}}})}disconnect(){var e;const{webSocket:t}=this;if(t){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,ys.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{t.close()}catch{}}}sendData(e){const{webSocket:t}=this;if(!t){this.pendingData.push(e),this.connect();return}t.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}ki.WalletLinkWebSocket=ab;Object.defineProperty(cc,"__esModule",{value:!0});cc.WalletLinkConnection=void 0;const xh=Wt,cb=lc,lb=uc,Yo=ki,as=Se,Ph=1e4,ub=6e4;class hb{constructor({session:e,linkAPIUrl:t,listener:n,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,as.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=o=>{if(!o)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",c=>o.JsonRpcUrl&&this.handleChainUpdated(c,o.JsonRpcUrl)]]).forEach((c,l)=>{const h=o[l];h!==void 0&&c(h)})},this.handleDestroyed=o=>{var a;o==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async o=>{var a;{const c=await this.cipher.decrypt(o);(a=this.listener)===null||a===void 0||a.accountUpdated(c)}},this.handleMetadataUpdated=async(o,a)=>{var c;{const l=await this.cipher.decrypt(a);(c=this.listener)===null||c===void 0||c.metadataUpdated(o,l)}},this.handleWalletUsernameUpdated=async o=>{this.handleMetadataUpdated(xh.WALLET_USER_NAME_KEY,o)},this.handleAppVersionUpdated=async o=>{this.handleMetadataUpdated(xh.APP_VERSION_KEY,o)},this.handleChainUpdated=async(o,a)=>{var c;{const l=await this.cipher.decrypt(o),h=await this.cipher.decrypt(a);(c=this.listener)===null||c===void 0||c.chainUpdated(l,h)}},this.session=e,this.cipher=new cb.WalletLinkCipher(e.secret),this.listener=n;const i=new Yo.WalletLinkWebSocket(`${t}/rpc`,s);i.setConnectionStateListener(async o=>{let a=!1;switch(o){case Yo.ConnectionState.DISCONNECTED:if(!this.destroyed){const c=async()=>{await new Promise(l=>setTimeout(l,5e3)),this.destroyed||i.connect().catch(()=>{c()})};c()}break;case Yo.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),a=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},Ph),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case Yo.ConnectionState.CONNECTING:break}this.connected!==a&&(this.connected=a)}),i.setIncomingDataListener(o=>{var a;switch(o.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const c=o.type==="IsLinkedOK"?o.linked:void 0;this.linked=c||o.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(o.metadata);break}case"Event":{this.handleIncomingEvent(o);break}}o.id!==void 0&&((a=this.requestResolutions.get(o.id))===null||a===void 0||a(o))}),this.ws=i,this.http=new lb.WalletLinkHTTP(t,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}destroy(){this.destroyed=!0,this.ws.disconnect(),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(e){var t;this._connected=e,e&&((t=this.onceConnected)===null||t===void 0||t.call(this))}setOnceConnected(e){return new Promise(t=>{this.connected?e().then(t):this.onceConnected=()=>{e().then(t),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(e){var t,n;this._linked=e,e&&((t=this.onceLinked)===null||t===void 0||t.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(t=>{this.linked?e().then(t):this.onceLinked=()=>{e().then(t),this.onceLinked=void 0}})}async handleIncomingEvent(e){var t;if(!(e.type!=="Event"||e.event!=="Web3Response")){const n=await this.cipher.decrypt(e.data),s=JSON.parse(n);if(s.type!=="WEB3_RESPONSE")return;(t=this.listener)===null||t===void 0||t.handleWeb3ResponseMessage(s)}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(t=>this.handleIncomingEvent(t))}async setSessionMetadata(e,t){const n={type:"SetSessionConfig",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[e]:t}};return this.setOnceConnected(async()=>{const s=await this.makeRequest(n);if(s.type==="Fail")throw new Error(s.error||"failed to set session metadata")})}async publishEvent(e,t,n=!1){const s=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},t),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),i={type:"PublishEvent",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:e,data:s,callWebhook:n};return this.setOnceLinked(async()=>{const o=await this.makeRequest(i);if(o.type==="Fail")throw new Error(o.error||"failed to publish event");return o.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Ph*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,t=ub){const n=e.id;this.sendData(e);let s;return Promise.race([new Promise((i,o)=>{s=window.setTimeout(()=>{o(new Error(`request ${n} timed out`))},t)}),new Promise(i=>{this.requestResolutions.set(n,o=>{clearTimeout(s),i(o),this.requestResolutions.delete(n)})})])}async authenticate(){const e={type:"HostSession",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},t=await this.makeRequest(e);if(t.type==="Fail")throw new Error(t.error||"failed to authenticate")}sendIsLinked(){const e={type:"IsLinked",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}sendGetSessionConfig(){const e={type:"GetSessionConfig",id:(0,as.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(e)}}cc.WalletLinkConnection=hb;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});hc.WalletLinkSession=void 0;const db=b.sha_jsExports,Rh=U,Oh="session:id",Th="session:secret",Bh="session:linked";class Yl{constructor(e,t,n,s){this._storage=e,this._id=t||(0,Rh.randomBytesHex)(16),this._secret=n||(0,Rh.randomBytesHex)(32),this._key=new db.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!s}static load(e){const t=e.getItem(Oh),n=e.getItem(Bh),s=e.getItem(Th);return t&&s?new Yl(e,t,s,n==="1"):null}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this._storage.setItem(Oh,this._id),this._storage.setItem(Th,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(Bh,this._linked?"1":"0")}}hc.WalletLinkSession=Yl;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.isDarkMode=Ye.isMobileWeb=Ye.getLocation=Ye.createQrUrl=void 0;function fb(r,e,t,n,s,i){const o=n?"parent-id":"id",a=new URLSearchParams({[o]:r,secret:e,server:t,v:s,chainId:i.toString()}).toString();return`${t}/#/link?${a}`}Ye.createQrUrl=fb;function pb(){try{return window.frameElement!==null}catch{return!1}}function gb(){try{return pb()&&window.top?window.top.location:window.location}catch{return window.location}}Ye.getLocation=gb;function mb(){var r;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((r=window==null?void 0:window.navigator)===null||r===void 0?void 0:r.userAgent)}Ye.isMobileWeb=mb;function yb(){var r,e;return(e=(r=window==null?void 0:window.matchMedia)===null||r===void 0?void 0:r.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}Ye.isDarkMode=yb;var dc={},Do={},Xl={};Object.defineProperty(Xl,"__esModule",{value:!0});Xl.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var wb=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Do,"__esModule",{value:!0});Do.injectCssReset=void 0;const bb=wb(Xl);function Ab(){const r=document.createElement("style");r.type="text/css",r.appendChild(document.createTextNode(bb.default)),document.documentElement.appendChild(r)}Do.injectCssReset=Ab;var eu={},tu={};Object.defineProperty(tu,"__esModule",{value:!0});tu.default=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}";(function(r){var e=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(r,"__esModule",{value:!0}),r.SnackbarInstance=r.SnackbarContainer=r.Snackbar=void 0;const t=e(Es.require$$0),n=Es.require$$1,s=Es.require$$2,i=Ye,o=e(tu),a="data:image/svg+xml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ZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",c="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class l{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=(0,i.isDarkMode)()}attach(g){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",g.appendChild(this.root),this.render()}presentItem(g){const w=this.nextItemKey++;return this.items.set(w,g),this.render(),()=>{this.items.delete(w),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,n.render)((0,n.h)("div",null,(0,n.h)(r.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([g,w])=>(0,n.h)(r.SnackbarInstance,Object.assign({},w,{key:g}))))),this.root)}}r.Snackbar=l;const h=f=>(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-container")},(0,n.h)("style",null,o.default),(0,n.h)("div",{class:"-cbwsdk-snackbar"},f.children));r.SnackbarContainer=h;const d=({autoExpand:f,message:g,menuItems:w})=>{const[m,C]=(0,s.useState)(!0),[v,k]=(0,s.useState)(f??!1);(0,s.useEffect)(()=>{const B=[window.setTimeout(()=>{C(!1)},1),window.setTimeout(()=>{k(!0)},1e4)];return()=>{B.forEach(window.clearTimeout)}});const S=()=>{k(!v)};return(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance",m&&"-cbwsdk-snackbar-instance-hidden",v&&"-cbwsdk-snackbar-instance-expanded")},(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:S},(0,n.h)("img",{src:a,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},g),(0,n.h)("div",{class:"-gear-container"},!v&&(0,n.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,n.h)("img",{src:c,class:"-gear-icon",title:"Expand"}))),w&&w.length>0&&(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},w.map((B,P)=>(0,n.h)("div",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item",B.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:B.onClick,key:P},(0,n.h)("svg",{width:B.svgWidth,height:B.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("path",{"fill-rule":B.defaultFillRule,"clip-rule":B.defaultClipRule,d:B.path,fill:"#AAAAAA"})),(0,n.h)("span",{class:(0,t.default)("-cbwsdk-snackbar-instance-menu-item-info",B.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},B.info)))))};r.SnackbarInstance=d})(eu);Object.defineProperty(dc,"__esModule",{value:!0});dc.WalletLinkRelayUI=void 0;const Eb=Do,Cb=eu;class vb{constructor(){this.attached=!1,this.snackbar=new Cb.Snackbar}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,t=document.createElement("div");t.className="-cbwsdk-css-reset",e.appendChild(t),this.snackbar.attach(t),this.attached=!0,(0,Eb.injectCssReset)()}showConnecting(e){let t;return e.isUnlinkedErrorState?t={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:t={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(t)}}dc.WalletLinkRelayUI=vb;var fc={},pc={},nu={};Object.defineProperty(nu,"__esModule",{value:!0});nu.default=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";var dp=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(pc,"__esModule",{value:!0});pc.RedirectDialog=void 0;const Ib=dp(Es.require$$0),Rt=Es.require$$1,Nb=Do,Sb=eu,kb=Ye,xb=dp(nu);class Pb{constructor(){this.root=null,this.darkMode=(0,kb.isDarkMode)()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),(0,Nb.injectCssReset)()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&((0,Rt.render)(null,this.root),e&&(0,Rt.render)((0,Rt.h)(Rb,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}pc.RedirectDialog=Pb;const Rb=({title:r,buttonText:e,darkMode:t,onButtonClick:n,onDismiss:s})=>{const i=t?"dark":"light";return(0,Rt.h)(Sb.SnackbarContainer,{darkMode:t},(0,Rt.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,Rt.h)("style",null,xb.default),(0,Rt.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:s}),(0,Rt.h)("div",{class:(0,Ib.default)("-cbwsdk-redirect-dialog-box",i)},(0,Rt.h)("p",null,r),(0,Rt.h)("button",{onClick:n},e))))};var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.CBW_MOBILE_DEEPLINK_URL=Vt.WALLETLINK_URL=Vt.CB_KEYS_URL=void 0;Vt.CB_KEYS_URL="https://keys.coinbase.com/connect";Vt.WALLETLINK_URL="https://www.walletlink.org";Vt.CBW_MOBILE_DEEPLINK_URL="https://go.cb-w.com/walletlink";Object.defineProperty(fc,"__esModule",{value:!0});fc.WLMobileRelayUI=void 0;const Ob=pc,Tb=Ye,Bb=Vt;class _b{constructor(){this.attached=!1,this.redirectDialog=new Ob.RedirectDialog}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const t=new URL(Bb.CBW_MOBILE_DEEPLINK_URL);t.searchParams.append("redirect_url",(0,Tb.getLocation)().href),e&&t.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=t.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}fc.WLMobileRelayUI=_b;Object.defineProperty(ac,"__esModule",{value:!0});ac.WalletLinkRelay=void 0;const Lb=cc,Ub=Wt,Mb=Mo,Kc=hc,cs=Ri,Db=Ye,Fb=dc,_h=fc,Hb=zt,ie=U,Gb=Jt;class tn{constructor(e){this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.isMobileWeb=(0,Db.isMobileWeb)(),this.appName="",this.appLogoUrl=null,this.linkedUpdated=i=>{this.isLinked=i;const o=this.storage.getItem(Ub.LOCAL_STORAGE_ADDRESSES_KEY);if(i&&(this._session.linked=i),this.isUnlinkedErrorState=!1,o){const a=o.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";a[0]!==""&&!i&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(i,o)=>{this.storage.setItem(i,o)},this.chainUpdated=(i,o)=>{this.chainCallbackParams.chainId===i&&this.chainCallbackParams.jsonRpcUrl===o||(this.chainCallbackParams={chainId:i,jsonRpcUrl:o},this.chainCallback&&this.chainCallback(i,o))},this.accountUpdated=i=>{this.accountsCallback&&this.accountsCallback([i]),tn.accountRequestCallbackIds.size>0&&(Array.from(tn.accountRequestCallbackIds.values()).forEach(o=>{const a={type:"WEB3_RESPONSE",id:o,response:{method:"requestEthereumAccounts",result:[i]}};this.invokeCallback(Object.assign(Object.assign({},a),{id:o}))}),tn.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage;const{session:t,ui:n,connection:s}=this.subscribe();this._session=t,this.connection=s,this.relayEventManager=new Mb.RelayEventManager,this.ui=n}subscribe(){const e=Kc.WalletLinkSession.load(this.storage)||new Kc.WalletLinkSession(this.storage).save(),{linkAPIUrl:t}=this,n=new Lb.WalletLinkConnection({session:e,linkAPIUrl:t,listener:this}),s=this.isMobileWeb?new _h.WLMobileRelayUI:new Fb.WalletLinkRelayUI;return n.connect(),{session:e,ui:s,connection:n}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(e=>setTimeout(()=>e(null),1e3))]).then(()=>{this.connection.destroy();const e=Kc.WalletLinkSession.load(this.storage);(e==null?void 0:e.id)===this._session.id&&Gb.ScopedLocalStorage.clearAll(),document.location.reload()}).catch(e=>{})}setAppInfo(e,t){this.appName=e,this.appLogoUrl=t}getStorageItem(e){return this.storage.getItem(e)}setStorageItem(e,t){this.storage.setItem(e,t)}signEthereumMessage(e,t,n,s){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,ie.hexStringFromBuffer)(e,!0),address:t,addPrefix:n,typedDataJson:s||null}})}ethereumAddressFromSignedMessage(e,t,n){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,ie.hexStringFromBuffer)(e,!0),signature:(0,ie.hexStringFromBuffer)(t,!0),addPrefix:n}})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,ie.bigIntStringFromBigInt)(e.weiValue),data:(0,ie.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,gasLimit:e.gasLimit?(0,ie.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:(0,ie.bigIntStringFromBigInt)(e.weiValue),data:(0,ie.hexStringFromBuffer)(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?(0,ie.bigIntStringFromBigInt)(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?(0,ie.bigIntStringFromBigInt)(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?(0,ie.bigIntStringFromBigInt)(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?(0,ie.bigIntStringFromBigInt)(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,t){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,ie.hexStringFromBuffer)(e,!0),chainId:t}})}scanQRCode(e){return this.sendRequest({method:"scanQRCode",params:{regExp:e}})}getWalletLinkSession(){return this._session}genericRequest(e,t){return this.sendRequest({method:"generic",params:{action:t,data:e}})}sendGenericMessage(e){return this.sendRequest(e)}sendRequest(e){let t=null;const n=(0,ie.randomBytesHex)(8),s=i=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,i),t==null||t()};return new Promise((i,o)=>{t=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:s,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,a=>{if(t==null||t(),(0,cs.isErrorResponse)(a))return o(new Error(a.errorMessage));i(a)}),this.publishWeb3RequestEvent(n,e)})}setAccountsCallback(e){this.accountsCallback=e}setChainCallback(e){this.chainCallback=e}setDappDefaultChainCallback(e){this.dappDefaultChain=e}publishWeb3RequestEvent(e,t){const n={type:"WEB3_REQUEST",id:e,request:t};this.publishEvent("Web3Request",n,!0).then(s=>{}).catch(s=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n.id,response:{method:t.method,errorMessage:s.message}})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(t.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof _h.WLMobileRelayUI)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const t={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",t,!1).then()}publishEvent(e,t,n){return this.connection.publishEvent(e,t,n)}handleWeb3ResponseMessage(e){const{response:t}=e;if(t.method==="requestEthereumAccounts"){tn.accountRequestCallbackIds.forEach(n=>this.invokeCallback(Object.assign(Object.assign({},e),{id:n}))),tn.accountRequestCallbackIds.clear();return}this.invokeCallback(e)}handleErrorResponse(e,t,n){var s;const i=(s=n==null?void 0:n.message)!==null&&s!==void 0?s:"Unspecified error message.";this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:e,response:{method:t,errorMessage:i}})}invokeCallback(e){const t=this.relayEventManager.callbacks.get(e.id);t&&(t(e.response),this.relayEventManager.callbacks.delete(e.id))}requestEthereumAccounts(){const e={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},t=(0,ie.randomBytesHex)(8);return new Promise((n,s)=>{this.relayEventManager.callbacks.set(t,i=>{if((0,cs.isErrorResponse)(i))return s(new Error(i.errorMessage));n(i)}),tn.accountRequestCallbackIds.add(t),this.publishWeb3RequestEvent(t,e)})}watchAsset(e,t,n,s,i,o){const a={method:"watchAsset",params:{type:e,options:{address:t,symbol:n,decimals:s,image:i},chainId:o}};let c=null;const l=(0,ie.randomBytesHex)(8),h=d=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,a.method,d),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((d,f)=>{this.relayEventManager.callbacks.set(l,g=>{if(c==null||c(),(0,cs.isErrorResponse)(g))return f(new Error(g.errorMessage));d(g)}),this.publishWeb3RequestEvent(l,a)})}addEthereumChain(e,t,n,s,i,o){const a={method:"addEthereumChain",params:{chainId:e,rpcUrls:t,blockExplorerUrls:s,chainName:i,iconUrls:n,nativeCurrency:o}};let c=null;const l=(0,ie.randomBytesHex)(8),h=d=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,a.method,d),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((d,f)=>{this.relayEventManager.callbacks.set(l,g=>{if(c==null||c(),(0,cs.isErrorResponse)(g))return f(new Error(g.errorMessage));d(g)}),this.publishWeb3RequestEvent(l,a)})}switchEthereumChain(e,t){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:t})},s=(0,ie.randomBytesHex)(8);return new Promise((i,o)=>{this.relayEventManager.callbacks.set(s,a=>{if((0,cs.isErrorResponse)(a)&&a.errorCode)return o(Hb.standardErrors.provider.custom({code:a.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,cs.isErrorResponse)(a))return o(new Error(a.errorMessage));i(a)}),this.publishWeb3RequestEvent(s,n)})}}ac.WalletLinkRelay=tn;tn.accountRequestCallbackIds=new Set;var Kb=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ic,"__esModule",{value:!0});ic.WalletLinkSigner=void 0;const jc=Kb(tb),Lh=Wt,jb=Mo,qt=Ri,Wb=ac,Uh=Vt,pe=zt,j=U,Vb=Jt,Wc="DefaultChainId",Mh="DefaultJsonRpcUrl";class Qb{constructor(e){var t,n;this._relay=null,this._addresses=[],this.hasMadeFirstChainChangedEmission=!1;const{appName:s,appLogoUrl:i}=e.metadata;this._appName=s,this._appLogoUrl=i,this._storage=new Vb.ScopedLocalStorage("walletlink",Uh.WALLETLINK_URL),this.updateListener=e.updateListener,this._relayEventManager=new jb.RelayEventManager,this._jsonRpcUrlFromOpts="";const o=this._storage.getItem(Lh.LOCAL_STORAGE_ADDRESSES_KEY);if(o){const c=o.split(" ");c[0]!==""&&(this._addresses=c.map(l=>(0,j.ensureAddressString)(l)),(t=this.updateListener)===null||t===void 0||t.onAccountsUpdate({accounts:this._addresses,source:"storage"}))}this._storage.getItem(Wc)&&((n=this.updateListener)===null||n===void 0||n.onChainUpdate({chain:{id:this.getChainId(),rpcUrl:this.jsonRpcUrl},source:"storage"}),this.hasMadeFirstChainChangedEmission=!0),this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:t,secret:n}=e.getWalletLinkSession();return{id:t,secret:n}}async handshake(){return await this.request({method:"eth_requestAccounts"})}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(Mh))!==null&&e!==void 0?e:this._jsonRpcUrlFromOpts}set jsonRpcUrl(e){this._storage.setItem(Mh,e)}updateProviderInfo(e,t){var n;this.jsonRpcUrl=e;const s=this.getChainId();this._storage.setItem(Wc,t.toString(10)),((0,j.ensureIntNumber)(t)!==s||!this.hasMadeFirstChainChangedEmission)&&((n=this.updateListener)===null||n===void 0||n.onChainUpdate({chain:{id:t,rpcUrl:e},source:"wallet"}),this.hasMadeFirstChainChangedEmission=!0)}async watchAsset(e,t,n,s,i,o){const c=await this.initializeRelay().watchAsset(e,t,n,s,i,o==null?void 0:o.toString());return(0,qt.isErrorResponse)(c)?!1:!!c.result}async addEthereumChain(e,t,n,s,i,o){var a,c;if((0,j.ensureIntNumber)(e)===this.getChainId())return!1;const l=this.initializeRelay();this._isAuthorized()||await l.requestEthereumAccounts();const h=await l.addEthereumChain(e.toString(),t,i,n,s,o);return(0,qt.isErrorResponse)(h)?!1:(((a=h.result)===null||a===void 0?void 0:a.isApproved)===!0&&this.updateProviderInfo(t[0],e),((c=h.result)===null||c===void 0?void 0:c.isApproved)===!0)}async switchEthereumChain(e){const n=await this.initializeRelay().switchEthereumChain(e.toString(10),this.selectedAddress||void 0);if((0,qt.isErrorResponse)(n)){if(!n.errorCode)return;throw n.errorCode===pe.standardErrorCodes.provider.unsupportedChain?pe.standardErrors.provider.unsupportedChain():pe.standardErrors.provider.custom({message:n.errorMessage,code:n.errorCode})}const s=n.result;s.isApproved&&s.rpcUrl.length>0&&this.updateProviderInfo(s.rpcUrl,e)}async disconnect(){this._relay&&this._relay.resetAndReload(),this._storage.clear()}async request(e){try{return this._request(e).catch(t=>{throw t})}catch(t){return Promise.reject(t)}}async _request(e){if(!e||typeof e!="object"||Array.isArray(e))throw pe.standardErrors.rpc.invalidRequest({message:"Expected a single, non-array, object argument.",data:e});const{method:t,params:n}=e;if(typeof t!="string"||t.length===0)throw pe.standardErrors.rpc.invalidRequest({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw pe.standardErrors.rpc.invalidRequest({message:"'args.params' must be an object or array if provided.",data:e});const s=n===void 0?[]:n,i=this._relayEventManager.makeRequestId();return(await this._sendRequestAsync({method:t,params:s,jsonrpc:"2.0",id:i})).result}_setAddresses(e,t){var n;if(!Array.isArray(e))throw new Error("addresses is not an array");const s=e.map(i=>(0,j.ensureAddressString)(i));JSON.stringify(s)!==JSON.stringify(this._addresses)&&(this._addresses=s,(n=this.updateListener)===null||n===void 0||n.onAccountsUpdate({accounts:s,source:"wallet"}),this._storage.setItem(Lh.LOCAL_STORAGE_ADDRESSES_KEY,s.join(" ")))}_sendRequestAsync(e){return new Promise((t,n)=>{try{const s=this._handleSynchronousMethods(e);if(s!==void 0)return t({jsonrpc:"2.0",id:e.id,result:s})}catch(s){return n(s)}this._handleAsynchronousMethods(e).then(s=>s&&t(Object.assign(Object.assign({},s),{id:e.id}))).catch(s=>n(s))})}_handleSynchronousMethods(e){const{method:t}=e;switch(t){case"eth_accounts":return this._eth_accounts();case"eth_coinbase":return this._eth_coinbase();case"net_version":return this._net_version();case"eth_chainId":return this._eth_chainId();default:return}}async _handleAsynchronousMethods(e){const{method:t}=e,n=e.params||[];switch(t){case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_sign":return this._eth_sign(n);case"eth_ecRecover":return this._eth_ecRecover(n);case"personal_sign":return this._personal_sign(n);case"personal_ecRecover":return this._personal_ecRecover(n);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":return this._eth_signTypedData_v1(n);case"eth_signTypedData_v2":return this._throwUnsupportedMethodError();case"eth_signTypedData_v3":return this._eth_signTypedData_v3(n);case"eth_signTypedData_v4":case"eth_signTypedData":return this._eth_signTypedData_v4(n);case"wallet_addEthereumChain":return this._wallet_addEthereumChain(n);case"wallet_switchEthereumChain":return this._wallet_switchEthereumChain(n);case"wallet_watchAsset":return this._wallet_watchAsset(n);default:return this._throwUnsupportedMethodError()}}_isKnownAddress(e){try{const t=(0,j.ensureAddressString)(e);return this._addresses.map(s=>(0,j.ensureAddressString)(s)).includes(t)}catch{}return!1}_ensureKnownAddress(e){if(!this._isKnownAddress(e))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const t=e.from?(0,j.ensureAddressString)(e.from):this.selectedAddress;if(!t)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(t);const n=e.to?(0,j.ensureAddressString)(e.to):null,s=e.value!=null?(0,j.ensureBigInt)(e.value):BigInt(0),i=e.data?(0,j.ensureBuffer)(e.data):b.Buffer.alloc(0),o=e.nonce!=null?(0,j.ensureIntNumber)(e.nonce):null,a=e.gasPrice!=null?(0,j.ensureBigInt)(e.gasPrice):null,c=e.maxFeePerGas!=null?(0,j.ensureBigInt)(e.maxFeePerGas):null,l=e.maxPriorityFeePerGas!=null?(0,j.ensureBigInt)(e.maxPriorityFeePerGas):null,h=e.gas!=null?(0,j.ensureBigInt)(e.gas):null,d=e.chainId?(0,j.ensureIntNumber)(e.chainId):this.getChainId();return{fromAddress:t,toAddress:n,weiValue:s,data:i,nonce:o,gasPriceInWei:a,maxFeePerGas:c,maxPriorityFeePerGas:l,gasLimit:h,chainId:d}}_isAuthorized(){return this._addresses.length>0}_requireAuthorization(){if(!this._isAuthorized())throw pe.standardErrors.provider.unauthorized({})}_throwUnsupportedMethodError(){throw pe.standardErrors.provider.unsupportedMethod({})}async _signEthereumMessage(e,t,n,s){this._ensureKnownAddress(t);try{const o=await this.initializeRelay().signEthereumMessage(e,t,n,s);if((0,qt.isErrorResponse)(o))throw new Error(o.errorMessage);return{jsonrpc:"2.0",id:0,result:o.result}}catch(i){throw typeof i.message=="string"&&i.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied message signature"):i}}async _ethereumAddressFromSignedMessage(e,t,n){const i=await this.initializeRelay().ethereumAddressFromSignedMessage(e,t,n);if((0,qt.isErrorResponse)(i))throw new Error(i.errorMessage);return{jsonrpc:"2.0",id:0,result:i.result}}_eth_accounts(){return[...this._addresses]}_eth_coinbase(){return this.selectedAddress||null}_net_version(){return this.getChainId().toString(10)}_eth_chainId(){return(0,j.hexStringFromIntNumber)(this.getChainId())}getChainId(){const e=this._storage.getItem(Wc);if(!e)return(0,j.ensureIntNumber)(1);const t=parseInt(e,10);return(0,j.ensureIntNumber)(t)}async _eth_requestAccounts(){if(this._isAuthorized())return Promise.resolve({jsonrpc:"2.0",id:0,result:this._addresses});let e;try{if(e=await this.initializeRelay().requestEthereumAccounts(),(0,qt.isErrorResponse)(e))throw new Error(e.errorMessage)}catch(t){throw typeof t.message=="string"&&t.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied account authorization"):t}if(!e.result)throw new Error("accounts received is empty");return this._setAddresses(e.result),{jsonrpc:"2.0",id:0,result:this._addresses}}_eth_sign(e){this._requireAuthorization();const t=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._signEthereumMessage(n,t,!1)}_eth_ecRecover(e){const t=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,n,!1)}_personal_sign(e){this._requireAuthorization();const t=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureAddressString)(e[1]);return this._signEthereumMessage(t,n,!0)}_personal_ecRecover(e){const t=(0,j.ensureBuffer)(e[0]),n=(0,j.ensureBuffer)(e[1]);return this._ethereumAddressFromSignedMessage(t,n,!0)}async _eth_signTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signEthereumTransaction(t);if((0,qt.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_sendRawTransaction(e){const t=(0,j.ensureBuffer)(e[0]),s=await this.initializeRelay().submitEthereumTransaction(t,this.getChainId());if((0,qt.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}async _eth_sendTransaction(e){this._requireAuthorization();const t=this._prepareTransactionParams(e[0]||{});try{const s=await this.initializeRelay().signAndSubmitEthereumTransaction(t);if((0,qt.isErrorResponse)(s))throw new Error(s.errorMessage);return{jsonrpc:"2.0",id:0,result:s.result}}catch(n){throw typeof n.message=="string"&&n.message.match(/(denied|rejected)/i)?pe.standardErrors.provider.userRejectedRequest("User denied transaction signature"):n}}async _eth_signTypedData_v1(e){this._requireAuthorization();const t=(0,j.ensureParsedJSONObject)(e[0]),n=(0,j.ensureAddressString)(e[1]);this._ensureKnownAddress(n);const s=jc.default.hashForSignTypedDataLegacy({data:t}),i=JSON.stringify(t,null,2);return this._signEthereumMessage(s,n,!1,i)}async _eth_signTypedData_v3(e){this._requireAuthorization();const t=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=jc.default.hashForSignTypedData_v3({data:n}),i=JSON.stringify(n,null,2);return this._signEthereumMessage(s,t,!1,i)}async _eth_signTypedData_v4(e){this._requireAuthorization();const t=(0,j.ensureAddressString)(e[0]),n=(0,j.ensureParsedJSONObject)(e[1]);this._ensureKnownAddress(t);const s=jc.default.hashForSignTypedData_v4({data:n}),i=JSON.stringify(n,null,2);return this._signEthereumMessage(s,t,!1,i)}async _wallet_addEthereumChain(e){var t,n,s,i;const o=e[0];if(((t=o.rpcUrls)===null||t===void 0?void 0:t.length)===0)return{jsonrpc:"2.0",id:0,error:{code:2,message:"please pass in at least 1 rpcUrl"}};if(!o.chainName||o.chainName.trim()==="")throw pe.standardErrors.rpc.invalidParams("chainName is a required field");if(!o.nativeCurrency)throw pe.standardErrors.rpc.invalidParams("nativeCurrency is a required field");const a=parseInt(o.chainId,16);return await this.addEthereumChain(a,(n=o.rpcUrls)!==null&&n!==void 0?n:[],(s=o.blockExplorerUrls)!==null&&s!==void 0?s:[],o.chainName,(i=o.iconUrls)!==null&&i!==void 0?i:[],o.nativeCurrency)?{jsonrpc:"2.0",id:0,result:null}:{jsonrpc:"2.0",id:0,error:{code:2,message:"unable to add ethereum chain"}}}async _wallet_switchEthereumChain(e){const t=e[0];return await this.switchEthereumChain(parseInt(t.chainId,16)),{jsonrpc:"2.0",id:0,result:null}}async _wallet_watchAsset(e){const t=Array.isArray(e)?e[0]:e;if(!t.type)throw pe.standardErrors.rpc.invalidParams("Type is required");if((t==null?void 0:t.type)!=="ERC20")throw pe.standardErrors.rpc.invalidParams(`Asset of type '${t.type}' is not supported`);if(!(t!=null&&t.options))throw pe.standardErrors.rpc.invalidParams("Options are required");if(!(t!=null&&t.options.address))throw pe.standardErrors.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:s,symbol:i,image:o,decimals:a}=t.options;return{jsonrpc:"2.0",id:0,result:await this.watchAsset(t.type,s,i,a,o,n)}}initializeRelay(){if(!this._relay){const e=new Wb.WalletLinkRelay({linkAPIUrl:Uh.WALLETLINK_URL,storage:this._storage});e.setAppInfo(this._appName,this._appLogoUrl),e.attachUI(),e.setAccountsCallback((t,n)=>this._setAddresses(t,n)),e.setChainCallback((t,n)=>{this.updateProviderInfo(n,parseInt(t,10))}),this._relay=e}return this._relay}}ic.WalletLinkSigner=Qb;var ct={};Object.defineProperty(ct,"__esModule",{value:!0});ct.checkErrorForInvalidRequestArgs=ct.getCoinbaseInjectedProvider=ct.getCoinbaseInjectedSigner=ct.fetchRPCRequest=void 0;const zb=Zr,ha=zt;async function Jb(r,e){if(!e.rpcUrl)throw ha.standardErrors.rpc.internal("No RPC URL set for chain");const t=Object.assign(Object.assign({},r),{jsonrpc:"2.0",id:crypto.randomUUID()});return(await(await window.fetch(e.rpcUrl,{method:"POST",body:JSON.stringify(t),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":zb.LIB_VERSION}})).json()).result}ct.fetchRPCRequest=Jb;function fp(){return globalThis.coinbaseWalletSigner}ct.getCoinbaseInjectedSigner=fp;function qb({metadata:r,preference:e}){var t,n,s;const i=globalThis;if(e.options!=="smartWalletOnly"){if(fp())return;const c=i.coinbaseWalletExtension;if(c){const{appName:l,appLogoUrl:h,appChainIds:d}=r;return(t=c.setAppInfo)===null||t===void 0||t.call(c,l,h,d),c}}const o=(n=i.ethereum)!==null&&n!==void 0?n:(s=i.top)===null||s===void 0?void 0:s.ethereum;if(o!=null&&o.isCoinbaseBrowser)return o}ct.getCoinbaseInjectedProvider=qb;function Zb(r){if(!r||typeof r!="object"||Array.isArray(r))return ha.standardErrors.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:r});const{method:e,params:t}=r;if(typeof e!="string"||e.length===0)return ha.standardErrors.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:r});if(t!==void 0&&!Array.isArray(t)&&(typeof t!="object"||t===null))return ha.standardErrors.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:r})}ct.checkErrorForInvalidRequestArgs=Zb;Object.defineProperty(Kt,"__esModule",{value:!0});Kt.createSigner=Kt.fetchSignerType=Kt.storeSignerType=Kt.loadSignerType=void 0;const $b=nc,pp=ic,Yb=zt,Xb=ct,e1=Jt,gp="SignerType",mp=new e1.ScopedLocalStorage("CBWSDK","SignerConfigurator");function t1(){return mp.getItem(gp)}Kt.loadSignerType=t1;function n1(r){mp.setItem(gp,r)}Kt.storeSignerType=n1;async function r1(r){const{communicator:e,metadata:t}=r;i1(e,t).catch(()=>{});const n={id:crypto.randomUUID(),event:"selectSignerType",data:r.preference},{data:s}=await e.postRequestAndWaitForResponse(n);return s}Kt.fetchSignerType=r1;function s1(r){const{signerType:e,metadata:t,communicator:n,updateListener:s}=r;switch(e){case"scw":return new $b.SCWSigner({metadata:t,updateListener:s,communicator:n});case"walletlink":return new pp.WalletLinkSigner({metadata:t,updateListener:s});case"extension":{const i=(0,Xb.getCoinbaseInjectedSigner)();if(!i)throw Yb.standardErrors.rpc.internal("injected signer not found");return i}}}Kt.createSigner=s1;async function i1(r,e){await r.onMessage(({event:n})=>n==="WalletLinkSessionRequest");const t=new pp.WalletLinkSigner({metadata:e});r.postMessage({event:"WalletLinkUpdate",data:{session:t.getSession()}}),await t.handshake(),r.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var gc={},xi={};Object.defineProperty(xi,"__esModule",{value:!0});xi.closePopup=xi.openPopup=void 0;const o1=zt,Dh=420,Fh=540;function a1(r){const e=(window.innerWidth-Dh)/2+window.screenX,t=(window.innerHeight-Fh)/2+window.screenY,n=window.open(r,"Smart Wallet",`width=${Dh}, height=${Fh}, left=${e}, top=${t}`);if(n==null||n.focus(),!n)throw o1.standardErrors.rpc.internal("Pop up window failed to open");return n}xi.openPopup=a1;function c1(r){r&&!r.closed&&r.close()}xi.closePopup=c1;Object.defineProperty(gc,"__esModule",{value:!0});gc.Communicator=void 0;const l1=Zr,Hh=xi,u1=Vt,Gh=zt;class h1{constructor(e=u1.CB_KEYS_URL){this.popup=null,this.listeners=new Map,this.postMessage=async t=>{(await this.waitForPopupLoaded()).postMessage(t,this.url.origin)},this.postRequestAndWaitForResponse=async t=>{const n=this.onMessage(({requestId:s})=>s===t.id);return this.postMessage(t),await n},this.onMessage=async t=>new Promise((n,s)=>{const i=o=>{if(o.origin!==this.url.origin)return;const a=o.data;t(a)&&(n(a),window.removeEventListener("message",i),this.listeners.delete(i))};window.addEventListener("message",i),this.listeners.set(i,{reject:s})}),this.disconnect=()=>{(0,Hh.closePopup)(this.popup),this.popup=null,this.listeners.forEach(({reject:t},n)=>{t(Gh.standardErrors.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",n)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?this.popup:(this.popup=(0,Hh.openPopup)(this.url),this.onMessage(({event:t})=>t==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:t})=>t==="PopupLoaded").then(t=>{this.postMessage({requestId:t.id,data:{version:l1.LIB_VERSION}})}).then(()=>{if(!this.popup)throw Gh.standardErrors.rpc.internal();return this.popup})),this.url=new URL(e)}}gc.Communicator=h1;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});mc.determineMethodCategory=void 0;const Kh={handshake:["eth_requestAccounts"],sign:["eth_ecRecover","personal_sign","personal_ecRecover","eth_signTransaction","eth_sendTransaction","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","eth_signTypedData","wallet_addEthereumChain","wallet_switchEthereumChain","wallet_watchAsset","wallet_getCapabilities","wallet_sendCalls","wallet_showCallsStatus"],state:["eth_chainId","eth_accounts","eth_coinbase","net_version"],deprecated:["eth_sign","eth_signTypedData_v2"],unsupported:["eth_subscribe","eth_unsubscribe"],fetch:[]};function d1(r){for(const e in Kh){const t=e;if(Kh[t].includes(r))return t}}mc.determineMethodCategory=d1;var f1=b.commonjsGlobal&&b.commonjsGlobal.__rest||function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},p1=b.commonjsGlobal&&b.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ya,"__esModule",{value:!0});Ya.CoinbaseWalletProvider=void 0;const g1=p1(b.eventemitter3Exports),ls=zt,m1=ec,Xo=Se,Ui=U,ea=Kt,jh=ct,y1=gc,w1=mc,b1=Jt;class A1 extends g1.default{constructor(e){var t,n,{metadata:s}=e,i=e.preference,{keysUrl:o}=i,a=f1(i,["keysUrl"]);super(),this.accounts=[],this.handlers={handshake:async l=>{try{if(this.connected)return this.emit("connect",{chainId:(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(this.chain.id))}),this.accounts;const h=await this.requestSignerSelection(),d=this.initSigner(h),f=await d.handshake();return this.signer=d,(0,ea.storeSignerType)(h),this.emit("connect",{chainId:(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(this.chain.id))}),f}catch(h){throw this.handleUnauthorizedError(h),h}},sign:async l=>{if(!this.connected||!this.signer)throw ls.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");try{return await this.signer.request(l)}catch(h){throw this.handleUnauthorizedError(h),h}},fetch:l=>(0,jh.fetchRPCRequest)(l,this.chain),state:l=>{const h=()=>{if(this.connected)return this.accounts;throw ls.standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")};switch(l.method){case"eth_chainId":return(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(this.chain.id));case"net_version":return this.chain.id;case"eth_accounts":return h();case"eth_coinbase":return h()[0];default:return this.handlers.unsupported(l)}},deprecated:({method:l})=>{throw ls.standardErrors.rpc.methodNotSupported(`Method ${l} is deprecated.`)},unsupported:({method:l})=>{throw ls.standardErrors.rpc.methodNotSupported(`Method ${l} is not supported.`)}},this.isCoinbaseWallet=!0,this.updateListener={onAccountsUpdate:({accounts:l,source:h})=>{(0,Ui.areAddressArraysEqual)(this.accounts,l)||(this.accounts=l,h!=="storage"&&this.emit("accountsChanged",this.accounts))},onChainUpdate:({chain:l,source:h})=>{l.id===this.chain.id&&l.rpcUrl===this.chain.rpcUrl||(this.chain=l,h!=="storage"&&this.emit("chainChanged",(0,Ui.hexStringFromIntNumber)((0,Xo.IntNumber)(l.id))))}},this.metadata=s,this.preference=a,this.communicator=new y1.Communicator(o),this.chain={id:(n=(t=s.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1};const c=(0,ea.loadSignerType)();this.signer=c?this.initSigner(c):null}get connected(){return this.accounts.length>0}async request(e){var t;try{const n=(0,jh.checkErrorForInvalidRequestArgs)(e);if(n)throw n;const s=(t=(0,w1.determineMethodCategory)(e.method))!==null&&t!==void 0?t:"fetch";return this.handlers[s](e)}catch(n){return Promise.reject((0,m1.serializeError)(n,e.method))}}handleUnauthorizedError(e){e.code===ls.standardErrorCodes.provider.unauthorized&&this.disconnect()}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),await this.request({method:"eth_requestAccounts"})}async disconnect(){this.accounts=[],this.chain={id:1},b1.ScopedLocalStorage.clearAll(),this.emit("disconnect",ls.standardErrors.provider.disconnected("User initiated disconnection"))}requestSignerSelection(){return(0,ea.fetchSignerType)({communicator:this.communicator,preference:this.preference,metadata:this.metadata})}initSigner(e){return(0,ea.createSigner)({signerType:e,metadata:this.metadata,communicator:this.communicator,updateListener:this.updateListener})}}Ya.CoinbaseWalletProvider=A1;Object.defineProperty(no,"__esModule",{value:!0});no.CoinbaseWalletSDK=void 0;const E1=$a,C1=Ya,v1=Jt,I1=Zr,N1=U,S1=ct;class k1{constructor(e){this.metadata={appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||(0,N1.getFavicon)(),appChainIds:e.appChainIds||[]},this.storeLatestVersion()}makeWeb3Provider(e={options:"all"}){var t;const n={metadata:this.metadata,preference:e};return(t=(0,S1.getCoinbaseInjectedProvider)(n))!==null&&t!==void 0?t:new C1.CoinbaseWalletProvider(n)}getCoinbaseWalletLogo(e,t=240){return(0,E1.walletLogo)(e,t)}storeLatestVersion(){new v1.ScopedLocalStorage("CBWSDK").setItem("VERSION",I1.LIB_VERSION)}}no.CoinbaseWalletSDK=k1;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.CoinbaseWalletSDK=void 0;const e=no;r.default=e.CoinbaseWalletSDK;var t=no;Object.defineProperty(r,"CoinbaseWalletSDK",{enumerable:!0,get:function(){return t.CoinbaseWalletSDK}})})(Hf);class x1{createEthersConfig(e){if(!e.metadata)return;let t,n;function s(){if(t)return t;if(!(typeof window>"u")&&window.ethereum)return t=window.ethereum,t}function i(){var c,l,h;return n||(typeof window>"u"?void 0:(n=new Hf.CoinbaseWalletSDK({appName:(c=e==null?void 0:e.metadata)==null?void 0:c.name,appLogoUrl:(l=e==null?void 0:e.metadata)==null?void 0:l.icons[0],appChainIds:((h=e.networks)==null?void 0:h.map(d=>d.chainId))||[1,84532]}).makeWeb3Provider({options:e.coinbasePreference??"all"}),n))}const o={metadata:e.metadata};return e.enableInjected!==!1&&(o.injected=s()),e.enableCoinbase!==!1&&(o.coinbase=i()),o.EIP6963=e.enableEIP6963!==!1,o}constructor(){var e,t;this.appKit=void 0,this.EIP6963Providers=[],this.options=void 0,this.caipNetworks=[],this.chainNamespace=b.ConstantsUtil$1.CHAIN.EVM,this.siweControllerClient=(e=this.options)==null?void 0:e.siweConfig,this.tokens=b.HelpersUtil.getCaipTokens((t=this.options)==null?void 0:t.tokens),this.defaultCaipNetwork=void 0,this.adapterType="ethers",this.providerHandlers=null,b.ChainController.subscribeKey("activeCaipNetwork",n=>{var a;const s=(a=this.appKit)==null?void 0:a.getCaipAddress(this.chainNamespace),i=s==null?void 0:s.startsWith("eip155:"),o=(n==null?void 0:n.chainNamespace)===this.chainNamespace;i&&o&&s&&(this.syncBalance(b.CoreHelperUtil.getPlainAddress(s),n),this.syncAccount({address:b.CoreHelperUtil.getPlainAddress(s),caipNetwork:n}))}),b.ChainController.subscribeKey("activeCaipAddress",n=>{const s=n==null?void 0:n.startsWith("eip155:"),i=b.ChainController.state.activeCaipNetwork,o=(i==null?void 0:i.chainNamespace)===this.chainNamespace;s&&(o&&this.syncBalance(b.CoreHelperUtil.getPlainAddress(n),i),this.syncAccount({address:b.CoreHelperUtil.getPlainAddress(n)}))}),b.AccountController.subscribeKey("shouldUpdateToAddress",n=>{(n==null?void 0:n.startsWith("0x"))&&this.syncAccount({address:n})},this.chainNamespace)}construct(e,t){var i,o,a,c,l,h,d;if(!t.projectId)throw new Error("appkit:ethers-client:initialize - projectId is undefined");this.appKit=e,this.options=t,this.caipNetworks=t.networks.map(f=>({...f,rpcUrl:b.CaipNetworksUtil.extendRpcUrlWithProjectId(f.rpcUrl,t.projectId)})),this.defaultCaipNetwork=t.defaultNetwork||t.networks[0],this.tokens=b.HelpersUtil.getCaipTokens(t.tokens),this.ethersConfig=this.createEthersConfig(t),this.networkControllerClient={switchCaipNetwork:async f=>{if(f!=null&&f.chainId)try{await this.switchNetwork(f)}catch{throw new Error("networkControllerClient:switchCaipNetwork - unable to switch chain")}},getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},this.connectionControllerClient={connectWalletConnect:async f=>{var g,w,m,C;await((C=(m=(w=(g=this.appKit)==null?void 0:g.universalAdapter)==null?void 0:w.connectionControllerClient)==null?void 0:m.connectWalletConnect)==null?void 0:C.call(m,f))},connectExternal:async({id:f,info:g,provider:w})=>{var k;(k=this.appKit)==null||k.setClientId(null);const C={[b.ConstantsUtil.INJECTED_CONNECTOR_ID]:{getProvider:()=>{var S;return(S=this.ethersConfig)==null?void 0:S.injected},providerType:"injected"},[b.ConstantsUtil.EIP6963_CONNECTOR_ID]:{getProvider:()=>w,providerType:"eip6963"},[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID]:{getProvider:()=>{var S;return(S=this.ethersConfig)==null?void 0:S.coinbase},providerType:"coinbase"},[b.ConstantsUtil.AUTH_CONNECTOR_ID]:{getProvider:()=>this.authProvider,providerType:"w3mAuth"}}[f];if(!C)throw new Error(`Unsupported connector ID: ${f}`);const v=C.getProvider();if(!v)throw new Error(`Provider for connector ${f} is undefined`);try{v&&f!==b.ConstantsUtil.AUTH_CONNECTOR_ID&&await v.request({method:"eth_requestAccounts"}),await this.setProvider(v,C.providerType,g==null?void 0:g.name)}catch(S){if(f===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID)throw new Error(S.message)}},checkInstalled:f=>{var g;return f?(g=this.ethersConfig)!=null&&g.injected&&!(window!=null&&window.ethereum)?!1:f.some(w=>{var m;return!!((m=window.ethereum)!=null&&m[String(w)])}):!!window.ethereum},disconnect:async()=>{var C,v,k,S,B;const f=b.ProviderUtil.getProvider("eip155"),g=b.ProviderUtil.state.providerIds.eip155;if((C=this.appKit)==null||C.setClientId(null),(S=(k=(v=this.options)==null?void 0:v.siweConfig)==null?void 0:k.options)!=null&&S.signOutOnDisconnect){const{SIWEController:P}=await Promise.resolve().then(()=>require("./index-C0D6DuSI.cjs"));await P.signOut()}const m={[b.ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]:async()=>{var P,R,M;return await((M=(R=(P=this.appKit)==null?void 0:P.universalAdapter)==null?void 0:R.connectionControllerClient)==null?void 0:M.disconnect())},coinbaseWalletSDK:async()=>{var P,R,M;return await((M=(R=(P=this.appKit)==null?void 0:P.universalAdapter)==null?void 0:R.connectionControllerClient)==null?void 0:M.disconnect())},[b.ConstantsUtil.AUTH_CONNECTOR_ID]:async()=>{var P;await((P=this.authProvider)==null?void 0:P.disconnect())},[b.ConstantsUtil.EIP6963_CONNECTOR_ID]:async()=>{f&&await this.revokeProviderPermissions(f)},[b.ConstantsUtil.INJECTED_CONNECTOR_ID]:async()=>{f&&(f.emit("disconnect"),await this.revokeProviderPermissions(f))}}[g];m?await m():console.warn(`No disconnect function found for provider type: ${g}`),b.SafeLocalStorage.removeItem(b.SafeLocalStorageKeys.WALLET_ID),(B=this.appKit)==null||B.resetAccount(this.chainNamespace)},signMessage:async f=>{const g=b.ProviderUtil.getProvider(this.chainNamespace),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w);if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.signMessage(f,g,m)},parseUnits:Pn.parseUnits,formatUnits:Pn.formatUnits,estimateGas:async f=>{var v;if(f.chainNamespace&&f.chainNamespace!=="eip155")throw new Error(`Invalid chain namespace - Expected eip155, got ${f.chainNamespace}`);const g=b.ProviderUtil.getProvider("eip155"),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w),C=(v=this.appKit)==null?void 0:v.getCaipNetwork();if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.estimateGas(f,g,m,Number(C==null?void 0:C.chainId))},sendTransaction:async f=>{var v;if(f.chainNamespace&&f.chainNamespace!=="eip155")throw new Error(`Invalid chain namespace - Expected eip155, got ${f.chainNamespace}`);const g=b.ProviderUtil.getProvider("eip155"),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w),C=(v=this.appKit)==null?void 0:v.getCaipNetwork();if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.sendTransaction(f,g,m,Number(C==null?void 0:C.chainId))},writeContract:async f=>{var v;const g=b.ProviderUtil.getProvider("eip155"),w=b.ChainController.state.activeCaipAddress,m=b.CoreHelperUtil.getPlainAddress(w),C=(v=this.appKit)==null?void 0:v.getCaipNetwork();if(!m)throw new Error("Address is undefined");if(!g)throw new Error("Provider is undefined");return await Pn.writeContract(f,g,m,Number(C==null?void 0:C.chainId))},getEnsAddress:async f=>this.appKit?await Pn.getEnsAddress(f,this.appKit):!1,getEnsAvatar:async f=>{var w;const g=(w=this.appKit)==null?void 0:w.getCaipNetwork();return await Pn.getEnsAvatar(f,Number(g==null?void 0:g.chainId))}},b.ChainController.state.chains.set(this.chainNamespace,{chainNamespace:this.chainNamespace,connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient,adapterType:this.adapterType,caipNetworks:this.caipNetworks}),this.ethersConfig&&this.syncConnectors(this.ethersConfig),typeof window<"u"&&this.listenConnectors(!0),(o=this.appKit)==null||o.setEIP6963Enabled((i=this.ethersConfig)==null?void 0:i.EIP6963);const n=((a=t.features)==null?void 0:a.email)===void 0?b.ConstantsUtil$2.DEFAULT_FEATURES.email:(c=t.features)==null?void 0:c.email,s=(l=t.features)!=null&&l.socials?((d=(h=t.features)==null?void 0:h.socials)==null?void 0:d.length)>0:b.ConstantsUtil$2.DEFAULT_FEATURES.socials;(n||s)&&this.syncAuthConnector(this.options.projectId),this.ethersConfig&&this.checkActiveProviders(this.ethersConfig),this.syncRequestedNetworks(this.caipNetworks)}subscribeState(e){var t;return(t=this.appKit)==null?void 0:t.subscribeState(n=>e(n))}async disconnect(){var e;await((e=this.connectionControllerClient)==null?void 0:e.disconnect())}async revokeProviderPermissions(e){try{(await e.request({method:"wallet_getPermissions"})).find(s=>s.parentCapability==="eth_accounts")&&await e.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]})}catch(t){console.info("Could not revoke permissions from wallet. Disconnecting...",t)}}getApprovedCaipNetworksData(){return new Promise(e=>{const t=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_ID);if(!t)throw new Error("No wallet id found to get approved networks data");const s={[b.ConstantsUtil.AUTH_CONNECTOR_ID]:{supportsAllNetworks:!0,approvedCaipNetworkIds:b.PresetsUtil.WalletConnectRpcChainIds.map(i=>`${b.ConstantsUtil.EIP155}:${i}`)}}[t];e(s||{supportsAllNetworks:!0,approvedCaipNetworkIds:[]})})}checkActiveProviders(e){var o;const t=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_ID),n=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_NAME);if(!t)return;const i={[b.ConstantsUtil.INJECTED_CONNECTOR_ID]:{provider:e.injected},[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID]:{provider:e.coinbase},[b.ConstantsUtil.EIP6963_CONNECTOR_ID]:{provider:(o=this.EIP6963Providers.find(a=>a.info.name===n))==null?void 0:o.provider}}[t];i!=null&&i.provider&&(this.setProvider(i.provider,t),this.setupProviderListeners(i.provider,t))}async setProvider(e,t,n){var s,i,o,a;if(t==="w3mAuth")this.setAuthProvider();else{const c=t;if(b.SafeLocalStorage.setItem(b.SafeLocalStorageKeys.WALLET_ID,c),n&&b.SafeLocalStorage.setItem(b.SafeLocalStorageKeys.WALLET_NAME,n),e){const{addresses:l,chainId:h}=await ur.getUserInfo(e),d=l==null?void 0:l[0],f=this.caipNetworks.find(w=>w.chainId===h),g=`${this.chainNamespace}:${h}:${d}`;d&&h&&f&&((s=this.appKit)==null||s.setCaipAddress(g,this.chainNamespace),(i=this.appKit)==null||i.setCaipNetwork(f),b.ProviderUtil.setProviderId("eip155",t),b.ProviderUtil.setProvider("eip155",e),(o=this.appKit)==null||o.setStatus("connected",this.chainNamespace),(a=this.appKit)==null||a.setAllAccounts(l.map(w=>({address:w,type:"eoa"})),this.chainNamespace))}}}async setAuthProvider(){var e,t,n,s,i,o,a,c,l,h,d,f;if(b.SafeLocalStorage.setItem(b.SafeLocalStorageKeys.WALLET_ID,b.ConstantsUtil.AUTH_CONNECTOR_ID),this.authProvider){(e=this.appKit)==null||e.setLoading(!0);const{address:g,chainId:w,smartAccountDeployed:m,preferredAccountType:C,accounts:v=[]}=await this.authProvider.connect({chainId:Number(b.NetworkUtil.caipNetworkIdToNumber((n=(t=this.appKit)==null?void 0:t.getCaipNetwork())==null?void 0:n.id)??((s=this.caipNetworks[0])==null?void 0:s.chainId))}),{smartAccountEnabledNetworks:k}=await this.authProvider.getSmartAccountEnabledNetworks();if((i=this.appKit)==null||i.setSmartAccountEnabledNetworks(k,this.chainNamespace),g&&w){(o=this.appKit)==null||o.setAllAccounts(v.length>0?v:[{address:g,type:C}],this.chainNamespace);const S=this.caipNetworks.find(B=>B.chainId===w);(a=this.appKit)==null||a.setCaipNetwork(S),(c=this.appKit)==null||c.setStatus("connected",this.chainNamespace),(l=this.appKit)==null||l.setCaipAddress(`${this.chainNamespace}:${w}:${g}`,this.chainNamespace),(h=this.appKit)==null||h.setPreferredAccountType(C,this.chainNamespace),(d=this.appKit)==null||d.setSmartAccountDeployed(!!m,this.chainNamespace),b.ProviderUtil.setProvider("eip155",this.authProvider),b.ProviderUtil.setProviderId("eip155",b.ConstantsUtil.AUTH_CONNECTOR_ID),this.setupProviderListeners(this.authProvider,"w3mAuth"),this.watchModal()}(f=this.appKit)==null||f.setLoading(!1)}}watchModal(){this.authProvider&&this.subscribeState(e=>{var t;e.open||(t=this.authProvider)==null||t.rejectRpcRequests()})}setupProviderListeners(e,t){const n=()=>{b.SafeLocalStorage.removeItem(b.SafeLocalStorageKeys.WALLET_ID),this.removeListeners(e)},s=o=>{var c,l,h,d;const a=o==null?void 0:o[0];a?((c=this.appKit)==null||c.setCaipAddress(a,this.chainNamespace),t===b.ConstantsUtil.EIP6963_CONNECTOR_ID&&((l=this.appKit)==null||l.setAllAccounts(o.map(f=>({address:f,type:"eoa"})),this.chainNamespace))):(t===b.ConstantsUtil.EIP6963_CONNECTOR_ID&&((h=this.appKit)==null||h.setAllAccounts([],this.chainNamespace)),b.SafeLocalStorage.removeItem(b.SafeLocalStorageKeys.WALLET_ID),(d=this.appKit)==null||d.resetAccount(this.chainNamespace))},i=o=>{var a;if(o){const c=typeof o=="string"?ur.hexStringToNumber(o):Number(o),l=this.caipNetworks.find(h=>h.chainId===c);(a=this.appKit)==null||a.setCaipNetwork(l)}};t===b.ConstantsUtil.AUTH_CONNECTOR_ID?this.setupAuthListeners(e):(e.on("disconnect",n),e.on("accountsChanged",s),e.on("chainChanged",i)),this.providerHandlers={disconnect:n,accountsChanged:s,chainChanged:i}}removeListeners(e){this.providerHandlers&&(e.removeListener("disconnect",this.providerHandlers.disconnect),e.removeListener("accountsChanged",this.providerHandlers.accountsChanged),e.removeListener("chainChanged",this.providerHandlers.chainChanged),this.providerHandlers=null)}setupAuthListeners(e){e.onRpcRequest(t=>{var n;b.W3mFrameHelpers.checkIfRequestExists(t)?b.W3mFrameHelpers.checkIfRequestIsSafe(t)||(n=this.appKit)==null||n.handleUnsafeRPCRequest():this.handleInvalidAuthRequest()}),e.onRpcError(()=>this.handleAuthRpcError()),e.onRpcSuccess((t,n)=>this.handleAuthRpcSuccess(t,n)),e.onNotConnected(()=>this.handleAuthNotConnected()),e.onIsConnected(({preferredAccountType:t})=>this.handleAuthIsConnected(t)),e.onSetPreferredAccount(({address:t,type:n})=>{t&&this.handleAuthSetPreferredAccount(t,n)})}handleInvalidAuthRequest(){var e;(e=this.appKit)==null||e.open(),setTimeout(()=>{var t;(t=this.appKit)==null||t.showErrorMessage(b.W3mFrameRpcConstants.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300)}handleAuthRpcError(){var e,t,n,s;(e=this.appKit)!=null&&e.isOpen()&&((t=this.appKit)!=null&&t.isTransactionStackEmpty()?(n=this.appKit)==null||n.close():(s=this.appKit)==null||s.popTransactionStack(!0))}handleAuthRpcSuccess(e,t){var s,i,o;b.W3mFrameHelpers.checkIfRequestIsSafe(t)||((s=this.appKit)!=null&&s.isTransactionStackEmpty()?(i=this.appKit)==null||i.close():(o=this.appKit)==null||o.popTransactionStack())}handleAuthNotConnected(){var e;(e=this.appKit)==null||e.setCaipAddress(void 0,this.chainNamespace)}handleAuthIsConnected(e){var n,s;((n=this.appKit)==null?void 0:n.getActiveChainNamespace())===this.chainNamespace&&((s=this.appKit)==null||s.setPreferredAccountType(e,this.chainNamespace))}handleAuthSetPreferredAccount(e,t){var i,o,a,c,l,h,d,f;if(!e)return;(i=this.appKit)==null||i.setLoading(!0);const n=b.NetworkUtil.caipNetworkIdToNumber((a=(o=this.appKit)==null?void 0:o.getCaipNetwork())==null?void 0:a.id),s=this.caipNetworks.find(g=>g.chainId===n);(c=this.appKit)==null||c.setCaipAddress(`eip155:${n}:${e}`,this.chainNamespace),(l=this.appKit)==null||l.setCaipNetwork(s),(h=this.appKit)==null||h.setStatus("connected",this.chainNamespace),(d=this.appKit)==null||d.setPreferredAccountType(t,this.chainNamespace),this.syncAccount({address:e}).then(()=>{var g;return(g=this.appKit)==null?void 0:g.setLoading(!1)}),(f=this.appKit)==null||f.setLoading(!1)}async syncReownName(e){var t,n,s,i;try{const o=await((t=this.appKit)==null?void 0:t.getReownName(e));if(o!=null&&o[0]){const a=o[0];(n=this.appKit)==null||n.setProfileName(a.name,this.chainNamespace)}else(s=this.appKit)==null||s.setProfileName(null,this.chainNamespace)}catch{(i=this.appKit)==null||i.setProfileName(null,this.chainNamespace)}}async syncAccount({address:e,caipNetwork:t}){var o,a,c,l,h,d,f,g;const n=t||((o=this.appKit)==null?void 0:o.getCaipNetwork()),s=(a=this.appKit)==null?void 0:a.getPreferredAccountType(),i=(n==null?void 0:n.chainNamespace)===b.ConstantsUtil$1.CHAIN.EVM;e?i&&((c=this.appKit)==null||c.setPreferredAccountType(s,this.chainNamespace),this.syncConnectedWalletInfo(),this.ethersConfig&&this.checkActiveProviders(this.ethersConfig),n!=null&&n.explorerUrl&&((l=this.appKit)==null||l.setAddressExplorerUrl(`${n.explorerUrl}/address/${e}`,this.chainNamespace)),await Promise.all([this.syncProfile(e),(h=this.appKit)==null?void 0:h.setApprovedCaipNetworksData(this.chainNamespace)])):((d=this.appKit)==null||d.resetWcConnection(),(f=this.appKit)==null||f.resetNetwork(),(g=this.appKit)==null||g.setAllAccounts([],this.chainNamespace))}async syncProfile(e){var n,s,i,o,a,c,l;const t=(n=this.appKit)==null?void 0:n.getCaipNetwork();try{const h=await((s=this.appKit)==null?void 0:s.fetchIdentity({address:e})),d=h==null?void 0:h.name,f=h==null?void 0:h.avatar;(i=this.appKit)==null||i.setProfileName(d,this.chainNamespace),(o=this.appKit)==null||o.setProfileImage(f,this.chainNamespace),d||await this.syncReownName(e)}catch{if((t==null?void 0:t.chainId)===1){const h=new Jr("mainnet"),d=await h.lookupAddress(e),f=await h.getAvatar(e);d?(a=this.appKit)==null||a.setProfileName(d,this.chainNamespace):await this.syncReownName(e),f&&((c=this.appKit)==null||c.setProfileImage(f,this.chainNamespace))}else await this.syncReownName(e),(l=this.appKit)==null||l.setProfileImage(null,this.chainNamespace)}}async syncBalance(e,t){var i,o;const n=(i=this.appKit)==null?void 0:i.getCaipNetworks().find(a=>a.id===t.id),s=t.chainNamespace===b.ConstantsUtil$1.CHAIN.EVM;if(t&&n&&s){const a=new Ff(t.rpcUrl,{chainId:t.chainId,name:t.name});if(a){const c=await a.getBalance(e),l=jp(c);(o=this.appKit)==null||o.setBalance(l,t.currency,this.chainNamespace)}}}syncConnectedWalletInfo(){var n,s,i,o,a,c,l;const e=b.SafeLocalStorage.getItem(b.SafeLocalStorageKeys.WALLET_ID),t=b.ProviderUtil.state.providerIds.eip155;if(t===b.ConstantsUtil.EIP6963_CONNECTOR_ID){if(e){const h=this.EIP6963Providers.find(d=>d.info.name===e);h&&((n=this.appKit)==null||n.setConnectedWalletInfo({...h.info},this.chainNamespace))}}else if(t===b.ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID){const h=b.ProviderUtil.getProvider("eip155");h!=null&&h.session&&((i=this.appKit)==null||i.setConnectedWalletInfo({...h.session.peer.metadata,name:h.session.peer.metadata.name,icon:(s=h.session.peer.metadata.icons)==null?void 0:s[0]},this.chainNamespace))}else if(t===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID){const h=(o=this.appKit)==null?void 0:o.getConnectors().find(d=>d.id===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID);(c=this.appKit)==null||c.setConnectedWalletInfo({name:"Coinbase Wallet",icon:(a=this.appKit)==null?void 0:a.getConnectorImage(h)},this.chainNamespace)}else e&&((l=this.appKit)==null||l.setConnectedWalletInfo({name:e},this.chainNamespace))}syncRequestedNetworks(e){[...new Set(e.map(n=>n.chainNamespace))].forEach(n=>{var s;(s=this.appKit)==null||s.setRequestedCaipNetworks(e.filter(i=>i.chainNamespace===n),n)})}async switchNetwork(e){var i,o,a,c,l,h,d,f;const t=async g=>{var w,m,C;try{await g.request({method:"wallet_switchEthereumChain",params:[{chainId:ur.numberToHexString(e.chainId)}]}),(w=this.appKit)==null||w.setCaipNetwork(e)}catch(v){if(v.code===bc.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||v.code===bc.ERROR_CODE_DEFAULT||((C=(m=v==null?void 0:v.data)==null?void 0:m.originalError)==null?void 0:C.code)===bc.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)await ur.addEthereumChain(g,e);else throw new Error("Chain is not supported")}},n=b.ProviderUtil.getProvider("eip155"),s=b.ProviderUtil.state.providerIds.eip155;if(n)switch(s){case b.ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID:(o=(i=this.appKit)==null?void 0:i.universalAdapter)==null||o.networkControllerClient.switchCaipNetwork(e);break;case b.ConstantsUtil.INJECTED_CONNECTOR_ID:case b.ConstantsUtil.EIP6963_CONNECTOR_ID:case b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID:n&&await t(n);break;case b.ConstantsUtil.AUTH_CONNECTOR_ID:if(this.authProvider)try{(a=this.appKit)==null||a.setLoading(!0);const{chainId:g}=await this.authProvider.switchNetwork(e.chainId),{address:w,preferredAccountType:m}=await this.authProvider.connect({chainId:e.chainId}),C=`${this.chainNamespace}:${g}:${w}`;(c=this.appKit)==null||c.setCaipNetwork(e),(l=this.appKit)==null||l.setCaipAddress(C,this.chainNamespace),(h=this.appKit)==null||h.setPreferredAccountType(m,this.chainNamespace),await this.syncAccount({address:w}),(d=this.appKit)==null||d.setLoading(!1)}catch{throw new Error("Switching chain failed")}finally{(f=this.appKit)==null||f.setLoading(!1)}break;default:throw new Error("Unsupported provider type")}}syncConnectors(e){var n,s,i,o,a;const t=[];if(e.injected){const c=b.PresetsUtil.ConnectorTypesMap[b.ConstantsUtil.INJECTED_CONNECTOR_ID];t.push({id:b.ConstantsUtil.INJECTED_CONNECTOR_ID,explorerId:b.PresetsUtil.ConnectorExplorerIds[b.ConstantsUtil.INJECTED_CONNECTOR_ID],imageId:b.PresetsUtil.ConnectorImageIds[b.ConstantsUtil.INJECTED_CONNECTOR_ID],imageUrl:(s=(n=this.options)==null?void 0:n.connectorImages)==null?void 0:s[b.ConstantsUtil.INJECTED_CONNECTOR_ID],name:b.PresetsUtil.ConnectorNamesMap[b.ConstantsUtil.INJECTED_CONNECTOR_ID],type:c,chain:this.chainNamespace})}e.coinbase&&t.push({id:b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID,explorerId:b.PresetsUtil.ConnectorExplorerIds[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],imageId:b.PresetsUtil.ConnectorImageIds[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],imageUrl:(o=(i=this.options)==null?void 0:i.connectorImages)==null?void 0:o[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],name:b.PresetsUtil.ConnectorNamesMap[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID],type:"EXTERNAL",chain:this.chainNamespace}),(a=this.appKit)==null||a.setConnectors(t)}async syncAuthConnector(e,t=!1){var n,s,i,o;if(t||typeof window<"u"){this.authProvider=b.W3mFrameProviderSingleton.getInstance(e),(n=this.appKit)==null||n.addConnector({id:b.ConstantsUtil.AUTH_CONNECTOR_ID,type:"AUTH",name:"Auth",provider:this.authProvider,chain:this.chainNamespace}),(s=this.appKit)==null||s.setLoading(!0);const a=this.authProvider.getLoginEmailUsed();(i=this.appKit)==null||i.setLoading(a);const{isConnected:c}=await this.authProvider.isConnected();c?await this.setAuthProvider():(o=this.appKit)==null||o.setLoading(!1)}}eip6963EventHandler(e){var t,n,s,i;if(e.detail){const{info:o,provider:a}=e.detail,c=(t=this.appKit)==null?void 0:t.getConnectors(),l=c==null?void 0:c.find(f=>f.name===o.name),d=(c==null?void 0:c.find(f=>f.id===b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID))&&e.detail.info.rdns===b.ConstantsUtil.CONNECTOR_RDNS_MAP[b.ConstantsUtil.COINBASE_SDK_CONNECTOR_ID];if(!l&&!d){const f=b.PresetsUtil.ConnectorTypesMap[b.ConstantsUtil.EIP6963_CONNECTOR_ID];{(i=this.appKit)==null||i.addConnector({id:b.ConstantsUtil.EIP6963_CONNECTOR_ID,type:f,imageUrl:o.icon??((s=(n=this.options)==null?void 0:n.connectorImages)==null?void 0:s[b.ConstantsUtil.EIP6963_CONNECTOR_ID]),name:o.name,provider:a,info:o,chain:this.chainNamespace});const g={provider:a,info:o};this.EIP6963Providers.push(g)}}}}listenConnectors(e){if(typeof window<"u"&&e){const t=this.eip6963EventHandler.bind(this);window.addEventListener(b.ConstantsUtil.EIP6963_ANNOUNCE_EVENT,t),window.dispatchEvent(new Event(b.ConstantsUtil.EIP6963_REQUEST_EVENT))}}}const P1="@reown/appkit-ethers",R1="1.0.1",O1="module",T1="./dist/esm/exports/index.js",B1="./dist/types/exports/index.d.ts",_1=["dist","!tsconfig.tsbuildinfo"],L1={".":{types:"./dist/types/exports/index.d.ts",import:"./dist/esm/exports/index.js",default:"./dist/esm/exports/index.js"},"./react":{types:"./dist/types/exports/react.d.ts",import:"./dist/esm/exports/react.js",default:"./dist/esm/exports/react.js"},"./vue":{types:"./dist/types/exports/vue.d.ts",import:"./dist/esm/exports/vue.js",default:"./dist/esm/exports/vue.js"}},U1={"*":{react:["./dist/types/exports/react.d.ts"],vue:["./dist/types/exports/vue.d.ts"]}},M1={"build:clean":"rm -rf dist",build:"tsc --build",watch:"tsc --watch",typecheck:"tsc --noEmit",lint:"eslint . --ext .js,.jsx,.ts,.tsx"},D1={"@coinbase/wallet-sdk":"4.0.3","@walletconnect/utils":"2.16.1","@reown/appkit":"workspace:*","@reown/appkit-adapter-ethers":"workspace:*","@reown/appkit-common":"workspace:*","@reown/appkit-wallet":"workspace:*","@reown/appkit-polyfills":"workspace:*","@reown/appkit-utils":"workspace:*","@reown/appkit-siwe":"workspace:*",valtio:"1.11.2"},F1={ethers:">=6.0.0",react:">=17","react-dom":">=17",vue:">=3"},H1={react:"18.2.0","react-dom":"18.2.0",vue:"3.4.3"},G1={react:{optional:!0},"react-dom":{optional:!0},vue:{optional:!0}},K1="Reown <support@reown.com> (https://reown.com)",j1="Apache-2.0",W1="https://github.com/reown-com/appkit",V1={type:"git",url:"git+https://github.com/WalletConnect/shadow-appkit.git"},Q1={url:"https://github.com/reown-com/appkit/issues"},z1={name:P1,version:R1,type:O1,main:T1,types:B1,files:_1,exports:L1,typesVersions:U1,scripts:M1,dependencies:D1,peerDependencies:F1,devDependencies:H1,peerDependenciesMeta:G1,author:K1,license:j1,homepage:W1,repository:V1,bugs:Q1};function J1(r){const e=new x1;return new b.AppKit({...r,sdkVersion:`html-ethers-${z1.version}`,adapters:[e]})}const q1=Object.freeze(Object.defineProperty({__proto__:null,createAppKit:J1},Symbol.toStringTag,{value:"Module"}));exports.AppKit=q1;