coinley-checkout 0.8.0 → 0.8.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.
@@ -1,17 +1,17 @@
|
|
1
|
-
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__reflectGet=Reflect.get,__pow=Math.pow,__defNormalProp=(t,e,n)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,__spreadValues=(t,e)=>{for(var n in e||(e={}))__hasOwnProp.call(e,n)&&__defNormalProp(t,n,e[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))__propIsEnum.call(e,n)&&__defNormalProp(t,n,e[n]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__publicField=(t,e,n)=>(__defNormalProp(t,"symbol"!=typeof e?e+"":e,n),n),__accessCheck=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},__privateGet=(t,e,n)=>(__accessCheck(t,e,"read from private field"),n?n.call(t):e.get(t)),__privateAdd=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},__privateSet=(t,e,n,r)=>(__accessCheck(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),__privateWrapper=(t,e,n,r)=>({set _(r){__privateSet(t,e,r,n)},get _(){return __privateGet(t,e,r)}}),__privateMethod=(t,e,n)=>(__accessCheck(t,e,"access private method"),n),__superGet=(t,e,n)=>__reflectGet(__getProtoOf(t),n,e),__async=(t,e,n)=>new Promise(((r,i)=>{var s=t=>{try{a(n.next(t))}catch(e){i(e)}},o=t=>{try{a(n.throw(t))}catch(e){i(e)}},a=t=>t.done?r(t.value):Promise.resolve(t.value).then(s,o);a((n=n.apply(t,e)).next())}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).CoinleyCheckout={},t.React)}(this,(function(t,e){var n,r,i,s,o,a,l,c,u,h,d,p,f,g,m,_,y,w,v,b,A,E,x,k,S,N,C,P,T,M,R,B,I,G,O,L,F,U,D,j,H,W,Q,z,V,K,J,q,Z,Y,X,$,tt,et,nt,rt,it,st,ot,at,lt,ct,ut,ht,dt,pt,ft,gt,mt,_t,yt,wt,vt,bt,At,Et,xt,kt,St,Nt,Ct,Pt,Tt,Mt,Rt,Bt,It,Gt,Ot,Lt,Ft,Ut,Dt,jt,Ht,Wt,Qt,zt,Vt,Kt,Jt,qt,Zt,Yt,Xt,$t,te,ee,ne,re,ie,se,oe,ae,le,ce,ue,he,de,pe,fe,ge,me,_e,ye,we,ve,be,Ae,Ee,xe,ke,Se,Ne,Ce,Pe,Te,Me,Re,Be,Ie,Ge,Oe,Le,Fe,Ue,De,je,He,We,Qe,ze,Ve,Ke,Je,qe,Ze,Ye,Xe,$e,tn,en,nn,rn,sn,on,an,ln,cn,un,hn,dn,pn,fn,gn,mn,_n,yn,wn,vn,bn,An,En,xn,kn,Sn,Nn,Cn;function Pn(t,e,n){const r=e.split("|").map((t=>t.trim()));for(let s=0;s<r.length;s++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${n}`,i.value=t,i}function Tn(t){return __async(this,null,(function*(){const e=Object.keys(t);return(yield Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,n,r)=>(t[e[r]]=n,t)),{})}))}function Mn(t,e,n){for(let r in e){let i=e[r];const s=n?n[r]:null;s&&Pn(i,s,r),Object.defineProperty(t,r,{enumerable:!0,value:i,writable:!1})}}function Rn(t,e){if(null==t)return"null";if(null==e&&(e=new Set),"object"==typeof t){if(e.has(t))return"[Circular]";e.add(t)}if(Array.isArray(t))return"[ "+t.map((t=>Rn(t,e))).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let n="0x";for(let r=0;r<t.length;r++)n+=e[t[r]>>4],n+=e[15&t[r]];return n}if("object"==typeof t&&"function"==typeof t.toJSON)return Rn(t.toJSON(),e);switch(typeof t){case"boolean":case"number":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const n=Object.keys(t);return n.sort(),"{ "+n.map((n=>`${Rn(n,e)}: ${Rn(t[n],e)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Bn(t,e){return t&&t.code===e}function In(t){return Bn(t,"CALL_EXCEPTION")}function Gn(t,e,n){let r,i=t;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${Rn(n)}`);for(const t in n){if("shortMessage"===t)continue;const e=n[t];r.push(t+"="+Rn(e))}}r.push(`code=${e}`),r.push("version=6.14.3"),r.length&&(t+=" ("+r.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":r=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(t);break;default:r=new Error(t)}return Mn(r,{code:e}),n&&Object.assign(r,n),null==r.shortMessage&&Mn(r,{shortMessage:i}),r}function On(t,e,n,r){if(!t)throw Gn(e,n,r)}function Ln(t,e,n,r){On(t,e,"INVALID_ARGUMENT",{argument:n,value:r})}function Fn(t,e,n){null==n&&(n=""),n&&(n=": "+n),On(t>=e,"missing argument"+n,"MISSING_ARGUMENT",{count:t,expectedCount:e}),On(t<=e,"too many arguments"+n,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const Un=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){const t=String.fromCharCode(233).normalize("NFD");if(t!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(n){}return t}),[]);function Dn(t,e,n){if(null==n&&(n=""),t!==e){let t=n,e="new";n&&(t+=".",e+=" "+n),On(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function jn(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if("string"==typeof t&&t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const e=new Uint8Array((t.length-2)/2);let n=2;for(let r=0;r<e.length;r++)e[r]=parseInt(t.substring(n,n+2),16),n+=2;return e}Ln(!1,"invalid BytesLike value",e||"value",t)}function Hn(t,e){return jn(t,e,!1)}function Wn(t,e){return jn(t,e,!0)}function Qn(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(("number"!=typeof e||t.length===2+2*e)&&(!0!==e||t.length%2==0))}function zn(t){return Qn(t,!0)||t instanceof Uint8Array}const Vn="0123456789abcdef";function Kn(t){const e=Hn(t);let n="0x";for(let r=0;r<e.length;r++){const t=e[r];n+=Vn[(240&t)>>4]+Vn[15&t]}return n}function Jn(t){return"0x"+t.map((t=>Kn(t).substring(2))).join("")}function qn(t){return Qn(t,!0)?(t.length-2)/2:Hn(t).length}function Zn(t,e,n){const r=Hn(t);return null!=n&&n>r.length&&On(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n}),Kn(r.slice(null==e?0:e,null==n?r.length:n))}function Yn(t,e,n){const r=Hn(t);On(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),n?i.set(r,e-r.length):i.set(r,0),Kn(i)}function Xn(t,e){return Yn(t,e,!0)}const $n=BigInt(0),tr=BigInt(1),er=9007199254740991;function nr(t,e){const n=or(t,"value"),r=BigInt(cr(e,"width"));if(On(n>>r===$n,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),n>>r-tr){return-((~n&(tr<<r)-tr)+tr)}return n}function rr(t,e){let n=sr(t,"value");const r=BigInt(cr(e,"width")),i=tr<<r-tr;if(n<$n){n=-n,On(n<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return(~n&(tr<<r)-tr)+tr}return On(n<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),n}function ir(t,e){const n=or(t,"value"),r=BigInt(cr(e,"bits"));return n&(tr<<r)-tr}function sr(t,e){switch(typeof t){case"bigint":return t;case"number":return Ln(Number.isInteger(t),"underflow",e||"value",t),Ln(t>=-er&&t<=er,"overflow",e||"value",t),BigInt(t);case"string":try{if(""===t)throw new Error("empty string");return"-"===t[0]&&"-"!==t[1]?-BigInt(t.substring(1)):BigInt(t)}catch(n){Ln(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}Ln(!1,"invalid BigNumberish value",e||"value",t)}function or(t,e){const n=sr(t,e);return On(n>=$n,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}const ar="0123456789abcdef";function lr(t){if(t instanceof Uint8Array){let e="0x0";for(const n of t)e+=ar[n>>4],e+=ar[15&n];return BigInt(e)}return sr(t)}function cr(t,e){switch(typeof t){case"bigint":return Ln(t>=-er&&t<=er,"overflow",e||"value",t),Number(t);case"number":return Ln(Number.isInteger(t),"underflow",e||"value",t),Ln(t>=-er&&t<=er,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return cr(BigInt(t),e)}catch(n){Ln(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}Ln(!1,"invalid numeric value",e||"value",t)}function ur(t,e){let n=or(t,"value").toString(16);if(null==e)n.length%2&&(n="0"+n);else{const r=cr(e,"width");for(On(2*r>=n.length,`value exceeds width (${r} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});n.length<2*r;)n="0"+n}return"0x"+n}function hr(t){const e=or(t,"value");if(e===$n)return new Uint8Array([]);let n=e.toString(16);n.length%2&&(n="0"+n);const r=new Uint8Array(n.length/2);for(let i=0;i<r.length;i++){const t=2*i;r[i]=parseInt(n.substring(t,t+2),16)}return r}function dr(t){let e=Kn(zn(t)?t:hr(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const pr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const fr=BigInt(58);class gr{constructor(t,e,r){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,n,void 0),__privateSet(this,n,e),Mn(this,{emitter:t,filter:r})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,n)&&(yield this.emitter.off(this.filter,__privateGet(this,n)))}))}}function mr(t,e,n,r,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let r=e+1;r<n.length&&n[r]>>6==2;r++)t++;return t}return"OVERRUN"===t?n.length-e-1:0}n=new WeakMap;const _r=Object.freeze({error:function(t,e,n,r,i){Ln(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",n)},ignore:mr,replace:function(t,e,n,r,i){return"OVERLONG"===t?(Ln("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),mr(t,e,n))}});function yr(t,e){Ln("string"==typeof t,"invalid string value","str",t),null!=e&&(!function(t){On(Un.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let n=[];for(let r=0;r<t.length;r++){const e=t.charCodeAt(r);if(e<128)n.push(e);else if(e<2048)n.push(e>>6|192),n.push(63&e|128);else if(55296==(64512&e)){r++;const i=t.charCodeAt(r);Ln(r<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const s=65536+((1023&e)<<10)+(1023&i);n.push(s>>18|240),n.push(s>>12&63|128),n.push(s>>6&63|128),n.push(63&s|128)}else n.push(e>>12|224),n.push(e>>6&63|128),n.push(63&e|128)}return new Uint8Array(n)}function wr(t,e){return n=function(t,e){null==e&&(e=_r.error);const n=Hn(t,"bytes"),r=[];let i=0;for(;i<n.length;){const t=n[i++];if(!(t>>7)){r.push(t);continue}let s=null,o=null;if(192==(224&t))s=1,o=127;else if(224==(240&t))s=2,o=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,n,r);continue}s=3,o=65535}if(i-1+s>=n.length){i+=e("OVERRUN",i-1,n,r);continue}let a=t&(1<<8-s-1)-1;for(let l=0;l<s;l++){let t=n[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,n,r),a=null;break}a=a<<6|63&t,i++}null!==a&&(a>1114111?i+=e("OUT_OF_RANGE",i-1-s,n,r,a):a>=55296&&a<=57343?i+=e("UTF16_SURROGATE",i-1-s,n,r,a):a<=o?i+=e("OVERLONG",i-1-s,n,r,a):r.push(a))}return r}(t,e),n.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("");var n}function vr(t){return function(e,n){return __async(this,null,(function*(){On(null==n||!n.cancelled,"request cancelled before sending","CANCELLED");const r=e.url.split(":")[0].toLowerCase();On("http"===r||"https"===r,`unsupported protocol ${r}`,"UNSUPPORTED_OPERATION",{info:{protocol:r},operation:"request"}),On("https"===r||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const s=new AbortController,o=setTimeout((()=>{i=Gn("request timeout","TIMEOUT"),s.abort()}),e.timeout);n&&n.addListener((()=>{i=Gn("request cancelled","CANCELLED"),s.abort()}));const a=Object.assign({},t,{method:e.method,headers:new Headers(Array.from(e)),body:e.body||void 0,signal:s.signal});let l;try{l=yield fetch(e.url,a)}catch(d){if(clearTimeout(o),i)throw i;throw d}clearTimeout(o);const c={};l.headers.forEach(((t,e)=>{c[e.toLowerCase()]=t}));const u=yield l.arrayBuffer(),h=null==u?null:new Uint8Array(u);return{statusCode:l.status,statusMessage:l.statusText,headers:c,body:h}}))}}let br=vr();const Ar=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),Er=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let xr=!1;function kr(t,e){return __async(this,null,(function*(){try{const e=t.match(Ar);if(!e)throw new Error("invalid data");return new Ir(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return Hn(e)}(e[3]):yr(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new Ir(599,"BAD REQUEST (invalid data: URI)",{},null,new Rr(t))}}))}function Sr(t){return function(e,n){return __async(this,null,(function*(){try{const n=e.match(Er);if(!n)throw new Error("invalid link");return new Rr(`${t}${n[2]}`)}catch(n){return new Ir(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Rr(e))}}))}}const Nr={data:kr,ipfs:Sr("https://gateway.ipfs.io/ipfs/")},Cr=new WeakMap;class Pr{constructor(t){__privateAdd(this,r,void 0),__privateAdd(this,i,void 0),__privateSet(this,r,[]),__privateSet(this,i,!1),Cr.set(t,(()=>{if(!__privateGet(this,i)){__privateSet(this,i,!0);for(const t of __privateGet(this,r))setTimeout((()=>{t()}),0);__privateSet(this,r,[])}}))}addListener(t){On(!__privateGet(this,i),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),__privateGet(this,r).push(t)}get cancelled(){return __privateGet(this,i)}checkSignal(){On(!this.cancelled,"cancelled","CANCELLED",{})}}function Tr(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}r=new WeakMap,i=new WeakMap;const Mr=class t{constructor(t){__privateAdd(this,v),__privateAdd(this,s,void 0),__privateAdd(this,o,void 0),__privateAdd(this,a,void 0),__privateAdd(this,l,void 0),__privateAdd(this,c,void 0),__privateAdd(this,u,void 0),__privateAdd(this,h,void 0),__privateAdd(this,d,void 0),__privateAdd(this,p,void 0),__privateAdd(this,f,void 0),__privateAdd(this,g,void 0),__privateAdd(this,m,void 0),__privateAdd(this,_,void 0),__privateAdd(this,y,void 0),__privateAdd(this,w,void 0),__privateSet(this,u,String(t)),__privateSet(this,s,!1),__privateSet(this,o,!0),__privateSet(this,a,{}),__privateSet(this,l,""),__privateSet(this,c,3e5),__privateSet(this,y,{slotInterval:250,maxAttempts:12}),__privateSet(this,w,null)}get url(){return __privateGet(this,u)}set url(t){__privateSet(this,u,String(t))}get body(){return null==__privateGet(this,h)?null:new Uint8Array(__privateGet(this,h))}set body(t){if(null==t)__privateSet(this,h,void 0),__privateSet(this,d,void 0);else if("string"==typeof t)__privateSet(this,h,yr(t)),__privateSet(this,d,"text/plain");else if(t instanceof Uint8Array)__privateSet(this,h,t),__privateSet(this,d,"application/octet-stream");else{if("object"!=typeof t)throw new Error("invalid body");__privateSet(this,h,yr(JSON.stringify(t))),__privateSet(this,d,"application/json")}}hasBody(){return null!=__privateGet(this,h)}get method(){return __privateGet(this,l)?__privateGet(this,l):this.hasBody()?"POST":"GET"}set method(t){null==t&&(t=""),__privateSet(this,l,String(t).toUpperCase())}get headers(){const t=Object.assign({},__privateGet(this,a));return __privateGet(this,p)&&(t.authorization=`Basic ${function(t){const e=Hn(t);let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}(yr(__privateGet(this,p)))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),null==t["content-type"]&&__privateGet(this,d)&&(t["content-type"]=__privateGet(this,d)),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){__privateGet(this,a)[String(t).toLowerCase()]=String(e)}clearHeaders(){__privateSet(this,a,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let n=0;return{next:()=>{if(n<e.length){const r=e[n++];return{value:[r,t[r]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return __privateGet(this,p)||null}setCredentials(t,e){Ln(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),__privateSet(this,p,`${t}:${e}`)}get allowGzip(){return __privateGet(this,o)}set allowGzip(t){__privateSet(this,o,!!t)}get allowInsecureAuthentication(){return!!__privateGet(this,s)}set allowInsecureAuthentication(t){__privateSet(this,s,!!t)}get timeout(){return __privateGet(this,c)}set timeout(t){Ln(t>=0,"timeout must be non-zero","timeout",t),__privateSet(this,c,t)}get preflightFunc(){return __privateGet(this,f)||null}set preflightFunc(t){__privateSet(this,f,t)}get processFunc(){return __privateGet(this,g)||null}set processFunc(t){__privateSet(this,g,t)}get retryFunc(){return __privateGet(this,m)||null}set retryFunc(t){__privateSet(this,m,t)}get getUrlFunc(){return __privateGet(this,w)||br}set getUrlFunc(t){__privateSet(this,w,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${__privateGet(this,h)?Kn(__privateGet(this,h)):"null"}>`}setThrottleParams(t){null!=t.slotInterval&&(__privateGet(this,y).slotInterval=t.slotInterval),null!=t.maxAttempts&&(__privateGet(this,y).maxAttempts=t.maxAttempts)}send(){return On(null==__privateGet(this,_),"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),__privateSet(this,_,new Pr(this)),__privateMethod(this,v,b).call(this,0,Gr()+this.timeout,0,this,new Ir(0,"",{},null,this))}cancel(){On(null!=__privateGet(this,_),"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Cr.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(e){const n=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();On("GET"===this.method&&("https"!==n||"http"!==r)&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const i=new t(e);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,__privateSet(i,a,Object.assign({},__privateGet(this,a))),__privateGet(this,h)&&__privateSet(i,h,new Uint8Array(__privateGet(this,h))),__privateSet(i,d,__privateGet(this,d)),i}clone(){const e=new t(this.url);return __privateSet(e,l,__privateGet(this,l)),__privateGet(this,h)&&__privateSet(e,h,__privateGet(this,h)),__privateSet(e,d,__privateGet(this,d)),__privateSet(e,a,Object.assign({},__privateGet(this,a))),__privateSet(e,p,__privateGet(this,p)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),__privateSet(e,f,__privateGet(this,f)),__privateSet(e,g,__privateGet(this,g)),__privateSet(e,m,__privateGet(this,m)),__privateSet(e,y,Object.assign({},__privateGet(this,y))),__privateSet(e,w,__privateGet(this,w)),e}static lockConfig(){xr=!0}static getGateway(t){return Nr[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(xr)throw new Error("gateways locked");Nr[t]=e}static registerGetUrl(t){if(xr)throw new Error("gateways locked");br=t}static createGetUrlFunc(t){return vr(t)}static createDataGateway(){return kr}static createIpfsGatewayFunc(t){return Sr(t)}};s=new WeakMap,o=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,h=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,m=new WeakMap,_=new WeakMap,y=new WeakMap,w=new WeakMap,v=new WeakSet,b=function(t,e,n,r,i){return __async(this,null,(function*(){var s,o,a;if(t>=__privateGet(this,y).maxAttempts)return i.makeServerError("exceeded maximum retry limit");On(Gr()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:r}),n>0&&(yield function(t){return new Promise((e=>setTimeout(e,t)))}(n));let l=this.clone();const c=(l.url.split(":")[0]||"").toLowerCase();if(c in Nr){const t=yield Nr[c](l.url,Tr(__privateGet(r,_)));if(t instanceof Ir){let e=t;if(this.processFunc){Tr(__privateGet(r,_));try{e=yield this.processFunc(l,e)}catch(d){null!=d.throttle&&"number"==typeof d.stall||e.makeServerError("error in post-processing function",d).assertOk()}}return e}l=t}this.preflightFunc&&(l=yield this.preflightFunc(l));const u=yield this.getUrlFunc(l,Tr(__privateGet(r,_)));let h=new Ir(u.statusCode,u.statusMessage,u.headers,u.body,r);if(301===h.statusCode||302===h.statusCode){try{const n=h.headers.location||"";return __privateMethod(s=l.redirect(n),v,b).call(s,t+1,e,0,r,h)}catch(d){}return h}if(429===h.statusCode&&(null==this.retryFunc||(yield this.retryFunc(l,h,t)))){const n=h.headers["retry-after"];let i=__privateGet(this,y).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof n&&n.match(/^[1-9][0-9]*$/)&&(i=parseInt(n)),__privateMethod(o=l.clone(),v,b).call(o,t+1,e,i,r,h)}if(this.processFunc){Tr(__privateGet(r,_));try{h=yield this.processFunc(l,h)}catch(d){null!=d.throttle&&"number"==typeof d.stall||h.makeServerError("error in post-processing function",d).assertOk();let n=__privateGet(this,y).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return d.stall>=0&&(n=d.stall),__privateMethod(a=l.clone(),v,b).call(a,t+1,e,n,r,h)}}return h}))};let Rr=Mr;const Br=class t{constructor(t,e,n,r,i){__privateAdd(this,A,void 0),__privateAdd(this,E,void 0),__privateAdd(this,x,void 0),__privateAdd(this,k,void 0),__privateAdd(this,S,void 0),__privateAdd(this,N,void 0),__privateSet(this,A,t),__privateSet(this,E,e),__privateSet(this,x,Object.keys(n).reduce(((t,e)=>(t[e.toLowerCase()]=String(n[e]),t)),{})),__privateSet(this,k,null==r?null:new Uint8Array(r)),__privateSet(this,S,i||null),__privateSet(this,N,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${__privateGet(this,k)?Kn(__privateGet(this,k)):"null"}>`}get statusCode(){return __privateGet(this,A)}get statusMessage(){return __privateGet(this,E)}get headers(){return Object.assign({},__privateGet(this,x))}get body(){return null==__privateGet(this,k)?null:new Uint8Array(__privateGet(this,k))}get bodyText(){try{return null==__privateGet(this,k)?"":wr(__privateGet(this,k))}catch(t){On(!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(t){On(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let n=0;return{next:()=>{if(n<e.length){const r=e[n++];return{value:[r,t[r]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,n){let r;r=e?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:`CLIENT ESCALATED SERVER ERROR (${e=`${this.statusCode} ${this.statusMessage}`})`;const i=new t(599,r,this.headers,this.body,__privateGet(this,S)||void 0);return __privateSet(i,N,{message:e,error:n}),i}throwThrottleError(t,e){null==e?e=-1:Ln(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const n=new Error(t||"throttling requests");throw Mn(n,{stall:e,throttle:!0}),n}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return null!=__privateGet(this,k)}get request(){return __privateGet(this,S)}ok(){return""===__privateGet(this,N).message&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=__privateGet(this,N);""===t&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let r=null;try{__privateGet(this,k)&&(r=wr(__privateGet(this,k)))}catch(i){}On(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:n,responseBody:r,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};A=new WeakMap,E=new WeakMap,x=new WeakMap,k=new WeakMap,S=new WeakMap,N=new WeakMap;let Ir=Br;function Gr(){return(new Date).getTime()}const Or=BigInt(-1),Lr=BigInt(0),Fr=BigInt(1),Ur=BigInt(5),Dr={};let jr="0000";for(;jr.length<80;)jr+=jr;function Hr(t){let e=jr;for(;e.length<t;)e+=e;return BigInt("1"+e.substring(0,t))}function Wr(t,e,n){const r=BigInt(e.width);if(e.signed){const e=Fr<<r-Fr;On(null==n||t>=-e&&t<e,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:t}),t=t>Lr?nr(ir(t,r),r):-nr(ir(-t,r),r)}else{const e=Fr<<r;On(null==n||t>=0&&t<e,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:t}),t=(t%e+e)%e&e-Fr}return t}function Qr(t){"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,n=128,r=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)e=!1;else{const i=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);Ln(i,"invalid fixed format","format",t),e="u"!==i[1],n=parseInt(i[2]),r=parseInt(i[3])}else if(t){const i=t,s=(t,e,n)=>null==i[t]?n:(Ln(typeof i[t]===e,"invalid fixed format ("+t+" not "+e+")","format."+t,i[t]),i[t]);e=s("signed","boolean",e),n=s("width","number",n),r=s("decimals","number",r)}Ln(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Ln(r<=80,"invalid FixedNumber decimals (too large)","format.decimals",r);return{signed:e,width:n,decimals:r,name:(e?"":"u")+"fixed"+String(n)+"x"+String(r)}}const zr=class t{constructor(t,e,n){__privateAdd(this,M),__privateAdd(this,B),__privateAdd(this,G),__privateAdd(this,L),__privateAdd(this,U),__privateAdd(this,j),__publicField(this,"format"),__privateAdd(this,C,void 0),__privateAdd(this,P,void 0),__privateAdd(this,T,void 0),__publicField(this,"_value"),Dn(t,Dr,"FixedNumber"),__privateSet(this,P,e),__privateSet(this,C,n);const r=function(t,e){let n="";t<Lr&&(n="-",t*=Or);let r=t.toString();if(0===e)return n+r;for(;r.length<=e;)r=jr+r;const i=r.length-e;for(r=r.substring(0,i)+"."+r.substring(i);"0"===r[0]&&"."!==r[1];)r=r.substring(1);for(;"0"===r[r.length-1]&&"."!==r[r.length-2];)r=r.substring(0,r.length-1);return n+r}(e,n.decimals);Mn(this,{format:n.name,_value:r}),__privateSet(this,T,Hr(n.decimals))}get signed(){return __privateGet(this,C).signed}get width(){return __privateGet(this,C).width}get decimals(){return __privateGet(this,C).decimals}get value(){return __privateGet(this,P)}addUnsafe(t){return __privateMethod(this,G,O).call(this,t)}add(t){return __privateMethod(this,G,O).call(this,t,"add")}subUnsafe(t){return __privateMethod(this,L,F).call(this,t)}sub(t){return __privateMethod(this,L,F).call(this,t,"sub")}mulUnsafe(t){return __privateMethod(this,U,D).call(this,t)}mul(t){return __privateMethod(this,U,D).call(this,t,"mul")}mulSignal(t){__privateMethod(this,M,R).call(this,t);const e=__privateGet(this,P)*__privateGet(t,P);return On(e%__privateGet(this,T)===Lr,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,B,I).call(this,e/__privateGet(this,T),"mulSignal")}divUnsafe(t){return __privateMethod(this,j,H).call(this,t)}div(t){return __privateMethod(this,j,H).call(this,t,"div")}divSignal(t){On(__privateGet(t,P)!==Lr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,M,R).call(this,t);const e=__privateGet(this,P)*__privateGet(this,T);return On(e%__privateGet(t,P)===Lr,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,B,I).call(this,e/__privateGet(t,P),"divSignal")}cmp(t){let e=this.value,n=t.value;const r=this.decimals-t.decimals;return r>0?n*=Hr(r):r<0&&(e*=Hr(-r)),e<n?-1:e>n?1:0}eq(t){return 0===this.cmp(t)}lt(t){return this.cmp(t)<0}lte(t){return this.cmp(t)<=0}gt(t){return this.cmp(t)>0}gte(t){return this.cmp(t)>=0}floor(){let t=__privateGet(this,P);return __privateGet(this,P)<Lr&&(t-=__privateGet(this,T)-Fr),t=__privateGet(this,P)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,B,I).call(this,t,"floor")}ceiling(){let t=__privateGet(this,P);return __privateGet(this,P)>Lr&&(t+=__privateGet(this,T)-Fr),t=__privateGet(this,P)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,B,I).call(this,t,"ceiling")}round(e){if(null==e&&(e=0),e>=this.decimals)return this;const n=this.decimals-e,r=Ur*Hr(n-1);let i=this.value+r;const s=Hr(n);return i=i/s*s,Wr(i,__privateGet(this,C),"round"),new t(Dr,i,__privateGet(this,C))}isZero(){return __privateGet(this,P)===Lr}isNegative(){return __privateGet(this,P)<Lr}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return t.fromString(this.toString(),e)}static fromValue(e,n,r){const i=null==n?0:cr(n),s=Qr(r);let o=sr(e,"value");const a=i-s.decimals;if(a>0){const t=Hr(a);On(o%t===Lr,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),o/=t}else a<0&&(o*=Hr(-a));return Wr(o,s,"fromValue"),new t(Dr,o,s)}static fromString(e,n){const r=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Ln(r&&r[2].length+r[3].length>0,"invalid FixedNumber string value","value",e);const i=Qr(n);let s=r[2]||"0",o=r[3]||"";for(;o.length<i.decimals;)o+=jr;On(o.substring(i.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),o=o.substring(0,i.decimals);const a=BigInt(r[1]+s+o);return Wr(a,i,"fromString"),new t(Dr,a,i)}static fromBytes(e,n){let r=lr(Hn(e,"value"));const i=Qr(n);return i.signed&&(r=nr(r,i.width)),Wr(r,i,"fromBytes"),new t(Dr,r,i)}};C=new WeakMap,P=new WeakMap,T=new WeakMap,M=new WeakSet,R=function(t){Ln(this.format===t.format,"incompatible format; use fixedNumber.toFormat","other",t)},B=new WeakSet,I=function(t,e){return t=Wr(t,__privateGet(this,C),e),new zr(Dr,t,__privateGet(this,C))},G=new WeakSet,O=function(t,e){return __privateMethod(this,M,R).call(this,t),__privateMethod(this,B,I).call(this,__privateGet(this,P)+__privateGet(t,P),e)},L=new WeakSet,F=function(t,e){return __privateMethod(this,M,R).call(this,t),__privateMethod(this,B,I).call(this,__privateGet(this,P)-__privateGet(t,P),e)},U=new WeakSet,D=function(t,e){return __privateMethod(this,M,R).call(this,t),__privateMethod(this,B,I).call(this,__privateGet(this,P)*__privateGet(t,P)/__privateGet(this,T),e)},j=new WeakSet,H=function(t,e){return On(__privateGet(t,P)!==Lr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,M,R).call(this,t),__privateMethod(this,B,I).call(this,__privateGet(this,P)*__privateGet(this,T)/__privateGet(t,P),e)};let Vr=zr;function Kr(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Jr(t,e,n){let r=0;for(let i=0;i<n;i++)r=256*r+t[e+i];return r}function qr(t,e,n,r){const i=[];for(;n<e+1+r;){const s=Zr(t,n);i.push(s.result),On((n+=s.consumed)<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:t,length:r,offset:e})}return{consumed:1+r,result:i}}function Zr(t,e){On(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const n=e=>{On(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const r=t[e]-247;n(e+1+r);const i=Jr(t,e+1,r);return n(e+1+r+i),qr(t,e,e+1+r,r+i)}if(t[e]>=192){const r=t[e]-192;return n(e+1+r),qr(t,e,e+1,r)}if(t[e]>=184){const r=t[e]-183;n(e+1+r);const i=Jr(t,e+1,r);n(e+1+r+i);return{consumed:1+r+i,result:Kn(t.slice(e+1+r,e+1+r+i))}}if(t[e]>=128){const r=t[e]-128;n(e+1+r);return{consumed:1+r,result:Kn(t.slice(e+1,e+1+r))}}return{consumed:1,result:Kr(t[e])}}function Yr(t){const e=Hn(t,"data"),n=Zr(e,0);return Ln(n.consumed===e.length,"unexpected junk after rlp payload","data",t),n.result}function Xr(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function $r(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat($r(t))})),e.length<=55)return e.unshift(192+e.length),e;const n=Xr(e.length);return n.unshift(247+n.length),n.concat(e)}const e=Array.prototype.slice.call(Hn(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const n=Xr(e.length);return n.unshift(183+n.length),n.concat(e)}const ti="0123456789abcdef";function ei(t){let e="0x";for(const n of $r(t))e+=ti[n>>4],e+=ti[15&n];return e}const ni=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ri(t,e){let n=18;if("string"==typeof e){const t=ni.indexOf(e);Ln(t>=0,"invalid unit","unit",e),n=3*t}else null!=e&&(n=cr(e,"unit"));return Vr.fromValue(t,n,{decimals:n,width:512}).toString()}function ii(t,e){Ln("string"==typeof t,"value must be a string","value",t);let n=18;if("string"==typeof e){const t=ni.indexOf(e);Ln(t>=0,"invalid unit","unit",e),n=3*t}else null!=e&&(n=cr(e,"unit"));return Vr.fromString(t,{decimals:n,width:512}).value}const si=32,oi=new Uint8Array(si),ai=["then"],li={},ci=new WeakMap;function ui(t){return ci.get(t)}function hi(t,e){ci.set(t,e)}function di(t,e){const n=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw n.error=e,n}function pi(t,e,n){return t.indexOf(null)>=0?e.map(((t,e)=>t instanceof fi?pi(ui(t),t,n):t)):t.reduce(((t,r,i)=>{let s=e.getValue(r);return r in t||(n&&s instanceof fi&&(s=pi(ui(s),s,n)),t[r]=s),t}),{})}W=new WeakMap;let fi=class t extends Array{constructor(...t){const e=t[0];let n=t[1],r=(t[2]||[]).slice(),i=!0;e!==li&&(n=t,r=[],i=!1),super(n.length),__privateAdd(this,W,void 0),n.forEach(((t,e)=>{this[e]=t}));const s=r.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(hi(this,Object.freeze(n.map(((t,e)=>{const n=r[e];return null!=n&&1===s.get(n)?n:null})))),__privateSet(this,W,[]),null==__privateGet(this,W)&&__privateGet(this,W),!i)return;Object.freeze(this);const o=new Proxy(this,{get:(t,e,n)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const n=cr(e,"%index");if(n<0||n>=this.length)throw new RangeError("out of result range");const r=t[n];return r instanceof Error&&di(`index ${n}`,r),r}if(ai.indexOf(e)>=0)return Reflect.get(t,e,n);const r=t[e];if(r instanceof Function)return function(...e){return r.apply(this===n?t:this,e)};if(!(e in t))return t.getValue.apply(this===n?t:this,[e])}return Reflect.get(t,e,n)}});return hi(o,ui(this)),o}toArray(e){const n=[];return this.forEach(((r,i)=>{r instanceof Error&&di(`index ${i}`,r),e&&r instanceof t&&(r=r.toArray(e)),n.push(r)})),n}toObject(t){const e=ui(this);return e.reduce(((n,r,i)=>(On(null!=r,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),pi(e,this,t))),{})}slice(e,n){null==e&&(e=0),e<0&&(e+=this.length)<0&&(e=0),null==n&&(n=this.length),n<0&&(n+=this.length)<0&&(n=0),n>this.length&&(n=this.length);const r=ui(this),i=[],s=[];for(let t=e;t<n;t++)i.push(this[t]),s.push(r[t]);return new t(li,i,s)}filter(e,n){const r=ui(this),i=[],s=[];for(let t=0;t<this.length;t++){const o=this[t];o instanceof Error&&di(`index ${t}`,o),e.call(n,o,t,this)&&(i.push(o),s.push(r[t]))}return new t(li,i,s)}map(t,e){const n=[];for(let r=0;r<this.length;r++){const i=this[r];i instanceof Error&&di(`index ${r}`,i),n.push(t.call(e,i,r,this))}return n}getValue(t){const e=ui(this).indexOf(t);if(-1===e)return;const n=this[e];return n instanceof Error&&di(`property ${JSON.stringify(t)}`,n.error),n}static fromItems(e,n){return new t(li,e,n)}};function gi(t){let e=hr(t);return On(e.length<=si,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:si,offset:e.length}),e.length!==si&&(e=Wn(Jn([oi.slice(e.length%si),e]))),e}class mi{constructor(t,e,n,r){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),Mn(this,{name:t,type:e,localName:n,dynamic:r},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){Ln(!1,t,this.localName,e)}}class _i{constructor(){__privateAdd(this,V),__privateAdd(this,Q,void 0),__privateAdd(this,z,void 0),__privateSet(this,Q,[]),__privateSet(this,z,0)}get data(){return Jn(__privateGet(this,Q))}get length(){return __privateGet(this,z)}appendWriter(t){return __privateMethod(this,V,K).call(this,Wn(t.data))}writeBytes(t){let e=Wn(t);const n=e.length%si;return n&&(e=Wn(Jn([e,oi.slice(n)]))),__privateMethod(this,V,K).call(this,e)}writeValue(t){return __privateMethod(this,V,K).call(this,gi(t))}writeUpdatableValue(){const t=__privateGet(this,Q).length;return __privateGet(this,Q).push(oi),__privateSet(this,z,__privateGet(this,z)+si),e=>{__privateGet(this,Q)[t]=gi(e)}}}Q=new WeakMap,z=new WeakMap,V=new WeakSet,K=function(t){return __privateGet(this,Q).push(t),__privateSet(this,z,__privateGet(this,z)+t.length),t.length};J=new WeakMap,q=new WeakMap,Z=new WeakMap,Y=new WeakMap,X=new WeakMap,$=new WeakSet,tt=function(t){var e;if(__privateGet(this,Y))return __privateMethod(e=__privateGet(this,Y),$,tt).call(e,t);__privateSet(this,Z,__privateGet(this,Z)+t),On(__privateGet(this,X)<1||__privateGet(this,Z)<=__privateGet(this,X)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${__privateGet(this,X)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Wn(__privateGet(this,J)),offset:__privateGet(this,q),length:t,info:{bytesRead:__privateGet(this,Z),dataLength:this.dataLength}})},et=new WeakSet,nt=function(t,e,n){let r=Math.ceil(e/si)*si;return __privateGet(this,q)+r>__privateGet(this,J).length&&(this.allowLoose&&n&&__privateGet(this,q)+e<=__privateGet(this,J).length?r=e:On(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Wn(__privateGet(this,J)),length:__privateGet(this,J).length,offset:__privateGet(this,q)+r})),__privateGet(this,J).slice(__privateGet(this,q),__privateGet(this,q)+r)};let yi=class t{constructor(t,e,n){__privateAdd(this,$),__privateAdd(this,et),__publicField(this,"allowLoose"),__privateAdd(this,J,void 0),__privateAdd(this,q,void 0),__privateAdd(this,Z,void 0),__privateAdd(this,Y,void 0),__privateAdd(this,X,void 0),Mn(this,{allowLoose:!!e}),__privateSet(this,J,Wn(t)),__privateSet(this,Z,0),__privateSet(this,Y,null),__privateSet(this,X,null!=n?n:1024),__privateSet(this,q,0)}get data(){return Kn(__privateGet(this,J))}get dataLength(){return __privateGet(this,J).length}get consumed(){return __privateGet(this,q)}get bytes(){return new Uint8Array(__privateGet(this,J))}subReader(e){const n=new t(__privateGet(this,J).slice(__privateGet(this,q)+e),this.allowLoose,__privateGet(this,X));return __privateSet(n,Y,this),n}readBytes(t,e){let n=__privateMethod(this,et,nt).call(this,0,t,!!e);return __privateMethod(this,$,tt).call(this,t),__privateSet(this,q,__privateGet(this,q)+n.length),n.slice(0,t)}readValue(){return lr(this.readBytes(si))}readIndex(){return cr(lr(this.readBytes(si)))}};function wi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function vi(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function bi(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ai(t,e){vi(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ei="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,xi=t=>t instanceof Uint8Array,ki=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Si=(t,e)=>t<<32-e|t>>>e;
|
2
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function Ni(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!xi(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Ci{clone(){return this._cloneInto()}}function Pi(t){const e=e=>t().update(Ni(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ti(t=32){if(Ei&&"function"==typeof Ei.getRandomValues)return Ei.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Mi extends Ci{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");wi(t.outputLen),wi(t.blockLen)}(t);const n=Ni(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return bi(this),this.iHash.update(t),this}digestInto(t){bi(this),vi(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return t.finished=r,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ri=(t,e,n)=>new Mi(t,e).update(n).digest();Ri.create=(t,e)=>new Mi(t,e);class Bi extends Ci{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ki(this.buffer)}update(t){bi(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Ni(t)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o!==r)n.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(e,0),this.pos=0);else{const e=ki(t);for(;r<=i-s;s+=r)this.process(e,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){bi(this),Ai(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let u=s;u<r;u++)e[u]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=ki(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)o.setUint32(4*u,c[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return t.length=r,t.pos=o,t.finished=i,t.destroyed=s,r%e&&t.buffer.set(n),t}}const Ii=(t,e,n)=>t&e^t&n^e&n,Gi=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]),Oi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Li=new Uint32Array(64);class Fi extends Bi{constructor(){super(64,32,8,!1),this.A=0|Oi[0],this.B=0|Oi[1],this.C=0|Oi[2],this.D=0|Oi[3],this.E=0|Oi[4],this.F=0|Oi[5],this.G=0|Oi[6],this.H=0|Oi[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[t,e,n,r,i,s,o,a]}set(t,e,n,r,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let h=0;h<16;h++,e+=4)Li[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){const t=Li[h-15],e=Li[h-2],n=Si(t,7)^Si(t,18)^t>>>3,r=Si(e,17)^Si(e,19)^e>>>10;Li[h]=r+Li[h-7]+n+Li[h-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let h=0;h<64;h++){const t=c+(Si(o,6)^Si(o,11)^Si(o,25))+((u=o)&a^~u&l)+Gi[h]+Li[h]|0,e=(Si(n,2)^Si(n,13)^Si(n,22))+Ii(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}var u;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){Li.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ui=Pi((()=>new Fi)),Di=BigInt(__pow(2,32)-1),ji=BigInt(32);function Hi(t,e=!1){return e?{h:Number(t&Di),l:Number(t>>ji&Di)}:{h:0|Number(t>>ji&Di),l:0|Number(t&Di)}}function Wi(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=Hi(t[i],e);[n[i],r[i]]=[s,o]}return[n,r]}const Qi=(t,e,n)=>t<<n|e>>>32-n,zi=(t,e,n)=>e<<n|t>>>32-n,Vi=(t,e,n)=>e<<n-32|t>>>64-n,Ki=(t,e,n)=>t<<n-32|e>>>64-n;const Ji={fromBig:Hi,split:Wi,toBig:(t,e)=>BigInt(t>>>0)<<ji|BigInt(e>>>0),shrSH:(t,e,n)=>t>>>n,shrSL:(t,e,n)=>t<<32-n|e>>>n,rotrSH:(t,e,n)=>t>>>n|e<<32-n,rotrSL:(t,e,n)=>t<<32-n|e>>>n,rotrBH:(t,e,n)=>t<<64-n|e>>>n-32,rotrBL:(t,e,n)=>t>>>n-32|e<<64-n,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:Qi,rotlSL:zi,rotlBH:Vi,rotlBL:Ki,add:function(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/__pow(2,32)|0)|0,l:0|i}},add3L:(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H:(t,e,n,r)=>e+n+r+(t/__pow(2,32)|0)|0,add4L:(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),add4H:(t,e,n,r,i)=>e+n+r+i+(t/__pow(2,32)|0)|0,add5H:(t,e,n,r,i,s)=>e+n+r+i+s+(t/__pow(2,32)|0)|0,add5L:(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},[qi,Zi]=(()=>Ji.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((t=>BigInt(t)))))(),Yi=new Uint32Array(80),Xi=new Uint32Array(80);class $i extends Bi{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:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:s,Dh:o,Dl:a,Eh:l,El:c,Fh:u,Fl:h,Gh:d,Gl:p,Hh:f,Hl:g}=this;return[t,e,n,r,i,s,o,a,l,c,u,h,d,p,f,g]}set(t,e,n,r,i,s,o,a,l,c,u,h,d,p,f,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|l,this.El=0|c,this.Fh=0|u,this.Fl=0|h,this.Gh=0|d,this.Gl=0|p,this.Hh=0|f,this.Hl=0|g}process(t,e){for(let y=0;y<16;y++,e+=4)Yi[y]=t.getUint32(e),Xi[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){const t=0|Yi[y-15],e=0|Xi[y-15],n=Ji.rotrSH(t,e,1)^Ji.rotrSH(t,e,8)^Ji.shrSH(t,e,7),r=Ji.rotrSL(t,e,1)^Ji.rotrSL(t,e,8)^Ji.shrSL(t,e,7),i=0|Yi[y-2],s=0|Xi[y-2],o=Ji.rotrSH(i,s,19)^Ji.rotrBH(i,s,61)^Ji.shrSH(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(0|this.Hh,0|this.Hl,0|m,0|_)),this.set(n,r,i,s,o,a,l,c,u,h,d,p,f,g,m,_)}roundClean(){Yi.fill(0),Xi.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 ts=Pi((()=>new $i));const es=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();es.crypto||es.msCrypto;const[ns,rs,is]=[[],[],[]],ss=BigInt(0),os=BigInt(1),as=BigInt(2),ls=BigInt(7),cs=BigInt(256),us=BigInt(113);for(let Op=0,Lp=os,Fp=1,Up=0;Op<24;Op++){[Fp,Up]=[Up,(2*Fp+3*Up)%5],ns.push(2*(5*Up+Fp)),rs.push((Op+1)*(Op+2)/2%64);let t=ss;for(let e=0;e<7;e++)Lp=(Lp<<os^(Lp>>ls)*us)%cs,Lp&as&&(t^=os<<(os<<BigInt(e))-os);is.push(t)}const[hs,ds]=Wi(is,!0),ps=(t,e,n)=>n>32?Vi(t,e,n):Qi(t,e,n),fs=(t,e,n)=>n>32?Ki(t,e,n):zi(t,e,n);class gs extends Ci{constructor(t,e,n,r=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,wi(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}keccak(){!function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let r=0;r<10;r++)n[r]=t[r]^t[r+10]^t[r+20]^t[r+30]^t[r+40];for(let r=0;r<10;r+=2){const e=(r+8)%10,i=(r+2)%10,s=n[i],o=n[i+1],a=ps(s,o,1)^n[e],l=fs(s,o,1)^n[e+1];for(let n=0;n<50;n+=10)t[r+n]^=a,t[r+n+1]^=l}let e=t[2],i=t[3];for(let n=0;n<24;n++){const r=rs[n],s=ps(e,i,r),o=fs(e,i,r),a=ns[n];e=t[a],i=t[a+1],t[a]=s,t[a+1]=o}for(let r=0;r<50;r+=10){for(let e=0;e<10;e++)n[e]=t[r+e];for(let e=0;e<10;e++)t[r+e]^=~n[(e+2)%10]&n[(e+4)%10]}t[0]^=hs[r],t[1]^=ds[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){bi(this);const{blockLen:e,state:n}=this,r=(t=Ni(t)).length;for(let i=0;i<r;){const s=Math.min(e-this.pos,r-i);for(let e=0;e<s;e++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){bi(this,!1),vi(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,i-r);t.set(e.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return wi(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ai(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:i,enableXOF:s}=this;return t||(t=new gs(e,n,r,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=s,t.destroyed=this.destroyed,t}}const ms=((t,e,n)=>Pi((()=>new gs(e,t,n))))(1,136,32);let _s=!1;const ys=function(t){return ms(t)};let ws=ys;function vs(t){const e=Hn(t,"data");return Kn(ws(e))}vs._=ys,vs.lock=function(){_s=!0},vs.register=function(t){if(_s)throw new TypeError("keccak256 is locked");ws=t},Object.freeze(vs);const bs=function(t){return function(t){switch(t){case"sha256":return Ui.create();case"sha512":return ts.create()}Ln(!1,"invalid hashing algorithm name","algorithm",t)}("sha256").update(t).digest()};let As=bs,Es=!1;function xs(t){const e=Hn(t,"data");return Kn(As(e))}xs._=bs,xs.lock=function(){Es=!0},xs.register=function(t){if(Es)throw new Error("sha256 is locked");As=t},Object.freeze(xs),Object.freeze(xs);
|
1
|
+
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__reflectGet=Reflect.get,__pow=Math.pow,__defNormalProp=(t,e,n)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,__spreadValues=(t,e)=>{for(var n in e||(e={}))__hasOwnProp.call(e,n)&&__defNormalProp(t,n,e[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))__propIsEnum.call(e,n)&&__defNormalProp(t,n,e[n]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__publicField=(t,e,n)=>(__defNormalProp(t,"symbol"!=typeof e?e+"":e,n),n),__accessCheck=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},__privateGet=(t,e,n)=>(__accessCheck(t,e,"read from private field"),n?n.call(t):e.get(t)),__privateAdd=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},__privateSet=(t,e,n,r)=>(__accessCheck(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),__privateWrapper=(t,e,n,r)=>({set _(r){__privateSet(t,e,r,n)},get _(){return __privateGet(t,e,r)}}),__privateMethod=(t,e,n)=>(__accessCheck(t,e,"access private method"),n),__superGet=(t,e,n)=>__reflectGet(__getProtoOf(t),n,e),__async=(t,e,n)=>new Promise(((r,i)=>{var s=t=>{try{a(n.next(t))}catch(e){i(e)}},o=t=>{try{a(n.throw(t))}catch(e){i(e)}},a=t=>t.done?r(t.value):Promise.resolve(t.value).then(s,o);a((n=n.apply(t,e)).next())}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).CoinleyCheckout={},t.React)}(this,(function(t,e){var n,r,i,s,o,a,l,c,u,h,d,p,f,g,m,y,_,w,v,b,A,E,x,k,S,N,C,P,T,M,R,B,G,I,O,L,F,U,D,j,H,W,Q,z,V,K,J,q,Z,Y,X,$,tt,et,nt,rt,it,st,ot,at,lt,ct,ut,ht,dt,pt,ft,gt,mt,yt,_t,wt,vt,bt,At,Et,xt,kt,St,Nt,Ct,Pt,Tt,Mt,Rt,Bt,Gt,It,Ot,Lt,Ft,Ut,Dt,jt,Ht,Wt,Qt,zt,Vt,Kt,Jt,qt,Zt,Yt,Xt,$t,te,ee,ne,re,ie,se,oe,ae,le,ce,ue,he,de,pe,fe,ge,me,ye,_e,we,ve,be,Ae,Ee,xe,ke,Se,Ne,Ce,Pe,Te,Me,Re,Be,Ge,Ie,Oe,Le,Fe,Ue,De,je,He,We,Qe,ze,Ve,Ke,Je,qe,Ze,Ye,Xe,$e,tn,en,nn,rn,sn,on,an,ln,cn,un,hn,dn,pn,fn,gn,mn,yn,_n,wn,vn,bn,An,En,xn,kn,Sn,Nn,Cn;function Pn(t,e,n){const r=e.split("|").map((t=>t.trim()));for(let s=0;s<r.length;s++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${n}`,i.value=t,i}function Tn(t){return __async(this,null,(function*(){const e=Object.keys(t);return(yield Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,n,r)=>(t[e[r]]=n,t)),{})}))}function Mn(t,e,n){for(let r in e){let i=e[r];const s=n?n[r]:null;s&&Pn(i,s,r),Object.defineProperty(t,r,{enumerable:!0,value:i,writable:!1})}}function Rn(t,e){if(null==t)return"null";if(null==e&&(e=new Set),"object"==typeof t){if(e.has(t))return"[Circular]";e.add(t)}if(Array.isArray(t))return"[ "+t.map((t=>Rn(t,e))).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let n="0x";for(let r=0;r<t.length;r++)n+=e[t[r]>>4],n+=e[15&t[r]];return n}if("object"==typeof t&&"function"==typeof t.toJSON)return Rn(t.toJSON(),e);switch(typeof t){case"boolean":case"number":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const n=Object.keys(t);return n.sort(),"{ "+n.map((n=>`${Rn(n,e)}: ${Rn(t[n],e)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Bn(t,e){return t&&t.code===e}function Gn(t){return Bn(t,"CALL_EXCEPTION")}function In(t,e,n){let r,i=t;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${Rn(n)}`);for(const t in n){if("shortMessage"===t)continue;const e=n[t];r.push(t+"="+Rn(e))}}r.push(`code=${e}`),r.push("version=6.14.3"),r.length&&(t+=" ("+r.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":r=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(t);break;default:r=new Error(t)}return Mn(r,{code:e}),n&&Object.assign(r,n),null==r.shortMessage&&Mn(r,{shortMessage:i}),r}function On(t,e,n,r){if(!t)throw In(e,n,r)}function Ln(t,e,n,r){On(t,e,"INVALID_ARGUMENT",{argument:n,value:r})}function Fn(t,e,n){null==n&&(n=""),n&&(n=": "+n),On(t>=e,"missing argument"+n,"MISSING_ARGUMENT",{count:t,expectedCount:e}),On(t<=e,"too many arguments"+n,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const Un=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){const t=String.fromCharCode(233).normalize("NFD");if(t!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(n){}return t}),[]);function Dn(t,e,n){if(null==n&&(n=""),t!==e){let t=n,e="new";n&&(t+=".",e+=" "+n),On(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function jn(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if("string"==typeof t&&t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const e=new Uint8Array((t.length-2)/2);let n=2;for(let r=0;r<e.length;r++)e[r]=parseInt(t.substring(n,n+2),16),n+=2;return e}Ln(!1,"invalid BytesLike value",e||"value",t)}function Hn(t,e){return jn(t,e,!1)}function Wn(t,e){return jn(t,e,!0)}function Qn(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(("number"!=typeof e||t.length===2+2*e)&&(!0!==e||t.length%2==0))}function zn(t){return Qn(t,!0)||t instanceof Uint8Array}const Vn="0123456789abcdef";function Kn(t){const e=Hn(t);let n="0x";for(let r=0;r<e.length;r++){const t=e[r];n+=Vn[(240&t)>>4]+Vn[15&t]}return n}function Jn(t){return"0x"+t.map((t=>Kn(t).substring(2))).join("")}function qn(t){return Qn(t,!0)?(t.length-2)/2:Hn(t).length}function Zn(t,e,n){const r=Hn(t);return null!=n&&n>r.length&&On(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n}),Kn(r.slice(null==e?0:e,null==n?r.length:n))}function Yn(t,e,n){const r=Hn(t);On(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),n?i.set(r,e-r.length):i.set(r,0),Kn(i)}function Xn(t,e){return Yn(t,e,!0)}const $n=BigInt(0),tr=BigInt(1),er=9007199254740991;function nr(t,e){const n=or(t,"value"),r=BigInt(cr(e,"width"));if(On(n>>r===$n,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),n>>r-tr){return-((~n&(tr<<r)-tr)+tr)}return n}function rr(t,e){let n=sr(t,"value");const r=BigInt(cr(e,"width")),i=tr<<r-tr;if(n<$n){n=-n,On(n<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return(~n&(tr<<r)-tr)+tr}return On(n<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),n}function ir(t,e){const n=or(t,"value"),r=BigInt(cr(e,"bits"));return n&(tr<<r)-tr}function sr(t,e){switch(typeof t){case"bigint":return t;case"number":return Ln(Number.isInteger(t),"underflow",e||"value",t),Ln(t>=-er&&t<=er,"overflow",e||"value",t),BigInt(t);case"string":try{if(""===t)throw new Error("empty string");return"-"===t[0]&&"-"!==t[1]?-BigInt(t.substring(1)):BigInt(t)}catch(n){Ln(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}Ln(!1,"invalid BigNumberish value",e||"value",t)}function or(t,e){const n=sr(t,e);return On(n>=$n,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}const ar="0123456789abcdef";function lr(t){if(t instanceof Uint8Array){let e="0x0";for(const n of t)e+=ar[n>>4],e+=ar[15&n];return BigInt(e)}return sr(t)}function cr(t,e){switch(typeof t){case"bigint":return Ln(t>=-er&&t<=er,"overflow",e||"value",t),Number(t);case"number":return Ln(Number.isInteger(t),"underflow",e||"value",t),Ln(t>=-er&&t<=er,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return cr(BigInt(t),e)}catch(n){Ln(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}Ln(!1,"invalid numeric value",e||"value",t)}function ur(t,e){let n=or(t,"value").toString(16);if(null==e)n.length%2&&(n="0"+n);else{const r=cr(e,"width");for(On(2*r>=n.length,`value exceeds width (${r} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});n.length<2*r;)n="0"+n}return"0x"+n}function hr(t){const e=or(t,"value");if(e===$n)return new Uint8Array([]);let n=e.toString(16);n.length%2&&(n="0"+n);const r=new Uint8Array(n.length/2);for(let i=0;i<r.length;i++){const t=2*i;r[i]=parseInt(n.substring(t,t+2),16)}return r}function dr(t){let e=Kn(zn(t)?t:hr(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const pr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const fr=BigInt(58);class gr{constructor(t,e,r){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,n,void 0),__privateSet(this,n,e),Mn(this,{emitter:t,filter:r})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,n)&&(yield this.emitter.off(this.filter,__privateGet(this,n)))}))}}function mr(t,e,n,r,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let r=e+1;r<n.length&&n[r]>>6==2;r++)t++;return t}return"OVERRUN"===t?n.length-e-1:0}n=new WeakMap;const yr=Object.freeze({error:function(t,e,n,r,i){Ln(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",n)},ignore:mr,replace:function(t,e,n,r,i){return"OVERLONG"===t?(Ln("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),mr(t,e,n))}});function _r(t,e){Ln("string"==typeof t,"invalid string value","str",t),null!=e&&(!function(t){On(Un.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let n=[];for(let r=0;r<t.length;r++){const e=t.charCodeAt(r);if(e<128)n.push(e);else if(e<2048)n.push(e>>6|192),n.push(63&e|128);else if(55296==(64512&e)){r++;const i=t.charCodeAt(r);Ln(r<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const s=65536+((1023&e)<<10)+(1023&i);n.push(s>>18|240),n.push(s>>12&63|128),n.push(s>>6&63|128),n.push(63&s|128)}else n.push(e>>12|224),n.push(e>>6&63|128),n.push(63&e|128)}return new Uint8Array(n)}function wr(t,e){return n=function(t,e){null==e&&(e=yr.error);const n=Hn(t,"bytes"),r=[];let i=0;for(;i<n.length;){const t=n[i++];if(!(t>>7)){r.push(t);continue}let s=null,o=null;if(192==(224&t))s=1,o=127;else if(224==(240&t))s=2,o=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,n,r);continue}s=3,o=65535}if(i-1+s>=n.length){i+=e("OVERRUN",i-1,n,r);continue}let a=t&(1<<8-s-1)-1;for(let l=0;l<s;l++){let t=n[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,n,r),a=null;break}a=a<<6|63&t,i++}null!==a&&(a>1114111?i+=e("OUT_OF_RANGE",i-1-s,n,r,a):a>=55296&&a<=57343?i+=e("UTF16_SURROGATE",i-1-s,n,r,a):a<=o?i+=e("OVERLONG",i-1-s,n,r,a):r.push(a))}return r}(t,e),n.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("");var n}function vr(t){return function(e,n){return __async(this,null,(function*(){On(null==n||!n.cancelled,"request cancelled before sending","CANCELLED");const r=e.url.split(":")[0].toLowerCase();On("http"===r||"https"===r,`unsupported protocol ${r}`,"UNSUPPORTED_OPERATION",{info:{protocol:r},operation:"request"}),On("https"===r||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const s=new AbortController,o=setTimeout((()=>{i=In("request timeout","TIMEOUT"),s.abort()}),e.timeout);n&&n.addListener((()=>{i=In("request cancelled","CANCELLED"),s.abort()}));const a=Object.assign({},t,{method:e.method,headers:new Headers(Array.from(e)),body:e.body||void 0,signal:s.signal});let l;try{l=yield fetch(e.url,a)}catch(d){if(clearTimeout(o),i)throw i;throw d}clearTimeout(o);const c={};l.headers.forEach(((t,e)=>{c[e.toLowerCase()]=t}));const u=yield l.arrayBuffer(),h=null==u?null:new Uint8Array(u);return{statusCode:l.status,statusMessage:l.statusText,headers:c,body:h}}))}}let br=vr();const Ar=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),Er=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let xr=!1;function kr(t,e){return __async(this,null,(function*(){try{const e=t.match(Ar);if(!e)throw new Error("invalid data");return new Gr(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return Hn(e)}(e[3]):_r(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new Gr(599,"BAD REQUEST (invalid data: URI)",{},null,new Rr(t))}}))}function Sr(t){return function(e,n){return __async(this,null,(function*(){try{const n=e.match(Er);if(!n)throw new Error("invalid link");return new Rr(`${t}${n[2]}`)}catch(n){return new Gr(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Rr(e))}}))}}const Nr={data:kr,ipfs:Sr("https://gateway.ipfs.io/ipfs/")},Cr=new WeakMap;class Pr{constructor(t){__privateAdd(this,r,void 0),__privateAdd(this,i,void 0),__privateSet(this,r,[]),__privateSet(this,i,!1),Cr.set(t,(()=>{if(!__privateGet(this,i)){__privateSet(this,i,!0);for(const t of __privateGet(this,r))setTimeout((()=>{t()}),0);__privateSet(this,r,[])}}))}addListener(t){On(!__privateGet(this,i),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),__privateGet(this,r).push(t)}get cancelled(){return __privateGet(this,i)}checkSignal(){On(!this.cancelled,"cancelled","CANCELLED",{})}}function Tr(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}r=new WeakMap,i=new WeakMap;const Mr=class t{constructor(t){__privateAdd(this,v),__privateAdd(this,s,void 0),__privateAdd(this,o,void 0),__privateAdd(this,a,void 0),__privateAdd(this,l,void 0),__privateAdd(this,c,void 0),__privateAdd(this,u,void 0),__privateAdd(this,h,void 0),__privateAdd(this,d,void 0),__privateAdd(this,p,void 0),__privateAdd(this,f,void 0),__privateAdd(this,g,void 0),__privateAdd(this,m,void 0),__privateAdd(this,y,void 0),__privateAdd(this,_,void 0),__privateAdd(this,w,void 0),__privateSet(this,u,String(t)),__privateSet(this,s,!1),__privateSet(this,o,!0),__privateSet(this,a,{}),__privateSet(this,l,""),__privateSet(this,c,3e5),__privateSet(this,_,{slotInterval:250,maxAttempts:12}),__privateSet(this,w,null)}get url(){return __privateGet(this,u)}set url(t){__privateSet(this,u,String(t))}get body(){return null==__privateGet(this,h)?null:new Uint8Array(__privateGet(this,h))}set body(t){if(null==t)__privateSet(this,h,void 0),__privateSet(this,d,void 0);else if("string"==typeof t)__privateSet(this,h,_r(t)),__privateSet(this,d,"text/plain");else if(t instanceof Uint8Array)__privateSet(this,h,t),__privateSet(this,d,"application/octet-stream");else{if("object"!=typeof t)throw new Error("invalid body");__privateSet(this,h,_r(JSON.stringify(t))),__privateSet(this,d,"application/json")}}hasBody(){return null!=__privateGet(this,h)}get method(){return __privateGet(this,l)?__privateGet(this,l):this.hasBody()?"POST":"GET"}set method(t){null==t&&(t=""),__privateSet(this,l,String(t).toUpperCase())}get headers(){const t=Object.assign({},__privateGet(this,a));return __privateGet(this,p)&&(t.authorization=`Basic ${function(t){const e=Hn(t);let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}(_r(__privateGet(this,p)))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),null==t["content-type"]&&__privateGet(this,d)&&(t["content-type"]=__privateGet(this,d)),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){__privateGet(this,a)[String(t).toLowerCase()]=String(e)}clearHeaders(){__privateSet(this,a,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let n=0;return{next:()=>{if(n<e.length){const r=e[n++];return{value:[r,t[r]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return __privateGet(this,p)||null}setCredentials(t,e){Ln(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),__privateSet(this,p,`${t}:${e}`)}get allowGzip(){return __privateGet(this,o)}set allowGzip(t){__privateSet(this,o,!!t)}get allowInsecureAuthentication(){return!!__privateGet(this,s)}set allowInsecureAuthentication(t){__privateSet(this,s,!!t)}get timeout(){return __privateGet(this,c)}set timeout(t){Ln(t>=0,"timeout must be non-zero","timeout",t),__privateSet(this,c,t)}get preflightFunc(){return __privateGet(this,f)||null}set preflightFunc(t){__privateSet(this,f,t)}get processFunc(){return __privateGet(this,g)||null}set processFunc(t){__privateSet(this,g,t)}get retryFunc(){return __privateGet(this,m)||null}set retryFunc(t){__privateSet(this,m,t)}get getUrlFunc(){return __privateGet(this,w)||br}set getUrlFunc(t){__privateSet(this,w,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${__privateGet(this,h)?Kn(__privateGet(this,h)):"null"}>`}setThrottleParams(t){null!=t.slotInterval&&(__privateGet(this,_).slotInterval=t.slotInterval),null!=t.maxAttempts&&(__privateGet(this,_).maxAttempts=t.maxAttempts)}send(){return On(null==__privateGet(this,y),"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),__privateSet(this,y,new Pr(this)),__privateMethod(this,v,b).call(this,0,Ir()+this.timeout,0,this,new Gr(0,"",{},null,this))}cancel(){On(null!=__privateGet(this,y),"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Cr.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(e){const n=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();On("GET"===this.method&&("https"!==n||"http"!==r)&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const i=new t(e);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,__privateSet(i,a,Object.assign({},__privateGet(this,a))),__privateGet(this,h)&&__privateSet(i,h,new Uint8Array(__privateGet(this,h))),__privateSet(i,d,__privateGet(this,d)),i}clone(){const e=new t(this.url);return __privateSet(e,l,__privateGet(this,l)),__privateGet(this,h)&&__privateSet(e,h,__privateGet(this,h)),__privateSet(e,d,__privateGet(this,d)),__privateSet(e,a,Object.assign({},__privateGet(this,a))),__privateSet(e,p,__privateGet(this,p)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),__privateSet(e,f,__privateGet(this,f)),__privateSet(e,g,__privateGet(this,g)),__privateSet(e,m,__privateGet(this,m)),__privateSet(e,_,Object.assign({},__privateGet(this,_))),__privateSet(e,w,__privateGet(this,w)),e}static lockConfig(){xr=!0}static getGateway(t){return Nr[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(xr)throw new Error("gateways locked");Nr[t]=e}static registerGetUrl(t){if(xr)throw new Error("gateways locked");br=t}static createGetUrlFunc(t){return vr(t)}static createDataGateway(){return kr}static createIpfsGatewayFunc(t){return Sr(t)}};s=new WeakMap,o=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,h=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,m=new WeakMap,y=new WeakMap,_=new WeakMap,w=new WeakMap,v=new WeakSet,b=function(t,e,n,r,i){return __async(this,null,(function*(){var s,o,a;if(t>=__privateGet(this,_).maxAttempts)return i.makeServerError("exceeded maximum retry limit");On(Ir()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:r}),n>0&&(yield function(t){return new Promise((e=>setTimeout(e,t)))}(n));let l=this.clone();const c=(l.url.split(":")[0]||"").toLowerCase();if(c in Nr){const t=yield Nr[c](l.url,Tr(__privateGet(r,y)));if(t instanceof Gr){let e=t;if(this.processFunc){Tr(__privateGet(r,y));try{e=yield this.processFunc(l,e)}catch(d){null!=d.throttle&&"number"==typeof d.stall||e.makeServerError("error in post-processing function",d).assertOk()}}return e}l=t}this.preflightFunc&&(l=yield this.preflightFunc(l));const u=yield this.getUrlFunc(l,Tr(__privateGet(r,y)));let h=new Gr(u.statusCode,u.statusMessage,u.headers,u.body,r);if(301===h.statusCode||302===h.statusCode){try{const n=h.headers.location||"";return __privateMethod(s=l.redirect(n),v,b).call(s,t+1,e,0,r,h)}catch(d){}return h}if(429===h.statusCode&&(null==this.retryFunc||(yield this.retryFunc(l,h,t)))){const n=h.headers["retry-after"];let i=__privateGet(this,_).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof n&&n.match(/^[1-9][0-9]*$/)&&(i=parseInt(n)),__privateMethod(o=l.clone(),v,b).call(o,t+1,e,i,r,h)}if(this.processFunc){Tr(__privateGet(r,y));try{h=yield this.processFunc(l,h)}catch(d){null!=d.throttle&&"number"==typeof d.stall||h.makeServerError("error in post-processing function",d).assertOk();let n=__privateGet(this,_).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return d.stall>=0&&(n=d.stall),__privateMethod(a=l.clone(),v,b).call(a,t+1,e,n,r,h)}}return h}))};let Rr=Mr;const Br=class t{constructor(t,e,n,r,i){__privateAdd(this,A,void 0),__privateAdd(this,E,void 0),__privateAdd(this,x,void 0),__privateAdd(this,k,void 0),__privateAdd(this,S,void 0),__privateAdd(this,N,void 0),__privateSet(this,A,t),__privateSet(this,E,e),__privateSet(this,x,Object.keys(n).reduce(((t,e)=>(t[e.toLowerCase()]=String(n[e]),t)),{})),__privateSet(this,k,null==r?null:new Uint8Array(r)),__privateSet(this,S,i||null),__privateSet(this,N,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${__privateGet(this,k)?Kn(__privateGet(this,k)):"null"}>`}get statusCode(){return __privateGet(this,A)}get statusMessage(){return __privateGet(this,E)}get headers(){return Object.assign({},__privateGet(this,x))}get body(){return null==__privateGet(this,k)?null:new Uint8Array(__privateGet(this,k))}get bodyText(){try{return null==__privateGet(this,k)?"":wr(__privateGet(this,k))}catch(t){On(!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(t){On(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let n=0;return{next:()=>{if(n<e.length){const r=e[n++];return{value:[r,t[r]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,n){let r;r=e?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:`CLIENT ESCALATED SERVER ERROR (${e=`${this.statusCode} ${this.statusMessage}`})`;const i=new t(599,r,this.headers,this.body,__privateGet(this,S)||void 0);return __privateSet(i,N,{message:e,error:n}),i}throwThrottleError(t,e){null==e?e=-1:Ln(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const n=new Error(t||"throttling requests");throw Mn(n,{stall:e,throttle:!0}),n}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return null!=__privateGet(this,k)}get request(){return __privateGet(this,S)}ok(){return""===__privateGet(this,N).message&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=__privateGet(this,N);""===t&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let r=null;try{__privateGet(this,k)&&(r=wr(__privateGet(this,k)))}catch(i){}On(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:n,responseBody:r,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};A=new WeakMap,E=new WeakMap,x=new WeakMap,k=new WeakMap,S=new WeakMap,N=new WeakMap;let Gr=Br;function Ir(){return(new Date).getTime()}const Or=BigInt(-1),Lr=BigInt(0),Fr=BigInt(1),Ur=BigInt(5),Dr={};let jr="0000";for(;jr.length<80;)jr+=jr;function Hr(t){let e=jr;for(;e.length<t;)e+=e;return BigInt("1"+e.substring(0,t))}function Wr(t,e,n){const r=BigInt(e.width);if(e.signed){const e=Fr<<r-Fr;On(null==n||t>=-e&&t<e,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:t}),t=t>Lr?nr(ir(t,r),r):-nr(ir(-t,r),r)}else{const e=Fr<<r;On(null==n||t>=0&&t<e,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:t}),t=(t%e+e)%e&e-Fr}return t}function Qr(t){"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,n=128,r=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)e=!1;else{const i=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);Ln(i,"invalid fixed format","format",t),e="u"!==i[1],n=parseInt(i[2]),r=parseInt(i[3])}else if(t){const i=t,s=(t,e,n)=>null==i[t]?n:(Ln(typeof i[t]===e,"invalid fixed format ("+t+" not "+e+")","format."+t,i[t]),i[t]);e=s("signed","boolean",e),n=s("width","number",n),r=s("decimals","number",r)}Ln(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Ln(r<=80,"invalid FixedNumber decimals (too large)","format.decimals",r);return{signed:e,width:n,decimals:r,name:(e?"":"u")+"fixed"+String(n)+"x"+String(r)}}const zr=class t{constructor(t,e,n){__privateAdd(this,M),__privateAdd(this,B),__privateAdd(this,I),__privateAdd(this,L),__privateAdd(this,U),__privateAdd(this,j),__publicField(this,"format"),__privateAdd(this,C,void 0),__privateAdd(this,P,void 0),__privateAdd(this,T,void 0),__publicField(this,"_value"),Dn(t,Dr,"FixedNumber"),__privateSet(this,P,e),__privateSet(this,C,n);const r=function(t,e){let n="";t<Lr&&(n="-",t*=Or);let r=t.toString();if(0===e)return n+r;for(;r.length<=e;)r=jr+r;const i=r.length-e;for(r=r.substring(0,i)+"."+r.substring(i);"0"===r[0]&&"."!==r[1];)r=r.substring(1);for(;"0"===r[r.length-1]&&"."!==r[r.length-2];)r=r.substring(0,r.length-1);return n+r}(e,n.decimals);Mn(this,{format:n.name,_value:r}),__privateSet(this,T,Hr(n.decimals))}get signed(){return __privateGet(this,C).signed}get width(){return __privateGet(this,C).width}get decimals(){return __privateGet(this,C).decimals}get value(){return __privateGet(this,P)}addUnsafe(t){return __privateMethod(this,I,O).call(this,t)}add(t){return __privateMethod(this,I,O).call(this,t,"add")}subUnsafe(t){return __privateMethod(this,L,F).call(this,t)}sub(t){return __privateMethod(this,L,F).call(this,t,"sub")}mulUnsafe(t){return __privateMethod(this,U,D).call(this,t)}mul(t){return __privateMethod(this,U,D).call(this,t,"mul")}mulSignal(t){__privateMethod(this,M,R).call(this,t);const e=__privateGet(this,P)*__privateGet(t,P);return On(e%__privateGet(this,T)===Lr,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,B,G).call(this,e/__privateGet(this,T),"mulSignal")}divUnsafe(t){return __privateMethod(this,j,H).call(this,t)}div(t){return __privateMethod(this,j,H).call(this,t,"div")}divSignal(t){On(__privateGet(t,P)!==Lr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,M,R).call(this,t);const e=__privateGet(this,P)*__privateGet(this,T);return On(e%__privateGet(t,P)===Lr,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,B,G).call(this,e/__privateGet(t,P),"divSignal")}cmp(t){let e=this.value,n=t.value;const r=this.decimals-t.decimals;return r>0?n*=Hr(r):r<0&&(e*=Hr(-r)),e<n?-1:e>n?1:0}eq(t){return 0===this.cmp(t)}lt(t){return this.cmp(t)<0}lte(t){return this.cmp(t)<=0}gt(t){return this.cmp(t)>0}gte(t){return this.cmp(t)>=0}floor(){let t=__privateGet(this,P);return __privateGet(this,P)<Lr&&(t-=__privateGet(this,T)-Fr),t=__privateGet(this,P)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,B,G).call(this,t,"floor")}ceiling(){let t=__privateGet(this,P);return __privateGet(this,P)>Lr&&(t+=__privateGet(this,T)-Fr),t=__privateGet(this,P)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,B,G).call(this,t,"ceiling")}round(e){if(null==e&&(e=0),e>=this.decimals)return this;const n=this.decimals-e,r=Ur*Hr(n-1);let i=this.value+r;const s=Hr(n);return i=i/s*s,Wr(i,__privateGet(this,C),"round"),new t(Dr,i,__privateGet(this,C))}isZero(){return __privateGet(this,P)===Lr}isNegative(){return __privateGet(this,P)<Lr}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return t.fromString(this.toString(),e)}static fromValue(e,n,r){const i=null==n?0:cr(n),s=Qr(r);let o=sr(e,"value");const a=i-s.decimals;if(a>0){const t=Hr(a);On(o%t===Lr,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),o/=t}else a<0&&(o*=Hr(-a));return Wr(o,s,"fromValue"),new t(Dr,o,s)}static fromString(e,n){const r=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Ln(r&&r[2].length+r[3].length>0,"invalid FixedNumber string value","value",e);const i=Qr(n);let s=r[2]||"0",o=r[3]||"";for(;o.length<i.decimals;)o+=jr;On(o.substring(i.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),o=o.substring(0,i.decimals);const a=BigInt(r[1]+s+o);return Wr(a,i,"fromString"),new t(Dr,a,i)}static fromBytes(e,n){let r=lr(Hn(e,"value"));const i=Qr(n);return i.signed&&(r=nr(r,i.width)),Wr(r,i,"fromBytes"),new t(Dr,r,i)}};C=new WeakMap,P=new WeakMap,T=new WeakMap,M=new WeakSet,R=function(t){Ln(this.format===t.format,"incompatible format; use fixedNumber.toFormat","other",t)},B=new WeakSet,G=function(t,e){return t=Wr(t,__privateGet(this,C),e),new zr(Dr,t,__privateGet(this,C))},I=new WeakSet,O=function(t,e){return __privateMethod(this,M,R).call(this,t),__privateMethod(this,B,G).call(this,__privateGet(this,P)+__privateGet(t,P),e)},L=new WeakSet,F=function(t,e){return __privateMethod(this,M,R).call(this,t),__privateMethod(this,B,G).call(this,__privateGet(this,P)-__privateGet(t,P),e)},U=new WeakSet,D=function(t,e){return __privateMethod(this,M,R).call(this,t),__privateMethod(this,B,G).call(this,__privateGet(this,P)*__privateGet(t,P)/__privateGet(this,T),e)},j=new WeakSet,H=function(t,e){return On(__privateGet(t,P)!==Lr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,M,R).call(this,t),__privateMethod(this,B,G).call(this,__privateGet(this,P)*__privateGet(this,T)/__privateGet(t,P),e)};let Vr=zr;function Kr(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Jr(t,e,n){let r=0;for(let i=0;i<n;i++)r=256*r+t[e+i];return r}function qr(t,e,n,r){const i=[];for(;n<e+1+r;){const s=Zr(t,n);i.push(s.result),On((n+=s.consumed)<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:t,length:r,offset:e})}return{consumed:1+r,result:i}}function Zr(t,e){On(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const n=e=>{On(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const r=t[e]-247;n(e+1+r);const i=Jr(t,e+1,r);return n(e+1+r+i),qr(t,e,e+1+r,r+i)}if(t[e]>=192){const r=t[e]-192;return n(e+1+r),qr(t,e,e+1,r)}if(t[e]>=184){const r=t[e]-183;n(e+1+r);const i=Jr(t,e+1,r);n(e+1+r+i);return{consumed:1+r+i,result:Kn(t.slice(e+1+r,e+1+r+i))}}if(t[e]>=128){const r=t[e]-128;n(e+1+r);return{consumed:1+r,result:Kn(t.slice(e+1,e+1+r))}}return{consumed:1,result:Kr(t[e])}}function Yr(t){const e=Hn(t,"data"),n=Zr(e,0);return Ln(n.consumed===e.length,"unexpected junk after rlp payload","data",t),n.result}function Xr(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function $r(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat($r(t))})),e.length<=55)return e.unshift(192+e.length),e;const n=Xr(e.length);return n.unshift(247+n.length),n.concat(e)}const e=Array.prototype.slice.call(Hn(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const n=Xr(e.length);return n.unshift(183+n.length),n.concat(e)}const ti="0123456789abcdef";function ei(t){let e="0x";for(const n of $r(t))e+=ti[n>>4],e+=ti[15&n];return e}const ni=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ri(t,e){let n=18;if("string"==typeof e){const t=ni.indexOf(e);Ln(t>=0,"invalid unit","unit",e),n=3*t}else null!=e&&(n=cr(e,"unit"));return Vr.fromValue(t,n,{decimals:n,width:512}).toString()}function ii(t,e){Ln("string"==typeof t,"value must be a string","value",t);let n=18;if("string"==typeof e){const t=ni.indexOf(e);Ln(t>=0,"invalid unit","unit",e),n=3*t}else null!=e&&(n=cr(e,"unit"));return Vr.fromString(t,{decimals:n,width:512}).value}const si=32,oi=new Uint8Array(si),ai=["then"],li={},ci=new WeakMap;function ui(t){return ci.get(t)}function hi(t,e){ci.set(t,e)}function di(t,e){const n=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw n.error=e,n}function pi(t,e,n){return t.indexOf(null)>=0?e.map(((t,e)=>t instanceof fi?pi(ui(t),t,n):t)):t.reduce(((t,r,i)=>{let s=e.getValue(r);return r in t||(n&&s instanceof fi&&(s=pi(ui(s),s,n)),t[r]=s),t}),{})}W=new WeakMap;let fi=class t extends Array{constructor(...t){const e=t[0];let n=t[1],r=(t[2]||[]).slice(),i=!0;e!==li&&(n=t,r=[],i=!1),super(n.length),__privateAdd(this,W,void 0),n.forEach(((t,e)=>{this[e]=t}));const s=r.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(hi(this,Object.freeze(n.map(((t,e)=>{const n=r[e];return null!=n&&1===s.get(n)?n:null})))),__privateSet(this,W,[]),null==__privateGet(this,W)&&__privateGet(this,W),!i)return;Object.freeze(this);const o=new Proxy(this,{get:(t,e,n)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const n=cr(e,"%index");if(n<0||n>=this.length)throw new RangeError("out of result range");const r=t[n];return r instanceof Error&&di(`index ${n}`,r),r}if(ai.indexOf(e)>=0)return Reflect.get(t,e,n);const r=t[e];if(r instanceof Function)return function(...e){return r.apply(this===n?t:this,e)};if(!(e in t))return t.getValue.apply(this===n?t:this,[e])}return Reflect.get(t,e,n)}});return hi(o,ui(this)),o}toArray(e){const n=[];return this.forEach(((r,i)=>{r instanceof Error&&di(`index ${i}`,r),e&&r instanceof t&&(r=r.toArray(e)),n.push(r)})),n}toObject(t){const e=ui(this);return e.reduce(((n,r,i)=>(On(null!=r,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),pi(e,this,t))),{})}slice(e,n){null==e&&(e=0),e<0&&(e+=this.length)<0&&(e=0),null==n&&(n=this.length),n<0&&(n+=this.length)<0&&(n=0),n>this.length&&(n=this.length);const r=ui(this),i=[],s=[];for(let t=e;t<n;t++)i.push(this[t]),s.push(r[t]);return new t(li,i,s)}filter(e,n){const r=ui(this),i=[],s=[];for(let t=0;t<this.length;t++){const o=this[t];o instanceof Error&&di(`index ${t}`,o),e.call(n,o,t,this)&&(i.push(o),s.push(r[t]))}return new t(li,i,s)}map(t,e){const n=[];for(let r=0;r<this.length;r++){const i=this[r];i instanceof Error&&di(`index ${r}`,i),n.push(t.call(e,i,r,this))}return n}getValue(t){const e=ui(this).indexOf(t);if(-1===e)return;const n=this[e];return n instanceof Error&&di(`property ${JSON.stringify(t)}`,n.error),n}static fromItems(e,n){return new t(li,e,n)}};function gi(t){let e=hr(t);return On(e.length<=si,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:si,offset:e.length}),e.length!==si&&(e=Wn(Jn([oi.slice(e.length%si),e]))),e}class mi{constructor(t,e,n,r){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),Mn(this,{name:t,type:e,localName:n,dynamic:r},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){Ln(!1,t,this.localName,e)}}class yi{constructor(){__privateAdd(this,V),__privateAdd(this,Q,void 0),__privateAdd(this,z,void 0),__privateSet(this,Q,[]),__privateSet(this,z,0)}get data(){return Jn(__privateGet(this,Q))}get length(){return __privateGet(this,z)}appendWriter(t){return __privateMethod(this,V,K).call(this,Wn(t.data))}writeBytes(t){let e=Wn(t);const n=e.length%si;return n&&(e=Wn(Jn([e,oi.slice(n)]))),__privateMethod(this,V,K).call(this,e)}writeValue(t){return __privateMethod(this,V,K).call(this,gi(t))}writeUpdatableValue(){const t=__privateGet(this,Q).length;return __privateGet(this,Q).push(oi),__privateSet(this,z,__privateGet(this,z)+si),e=>{__privateGet(this,Q)[t]=gi(e)}}}Q=new WeakMap,z=new WeakMap,V=new WeakSet,K=function(t){return __privateGet(this,Q).push(t),__privateSet(this,z,__privateGet(this,z)+t.length),t.length};J=new WeakMap,q=new WeakMap,Z=new WeakMap,Y=new WeakMap,X=new WeakMap,$=new WeakSet,tt=function(t){var e;if(__privateGet(this,Y))return __privateMethod(e=__privateGet(this,Y),$,tt).call(e,t);__privateSet(this,Z,__privateGet(this,Z)+t),On(__privateGet(this,X)<1||__privateGet(this,Z)<=__privateGet(this,X)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${__privateGet(this,X)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Wn(__privateGet(this,J)),offset:__privateGet(this,q),length:t,info:{bytesRead:__privateGet(this,Z),dataLength:this.dataLength}})},et=new WeakSet,nt=function(t,e,n){let r=Math.ceil(e/si)*si;return __privateGet(this,q)+r>__privateGet(this,J).length&&(this.allowLoose&&n&&__privateGet(this,q)+e<=__privateGet(this,J).length?r=e:On(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Wn(__privateGet(this,J)),length:__privateGet(this,J).length,offset:__privateGet(this,q)+r})),__privateGet(this,J).slice(__privateGet(this,q),__privateGet(this,q)+r)};let _i=class t{constructor(t,e,n){__privateAdd(this,$),__privateAdd(this,et),__publicField(this,"allowLoose"),__privateAdd(this,J,void 0),__privateAdd(this,q,void 0),__privateAdd(this,Z,void 0),__privateAdd(this,Y,void 0),__privateAdd(this,X,void 0),Mn(this,{allowLoose:!!e}),__privateSet(this,J,Wn(t)),__privateSet(this,Z,0),__privateSet(this,Y,null),__privateSet(this,X,null!=n?n:1024),__privateSet(this,q,0)}get data(){return Kn(__privateGet(this,J))}get dataLength(){return __privateGet(this,J).length}get consumed(){return __privateGet(this,q)}get bytes(){return new Uint8Array(__privateGet(this,J))}subReader(e){const n=new t(__privateGet(this,J).slice(__privateGet(this,q)+e),this.allowLoose,__privateGet(this,X));return __privateSet(n,Y,this),n}readBytes(t,e){let n=__privateMethod(this,et,nt).call(this,0,t,!!e);return __privateMethod(this,$,tt).call(this,t),__privateSet(this,q,__privateGet(this,q)+n.length),n.slice(0,t)}readValue(){return lr(this.readBytes(si))}readIndex(){return cr(lr(this.readBytes(si)))}};function wi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function vi(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function bi(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ai(t,e){vi(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ei="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,xi=t=>t instanceof Uint8Array,ki=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Si=(t,e)=>t<<32-e|t>>>e;
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function Ni(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!xi(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Ci{clone(){return this._cloneInto()}}function Pi(t){const e=e=>t().update(Ni(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ti(t=32){if(Ei&&"function"==typeof Ei.getRandomValues)return Ei.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Mi extends Ci{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");wi(t.outputLen),wi(t.blockLen)}(t);const n=Ni(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return bi(this),this.iHash.update(t),this}digestInto(t){bi(this),vi(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return t.finished=r,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ri=(t,e,n)=>new Mi(t,e).update(n).digest();Ri.create=(t,e)=>new Mi(t,e);class Bi extends Ci{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ki(this.buffer)}update(t){bi(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Ni(t)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o!==r)n.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(e,0),this.pos=0);else{const e=ki(t);for(;r<=i-s;s+=r)this.process(e,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){bi(this),Ai(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let u=s;u<r;u++)e[u]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=ki(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)o.setUint32(4*u,c[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return t.length=r,t.pos=o,t.finished=i,t.destroyed=s,r%e&&t.buffer.set(n),t}}const Gi=(t,e,n)=>t&e^t&n^e&n,Ii=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]),Oi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Li=new Uint32Array(64);class Fi extends Bi{constructor(){super(64,32,8,!1),this.A=0|Oi[0],this.B=0|Oi[1],this.C=0|Oi[2],this.D=0|Oi[3],this.E=0|Oi[4],this.F=0|Oi[5],this.G=0|Oi[6],this.H=0|Oi[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[t,e,n,r,i,s,o,a]}set(t,e,n,r,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let h=0;h<16;h++,e+=4)Li[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){const t=Li[h-15],e=Li[h-2],n=Si(t,7)^Si(t,18)^t>>>3,r=Si(e,17)^Si(e,19)^e>>>10;Li[h]=r+Li[h-7]+n+Li[h-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let h=0;h<64;h++){const t=c+(Si(o,6)^Si(o,11)^Si(o,25))+((u=o)&a^~u&l)+Ii[h]+Li[h]|0,e=(Si(n,2)^Si(n,13)^Si(n,22))+Gi(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}var u;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){Li.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ui=Pi((()=>new Fi)),Di=BigInt(__pow(2,32)-1),ji=BigInt(32);function Hi(t,e=!1){return e?{h:Number(t&Di),l:Number(t>>ji&Di)}:{h:0|Number(t>>ji&Di),l:0|Number(t&Di)}}function Wi(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=Hi(t[i],e);[n[i],r[i]]=[s,o]}return[n,r]}const Qi=(t,e,n)=>t<<n|e>>>32-n,zi=(t,e,n)=>e<<n|t>>>32-n,Vi=(t,e,n)=>e<<n-32|t>>>64-n,Ki=(t,e,n)=>t<<n-32|e>>>64-n;const Ji={fromBig:Hi,split:Wi,toBig:(t,e)=>BigInt(t>>>0)<<ji|BigInt(e>>>0),shrSH:(t,e,n)=>t>>>n,shrSL:(t,e,n)=>t<<32-n|e>>>n,rotrSH:(t,e,n)=>t>>>n|e<<32-n,rotrSL:(t,e,n)=>t<<32-n|e>>>n,rotrBH:(t,e,n)=>t<<64-n|e>>>n-32,rotrBL:(t,e,n)=>t>>>n-32|e<<64-n,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:Qi,rotlSL:zi,rotlBH:Vi,rotlBL:Ki,add:function(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/__pow(2,32)|0)|0,l:0|i}},add3L:(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H:(t,e,n,r)=>e+n+r+(t/__pow(2,32)|0)|0,add4L:(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),add4H:(t,e,n,r,i)=>e+n+r+i+(t/__pow(2,32)|0)|0,add5H:(t,e,n,r,i,s)=>e+n+r+i+s+(t/__pow(2,32)|0)|0,add5L:(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},[qi,Zi]=(()=>Ji.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((t=>BigInt(t)))))(),Yi=new Uint32Array(80),Xi=new Uint32Array(80);class $i extends Bi{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:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:s,Dh:o,Dl:a,Eh:l,El:c,Fh:u,Fl:h,Gh:d,Gl:p,Hh:f,Hl:g}=this;return[t,e,n,r,i,s,o,a,l,c,u,h,d,p,f,g]}set(t,e,n,r,i,s,o,a,l,c,u,h,d,p,f,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|l,this.El=0|c,this.Fh=0|u,this.Fl=0|h,this.Gh=0|d,this.Gl=0|p,this.Hh=0|f,this.Hl=0|g}process(t,e){for(let _=0;_<16;_++,e+=4)Yi[_]=t.getUint32(e),Xi[_]=t.getUint32(e+=4);for(let _=16;_<80;_++){const t=0|Yi[_-15],e=0|Xi[_-15],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:c}=Ji.add(0|this.Dh,0|this.Dl,0|l,0|c)),({h:u,l:h}=Ji.add(0|this.Eh,0|this.El,0|u,0|h)),({h:d,l:p}=Ji.add(0|this.Fh,0|this.Fl,0|d,0|p)),({h:f,l:g}=Ji.add(0|this.Gh,0|this.Gl,0|f,0|g)),({h:m,l:y}=Ji.add(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(n,r,i,s,o,a,l,c,u,h,d,p,f,g,m,y)}roundClean(){Yi.fill(0),Xi.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 ts=Pi((()=>new $i));const es=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();es.crypto||es.msCrypto;const[ns,rs,is]=[[],[],[]],ss=BigInt(0),os=BigInt(1),as=BigInt(2),ls=BigInt(7),cs=BigInt(256),us=BigInt(113);for(let Op=0,Lp=os,Fp=1,Up=0;Op<24;Op++){[Fp,Up]=[Up,(2*Fp+3*Up)%5],ns.push(2*(5*Up+Fp)),rs.push((Op+1)*(Op+2)/2%64);let t=ss;for(let e=0;e<7;e++)Lp=(Lp<<os^(Lp>>ls)*us)%cs,Lp&as&&(t^=os<<(os<<BigInt(e))-os);is.push(t)}const[hs,ds]=Wi(is,!0),ps=(t,e,n)=>n>32?Vi(t,e,n):Qi(t,e,n),fs=(t,e,n)=>n>32?Ki(t,e,n):zi(t,e,n);class gs extends Ci{constructor(t,e,n,r=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,wi(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}keccak(){!function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let r=0;r<10;r++)n[r]=t[r]^t[r+10]^t[r+20]^t[r+30]^t[r+40];for(let r=0;r<10;r+=2){const e=(r+8)%10,i=(r+2)%10,s=n[i],o=n[i+1],a=ps(s,o,1)^n[e],l=fs(s,o,1)^n[e+1];for(let n=0;n<50;n+=10)t[r+n]^=a,t[r+n+1]^=l}let e=t[2],i=t[3];for(let n=0;n<24;n++){const r=rs[n],s=ps(e,i,r),o=fs(e,i,r),a=ns[n];e=t[a],i=t[a+1],t[a]=s,t[a+1]=o}for(let r=0;r<50;r+=10){for(let e=0;e<10;e++)n[e]=t[r+e];for(let e=0;e<10;e++)t[r+e]^=~n[(e+2)%10]&n[(e+4)%10]}t[0]^=hs[r],t[1]^=ds[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){bi(this);const{blockLen:e,state:n}=this,r=(t=Ni(t)).length;for(let i=0;i<r;){const s=Math.min(e-this.pos,r-i);for(let e=0;e<s;e++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){bi(this,!1),vi(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,i-r);t.set(e.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return wi(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ai(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:i,enableXOF:s}=this;return t||(t=new gs(e,n,r,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=s,t.destroyed=this.destroyed,t}}const ms=((t,e,n)=>Pi((()=>new gs(e,t,n))))(1,136,32);let ys=!1;const _s=function(t){return ms(t)};let ws=_s;function vs(t){const e=Hn(t,"data");return Kn(ws(e))}vs._=_s,vs.lock=function(){ys=!0},vs.register=function(t){if(ys)throw new TypeError("keccak256 is locked");ws=t},Object.freeze(vs);const bs=function(t){return function(t){switch(t){case"sha256":return Ui.create();case"sha512":return ts.create()}Ln(!1,"invalid hashing algorithm name","algorithm",t)}("sha256").update(t).digest()};let As=bs,Es=!1;function xs(t){const e=Hn(t,"data");return Kn(As(e))}xs._=bs,xs.lock=function(){Es=!0},xs.register=function(t){if(Es)throw new Error("sha256 is locked");As=t},Object.freeze(xs),Object.freeze(xs);
|
3
3
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
4
|
-
const ks=BigInt(0),Ss=BigInt(1),Ns=BigInt(2),Cs=t=>t instanceof Uint8Array,Ps=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Ts(t){if(!Cs(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Ps[t[n]];return e}function Ms(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function Rs(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function Bs(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const e=2*r,i=t.slice(e,e+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function
|
4
|
+
const ks=BigInt(0),Ss=BigInt(1),Ns=BigInt(2),Cs=t=>t instanceof Uint8Array,Ps=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Ts(t){if(!Cs(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Ps[t[n]];return e}function Ms(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function Rs(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function Bs(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const e=2*r,i=t.slice(e,e+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function Gs(t){return Rs(Ts(t))}function Is(t){if(!Cs(t))throw new Error("Uint8Array expected");return Rs(Ts(Uint8Array.from(t).reverse()))}function Os(t,e){return Bs(t.toString(16).padStart(2*e,"0"))}function Ls(t,e){return Os(t,e).reverse()}function Fs(t,e,n){let r;if("string"==typeof e)try{r=Bs(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else{if(!Cs(e))throw new Error(`${t} must be hex string or Uint8Array`);r=Uint8Array.from(e)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${t} expected ${n} bytes, got ${i}`);return r}function Us(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let n=0;return t.forEach((t=>{if(!Cs(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}const Ds=t=>(Ns<<BigInt(t-1))-Ss,js=t=>new Uint8Array(t),Hs=t=>Uint8Array.from(t);function Ws(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=js(t),i=js(t),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...t)=>n(i,r,...t),l=(t=js())=>{i=a(Hs([0]),t),r=a(),0!==t.length&&(i=a(Hs([1]),t),r=a())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t<e;){r=a();const e=r.slice();n.push(e),t+=r.length}return Us(...n)};return(t,e)=>{let n;for(o(),l(t);!(n=e(c()));)l();return o(),n}}const Qs={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function zs(t,e,n={}){const r=(e,n,r)=>{const i=Qs[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const s=t[e];if(!(r&&void 0===s||i(s,t)))throw new Error(`Invalid param ${String(e)}=${s} (${typeof s}), expected ${n}`)};for(const[i,s]of Object.entries(e))r(i,s,!1);for(const[i,s]of Object.entries(n))r(i,s,!0);return t}const Vs=Object.freeze(Object.defineProperty({__proto__:null,bitGet:function(t,e){return t>>BigInt(e)&Ss},bitLen:function(t){let e;for(e=0;t>ks;t>>=Ss,e+=1);return e},bitMask:Ds,bitSet:(t,e,n)=>t|(n?Ss:ks)<<BigInt(e),bytesToHex:Ts,bytesToNumberBE:Gs,bytesToNumberLE:Is,concatBytes:Us,createHmacDrbg:Ws,ensureBytes:Fs,equalBytes:function(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0},hexToBytes:Bs,hexToNumber:Rs,numberToBytesBE:Os,numberToBytesLE:Ls,numberToHexUnpadded:Ms,numberToVarBytesBE:function(t){return Bs(Ms(t))},utf8ToBytes:function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))},validateObject:zs},Symbol.toStringTag,{value:"Module"})),Ks=BigInt(0),Js=BigInt(1),qs=BigInt(2),Zs=BigInt(3),Ys=BigInt(4),Xs=BigInt(5),$s=BigInt(8);
|
5
5
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function to(t,e){const n=t%e;return n>=Ks?n:e+n}function eo(t,e,n){if(n<=Ks||e<Ks)throw new Error("Expected power/modulo > 0");if(n===Js)return Ks;let r=Js;for(;e>Ks;)e&Js&&(r=r*t%n),t=t*t%n,e>>=Js;return r}function no(t,e,n){let r=t;for(;e-- >Ks;)r*=r,r%=n;return r}function ro(t,e){if(t===Ks||e<=Ks)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=to(t,e),r=e,i=Ks,s=Js;for(;n!==Ks;){const t=r%n,e=i-s*(r/n);r=n,n=t,i=s,s=e}if(r!==Js)throw new Error("invert: does not exist");return to(i,e)}function io(t){if(t%Ys===Zs){const e=(t+Js)/Ys;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}if(t%$s===Xs){const e=(t-Xs)/$s;return function(t,n){const r=t.mul(n,qs),i=t.pow(r,e),s=t.mul(n,i),o=t.mul(t.mul(s,qs),i),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-Js)/qs;let n,r,i;for(n=t-Js,r=0;n%qs===Ks;n/=qs,r++);for(i=qs;i<t&&eo(i,e,t)!==t-Js;i++);if(1===r){const e=(t+Js)/Ys;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}const s=(n+Js)/qs;return function(t,o){if(t.pow(o,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=r,l=t.pow(t.mul(t.ONE,i),n),c=t.pow(o,s),u=t.pow(o,n);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(u);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const n=t.pow(l,Js<<BigInt(a-e-1));l=t.sqr(n),c=t.mul(c,n),u=t.mul(u,l),a=e}return c}}(t)}BigInt(9),BigInt(16);const so=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function oo(t,e){const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function ao(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function lo(t){const e=ao(t);return e+Math.ceil(e/2)}
|
6
6
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
7
7
|
const co=BigInt(0),uo=BigInt(1);function ho(t){return zs(t.Fp,so.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),zs(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze(__spreadValues(__spreadValues(__spreadValues({},oo(t.n,t.nBitLength)),t),{p:t.Fp.ORDER}))}
|
8
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:po,hexToBytes:fo}=Vs,go={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=go;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:po(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=go,n="string"==typeof t?fo(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=go._parseInt(n.subarray(2)),{d:o,l:a}=go._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),i=e(n(t.r)),s=r.length/2,o=i.length/2,a=n(s),l=n(o);return`30${n(o+s+4)}02${l}${i}02${a}${r}`}},mo=BigInt(0),_o=BigInt(1);BigInt(2);const yo=BigInt(3);function wo(t){const e=function(t){const e=ho(t);zs(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze(__spreadValues({},e))}(t),{Fp:n}=e,r=e.toBytes||((t,e,r)=>{const i=e.toAffine();return Us(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function s(t){const{a:r,b:i}=e,s=n.sqr(t),o=n.mul(s,t);return n.add(n.add(o,n.mul(t,r)),i)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(t){return"bigint"==typeof t&&mo<t&&t<e.n}function a(t){if(!o(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:s}=e;if(n&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Ts(t)),"string"!=typeof t||!n.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*r,"0")}let o;try{o="bigint"==typeof t?t:Is(Fs("private key",t,r))}catch(l){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof t}`)}return i&&(o=to(o,s)),a(o),o}const c=new Map;function u(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(t,e,r){if(this.px=t,this.py=e,this.pz=r,null==t||!n.isValid(t))throw new Error("x required");if(null==e||!n.isValid(e))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const i=t=>n.eql(t,n.ZERO);return i(e)&&i(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(Fs("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(t);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:i}=this,{px:s,py:o,pz:a}=t,l=n.eql(n.mul(e,a),n.mul(s,i)),c=n.eql(n.mul(r,a),n.mul(o,i));return l&&c}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,i=n.mul(r,yo),{px:s,py:o,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,d=n.mul(s,s),p=n.mul(o,o),f=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,a),u=n.add(u,u),l=n.mul(t,u),c=n.mul(i,f),c=n.add(l,c),l=n.sub(p,c),c=n.add(p,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(i,u),f=n.mul(t,f),g=n.sub(d,f),g=n.mul(t,g),g=n.add(g,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,f),d=n.mul(d,g),c=n.add(c,d),f=n.mul(o,a),f=n.add(f,f),d=n.mul(f,g),l=n.sub(l,d),u=n.mul(f,p),u=n.add(u,u),u=n.add(u,u),new h(l,c,u)}add(t){u(t);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:l}=t;let c=n.ZERO,d=n.ZERO,p=n.ZERO;const f=e.a,g=n.mul(e.b,yo);let m=n.mul(r,o),_=n.mul(i,a),y=n.mul(s,l),w=n.add(r,i),v=n.add(o,a);w=n.mul(w,v),v=n.add(m,_),w=n.sub(w,v),v=n.add(r,s);let b=n.add(o,l);return v=n.mul(v,b),b=n.add(m,y),v=n.sub(v,b),b=n.add(i,s),c=n.add(a,l),b=n.mul(b,c),c=n.add(_,y),b=n.sub(b,c),p=n.mul(f,v),c=n.mul(g,y),p=n.add(c,p),c=n.sub(_,p),p=n.add(_,p),d=n.mul(c,p),_=n.add(m,m),_=n.add(_,m),y=n.mul(f,y),v=n.mul(g,v),_=n.add(_,y),y=n.sub(m,y),y=n.mul(f,y),v=n.add(v,y),m=n.mul(_,v),d=n.add(d,m),m=n.mul(b,v),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,_),p=n.mul(b,p),p=n.add(p,m),new h(c,d,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,(t=>{const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}))}multiplyUnsafe(t){const r=h.ZERO;if(t===mo)return r;if(a(t),t===_o)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:o,k2neg:l,k2:c}=i.splitScalar(t),u=r,d=r,f=this;for(;o>mo||c>mo;)o&_o&&(u=u.add(f)),c&_o&&(d=d.add(f)),f=f.double(),o>>=_o,c>>=_o;return s&&(u=u.negate()),l&&(d=d.negate()),d=new h(n.mul(d.px,i.beta),d.py,d.pz),u.add(d)}multiply(t){a(t);let r,i,s=t;const{endo:o}=e;if(o){const{k1neg:t,k1:e,k2neg:a,k2:l}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(e),{p:d,f:f}=this.wNAF(l);c=p.constTimeNegate(t,c),d=p.constTimeNegate(a,d),d=new h(n.mul(d.px,o.beta),d.py,d.pz),r=c.add(d),i=u.add(f)}else{const{p:t,f:e}=this.wNAF(s);r=t,i=e}return h.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,i=(t,e)=>e!==mo&&e!==_o&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,n));return s.is0()?void 0:s}toAffine(t){const{px:e,py:r,pz:i}=this,s=this.is0();null==t&&(t=s?n.ONE:n.inv(i));const o=n.mul(e,t),a=n.mul(r,t),l=n.mul(i,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===_o)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===_o?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return Ts(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,p=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:__pow(2,t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,i=e;for(;n>co;)n&uo&&(r=r.add(i)),i=i.double(),n>>=uo;return r},precomputeWindow(t,e){const{windows:n,windowSize:i}=r(e),s=[];let o=t,a=o;for(let r=0;r<n;r++){a=o,s.push(a);for(let t=1;t<i;t++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(e,i,s){const{windows:o,windowSize:a}=r(e);let l=t.ZERO,c=t.BASE;const u=BigInt(__pow(2,e)-1),h=__pow(2,e),d=BigInt(e);for(let t=0;t<o;t++){const e=t*a;let r=Number(s&u);s>>=d,r>a&&(r-=h,s+=uo);const o=e,p=e+Math.abs(r)-1,f=t%2!=0,g=r<0;0===r?c=c.add(n(f,i[o])):l=l.add(n(g,i[p]))}return{p:l,f:c}},wNAFCached(t,e,n,r){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,r(s))),this.wNAF(i,s,n)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:o}}function vo(t){const e=function(t){const e=ho(t);return zs(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze(__spreadValues({lowS:!0},e))}(t),{Fp:n,n:r}=e,i=n.BYTES+1,s=2*n.BYTES+1;function o(t){return to(t,r)}function a(t){return ro(t,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=wo(__spreadProps(__spreadValues({},e),{toBytes(t,e,r){const i=e.toAffine(),s=n.toBytes(i.x),o=Us;return r?o(Uint8Array.from([e.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(t){const e=t.length,r=t[0],o=t.subarray(1);if(e!==i||2!==r&&3!==r){if(e===s&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=Is(o);if(!(mo<(a=t)&&a<n.ORDER))throw new Error("Point is not on curve");const e=u(t);let i=n.sqrt(e);return!(1&~r)!==((i&_o)===_o)&&(i=n.neg(i)),{x:t,y:i}}var a}})),d=t=>Ts(Os(t,e.nByteLength));function p(t){return t>r>>_o}const f=(t,e,n)=>Is(t.slice(e,n));class g{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=Fs("compactSignature",t,2*n),new g(f(t,0,n),f(t,n,2*n))}static fromDER(t){const{r:e,s:n}=go.toSig(Fs("DER",t));return new g(e,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:i,recovery:s}=this,c=w(Fs("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+d(u)),f=a(u),g=o(-c*f),m=o(i*f),_=l.BASE.multiplyAndAddUnsafe(p,g,m);if(!_)throw new Error("point at infinify");return _.assertValidity(),_}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Bs(this.toDERHex())}toDERHex(){return go.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Bs(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(t){try{return c(t),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=lo(e.n);return function(t,e,n=!1){const r=t.length,i=ao(e),s=lo(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=to(n?Is(t):Gs(t),e-Js)+Js;return n?Ls(o,i):Os(o,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=l.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function _(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===i||r===s:n?r===2*i||r===2*s:t instanceof l}const y=e.bits2int||function(t){const n=Is(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},w=e.bits2int_modN||function(t){return o(y(t))},v=Ds(e.nBitLength);function b(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(mo<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Os(t,e.nByteLength)}function A(t,r,i=E){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=e;let{lowS:d,prehash:f,extraEntropy:m}=i;null==d&&(d=!0),t=Fs("msgHash",t),f&&(t=Fs("prehashed msgHash",s(t)));const _=w(t),v=c(r),A=[b(v),b(_)];if(null!=m){const t=!0===m?u(n.BYTES):m;A.push(Fs("extraEntropy",t))}const x=Us(...A),k=_;return{seed:x,k2sig:function(t){const e=y(t);if(!h(e))return;const n=a(e),r=l.BASE.multiply(e).toAffine(),i=o(r.x);if(i===mo)return;const s=o(n*o(k+i*v));if(s===mo)return;let c=(r.x===i?0:2)|Number(r.y&_o),u=s;return d&&p(s)&&(u=function(t){return p(t)?o(-t):t}(s),c^=1),new g(i,u,c)}}}const E={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return l.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(_(t))throw new Error("first arg must be private key");if(!_(e))throw new Error("second arg must be public key");return l.fromHex(e).multiply(c(t)).toRawBytes(n)},sign:function(t,n,r=E){const{seed:i,k2sig:s}=A(t,n,r),o=e;return Ws(o.hash.outputLen,o.nByteLength,o.hmac)(i,s)},verify:function(t,n,r,i=x){var s;const c=t;if(n=Fs("msgHash",n),r=Fs("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:h}=i;let d,p;try{if("string"==typeof c||c instanceof Uint8Array)try{d=g.fromDER(c)}catch(E){if(!(E instanceof go.Err))throw E;d=g.fromCompact(c)}else{if("object"!=typeof c||"bigint"!=typeof c.r||"bigint"!=typeof c.s)throw new Error("PARSE");{const{r:t,s:e}=c;d=new g(t,e)}}p=l.fromHex(r)}catch(k){if("PARSE"===k.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&d.hasHighS())return!1;h&&(n=e.hash(n));const{r:f,s:m}=d,_=w(n),y=a(m),v=o(_*y),b=o(f*y),A=null==(s=l.BASE.multiplyAndAddUnsafe(p,v,b))?void 0:s.toAffine();return!!A&&o(A.x)===f},ProjectivePoint:l,Signature:g,utils:m}}
|
8
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:po,hexToBytes:fo}=Vs,go={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=go;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:po(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=go,n="string"==typeof t?fo(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=go._parseInt(n.subarray(2)),{d:o,l:a}=go._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),i=e(n(t.r)),s=r.length/2,o=i.length/2,a=n(s),l=n(o);return`30${n(o+s+4)}02${l}${i}02${a}${r}`}},mo=BigInt(0),yo=BigInt(1);BigInt(2);const _o=BigInt(3);function wo(t){const e=function(t){const e=ho(t);zs(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze(__spreadValues({},e))}(t),{Fp:n}=e,r=e.toBytes||((t,e,r)=>{const i=e.toAffine();return Us(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function s(t){const{a:r,b:i}=e,s=n.sqr(t),o=n.mul(s,t);return n.add(n.add(o,n.mul(t,r)),i)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(t){return"bigint"==typeof t&&mo<t&&t<e.n}function a(t){if(!o(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:s}=e;if(n&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Ts(t)),"string"!=typeof t||!n.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*r,"0")}let o;try{o="bigint"==typeof t?t:Gs(Fs("private key",t,r))}catch(l){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof t}`)}return i&&(o=to(o,s)),a(o),o}const c=new Map;function u(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(t,e,r){if(this.px=t,this.py=e,this.pz=r,null==t||!n.isValid(t))throw new Error("x required");if(null==e||!n.isValid(e))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const i=t=>n.eql(t,n.ZERO);return i(e)&&i(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(Fs("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(t);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:i}=this,{px:s,py:o,pz:a}=t,l=n.eql(n.mul(e,a),n.mul(s,i)),c=n.eql(n.mul(r,a),n.mul(o,i));return l&&c}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,i=n.mul(r,_o),{px:s,py:o,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,d=n.mul(s,s),p=n.mul(o,o),f=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,a),u=n.add(u,u),l=n.mul(t,u),c=n.mul(i,f),c=n.add(l,c),l=n.sub(p,c),c=n.add(p,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(i,u),f=n.mul(t,f),g=n.sub(d,f),g=n.mul(t,g),g=n.add(g,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,f),d=n.mul(d,g),c=n.add(c,d),f=n.mul(o,a),f=n.add(f,f),d=n.mul(f,g),l=n.sub(l,d),u=n.mul(f,p),u=n.add(u,u),u=n.add(u,u),new h(l,c,u)}add(t){u(t);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:l}=t;let c=n.ZERO,d=n.ZERO,p=n.ZERO;const f=e.a,g=n.mul(e.b,_o);let m=n.mul(r,o),y=n.mul(i,a),_=n.mul(s,l),w=n.add(r,i),v=n.add(o,a);w=n.mul(w,v),v=n.add(m,y),w=n.sub(w,v),v=n.add(r,s);let b=n.add(o,l);return v=n.mul(v,b),b=n.add(m,_),v=n.sub(v,b),b=n.add(i,s),c=n.add(a,l),b=n.mul(b,c),c=n.add(y,_),b=n.sub(b,c),p=n.mul(f,v),c=n.mul(g,_),p=n.add(c,p),c=n.sub(y,p),p=n.add(y,p),d=n.mul(c,p),y=n.add(m,m),y=n.add(y,m),_=n.mul(f,_),v=n.mul(g,v),y=n.add(y,_),_=n.sub(m,_),_=n.mul(f,_),v=n.add(v,_),m=n.mul(y,v),d=n.add(d,m),m=n.mul(b,v),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,y),p=n.mul(b,p),p=n.add(p,m),new h(c,d,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,(t=>{const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}))}multiplyUnsafe(t){const r=h.ZERO;if(t===mo)return r;if(a(t),t===yo)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:o,k2neg:l,k2:c}=i.splitScalar(t),u=r,d=r,f=this;for(;o>mo||c>mo;)o&yo&&(u=u.add(f)),c&yo&&(d=d.add(f)),f=f.double(),o>>=yo,c>>=yo;return s&&(u=u.negate()),l&&(d=d.negate()),d=new h(n.mul(d.px,i.beta),d.py,d.pz),u.add(d)}multiply(t){a(t);let r,i,s=t;const{endo:o}=e;if(o){const{k1neg:t,k1:e,k2neg:a,k2:l}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(e),{p:d,f:f}=this.wNAF(l);c=p.constTimeNegate(t,c),d=p.constTimeNegate(a,d),d=new h(n.mul(d.px,o.beta),d.py,d.pz),r=c.add(d),i=u.add(f)}else{const{p:t,f:e}=this.wNAF(s);r=t,i=e}return h.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,i=(t,e)=>e!==mo&&e!==yo&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,n));return s.is0()?void 0:s}toAffine(t){const{px:e,py:r,pz:i}=this,s=this.is0();null==t&&(t=s?n.ONE:n.inv(i));const o=n.mul(e,t),a=n.mul(r,t),l=n.mul(i,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===yo)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===yo?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return Ts(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,p=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:__pow(2,t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,i=e;for(;n>co;)n&uo&&(r=r.add(i)),i=i.double(),n>>=uo;return r},precomputeWindow(t,e){const{windows:n,windowSize:i}=r(e),s=[];let o=t,a=o;for(let r=0;r<n;r++){a=o,s.push(a);for(let t=1;t<i;t++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(e,i,s){const{windows:o,windowSize:a}=r(e);let l=t.ZERO,c=t.BASE;const u=BigInt(__pow(2,e)-1),h=__pow(2,e),d=BigInt(e);for(let t=0;t<o;t++){const e=t*a;let r=Number(s&u);s>>=d,r>a&&(r-=h,s+=uo);const o=e,p=e+Math.abs(r)-1,f=t%2!=0,g=r<0;0===r?c=c.add(n(f,i[o])):l=l.add(n(g,i[p]))}return{p:l,f:c}},wNAFCached(t,e,n,r){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,r(s))),this.wNAF(i,s,n)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:o}}function vo(t){const e=function(t){const e=ho(t);return zs(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze(__spreadValues({lowS:!0},e))}(t),{Fp:n,n:r}=e,i=n.BYTES+1,s=2*n.BYTES+1;function o(t){return to(t,r)}function a(t){return ro(t,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=wo(__spreadProps(__spreadValues({},e),{toBytes(t,e,r){const i=e.toAffine(),s=n.toBytes(i.x),o=Us;return r?o(Uint8Array.from([e.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(t){const e=t.length,r=t[0],o=t.subarray(1);if(e!==i||2!==r&&3!==r){if(e===s&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=Gs(o);if(!(mo<(a=t)&&a<n.ORDER))throw new Error("Point is not on curve");const e=u(t);let i=n.sqrt(e);return!(1&~r)!==((i&yo)===yo)&&(i=n.neg(i)),{x:t,y:i}}var a}})),d=t=>Ts(Os(t,e.nByteLength));function p(t){return t>r>>yo}const f=(t,e,n)=>Gs(t.slice(e,n));class g{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=Fs("compactSignature",t,2*n),new g(f(t,0,n),f(t,n,2*n))}static fromDER(t){const{r:e,s:n}=go.toSig(Fs("DER",t));return new g(e,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:i,recovery:s}=this,c=w(Fs("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+d(u)),f=a(u),g=o(-c*f),m=o(i*f),y=l.BASE.multiplyAndAddUnsafe(p,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Bs(this.toDERHex())}toDERHex(){return go.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Bs(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(t){try{return c(t),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=lo(e.n);return function(t,e,n=!1){const r=t.length,i=ao(e),s=lo(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=to(n?Gs(t):Is(t),e-Js)+Js;return n?Ls(o,i):Os(o,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=l.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function y(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===i||r===s:n?r===2*i||r===2*s:t instanceof l}const _=e.bits2int||function(t){const n=Gs(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},w=e.bits2int_modN||function(t){return o(_(t))},v=Ds(e.nBitLength);function b(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(mo<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Os(t,e.nByteLength)}function A(t,r,i=E){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=e;let{lowS:d,prehash:f,extraEntropy:m}=i;null==d&&(d=!0),t=Fs("msgHash",t),f&&(t=Fs("prehashed msgHash",s(t)));const y=w(t),v=c(r),A=[b(v),b(y)];if(null!=m){const t=!0===m?u(n.BYTES):m;A.push(Fs("extraEntropy",t))}const x=Us(...A),k=y;return{seed:x,k2sig:function(t){const e=_(t);if(!h(e))return;const n=a(e),r=l.BASE.multiply(e).toAffine(),i=o(r.x);if(i===mo)return;const s=o(n*o(k+i*v));if(s===mo)return;let c=(r.x===i?0:2)|Number(r.y&yo),u=s;return d&&p(s)&&(u=function(t){return p(t)?o(-t):t}(s),c^=1),new g(i,u,c)}}}const E={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return l.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(y(t))throw new Error("first arg must be private key");if(!y(e))throw new Error("second arg must be public key");return l.fromHex(e).multiply(c(t)).toRawBytes(n)},sign:function(t,n,r=E){const{seed:i,k2sig:s}=A(t,n,r),o=e;return Ws(o.hash.outputLen,o.nByteLength,o.hmac)(i,s)},verify:function(t,n,r,i=x){var s;const c=t;if(n=Fs("msgHash",n),r=Fs("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:h}=i;let d,p;try{if("string"==typeof c||c instanceof Uint8Array)try{d=g.fromDER(c)}catch(E){if(!(E instanceof go.Err))throw E;d=g.fromCompact(c)}else{if("object"!=typeof c||"bigint"!=typeof c.r||"bigint"!=typeof c.s)throw new Error("PARSE");{const{r:t,s:e}=c;d=new g(t,e)}}p=l.fromHex(r)}catch(k){if("PARSE"===k.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&d.hasHighS())return!1;h&&(n=e.hash(n));const{r:f,s:m}=d,y=w(n),_=a(m),v=o(y*_),b=o(f*_),A=null==(s=l.BASE.multiplyAndAddUnsafe(p,v,b))?void 0:s.toAffine();return!!A&&o(A.x)===f},ProjectivePoint:l,Signature:g,utils:m}}
|
9
9
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bo(t){return{hash:t,hmac:(e,...n)=>Ri(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let n=0;return t.forEach((t=>{if(!xi(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}(...n)),randomBytes:Ti}}BigInt(4);
|
10
10
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
11
|
-
const Ao=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Eo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xo=BigInt(1),ko=BigInt(2),So=(t,e)=>(t+e/ko)/e;const No=function(t,e,n=!1,r={}){if(t<=Ks)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=oo(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=io(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Ds(i),ZERO:Ks,ONE:Js,create:e=>to(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return Ks<=e&&e<t},is0:t=>t===Ks,isOdd:t=>(t&Js)===Js,neg:e=>to(-e,t),eql:(t,e)=>t===e,sqr:e=>to(e*e,t),add:(e,n)=>to(e+n,t),sub:(e,n)=>to(e-n,t),mul:(e,n)=>to(e*n,t),pow:(t,e)=>function(t,e,n){if(n<Ks)throw new Error("Expected power > 0");if(n===Ks)return t.ONE;if(n===Js)return e;let r=t.ONE,i=e;for(;n>Ks;)n&Js&&(r=t.mul(r,i)),i=t.sqr(i),n>>=Js;return r}(a,t,e),div:(e,n)=>to(e*ro(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>ro(e,t),sqrt:r.sqrt||(t=>o(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce(((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r))),t.ONE),i=t.inv(r);return e.reduceRight(((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r))),i),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?Ls(t,s):Os(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return n?Gs(t):Is(t)}});return Object.freeze(a)}(Ao,void 0,void 0,{sqrt:function(t){const e=Ao,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=no(u,n,e)*u%e,d=no(h,n,e)*u%e,p=no(d,ko,e)*c%e,f=no(p,i,e)*p%e,g=no(f,s,e)*f%e,m=no(g,a,e)*g%e,_=no(m,l,e)*m%e,y=no(_,a,e)*g%e,w=no(y,n,e)*u%e,v=no(w,o,e)*f%e,b=no(v,r,e)*c%e,A=no(b,ko,e);if(!No.eql(No.sqr(A),t))throw new Error("Cannot find square root");return A}}),Co=function(t,e){const n=e=>vo(__spreadValues(__spreadValues({},t),bo(e)));return Object.freeze(__spreadProps(__spreadValues({},n(e)),{create:n}))}({a:BigInt(0),b:BigInt(7),Fp:No,n:Eo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Eo,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-xo*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=So(s*t,e),l=So(-r*t,e);let c=to(t-a*n-l*i,e),u=to(-a*r-l*s,e);const h=c>o,d=u>o;if(h&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Ui);BigInt(0),Co.ProjectivePoint;const Po="0x0000000000000000000000000000000000000000",To="0x0000000000000000000000000000000000000000000000000000000000000000",Mo=BigInt(0),Ro=BigInt(1),Bo=BigInt(2),Io=BigInt(27),Go=BigInt(28),Oo=BigInt(35),Lo={};function Fo(t){return Xn(hr(t),32)}const Uo=class t{constructor(t,e,n,r){__privateAdd(this,rt,void 0),__privateAdd(this,it,void 0),__privateAdd(this,st,void 0),__privateAdd(this,ot,void 0),Dn(t,Lo,"Signature"),__privateSet(this,rt,e),__privateSet(this,it,n),__privateSet(this,st,r),__privateSet(this,ot,null)}get r(){return __privateGet(this,rt)}set r(t){Ln(32===qn(t),"invalid r","value",t),__privateSet(this,rt,Kn(t))}get s(){return __privateGet(this,it)}set s(t){Ln(32===qn(t),"invalid s","value",t);const e=Kn(t);Ln(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),__privateSet(this,it,e)}get v(){return __privateGet(this,st)}set v(t){const e=cr(t,"value");Ln(27===e||28===e,"invalid v","v",t),__privateSet(this,st,e)}get networkV(){return __privateGet(this,ot)}get legacyChainId(){const e=this.networkV;return null==e?null:t.getChainId(e)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=Hn(this.s);return this.yParity&&(t[0]|=128),Kn(t)}get compactSerialized(){return Jn([this.r,this.yParityAndS])}get serialized(){return Jn([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 t(Lo,this.r,this.s,this.v);return this.networkV&&__privateSet(e,ot,this.networkV),e}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=sr(t,"v");return e==Io||e==Go?Mo:(Ln(e>=Oo,"invalid EIP-155 v","v",t),(e-Oo)/Bo)}static getChainIdV(t,e){return sr(t)*Bo+BigInt(35+e-27)}static getNormalizedV(t){const e=sr(t);return e===Mo||e===Io?27:e===Ro||e===Go?28:(Ln(e>=Oo,"invalid v","v",t),e&Ro?27:28)}static from(e){function n(t,n){Ln(t,n,"signature",e)}if(null==e)return new t(Lo,To,To,27);if("string"==typeof e){const r=Hn(e,"signature");if(64===r.length){const e=Kn(r.slice(0,32)),n=r.slice(32,64),i=128&n[0]?28:27;return n[0]&=127,new t(Lo,e,Kn(n),i)}if(65===r.length){const e=Kn(r.slice(0,32)),i=r.slice(32,64);n(!(128&i[0]),"non-canonical s");const s=t.getNormalizedV(r[64]);return new t(Lo,e,Kn(i),s)}n(!1,"invalid raw signature length")}if(e instanceof t)return e.clone();const r=e.r;n(null!=r,"missing r");const i=Fo(r),s=function(t,e){if(null!=t)return Fo(t);if(null!=e){n(Qn(e,32),"invalid yParityAndS");const t=Hn(e);return t[0]&=127,Kn(t)}n(!1,"missing s")}(e.s,e.yParityAndS);n(!(128&Hn(s)[0]),"non-canonical s");const{networkV:o,v:a}=function(e,r,i){if(null!=e){const n=sr(e);return{networkV:n>=Oo?n:void 0,v:t.getNormalizedV(n)}}if(null!=r)return n(Qn(r,32),"invalid yParityAndS"),{v:128&Hn(r)[0]?28:27};if(null!=i){switch(cr(i,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}n(!1,"invalid yParity")}n(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new t(Lo,i,s,a);return o&&__privateSet(l,ot,o),n(null==e.yParity||cr(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),n(null==e.yParityAndS||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};rt=new WeakMap,it=new WeakMap,st=new WeakMap,ot=new WeakMap;let Do=Uo;at=new WeakMap;let jo=class t{constructor(t){__privateAdd(this,at,void 0),Ln(32===qn(t),"invalid private key","privateKey","[REDACTED]"),__privateSet(this,at,Kn(t))}get privateKey(){return __privateGet(this,at)}get publicKey(){return t.computePublicKey(__privateGet(this,at))}get compressedPublicKey(){return t.computePublicKey(__privateGet(this,at),!0)}sign(t){Ln(32===qn(t),"invalid digest length","digest",t);const e=Co.sign(Wn(t),Wn(__privateGet(this,at)),{lowS:!0});return Do.from({r:ur(e.r,32),s:ur(e.s,32),v:e.recovery?28:27})}computeSharedSecret(e){const n=t.computePublicKey(e);return Kn(Co.getSharedSecret(Wn(__privateGet(this,at)),Hn(n),!1))}static computePublicKey(t,e){let n=Hn(t,"key");if(32===n.length){return Kn(Co.getPublicKey(n,!!e))}if(64===n.length){const t=new Uint8Array(65);t[0]=4,t.set(n,1),n=t}return Kn(Co.ProjectivePoint.fromHex(n).toRawBytes(e))}static recoverPublicKey(t,e){Ln(32===qn(t),"invalid digest length","digest",t);const n=Do.from(e);let r=Co.Signature.fromCompact(Wn(Jn([n.r,n.s])));r=r.addRecoveryBit(n.yParity);const i=r.recoverPublicKey(Wn(t));return Ln(null!=i,"invalid signature for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(e,n,r){const i=Co.ProjectivePoint.fromHex(t.computePublicKey(e).substring(2)),s=Co.ProjectivePoint.fromHex(t.computePublicKey(n).substring(2));return"0x"+i.add(s).toHex(!!r)}};const Ho=BigInt(0),Wo=BigInt(36);function Qo(t){const e=(t=t.toLowerCase()).substring(2).split(""),n=new Uint8Array(40);for(let i=0;i<40;i++)n[i]=e[i].charCodeAt(0);const r=Hn(vs(n));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(15&r[i>>1])>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const zo={};for(let Op=0;Op<10;Op++)zo[String(Op)]=String(Op);for(let Op=0;Op<26;Op++)zo[String.fromCharCode(65+Op)]=String(10+Op);const Vo=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function Ko(t){if(Ln("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=Qo(t);return Ln(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){Ln(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>zo[t])).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let n=String(98-parseInt(e,10)%97);for(;n.length<2;)n="0"+n;return n}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=Ho;for(let n=0;n<t.length;n++)e=e*Wo+Vo[t[n]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Qo("0x"+e)}Ln(!1,"invalid address","address",t)}function Jo(t){return t&&"function"==typeof t.getAddress}function qo(t,e){return __async(this,null,(function*(){const n=yield e;return null!=n&&"0x0000000000000000000000000000000000000000"!==n||(On("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),Ln(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),Ko(n)}))}function Zo(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?Ko(t):(On(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),qo(t,e.resolveName(t))):Jo(t)?qo(t,t.getAddress()):t&&"function"==typeof t.then?qo(t,t):void Ln(!1,"unsupported addressable value","target",t)}const Yo={};function Xo(t,e){let n=!1;return e<0&&(n=!0,e*=-1),new ea(Yo,`${n?"":"u"}int${e}`,t,{signed:n,width:e})}function $o(t,e){return new ea(Yo,`bytes${e||""}`,t,{size:e})}const ta=Symbol.for("_ethers_typed");lt=new WeakMap;let ea=class t{constructor(t,e,n,r){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,lt,void 0),__publicField(this,"_typedSymbol"),null==r&&(r=null),Dn(Yo,t,"Typed"),Mn(this,{_typedSymbol:ta,type:e,value:n}),__privateSet(this,lt,r),this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.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"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return __privateGet(this,lt)}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===__privateGet(this,lt)?-1:!1===__privateGet(this,lt)?this.value.length:null}static from(e,n){return new t(Yo,e,n)}static uint8(t){return Xo(t,8)}static uint16(t){return Xo(t,16)}static uint24(t){return Xo(t,24)}static uint32(t){return Xo(t,32)}static uint40(t){return Xo(t,40)}static uint48(t){return Xo(t,48)}static uint56(t){return Xo(t,56)}static uint64(t){return Xo(t,64)}static uint72(t){return Xo(t,72)}static uint80(t){return Xo(t,80)}static uint88(t){return Xo(t,88)}static uint96(t){return Xo(t,96)}static uint104(t){return Xo(t,104)}static uint112(t){return Xo(t,112)}static uint120(t){return Xo(t,120)}static uint128(t){return Xo(t,128)}static uint136(t){return Xo(t,136)}static uint144(t){return Xo(t,144)}static uint152(t){return Xo(t,152)}static uint160(t){return Xo(t,160)}static uint168(t){return Xo(t,168)}static uint176(t){return Xo(t,176)}static uint184(t){return Xo(t,184)}static uint192(t){return Xo(t,192)}static uint200(t){return Xo(t,200)}static uint208(t){return Xo(t,208)}static uint216(t){return Xo(t,216)}static uint224(t){return Xo(t,224)}static uint232(t){return Xo(t,232)}static uint240(t){return Xo(t,240)}static uint248(t){return Xo(t,248)}static uint256(t){return Xo(t,256)}static uint(t){return Xo(t,256)}static int8(t){return Xo(t,-8)}static int16(t){return Xo(t,-16)}static int24(t){return Xo(t,-24)}static int32(t){return Xo(t,-32)}static int40(t){return Xo(t,-40)}static int48(t){return Xo(t,-48)}static int56(t){return Xo(t,-56)}static int64(t){return Xo(t,-64)}static int72(t){return Xo(t,-72)}static int80(t){return Xo(t,-80)}static int88(t){return Xo(t,-88)}static int96(t){return Xo(t,-96)}static int104(t){return Xo(t,-104)}static int112(t){return Xo(t,-112)}static int120(t){return Xo(t,-120)}static int128(t){return Xo(t,-128)}static int136(t){return Xo(t,-136)}static int144(t){return Xo(t,-144)}static int152(t){return Xo(t,-152)}static int160(t){return Xo(t,-160)}static int168(t){return Xo(t,-168)}static int176(t){return Xo(t,-176)}static int184(t){return Xo(t,-184)}static int192(t){return Xo(t,-192)}static int200(t){return Xo(t,-200)}static int208(t){return Xo(t,-208)}static int216(t){return Xo(t,-216)}static int224(t){return Xo(t,-224)}static int232(t){return Xo(t,-232)}static int240(t){return Xo(t,-240)}static int248(t){return Xo(t,-248)}static int256(t){return Xo(t,-256)}static int(t){return Xo(t,-256)}static bytes1(t){return $o(t,1)}static bytes2(t){return $o(t,2)}static bytes3(t){return $o(t,3)}static bytes4(t){return $o(t,4)}static bytes5(t){return $o(t,5)}static bytes6(t){return $o(t,6)}static bytes7(t){return $o(t,7)}static bytes8(t){return $o(t,8)}static bytes9(t){return $o(t,9)}static bytes10(t){return $o(t,10)}static bytes11(t){return $o(t,11)}static bytes12(t){return $o(t,12)}static bytes13(t){return $o(t,13)}static bytes14(t){return $o(t,14)}static bytes15(t){return $o(t,15)}static bytes16(t){return $o(t,16)}static bytes17(t){return $o(t,17)}static bytes18(t){return $o(t,18)}static bytes19(t){return $o(t,19)}static bytes20(t){return $o(t,20)}static bytes21(t){return $o(t,21)}static bytes22(t){return $o(t,22)}static bytes23(t){return $o(t,23)}static bytes24(t){return $o(t,24)}static bytes25(t){return $o(t,25)}static bytes26(t){return $o(t,26)}static bytes27(t){return $o(t,27)}static bytes28(t){return $o(t,28)}static bytes29(t){return $o(t,29)}static bytes30(t){return $o(t,30)}static bytes31(t){return $o(t,31)}static bytes32(t){return $o(t,32)}static address(e){return new t(Yo,"address",e)}static bool(e){return new t(Yo,"bool",!!e)}static bytes(e){return new t(Yo,"bytes",e)}static string(e){return new t(Yo,"string",e)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(e){return new t(Yo,"overrides",Object.assign({},e))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===ta}static dereference(e,n){if(t.isTyped(e)){if(e.type!==n)throw new Error(`invalid type: expecetd ${n}, got ${e.type}`);return e.value}return e}};class na extends mi{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=ea.dereference(e,"string");try{n=Ko(n)}catch(r){return this._throwError(r.message,e)}return t.writeValue(n)}decode(t){return Ko(ur(t.readValue(),20))}}class ra extends mi{constructor(t){super(t.name,t.type,"_",t.dynamic),__publicField(this,"coder"),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function ia(t,e,n){let r=[];if(Array.isArray(n))r=n;else if(n&&"object"==typeof n){let t={};r=e.map((e=>{const r=e.localName;return On(r,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:n}),On(!t[r],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:n}),t[r]=!0,n[r]}))}else Ln(!1,"invalid tuple value","tuple",n);Ln(e.length===r.length,"types/value length mismatch","tuple",n);let i=new _i,s=new _i,o=[];e.forEach(((t,e)=>{let n=r[e];if(t.dynamic){let e=s.length;t.encode(s,n);let r=i.writeUpdatableValue();o.push((t=>{r(t+e)}))}else t.encode(i,n)})),o.forEach((t=>{t(i.length)}));let a=t.appendWriter(i);return a+=t.appendWriter(s),a}function sa(t,e){let n=[],r=[],i=t.subReader(0);return e.forEach((e=>{let s=null;if(e.dynamic){let n=t.readIndex(),r=i.subReader(n);try{s=e.decode(r)}catch(o){if(Bn(o,"BUFFER_OVERRUN"))throw o;s=o,s.baseType=e.name,s.name=e.localName,s.type=e.type}}else try{s=e.decode(t)}catch(o){if(Bn(o,"BUFFER_OVERRUN"))throw o;s=o,s.baseType=e.name,s.name=e.localName,s.type=e.type}if(null==s)throw new Error("investigate");n.push(s),r.push(e.localName||null)})),fi.fromItems(n,r)}class oa extends mi{constructor(t,e,n){super("array",t.type+"["+(e>=0?e:"")+"]",n,-1===e||t.dynamic),__publicField(this,"coder"),__publicField(this,"length"),Mn(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let n=0;n<this.length;n++)e.push(t);return e}encode(t,e){const n=ea.dereference(e,"array");Array.isArray(n)||this._throwError("expected array value",n);let r=this.length;-1===r&&(r=n.length,t.writeValue(n.length)),Fn(n.length,r,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let s=0;s<n.length;s++)i.push(this.coder);return ia(t,i,n)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),On(e*si<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*si,length:t.dataLength}));let n=[];for(let r=0;r<e;r++)n.push(new ra(this.coder));return sa(t,n)}}class aa extends mi{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const n=ea.dereference(e,"bool");return t.writeValue(n?1:0)}decode(t){return!!t.readValue()}}class la extends mi{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=Wn(e);let n=t.writeValue(e.length);return n+=t.writeBytes(e),n}decode(t){return t.readBytes(t.readIndex(),!0)}}class ca extends la{constructor(t){super("bytes",t)}decode(t){return Kn(super.decode(t))}}class ua extends mi{constructor(t,e){let n="bytes"+String(t);super(n,n,e,!1),__publicField(this,"size"),Mn(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let n=Wn(ea.dereference(e,this.type));return n.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(n)}decode(t){return Kn(t.readBytes(this.size))}}const ha=new Uint8Array([]);class da extends mi{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(ha)}decode(t){return t.readBytes(0),null}}const pa=BigInt(0),fa=BigInt(1),ga=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class ma extends mi{constructor(t,e,n){const r=(e?"int":"uint")+8*t;super(r,r,n,!1),__publicField(this,"size"),__publicField(this,"signed"),Mn(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let n=sr(ea.dereference(e,this.type)),r=ir(ga,256);if(this.signed){let t=ir(r,8*this.size-1);(n>t||n<-(t+fa))&&this._throwError("value out-of-bounds",e),n=rr(n,256)}else(n<pa||n>ir(r,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(n)}decode(t){let e=ir(t.readValue(),8*this.size);return this.signed&&(e=nr(e,8*this.size)),e}}class _a extends la{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,yr(ea.dereference(e,"string")))}decode(t){return wr(super.decode(t))}}class ya extends mi{constructor(t,e){let n=!1;const r=[];t.forEach((t=>{t.dynamic&&(n=!0),r.push(t.type)}));super("tuple","tuple("+r.join(",")+")",e,n),__publicField(this,"coders"),Mn(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const n=e.localName;return n&&(t[n]||(t[n]=0),t[n]++),t}),{});return this.coders.forEach(((n,r)=>{let i=n.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[r]))})),Object.freeze(t)}encode(t,e){const n=ea.dereference(e,"tuple");return ia(t,this.coders,n)}decode(t){return sa(t,this.coders)}}function wa(t,e){return{address:Ko(t),storageKeys:e.map(((t,e)=>(Ln(Qn(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function va(t){if(Array.isArray(t))return t.map(((e,n)=>Array.isArray(e)?(Ln(2===e.length,"invalid slot set",`value[${n}]`,e),wa(e[0],e[1])):(Ln(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),wa(e.address,e.storageKeys))));Ln(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const n=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return wa(e,Object.keys(n).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function ba(t){return{address:Ko(t.address),nonce:sr(null!=t.nonce?t.nonce:0),chainId:sr(null!=t.chainId?t.chainId:0),signature:Do.from(t.signature)}}function Aa(t,e){return function(t){let e;return e="string"==typeof t?jo.computePublicKey(t,!1):t.publicKey,Ko(vs("0x"+e.substring(4)).substring(26))}(jo.recoverPublicKey(t,e))}const Ea=BigInt(0),xa=BigInt(2),ka=BigInt(27),Sa=BigInt(28),Na=BigInt(35),Ca=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Pa=131072;function Ta(t,e){let n=t.toString(16);for(;n.length<2;)n="0"+n;return n+=xs(e).substring(4),"0x"+n}function Ma(t){return"0x"===t?null:Ko(t)}function Ra(t,e){try{return va(t)}catch(n){Ln(!1,n.message,e,t)}}function Ba(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!Array.isArray(r))throw new Error(`authorization[${n}]: invalid array`);if(6!==r.length)throw new Error(`authorization[${n}]: wrong length`);if(!r[1])throw new Error(`authorization[${n}]: null address`);e.push({address:Ma(r[1]),nonce:Ga(r[2],"nonce"),chainId:Ga(r[0],"chainId"),signature:Do.from({yParity:Ia(r[3],"yParity"),r:Xn(r[4],32),s:Xn(r[5],32)})})}return e}catch(n){Ln(!1,n.message,e,t)}}function Ia(t,e){return"0x"===t?0:cr(t,e)}function Ga(t,e){if("0x"===t)return Ea;const n=sr(t,e);return Ln(n<=Ca,"value exceeds uint size",e,n),n}function Oa(t,e){const n=sr(t,"value"),r=hr(n);return Ln(r.length<=32,"value too large",`tx.${e}`,n),r}function La(t){return va(t).map((t=>[t.address,t.storageKeys]))}function Fa(t,e){Ln(Array.isArray(t),`invalid ${e}`,"value",t);for(let n=0;n<t.length;n++)Ln(Qn(t[n],32),"invalid ${ param } hash",`value[${n}]`,t[n]);return t}function Ua(t,e){let n;try{if(n=Ia(e[0],"yParity"),0!==n&&1!==n)throw new Error("bad yParity")}catch(o){Ln(!1,"invalid yParity","yParity",e[0])}const r=Xn(e[1],32),i=Xn(e[2],32),s=Do.from({r:r,s:i,yParity:n});t.signature=s}ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,ft=new WeakMap,gt=new WeakMap,mt=new WeakMap,_t=new WeakMap,yt=new WeakMap,wt=new WeakMap,vt=new WeakMap,bt=new WeakMap,At=new WeakMap,Et=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakSet,Nt=function(t,e){On(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const n=[Oa(t.nonce,"nonce"),Oa(t.gasPrice||0,"gasPrice"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data];let r=Ea;if(t.chainId!=Ea)r=sr(t.chainId,"tx.chainId"),Ln(!e||null==e.networkV||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(r=e)}if(!e)return r!==Ea&&(n.push(hr(r)),n.push("0x"),n.push("0x")),ei(n);let i=BigInt(27+e.yParity);return r!==Ea?i=Do.getChainIdV(r,e.v):BigInt(e.v)!==i&&Ln(!1,"tx.chainId/sig.v mismatch","sig",e),n.push(hr(i)),n.push(hr(e.r)),n.push(hr(e.s)),ei(n)}(this,n);case 1:return function(t,e){const n=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.gasPrice||0,"gasPrice"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data,La(t.accessList||[])];return e&&(n.push(Oa(e.yParity,"recoveryParam")),n.push(hr(e.r)),n.push(hr(e.s))),Jn(["0x01",ei(n)])}(this,n);case 2:return function(t,e){const n=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oa(t.maxFeePerGas||0,"maxFeePerGas"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data,La(t.accessList||[])];return e&&(n.push(Oa(e.yParity,"yParity")),n.push(hr(e.r)),n.push(hr(e.s))),Jn(["0x02",ei(n)])}(this,n);case 3:return function(t,e,n){const r=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oa(t.maxFeePerGas||0,"maxFeePerGas"),Oa(t.gasLimit,"gasLimit"),t.to||Po,Oa(t.value,"value"),t.data,La(t.accessList||[]),Oa(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Fa(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(Oa(e.yParity,"yParity")),r.push(hr(e.r)),r.push(hr(e.s)),n)?Jn(["0x03",ei([r,n.map((t=>t.data)),n.map((t=>t.commitment)),n.map((t=>t.proof))])]):Jn(["0x03",ei(r)])}(this,n,e?this.blobs:null);case 4:return function(t,e){const n=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oa(t.maxFeePerGas||0,"maxFeePerGas"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data,La(t.accessList||[]),(r=t.authorizationList||[],r.map((t=>[Oa(t.chainId,"chainId"),t.address,Oa(t.nonce,"nonce"),Oa(t.signature.yParity,"yParity"),t.signature.r,t.signature.s])))];var r;return e&&(n.push(Oa(e.yParity,"yParity")),n.push(hr(e.r)),n.push(hr(e.s))),Jn(["0x04",ei(n)])}(this,n)}On(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Da=class t{constructor(){__privateAdd(this,St),__privateAdd(this,ct,void 0),__privateAdd(this,ut,void 0),__privateAdd(this,ht,void 0),__privateAdd(this,dt,void 0),__privateAdd(this,pt,void 0),__privateAdd(this,ft,void 0),__privateAdd(this,gt,void 0),__privateAdd(this,mt,void 0),__privateAdd(this,_t,void 0),__privateAdd(this,yt,void 0),__privateAdd(this,wt,void 0),__privateAdd(this,vt,void 0),__privateAdd(this,bt,void 0),__privateAdd(this,At,void 0),__privateAdd(this,Et,void 0),__privateAdd(this,xt,void 0),__privateAdd(this,kt,void 0),__privateSet(this,ct,null),__privateSet(this,ut,null),__privateSet(this,dt,0),__privateSet(this,pt,Ea),__privateSet(this,ft,null),__privateSet(this,gt,null),__privateSet(this,mt,null),__privateSet(this,ht,"0x"),__privateSet(this,_t,Ea),__privateSet(this,yt,Ea),__privateSet(this,wt,null),__privateSet(this,vt,null),__privateSet(this,bt,null),__privateSet(this,At,null),__privateSet(this,Et,null),__privateSet(this,xt,null),__privateSet(this,kt,null)}get type(){return __privateGet(this,ct)}set type(t){switch(t){case null:__privateSet(this,ct,null);break;case 0:case"legacy":__privateSet(this,ct,0);break;case 1:case"berlin":case"eip-2930":__privateSet(this,ct,1);break;case 2:case"london":case"eip-1559":__privateSet(this,ct,2);break;case 3:case"cancun":case"eip-4844":__privateSet(this,ct,3);break;case 4:case"pectra":case"eip-7702":__privateSet(this,ct,4);break;default:Ln(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const t=__privateGet(this,ut);return null==t&&3===this.type?Po:t}set to(t){__privateSet(this,ut,null==t?null:Ko(t))}get nonce(){return __privateGet(this,dt)}set nonce(t){__privateSet(this,dt,cr(t,"value"))}get gasLimit(){return __privateGet(this,pt)}set gasLimit(t){__privateSet(this,pt,sr(t))}get gasPrice(){const t=__privateGet(this,ft);return null!=t||0!==this.type&&1!==this.type?t:Ea}set gasPrice(t){__privateSet(this,ft,null==t?null:sr(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=__privateGet(this,gt);return null==t?2===this.type||3===this.type?Ea:null:t}set maxPriorityFeePerGas(t){__privateSet(this,gt,null==t?null:sr(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=__privateGet(this,mt);return null==t?2===this.type||3===this.type?Ea:null:t}set maxFeePerGas(t){__privateSet(this,mt,null==t?null:sr(t,"maxFeePerGas"))}get data(){return __privateGet(this,ht)}set data(t){__privateSet(this,ht,Kn(t))}get value(){return __privateGet(this,_t)}set value(t){__privateSet(this,_t,sr(t,"value"))}get chainId(){return __privateGet(this,yt)}set chainId(t){__privateSet(this,yt,sr(t))}get signature(){return __privateGet(this,wt)||null}set signature(t){__privateSet(this,wt,null==t?null:Do.from(t))}get accessList(){const t=__privateGet(this,vt)||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){__privateSet(this,vt,null==t?null:va(t))}get authorizationList(){const t=__privateGet(this,kt)||null;return null==t&&4===this.type?[]:t}set authorizationList(t){__privateSet(this,kt,null==t?null:t.map((t=>ba(t))))}get maxFeePerBlobGas(){const t=__privateGet(this,bt);return null==t&&3===this.type?Ea:t}set maxFeePerBlobGas(t){__privateSet(this,bt,null==t?null:sr(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=__privateGet(this,At);return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){Ln(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)Ln(Qn(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}__privateSet(this,At,t)}get blobs(){return null==__privateGet(this,xt)?null:__privateGet(this,xt).map((t=>Object.assign({},t)))}set blobs(t){if(null==t)return void __privateSet(this,xt,null);const e=[],n=[];for(let r=0;r<t.length;r++){const i=t[r];if(zn(i)){On(__privateGet(this,Et),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=Hn(i);if(Ln(t.length<=Pa,"blob is too large",`blobs[${r}]`,i),t.length!==Pa){const e=new Uint8Array(Pa);e.set(t),t=e}const s=__privateGet(this,Et).blobToKzgCommitment(t),o=Kn(__privateGet(this,Et).computeBlobKzgProof(t,s));e.push({data:Kn(t),commitment:Kn(s),proof:o}),n.push(Ta(1,s))}else{const t=Kn(i.commitment);e.push({data:Kn(i.data),commitment:t,proof:Kn(i.proof)}),n.push(Ta(1,t))}}__privateSet(this,xt,e),__privateSet(this,At,n)}get kzg(){return __privateGet(this,Et)}set kzg(t){__privateSet(this,Et,null==t?null:function(t){return{blobToKzgCommitment:e=>{if("computeBlobProof"in t){if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return Hn(t.blobToKzgCommitment(Kn(e)))}else if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return Hn(t.blobToKzgCommitment(e));if("blobToKZGCommitment"in t&&"function"==typeof t.blobToKZGCommitment)return Hn(t.blobToKZGCommitment(Kn(e)));Ln(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(e,n)=>"computeBlobProof"in t&&"function"==typeof t.computeBlobProof?Hn(t.computeBlobProof(Kn(e),Kn(n))):"computeBlobKzgProof"in t&&"function"==typeof t.computeBlobKzgProof?t.computeBlobKzgProof(e,n):"computeBlobKZGProof"in t&&"function"==typeof t.computeBlobKZGProof?Hn(t.computeBlobKZGProof(Kn(e),Kn(n))):void Ln(!1,"unsupported KZG library","kzg",t)}}(t))}get hash(){return null==this.signature?null:vs(__privateMethod(this,St,Nt).call(this,!0,!1))}get unsignedHash(){return vs(this.unsignedSerialized)}get from(){return null==this.signature?null:Aa(this.unsignedHash,this.signature)}get fromPublicKey(){return null==this.signature?null:jo.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return null!=this.signature}get serialized(){return __privateMethod(this,St,Nt).call(this,!0,!0)}get unsignedSerialized(){return __privateMethod(this,St,Nt).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,n=null!=this.accessList,r=null!=__privateGet(this,bt)||__privateGet(this,At);null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&On(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),On(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),On(0!==this.type||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):this.authorizationList&&this.authorizationList.length?i.push(4):e?i.push(2):t?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):(r&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return t.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(null==e)return new t;if("string"==typeof e){const n=Hn(e);if(n[0]>=127)return t.from(function(t){const e=Yr(t);Ln(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const n={type:0,nonce:Ia(e[0],"nonce"),gasPrice:Ga(e[1],"gasPrice"),gasLimit:Ga(e[2],"gasLimit"),to:Ma(e[3]),value:Ga(e[4],"value"),data:Kn(e[5]),chainId:Ea};if(6===e.length)return n;const r=Ga(e[6],"v"),i=Ga(e[7],"r"),s=Ga(e[8],"s");if(i===Ea&&s===Ea)n.chainId=r;else{let t=(r-Na)/xa;t<Ea&&(t=Ea),n.chainId=t,Ln(t!==Ea||r===ka||r===Sa,"non-canonical legacy v","v",e[6]),n.signature=Do.from({r:Xn(e[7],32),s:Xn(e[8],32),v:r})}return n}(n));switch(n[0]){case 1:return t.from(function(t){const e=Yr(Hn(t).slice(1));Ln(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",Kn(t));const n={type:1,chainId:Ga(e[0],"chainId"),nonce:Ia(e[1],"nonce"),gasPrice:Ga(e[2],"gasPrice"),gasLimit:Ga(e[3],"gasLimit"),to:Ma(e[4]),value:Ga(e[5],"value"),data:Kn(e[6]),accessList:Ra(e[7],"accessList")};return 8===e.length||Ua(n,e.slice(8)),n}(n));case 2:return t.from(function(t){const e=Yr(Hn(t).slice(1));Ln(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",Kn(t));const n={type:2,chainId:Ga(e[0],"chainId"),nonce:Ia(e[1],"nonce"),maxPriorityFeePerGas:Ga(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ga(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ga(e[4],"gasLimit"),to:Ma(e[5]),value:Ga(e[6],"value"),data:Kn(e[7]),accessList:Ra(e[8],"accessList")};return 9===e.length||Ua(n,e.slice(9)),n}(n));case 3:return t.from(function(t){let e=Yr(Hn(t).slice(1)),n="3",r=null;if(4===e.length&&Array.isArray(e[0])){n="3 (network format)";const t=e[1],i=e[2],s=e[3];Ln(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),Ln(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),Ln(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),Ln(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),Ln(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let n=0;n<e[1].length;n++)r.push({data:t[n],commitment:i[n],proof:s[n]});e=e[0]}Ln(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${n}`,"data",Kn(t));const i={type:3,chainId:Ga(e[0],"chainId"),nonce:Ia(e[1],"nonce"),maxPriorityFeePerGas:Ga(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ga(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ga(e[4],"gasLimit"),to:Ma(e[5]),value:Ga(e[6],"value"),data:Kn(e[7]),accessList:Ra(e[8],"accessList"),maxFeePerBlobGas:Ga(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(i.blobs=r),Ln(null!=i.to,`invalid address for transaction type: ${n}`,"data",t),Ln(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let s=0;s<i.blobVersionedHashes.length;s++)Ln(Qn(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",t);return 11===e.length||Ua(i,e.slice(11)),i}(n));case 4:return t.from(function(t){const e=Yr(Hn(t).slice(1));Ln(Array.isArray(e)&&(10===e.length||13===e.length),"invalid field count for transaction type: 4","data",Kn(t));const n={type:4,chainId:Ga(e[0],"chainId"),nonce:Ia(e[1],"nonce"),maxPriorityFeePerGas:Ga(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ga(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ga(e[4],"gasLimit"),to:Ma(e[5]),value:Ga(e[6],"value"),data:Kn(e[7]),accessList:Ra(e[8],"accessList"),authorizationList:Ba(e[9],"authorizationList")};return 10===e.length||Ua(n,e.slice(10)),n}(n))}On(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const n=new t;return null!=e.type&&(n.type=e.type),null!=e.to&&(n.to=e.to),null!=e.nonce&&(n.nonce=e.nonce),null!=e.gasLimit&&(n.gasLimit=e.gasLimit),null!=e.gasPrice&&(n.gasPrice=e.gasPrice),null!=e.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=e.maxPriorityFeePerGas),null!=e.maxFeePerGas&&(n.maxFeePerGas=e.maxFeePerGas),null!=e.maxFeePerBlobGas&&(n.maxFeePerBlobGas=e.maxFeePerBlobGas),null!=e.data&&(n.data=e.data),null!=e.value&&(n.value=e.value),null!=e.chainId&&(n.chainId=e.chainId),null!=e.signature&&(n.signature=Do.from(e.signature)),null!=e.accessList&&(n.accessList=e.accessList),null!=e.authorizationList&&(n.authorizationList=e.authorizationList),null!=e.blobVersionedHashes&&(n.blobVersionedHashes=e.blobVersionedHashes),null!=e.kzg&&(n.kzg=e.kzg),null!=e.blobs&&(n.blobs=e.blobs),null!=e.hash&&(Ln(n.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),Ln(n.hash===e.hash,"hash mismatch","tx",e)),null!=e.from&&(Ln(n.isSigned(),"unsigned transaction cannot define '.from'","tx",e),Ln(n.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),n}};function ja(t){return vs(yr(t))}const Ha=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);function Wa(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function n(){return t[e++]<<8|t[e++]}let r=n(),i=1,s=[0,1];for(let v=1;v<r;v++)s.push(i+=n());let o=n(),a=e;e+=o;let l=0,c=0;function u(){return 0==l&&(c=c<<8|t[e++],l=8),c>>--l&1}const h=__pow(2,31),d=h>>>1,p=d>>1,f=h-1;let g=0;for(let v=0;v<31;v++)g=g<<1|u();let m=[],_=0,y=h;for(;;){let t=Math.floor(((g-_+1)*i-1)/y),e=0,n=r;for(;n-e>1;){let r=e+n>>>1;t<s[r]?n=r:e=r}if(0==e)break;m.push(e);let o=_+Math.floor(y*s[e]/i),a=_+Math.floor(y*s[e+1]/i)-1;for(;0==((o^a)&d);)g=g<<1&f|u(),o=o<<1&f,a=a<<1&f|1;for(;o&~a&p;)g=g&d|g<<1&f>>>1|u(),o=o<<1^d,a=(a^d)<<1|d|1;_=o,y=1+a-o}let w=r-4;return m.map((e=>{switch(e-w){case 3:return w+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return w+256+(t[a++]<<8|t[a++]);case 1:return w+t[a++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,n)=>e[t.charCodeAt(0)]=n));let n=t.length,r=new Uint8Array(6*n>>3);for(let i=0,s=0,o=0,a=0;i<n;i++)a=a<<6|e[t.charCodeAt(i)],o+=6,o>=8&&(r[s++]=a>>(o-=8));return r}(t)))}function Qa(t){return 1&t?~t>>1:t>>1}function za(t,e){let n=Array(t);for(let r=0,i=0;r<t;r++)n[r]=i+=Qa(e());return n}function Va(t,e=0){let n=[];for(;;){let r=t(),i=t();if(!i)break;e+=r;for(let t=0;t<i;t++)n.push(e+t);e+=i+1}return n}function Ka(t){return qa((()=>{let e=Va(t);if(e.length)return e}))}function Ja(t){let e=[];for(;;){let n=t();if(0==n)break;e.push(Ya(n,t))}for(;;){let n=t()-1;if(n<0)break;e.push(Xa(n,t))}return e.flat()}function qa(t){let e=[];for(;;){let n=t(e.length);if(!n)break;e.push(n)}return e}function Za(t,e,n){let r=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)za(t,n).forEach(((t,e)=>r[e].push(t)));return r}function Ya(t,e){let n=1+e(),r=e(),i=qa(e);return Za(i.length,1+t,e).flatMap(((t,e)=>{let[s,...o]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*r;return[s+e*n,o.map((t=>t+i))]}))}))}function Xa(t,e){return Za(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function $a(t){return`{${function(t){return t.toString(16).toUpperCase().padStart(2,"0")}(t)}}`}function tl(t){let e=t.length;if(e<4096)return String.fromCodePoint(...t);let n=[];for(let r=0;r<e;)n.push(String.fromCodePoint(...t.slice(r,r+=4096)));return n.join("")}function el(t,e){let n=t.length,r=n-e.length;for(let i=0;0==r&&i<n;i++)r=t[i]-e[i];return r}const nl=44032,rl=4352,il=4449,sl=4519,ol=28,al=588;function ll(t){return t>>24&255}function cl(t){return 16777215&t}let ul,hl,dl,pl;function fl(t){return t>=nl&&t<55204}function gl(t,e){if(t>=rl&&t<4371&&e>=il&&e<4470)return nl+(t-rl)*al+(e-il)*ol;if(fl(t)&&e>sl&&e<4547&&(t-nl)%ol==0)return t+(e-sl);{let n=pl.get(t);return n&&(n=n.get(e),n)?n:-1}}function ml(t){ul||function(){let t=Wa("AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwD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M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/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");ul=new Map(Ka(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),hl=new Set(Va(t)),dl=new Map,pl=new Map;for(let[e,n]of Ja(t)){if(!hl.has(e)&&2==n.length){let[t,r]=n,i=pl.get(t);i||(i=new Map,pl.set(t,i)),i.set(r,e)}dl.set(e,n.reverse())}}();let e=[],n=[],r=!1;function i(t){let n=ul.get(t);n&&(r=!0,t|=n),e.push(t)}for(let s of t)for(;;){if(s<128)e.push(s);else if(fl(s)){let t=s-nl,e=t%al/ol|0,n=t%ol;i(rl+(t/al|0)),i(il+e),n>0&&i(sl+n)}else{let t=dl.get(s);t?n.push(...t):i(s)}if(!n.length)break;s=n.pop()}if(r&&e.length>1){let t=ll(e[0]);for(let n=1;n<e.length;n++){let r=ll(e[n]);if(0==r||t<=r){t=r;continue}let i=n-1;for(;;){let n=e[i+1];if(e[i+1]=e[i],e[i]=n,!i)break;if(t=ll(e[--i]),t<=r)break}t=ll(e[n])}}return e}function _l(t){return ml(t).map(cl)}function yl(t){return function(t){let e=[],n=[],r=-1,i=0;for(let s of t){let t=ll(s),o=cl(s);if(-1==r)0==t?r=o:e.push(o);else if(i>0&&i>=t)0==t?(e.push(r,...n),n.length=0,r=o):n.push(o),i=t;else{let s=gl(r,o);s>=0?r=s:0==i&&0==t?(e.push(r),r=o):(n.push(o),i=t)}}return r>=0&&e.push(r,...n),e}(ml(t))}const wl=".",vl=t=>Array.from(t);function bl(t,e){return t.P.has(e)||t.Q.has(e)}class Al extends Array{get is_emoji(){return!0}}let El,xl,kl,Sl,Nl,Cl,Pl,Tl,Ml,Rl,Bl;function Il(){if(El)return;let t=Wa("AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwA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AUK3vBAbZZrcJpDQ/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 e=()=>Va(t),n=()=>new Set(e()),r=(t,e)=>e.forEach((e=>t.add(e)));El=new Map(Ja(t)),xl=n(),kl=e(),Sl=new Set(e().map((t=>kl[t]))),kl=new Set(kl),Nl=n(),n();let i=Ka(t),s=t();const o=()=>{let t=new Set;return e().forEach((e=>r(t,i[e]))),r(t,e()),t};Cl=qa((e=>{let n=qa(t).map((t=>t+96));if(n.length){let r=e>=s;return n[0]-=32,n=tl(n),r&&(n=`Restricted[${n}]`),{N:n,P:o(),Q:o(),M:!t(),R:r}}})),Pl=n(),Tl=new Map;let a=e().concat(vl(Pl)).sort(((t,e)=>t-e));a.forEach(((e,n)=>{let r=t(),i=a[n]=r?a[n-r]:{V:[],M:new Map};i.V.push(e),Pl.has(e)||Tl.set(e,i)}));for(let{V:u,M:h}of new Set(Tl.values())){let t=[];for(let n of u){let e=Cl.filter((t=>bl(t,n))),i=t.find((({G:t})=>e.some((e=>t.has(e)))));i||(i={G:new Set,V:[]},t.push(i)),i.V.push(n),r(i.G,e)}let e=t.flatMap((t=>vl(t.G)));for(let{G:n,V:r}of t){let t=new Set(e.filter((t=>!n.has(t))));for(let e of r)h.set(e,t)}}Ml=new Set;let l=new Set;const c=t=>Ml.has(t)?l.add(t):Ml.add(t);for(let u of Cl){for(let t of u.P)c(t);for(let t of u.Q)c(t)}for(let u of Ml)Tl.has(u)||l.has(u)||Tl.set(u,1);r(Ml,_l(Ml)),Rl=function(t){let e=[],n=Va(t);return function t({S:n,B:r},i,s){if(!(4&n&&s===i[i.length-1])){2&n&&(s=i[i.length-1]),1&n&&e.push(i);for(let e of r)for(let n of e.Q)t(e,[...i,n],s)}}(function e(r){return{S:t(),B:qa((()=>{let r=Va(t).map((t=>n[t]));if(r.length)return e(r)})),Q:r}}([]),[]),e}(t).map((t=>Al.from(t))).sort(el),Bl=new Map;for(let u of Rl){let t=[Bl];for(let e of u){let n=t.map((t=>{let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}));65039===e?t.push(...n):t=n}for(let e of t)e.V=u}}function Gl(t){return(Fl(t)?"":`${Ol(Ll([t]))} `)+$a(t)}function Ol(t){return`"${t}"`}function Ll(t,e=1/0,n=$a){let r=[];var i;i=t[0],Il(),kl.has(i)&&r.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let s=0,o=t.length;for(let a=0;a<o;a++){let e=t[a];Fl(e)&&(r.push(tl(t.slice(s,a))),r.push(n(e)),s=a+1)}return r.push(tl(t.slice(s,o))),r.join("")}function Fl(t){return Il(),Nl.has(t)}function Ul(t){return e=function(t,e,n){if(!t)return[];Il();let r=0;return t.split(wl).map((t=>{let i=function(t){let e=[];for(let n=0,r=t.length;n<r;){let r=t.codePointAt(n);n+=r<65536?1:2,e.push(r)}return e}(t),s={input:i,offset:r};r+=i.length+1;try{let t,r=s.tokens=function(t,e,n){let r=[],i=[];for(t=t.slice().reverse();t.length;){let s=Ql(t);if(s)i.length&&(r.push(e(i)),i=[]),r.push(n(s));else{let e=t.pop();if(Ml.has(e))i.push(e);else{let t=El.get(e);if(t)i.push(...t);else if(!xl.has(e))throw Dl(e)}}}return i.length&&r.push(e(i)),r}(i,e,n),o=r.length;if(!o)throw new Error("empty label");let a=s.output=r.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(a),!(s.emoji=o>1||r[0].is_emoji)&&a.every((t=>t<128)))!function(t){if(t.length>=4&&45==t[2]&&45==t[3])throw new Error(`invalid label extension: "${tl(t.slice(0,4))}"`)}(a),t="ASCII";else{let e=r.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(kl.has(a[0]))throw Hl("leading combining mark");for(let t=1;t<o;t++){let e=r[t];if(!e.is_emoji&&kl.has(e[0]))throw Hl(`emoji + combining mark: "${tl(r[t-1])} + ${Ll([e[0]])}"`)}!function(t){let e=t[0],n=Ha.get(e);if(n)throw Hl(`leading ${n}`);let r=t.length,i=-1;for(let s=1;s<r;s++){e=t[s];let r=Ha.get(e);if(r){if(i==s)throw Hl(`${n} + ${r}`);i=s+1,n=r}}if(i==r)throw Hl(`trailing ${n}`)}(a);let n=vl(new Set(e)),[i]=function(t){let e=Cl;for(let n of t){let t=e.filter((t=>bl(t,n)));if(!t.length)throw Cl.some((t=>bl(t,n)))?jl(e[0],n):Dl(n);if(e=t,1==t.length)break}return e}(n);!function(t,e){for(let n of e)if(!bl(t,n))throw jl(t,n);if(t.M){let t=_l(e);for(let e=1,n=t.length;e<n;e++)if(Sl.has(t[e])){let r=e+1;for(let i;r<n&&Sl.has(i=t[r]);r++)for(let n=e;n<r;n++)if(t[n]==i)throw new Error(`duplicate non-spacing marks: ${Gl(i)}`);if(r-e>4)throw new Error(`excessive non-spacing marks: ${Ol(Ll(t.slice(e-1,r)))} (${r-e}/4)`);e=r}}}(i,e),function(t,e){let n,r=[];for(let i of e){let t=Tl.get(i);if(1===t)return;if(t){let e=t.M.get(i);if(n=n?n.filter((t=>e.has(t))):vl(e),!n.length)return}else r.push(i)}if(n)for(let i of n)if(r.every((t=>bl(i,t))))throw new Error(`whole-script confusable: ${t.N}/${i.N}`)}(i,n),t=i.N}else t="Emoji"}s.type=t}catch(o){s.error=o}return s}))}(t,yl,Wl),e.map((({input:t,error:n,output:r})=>{if(n){let r=n.message;throw new Error(1==e.length?r:`Invalid label ${Ol(Ll(t,63))}: ${r}`)}return tl(r)})).join(wl);var e}function Dl(t){return new Error(`disallowed character: ${Gl(t)}`)}function jl(t,e){let n=Gl(e),r=Cl.find((t=>t.P.has(e)));return r&&(n=`${r.N} ${n}`),new Error(`illegal mixture: ${t.N} + ${n}`)}function Hl(t){return new Error(`illegal placement: ${t}`)}function Wl(t){return t.filter((t=>65039!=t))}function Ql(t,e){let n,r=Bl,i=t.length;for(;i&&(r=r.get(t[--i]),r);){let{V:s}=r;s&&(n=s,e&&e.push(...t.slice(i).reverse()),t.length=i)}return n}const zl=new Uint8Array(32);function Vl(t){return Ln(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Kl(t){const e=yr(function(t){try{if(0===t.length)throw new Error("empty label");return Ul(t)}catch(e){Ln(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),n=[];if(0===t.length)return n;let r=0;for(let i=0;i<e.length;i++){46===e[i]&&(n.push(Vl(e.slice(r,i))),r=i+1)}return Ln(r<e.length,"invalid ENS name; empty component","name",t),n.push(Vl(e.slice(r))),n}function Jl(t){Ln("string"==typeof t,"invalid ENS name; not a string","name",t),Ln(t.length,"invalid ENS name (empty label)","name",t);let e=zl;const n=Kl(t);for(;n.length;)e=vs(Jn([e,vs(n.pop())]));return Kn(e)}function ql(t,e){const n=null!=e?e:63;return Ln(n<=255,"DNS encoded label cannot exceed 255","length",n),Kn(Jn(Kl(t).map((e=>{Ln(e.length<=n,`label ${JSON.stringify(t)} exceeds ${n} bytes`,"name",t);const r=new Uint8Array(e.length+1);return r.set(e,1),r[0]=r.length-1,r}))))+"00"}zl.fill(0);const Zl=new Uint8Array(32);Zl.fill(0);const Yl=BigInt(-1),Xl=BigInt(0),$l=BigInt(1),tc=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const ec=ur($l,32),nc=ur(Xl,32),rc={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},ic=["name","version","chainId","verifyingContract","salt"];function sc(t){return function(e){return Ln("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const oc={name:sc("name"),version:sc("version"),chainId:function(t){const e=sr(t,"domain.chainId");return Ln(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):dr(e)},verifyingContract:function(t){try{return Ko(t).toLowerCase()}catch(e){}Ln(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=Hn(t,"domain.salt");return Ln(32===e.length,'invalid domain value "salt"',"domain.salt",t),Kn(e)}};function ac(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const n=""===e[1],r=parseInt(e[2]);Ln(r%8==0&&0!==r&&r<=256&&e[2]===String(r),"invalid numeric width","type",t);const i=ir(tc,n?r-1:r),s=n?(i+$l)*Yl:Xl;return function(e){const r=sr(e,"value");return Ln(r>=s&&r<=i,`value out-of-bounds for ${t}`,"value",r),ur(n?rr(r,256):r,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const n=parseInt(e[1]);return Ln(0!==n&&n<=32&&e[1]===String(n),"invalid bytes width","type",t),function(e){return Ln(Hn(e).length===n,`invalid length for ${t}`,"value",e),function(t){const e=Hn(t),n=e.length%32;return n?Jn([e,Zl.slice(n)]):Kn(e)}(e)}}}switch(t){case"address":return function(t){return Xn(Ko(t),32)};case"bool":return function(t){return t?ec:nc};case"bytes":return function(t){return vs(t)};case"string":return function(t){return ja(t)}}return null}function lc(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}function cc(t){const e=t.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:t}}Ct=new WeakMap,Pt=new WeakMap,Tt=new WeakMap,Mt=new WeakSet,Rt=function(t){{const e=ac(t);if(e)return e}const e=cc(t).array;if(e){const t=e.prefix,n=this.getEncoder(t);return r=>{Ln(-1===e.count||e.count===r.length,`array length mismatch; expected length ${e.count}`,"value",r);let i=r.map(n);return __privateGet(this,Pt).has(t)&&(i=i.map(vs)),vs(Jn(i))}}const n=this.types[t];if(n){const e=ja(__privateGet(this,Pt).get(t));return t=>{const r=n.map((({name:e,type:n})=>{const r=this.getEncoder(n)(t[e]);return __privateGet(this,Pt).has(n)?vs(r):r}));return r.unshift(e),Jn(r)}}Ln(!1,`unknown type: ${t}`,"type",t)};let uc=class t{constructor(t){__privateAdd(this,Mt),__publicField(this,"primaryType"),__privateAdd(this,Ct,void 0),__privateAdd(this,Pt,void 0),__privateAdd(this,Tt,void 0),__privateSet(this,Pt,new Map),__privateSet(this,Tt,new Map);const e=new Map,n=new Map,r=new Map,i={};Object.keys(t).forEach((s=>{i[s]=t[s].map((({name:e,type:n})=>{let{base:r,index:i}=cc(n);return"int"!==r||t.int||(r="int256"),"uint"!==r||t.uint||(r="uint256"),{name:e,type:r+(i||"")}})),e.set(s,new Set),n.set(s,[]),r.set(s,new Set)})),__privateSet(this,Ct,JSON.stringify(i));for(const o in i){const r=new Set;for(const s of i[o]){Ln(!r.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(o)}`,"types",t),r.add(s.name);const i=cc(s.type).base;Ln(i!==o,`circular type reference to ${JSON.stringify(i)}`,"types",t);ac(i)||(Ln(n.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),n.get(i).push(o),e.get(o).add(i))}}const s=Array.from(n.keys()).filter((t=>0===n.get(t).length));Ln(0!==s.length,"missing primary type","types",t),Ln(1===s.length,`ambiguous primary types or unused types: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Mn(this,{primaryType:s[0]}),function i(s,o){Ln(!o.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),o.add(s);for(const t of e.get(s))if(n.has(t)){i(t,o);for(const e of o)r.get(e).add(t)}o.delete(s)}(this.primaryType,new Set);for(const[o,a]of r){const t=Array.from(a);t.sort(),__privateGet(this,Pt).set(o,lc(o,i[o])+t.map((t=>lc(t,i[t]))).join(""))}}get types(){return JSON.parse(__privateGet(this,Ct))}getEncoder(t){let e=__privateGet(this,Tt).get(t);return e||(e=__privateMethod(this,Mt,Rt).call(this,t),__privateGet(this,Tt).set(t,e)),e}encodeType(t){const e=__privateGet(this,Pt).get(t);return Ln(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return vs(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,n){if(ac(t))return n(t,e);const r=cc(t).array;if(r)return Ln(-1===r.count||r.count===e.length,`array length mismatch; expected length ${r.count}`,"value",e),e.map((t=>this._visit(r.prefix,t,n)));const i=this.types[t];if(i)return i.reduce(((t,{name:r,type:i})=>(t[r]=this._visit(i,e[r],n),t)),{});Ln(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(e){return new t(e)}static getPrimaryType(e){return t.from(e).primaryType}static hashStruct(e,n,r){return t.from(n).hashStruct(e,r)}static hashDomain(e){const n=[];for(const t in e){if(null==e[t])continue;const r=rc[t];Ln(r,`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",e),n.push({name:t,type:r})}return n.sort(((t,e)=>ic.indexOf(t.name)-ic.indexOf(e.name))),t.hashStruct("EIP712Domain",{EIP712Domain:n},e)}static encode(e,n,r){return Jn(["0x1901",t.hashDomain(e),t.from(n).hash(r)])}static hash(e,n,r){return vs(t.encode(e,n,r))}static resolveNames(e,n,r,i){return __async(this,null,(function*(){e=Object.assign({},e);for(const t in e)null==e[t]&&delete e[t];const s={};e.verifyingContract&&!Qn(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=t.from(n);o.visit(r,((t,e)=>("address"!==t||Qn(e,20)||(s[e]="0x"),e)));for(const t in s)s[t]=yield i(t);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:e,value:r}}))}static getPayload(e,n,r){t.hashDomain(e);const i={},s=[];ic.forEach((t=>{const n=e[t];null!=n&&(i[t]=oc[t](n),s.push({name:t,type:rc[t]}))}));const o=t.from(n);n=o.types;const a=Object.assign({},n);return Ln(null==a.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",n),a.EIP712Domain=s,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return Kn(Hn(e));if(t.match(/^u?int/))return sr(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return Ln("string"==typeof e,"invalid string","value",e),e}Ln(!1,"unsupported type","type",t)}))}}};function hc(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const dc=hc("external public payable override".split(" ")),pc="constant external internal payable private public pure view override",fc=hc(pc.split(" ")),gc="constructor error event fallback function receive struct",mc=hc(gc.split(" ")),_c="calldata memory storage payable indexed",yc=hc(_c.split(" ")),wc=hc([gc,_c,"tuple returns",pc].join(" ").split(" ")),vc={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},bc=new RegExp("^(\\s*)"),Ac=new RegExp("^([0-9]+)"),Ec=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),xc=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),kc=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Sc=class t{constructor(t){__privateAdd(this,Gt),__privateAdd(this,Bt,void 0),__privateAdd(this,It,void 0),__privateSet(this,Bt,0),__privateSet(this,It,t.slice())}get offset(){return __privateGet(this,Bt)}get length(){return __privateGet(this,It).length-__privateGet(this,Bt)}clone(){return new t(__privateGet(this,It))}reset(){__privateSet(this,Bt,0)}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=__privateMethod(this,Gt,Ot).call(this,__privateGet(this,Bt)+1,t.match+1);return __privateSet(this,Bt,t.match+1),e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;__privateGet(this,Bt)<t.match-1;){const t=this.peek().linkNext;e.push(__privateMethod(this,Gt,Ot).call(this,__privateGet(this,Bt)+1,t)),__privateSet(this,Bt,t)}return __privateSet(this,Bt,t.match+1),e}peek(){if(__privateGet(this,Bt)>=__privateGet(this,It).length)throw new Error("out-of-bounds");return __privateGet(this,It)[__privateGet(this,Bt)]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return __privateWrapper(this,Bt)._++,t}toString(){const t=[];for(let e=__privateGet(this,Bt);e<__privateGet(this,It).length;e++){const n=__privateGet(this,It)[e];t.push(`${n.type}:${n.text}`)}return`<TokenString ${t.join(" ")}>`}};Bt=new WeakMap,It=new WeakMap,Gt=new WeakSet,Ot=function(t=0,e=0){return new Sc(__privateGet(this,It).slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))};let Nc=Sc;function Cc(t){const e=[],n=e=>{const n=s<t.length?JSON.stringify(t[s]):"$EOI";throw new Error(`invalid token ${n} at ${s}: ${e}`)};let r=[],i=[],s=0;for(;s<t.length;){let o=t.substring(s),a=o.match(bc);a&&(s+=a[1].length,o=t.substring(s));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(l);let c=vc[o[0]]||"";if(c){if(l.type=c,l.text=o[0],s++,"OPEN_PAREN"===c)r.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===r.length&&n("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1;else if("COMMA"===c)l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1,i.push(e.length-1);else if("OPEN_BRACKET"===c)l.type="BRACKET";else if("CLOSE_BRACKET"===c){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const n=e.pop().text;t=n+t,e[e.length-1].value=cr(n)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(a=o.match(Ec),a){if(l.text=a[1],s+=l.text.length,wc.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(kc)){l.type="TYPE";continue}l.type="ID"}else{if(a=o.match(Ac),!a)throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`);l.text=a[1],l.type="NUMBER",s+=l.text.length}}return new Nc(e.map((t=>Object.freeze(t))))}function Pc(t,e){let n=[];for(const r in e.keys())t.has(r)&&n.push(r);if(n.length>1)throw new Error(`conflicting types: ${n.join(", ")}`)}function Tc(t,e){if(e.peekKeyword(mc)){const n=e.pop().text;if(n!==t)throw new Error(`expected ${t}, got ${n}`)}return e.popType("ID")}function Mc(t,e){const n=new Set;for(;;){const r=t.peekType("KEYWORD");if(null==r||e&&!e.has(r))break;if(t.pop(),n.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}function Rc(t){let e=Mc(t,fc);return Pc(e,hc("constant payable nonpayable".split(" "))),Pc(e,hc("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 Bc(t,e){return t.popParams().map((t=>Kc.from(t,e)))}function Ic(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return sr(t.pop().text);throw new Error("invalid gas")}return null}function Gc(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const Oc=new RegExp(/^(.*)\[([0-9]*)\]$/);function Lc(t){const e=t.match(kc);if(Ln(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const n=parseInt(e[2]);Ln(0!==n&&n<=32,"invalid bytes length","type",t)}else if(e[3]){const n=parseInt(e[3]);Ln(0!==n&&n<=256&&n%8==0,"invalid numeric width","type",t)}return t}const Fc={},Uc=Symbol.for("_ethers_internal"),Dc="_ParamTypeInternal",jc="_ErrorInternal",Hc="_EventInternal",Wc="_ConstructorInternal",Qc="_FallbackInternal",zc="_FunctionInternal",Vc="_StructInternal";Lt=new WeakSet,Ft=function(t,e,n,r){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const i=this.arrayChildren,s=e.slice();return s.forEach(((e,r)=>{var o;__privateMethod(o=i,Lt,Ft).call(o,t,e,n,(t=>{s[r]=t}))})),void r(s)}if(this.isTuple()){const i=this.components;let s;if(Array.isArray(e))s=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");s=i.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(s.length!==this.components.length)throw new Error("array is wrong length");return s.forEach(((e,r)=>{var o;__privateMethod(o=i[r],Lt,Ft).call(o,t,e,n,(t=>{s[r]=t}))})),void r(s)}const i=n(this.type,e);i.then?t.push(function(){return __async(this,null,(function*(){r(yield i)}))}()):r(i)};let Kc=class t{constructor(t,e,n,r,i,s,o,a){if(__privateAdd(this,Lt),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),Dn(t,Fc,"ParamType"),Object.defineProperty(this,Uc,{value:Dc}),s&&(s=Object.freeze(s.slice())),"array"===r){if(null==o||null==a)throw new Error("")}else if(null!=o||null!=a)throw new Error("");if("tuple"===r){if(null==s)throw new Error("")}else if(null!=s)throw new Error("");Mn(this,{name:e,type:n,baseType:r,indexed:i,components:s,arrayLength:o,arrayChildren:a})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const n={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(n)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map((t=>n.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map(((t,r)=>n.components[r].walk(t,e)))}return e(this.type,t)}walkAsync(t,e){return __async(this,null,(function*(){const n=[],r=[t];return __privateMethod(this,Lt,Ft).call(this,n,t,e,(t=>{r[0]=t})),n.length&&(yield Promise.all(n)),r[0]}))}static from(e,n){if(t.isParamType(e))return e;if("string"==typeof e)try{return t.from(Cc(e),n)}catch(a){Ln(!1,"invalid param type","obj",e)}else if(e instanceof Nc){let r="",i="",s=null;Mc(e,hc(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(i="tuple",s=e.popParams().map((e=>t.from(e))),r=`tuple(${s.map((t=>t.format())).join(",")})`):(r=Lc(e.popType("TYPE")),i=r);let o=null,a=null;for(;e.length&&e.peekType("BRACKET");){const n=e.pop();o=new t(Fc,"",r,i,null,s,a,o),a=n.value,r+=n.text,i="array",s=null}let l=null;if(Mc(e,yc).has("indexed")){if(!n)throw new Error("");l=!0}const c=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new t(Fc,c,r,i,l,s,a,o)}const r=e.name;Ln(!r||"string"==typeof r&&r.match(xc),"invalid name","obj.name",r);let i=e.indexed;null!=i&&(Ln(n,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,o=s.match(Oc);if(o){const n=parseInt(o[2]||"-1"),a=t.from({type:o[1],components:e.components});return new t(Fc,r||"",s,"array",i,null,n,a)}if("tuple"===s||s.startsWith("tuple(")||s.startsWith("(")){const n=null!=e.components?e.components.map((e=>t.from(e))):null;return new t(Fc,r||"",s,"tuple",i,n,null,null)}return s=Lc(e.type),new t(Fc,r||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Uc]===Dc}};class Jc{constructor(t,e,n){__publicField(this,"type"),__publicField(this,"inputs"),Dn(t,Fc,"Fragment"),Mn(this,{type:e,inputs:n=Object.freeze(n.slice())})}static from(t){if("string"==typeof t){try{Jc.from(JSON.parse(t))}catch(e){}return Jc.from(Cc(t))}if(t instanceof Nc){switch(t.peekKeyword(mc)){case"constructor":return $c.from(t);case"error":return Yc.from(t);case"event":return Xc.from(t);case"fallback":case"receive":return tu.from(t);case"function":return eu.from(t);case"struct":return nu.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return $c.from(t);case"error":return Yc.from(t);case"event":return Xc.from(t);case"fallback":case"receive":return tu.from(t);case"function":return eu.from(t);case"struct":return nu.from(t)}On(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}Ln(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return $c.isFragment(t)}static isError(t){return Yc.isFragment(t)}static isEvent(t){return Xc.isFragment(t)}static isFunction(t){return eu.isFragment(t)}static isStruct(t){return nu.isFragment(t)}}class qc extends Jc{constructor(t,e,n,r){super(t,e,r),__publicField(this,"name"),Ln("string"==typeof n&&n.match(xc),"invalid identifier","name",n),r=Object.freeze(r.slice()),Mn(this,{name:n})}}function Zc(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class Yc extends qc{constructor(t,e,n){super(t,"error",e,n),Object.defineProperty(this,Uc,{value:jc})}get selector(){return ja(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("error"),e.push(this.name+Zc(t,this.inputs)),e.join(" ")}static from(t){if(Yc.isFragment(t))return t;if("string"==typeof t)return Yc.from(Cc(t));if(t instanceof Nc){const e=Tc("error",t),n=Bc(t);return Gc(t),new Yc(Fc,e,n)}return new Yc(Fc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Uc]===jc}}class Xc extends qc{constructor(t,e,n,r){super(t,"event",e,n),__publicField(this,"anonymous"),Object.defineProperty(this,Uc,{value:Hc}),Mn(this,{anonymous:r})}get topicHash(){return ja(this.format("sighash"))}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("event"),e.push(this.name+Zc(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){e=(e||[]).map((t=>Kc.from(t)));return new Xc(Fc,t,e,!1).topicHash}static from(t){if(Xc.isFragment(t))return t;if("string"==typeof t)try{return Xc.from(Cc(t))}catch(e){Ln(!1,"invalid event fragment","obj",t)}else if(t instanceof Nc){const e=Tc("event",t),n=Bc(t,!0),r=!!Mc(t,hc(["anonymous"])).has("anonymous");return Gc(t),new Xc(Fc,e,n,r)}return new Xc(Fc,t.name,t.inputs?t.inputs.map((t=>Kc.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Uc]===Hc}}class $c extends Jc{constructor(t,e,n,r,i){super(t,e,n),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:Wc}),Mn(this,{payable:r,gas:i})}format(t){if(On(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${Zc(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if($c.isFragment(t))return t;if("string"==typeof t)try{return $c.from(Cc(t))}catch(e){Ln(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Nc){Mc(t,hc(["constructor"]));const e=Bc(t),n=!!Mc(t,dc).has("payable"),r=Ic(t);return Gc(t),new $c(Fc,"constructor",e,n,r)}return new $c(Fc,"constructor",t.inputs?t.inputs.map(Kc.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===Wc}}class tu extends Jc{constructor(t,e,n){super(t,"fallback",e),__publicField(this,"payable"),Object.defineProperty(this,Uc,{value:Qc}),Mn(this,{payable:n})}format(t){const e=0===this.inputs.length?"receive":"fallback";if("json"===t){const t=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:t})}return`${e}()${this.payable?" payable":""}`}static from(t){if(tu.isFragment(t))return t;if("string"==typeof t)try{return tu.from(Cc(t))}catch(e){Ln(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Nc){const e=t.toString();Ln(t.peekKeyword(hc(["fallback","receive"])),"type must be fallback or receive","obj",e);if("receive"===t.popKeyword(hc(["fallback","receive"]))){const e=Bc(t);return Ln(0===e.length,"receive cannot have arguments","obj.inputs",e),Mc(t,hc(["payable"])),Gc(t),new tu(Fc,[],!0)}let n=Bc(t);n.length?Ln(1===n.length&&"bytes"===n[0].type,"invalid fallback inputs","obj.inputs",n.map((t=>t.format("minimal"))).join(", ")):n=[Kc.from("bytes")];const r=Rc(t);if(Ln("nonpayable"===r||"payable"===r,"fallback cannot be constants","obj.stateMutability",r),Mc(t,hc(["returns"])).has("returns")){const e=Bc(t);Ln(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Gc(t),new tu(Fc,n,"payable"===r)}if("receive"===t.type)return new tu(Fc,[],!0);if("fallback"===t.type){const e=[Kc.from("bytes")],n="payable"===t.stateMutability;return new tu(Fc,e,n)}Ln(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Uc]===Qc}}class eu extends qc{constructor(t,e,n,r,i,s){super(t,"function",e,r),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:zc});Mn(this,{constant:"view"===n||"pure"===n,gas:s,outputs:i=Object.freeze(i.slice()),payable:"payable"===n,stateMutability:n})}get selector(){return ja(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("function"),e.push(this.name+Zc(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(Zc(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){e=(e||[]).map((t=>Kc.from(t)));return new eu(Fc,t,"view",e,[],null).selector}static from(t){if(eu.isFragment(t))return t;if("string"==typeof t)try{return eu.from(Cc(t))}catch(n){Ln(!1,"invalid function fragment","obj",t)}else if(t instanceof Nc){const e=Tc("function",t),n=Bc(t),r=Rc(t);let i=[];Mc(t,hc(["returns"])).has("returns")&&(i=Bc(t));const s=Ic(t);return Gc(t),new eu(Fc,e,r,n,i,s)}let e=t.stateMutability;return null==e&&(e="payable","boolean"==typeof t.constant?(e="view",t.constant||(e="payable","boolean"!=typeof t.payable||t.payable||(e="nonpayable"))):"boolean"!=typeof t.payable||t.payable||(e="nonpayable")),new eu(Fc,t.name,e,t.inputs?t.inputs.map(Kc.from):[],t.outputs?t.outputs.map(Kc.from):[],null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===zc}}class nu extends qc{constructor(t,e,n){super(t,"struct",e,n),Object.defineProperty(this,Uc,{value:Vc})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return nu.from(Cc(t))}catch(e){Ln(!1,"invalid struct fragment","obj",t)}else if(t instanceof Nc){const e=Tc("struct",t),n=Bc(t);return Gc(t),new nu(Fc,e,n)}return new nu(Fc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Uc]===Vc}}const ru=new Map;ru.set(0,"GENERIC_PANIC"),ru.set(1,"ASSERT_FALSE"),ru.set(17,"OVERFLOW"),ru.set(18,"DIVIDE_BY_ZERO"),ru.set(33,"ENUM_RANGE_ERROR"),ru.set(34,"BAD_STORAGE_DATA"),ru.set(49,"STACK_UNDERFLOW"),ru.set(50,"ARRAY_RANGE_ERROR"),ru.set(65,"OUT_OF_MEMORY"),ru.set(81,"UNINITIALIZED_FUNCTION_CALL");const iu=new RegExp(/^bytes([0-9]*)$/),su=new RegExp(/^(u?int)([0-9]*)$/);let ou=null,au=1024;Ut=new WeakSet,Dt=function(t){if(t.isArray())return new oa(__privateMethod(this,Ut,Dt).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new ya(t.components.map((t=>__privateMethod(this,Ut,Dt).call(this,t))),t.name);switch(t.baseType){case"address":return new na(t.name);case"bool":return new aa(t.name);case"string":return new _a(t.name);case"bytes":return new ca(t.name);case"":return new da(t.name)}let e=t.type.match(su);if(e){let n=parseInt(e[2]||"256");return Ln(0!==n&&n<=256&&n%8==0,"invalid "+e[1]+" bit length","param",t),new ma(n/8,"int"===e[1],t.name)}if(e=t.type.match(iu),e){let n=parseInt(e[1]);return Ln(0!==n&&n<=32,"invalid bytes length","param",t),new ua(n,t.name)}Ln(!1,"invalid type","type",t.type)};let lu=class t{constructor(){__privateAdd(this,Ut)}getDefaultValue(t){const e=t.map((t=>__privateMethod(this,Ut,Dt).call(this,Kc.from(t))));return new ya(e,"_").defaultValue()}encode(t,e){Fn(e.length,t.length,"types/values length mismatch");const n=t.map((t=>__privateMethod(this,Ut,Dt).call(this,Kc.from(t)))),r=new ya(n,"_"),i=new _i;return r.encode(i,e),i.data}decode(t,e,n){const r=t.map((t=>__privateMethod(this,Ut,Dt).call(this,Kc.from(t))));return new ya(r,"_").decode(new yi(e,n,au))}static _setDefaultMaxInflation(t){Ln("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),au=t}static defaultAbiCoder(){return null==ou&&(ou=new t),ou}static getBuiltinCallException(e,n,r){return function(t,e,n,r){let i="missing revert data",s=null,o=null;if(n){i="execution reverted";const t=Hn(n);if(n=Kn(n),0===t.length)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(t.length%32!=4)i+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===Kn(t.slice(0,4)))try{s=r.decode(["string"],t.slice(4))[0],o={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch(l){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===Kn(t.slice(0,4)))try{const e=Number(r.decode(["uint256"],t.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[e]},s=`Panic due to ${ru.get(e)||"UNKNOWN"}(${e})`,i+=`: ${s}`}catch(l){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const a={to:e.to?Ko(e.to):null,data:e.data||"0x"};return e.from&&(a.from=Ko(e.from)),Gn(i,"CALL_EXCEPTION",{action:t,data:n,reason:s,transaction:a,invocation:null,revert:o})}(e,n,r,t.defaultAbiCoder())}};class cu{constructor(t,e,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const r=t.name,i=t.format();Mn(this,{fragment:t,name:r,signature:i,topic:e,args:n})}}class uu{constructor(t,e,n,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector"),__publicField(this,"value");const i=t.name,s=t.format();Mn(this,{fragment:t,name:i,args:n,signature:s,selector:e,value:r})}}class hu{constructor(t,e,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const r=t.name,i=t.format();Mn(this,{fragment:t,name:r,args:n,signature:i,selector:e})}}class du{constructor(t){__publicField(this,"hash"),__publicField(this,"_isIndexed"),Mn(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!(!t||!t._isIndexed)}}const pu={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"},fu={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:t=>`reverted with reason string ${JSON.stringify(t)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:t=>{let e="unknown panic code";return t>=0&&t<=255&&pu[t.toString()]&&(e=pu[t.toString()]),`reverted with panic code 0x${t.toString(16)} (${e})`}}};jt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,Qt=new WeakMap,zt=new WeakSet,Vt=function(t,e,n){if(Qn(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Wt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const r=[];for(const[e,n]of __privateGet(this,Wt))e.split("(")[0]===t&&r.push(n);if(e){const t=e.length>0?e[e.length-1]:null;let n=e.length,i=!0;ea.isTyped(t)&&"overrides"===t.type&&(i=!1,n--);for(let e=r.length-1;e>=0;e--){const t=r[e].inputs.length;t===n||i&&t===n-1||r.splice(e,1)}for(let s=r.length-1;s>=0;s--){const t=r[s].inputs;for(let n=0;n<e.length;n++)if(ea.isTyped(e[n])){if(n>=t.length){if("overrides"===e[n].type)continue;r.splice(s,1);break}if(e[n].type!==t[n].baseType){r.splice(s,1);break}}}}if(1===r.length&&e&&e.length!==r[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&r.splice(0,1)}if(0===r.length)return null;if(r.length>1&&n){Ln(!1,`ambiguous function description (i.e. matches ${r.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return r[0]}const r=__privateGet(this,Wt).get(eu.from(t).format());return r||null},Kt=new WeakSet,Jt=function(t,e,n){if(Qn(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Ht).values())if(e===t.topicHash)return t;return null}if(-1===t.indexOf("(")){const r=[];for(const[e,n]of __privateGet(this,Ht))e.split("(")[0]===t&&r.push(n);if(e){for(let t=r.length-1;t>=0;t--)r[t].inputs.length<e.length&&r.splice(t,1);for(let t=r.length-1;t>=0;t--){const n=r[t].inputs;for(let i=0;i<e.length;i++)if(ea.isTyped(e[i])&&e[i].type!==n[i].baseType){r.splice(t,1);break}}}if(0===r.length)return null;if(r.length>1&&n){Ln(!1,`ambiguous event description (i.e. matches ${r.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return r[0]}const r=__privateGet(this,Ht).get(Xc.from(t).format());return r||null};let gu=class t{constructor(t){__privateAdd(this,zt),__privateAdd(this,Kt),__publicField(this,"fragments"),__publicField(this,"deploy"),__publicField(this,"fallback"),__publicField(this,"receive"),__privateAdd(this,jt,void 0),__privateAdd(this,Ht,void 0),__privateAdd(this,Wt,void 0),__privateAdd(this,Qt,void 0);let e=[];e="string"==typeof t?JSON.parse(t):t,__privateSet(this,Wt,new Map),__privateSet(this,jt,new Map),__privateSet(this,Ht,new Map);const n=[];for(const o of e)try{n.push(Jc.from(o))}catch(s){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,s.message)}Mn(this,{fragments:Object.freeze(n)});let r=null,i=!1;__privateSet(this,Qt,this.getAbiCoder()),this.fragments.forEach(((t,e)=>{let n;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void Mn(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(Ln(!r||t.payable!==r.payable,"conflicting fallback fragments",`fragments[${e}]`,t),r=t,i=r.payable));case"function":n=__privateGet(this,Wt);break;case"event":n=__privateGet(this,Ht);break;case"error":n=__privateGet(this,jt);break;default:return}const s=t.format();n.has(s)||n.set(s,t)})),this.deploy||Mn(this,{deploy:$c.from("constructor()")}),Mn(this,{fallback:r,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map((t=>t.format(e)))}formatJson(){const t=this.fragments.map((t=>t.format("json")));return JSON.stringify(t.map((t=>JSON.parse(t))))}getAbiCoder(){return lu.defaultAbiCoder()}getFunctionName(t){const e=__privateMethod(this,zt,Vt).call(this,t,null,!1);return Ln(e,"no matching function","key",t),e.name}hasFunction(t){return!!__privateMethod(this,zt,Vt).call(this,t,null,!1)}getFunction(t,e){return __privateMethod(this,zt,Vt).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(__privateGet(this,Wt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let n=0;n<e.length;n++){const r=e[n];t(__privateGet(this,Wt).get(r),n)}}getEventName(t){const e=__privateMethod(this,Kt,Jt).call(this,t,null,!1);return Ln(e,"no matching event","key",t),e.name}hasEvent(t){return!!__privateMethod(this,Kt,Jt).call(this,t,null,!1)}getEvent(t,e){return __privateMethod(this,Kt,Jt).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(__privateGet(this,Ht).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let n=0;n<e.length;n++){const r=e[n];t(__privateGet(this,Ht).get(r),n)}}getError(t,e){if(Qn(t)){const e=t.toLowerCase();if(fu[e])return Yc.from(fu[e].signature);for(const t of __privateGet(this,jt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[n,r]of __privateGet(this,jt))n.split("(")[0]===t&&e.push(r);if(0===e.length)return"Error"===t?Yc.from("error Error(string)"):"Panic"===t?Yc.from("error Panic(uint256)"):null;if(e.length>1){Ln(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t)}return e[0]}if("Error(string)"===(t=Yc.from(t).format()))return Yc.from("error Error(string)");if("Panic(uint256)"===t)return Yc.from("error Panic(uint256)");const n=__privateGet(this,jt).get(t);return n||null}forEachError(t){const e=Array.from(__privateGet(this,jt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let n=0;n<e.length;n++){const r=e[n];t(__privateGet(this,jt).get(r),n)}}_decodeParams(t,e){return __privateGet(this,Qt).decode(t,e)}_encodeParams(t,e){return __privateGet(this,Qt).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Ln(e,"unknown error","fragment",t),t=e}return Ln(Zn(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,Zn(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Ln(e,"unknown error","fragment",t),t=e}return Jn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}return Ln(Zn(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,Zn(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}return Jn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}let n="invalid length for result data";const r=Wn(e);if(r.length%32==0)try{return __privateGet(this,Qt).decode(t.outputs,r)}catch(i){n="could not decode result data"}On(!1,n,"BAD_DATA",{value:Kn(r),info:{method:t.name,signature:t.format()}})}makeError(t,e){const n=Hn(t,"data"),r=lu.getBuiltinCallException("call",e,n);if(r.message.startsWith("execution reverted (unknown custom error)")){const t=Kn(n.slice(0,4)),e=this.getError(t);if(e)try{const t=__privateGet(this,Qt).decode(e.inputs,n.slice(4));r.revert={name:e.name,signature:e.format(),args:t},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch(s){r.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(r.invocation={method:i.name,signature:i.signature,args:i.args}),r}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}return Kn(__privateGet(this,Qt).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);Ln(e,"unknown event","eventFragment",t),t=e}On(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const n=[];t.anonymous||n.push(t.topicHash);const r=(t,e)=>"string"===t.type?ja(e):"bytes"===t.type?vs(Kn(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=ur(e):t.type.match(/^bytes/)?e=Yn(e,32,!1):"address"===t.type&&__privateGet(this,Qt).encode(["address"],[e]),Xn(Kn(e),32));for(e.forEach(((e,i)=>{const s=t.inputs[i];s.indexed?null==e?n.push(null):"array"===s.baseType||"tuple"===s.baseType?Ln(!1,"filtering with tuples or arrays not supported","contract."+s.name,e):Array.isArray(e)?n.push(e.map((t=>r(s,t)))):n.push(r(s,e)):Ln(null==e,"cannot filter non-indexed parameters; must be null","contract."+s.name,e)}));n.length&&null===n[n.length-1];)n.pop();return n}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);Ln(e,"unknown event","eventFragment",t),t=e}const n=[],r=[],i=[];return t.anonymous||n.push(t.topicHash),Ln(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,s)=>{const o=e[s];if(t.indexed)if("string"===t.type)n.push(ja(o));else if("bytes"===t.type)n.push(vs(o));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");n.push(__privateGet(this,Qt).encode([t.type],[o]))}else r.push(t),i.push(o)})),{data:__privateGet(this,Qt).encode(r,i),topics:n}}decodeEventLog(t,e,n){if("string"==typeof t){const e=this.getEvent(t);Ln(e,"unknown event","eventFragment",t),t=e}if(null!=n&&!t.anonymous){const e=t.topicHash;Ln(Qn(n[0],32)&&n[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const r=[],i=[],s=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(r.push(Kc.from({type:"bytes32",name:t.name})),s.push(!0)):(r.push(t),s.push(!1)):(i.push(t),s.push(!1))}));const o=null!=n?__privateGet(this,Qt).decode(r,Jn(n)):null,a=__privateGet(this,Qt).decode(i,e,!0),l=[],c=[];let u=0,h=0;return t.inputs.forEach(((t,e)=>{let n=null;if(t.indexed)if(null==o)n=new du(null);else if(s[e])n=new du(o[h++]);else try{n=o[h++]}catch(r){n=r}else try{n=a[u++]}catch(r){n=r}l.push(n),c.push(t.name||null)})),fi.fromItems(l,c)}parseTransaction(t){const e=Hn(t.data,"tx.data"),n=sr(null!=t.value?t.value:0,"tx.value"),r=this.getFunction(Kn(e.slice(0,4)));if(!r)return null;const i=__privateGet(this,Qt).decode(r.inputs,e.slice(4));return new uu(r,r.selector,i,n)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new cu(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=Kn(t),n=this.getError(Zn(e,0,4));if(!n)return null;const r=__privateGet(this,Qt).decode(n.inputs,Zn(e,4));return new hu(n,n.selector,r)}static from(e){return e instanceof t?e:"string"==typeof e?new t(JSON.parse(e)):"function"==typeof e.formatJson?new t(e.formatJson()):"function"==typeof e.format?new t(e.format("json")):new t(e)}};const mu=BigInt(0);function _u(t){return null==t?null:t}function yu(t){return null==t?null:t.toString()}class wu{constructor(t,e,n){__publicField(this,"gasPrice"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxPriorityFeePerGas"),Mn(this,{gasPrice:_u(t),maxFeePerGas:_u(e),maxPriorityFeePerGas:_u(n)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:yu(t),maxFeePerGas:yu(e),maxPriorityFeePerGas:yu(n)}}}function vu(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=Kn(t.data));const n="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of n)i in t&&null!=t[i]&&(e[i]=sr(t[i],`request.${i}`));const r="type,nonce".split(/,/);for(const i of r)i in t&&null!=t[i]&&(e[i]=cr(t[i],`request.${i}`));return t.accessList&&(e.accessList=va(t.accessList)),t.authorizationList&&(e.authorizationList=t.authorizationList.slice()),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map((t=>zn(t)?Kn(t):Object.assign({},t)))),e}class bu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"number"),__publicField(this,"hash"),__publicField(this,"timestamp"),__publicField(this,"parentHash"),__publicField(this,"parentBeaconBlockRoot"),__publicField(this,"nonce"),__publicField(this,"difficulty"),__publicField(this,"gasLimit"),__publicField(this,"gasUsed"),__publicField(this,"stateRoot"),__publicField(this,"receiptsRoot"),__publicField(this,"blobGasUsed"),__publicField(this,"excessBlobGas"),__publicField(this,"miner"),__publicField(this,"prevRandao"),__publicField(this,"extraData"),__publicField(this,"baseFeePerGas"),__privateAdd(this,qt,void 0),__privateSet(this,qt,t.transactions.map((t=>"string"!=typeof t?new xu(t,e):t))),Mn(this,{provider:e,hash:_u(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:_u(t.prevRandao),extraData:t.extraData,baseFeePerGas:_u(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return __privateGet(this,qt).map((t=>"string"==typeof t?t:t.hash))}get prefetchedTransactions(){const t=__privateGet(this,qt).slice();return 0===t.length?[]:(On("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:n,gasLimit:r,gasUsed:i,hash:s,miner:o,prevRandao:a,nonce:l,number:c,parentHash:u,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,timestamp:f,transactions:g}=this;return{_type:"Block",baseFeePerGas:yu(t),difficulty:yu(e),extraData:n,gasLimit:yu(r),gasUsed:yu(i),blobGasUsed:yu(this.blobGasUsed),excessBlobGas:yu(this.excessBlobGas),hash:s,miner:o,prevRandao:a,nonce:l,number:c,parentHash:u,timestamp:f,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,transactions:g}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return __privateGet(this,qt).length}get date(){return null==this.timestamp?null:new Date(1e3*this.timestamp)}getTransaction(t){return __async(this,null,(function*(){let e;if("number"==typeof t)e=__privateGet(this,qt)[t];else{const n=t.toLowerCase();for(const t of __privateGet(this,qt)){if("string"==typeof t){if(t!==n)continue;e=t;break}if(t.hash===n){e=t;break}}}if(null==e)throw new Error("no such tx");return"string"==typeof e?yield this.provider.getTransaction(e):e}))}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if("number"==typeof t)return e[t];t=t.toLowerCase();for(const n of e)if(n.hash===t)return n;Ln(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return{orphan:"drop-block",hash:(t=this).hash,number:t.number};var t}}qt=new WeakMap;class Au{constructor(t,e){__publicField(this,"provider"),__publicField(this,"transactionHash"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"removed"),__publicField(this,"address"),__publicField(this,"data"),__publicField(this,"topics"),__publicField(this,"index"),__publicField(this,"transactionIndex"),this.provider=e;const n=Object.freeze(t.topics.slice());Mn(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:n,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:s,topics:o,transactionHash:a,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:s,topics:o,transactionHash:a,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);return On(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.transactionHash);return On(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransactionReceipt(){return __async(this,null,(function*(){const t=yield this.provider.getTransactionReceipt(this.transactionHash);return On(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}))}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class Eu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"contractAddress"),__publicField(this,"hash"),__publicField(this,"index"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"logsBloom"),__publicField(this,"gasUsed"),__publicField(this,"blobGasUsed"),__publicField(this,"cumulativeGasUsed"),__publicField(this,"gasPrice"),__publicField(this,"blobGasPrice"),__publicField(this,"type"),__publicField(this,"status"),__publicField(this,"root"),__privateAdd(this,Zt,void 0),__privateSet(this,Zt,Object.freeze(t.logs.map((t=>new Au(t,e)))));let n=mu;null!=t.effectiveGasPrice?n=t.effectiveGasPrice:null!=t.gasPrice&&(n=t.gasPrice),Mn(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:n,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return __privateGet(this,Zt)}toJSON(){const{to:t,from:e,contractAddress:n,hash:r,index:i,blockHash:s,blockNumber:o,logsBloom:a,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:s,blockNumber:o,contractAddress:n,cumulativeGasUsed:yu(this.cumulativeGasUsed),from:e,gasPrice:yu(this.gasPrice),blobGasUsed:yu(this.blobGasUsed),blobGasPrice:yu(this.blobGasPrice),gasUsed:yu(this.gasUsed),hash:r,index:i,logs:l,logsBloom:a,root:u,status:c,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);if(null==t)throw new Error("TODO");return t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.hash);if(null==t)throw new Error("TODO");return t}))}getResult(){return __async(this,null,(function*(){return yield this.provider.getTransactionResult(this.hash)}))}confirmations(){return __async(this,null,(function*(){return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}removedEvent(){return Su(this)}reorderedEvent(t){return On(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ku(this,t)}}Zt=new WeakMap;Yt=new WeakMap;let xu=class t{constructor(t,e){__publicField(this,"provider"),__publicField(this,"blockNumber"),__publicField(this,"blockHash"),__publicField(this,"index"),__publicField(this,"hash"),__publicField(this,"type"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"nonce"),__publicField(this,"gasLimit"),__publicField(this,"gasPrice"),__publicField(this,"maxPriorityFeePerGas"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxFeePerBlobGas"),__publicField(this,"data"),__publicField(this,"value"),__publicField(this,"chainId"),__publicField(this,"signature"),__publicField(this,"accessList"),__publicField(this,"blobVersionedHashes"),__publicField(this,"authorizationList"),__privateAdd(this,Yt,void 0),this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.authorizationList=null!=t.authorizationList?t.authorizationList:null,__privateSet(this,Yt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:n,hash:r,type:i,to:s,from:o,nonce:a,data:l,signature:c,accessList:u,blobVersionedHashes:h}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:t,blockHash:e,blobVersionedHashes:h,chainId:yu(this.chainId),data:l,from:o,gasLimit:yu(this.gasLimit),gasPrice:yu(this.gasPrice),hash:r,maxFeePerGas:yu(this.maxFeePerGas),maxPriorityFeePerGas:yu(this.maxPriorityFeePerGas),maxFeePerBlobGas:yu(this.maxFeePerBlobGas),nonce:a,signature:c,to:s,index:n,type:i,value:yu(this.value)}}getBlock(){return __async(this,null,(function*(){let t=this.blockNumber;if(null==t){const e=yield this.getTransaction();e&&(t=e.blockNumber)}if(null==t)return null;const e=this.provider.getBlock(t);if(null==e)throw new Error("TODO");return e}))}getTransaction(){return __async(this,null,(function*(){return this.provider.getTransaction(this.hash)}))}confirmations(){return __async(this,null,(function*(){if(null==this.blockNumber){const{tx:t,blockNumber:e}=yield Tn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==t||null==t.blockNumber?0:e-t.blockNumber+1}return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}wait(t,e){return __async(this,null,(function*(){const n=null==t?1:t,r=null==e?0:e;let i=__privateGet(this,Yt),s=-1,o=-1===i;const a=()=>__async(this,null,(function*(){if(o)return null;const{blockNumber:t,nonce:e}=yield Tn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(o)return null;const r=yield this.getTransaction();if(!r||null==r.blockNumber)for(-1===s&&(s=i-3,s<__privateGet(this,Yt)&&(s=__privateGet(this,Yt)));s<=t;){if(o)return null;const e=yield this.provider.getBlock(s,!0);if(null==e)return;for(const t of e)if(t===this.hash)return;for(let r=0;r<e.length;r++){const s=yield e.getTransaction(r);if(s.from===this.from&&s.nonce===this.nonce){if(o)return null;const e=yield this.provider.getTransactionReceipt(s.hash);if(null==e)return;if(t-e.blockNumber+1<n)return;let r="replaced";s.data===this.data&&s.to===this.to&&s.value===this.value?r="repriced":"0x"===s.data&&s.from===s.to&&s.value===mu&&(r="cancelled"),On(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===r||"cancelled"===r,reason:r,replacement:s.replaceableTransaction(i),hash:s.hash,receipt:e})}}s++}})),l=t=>{if(null==t||0!==t.status)return t;On(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:t.to,from:t.from,data:""},receipt:t})},c=yield this.provider.getTransactionReceipt(this.hash);if(0===n)return l(c);if(c){if(1===n||(yield c.confirmations())>=n)return l(c)}else if(yield a(),0===n)return null;const u=new Promise(((t,e)=>{const s=[],c=()=>{s.forEach((t=>t()))};if(s.push((()=>{o=!0})),r>0){const t=setTimeout((()=>{c(),e(Gn("wait for transaction timeout","TIMEOUT"))}),r);s.push((()=>{clearTimeout(t)}))}const u=r=>__async(this,null,(function*(){if((yield r.confirmations())>=n){c();try{t(l(r))}catch(i){e(i)}}}));if(s.push((()=>{this.provider.off(this.hash,u)})),this.provider.on(this.hash,u),i>=0){const t=()=>__async(this,null,(function*(){try{yield a()}catch(n){if(Bn(n,"TRANSACTION_REPLACED"))return c(),void e(n)}o||this.provider.once("block",t)}));s.push((()=>{this.provider.off("block",t)})),this.provider.once("block",t)}}));return yield u}))}isMined(){return null!=this.blockHash}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}removedEvent(){return On(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Su(this)}reorderedEvent(t){return On(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),On(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ku(this,t)}replaceableTransaction(e){Ln(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const n=new t(this,this.provider);return __privateSet(n,Yt,e),n}};function ku(t,e){return{orphan:"reorder-transaction",tx:t,other:e}}function Su(t){return{orphan:"drop-transaction",tx:t}}class Nu extends Au{constructor(t,e,n){super(t,t.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");Mn(this,{args:e.decodeEventLog(n,t.data,t.topics),fragment:n,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Cu extends Au{constructor(t,e){super(t,t.provider),__publicField(this,"error"),Mn(this,{error:e})}}class Pu extends Eu{constructor(t,e,n){super(n,e),__privateAdd(this,Xt,void 0),__privateSet(this,Xt,t)}get logs(){return super.logs.map((t=>{const e=t.topics.length?__privateGet(this,Xt).getEvent(t.topics[0]):null;if(e)try{return new Nu(t,__privateGet(this,Xt),e)}catch(n){return new Cu(t,n)}return t}))}}Xt=new WeakMap;$t=new WeakMap;let Tu=class t extends xu{constructor(t,e,n){super(n,e),__privateAdd(this,$t,void 0),__privateSet(this,$t,t)}wait(e,n){return __async(this,null,(function*(){const r=yield __superGet(t.prototype,this,"wait").call(this,e,n);return null==r?null:new Pu(__privateGet(this,$t),this.provider,r)}))}};class Mu extends gr{constructor(t,e,n,r){super(t,e,n),__publicField(this,"log"),Mn(this,{log:r})}getBlock(){return __async(this,null,(function*(){return yield this.log.getBlock()}))}getTransaction(){return __async(this,null,(function*(){return yield this.log.getTransaction()}))}getTransactionReceipt(){return __async(this,null,(function*(){return yield this.log.getTransactionReceipt()}))}}class Ru extends Mu{constructor(t,e,n,r,i){super(t,e,n,new Nu(i,t.interface,r));Mn(this,{args:t.interface.decodeEventLog(r,this.log.data,this.log.topics),fragment:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Bu=BigInt(0);function Iu(t){return t&&"function"==typeof t.call}function Gu(t){return t&&"function"==typeof t.estimateGas}function Ou(t){return t&&"function"==typeof t.resolveName}function Lu(t){return t&&"function"==typeof t.sendTransaction}function Fu(t){if(null!=t){if(Ou(t))return t;if(t.provider)return t.provider}}class Uu{constructor(t,e,n){if(__privateAdd(this,te,void 0),__publicField(this,"fragment"),Mn(this,{fragment:e}),e.inputs.length<n.length)throw new Error("too many arguments");const r=Du(t.runner,"resolveName"),i=Ou(r)?r:null;__privateSet(this,te,function(){return __async(this,null,(function*(){const r=yield Promise.all(e.inputs.map(((t,e)=>null==n[e]?null:t.walkAsync(n[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>Zo(t,i)))):Zo(e,i):e)))));return t.interface.encodeFilterTopics(e,r)}))}())}getTopicFilter(){return __privateGet(this,te)}}function Du(t,e){return null==t?null:"function"==typeof t[e]?t:t.provider&&"function"==typeof t.provider[e]?t.provider:null}function ju(t){return null==t?null:t.provider||null}function Hu(t,e){return __async(this,null,(function*(){const n=ea.dereference(t,"overrides");Ln("object"==typeof n,"invalid overrides parameter","overrides",t);const r=vu(n);return Ln(null==r.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),Ln(null==r.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}))}function Wu(t){const e=function(e){return __async(this,null,(function*(){const n=yield Hu(e,["data"]);n.to=yield t.getAddress(),n.from&&(n.from=yield Zo(n.from,Fu(t.runner)));const r=t.interface,i=sr(n.value||Bu,"overrides.value")===Bu,s="0x"===(n.data||"0x");!r.fallback||r.fallback.payable||!r.receive||s||i||Ln(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),Ln(r.fallback||s,"cannot send data to receive-only contract","overrides.data",n.data);return Ln(r.receive||r.fallback&&r.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",n.value),Ln(r.fallback||s,"cannot send data to receive-only contract","overrides.data",n.data),n}))},n=function(n){return __async(this,null,(function*(){const r=t.runner;On(Lu(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield r.sendTransaction(yield e(n)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},r=t=>__async(this,null,(function*(){return yield n(t)}));return Mn(r,{_contract:t,estimateGas:function(n){return __async(this,null,(function*(){const r=Du(t.runner,"estimateGas");return On(Gu(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield e(n))}))},populateTransaction:e,send:n,staticCall:function(n){return __async(this,null,(function*(){const r=Du(t.runner,"call");On(Iu(r),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield e(n);try{return yield r.call(i)}catch(s){if(In(s)&&s.data)throw t.interface.makeError(s.data,i);throw s}}))}}),r}function Qu(t,e){const n=function(...n){const r=t.interface.getFunction(e,n);return On(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:n}}),r},r=function(...e){return __async(this,null,(function*(){const r=n(...e);let i={};if(r.inputs.length+1===e.length&&(i=yield Hu(e.pop()),i.from&&(i.from=yield Zo(i.from,Fu(t.runner)))),r.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const s=yield function(t,e,n){return __async(this,null,(function*(){const r=Du(t,"resolveName"),i=Ou(r)?r:null;return yield Promise.all(e.map(((t,e)=>t.walkAsync(n[e],((t,e)=>(e=ea.dereference(e,t),"address"===t?Zo(e,i):e))))))}))}(t.runner,r.inputs,e);return Object.assign({},i,yield Tn({to:t.getAddress(),data:t.interface.encodeFunctionData(r,s)}))}))},i=function(...t){return __async(this,null,(function*(){const e=yield o(...t);return 1===e.length?e[0]:e}))},s=function(...e){return __async(this,null,(function*(){const n=t.runner;On(Lu(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield n.sendTransaction(yield r(...e)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},o=function(...e){return __async(this,null,(function*(){const i=Du(t.runner,"call");On(Iu(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield r(...e);let o="0x";try{o=yield i.call(s)}catch(l){if(In(l)&&l.data)throw t.interface.makeError(l.data,s);throw l}const a=n(...e);return t.interface.decodeFunctionResult(a,o)}))},a=(...t)=>__async(this,null,(function*(){return n(...t).constant?yield i(...t):yield s(...t)}));return Mn(a,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:n,estimateGas:function(...e){return __async(this,null,(function*(){const n=Du(t.runner,"estimateGas");return On(Gu(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield r(...e))}))},populateTransaction:r,send:s,staticCall:i,staticCallResult:o}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const n=t.interface.getFunction(e);return On(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),n}}),a}te=new WeakMap;const zu=Symbol.for("_ethersInternal_contract"),Vu=new WeakMap;function Ku(t){return Vu.get(t[zu])}function Ju(t,e){return __async(this,null,(function*(){let n,r=null;if(Array.isArray(e)){const r=function(e){if(Qn(e,32))return e;const n=t.interface.getEvent(e);return Ln(n,"unknown fragment","name",e),n.topicHash};n=e.map((t=>null==t?null:Array.isArray(t)?t.map(r):r(t)))}else"*"===e?n=[null]:"string"==typeof e?Qn(e,32)?n=[e]:(r=t.interface.getEvent(e),Ln(r,"unknown fragment","event",e),n=[r.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?n=yield e.getTopicFilter():"fragment"in e?(r=e.fragment,n=[r.topicHash]):Ln(!1,"unknown event name","event",e);var i;n=n.map((t=>{if(null==t)return null;if(Array.isArray(t)){const e=Array.from(new Set(t.map((t=>t.toLowerCase()))).values());return 1===e.length?e[0]:(e.sort(),e)}return t.toLowerCase()}));return{fragment:r,tag:n.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:n}}))}function qu(t,e){return __async(this,null,(function*(){const{subs:n}=Ku(t);return n.get((yield Ju(t,e)).tag)||null}))}function Zu(t,e,n){return __async(this,null,(function*(){const r=ju(t.runner);On(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:o}=yield Ju(t,n),{addr:a,subs:l}=Ku(t);let c=l.get(s);if(!c){const e={address:a||t,topics:o},u=e=>{let r=i;if(null==r)try{r=t.interface.getEvent(e.topics[0])}catch(s){}if(r){const s=r,o=i?t.interface.decodeEventLog(i,e.data,e.topics):[];Xu(t,n,o,(r=>new Ru(t,r,n,s,e)))}else Xu(t,n,[],(r=>new Mu(t,r,n,e)))};let h=[];c={tag:s,listeners:[],start:()=>{h.length||h.push(r.on(e,u))},stop:()=>__async(this,null,(function*(){if(0==h.length)return;let t=h;h=[],yield Promise.all(t),r.off(e,u)}))},l.set(s,c)}return c}))}let Yu=Promise.resolve();function Xu(t,e,n,r){return __async(this,null,(function*(){try{yield Yu}catch(s){}const i=function(t,e,n,r){return __async(this,null,(function*(){yield Yu;const i=yield qu(t,e);if(!i)return!1;const o=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const o=Array.from(n);r&&o.push(r(i?null:e));try{e.call(t,...o)}catch(s){}return!i})),0===i.listeners.length&&(i.stop(),Ku(t).subs.delete(i.tag)),o>0}))}(t,e,n,r);return Yu=i,yield i}))}const $u=["then"];ee=zu;let th=class t{constructor(t,e,n,r){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),Ln("string"==typeof t||Jo(t),"invalid value for Contract target","target",t),null==n&&(n=null);const i=gu.from(e);let s;Mn(this,{target:t,runner:n,interface:i}),Object.defineProperty(this,zu,{value:{}});let o=null,a=null;if(r){const t=ju(n);a=new Tu(this.interface,t,r)}let l=new Map;if("string"==typeof t)if(Qn(t))o=t,s=Promise.resolve(t);else{const e=Du(n,"resolveName");if(!Ou(e))throw Gn("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw Gn("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Ku(this).addr=e,e}))}else s=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return Ku(this).addr=t,t}));var c,u;c=this,u={addrPromise:s,addr:o,deployTx:a,subs:l},Vu.set(c[zu],u);return Mn(this,{filters:new Proxy({},{get:(t,e,n)=>{if("symbol"==typeof e||$u.indexOf(e)>=0)return Reflect.get(t,e,n);try{return this.getEvent(e)}catch(r){if(!Bn(r,"INVALID_ARGUMENT")||"key"!==r.argument)throw r}},has:(t,e)=>$u.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))})}),Mn(this,{fallback:i.receive||i.fallback?Wu(this):null}),new Proxy(this,{get:(t,e,n)=>{if("symbol"==typeof e||e in t||$u.indexOf(e)>=0)return Reflect.get(t,e,n);try{return t.getFunction(e)}catch(r){if(!Bn(r,"INVALID_ARGUMENT")||"key"!==r.argument)throw r}},has:(t,e)=>"symbol"==typeof e||e in t||$u.indexOf(e)>=0?Reflect.has(t,e):t.interface.hasFunction(e)})}connect(e){return new t(this.target,this.interface,e)}attach(e){return new t(e,this.interface,this.runner)}getAddress(){return __async(this,null,(function*(){return yield Ku(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const t=ju(this.runner);On(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=yield t.getCode(yield this.getAddress());return"0x"===e?null:e}))}waitForDeployment(){return __async(this,null,(function*(){const t=this.deploymentTransaction();if(t)return yield t.wait(),this;if(null!=(yield this.getDeployedCode()))return this;const e=ju(this.runner);return On(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,n)=>{const r=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return t(this);e.once("block",r)}catch(i){n(i)}}));r()}))}))}deploymentTransaction(){return Ku(this).deployTx}getFunction(t){"string"!=typeof t&&(t=t.format());return Qu(this,t)}getEvent(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const n=function(...n){const r=t.interface.getEvent(e,n);return On(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:n}}),r},r=function(...e){return new Uu(t,n(...e),e)};return Mn(r,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:n}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const n=t.interface.getEvent(e);return On(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),n}}),r}(this,t)}queryTransaction(t){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(t,e,n){return __async(this,null,(function*(){null==e&&(e=0),null==n&&(n="latest");const{addr:r,addrPromise:i}=Ku(this),s=r||(yield i),{fragment:o,topics:a}=yield Ju(this,t),l={address:s,topics:a,fromBlock:e,toBlock:n},c=ju(this.runner);return On(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((t=>{let e=o;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(n){}if(e)try{return new Nu(t,this.interface,e)}catch(n){return new Cu(t,n)}return new Au(t,c)}))}))}on(t,e){return __async(this,null,(function*(){const n=yield Zu(this,"on",t);return n.listeners.push({listener:e,once:!1}),n.start(),this}))}once(t,e){return __async(this,null,(function*(){const n=yield Zu(this,"once",t);return n.listeners.push({listener:e,once:!0}),n.start(),this}))}emit(t,...e){return __async(this,null,(function*(){return yield Xu(this,t,e,null)}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield qu(this,t);return e?e.listeners.length:0}const{subs:e}=Ku(this);let n=0;for(const{listeners:t}of e.values())n+=t.length;return n}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield qu(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}const{subs:e}=Ku(this);let n=[];for(const{listeners:t}of e.values())n=n.concat(t.map((({listener:t})=>t)));return n}))}off(t,e){return __async(this,null,(function*(){const n=yield qu(this,t);if(!n)return this;if(e){const t=n.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&n.listeners.splice(t,1)}return null!=e&&0!==n.listeners.length||(n.stop(),Ku(this).subs.delete(n.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const e=yield qu(this,t);if(!e)return this;e.stop(),Ku(this).subs.delete(e.tag)}else{const{subs:t}=Ku(this);for(const{tag:e,stop:n}of t.values())n(),t.delete(e)}return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return yield this.off(t,e)}))}static buildClass(e){return class extends t{constructor(t,n=null){super(t,e,n)}}}static from(t,e,n){null==n&&(n=null);return new this(t,e,n)}};class eh extends(function(){return th}()){}function nh(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):Ln(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class rh{constructor(t){__publicField(this,"name"),Mn(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}encodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}decodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}}const ih=new RegExp("^(ipfs)://(.*)$","i"),sh=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),ih,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],oh=class t{constructor(t,e,n){__privateAdd(this,ie),__publicField(this,"provider"),__publicField(this,"address"),__publicField(this,"name"),__privateAdd(this,ne,void 0),__privateAdd(this,re,void 0),Mn(this,{provider:t,address:e,name:n}),__privateSet(this,ne,null),__privateSet(this,re,new eh(e,["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)"],t))}supportsWildcard(){return __async(this,null,(function*(){return null==__privateGet(this,ne)&&__privateSet(this,ne,(()=>__async(this,null,(function*(){try{return yield __privateGet(this,re).supportsInterface("0x9061b923")}catch(t){if(Bn(t,"CALL_EXCEPTION"))return!1;throw __privateSet(this,ne,null),t}})))()),yield __privateGet(this,ne)}))}getAddress(t){return __async(this,null,(function*(){if(null==t&&(t=60),60===t)try{const t=yield __privateMethod(this,ie,se).call(this,"addr(bytes32)");return null==t||t===Po?null:t}catch(i){if(Bn(i,"CALL_EXCEPTION"))return null;throw i}if(t>=0&&t<2147483648){let e=t+2147483648;const n=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[e]);if(Qn(n,20))return Ko(n)}let e=null;for(const s of this.provider.plugins)if(s instanceof rh&&s.supportsCoinType(t)){e=s;break}if(null==e)return null;const n=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[t]);if(null==n||"0x"===n)return null;const r=yield e.decodeAddress(t,n);if(null!=r)return r;On(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:n}})}))}getText(t){return __async(this,null,(function*(){const e=yield __privateMethod(this,ie,se).call(this,"text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}))}getContentHash(){return __async(this,null,(function*(){const t=yield __privateMethod(this,ie,se).call(this,"contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",n=parseInt(e[4],16);if(e[5].length===2*n)return`${t}://${function(t){const e=Hn(t);let n=lr(e),r="";for(;n;)r=pr[Number(n%fr)]+r,n/=fr;for(let i=0;i<e.length&&!e[i];i++)r=pr[0]+r;return r}("0x"+e[2])}`}const n=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&64===n[1].length)return`bzz://${n[1]}`;On(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}))}getAvatar(){return __async(this,null,(function*(){return(yield this._getAvatar()).url}))}_getAvatar(){return __async(this,null,(function*(){const t=[{type:"name",value:this.name}];try{const r=yield this.getText("avatar");if(null==r)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:r});for(let i=0;i<sh.length;i++){const s=r.match(sh[i]);if(null==s)continue;const o=s[1].toLowerCase();switch(o){case"https":case"data":return t.push({type:"url",value:r}),{linkage:t,url:r};case"ipfs":{const e=nh(r);return t.push({type:"ipfs",value:r}),t.push({type:"url",value:e}),{linkage:t,url:e}}case"erc721":case"erc1155":{const i="erc721"===o?"tokenURI(uint256)":"uri(uint256)";t.push({type:o,value:r});const a=yield this.getAddress();if(null==a)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const l=(s[2]||"").split("/");if(2!==l.length)return t.push({type:`!${o}caip`,value:s[2]||""}),{url:null,linkage:t};const c=l[1],u=new eh(l[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("erc721"===o){const e=yield u.ownerOf(c);if(a!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===o){const e=yield u.balanceOf(a,c);if(!e)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:e.toString()})}let h=yield u[i](c);if(null==h||"0x"===h)return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:h}),"erc1155"===o&&(h=h.replace("{id}",ur(c,32).substring(2)),t.push({type:"metadata-url-expanded",value:h})),h.match(/^ipfs:/i)&&(h=nh(h)),t.push({type:"metadata-url",value:h});let d={};const p=yield new Rr(h).send();p.assertOk();try{d=p.bodyJson}catch(e){try{t.push({type:"!metadata",value:p.bodyText})}catch(n){const e=p.body;return e&&t.push({type:"!metadata",value:Kn(e)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!d)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(d)});let f=d.image;if("string"!=typeof f)return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(f.match(/^(https:\/\/|data:)/i));else{if(null==f.match(ih))return t.push({type:"!imageUrl-ipfs",value:f}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:f}),f=nh(f)}return t.push({type:"url",value:f}),{linkage:t,url:f}}}}}catch(e){}return{linkage:t,url:null}}))}static getEnsAddress(t){return __async(this,null,(function*(){const e=yield t.getNetwork(),n=e.getPlugin("org.ethers.plugins.network.Ens");return On(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),n.address}))}static fromName(e,n){return __async(this,null,(function*(){var r;let i=n;for(;;){if(""===i||"."===i)return null;if("eth"!==n&&"eth"===i)return null;const s=yield __privateMethod(r=t,oe,ae).call(r,e,i);if(null!=s){const r=new t(e,s,n);return i===n||(yield r.supportsWildcard())?r:null}i=i.split(".").slice(1).join(".")}}))}};ne=new WeakMap,re=new WeakMap,ie=new WeakSet,se=function(t,e){return __async(this,null,(function*(){e=(e||[]).slice();const n=__privateGet(this,re).interface;e.unshift(Jl(this.name));let r=null;(yield this.supportsWildcard())&&(r=n.getFunction(t),On(r,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[ql(this.name,255),n.encodeFunctionData(r,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=yield __privateGet(this,re)[t](...e);return r?n.decodeFunctionResult(r,i)[0]:i}catch(i){if(!Bn(i,"CALL_EXCEPTION"))throw i}return null}))},oe=new WeakSet,ae=function(t,e){return __async(this,null,(function*(){const n=yield oh.getEnsAddress(t);try{const r=new eh(n,["function resolver(bytes32) view returns (address)"],t),i=yield r.resolver(Jl(e),{enableCcipRead:!0});return i===Po?null:i}catch(r){throw r}return null}))},__privateAdd(oh,oe);let ah=oh;const lh=BigInt(0);function ch(t,e){return function(n){return null==n?e:t(n)}}function uh(t,e){return n=>{if(e&&null==n)return null;if(!Array.isArray(n))throw new Error("not an array");return n.map((e=>t(e)))}}function hh(t,e){return n=>{const r={};for(const s in t){let o=s;if(e&&s in e&&!(o in n))for(const t of e[s])if(t in n){o=t;break}try{const e=t[s](n[o]);void 0!==e&&(r[s]=e)}catch(i){On(!1,`invalid value for value.${s} (${i instanceof Error?i.message:"not-an-error"})`,"BAD_DATA",{value:n})}}return r}}function dh(t){return Ln(Qn(t,!0),"invalid data","value",t),t}function ph(t){return Ln(Qn(t,32),"invalid hash","value",t),t}const fh=hh({address:Ko,blockHash:ph,blockNumber:cr,data:dh,index:cr,removed:ch((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}Ln(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:uh(ph),transactionHash:ph,transactionIndex:cr},{index:["logIndex"]});const gh=hh({hash:ch(ph),parentHash:ph,parentBeaconBlockRoot:ch(ph,null),number:cr,timestamp:cr,nonce:ch(dh),difficulty:sr,gasLimit:sr,gasUsed:sr,stateRoot:ch(ph,null),receiptsRoot:ch(ph,null),blobGasUsed:ch(sr,null),excessBlobGas:ch(sr,null),miner:ch(Ko),prevRandao:ch(ph,null),extraData:dh,baseFeePerGas:ch(sr)},{prevRandao:["mixHash"]});const mh=hh({transactionIndex:cr,blockNumber:cr,transactionHash:ph,address:Ko,topics:uh(ph),data:dh,index:cr,blockHash:ph},{index:["logIndex"]});const _h=hh({to:ch(Ko,null),from:ch(Ko,null),contractAddress:ch(Ko,null),index:cr,root:ch(Kn),gasUsed:sr,blobGasUsed:ch(sr,null),logsBloom:ch(dh),blockHash:ph,hash:ph,logs:uh((function(t){return mh(t)})),blockNumber:cr,cumulativeGasUsed:sr,effectiveGasPrice:ch(sr),blobGasPrice:ch(sr,null),status:ch(cr),type:ch(cr,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function yh(t){t.to&&sr(t.to)===lh&&(t.to="0x0000000000000000000000000000000000000000");const e=hh({hash:ph,index:ch(cr,void 0),type:t=>"0x"===t||null==t?0:cr(t),accessList:ch(va,null),blobVersionedHashes:ch(uh(ph,!0),null),authorizationList:ch(uh((t=>{let e;if(t.signature)e=t.signature;else{let n=t.yParity;"0x1b"===n?n=0:"0x1c"===n&&(n=1),e=Object.assign({},t,{yParity:n})}return{address:Ko(t.address),chainId:sr(t.chainId),nonce:sr(t.nonce),signature:Do.from(e)}}),!1),null),blockHash:ch(ph,null),blockNumber:ch(cr,null),transactionIndex:ch(cr,null),from:Ko,gasPrice:ch(sr),maxPriorityFeePerGas:ch(sr),maxFeePerGas:ch(sr),maxFeePerBlobGas:ch(sr,null),gasLimit:sr,to:ch(Ko,null),value:sr,nonce:cr,data:dh,creates:ch(Ko,null),chainId:ch(sr,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=Ko(t.from);let n=sr(t.nonce,"tx.nonce").toString(16);return n="0"===n?"0x":n.length%2?"0x0"+n:"0x"+n,Ko(Zn(vs(ei([e,n])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=Do.from(t.signature):e.signature=Do.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&sr(e.blockHash)===lh&&(e.blockHash=null),e}class wh{constructor(t){__publicField(this,"name"),Mn(this,{name:t})}clone(){return new wh(this.name)}}class vh extends wh{constructor(t,e){null==t&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`),__publicField(this,"effectiveBlock"),__publicField(this,"txBase"),__publicField(this,"txCreate"),__publicField(this,"txDataZero"),__publicField(this,"txDataNonzero"),__publicField(this,"txAccessListStorageKey"),__publicField(this,"txAccessListAddress");const n={effectiveBlock:t};function r(t,r){let i=(e||{})[t];null==i&&(i=r),Ln("number"==typeof i,`invalud value for ${t}`,"costs",e),n[t]=i}r("txBase",21e3),r("txCreate",32e3),r("txDataZero",4),r("txDataNonzero",16),r("txAccessListStorageKey",1900),r("txAccessListAddress",2400),Mn(this,n)}clone(){return new vh(this.effectiveBlock,this)}}class bh extends wh{constructor(t,e){super("org.ethers.plugins.network.Ens"),__publicField(this,"address"),__publicField(this,"targetNetwork"),Mn(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new bh(this.address,this.targetNetwork)}}class Ah extends wh{constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),__privateAdd(this,le,void 0),__privateAdd(this,ce,void 0),__privateSet(this,le,t),__privateSet(this,ce,e)}get url(){return __privateGet(this,le)}get processFunc(){return __privateGet(this,ce)}clone(){return this}}le=new WeakMap,ce=new WeakMap;const Eh=new Map;ue=new WeakMap,he=new WeakMap,de=new WeakMap;let xh=class t{constructor(t,e){__privateAdd(this,ue,void 0),__privateAdd(this,he,void 0),__privateAdd(this,de,void 0),__privateSet(this,ue,t),__privateSet(this,he,sr(e)),__privateSet(this,de,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return __privateGet(this,ue)}set name(t){__privateSet(this,ue,t)}get chainId(){return __privateGet(this,he)}set chainId(t){__privateSet(this,he,sr(t,"chainId"))}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===sr(t)}catch(e){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===sr(t)}catch(e){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===sr(t.chainId)}catch(e){}return!1}return null!=t.name&&this.name===t.name}return!1}get plugins(){return Array.from(__privateGet(this,de).values())}attachPlugin(t){if(__privateGet(this,de).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,de).set(t.name,t.clone()),this}getPlugin(t){return __privateGet(this,de).get(t)||null}getPlugins(t){return this.plugins.filter((e=>e.name.split("#")[0]===t))}clone(){const e=new t(this.name,this.chainId);return this.plugins.forEach((t=>{e.attachPlugin(t.clone())})),e}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new vh;let n=e.txBase;if(null==t.to&&(n+=e.txCreate),t.data)for(let r=2;r<t.data.length;r+=2)"00"===t.data.substring(r,r+2)?n+=e.txDataZero:n+=e.txDataNonzero;if(t.accessList){const r=va(t.accessList);for(const t in r)n+=e.txAccessListAddress+e.txAccessListStorageKey*r[t].storageKeys.length}return n}static from(e){if(function(){if(Nh)return;function t(t,e,n){const r=function(){const r=new xh(t,e);return null!=n.ensNetwork&&r.attachPlugin(new bh(null,n.ensNetwork)),r.attachPlugin(new vh),(n.plugins||[]).forEach((t=>{r.attachPlugin(t)})),r};xh.register(t,r),xh.register(e,r),n.altNames&&n.altNames.forEach((t=>{xh.register(t,r)}))}Nh=!0,t("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),t("ropsten",3,{ensNetwork:3}),t("rinkeby",4,{ensNetwork:4}),t("goerli",5,{ensNetwork:5}),t("kovan",42,{ensNetwork:42}),t("sepolia",11155111,{ensNetwork:11155111}),t("holesky",17e3,{ensNetwork:17e3}),t("classic",61,{}),t("classicKotti",6,{}),t("arbitrum",42161,{ensNetwork:1}),t("arbitrum-goerli",421613,{}),t("arbitrum-sepolia",421614,{}),t("base",8453,{ensNetwork:1}),t("base-goerli",84531,{}),t("base-sepolia",84532,{}),t("bnb",56,{ensNetwork:1}),t("bnbt",97,{}),t("linea",59144,{ensNetwork:1}),t("linea-goerli",59140,{}),t("linea-sepolia",59141,{}),t("matic",137,{ensNetwork:1,plugins:[Sh("https://gasstation.polygon.technology/v2")]}),t("matic-amoy",80002,{}),t("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Sh("https://gasstation-testnet.polygon.technology/v2")]}),t("optimism",10,{ensNetwork:1,plugins:[]}),t("optimism-goerli",420,{}),t("optimism-sepolia",11155420,{}),t("xdai",100,{ensNetwork:1})}(),null==e)return t.from("mainnet");if("number"==typeof e&&(e=BigInt(e)),"string"==typeof e||"bigint"==typeof e){const n=Eh.get(e);if(n)return n();if("bigint"==typeof e)return new t("unknown",e);Ln(!1,"unknown network","network",e)}if("function"==typeof e.clone){return e.clone()}if("object"==typeof e){Ln("string"==typeof e.name&&"number"==typeof e.chainId,"invalid network object name or chainId","network",e);const n=new t(e.name,e.chainId);return(e.ensAddress||null!=e.ensNetwork)&&n.attachPlugin(new bh(e.ensAddress,e.ensNetwork)),n}Ln(!1,"invalid network","network",e)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const n=Eh.get(t);n&&Ln(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",t),Eh.set(t,e)}};function kh(t,e){const n=String(t);if(!n.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const r=n.split(".");if(1===r.length&&r.push(""),2!==r.length)throw new Error(`invalid gwei value: ${t}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let t=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||t++,r[1]=t.toString()}return BigInt(r[0]+r[1])}function Sh(t){return new Ah(t,((t,e,n)=>__async(this,null,(function*(){let e;n.setHeader("User-Agent","ethers");try{const[r,i]=yield Promise.all([n.send(),t()]);e=r;const s=e.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:kh(s.maxFee,9),maxPriorityFeePerGas:kh(s.maxPriorityFee,9)}}catch(r){On(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:e,error:r})}}))))}let Nh=!1;function Ch(t){return JSON.parse(JSON.stringify(t))}class Ph{constructor(t){__privateAdd(this,_e),__privateAdd(this,pe,void 0),__privateAdd(this,fe,void 0),__privateAdd(this,ge,void 0),__privateAdd(this,me,void 0),__privateSet(this,pe,t),__privateSet(this,fe,null),__privateSet(this,ge,4e3),__privateSet(this,me,-2)}get pollingInterval(){return __privateGet(this,ge)}set pollingInterval(t){__privateSet(this,ge,t)}start(){__privateGet(this,fe)||(__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,_e,ye).bind(this),__privateGet(this,ge))),__privateMethod(this,_e,ye).call(this))}stop(){__privateGet(this,fe)&&(__privateGet(this,pe)._clearTimeout(__privateGet(this,fe)),__privateSet(this,fe,null))}pause(t){this.stop(),t&&__privateSet(this,me,-2)}resume(){this.start()}}pe=new WeakMap,fe=new WeakMap,ge=new WeakMap,me=new WeakMap,_e=new WeakSet,ye=function(){return __async(this,null,(function*(){try{const t=yield __privateGet(this,pe).getBlockNumber();if(-2===__privateGet(this,me))return void __privateSet(this,me,t);if(t!==__privateGet(this,me)){for(let e=__privateGet(this,me)+1;e<=t;e++){if(null==__privateGet(this,fe))return;yield __privateGet(this,pe).emit("block",e)}__privateSet(this,me,t)}}catch(t){}null!=__privateGet(this,fe)&&__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,_e,ye).bind(this),__privateGet(this,ge)))}))};class Th{constructor(t){__privateAdd(this,we,void 0),__privateAdd(this,ve,void 0),__privateAdd(this,be,void 0),__privateSet(this,we,t),__privateSet(this,be,!1),__privateSet(this,ve,(t=>{this._poll(t,__privateGet(this,we))}))}_poll(t,e){return __async(this,null,(function*(){throw new Error("sub-classes must override this")}))}start(){__privateGet(this,be)||(__privateSet(this,be,!0),__privateGet(this,ve).call(this,-2),__privateGet(this,we).on("block",__privateGet(this,ve)))}stop(){__privateGet(this,be)&&(__privateSet(this,be,!1),__privateGet(this,we).off("block",__privateGet(this,ve)))}pause(t){this.stop()}resume(){this.start()}}we=new WeakMap,ve=new WeakMap,be=new WeakMap;class Mh extends Th{constructor(t,e){super(t),__privateAdd(this,Ae,void 0),__privateAdd(this,Ee,void 0),__privateSet(this,Ae,e),__privateSet(this,Ee,-2)}pause(t){t&&__privateSet(this,Ee,-2),super.pause(t)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getBlock(__privateGet(this,Ae));null!=t&&(-2===__privateGet(this,Ee)?__privateSet(this,Ee,t.number):t.number>__privateGet(this,Ee)&&(e.emit(__privateGet(this,Ae),t.number),__privateSet(this,Ee,t.number)))}))}}Ae=new WeakMap,Ee=new WeakMap;class Rh extends Th{constructor(t,e){super(t),__privateAdd(this,xe,void 0),__privateSet(this,xe,Ch(e))}_poll(t,e){return __async(this,null,(function*(){throw new Error("@TODO")}))}}xe=new WeakMap;class Bh extends Th{constructor(t,e){super(t),__privateAdd(this,ke,void 0),__privateSet(this,ke,e)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getTransactionReceipt(__privateGet(this,ke));t&&e.emit(__privateGet(this,ke),t)}))}}ke=new WeakMap;class Ih{constructor(t,e){__privateAdd(this,Me),__privateAdd(this,Se,void 0),__privateAdd(this,Ne,void 0),__privateAdd(this,Ce,void 0),__privateAdd(this,Pe,void 0),__privateAdd(this,Te,void 0),__privateSet(this,Se,t),__privateSet(this,Ne,Ch(e)),__privateSet(this,Ce,__privateMethod(this,Me,Re).bind(this)),__privateSet(this,Pe,!1),__privateSet(this,Te,-2)}start(){__privateGet(this,Pe)||(__privateSet(this,Pe,!0),-2===__privateGet(this,Te)&&__privateGet(this,Se).getBlockNumber().then((t=>{__privateSet(this,Te,t)})),__privateGet(this,Se).on("block",__privateGet(this,Ce)))}stop(){__privateGet(this,Pe)&&(__privateSet(this,Pe,!1),__privateGet(this,Se).off("block",__privateGet(this,Ce)))}pause(t){this.stop(),t&&__privateSet(this,Te,-2)}resume(){this.start()}}Se=new WeakMap,Ne=new WeakMap,Ce=new WeakMap,Pe=new WeakMap,Te=new WeakMap,Me=new WeakSet,Re=function(t){return __async(this,null,(function*(){if(-2===__privateGet(this,Te))return;const e=Ch(__privateGet(this,Ne));e.fromBlock=__privateGet(this,Te)+1,e.toBlock=t;const n=yield __privateGet(this,Se).getLogs(e);if(0!==n.length)for(const t of n)__privateGet(this,Se).emit(__privateGet(this,Ne),t),__privateSet(this,Te,t.blockNumber);else __privateGet(this,Te)<t-60&&__privateSet(this,Te,t-60)}))};const Gh=BigInt(2);function Oh(t){return t&&"function"==typeof t.then}function Lh(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,n)=>(t[n]=e[n],t)),{})}return e}))}class Fh{constructor(t){__publicField(this,"name"),Mn(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function Uh(t){return(t=Array.from(new Set(t).values())).sort(),t}function Dh(t,e){return __async(this,null,(function*(){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if(Qn(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:Lh("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:Lh("orphan",e),filter:(n=e,JSON.parse(JSON.stringify(n)))}}var n;if(t.address||t.topics){const n=t,r={topics:(n.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(n.address){const t=[],i=[],s=n=>{Qn(n)?t.push(n):i.push((()=>__async(this,null,(function*(){t.push(yield Zo(n,e))})))())};Array.isArray(n.address)?n.address.forEach(s):s(n.address),i.length&&(yield Promise.all(i)),r.address=Uh(t.map((t=>t.toLowerCase())))}return{filter:r,tag:Lh("event",r),type:"event"}}Ln(!1,"unknown ProviderEvent","event",t)}))}function jh(){return(new Date).getTime()}const Hh={cacheTimeout:250,pollingInterval:4e3};class Wh{constructor(t,e){if(__privateAdd(this,ze),__privateAdd(this,Ke),__privateAdd(this,qe),__privateAdd(this,Ye),__privateAdd(this,$e),__privateAdd(this,en),__privateAdd(this,rn),__privateAdd(this,Be,void 0),__privateAdd(this,Ie,void 0),__privateAdd(this,Ge,void 0),__privateAdd(this,Oe,void 0),__privateAdd(this,Le,void 0),__privateAdd(this,Fe,void 0),__privateAdd(this,Ue,void 0),__privateAdd(this,De,void 0),__privateAdd(this,je,void 0),__privateAdd(this,He,void 0),__privateAdd(this,We,void 0),__privateAdd(this,Qe,void 0),__privateSet(this,Qe,Object.assign({},Hh,e||{})),"any"===t)__privateSet(this,Fe,!0),__privateSet(this,Le,null);else if(t){const e=xh.from(t);__privateSet(this,Fe,!1),__privateSet(this,Le,Promise.resolve(e)),setTimeout((()=>{this.emit("network",e,null)}),0)}else __privateSet(this,Fe,!1),__privateSet(this,Le,null);__privateSet(this,De,-1),__privateSet(this,Ue,new Map),__privateSet(this,Be,new Map),__privateSet(this,Ie,new Map),__privateSet(this,Ge,null),__privateSet(this,Oe,!1),__privateSet(this,je,1),__privateSet(this,He,new Map),__privateSet(this,We,!1)}get pollingInterval(){return __privateGet(this,Qe).pollingInterval}get provider(){return this}get plugins(){return Array.from(__privateGet(this,Ie).values())}attachPlugin(t){if(__privateGet(this,Ie).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,Ie).set(t.name,t.connect(this)),this}getPlugin(t){return __privateGet(this,Ie).get(t)||null}get disableCcipRead(){return __privateGet(this,We)}set disableCcipRead(t){__privateSet(this,We,!!t)}ccipReadFetch(t,e,n){return __async(this,null,(function*(){if(this.disableCcipRead||0===n.length||null==t.to)return null;const r=t.to.toLowerCase(),i=e.toLowerCase(),s=[];for(let e=0;e<n.length;e++){const a=n[e],l=a.replace("{sender}",r).replace("{data}",i),c=new Rr(l);-1===a.indexOf("{data}")&&(c.body={data:i,sender:r}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:c,index:e,urls:n});let u,h="unknown error";try{u=yield c.send()}catch(o){s.push(o.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:{error:o}});continue}try{const t=u.bodyJson;if(t.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:c,result:t}),t.data;t.message&&(h=t.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:t})}catch(o){}On(u.statusCode<400||u.statusCode>=500,`response not found during CCIP fetch: ${h}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:a,errorMessage:h}}),s.push(h)}On(!1,`error encountered during CCIP fetch: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:n,errorMessages:s}})}))}_wrapBlock(t,e){return new bu(function(t){const e=gh(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:yh(t))),e}(t),this)}_wrapLog(t,e){return new Au(function(t){return fh(t)}(t),this)}_wrapTransactionReceipt(t,e){return new Eu(function(t){return _h(t)}(t),this)}_wrapTransactionResponse(t,e){return new xu(yh(t),this)}_detectNetwork(){On(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}_perform(t){return __async(this,null,(function*(){On(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}))}getBlockNumber(){return __async(this,null,(function*(){const t=cr(yield __privateMethod(this,ze,Ve).call(this,{method:"getBlockNumber"}),"%response");return __privateGet(this,De)>=0&&__privateSet(this,De,t),t}))}_getAddress(t){return Zo(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return Qn(t)?Qn(t,32)?t:dr(t):("bigint"==typeof t&&(t=cr(t,"blockTag")),"number"==typeof t?t>=0?dr(t):__privateGet(this,De)>=0?dr(__privateGet(this,De)+t):this.getBlockNumber().then((e=>dr(e+t))):void Ln(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase())),n="blockHash"in t?t.blockHash:void 0,r=(t,r,i)=>{let s;switch(t.length){case 0:break;case 1:s=t[0];break;default:t.sort(),s=t}if(n&&(null!=r||null!=i))throw new Error("invalid filter");const o={};return s&&(o.address=s),e.length&&(o.topics=e),r&&(o.fromBlock=r),i&&(o.toBlock=i),n&&(o.blockHash=n),o};let i,s,o=[];if(t.address)if(Array.isArray(t.address))for(const a of t.address)o.push(this._getAddress(a));else o.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(s=this._getBlockTag(t.toBlock)),o.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=s&&"string"!=typeof s?Promise.all([Promise.all(o),i,s]).then((t=>r(t[0],t[1],t[2]))):r(o,i,s)}_getTransactionRequest(t){const e=vu(t),n=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const r=Zo(e[t],this);Oh(r)?n.push(function(){return __async(this,null,(function*(){e[t]=yield r}))}()):e[t]=r})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);Oh(t)?n.push(function(){return __async(this,null,(function*(){e.blockTag=yield t}))}()):e.blockTag=t}return n.length?function(){return __async(this,null,(function*(){return yield Promise.all(n),e}))}():e}getNetwork(){return __async(this,null,(function*(){if(null==__privateGet(this,Le)){const t=(()=>__async(this,null,(function*(){try{const t=yield this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw __privateGet(this,Le)===t&&__privateSet(this,Le,null),e}})))();return __privateSet(this,Le,t),(yield t).clone()}const t=__privateGet(this,Le),[e,n]=yield Promise.all([t,this._detectNetwork()]);return e.chainId!==n.chainId&&(__privateGet(this,Fe)?(this.emit("network",n,e),__privateGet(this,Le)===t&&__privateSet(this,Le,Promise.resolve(n))):On(!1,`network changed: ${e.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}))}getFeeData(){return __async(this,null,(function*(){const t=yield this.getNetwork(),e=()=>__async(this,null,(function*(){const{_block:e,gasPrice:n,priorityFee:r}=yield Tn({_block:__privateMethod(this,$e,tn).call(this,"latest",!1),gasPrice:(()=>__async(this,null,(function*(){try{return sr(yield __privateMethod(this,ze,Ve).call(this,{method:"getGasPrice"}),"%response")}catch(t){}return null})))(),priorityFee:(()=>__async(this,null,(function*(){try{return sr(yield __privateMethod(this,ze,Ve).call(this,{method:"getPriorityFee"}),"%response")}catch(t){}return null})))()});let i=null,s=null;const o=this._wrapBlock(e,t);return o&&o.baseFeePerGas&&(s=null!=r?r:BigInt("1000000000"),i=o.baseFeePerGas*Gh+s),new wu(n,i,s)})),n=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const t=new Rr(n.url),r=yield n.processFunc(e,this,t);return new wu(r.gasPrice,r.maxFeePerGas,r.maxPriorityFeePerGas)}return yield e()}))}estimateGas(t){return __async(this,null,(function*(){let e=this._getTransactionRequest(t);return Oh(e)&&(e=yield e),sr(yield __privateMethod(this,ze,Ve).call(this,{method:"estimateGas",transaction:e}),"%response")}))}call(t){return __async(this,null,(function*(){const{tx:e,blockTag:n}=yield Tn({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,Ke,Je).call(this,e,n,t.enableCcipRead?0:-1))}))}getBalance(t,e){return __async(this,null,(function*(){return sr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getBalance"},t,e),"%response")}))}getTransactionCount(t,e){return __async(this,null,(function*(){return cr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getTransactionCount"},t,e),"%response")}))}getCode(t,e){return __async(this,null,(function*(){return Kn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getCode"},t,e))}))}getStorage(t,e,n){return __async(this,null,(function*(){const r=sr(e,"position");return Kn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getStorage",position:r},t,n))}))}broadcastTransaction(t){return __async(this,null,(function*(){const{blockNumber:e,hash:n,network:r}=yield Tn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=Da.from(t);if(i.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,r).replaceableTransaction(e)}))}getBlock(t,e){return __async(this,null,(function*(){const{network:n,params:r}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,$e,tn).call(this,t,!!e)});return null==r?null:this._wrapBlock(r,n)}))}getTransaction(t){return __async(this,null,(function*(){const{network:e,params:n}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t})});return null==n?null:this._wrapTransactionResponse(n,e)}))}getTransactionReceipt(t){return __async(this,null,(function*(){const{network:e,params:n}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionReceipt",hash:t})});if(null==n)return null;if(null==n.gasPrice&&null==n.effectiveGasPrice){const e=yield __privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(n,e)}))}getTransactionResult(t){return __async(this,null,(function*(){const{result:e}=yield Tn({network:this.getNetwork(),result:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionResult",hash:t})});return null==e?null:Kn(e)}))}getLogs(t){return __async(this,null,(function*(){let e=this._getFilter(t);Oh(e)&&(e=yield e);const{network:n,params:r}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getLogs",filter:e})});return r.map((t=>this._wrapLog(t,n)))}))}_getProvider(t){On(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}getResolver(t){return __async(this,null,(function*(){return yield ah.fromName(this,t)}))}getAvatar(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAvatar():null}))}resolveName(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAddress():null}))}lookupAddress(t){return __async(this,null,(function*(){const e=Jl((t=Ko(t)).substring(2).toLowerCase()+".addr.reverse");try{const n=yield ah.getEnsAddress(this),r=new eh(n,["function resolver(bytes32) view returns (address)"],this),i=yield r.resolver(e);if(null==i||i===Po)return null;const s=new eh(i,["function name(bytes32) view returns (string)"],this),o=yield s.name(e);return(yield this.resolveName(o))!==t?null:o}catch(n){if(Bn(n,"BAD_DATA")&&"0x"===n.value)return null;if(Bn(n,"CALL_EXCEPTION"))return null;throw n}return null}))}waitForTransaction(t,e,n){return __async(this,null,(function*(){const r=null!=e?e:1;return 0===r?this.getTransactionReceipt(t):new Promise(((e,i)=>__async(this,null,(function*(){let s=null;const o=n=>__async(this,null,(function*(){try{const i=yield this.getTransactionReceipt(t);if(null!=i&&n-i.blockNumber+1>=r)return e(i),void(s&&(clearTimeout(s),s=null))}catch(i){console.log("EEE",i)}this.once("block",o)}));null!=n&&(s=setTimeout((()=>{null!=s&&(s=null,this.off("block",o),i(Gn("timeout","TIMEOUT",{reason:"timeout"})))}),n)),o(yield this.getBlockNumber())}))))}))}waitForBlock(t){return __async(this,null,(function*(){On(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}))}_clearTimeout(t){const e=__privateGet(this,He).get(t);e&&(e.timer&&clearTimeout(e.timer),__privateGet(this,He).delete(t))}_setTimeout(t,e){null==e&&(e=0);const n=__privateWrapper(this,je)._++,r=()=>{__privateGet(this,He).delete(n),t()};if(this.paused)__privateGet(this,He).set(n,{timer:null,func:r,time:e});else{const t=setTimeout(r,e);__privateGet(this,He).set(n,{timer:t,func:r,time:jh()})}return n}_forEachSubscriber(t){for(const e of __privateGet(this,Be).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Fh(t.type);case"block":{const t=new Ph(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Mh(this,t.type);case"event":return new Ih(this,t.filter);case"transaction":return new Bh(this,t.hash);case"orphan":return new Rh(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const n of __privateGet(this,Be).values())if(n.subscriber===t){n.started&&n.subscriber.stop(),n.subscriber=e,n.started&&e.start(),null!=__privateGet(this,Ge)&&e.pause(__privateGet(this,Ge));break}}on(t,e){return __async(this,null,(function*(){const n=yield __privateMethod(this,rn,sn).call(this,t);return n.listeners.push({listener:e,once:!1}),n.started||(n.subscriber.start(),n.started=!0,null!=__privateGet(this,Ge)&&n.subscriber.pause(__privateGet(this,Ge))),this}))}once(t,e){return __async(this,null,(function*(){const n=yield __privateMethod(this,rn,sn).call(this,t);return n.listeners.push({listener:e,once:!0}),n.started||(n.subscriber.start(),n.started=!0,null!=__privateGet(this,Ge)&&n.subscriber.pause(__privateGet(this,Ge))),this}))}emit(t,...e){return __async(this,null,(function*(){const n=yield __privateMethod(this,en,nn).call(this,t,e);if(!n||0===n.listeners.length)return!1;const r=n.listeners.length;return n.listeners=n.listeners.filter((({listener:n,once:r})=>{const i=new gr(this,r?null:n,t);try{n.call(this,...e,i)}catch(s){}return!r})),0===n.listeners.length&&(n.started&&n.subscriber.stop(),__privateGet(this,Be).delete(n.tag)),r>0}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,en,nn).call(this,t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of __privateGet(this,Be).values())e+=t.length;return e}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,en,nn).call(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of __privateGet(this,Be).values())e=e.concat(t.map((({listener:t})=>t)));return e}))}off(t,e){return __async(this,null,(function*(){const n=yield __privateMethod(this,en,nn).call(this,t);if(!n)return this;if(e){const t=n.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&n.listeners.splice(t,1)}return e&&0!==n.listeners.length||(n.started&&n.subscriber.stop(),__privateGet(this,Be).delete(n.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const{tag:e,started:n,subscriber:r}=yield __privateMethod(this,rn,sn).call(this,t);n&&r.stop(),__privateGet(this,Be).delete(e)}else for(const[t,{started:e,subscriber:n}]of __privateGet(this,Be))e&&n.stop(),__privateGet(this,Be).delete(t);return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return this.off(t,e)}))}get destroyed(){return __privateGet(this,Oe)}destroy(){this.removeAllListeners();for(const t of __privateGet(this,He).keys())this._clearTimeout(t);__privateSet(this,Oe,!0)}get paused(){return null!=__privateGet(this,Ge)}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(__privateSet(this,De,-1),null!=__privateGet(this,Ge)){if(__privateGet(this,Ge)==!!t)return;On(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),__privateSet(this,Ge,!!t);for(const e of __privateGet(this,He).values())e.timer&&clearTimeout(e.timer),e.time=jh()-e.time}resume(){if(null!=__privateGet(this,Ge)){this._forEachSubscriber((t=>t.resume())),__privateSet(this,Ge,null);for(const t of __privateGet(this,He).values()){let e=t.time;e<0&&(e=0),t.time=jh(),setTimeout(t.func,e)}}}}function Qh(t,e){try{const n=zh(t,e);if(n)return wr(n)}catch(n){}return null}function zh(t,e){if("0x"===t)return null;try{const n=cr(Zn(t,e,e+32)),r=cr(Zn(t,n,n+32));return Zn(t,n+32,n+32+r)}catch(n){}return null}function Vh(t){const e=hr(t);if(e.length>32)throw new Error("internal; should not happen");const n=new Uint8Array(32);return n.set(e,32-e.length),n}function Kh(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}Be=new WeakMap,Ie=new WeakMap,Ge=new WeakMap,Oe=new WeakMap,Le=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,De=new WeakMap,je=new WeakMap,He=new WeakMap,We=new WeakMap,Qe=new WeakMap,ze=new WeakSet,Ve=function(t){return __async(this,null,(function*(){const e=__privateGet(this,Qe).cacheTimeout;if(e<0)return yield this._perform(t);const n=Lh(t.method,t);let r=__privateGet(this,Ue).get(n);return r||(r=this._perform(t),__privateGet(this,Ue).set(n,r),setTimeout((()=>{__privateGet(this,Ue).get(n)===r&&__privateGet(this,Ue).delete(n)}),e)),yield r}))},Ke=new WeakSet,Je=function(t,e,n){return __async(this,null,(function*(){On(n<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const r=vu(t);try{return Kn(yield this._perform({method:"call",transaction:r,blockTag:e}))}catch(i){if(!this.disableCcipRead&&In(i)&&i.data&&n>=0&&"latest"===e&&null!=r.to&&"0x556f1830"===Zn(i.data,0,4)){const t=i.data,o=yield Zo(r.to,this);let a;try{a=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};On(qn(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const n=Zn(t,0,32);On(Zn(n,0,12)===Zn(Zh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Zn(n,12);try{const n=[],r=cr(Zn(t,32,64)),i=cr(Zn(t,r,r+32)),s=Zn(t,r+32);for(let t=0;t<i;t++){const e=Qh(s,32*t);if(null==e)throw new Error("abort");n.push(e)}e.urls=n}catch(i){On(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=zh(t,64);if(null==n)throw new Error("abort");e.calldata=n}catch(i){On(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}On(Zn(t,100,128)===Zn(Zh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Zn(t,96,100);try{const n=zh(t,128);if(null==n)throw new Error("abort");e.extraData=n}catch(i){On(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(Zn(i.data,4))}catch(s){On(!1,s.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:r,info:{data:t}})}On(a.sender.toLowerCase()===o.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:t,reason:"OffchainLookup",transaction:r,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:a.errorArgs}});const l=yield this.ccipReadFetch(r,a.calldata,a.urls);On(null!=l,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:r,info:{data:i.data,errorArgs:a.errorArgs}});const c={to:o,data:Jn([a.selector,qh([l,a.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=yield __privateMethod(this,Ke,Je).call(this,c,e,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},c),result:t}),t}catch(s){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},c),error:s}),s}}throw i}}))},qe=new WeakSet,Ze=function(t){return __async(this,null,(function*(){const{value:e}=yield Tn({network:this.getNetwork(),value:t});return e}))},Ye=new WeakSet,Xe=function(t,e,n){return __async(this,null,(function*(){let r=this._getAddress(e),i=this._getBlockTag(n);return"string"==typeof r&&"string"==typeof i||([r,i]=yield Promise.all([r,i])),yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,ze,Ve).call(this,Object.assign(t,{address:r,blockTag:i})))}))},$e=new WeakSet,tn=function(t,e){return __async(this,null,(function*(){if(Qn(t,32))return yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let n=this._getBlockTag(t);return"string"!=typeof n&&(n=yield n),yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockTag:n,includeTransactions:e})}))},en=new WeakSet,nn=function(t,e){return __async(this,null,(function*(){let n=yield Dh(t,this);return"event"===n.type&&e&&e.length>0&&!0===e[0].removed&&(n=yield Dh({orphan:"drop-log",log:e[0]},this)),__privateGet(this,Be).get(n.tag)||null}))},rn=new WeakSet,sn=function(t){return __async(this,null,(function*(){const e=yield Dh(t,this),n=e.tag;let r=__privateGet(this,Be).get(n);if(!r){r={subscriber:this._getSubscriber(e),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},__privateGet(this,Be).set(n,r)}return r}))};const Jh=new Uint8Array([]);function qh(t){const e=[];let n=0;for(let r=0;r<t.length;r++)e.push(Jh),n+=32;for(let r=0;r<t.length;r++){const i=Hn(t[r]);e[r]=Vh(n),e.push(Vh(i.length)),e.push(Kh(i)),n+=32+32*Math.ceil(i.length/32)}return Jn(e)}const Zh="0x0000000000000000000000000000000000000000000000000000000000000000";function Yh(t,e){if(t.provider)return t.provider;On(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}function Xh(t,e){return __async(this,null,(function*(){let n=vu(e);if(null!=n.to&&(n.to=Zo(n.to,t)),null!=n.from){const e=n.from;n.from=Promise.all([t.getAddress(),Zo(e,t)]).then((([t,e])=>(Ln(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else n.from=t.getAddress();return yield Tn(n)}))}class $h{constructor(t){__publicField(this,"provider"),Mn(this,{provider:t||null})}getNonce(t){return __async(this,null,(function*(){return Yh(this,"getTransactionCount").getTransactionCount(yield this.getAddress(),t)}))}populateCall(t){return __async(this,null,(function*(){return yield Xh(this,t)}))}populateTransaction(t){return __async(this,null,(function*(){const e=Yh(this,"populateTransaction"),n=yield Xh(this,t);null==n.nonce&&(n.nonce=yield this.getNonce("pending")),null==n.gasLimit&&(n.gasLimit=yield this.estimateGas(n));const r=yield this.provider.getNetwork();if(null!=n.chainId){Ln(sr(n.chainId)===r.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else n.chainId=r.chainId;const i=null!=n.maxFeePerGas||null!=n.maxPriorityFeePerGas;if(null==n.gasPrice||2!==n.type&&!i?0!==n.type&&1!==n.type||!i||Ln(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):Ln(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==n.type&&null!=n.type||null==n.maxFeePerGas||null==n.maxPriorityFeePerGas)if(0===n.type||1===n.type){const t=yield e.getFeeData();On(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==n.gasPrice&&(n.gasPrice=t.gasPrice)}else{const t=yield e.getFeeData();if(null==n.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(n.authorizationList&&n.authorizationList.length?n.type=4:n.type=2,null!=n.gasPrice){const t=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=t,n.maxPriorityFeePerGas=t}else null==n.maxFeePerGas&&(n.maxFeePerGas=t.maxFeePerGas),null==n.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(On(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==n.gasPrice&&(n.gasPrice=t.gasPrice),n.type=0):On(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==n.type&&3!==n.type&&4!==n.type||(null==n.maxFeePerGas&&(n.maxFeePerGas=t.maxFeePerGas),null==n.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else n.type=2;return yield Tn(n)}))}populateAuthorization(t){return __async(this,null,(function*(){const e=Object.assign({},t);return null==e.chainId&&(e.chainId=(yield Yh(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=yield this.getNonce()),e}))}estimateGas(t){return __async(this,null,(function*(){return Yh(this,"estimateGas").estimateGas(yield this.populateCall(t))}))}call(t){return __async(this,null,(function*(){return Yh(this,"call").call(yield this.populateCall(t))}))}resolveName(t){return __async(this,null,(function*(){const e=Yh(this,"resolveName");return yield e.resolveName(t)}))}sendTransaction(t){return __async(this,null,(function*(){const e=Yh(this,"sendTransaction"),n=yield this.populateTransaction(t);delete n.from;const r=Da.from(n);return yield e.broadcastTransaction(yield this.signTransaction(r))}))}authorize(t){On(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class td{constructor(t){__privateAdd(this,dn),__privateAdd(this,fn),__privateAdd(this,on,void 0),__privateAdd(this,an,void 0),__privateAdd(this,ln,void 0),__privateAdd(this,cn,void 0),__privateAdd(this,un,void 0),__privateAdd(this,hn,void 0),__privateSet(this,on,t),__privateSet(this,an,null),__privateSet(this,ln,__privateMethod(this,dn,pn).bind(this)),__privateSet(this,cn,!1),__privateSet(this,un,null),__privateSet(this,hn,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){__privateGet(this,cn)||(__privateSet(this,cn,!0),__privateMethod(this,dn,pn).call(this,-2))}stop(){__privateGet(this,cn)&&(__privateSet(this,cn,!1),__privateSet(this,hn,!0),__privateMethod(this,fn,gn).call(this),__privateGet(this,on).off("block",__privateGet(this,ln)))}pause(t){t&&__privateMethod(this,fn,gn).call(this),__privateGet(this,on).off("block",__privateGet(this,ln))}resume(){this.start()}}on=new WeakMap,an=new WeakMap,ln=new WeakMap,cn=new WeakMap,un=new WeakMap,hn=new WeakMap,dn=new WeakSet,pn=function(t){return __async(this,null,(function*(){try{null==__privateGet(this,an)&&__privateSet(this,an,this._subscribe(__privateGet(this,on)));let e=null;try{e=yield __privateGet(this,an)}catch(t){if(!Bn(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==e)return __privateSet(this,an,null),void __privateGet(this,on)._recoverSubscriber(this,this._recover(__privateGet(this,on)));const n=yield __privateGet(this,on).getNetwork();if(__privateGet(this,un)||__privateSet(this,un,n),__privateGet(this,un).chainId!==n.chainId)throw new Error("chaid changed");if(__privateGet(this,hn))return;const r=yield __privateGet(this,on).send("eth_getFilterChanges",[e]);yield this._emitResults(__privateGet(this,on),r)}catch(t){console.log("@TODO",t)}__privateGet(this,on).once("block",__privateGet(this,ln))}))},fn=new WeakSet,gn=function(){const t=__privateGet(this,an);t&&(__privateSet(this,an,null),t.then((t=>{__privateGet(this,on).destroyed||__privateGet(this,on).send("eth_uninstallFilter",[t])})))};class ed extends td{constructor(t,e){var n;super(t),__privateAdd(this,mn,void 0),__privateSet(this,mn,(n=e,JSON.parse(JSON.stringify(n))))}_recover(t){return new Ih(t,__privateGet(this,mn))}_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newFilter",[__privateGet(this,mn)])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const n of e)t.emit(__privateGet(this,mn),t._wrapLog(n,t._network))}))}}mn=new WeakMap;class nd extends td{_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newPendingTransactionFilter",[])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const n of e)t.emit("pending",n)}))}}const rd="bigint,boolean,function,number,string,symbol".split(/,/g);function id(t){if(null==t||rd.indexOf(typeof t)>=0)return t;if("function"==typeof t.getAddress)return t;if(Array.isArray(t))return t.map(id);if("object"==typeof t)return Object.keys(t).reduce(((e,n)=>(e[n]=t[n],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function sd(t){return new Promise((e=>{setTimeout(e,t)}))}function od(t){return t?t.toLowerCase():t}function ad(t){return t&&"number"==typeof t.pollingInterval}const ld={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class cd extends $h{constructor(t,e){super(t),__publicField(this,"address"),Mn(this,{address:e=Ko(e)})}connect(t){On(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}getAddress(){return __async(this,null,(function*(){return this.address}))}populateTransaction(t){return __async(this,null,(function*(){return yield this.populateCall(t)}))}sendUncheckedTransaction(t){return __async(this,null,(function*(){const e=id(t),n=[];if(e.from){const r=e.from;n.push((()=>__async(this,null,(function*(){const n=yield Zo(r,this.provider);Ln(null!=n&&n.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=n})))())}else e.from=this.address;if(null==e.gasLimit&&n.push((()=>__async(this,null,(function*(){e.gasLimit=yield this.provider.estimateGas(__spreadProps(__spreadValues({},e),{from:this.address}))})))()),null!=e.to){const t=e.to;n.push((()=>__async(this,null,(function*(){e.to=yield Zo(t,this.provider)})))())}n.length&&(yield Promise.all(n));const r=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[r])}))}sendTransaction(t){return __async(this,null,(function*(){const e=yield this.provider.getBlockNumber(),n=yield this.sendUncheckedTransaction(t);return yield new Promise(((t,r)=>{const i=[1e3,100];let s=0;const o=()=>__async(this,null,(function*(){try{const r=yield this.provider.getTransaction(n);if(null!=r)return void t(r.replaceableTransaction(e))}catch(a){if(Bn(a,"CANCELLED")||Bn(a,"BAD_DATA")||Bn(a,"NETWORK_ERROR")||Bn(a,"UNSUPPORTED_OPERATION"))return null==a.info&&(a.info={}),a.info.sendTransactionHash=n,void r(a);if(Bn(a,"INVALID_ARGUMENT")&&(s++,null==a.info&&(a.info={}),a.info.sendTransactionHash=n,s>10))return void r(a);this.provider.emit("error",Gn("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:a}))}this.provider._setTimeout((()=>{o()}),i.pop()||4e3)}));o()}))}))}signTransaction(t){return __async(this,null,(function*(){const e=id(t);if(e.from){const n=yield Zo(e.from,this.provider);Ln(null!=n&&n.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=n}else e.from=this.address;const n=this.provider.getRpcTransaction(e);return yield this.provider.send("eth_signTransaction",[n])}))}signMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?yr(t):t;return yield this.provider.send("personal_sign",[Kn(e),this.address.toLowerCase()])}))}signTypedData(t,e,n){return __async(this,null,(function*(){const r=id(n),i=yield uc.resolveNames(t,e,r,(t=>__async(this,null,(function*(){const e=yield Zo(t);return Ln(null!=e,"TypedData does not support null address","value",t),e}))));return yield this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(uc.getPayload(i.domain,e,i.value))])}))}unlock(t){return __async(this,null,(function*(){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}))}_legacySignMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?yr(t):t;return yield this.provider.send("eth_sign",[this.address.toLowerCase(),Kn(e)])}))}}_n=new WeakMap,yn=new WeakMap,wn=new WeakMap,vn=new WeakMap,bn=new WeakMap,An=new WeakMap,En=new WeakMap,xn=new WeakSet,kn=function(){if(__privateGet(this,vn))return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");__privateSet(this,vn,setTimeout((()=>{__privateSet(this,vn,null);const t=__privateGet(this,wn);for(__privateSet(this,wn,[]);t.length;){const e=[t.shift()];for(;t.length&&e.length!==__privateGet(this,_n).batchMaxCount;){e.push(t.shift());if(JSON.stringify(e.map((t=>t.payload))).length>__privateGet(this,_n).batchMaxSize){t.unshift(e.pop());break}}(()=>{__async(this,null,(function*(){const t=1===e.length?e[0].payload:e.map((t=>t.payload));this.emit("debug",{action:"sendRpcPayload",payload:t});try{const n=yield this._send(t);this.emit("debug",{action:"receiveRpcResult",result:n});for(const{resolve:t,reject:r,payload:i}of e){if(this.destroyed){r(Gn("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=n.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?r(this.getRpcError(i,e)):t(e.result);else{const t=Gn("missing response for request","BAD_DATA",{value:n,info:{payload:i}});this.emit("error",t),r(t)}}}catch(n){this.emit("debug",{action:"receiveRpcError",error:n});for(const{reject:t}of e)t(n)}}))})()}}),t))};let ud=class t extends Wh{constructor(t,e){super(t,e),__privateAdd(this,xn),__privateAdd(this,_n,void 0),__privateAdd(this,yn,void 0),__privateAdd(this,wn,void 0),__privateAdd(this,vn,void 0),__privateAdd(this,bn,void 0),__privateAdd(this,An,void 0),__privateAdd(this,En,void 0),__privateSet(this,yn,1),__privateSet(this,_n,Object.assign({},ld,e||{})),__privateSet(this,wn,[]),__privateSet(this,vn,null),__privateSet(this,An,null),__privateSet(this,En,null);{let t=null;const e=new Promise((e=>{t=e}));__privateSet(this,bn,{promise:e,resolve:t})}const n=this._getOption("staticNetwork");"boolean"==typeof n?(Ln(!n||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),n&&null!=t&&__privateSet(this,An,xh.from(t))):n&&(Ln(null==t||n.matches(t),"staticNetwork MUST match network object","options",e),__privateSet(this,An,n))}_getOption(t){return __privateGet(this,_n)[t]}get _network(){return On(__privateGet(this,An),"network is not available yet","NETWORK_ERROR"),__privateGet(this,An)}_perform(e){return __async(this,null,(function*(){if("call"===e.method||"estimateGas"===e.method){let t=e.transaction;if(t&&null!=t.type&&sr(t.type)&&null==t.maxFeePerGas&&null==t.maxPriorityFeePerGas){const n=yield this.getFeeData();null==n.maxFeePerGas&&null==n.maxPriorityFeePerGas&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}const n=this.getRpcRequest(e);return null!=n?yield this.send(n.method,n.args):__superGet(t.prototype,this,"_perform").call(this,e)}))}_detectNetwork(){return __async(this,null,(function*(){const t=this._getOption("staticNetwork");if(t){if(!0!==t)return t;if(__privateGet(this,An))return __privateGet(this,An)}return __privateGet(this,En)?yield __privateGet(this,En):this.ready?(__privateSet(this,En,(()=>__async(this,null,(function*(){try{const t=xh.from(sr(yield this.send("eth_chainId",[])));return __privateSet(this,En,null),t}catch(t){throw __privateSet(this,En,null),t}})))()),yield __privateGet(this,En)):(__privateSet(this,En,(()=>__async(this,null,(function*(){const t={id:__privateWrapper(this,yn)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};let e;this.emit("debug",{action:"sendRpcPayload",payload:t});try{e=(yield this._send(t))[0],__privateSet(this,En,null)}catch(n){throw __privateSet(this,En,null),this.emit("debug",{action:"receiveRpcError",error:n}),n}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return xh.from(sr(e.result));throw this.getRpcError(t,e)})))()),yield __privateGet(this,En))}))}_start(){null!=__privateGet(this,bn)&&null!=__privateGet(this,bn).resolve&&(__privateGet(this,bn).resolve(),__privateSet(this,bn,null),(()=>{__async(this,null,(function*(){for(;null==__privateGet(this,An)&&!this.destroyed;)try{__privateSet(this,An,yield 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",Gn("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),yield sd(1e3)}__privateMethod(this,xn,kn).call(this)}))})())}_waitUntilReady(){return __async(this,null,(function*(){if(null!=__privateGet(this,bn))return yield __privateGet(this,bn).promise}))}_getSubscriber(t){return"pending"===t.type?new nd(this):"event"===t.type?this._getOption("polling")?new Ih(this,t.filter):new ed(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new Fh("orphan"):super._getSubscriber(t)}get ready(){return null==__privateGet(this,bn)}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((n=>{if(null==t[n])return;let r=n;"gasLimit"===n&&(r="gas"),e[r]=dr(sr(t[n],`tx.${n}`))})),["from","to","data"].forEach((n=>{null!=t[n]&&(e[n]=Kn(t[n]))})),t.accessList&&(e.accessList=va(t.accessList)),t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.map((t=>t.toLowerCase()))),t.authorizationList&&(e.authorizationList=t.authorizationList.map((t=>{const e=ba(t);return{address:e.address,nonce:dr(e.nonce),chainId:dr(e.chainId),yParity:dr(e.signature.yParity),r:dr(e.signature.r),s:dr(e.signature.s)}}))),e}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:[od(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[od(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[od(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[od(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&&null!=t.filter.address&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(od):t.filter.address=od(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:n}=t,{error:r}=e;if("eth_estimateGas"===n&&r.message){const e=r.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return Gn("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:r}});if(e.match(/nonce/i)&&e.match(/too low/i))return Gn("nonce has already been used","NONCE_EXPIRED",{transaction:t.params[0],info:{payload:t,error:r}})}if("eth_call"===n||"eth_estimateGas"===n){const e=dd(r),i=lu.getBuiltinCallException("eth_call"===n?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:r,payload:t},i}const i=JSON.stringify(function(t){const e=[];return pd(t,e),e}(r));if("string"==typeof r.message&&r.message.match(/user denied|ethers-user-denied/i)){return Gn("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"}[n]||"unknown",reason:"rejected",info:{payload:t,error:r}})}if("eth_sendRawTransaction"===n||"eth_sendTransaction"===n){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Gn("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:r}});if(i.match(/nonce/i)&&i.match(/too low/i))return Gn("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:r}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Gn("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:r}});if(i.match(/only replay-protected/i))return Gn("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:n,info:{transaction:e,info:{error:r}}})}let s=!!i.match(/the method .* does not exist/i);return s||r&&r.details&&r.details.startsWith("Unauthorized method:")&&(s=!0),s?Gn("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:r,payload:t}}):Gn("could not coalesce error","UNKNOWN_ERROR",{error:r,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Gn("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const n=__privateWrapper(this,yn)._++,r=new Promise(((r,i)=>{__privateGet(this,wn).push({resolve:r,reject:i,payload:{method:t,params:e,id:n,jsonrpc:"2.0"}})}));return __privateMethod(this,xn,kn).call(this),r}getSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const n=yield e;if(t>=n.length)throw new Error("no such account");return new cd(this,n[t])}const{accounts:n}=yield Tn({network:this.getNetwork(),accounts:e});t=Ko(t);for(const r of n)if(Ko(r)===t)return new cd(this,t);throw new Error("invalid account")}))}listAccounts(){return __async(this,null,(function*(){return(yield this.send("eth_accounts",[])).map((t=>new cd(this,t)))}))}destroy(){__privateGet(this,vn)&&(clearTimeout(__privateGet(this,vn)),__privateSet(this,vn,null));for(const{payload:t,reject:e}of __privateGet(this,wn))e(Gn("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));__privateSet(this,wn,[]),super.destroy()}};class hd extends ud{constructor(t,e){super(t,e),__privateAdd(this,Sn,void 0);let n=this._getOption("pollingInterval");null==n&&(n=ld.pollingInterval),__privateSet(this,Sn,n)}_getSubscriber(t){const e=super._getSubscriber(t);return ad(e)&&(e.pollingInterval=__privateGet(this,Sn)),e}get pollingInterval(){return __privateGet(this,Sn)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");__privateSet(this,Sn,t),this._forEachSubscriber((t=>{ad(t)&&(t.pollingInterval=__privateGet(this,Sn))}))}}function dd(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&Qn(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const n=dd(t[e]);if(n)return n}return null}if("string"==typeof t)try{return dd(JSON.parse(t))}catch(e){}return null}function pd(t,e){if(null!=t){if("string"==typeof t.message&&e.push(t.message),"object"==typeof t)for(const n in t)pd(t[n],e);if("string"==typeof t)try{return pd(JSON.parse(t),e)}catch(n){}}}Sn=new WeakMap;Nn=new WeakMap,Cn=new WeakMap;let fd=class t extends hd{constructor(t,e,n){const r=Object.assign({},null!=n?n:{},{batchMaxCount:1});Ln(t&&t.request,"invalid EIP-1193 provider","ethereum",t),super(e,r),__privateAdd(this,Nn,void 0),__privateAdd(this,Cn,void 0),__privateSet(this,Cn,null),n&&n.providerInfo&&__privateSet(this,Cn,n.providerInfo),__privateSet(this,Nn,((e,n)=>__async(this,null,(function*(){const r={method:e,params:n};this.emit("debug",{action:"sendEip1193Request",payload:r});try{const e=yield t.request(r);return this.emit("debug",{action:"receiveEip1193Result",result:e}),e}catch(i){const t=new Error(i.message);throw t.code=i.code,t.data=i.data,t.payload=r,this.emit("debug",{action:"receiveEip1193Error",error:t}),t}}))))}get providerInfo(){return __privateGet(this,Cn)}send(e,n){return __async(this,null,(function*(){return yield this._start(),yield __superGet(t.prototype,this,"send").call(this,e,n)}))}_send(t){return __async(this,null,(function*(){Ln(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const e=yield __privateGet(this,Nn).call(this,t.method,t.params||[]);return[{id:t.id,result:e}]}catch(e){return[{id:t.id,error:{code:e.code,data:e.data,message:e.message}}]}}))}getRpcError(t,e){switch((e=JSON.parse(JSON.stringify(e))).error.code||-1){case 4001:e.error.message=`ethers-user-denied: ${e.error.message}`;break;case 4200:e.error.message=`ethers-unsupported: ${e.error.message}`}return super.getRpcError(t,e)}hasSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=yield this.send("eth_accounts",[]);return"number"==typeof t?e.length>t:(t=t.toLowerCase(),0!==e.filter((e=>e.toLowerCase()===t)).length)}))}getSigner(e){return __async(this,null,(function*(){if(null==e&&(e=0),!(yield this.hasSigner(e)))try{yield __privateGet(this,Nn).call(this,"eth_requestAccounts",[])}catch(n){const t=n.payload;throw this.getRpcError(t,{id:t.id,error:n})}return yield __superGet(t.prototype,this,"getSigner").call(this,e)}))}static discover(e){return __async(this,null,(function*(){if(null==e&&(e={}),e.provider)return new t(e.provider);const n=e.window?e.window:"undefined"!=typeof window?window:null;if(null==n)return null;const r=e.anyProvider;if(r&&n.ethereum)return new t(n.ethereum);if(!("addEventListener"in n&&"dispatchEvent"in n&&"removeEventListener"in n))return null;const i=e.timeout?e.timeout:300;return 0===i?null:yield new Promise(((s,o)=>{let a=[];const l=t=>{a.push(t.detail),r&&c()},c=()=>{if(clearTimeout(u),a.length)if(e&&e.filter){const n=e.filter(a.map((t=>Object.assign({},t.info))));if(null==n)s(null);else if(n instanceof t)s(n);else{let e=null;if(n.uuid){e=a.filter((t=>n.uuid===t.info.uuid))[0]}if(e){const{provider:n,info:r}=e;s(new t(n,void 0,{providerInfo:r}))}else o(Gn("filter returned unknown info","UNSUPPORTED_OPERATION",{value:n}))}}else{const{provider:e,info:n}=a[0];s(new t(e,void 0,{providerInfo:n}))}else s(null);n.removeEventListener("eip6963:announceProvider",l)},u=setTimeout((()=>{c()}),i);n.addEventListener("eip6963:announceProvider",l),n.dispatchEvent(new Event("eip6963:requestProvider"))}))}))}};const gd={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trustwallet",LUTE:"lute"},md={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},_d={[md.ETHEREUM]:{name:"Ethereum Mainnet",chainId:1,symbol:"ETH",decimals:18,rpcUrl:"https://mainnet.infura.io/v3/your-infura-key",blockExplorerUrl:"https://etherscan.io"},[md.BSC]:{name:"Binance Smart Chain",chainId:56,symbol:"BNB",decimals:18,rpcUrl:"https://bsc-dataseed.binance.org/",blockExplorerUrl:"https://bscscan.com"},[md.TRON]:{name:"TRON Mainnet",symbol:"TRX",decimals:6,rpcUrl:"https://api.trongrid.io",blockExplorerUrl:"https://tronscan.org"},[md.ALGORAND]:{name:"Algorand Mainnet",symbol:"ALGO",decimals:6,rpcUrl:"https://mainnet-api.algonode.cloud",blockExplorerUrl:"https://algoexplorer.io"}},yd={USDT:{ethereum:{contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,symbol:"USDT"},bsc:{contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,symbol:"USDT"},tron:{contractAddress:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",decimals:6,symbol:"USDT"},algorand:{assetId:312769,decimals:6,symbol:"USDT"}},USDC:{ethereum:{contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,symbol:"USDC"},bsc:{contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,symbol:"USDC"},tron:{contractAddress:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",decimals:6,symbol:"USDC"},algorand:{assetId:31566704,decimals:6,symbol:"USDC"}},BNB:{bsc:{decimals:18,symbol:"BNB",isNative:!0}},ETH:{ethereum:{decimals:18,symbol:"ETH",isNative:!0}},TRX:{tron:{decimals:6,symbol:"TRX",isNative:!0}},ALGO:{algorand:{decimals:6,symbol:"ALGO",isNative:!0}}},wd={[md.ETHEREUM]:[gd.METAMASK,gd.TRUST_WALLET],[md.BSC]:[gd.METAMASK,gd.TRUST_WALLET],[md.TRON]:[gd.TRONLINK],[md.ALGORAND]:[gd.LUTE]},vd=t=>({[gd.METAMASK]:"https://metamask.io/download/",[gd.TRONLINK]:"https://www.tronlink.org/download/",[gd.TRUST_WALLET]:"https://trustwallet.com/download/",[gd.LUTE]:"https://lute.app/download/"}[t]||""),bd=()=>{if("undefined"==typeof window)return!1;return[()=>void 0!==window.lute,()=>void 0!==window.algorand,()=>void 0!==window.AlgoSigner,()=>void 0!==window.luteWallet,()=>null!==document.querySelector('[data-wallet="lute"]'),()=>window.postMessage&&"true"===document.documentElement.getAttribute("data-lute-extension")].some((t=>{try{return t()}catch(e){return console.warn("Lute detection method failed:",e),!1}}))},Ad=()=>{const t={[gd.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum&&window.ethereum.isMetaMask,[gd.TRONLINK]:"undefined"!=typeof window&&void 0!==window.tronWeb,[gd.TRUST_WALLET]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isTrust,[gd.LUTE]:bd()};return"undefined"!=typeof window&&(console.log("=== LUTE WALLET DETECTION DEBUG ==="),console.log("window.lute:",Boolean(window.lute)),console.log("window.algorand:",Boolean(window.algorand)),console.log("window.AlgoSigner:",Boolean(window.AlgoSigner)),console.log("window.luteWallet:",Boolean(window.luteWallet)),console.log("Lute detected overall:",t[gd.LUTE]),console.log("=== END LUTE DETECTION DEBUG ===")),t},Ed=(t=5,e=1e3)=>__async(this,null,(function*(){let n=0,r=Ad();for(;n<t;){r=Ad();if(Object.values(r).some((t=>!0===t))||n>=t-1)break;console.log(`Wallet detection attempt ${n+1}/${t}...`),console.log("Current detection results:",r),yield new Promise((t=>setTimeout(t,e))),n++}if(!r[gd.LUTE]&&(console.log("Performing extended Lute wallet detection..."),"undefined"!=typeof window))try{const t=new CustomEvent("lute-wallet-detect",{detail:{source:"coinley-sdk"}});window.dispatchEvent(t),yield new Promise((t=>setTimeout(t,500))),r[gd.LUTE]=bd()}catch(i){console.warn("Extended Lute detection failed:",i)}return console.log("Final wallet detection results:",r),r})),xd=()=>__async(this,null,(function*(){if(console.log("Connecting to MetaMask wallet..."),!window.ethereum||!window.ethereum.isMetaMask)throw console.error("MetaMask not found."),new Error("MetaMask not detected. Please install MetaMask extension.");try{const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],n=yield window.ethereum.request({method:"eth_chainId"}),r=parseInt(n,16);let i;switch(r){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${r}`}const s=new fd(window.ethereum);return{walletType:gd.METAMASK,address:e,provider:s,network:i,isConnected:!0,chainId:r}}catch(t){throw console.error("Error connecting to MetaMask:",t),t}})),kd=()=>__async(this,null,(function*(){if(console.log("Connecting to Trust Wallet..."),!window.ethereum||!window.ethereum.isTrust)throw console.error("Trust Wallet not found."),new Error("Trust Wallet not detected. Please install Trust Wallet.");try{const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],n=yield window.ethereum.request({method:"eth_chainId"}),r=parseInt(n,16);let i;switch(r){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${r}`}const s=new fd(window.ethereum);return{walletType:gd.TRUST_WALLET,address:e,provider:s,network:i,isConnected:!0,chainId:r}}catch(t){throw console.error("Error connecting to Trust Wallet:",t),t}})),Sd=()=>__async(this,null,(function*(){if(console.log("Connecting to TronLink wallet..."),!window.tronWeb)throw console.error("TronWeb not found. Is TronLink installed?"),new Error("TronLink not detected. Please install TronLink extension.");const t=(t=10,e=500)=>__async(this,null,(function*(){for(let n=0;n<t;n++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${n+1}/${t}`),yield new Promise((t=>setTimeout(t,e)))}throw new Error("TronWeb took too long to be ready")}));try{const n=yield t();if(!n.defaultAddress||!n.defaultAddress.base58)try{yield window.tronWeb.request({method:"tron_requestAccounts"})}catch(e){throw console.error("Failed to get permission from TronLink:",e),new Error("Please unlock TronLink and approve connection")}const r=n.defaultAddress.base58;return console.log("Connected to TronLink wallet:",r),{walletType:gd.TRONLINK,address:r,provider:n,network:md.TRON,isConnected:!0}}catch(n){throw console.error("Error connecting to TronLink:",n),n}})),Nd=()=>__async(this,null,(function*(){var t;console.log("Connecting to Lute wallet...");let e=null,n="";if(window.lute?(e=window.lute,n="Lute"):window.algorand?(e=window.algorand,n="Algorand Provider"):window.AlgoSigner?(e=window.AlgoSigner,n="AlgoSigner"):window.luteWallet&&(e=window.luteWallet,n="Lute Wallet"),!e)throw console.error("No Algorand wallet detected."),console.log("Available window properties:",Object.keys(window).filter((t=>t.toLowerCase().includes("lute")||t.toLowerCase().includes("algo")||t.toLowerCase().includes("wallet")))),new Error("Lute wallet not detected. Please install Lute extension or another Algorand wallet.");console.log(`Found ${n} wallet provider:`,e);try{let r=null;if(e.connect){console.log("Using connect() method...");const t=yield e.connect();r=t.address||t}else if(e.enable){console.log("Using enable() method...");const t=yield e.enable();r=t[0]||t}else if(e.requestAccounts){console.log("Using requestAccounts() method...");r=(yield e.requestAccounts())[0]}else if(e.connect&&"AlgoSigner"===n){console.log("Using AlgoSigner connect..."),yield e.connect();r=null==(t=(yield e.accounts({ledger:"MainNet"}))[0])?void 0:t.address}if(!r)throw new Error(`No address returned from ${n}. Please unlock your wallet and try again.`);return console.log(`Connected to ${n} wallet:`,r),{walletType:gd.LUTE,address:r,provider:e,network:md.ALGORAND,isConnected:!0,walletName:n}}catch(r){throw console.error(`Error connecting to ${n}:`,r),r.message&&r.message.includes("User rejected")?new Error("Connection rejected by user. Please approve the connection in your wallet."):r.message&&r.message.includes("locked")?new Error("Wallet is locked. Please unlock your wallet and try again."):new Error(`Failed to connect to ${n}: ${r.message||"Unknown error"}`)}})),Cd=t=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",t),t){case gd.METAMASK:return xd();case gd.TRONLINK:return Sd();case gd.TRUST_WALLET:return kd();case gd.LUTE:return Nd();default:throw new Error(`Unsupported wallet type: ${t}`)}})),Pd=t=>wd[t]||[],Td=(t,e,n)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:e,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");try{let r;switch(t.walletType){case gd.METAMASK:case gd.TRUST_WALLET:const i=t.provider,s=yield i.getSigner(),o=n.toString(),a=ii(o,18);console.log("Sending ETH/BNB:",{to:e,value:a.toString()});const l=yield i.estimateGas({to:e,value:a,from:yield s.getAddress()});console.log("Gas estimate:",l.toString());const c=l*BigInt(110)/BigInt(100);console.log("Using gas limit:",c.toString()),r=yield s.sendTransaction({to:e,value:a,gasLimit:c});break;case gd.TRONLINK:const u=t.provider;if(!u||!u.ready)throw new Error("TronWeb not initialized");const h=u.toSun(n.toString());console.log("Sending TRX:",{to:e,value:h}),r=yield u.trx.sendTransaction(e,h);break;case gd.LUTE:const d=t.provider,p=Math.floor(1e6*parseFloat(n));if(console.log("Sending Algos:",{to:e,amount:p,walletName:t.walletName}),d.sendPayment)r=yield d.sendPayment({recipient:e,amount:p});else{if(!d.signTransaction)throw new Error(`Unsupported Algorand wallet API for ${t.walletName}`);{const t={to:e,fee:1e3,amount:p,firstRound:1e3,lastRound:2e3,type:"pay"};r=yield d.signTransaction(t)}}break;default:throw new Error(`Unsupported wallet type: ${t.walletType}`)}console.log("Transaction sent:",r);const i=r.hash||r.txID||r.txId||r;return console.log("Transaction hash:",i),i}catch(r){throw console.error("Native transaction error:",r),r}})),Md=(t,e)=>__async(this,null,(function*(){var n;if(console.log("Sending transaction with:",e),!t)throw new Error("Wallet not connected");const{to:r,amount:i,tokenAddress:s,currency:o,network:a}=e;if(!r)throw new Error("Recipient address not provided");const l=null==(n=yd[o])?void 0:n[a];return l&&l.isNative?Td(t,r,i):l?Rd(t,l,r,i):Td(t,r,i)})),Rd=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending token transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Token configuration not provided");if(!n)throw new Error("Recipient address not provided");if(!r||isNaN(parseFloat(r))||parseFloat(r)<=0)throw new Error("Invalid amount");const{contractAddress:i,decimals:s,symbol:o}=e;switch(console.log(`Token: ${o}, Decimals: ${s}, Contract: ${i}`),t.walletType){case gd.TRONLINK:return Id(t,e,n,r);case gd.LUTE:return Gd(t,e,n,r);default:return Bd(t,e,n,r)}})),Bd=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending ERC20/BEP20 transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");const i=t.provider,s=yield i.getSigner(),{contractAddress:o,decimals:a,symbol:l}=e,c=parseFloat(r),u=parseInt(a),h=ii(c.toString(),u);console.log(`Sending ${c} ${l} (${h.toString()} base units) to ${n}`),console.log("Token config:",{contractAddress:o,decimals:a,symbol:l});try{const t=new eh(o,["function transfer(address to, uint256 amount) returns (bool)","function balanceOf(address owner) view returns (uint256)","function decimals() view returns (uint8)"],s),e=yield s.getAddress(),r=yield t.balanceOf(e);if(console.log(`User ${l} balance:`,ri(r,a)),r<h)throw new Error(`Insufficient ${l} balance. Required: ${c}, Available: ${ri(r,a)}`);try{const e=yield t.transfer.estimateGas(n,h);let r;console.log("Gas estimate:",e.toString()),r="USDC"===l?BigInt(150):"USDT"===l?BigInt(130):BigInt(120);const i=e*r/BigInt(100);console.log("Using gas limit:",i.toString());const s=yield t.transfer(n,h,{gasLimit:i});return console.log("Transaction sent:",s),s.hash}catch(d){let e;console.error("Gas estimation failed:",d),e="USDC"===l?BigInt(2e5):"USDT"===l?BigInt(18e4):BigInt(15e4),console.log(`Trying ${l} transaction with fixed gas limit:`,e.toString());const r=yield t.transfer(n,h,{gasLimit:e});return console.log("Transaction sent with fixed gas limit:",r),r.hash}}catch(p){throw console.error("ERC20 transaction error:",p),p.message&&p.message.includes("user rejected")?new Error("Transaction rejected by user"):p.message&&p.message.includes("insufficient funds")?new Error("Insufficient funds for transaction"):(p.message&&p.message.includes("Insufficient"),p)}})),Id=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending TRC20 transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Tron wallet not connected");const i=t.provider;if(!i||!i.ready)throw new Error("TronWeb not initialized");if(!e||!e.contractAddress)throw new Error("Invalid token configuration");const{contractAddress:s,decimals:o,symbol:a}=e,l=parseFloat(r),c=parseInt(o),u=(l*Math.pow(10,c)).toString();console.log(`Sending ${l} ${a} (${u} base units) to ${n}`);try{const t=yield i.contract().at(s);if(!t.transfer)throw new Error("Invalid TRC-20 contract");const e=yield t.transfer(n,u).send({feeLimit:1e8,callValue:0,shouldPollResponse:!1});return console.log("TRC20 transaction sent:",e),e}catch(h){throw console.error("TRC20 transaction failed:",h),h.message&&h.message.includes("User rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("bandwidth")?new Error("Insufficient energy or bandwidth. Make sure you have enough TRX for fees."):h.message&&h.message.includes("balance")?new Error("Insufficient token balance for transfer"):new Error(`Transaction failed: ${h.message||"Unknown error"}`)}})),Gd=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending Algorand asset transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Algorand wallet not connected");const i=t.provider;if(!e||!e.assetId)throw new Error("Invalid token configuration - missing assetId");const{assetId:s,decimals:o,symbol:a}=e,l=parseFloat(r),c=parseInt(o),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${a} (${u} base units) to ${n}`),console.log(`Using wallet: ${t.walletName||"Unknown"}`);try{let e;if(i.sendAssetTransfer)console.log("Using sendAssetTransfer method..."),e=yield i.sendAssetTransfer({recipient:n,assetId:s,amount:u});else{if(!i.signTransaction)throw new Error(`Unsupported Algorand wallet API for asset transfers in ${t.walletName||"this wallet"}`);{console.log("Using signTransaction method for asset transfer...");const r={type:"axfer",from:t.address,to:n,amount:u,assetIndex:s,fee:1e3,firstRound:1e3,lastRound:2e3};e=yield i.signTransaction(r)}}return console.log("Algorand asset transaction sent:",e),e.txId||e.txID||e}catch(h){throw console.error("Algorand asset transaction error:",h),h.message&&h.message.includes("rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("balance")?new Error("Insufficient asset balance"):h.message&&h.message.includes("opted")?new Error("Account not opted in to this asset. Please opt in first."):h}}));let Od={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{},authToken:null};const Ld=t=>__async(this,null,(function*(){Od=__spreadValues(__spreadValues({},Od),t),console.log("API initialized with:",{apiUrl:Od.apiUrl,apiKey:Od.apiKey?`${Od.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Od.merchantWalletAddresses||{}).length>0});try{yield Fd()}catch(e){console.error("Failed to fetch merchant wallets during initialization:",e)}})),Fd=()=>__async(this,null,(function*(){try{console.log("Authenticating and fetching merchant wallets...");const t=btoa(`${Od.apiKey}:${Od.apiSecret}`),e=yield fetch(`${Od.apiUrl}/api/merchants/dashboard`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,"x-api-key":Od.apiKey,"x-api-secret":Od.apiSecret}});if(e.ok){const t=yield e.json();if(console.log("Merchant dashboard data received:",t),t.merchant){const e={};return t.merchant.walletAddress&&(e.ethereum=t.merchant.walletAddress),t.merchant.solWalletAddress&&(e.solana=t.merchant.solWalletAddress),t.merchant.merchantWallets&&Object.assign(e,t.merchant.merchantWallets),Od.merchantWalletAddresses=e,console.log("Merchant wallet addresses retrieved:",e),e}}else console.error("Failed to fetch merchant dashboard:",e.status)}catch(t){console.error("Error fetching merchant wallets:",t)}return{}})),Ud=()=>__async(this,null,(function*(){return 0===Object.keys(Od.merchantWalletAddresses).length&&(yield Fd()),Od.merchantWalletAddresses})),Dd=()=>({"Content-Type":"application/json","x-api-key":Od.apiKey,"x-api-secret":Od.apiSecret,Authorization:Od.authToken?`Bearer ${Od.authToken}`:void 0}),jd=t=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",t),!t.amount)throw new Error("Payment amount is required");const n=yield Ud();console.log("Using merchant wallets:",n);const r=__spreadProps(__spreadValues({},t),{merchantWalletAddresses:__spreadValues(__spreadValues({},n),t.merchantWalletAddresses)});console.log("Enhanced payment data:",r);const i=yield fetch(`${Od.apiUrl}/api/payments/create`,{method:"POST",headers:Dd(),body:JSON.stringify(r)});if(console.log("Create payment response status:",i.status),!i.ok){let t;try{t=yield i.json()}catch(e){throw new Error(`Failed to create payment: ${i.status} ${i.statusText}`)}throw console.error("Error creating payment:",t),new Error(t.error||`Failed to create payment: ${i.status}`)}const s=yield i.json();return console.log("Payment created successfully:",s),s}catch(n){throw console.error("Create payment error:",n),n}})),Hd=t=>__async(this,null,(function*(){try{if(console.log("Processing payment with data:",t),!t.paymentId)throw new Error("Payment ID is required");if(!t.transactionHash)throw new Error("Transaction hash is required");const n=yield fetch(`${Od.apiUrl}/api/payments/process`,{method:"POST",headers:Dd(),body:JSON.stringify(t)});if(console.log("Process payment response status:",n.status),!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to process payment: ${n.status} ${n.statusText}`)}throw console.error("Error processing payment:",t),new Error(t.error||`Failed to process payment: ${n.status}`)}const r=yield n.json();return console.log("Process payment response data:",r),r}catch(n){throw console.error("Process payment error:",n),n}}));var Wd={exports:{}},Qd={},zd=e,Vd=Symbol.for("react.element"),Kd=Symbol.for("react.fragment"),Jd=Object.prototype.hasOwnProperty,qd=zd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Zd={key:!0,ref:!0,__self:!0,__source:!0};function Yd(t,e,n){var r,i={},s=null,o=null;for(r in void 0!==n&&(s=""+n),void 0!==e.key&&(s=""+e.key),void 0!==e.ref&&(o=e.ref),e)Jd.call(e,r)&&!Zd.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps)void 0===i[r]&&(i[r]=e[r]);return{$$typeof:Vd,type:t,key:s,ref:o,props:i,_owner:qd.current}}Qd.Fragment=Kd,Qd.jsx=Yd,Qd.jsxs=Yd,Wd.exports=Qd;var Xd=Wd.exports;const $d=e.createContext(),tp=e.createContext(),ep=()=>e.useContext(tp);var np,rp,ip=Object.defineProperty,sp=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,lp=(t,e,n)=>e in t?ip(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,cp=(t,e)=>{for(var n in e||(e={}))op.call(e,n)&&lp(t,n,e[n]);if(sp)for(var n of sp(e))ap.call(e,n)&&lp(t,n,e[n]);return t},up=(t,e)=>{var n={};for(var r in t)op.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&sp)for(var r of sp(t))e.indexOf(r)<0&&ap.call(t,r)&&(n[r]=t[r]);return n};(t=>{const e=class e{constructor(t,n,r,s){if(this.version=t,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version value out of range");if(s<-1||s>7)throw new RangeError("Mask value out of range");this.size=4*t+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();const a=this.addEccAndInterleave(r);if(this.drawCodewords(a),-1==s){let t=1e9;for(let e=0;e<8;e++){this.applyMask(e),this.drawFormatBits(e);const n=this.getPenaltyScore();n<t&&(s=e,t=n),this.applyMask(e)}}i(0<=s&&s<=7),this.mask=s,this.applyMask(s),this.drawFormatBits(s),this.isFunction=[]}static encodeText(n,r){const i=t.QrSegment.makeSegments(n);return e.encodeSegments(i,r)}static encodeBinary(n,r){const i=t.QrSegment.makeBytes(n);return e.encodeSegments([i],r)}static encodeSegments(t,r,s=1,a=40,l=-1,c=!0){if(!(e.MIN_VERSION<=s&&s<=a&&a<=e.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,h;for(u=s;;u++){const n=8*e.getNumDataCodewords(u,r),i=o.getTotalBits(t,u);if(i<=n){h=i;break}if(u>=a)throw new RangeError("Data too long")}for(const n of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])c&&h<=8*e.getNumDataCodewords(u,n)&&(r=n);let d=[];for(const e of t){n(e.mode.modeBits,4,d),n(e.numChars,e.mode.numCharCountBits(u),d);for(const t of e.getData())d.push(t)}i(d.length==h);const p=8*e.getNumDataCodewords(u,r);i(d.length<=p),n(0,Math.min(4,p-d.length),d),n(0,(8-d.length%8)%8,d),i(d.length%8==0);for(let e=236;d.length<p;e^=253)n(e,8,d);let f=[];for(;8*f.length<d.length;)f.push(0);return d.forEach(((t,e)=>f[e>>>3]|=t<<7-(7&e))),new e(u,r,f,l)}getModule(t,e){return 0<=t&&t<this.size&&0<=e&&e<this.size&&this.modules[e][t]}getModules(){return this.modules}drawFunctionPatterns(){for(let n=0;n<this.size;n++)this.setFunctionModule(6,n,n%2==0),this.setFunctionModule(n,6,n%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),e=t.length;for(let n=0;n<e;n++)for(let r=0;r<e;r++)0==n&&0==r||0==n&&r==e-1||n==e-1&&0==r||this.drawAlignmentPattern(t[n],t[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.errorCorrectionLevel.formatBits<<3|t;let n=e;for(let r=0;r<10;r++)n=n<<1^1335*(n>>>9);const s=21522^(e<<10|n);i(s>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,r(s,i));this.setFunctionModule(8,7,r(s,6)),this.setFunctionModule(8,8,r(s,7)),this.setFunctionModule(7,8,r(s,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,r(s,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,r(s,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,r(s,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let n=0;n<12;n++)t=t<<1^7973*(t>>>11);const e=this.version<<12|t;i(e>>>18==0);for(let n=0;n<18;n++){const t=r(e,n),i=this.size-11+n%3,s=Math.floor(n/3);this.setFunctionModule(i,s,t),this.setFunctionModule(s,i,t)}}drawFinderPattern(t,e){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){const i=Math.max(Math.abs(r),Math.abs(n)),s=t+r,o=e+n;0<=s&&s<this.size&&0<=o&&o<this.size&&this.setFunctionModule(s,o,2!=i&&4!=i)}}drawAlignmentPattern(t,e){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(t+r,e+n,1!=Math.max(Math.abs(r),Math.abs(n)))}setFunctionModule(t,e,n){this.modules[e][t]=n,this.isFunction[e][t]=!0}addEccAndInterleave(t){const n=this.version,r=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(n,r))throw new RangeError("Invalid argument");const s=e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],a=Math.floor(e.getNumRawDataModules(n)/8),l=s-a%s,c=Math.floor(a/s);let u=[];const h=e.reedSolomonComputeDivisor(o);for(let i=0,p=0;i<s;i++){let n=t.slice(p,p+c-o+(i<l?0:1));p+=n.length;const r=e.reedSolomonComputeRemainder(n,h);i<l&&n.push(0),u.push(n.concat(r))}let d=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-o||n>=l)&&d.push(t[e])}));return i(d.length==a),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let e=this.size-1;e>=1;e-=2){6==e&&(e=5);for(let i=0;i<this.size;i++)for(let s=0;s<2;s++){const o=e-s,a=!(e+1&2)?this.size-1-i:i;!this.isFunction[a][o]&&n<8*t.length&&(this.modules[a][o]=r(t[n>>>3],7-(7&n)),n++)}}i(n==8*t.length)}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let n=0;n<this.size;n++){let r;switch(t){case 0:r=(n+e)%2==0;break;case 1:r=e%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+e)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(e/2))%2==0;break;case 5:r=n*e%2+n*e%3==0;break;case 6:r=(n*e%2+n*e%3)%2==0;break;case 7:r=((n+e)%2+n*e%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[e][n]&&r&&(this.modules[e][n]=!this.modules[e][n])}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let n=!1,r=0,s=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[i][o]==n?(r++,5==r?t+=e.PENALTY_N1:r>5&&t++):(this.finderPenaltyAddHistory(r,s),n||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),n=this.modules[i][o],r=1);t+=this.finderPenaltyTerminateAndCount(n,r,s)*e.PENALTY_N3}for(let i=0;i<this.size;i++){let n=!1,r=0,s=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][i]==n?(r++,5==r?t+=e.PENALTY_N1:r>5&&t++):(this.finderPenaltyAddHistory(r,s),n||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),n=this.modules[o][i],r=1);t+=this.finderPenaltyTerminateAndCount(n,r,s)*e.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let n=0;n<this.size-1;n++){const r=this.modules[i][n];r==this.modules[i][n+1]&&r==this.modules[i+1][n]&&r==this.modules[i+1][n+1]&&(t+=e.PENALTY_N2)}let n=0;for(const e of this.modules)n=e.reduce(((t,e)=>t+(e?1:0)),n);const r=this.size*this.size,s=Math.ceil(Math.abs(20*n-10*r)/r)-1;return i(0<=s&&s<=9),t+=s*e.PENALTY_N4,i(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(1==this.version)return[];{const t=Math.floor(this.version/7)+2,e=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*t-2));let n=[6];for(let r=this.size-7;n.length<t;r-=e)n.splice(1,0,r);return n}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(t,n){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let n=[];for(let e=0;e<t-1;e++)n.push(0);n.push(1);let r=1;for(let i=0;i<t;i++){for(let t=0;t<n.length;t++)n[t]=e.reedSolomonMultiply(n[t],r),t+1<n.length&&(n[t]^=n[t+1]);r=e.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(t,n){let r=n.map((t=>0));for(const i of t){const t=i^r.shift();r.push(0),n.forEach(((n,i)=>r[i]^=e.reedSolomonMultiply(n,t)))}return r}static reedSolomonMultiply(t,e){if(t>>>8!=0||e>>>8!=0)throw new RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^285*(n>>>7),n^=(e>>>r&1)*t;return i(n>>>8==0),n}finderPenaltyCountPatterns(t){const e=t[1];i(e<=3*this.size);const n=e>0&&t[2]==e&&t[3]==3*e&&t[4]==e&&t[5]==e;return(n&&t[0]>=4*e&&t[6]>=e?1:0)+(n&&t[6]>=4*e&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,n){return t&&(this.finderPenaltyAddHistory(e,n),e=0),e+=this.size,this.finderPenaltyAddHistory(e,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(t,e){0==e[0]&&(t+=this.size),e.pop(),e.unshift(t)}};function n(t,e,n){if(e<0||e>31||t>>>e!=0)throw new RangeError("Value out of range");for(let r=e-1;r>=0;r--)n.push(t>>>r&1)}function r(t,e){return!!(t>>>e&1)}function i(t){if(!t)throw new Error("Assertion error")}e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=e;const s=class t{constructor(t,e,n){if(this.mode=t,this.numChars=e,this.bitData=n,e<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}static makeBytes(e){let r=[];for(const t of e)n(t,8,r);return new t(t.Mode.BYTE,e.length,r)}static makeNumeric(e){if(!t.isNumeric(e))throw new RangeError("String contains non-numeric characters");let r=[];for(let t=0;t<e.length;){const i=Math.min(e.length-t,3);n(parseInt(e.substring(t,t+i),10),3*i+1,r),t+=i}return new t(t.Mode.NUMERIC,e.length,r)}static makeAlphanumeric(e){if(!t.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let r,i=[];for(r=0;r+2<=e.length;r+=2){let s=45*t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r));s+=t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r+1)),n(s,11,i)}return r<e.length&&n(t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r)),6,i),new t(t.Mode.ALPHANUMERIC,e.length,i)}static makeSegments(e){return""==e?[]:t.isNumeric(e)?[t.makeNumeric(e)]:t.isAlphanumeric(e)?[t.makeAlphanumeric(e)]:[t.makeBytes(t.toUtf8ByteArray(e))]}static makeEci(e){let r=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)n(e,8,r);else if(e<16384)n(2,2,r),n(e,14,r);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");n(6,3,r),n(e,21,r)}return new t(t.Mode.ECI,0,r)}static isNumeric(e){return t.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return t.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(t,e){let n=0;for(const r of t){const t=r.mode.numCharCountBits(e);if(r.numChars>=1<<t)return 1/0;n+=4+t+r.bitData.length}return n}static toUtf8ByteArray(t){t=encodeURI(t);let e=[];for(let n=0;n<t.length;n++)"%"!=t.charAt(n)?e.push(t.charCodeAt(n)):(e.push(parseInt(t.substring(n+1,n+3),16)),n+=2);return e}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=s;t.QrSegment=s})(np||(np={})),(t=>{const e=class{constructor(t,e){this.ordinal=t,this.formatBits=e}};e.LOW=new e(0,1),e.MEDIUM=new e(1,0),e.QUARTILE=new e(2,3),e.HIGH=new e(3,2),t.Ecc=e})((rp=np||(np={})).QrCode||(rp.QrCode={})),(t=>{(t=>{const e=class{constructor(t,e){this.modeBits=t,this.numBitsCharCount=e}numCharCountBits(t){return this.numBitsCharCount[Math.floor((t+7)/17)]}};e.NUMERIC=new e(1,[10,12,14]),e.ALPHANUMERIC=new e(2,[9,11,13]),e.BYTE=new e(4,[8,16,16]),e.KANJI=new e(8,[8,10,12]),e.ECI=new e(7,[0,0,0]),t.Mode=e})(t.QrSegment||(t.QrSegment={}))})(np||(np={}));var hp=np,dp={L:hp.QrCode.Ecc.LOW,M:hp.QrCode.Ecc.MEDIUM,Q:hp.QrCode.Ecc.QUARTILE,H:hp.QrCode.Ecc.HIGH},pp=128,fp="L",gp="#FFFFFF",mp="#000000",_p=!1,yp=1;
|
11
|
+
const Ao=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Eo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xo=BigInt(1),ko=BigInt(2),So=(t,e)=>(t+e/ko)/e;const No=function(t,e,n=!1,r={}){if(t<=Ks)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=oo(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=io(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Ds(i),ZERO:Ks,ONE:Js,create:e=>to(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return Ks<=e&&e<t},is0:t=>t===Ks,isOdd:t=>(t&Js)===Js,neg:e=>to(-e,t),eql:(t,e)=>t===e,sqr:e=>to(e*e,t),add:(e,n)=>to(e+n,t),sub:(e,n)=>to(e-n,t),mul:(e,n)=>to(e*n,t),pow:(t,e)=>function(t,e,n){if(n<Ks)throw new Error("Expected power > 0");if(n===Ks)return t.ONE;if(n===Js)return e;let r=t.ONE,i=e;for(;n>Ks;)n&Js&&(r=t.mul(r,i)),i=t.sqr(i),n>>=Js;return r}(a,t,e),div:(e,n)=>to(e*ro(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>ro(e,t),sqrt:r.sqrt||(t=>o(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce(((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r))),t.ONE),i=t.inv(r);return e.reduceRight(((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r))),i),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?Ls(t,s):Os(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return n?Is(t):Gs(t)}});return Object.freeze(a)}(Ao,void 0,void 0,{sqrt:function(t){const e=Ao,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=no(u,n,e)*u%e,d=no(h,n,e)*u%e,p=no(d,ko,e)*c%e,f=no(p,i,e)*p%e,g=no(f,s,e)*f%e,m=no(g,a,e)*g%e,y=no(m,l,e)*m%e,_=no(y,a,e)*g%e,w=no(_,n,e)*u%e,v=no(w,o,e)*f%e,b=no(v,r,e)*c%e,A=no(b,ko,e);if(!No.eql(No.sqr(A),t))throw new Error("Cannot find square root");return A}}),Co=function(t,e){const n=e=>vo(__spreadValues(__spreadValues({},t),bo(e)));return Object.freeze(__spreadProps(__spreadValues({},n(e)),{create:n}))}({a:BigInt(0),b:BigInt(7),Fp:No,n:Eo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Eo,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-xo*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=So(s*t,e),l=So(-r*t,e);let c=to(t-a*n-l*i,e),u=to(-a*r-l*s,e);const h=c>o,d=u>o;if(h&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Ui);BigInt(0),Co.ProjectivePoint;const Po="0x0000000000000000000000000000000000000000",To="0x0000000000000000000000000000000000000000000000000000000000000000",Mo=BigInt(0),Ro=BigInt(1),Bo=BigInt(2),Go=BigInt(27),Io=BigInt(28),Oo=BigInt(35),Lo={};function Fo(t){return Xn(hr(t),32)}const Uo=class t{constructor(t,e,n,r){__privateAdd(this,rt,void 0),__privateAdd(this,it,void 0),__privateAdd(this,st,void 0),__privateAdd(this,ot,void 0),Dn(t,Lo,"Signature"),__privateSet(this,rt,e),__privateSet(this,it,n),__privateSet(this,st,r),__privateSet(this,ot,null)}get r(){return __privateGet(this,rt)}set r(t){Ln(32===qn(t),"invalid r","value",t),__privateSet(this,rt,Kn(t))}get s(){return __privateGet(this,it)}set s(t){Ln(32===qn(t),"invalid s","value",t);const e=Kn(t);Ln(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),__privateSet(this,it,e)}get v(){return __privateGet(this,st)}set v(t){const e=cr(t,"value");Ln(27===e||28===e,"invalid v","v",t),__privateSet(this,st,e)}get networkV(){return __privateGet(this,ot)}get legacyChainId(){const e=this.networkV;return null==e?null:t.getChainId(e)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=Hn(this.s);return this.yParity&&(t[0]|=128),Kn(t)}get compactSerialized(){return Jn([this.r,this.yParityAndS])}get serialized(){return Jn([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 t(Lo,this.r,this.s,this.v);return this.networkV&&__privateSet(e,ot,this.networkV),e}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=sr(t,"v");return e==Go||e==Io?Mo:(Ln(e>=Oo,"invalid EIP-155 v","v",t),(e-Oo)/Bo)}static getChainIdV(t,e){return sr(t)*Bo+BigInt(35+e-27)}static getNormalizedV(t){const e=sr(t);return e===Mo||e===Go?27:e===Ro||e===Io?28:(Ln(e>=Oo,"invalid v","v",t),e&Ro?27:28)}static from(e){function n(t,n){Ln(t,n,"signature",e)}if(null==e)return new t(Lo,To,To,27);if("string"==typeof e){const r=Hn(e,"signature");if(64===r.length){const e=Kn(r.slice(0,32)),n=r.slice(32,64),i=128&n[0]?28:27;return n[0]&=127,new t(Lo,e,Kn(n),i)}if(65===r.length){const e=Kn(r.slice(0,32)),i=r.slice(32,64);n(!(128&i[0]),"non-canonical s");const s=t.getNormalizedV(r[64]);return new t(Lo,e,Kn(i),s)}n(!1,"invalid raw signature length")}if(e instanceof t)return e.clone();const r=e.r;n(null!=r,"missing r");const i=Fo(r),s=function(t,e){if(null!=t)return Fo(t);if(null!=e){n(Qn(e,32),"invalid yParityAndS");const t=Hn(e);return t[0]&=127,Kn(t)}n(!1,"missing s")}(e.s,e.yParityAndS);n(!(128&Hn(s)[0]),"non-canonical s");const{networkV:o,v:a}=function(e,r,i){if(null!=e){const n=sr(e);return{networkV:n>=Oo?n:void 0,v:t.getNormalizedV(n)}}if(null!=r)return n(Qn(r,32),"invalid yParityAndS"),{v:128&Hn(r)[0]?28:27};if(null!=i){switch(cr(i,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}n(!1,"invalid yParity")}n(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new t(Lo,i,s,a);return o&&__privateSet(l,ot,o),n(null==e.yParity||cr(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),n(null==e.yParityAndS||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};rt=new WeakMap,it=new WeakMap,st=new WeakMap,ot=new WeakMap;let Do=Uo;at=new WeakMap;let jo=class t{constructor(t){__privateAdd(this,at,void 0),Ln(32===qn(t),"invalid private key","privateKey","[REDACTED]"),__privateSet(this,at,Kn(t))}get privateKey(){return __privateGet(this,at)}get publicKey(){return t.computePublicKey(__privateGet(this,at))}get compressedPublicKey(){return t.computePublicKey(__privateGet(this,at),!0)}sign(t){Ln(32===qn(t),"invalid digest length","digest",t);const e=Co.sign(Wn(t),Wn(__privateGet(this,at)),{lowS:!0});return Do.from({r:ur(e.r,32),s:ur(e.s,32),v:e.recovery?28:27})}computeSharedSecret(e){const n=t.computePublicKey(e);return Kn(Co.getSharedSecret(Wn(__privateGet(this,at)),Hn(n),!1))}static computePublicKey(t,e){let n=Hn(t,"key");if(32===n.length){return Kn(Co.getPublicKey(n,!!e))}if(64===n.length){const t=new Uint8Array(65);t[0]=4,t.set(n,1),n=t}return Kn(Co.ProjectivePoint.fromHex(n).toRawBytes(e))}static recoverPublicKey(t,e){Ln(32===qn(t),"invalid digest length","digest",t);const n=Do.from(e);let r=Co.Signature.fromCompact(Wn(Jn([n.r,n.s])));r=r.addRecoveryBit(n.yParity);const i=r.recoverPublicKey(Wn(t));return Ln(null!=i,"invalid signature for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(e,n,r){const i=Co.ProjectivePoint.fromHex(t.computePublicKey(e).substring(2)),s=Co.ProjectivePoint.fromHex(t.computePublicKey(n).substring(2));return"0x"+i.add(s).toHex(!!r)}};const Ho=BigInt(0),Wo=BigInt(36);function Qo(t){const e=(t=t.toLowerCase()).substring(2).split(""),n=new Uint8Array(40);for(let i=0;i<40;i++)n[i]=e[i].charCodeAt(0);const r=Hn(vs(n));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(15&r[i>>1])>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const zo={};for(let Op=0;Op<10;Op++)zo[String(Op)]=String(Op);for(let Op=0;Op<26;Op++)zo[String.fromCharCode(65+Op)]=String(10+Op);const Vo=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function Ko(t){if(Ln("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=Qo(t);return Ln(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){Ln(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>zo[t])).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let n=String(98-parseInt(e,10)%97);for(;n.length<2;)n="0"+n;return n}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=Ho;for(let n=0;n<t.length;n++)e=e*Wo+Vo[t[n]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Qo("0x"+e)}Ln(!1,"invalid address","address",t)}function Jo(t){return t&&"function"==typeof t.getAddress}function qo(t,e){return __async(this,null,(function*(){const n=yield e;return null!=n&&"0x0000000000000000000000000000000000000000"!==n||(On("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),Ln(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),Ko(n)}))}function Zo(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?Ko(t):(On(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),qo(t,e.resolveName(t))):Jo(t)?qo(t,t.getAddress()):t&&"function"==typeof t.then?qo(t,t):void Ln(!1,"unsupported addressable value","target",t)}const Yo={};function Xo(t,e){let n=!1;return e<0&&(n=!0,e*=-1),new ea(Yo,`${n?"":"u"}int${e}`,t,{signed:n,width:e})}function $o(t,e){return new ea(Yo,`bytes${e||""}`,t,{size:e})}const ta=Symbol.for("_ethers_typed");lt=new WeakMap;let ea=class t{constructor(t,e,n,r){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,lt,void 0),__publicField(this,"_typedSymbol"),null==r&&(r=null),Dn(Yo,t,"Typed"),Mn(this,{_typedSymbol:ta,type:e,value:n}),__privateSet(this,lt,r),this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.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"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return __privateGet(this,lt)}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===__privateGet(this,lt)?-1:!1===__privateGet(this,lt)?this.value.length:null}static from(e,n){return new t(Yo,e,n)}static uint8(t){return Xo(t,8)}static uint16(t){return Xo(t,16)}static uint24(t){return Xo(t,24)}static uint32(t){return Xo(t,32)}static uint40(t){return Xo(t,40)}static uint48(t){return Xo(t,48)}static uint56(t){return Xo(t,56)}static uint64(t){return Xo(t,64)}static uint72(t){return Xo(t,72)}static uint80(t){return Xo(t,80)}static uint88(t){return Xo(t,88)}static uint96(t){return Xo(t,96)}static uint104(t){return Xo(t,104)}static uint112(t){return Xo(t,112)}static uint120(t){return Xo(t,120)}static uint128(t){return Xo(t,128)}static uint136(t){return Xo(t,136)}static uint144(t){return Xo(t,144)}static uint152(t){return Xo(t,152)}static uint160(t){return Xo(t,160)}static uint168(t){return Xo(t,168)}static uint176(t){return Xo(t,176)}static uint184(t){return Xo(t,184)}static uint192(t){return Xo(t,192)}static uint200(t){return Xo(t,200)}static uint208(t){return Xo(t,208)}static uint216(t){return Xo(t,216)}static uint224(t){return Xo(t,224)}static uint232(t){return Xo(t,232)}static uint240(t){return Xo(t,240)}static uint248(t){return Xo(t,248)}static uint256(t){return Xo(t,256)}static uint(t){return Xo(t,256)}static int8(t){return Xo(t,-8)}static int16(t){return Xo(t,-16)}static int24(t){return Xo(t,-24)}static int32(t){return Xo(t,-32)}static int40(t){return Xo(t,-40)}static int48(t){return Xo(t,-48)}static int56(t){return Xo(t,-56)}static int64(t){return Xo(t,-64)}static int72(t){return Xo(t,-72)}static int80(t){return Xo(t,-80)}static int88(t){return Xo(t,-88)}static int96(t){return Xo(t,-96)}static int104(t){return Xo(t,-104)}static int112(t){return Xo(t,-112)}static int120(t){return Xo(t,-120)}static int128(t){return Xo(t,-128)}static int136(t){return Xo(t,-136)}static int144(t){return Xo(t,-144)}static int152(t){return Xo(t,-152)}static int160(t){return Xo(t,-160)}static int168(t){return Xo(t,-168)}static int176(t){return Xo(t,-176)}static int184(t){return Xo(t,-184)}static int192(t){return Xo(t,-192)}static int200(t){return Xo(t,-200)}static int208(t){return Xo(t,-208)}static int216(t){return Xo(t,-216)}static int224(t){return Xo(t,-224)}static int232(t){return Xo(t,-232)}static int240(t){return Xo(t,-240)}static int248(t){return Xo(t,-248)}static int256(t){return Xo(t,-256)}static int(t){return Xo(t,-256)}static bytes1(t){return $o(t,1)}static bytes2(t){return $o(t,2)}static bytes3(t){return $o(t,3)}static bytes4(t){return $o(t,4)}static bytes5(t){return $o(t,5)}static bytes6(t){return $o(t,6)}static bytes7(t){return $o(t,7)}static bytes8(t){return $o(t,8)}static bytes9(t){return $o(t,9)}static bytes10(t){return $o(t,10)}static bytes11(t){return $o(t,11)}static bytes12(t){return $o(t,12)}static bytes13(t){return $o(t,13)}static bytes14(t){return $o(t,14)}static bytes15(t){return $o(t,15)}static bytes16(t){return $o(t,16)}static bytes17(t){return $o(t,17)}static bytes18(t){return $o(t,18)}static bytes19(t){return $o(t,19)}static bytes20(t){return $o(t,20)}static bytes21(t){return $o(t,21)}static bytes22(t){return $o(t,22)}static bytes23(t){return $o(t,23)}static bytes24(t){return $o(t,24)}static bytes25(t){return $o(t,25)}static bytes26(t){return $o(t,26)}static bytes27(t){return $o(t,27)}static bytes28(t){return $o(t,28)}static bytes29(t){return $o(t,29)}static bytes30(t){return $o(t,30)}static bytes31(t){return $o(t,31)}static bytes32(t){return $o(t,32)}static address(e){return new t(Yo,"address",e)}static bool(e){return new t(Yo,"bool",!!e)}static bytes(e){return new t(Yo,"bytes",e)}static string(e){return new t(Yo,"string",e)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(e){return new t(Yo,"overrides",Object.assign({},e))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===ta}static dereference(e,n){if(t.isTyped(e)){if(e.type!==n)throw new Error(`invalid type: expecetd ${n}, got ${e.type}`);return e.value}return e}};class na extends mi{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=ea.dereference(e,"string");try{n=Ko(n)}catch(r){return this._throwError(r.message,e)}return t.writeValue(n)}decode(t){return Ko(ur(t.readValue(),20))}}class ra extends mi{constructor(t){super(t.name,t.type,"_",t.dynamic),__publicField(this,"coder"),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function ia(t,e,n){let r=[];if(Array.isArray(n))r=n;else if(n&&"object"==typeof n){let t={};r=e.map((e=>{const r=e.localName;return On(r,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:n}),On(!t[r],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:n}),t[r]=!0,n[r]}))}else Ln(!1,"invalid tuple value","tuple",n);Ln(e.length===r.length,"types/value length mismatch","tuple",n);let i=new yi,s=new yi,o=[];e.forEach(((t,e)=>{let n=r[e];if(t.dynamic){let e=s.length;t.encode(s,n);let r=i.writeUpdatableValue();o.push((t=>{r(t+e)}))}else t.encode(i,n)})),o.forEach((t=>{t(i.length)}));let a=t.appendWriter(i);return a+=t.appendWriter(s),a}function sa(t,e){let n=[],r=[],i=t.subReader(0);return e.forEach((e=>{let s=null;if(e.dynamic){let n=t.readIndex(),r=i.subReader(n);try{s=e.decode(r)}catch(o){if(Bn(o,"BUFFER_OVERRUN"))throw o;s=o,s.baseType=e.name,s.name=e.localName,s.type=e.type}}else try{s=e.decode(t)}catch(o){if(Bn(o,"BUFFER_OVERRUN"))throw o;s=o,s.baseType=e.name,s.name=e.localName,s.type=e.type}if(null==s)throw new Error("investigate");n.push(s),r.push(e.localName||null)})),fi.fromItems(n,r)}class oa extends mi{constructor(t,e,n){super("array",t.type+"["+(e>=0?e:"")+"]",n,-1===e||t.dynamic),__publicField(this,"coder"),__publicField(this,"length"),Mn(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let n=0;n<this.length;n++)e.push(t);return e}encode(t,e){const n=ea.dereference(e,"array");Array.isArray(n)||this._throwError("expected array value",n);let r=this.length;-1===r&&(r=n.length,t.writeValue(n.length)),Fn(n.length,r,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let s=0;s<n.length;s++)i.push(this.coder);return ia(t,i,n)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),On(e*si<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*si,length:t.dataLength}));let n=[];for(let r=0;r<e;r++)n.push(new ra(this.coder));return sa(t,n)}}class aa extends mi{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const n=ea.dereference(e,"bool");return t.writeValue(n?1:0)}decode(t){return!!t.readValue()}}class la extends mi{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=Wn(e);let n=t.writeValue(e.length);return n+=t.writeBytes(e),n}decode(t){return t.readBytes(t.readIndex(),!0)}}class ca extends la{constructor(t){super("bytes",t)}decode(t){return Kn(super.decode(t))}}class ua extends mi{constructor(t,e){let n="bytes"+String(t);super(n,n,e,!1),__publicField(this,"size"),Mn(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let n=Wn(ea.dereference(e,this.type));return n.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(n)}decode(t){return Kn(t.readBytes(this.size))}}const ha=new Uint8Array([]);class da extends mi{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(ha)}decode(t){return t.readBytes(0),null}}const pa=BigInt(0),fa=BigInt(1),ga=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class ma extends mi{constructor(t,e,n){const r=(e?"int":"uint")+8*t;super(r,r,n,!1),__publicField(this,"size"),__publicField(this,"signed"),Mn(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let n=sr(ea.dereference(e,this.type)),r=ir(ga,256);if(this.signed){let t=ir(r,8*this.size-1);(n>t||n<-(t+fa))&&this._throwError("value out-of-bounds",e),n=rr(n,256)}else(n<pa||n>ir(r,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(n)}decode(t){let e=ir(t.readValue(),8*this.size);return this.signed&&(e=nr(e,8*this.size)),e}}class ya extends la{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,_r(ea.dereference(e,"string")))}decode(t){return wr(super.decode(t))}}class _a extends mi{constructor(t,e){let n=!1;const r=[];t.forEach((t=>{t.dynamic&&(n=!0),r.push(t.type)}));super("tuple","tuple("+r.join(",")+")",e,n),__publicField(this,"coders"),Mn(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const n=e.localName;return n&&(t[n]||(t[n]=0),t[n]++),t}),{});return this.coders.forEach(((n,r)=>{let i=n.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[r]))})),Object.freeze(t)}encode(t,e){const n=ea.dereference(e,"tuple");return ia(t,this.coders,n)}decode(t){return sa(t,this.coders)}}function wa(t,e){return{address:Ko(t),storageKeys:e.map(((t,e)=>(Ln(Qn(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function va(t){if(Array.isArray(t))return t.map(((e,n)=>Array.isArray(e)?(Ln(2===e.length,"invalid slot set",`value[${n}]`,e),wa(e[0],e[1])):(Ln(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),wa(e.address,e.storageKeys))));Ln(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const n=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return wa(e,Object.keys(n).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function ba(t){return{address:Ko(t.address),nonce:sr(null!=t.nonce?t.nonce:0),chainId:sr(null!=t.chainId?t.chainId:0),signature:Do.from(t.signature)}}function Aa(t,e){return function(t){let e;return e="string"==typeof t?jo.computePublicKey(t,!1):t.publicKey,Ko(vs("0x"+e.substring(4)).substring(26))}(jo.recoverPublicKey(t,e))}const Ea=BigInt(0),xa=BigInt(2),ka=BigInt(27),Sa=BigInt(28),Na=BigInt(35),Ca=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Pa=131072;function Ta(t,e){let n=t.toString(16);for(;n.length<2;)n="0"+n;return n+=xs(e).substring(4),"0x"+n}function Ma(t){return"0x"===t?null:Ko(t)}function Ra(t,e){try{return va(t)}catch(n){Ln(!1,n.message,e,t)}}function Ba(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!Array.isArray(r))throw new Error(`authorization[${n}]: invalid array`);if(6!==r.length)throw new Error(`authorization[${n}]: wrong length`);if(!r[1])throw new Error(`authorization[${n}]: null address`);e.push({address:Ma(r[1]),nonce:Ia(r[2],"nonce"),chainId:Ia(r[0],"chainId"),signature:Do.from({yParity:Ga(r[3],"yParity"),r:Xn(r[4],32),s:Xn(r[5],32)})})}return e}catch(n){Ln(!1,n.message,e,t)}}function Ga(t,e){return"0x"===t?0:cr(t,e)}function Ia(t,e){if("0x"===t)return Ea;const n=sr(t,e);return Ln(n<=Ca,"value exceeds uint size",e,n),n}function Oa(t,e){const n=sr(t,"value"),r=hr(n);return Ln(r.length<=32,"value too large",`tx.${e}`,n),r}function La(t){return va(t).map((t=>[t.address,t.storageKeys]))}function Fa(t,e){Ln(Array.isArray(t),`invalid ${e}`,"value",t);for(let n=0;n<t.length;n++)Ln(Qn(t[n],32),"invalid ${ param } hash",`value[${n}]`,t[n]);return t}function Ua(t,e){let n;try{if(n=Ga(e[0],"yParity"),0!==n&&1!==n)throw new Error("bad yParity")}catch(o){Ln(!1,"invalid yParity","yParity",e[0])}const r=Xn(e[1],32),i=Xn(e[2],32),s=Do.from({r:r,s:i,yParity:n});t.signature=s}ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,ft=new WeakMap,gt=new WeakMap,mt=new WeakMap,yt=new WeakMap,_t=new WeakMap,wt=new WeakMap,vt=new WeakMap,bt=new WeakMap,At=new WeakMap,Et=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakSet,Nt=function(t,e){On(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const n=[Oa(t.nonce,"nonce"),Oa(t.gasPrice||0,"gasPrice"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data];let r=Ea;if(t.chainId!=Ea)r=sr(t.chainId,"tx.chainId"),Ln(!e||null==e.networkV||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(r=e)}if(!e)return r!==Ea&&(n.push(hr(r)),n.push("0x"),n.push("0x")),ei(n);let i=BigInt(27+e.yParity);return r!==Ea?i=Do.getChainIdV(r,e.v):BigInt(e.v)!==i&&Ln(!1,"tx.chainId/sig.v mismatch","sig",e),n.push(hr(i)),n.push(hr(e.r)),n.push(hr(e.s)),ei(n)}(this,n);case 1:return function(t,e){const n=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.gasPrice||0,"gasPrice"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data,La(t.accessList||[])];return e&&(n.push(Oa(e.yParity,"recoveryParam")),n.push(hr(e.r)),n.push(hr(e.s))),Jn(["0x01",ei(n)])}(this,n);case 2:return function(t,e){const n=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oa(t.maxFeePerGas||0,"maxFeePerGas"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data,La(t.accessList||[])];return e&&(n.push(Oa(e.yParity,"yParity")),n.push(hr(e.r)),n.push(hr(e.s))),Jn(["0x02",ei(n)])}(this,n);case 3:return function(t,e,n){const r=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oa(t.maxFeePerGas||0,"maxFeePerGas"),Oa(t.gasLimit,"gasLimit"),t.to||Po,Oa(t.value,"value"),t.data,La(t.accessList||[]),Oa(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Fa(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(Oa(e.yParity,"yParity")),r.push(hr(e.r)),r.push(hr(e.s)),n)?Jn(["0x03",ei([r,n.map((t=>t.data)),n.map((t=>t.commitment)),n.map((t=>t.proof))])]):Jn(["0x03",ei(r)])}(this,n,e?this.blobs:null);case 4:return function(t,e){const n=[Oa(t.chainId,"chainId"),Oa(t.nonce,"nonce"),Oa(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oa(t.maxFeePerGas||0,"maxFeePerGas"),Oa(t.gasLimit,"gasLimit"),t.to||"0x",Oa(t.value,"value"),t.data,La(t.accessList||[]),(r=t.authorizationList||[],r.map((t=>[Oa(t.chainId,"chainId"),t.address,Oa(t.nonce,"nonce"),Oa(t.signature.yParity,"yParity"),t.signature.r,t.signature.s])))];var r;return e&&(n.push(Oa(e.yParity,"yParity")),n.push(hr(e.r)),n.push(hr(e.s))),Jn(["0x04",ei(n)])}(this,n)}On(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Da=class t{constructor(){__privateAdd(this,St),__privateAdd(this,ct,void 0),__privateAdd(this,ut,void 0),__privateAdd(this,ht,void 0),__privateAdd(this,dt,void 0),__privateAdd(this,pt,void 0),__privateAdd(this,ft,void 0),__privateAdd(this,gt,void 0),__privateAdd(this,mt,void 0),__privateAdd(this,yt,void 0),__privateAdd(this,_t,void 0),__privateAdd(this,wt,void 0),__privateAdd(this,vt,void 0),__privateAdd(this,bt,void 0),__privateAdd(this,At,void 0),__privateAdd(this,Et,void 0),__privateAdd(this,xt,void 0),__privateAdd(this,kt,void 0),__privateSet(this,ct,null),__privateSet(this,ut,null),__privateSet(this,dt,0),__privateSet(this,pt,Ea),__privateSet(this,ft,null),__privateSet(this,gt,null),__privateSet(this,mt,null),__privateSet(this,ht,"0x"),__privateSet(this,yt,Ea),__privateSet(this,_t,Ea),__privateSet(this,wt,null),__privateSet(this,vt,null),__privateSet(this,bt,null),__privateSet(this,At,null),__privateSet(this,Et,null),__privateSet(this,xt,null),__privateSet(this,kt,null)}get type(){return __privateGet(this,ct)}set type(t){switch(t){case null:__privateSet(this,ct,null);break;case 0:case"legacy":__privateSet(this,ct,0);break;case 1:case"berlin":case"eip-2930":__privateSet(this,ct,1);break;case 2:case"london":case"eip-1559":__privateSet(this,ct,2);break;case 3:case"cancun":case"eip-4844":__privateSet(this,ct,3);break;case 4:case"pectra":case"eip-7702":__privateSet(this,ct,4);break;default:Ln(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const t=__privateGet(this,ut);return null==t&&3===this.type?Po:t}set to(t){__privateSet(this,ut,null==t?null:Ko(t))}get nonce(){return __privateGet(this,dt)}set nonce(t){__privateSet(this,dt,cr(t,"value"))}get gasLimit(){return __privateGet(this,pt)}set gasLimit(t){__privateSet(this,pt,sr(t))}get gasPrice(){const t=__privateGet(this,ft);return null!=t||0!==this.type&&1!==this.type?t:Ea}set gasPrice(t){__privateSet(this,ft,null==t?null:sr(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=__privateGet(this,gt);return null==t?2===this.type||3===this.type?Ea:null:t}set maxPriorityFeePerGas(t){__privateSet(this,gt,null==t?null:sr(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=__privateGet(this,mt);return null==t?2===this.type||3===this.type?Ea:null:t}set maxFeePerGas(t){__privateSet(this,mt,null==t?null:sr(t,"maxFeePerGas"))}get data(){return __privateGet(this,ht)}set data(t){__privateSet(this,ht,Kn(t))}get value(){return __privateGet(this,yt)}set value(t){__privateSet(this,yt,sr(t,"value"))}get chainId(){return __privateGet(this,_t)}set chainId(t){__privateSet(this,_t,sr(t))}get signature(){return __privateGet(this,wt)||null}set signature(t){__privateSet(this,wt,null==t?null:Do.from(t))}get accessList(){const t=__privateGet(this,vt)||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){__privateSet(this,vt,null==t?null:va(t))}get authorizationList(){const t=__privateGet(this,kt)||null;return null==t&&4===this.type?[]:t}set authorizationList(t){__privateSet(this,kt,null==t?null:t.map((t=>ba(t))))}get maxFeePerBlobGas(){const t=__privateGet(this,bt);return null==t&&3===this.type?Ea:t}set maxFeePerBlobGas(t){__privateSet(this,bt,null==t?null:sr(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=__privateGet(this,At);return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){Ln(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)Ln(Qn(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}__privateSet(this,At,t)}get blobs(){return null==__privateGet(this,xt)?null:__privateGet(this,xt).map((t=>Object.assign({},t)))}set blobs(t){if(null==t)return void __privateSet(this,xt,null);const e=[],n=[];for(let r=0;r<t.length;r++){const i=t[r];if(zn(i)){On(__privateGet(this,Et),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=Hn(i);if(Ln(t.length<=Pa,"blob is too large",`blobs[${r}]`,i),t.length!==Pa){const e=new Uint8Array(Pa);e.set(t),t=e}const s=__privateGet(this,Et).blobToKzgCommitment(t),o=Kn(__privateGet(this,Et).computeBlobKzgProof(t,s));e.push({data:Kn(t),commitment:Kn(s),proof:o}),n.push(Ta(1,s))}else{const t=Kn(i.commitment);e.push({data:Kn(i.data),commitment:t,proof:Kn(i.proof)}),n.push(Ta(1,t))}}__privateSet(this,xt,e),__privateSet(this,At,n)}get kzg(){return __privateGet(this,Et)}set kzg(t){__privateSet(this,Et,null==t?null:function(t){return{blobToKzgCommitment:e=>{if("computeBlobProof"in t){if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return Hn(t.blobToKzgCommitment(Kn(e)))}else if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return Hn(t.blobToKzgCommitment(e));if("blobToKZGCommitment"in t&&"function"==typeof t.blobToKZGCommitment)return Hn(t.blobToKZGCommitment(Kn(e)));Ln(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(e,n)=>"computeBlobProof"in t&&"function"==typeof t.computeBlobProof?Hn(t.computeBlobProof(Kn(e),Kn(n))):"computeBlobKzgProof"in t&&"function"==typeof t.computeBlobKzgProof?t.computeBlobKzgProof(e,n):"computeBlobKZGProof"in t&&"function"==typeof t.computeBlobKZGProof?Hn(t.computeBlobKZGProof(Kn(e),Kn(n))):void Ln(!1,"unsupported KZG library","kzg",t)}}(t))}get hash(){return null==this.signature?null:vs(__privateMethod(this,St,Nt).call(this,!0,!1))}get unsignedHash(){return vs(this.unsignedSerialized)}get from(){return null==this.signature?null:Aa(this.unsignedHash,this.signature)}get fromPublicKey(){return null==this.signature?null:jo.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return null!=this.signature}get serialized(){return __privateMethod(this,St,Nt).call(this,!0,!0)}get unsignedSerialized(){return __privateMethod(this,St,Nt).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,n=null!=this.accessList,r=null!=__privateGet(this,bt)||__privateGet(this,At);null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&On(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),On(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),On(0!==this.type||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):this.authorizationList&&this.authorizationList.length?i.push(4):e?i.push(2):t?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):(r&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return t.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(null==e)return new t;if("string"==typeof e){const n=Hn(e);if(n[0]>=127)return t.from(function(t){const e=Yr(t);Ln(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const n={type:0,nonce:Ga(e[0],"nonce"),gasPrice:Ia(e[1],"gasPrice"),gasLimit:Ia(e[2],"gasLimit"),to:Ma(e[3]),value:Ia(e[4],"value"),data:Kn(e[5]),chainId:Ea};if(6===e.length)return n;const r=Ia(e[6],"v"),i=Ia(e[7],"r"),s=Ia(e[8],"s");if(i===Ea&&s===Ea)n.chainId=r;else{let t=(r-Na)/xa;t<Ea&&(t=Ea),n.chainId=t,Ln(t!==Ea||r===ka||r===Sa,"non-canonical legacy v","v",e[6]),n.signature=Do.from({r:Xn(e[7],32),s:Xn(e[8],32),v:r})}return n}(n));switch(n[0]){case 1:return t.from(function(t){const e=Yr(Hn(t).slice(1));Ln(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",Kn(t));const n={type:1,chainId:Ia(e[0],"chainId"),nonce:Ga(e[1],"nonce"),gasPrice:Ia(e[2],"gasPrice"),gasLimit:Ia(e[3],"gasLimit"),to:Ma(e[4]),value:Ia(e[5],"value"),data:Kn(e[6]),accessList:Ra(e[7],"accessList")};return 8===e.length||Ua(n,e.slice(8)),n}(n));case 2:return t.from(function(t){const e=Yr(Hn(t).slice(1));Ln(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",Kn(t));const n={type:2,chainId:Ia(e[0],"chainId"),nonce:Ga(e[1],"nonce"),maxPriorityFeePerGas:Ia(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ia(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ia(e[4],"gasLimit"),to:Ma(e[5]),value:Ia(e[6],"value"),data:Kn(e[7]),accessList:Ra(e[8],"accessList")};return 9===e.length||Ua(n,e.slice(9)),n}(n));case 3:return t.from(function(t){let e=Yr(Hn(t).slice(1)),n="3",r=null;if(4===e.length&&Array.isArray(e[0])){n="3 (network format)";const t=e[1],i=e[2],s=e[3];Ln(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),Ln(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),Ln(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),Ln(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),Ln(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let n=0;n<e[1].length;n++)r.push({data:t[n],commitment:i[n],proof:s[n]});e=e[0]}Ln(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${n}`,"data",Kn(t));const i={type:3,chainId:Ia(e[0],"chainId"),nonce:Ga(e[1],"nonce"),maxPriorityFeePerGas:Ia(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ia(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ia(e[4],"gasLimit"),to:Ma(e[5]),value:Ia(e[6],"value"),data:Kn(e[7]),accessList:Ra(e[8],"accessList"),maxFeePerBlobGas:Ia(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(i.blobs=r),Ln(null!=i.to,`invalid address for transaction type: ${n}`,"data",t),Ln(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let s=0;s<i.blobVersionedHashes.length;s++)Ln(Qn(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",t);return 11===e.length||Ua(i,e.slice(11)),i}(n));case 4:return t.from(function(t){const e=Yr(Hn(t).slice(1));Ln(Array.isArray(e)&&(10===e.length||13===e.length),"invalid field count for transaction type: 4","data",Kn(t));const n={type:4,chainId:Ia(e[0],"chainId"),nonce:Ga(e[1],"nonce"),maxPriorityFeePerGas:Ia(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Ia(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Ia(e[4],"gasLimit"),to:Ma(e[5]),value:Ia(e[6],"value"),data:Kn(e[7]),accessList:Ra(e[8],"accessList"),authorizationList:Ba(e[9],"authorizationList")};return 10===e.length||Ua(n,e.slice(10)),n}(n))}On(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const n=new t;return null!=e.type&&(n.type=e.type),null!=e.to&&(n.to=e.to),null!=e.nonce&&(n.nonce=e.nonce),null!=e.gasLimit&&(n.gasLimit=e.gasLimit),null!=e.gasPrice&&(n.gasPrice=e.gasPrice),null!=e.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=e.maxPriorityFeePerGas),null!=e.maxFeePerGas&&(n.maxFeePerGas=e.maxFeePerGas),null!=e.maxFeePerBlobGas&&(n.maxFeePerBlobGas=e.maxFeePerBlobGas),null!=e.data&&(n.data=e.data),null!=e.value&&(n.value=e.value),null!=e.chainId&&(n.chainId=e.chainId),null!=e.signature&&(n.signature=Do.from(e.signature)),null!=e.accessList&&(n.accessList=e.accessList),null!=e.authorizationList&&(n.authorizationList=e.authorizationList),null!=e.blobVersionedHashes&&(n.blobVersionedHashes=e.blobVersionedHashes),null!=e.kzg&&(n.kzg=e.kzg),null!=e.blobs&&(n.blobs=e.blobs),null!=e.hash&&(Ln(n.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),Ln(n.hash===e.hash,"hash mismatch","tx",e)),null!=e.from&&(Ln(n.isSigned(),"unsigned transaction cannot define '.from'","tx",e),Ln(n.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),n}};function ja(t){return vs(_r(t))}const Ha=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);function Wa(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function n(){return t[e++]<<8|t[e++]}let r=n(),i=1,s=[0,1];for(let v=1;v<r;v++)s.push(i+=n());let o=n(),a=e;e+=o;let l=0,c=0;function u(){return 0==l&&(c=c<<8|t[e++],l=8),c>>--l&1}const h=__pow(2,31),d=h>>>1,p=d>>1,f=h-1;let g=0;for(let v=0;v<31;v++)g=g<<1|u();let m=[],y=0,_=h;for(;;){let t=Math.floor(((g-y+1)*i-1)/_),e=0,n=r;for(;n-e>1;){let r=e+n>>>1;t<s[r]?n=r:e=r}if(0==e)break;m.push(e);let o=y+Math.floor(_*s[e]/i),a=y+Math.floor(_*s[e+1]/i)-1;for(;0==((o^a)&d);)g=g<<1&f|u(),o=o<<1&f,a=a<<1&f|1;for(;o&~a&p;)g=g&d|g<<1&f>>>1|u(),o=o<<1^d,a=(a^d)<<1|d|1;y=o,_=1+a-o}let w=r-4;return m.map((e=>{switch(e-w){case 3:return w+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return w+256+(t[a++]<<8|t[a++]);case 1:return w+t[a++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,n)=>e[t.charCodeAt(0)]=n));let n=t.length,r=new Uint8Array(6*n>>3);for(let i=0,s=0,o=0,a=0;i<n;i++)a=a<<6|e[t.charCodeAt(i)],o+=6,o>=8&&(r[s++]=a>>(o-=8));return r}(t)))}function Qa(t){return 1&t?~t>>1:t>>1}function za(t,e){let n=Array(t);for(let r=0,i=0;r<t;r++)n[r]=i+=Qa(e());return n}function Va(t,e=0){let n=[];for(;;){let r=t(),i=t();if(!i)break;e+=r;for(let t=0;t<i;t++)n.push(e+t);e+=i+1}return n}function Ka(t){return qa((()=>{let e=Va(t);if(e.length)return e}))}function Ja(t){let e=[];for(;;){let n=t();if(0==n)break;e.push(Ya(n,t))}for(;;){let n=t()-1;if(n<0)break;e.push(Xa(n,t))}return e.flat()}function qa(t){let e=[];for(;;){let n=t(e.length);if(!n)break;e.push(n)}return e}function Za(t,e,n){let r=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)za(t,n).forEach(((t,e)=>r[e].push(t)));return r}function Ya(t,e){let n=1+e(),r=e(),i=qa(e);return Za(i.length,1+t,e).flatMap(((t,e)=>{let[s,...o]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*r;return[s+e*n,o.map((t=>t+i))]}))}))}function Xa(t,e){return Za(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function $a(t){return`{${function(t){return t.toString(16).toUpperCase().padStart(2,"0")}(t)}}`}function tl(t){let e=t.length;if(e<4096)return String.fromCodePoint(...t);let n=[];for(let r=0;r<e;)n.push(String.fromCodePoint(...t.slice(r,r+=4096)));return n.join("")}function el(t,e){let n=t.length,r=n-e.length;for(let i=0;0==r&&i<n;i++)r=t[i]-e[i];return r}const nl=44032,rl=4352,il=4449,sl=4519,ol=28,al=588;function ll(t){return t>>24&255}function cl(t){return 16777215&t}let ul,hl,dl,pl;function fl(t){return t>=nl&&t<55204}function gl(t,e){if(t>=rl&&t<4371&&e>=il&&e<4470)return nl+(t-rl)*al+(e-il)*ol;if(fl(t)&&e>sl&&e<4547&&(t-nl)%ol==0)return t+(e-sl);{let n=pl.get(t);return n&&(n=n.get(e),n)?n:-1}}function ml(t){ul||function(){let t=Wa("AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDd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HvOdC8bP6FGDbE/VV0mX4IakzbdS/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");ul=new Map(Ka(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),hl=new Set(Va(t)),dl=new Map,pl=new Map;for(let[e,n]of Ja(t)){if(!hl.has(e)&&2==n.length){let[t,r]=n,i=pl.get(t);i||(i=new Map,pl.set(t,i)),i.set(r,e)}dl.set(e,n.reverse())}}();let e=[],n=[],r=!1;function i(t){let n=ul.get(t);n&&(r=!0,t|=n),e.push(t)}for(let s of t)for(;;){if(s<128)e.push(s);else if(fl(s)){let t=s-nl,e=t%al/ol|0,n=t%ol;i(rl+(t/al|0)),i(il+e),n>0&&i(sl+n)}else{let t=dl.get(s);t?n.push(...t):i(s)}if(!n.length)break;s=n.pop()}if(r&&e.length>1){let t=ll(e[0]);for(let n=1;n<e.length;n++){let r=ll(e[n]);if(0==r||t<=r){t=r;continue}let i=n-1;for(;;){let n=e[i+1];if(e[i+1]=e[i],e[i]=n,!i)break;if(t=ll(e[--i]),t<=r)break}t=ll(e[n])}}return e}function yl(t){return ml(t).map(cl)}function _l(t){return function(t){let e=[],n=[],r=-1,i=0;for(let s of t){let t=ll(s),o=cl(s);if(-1==r)0==t?r=o:e.push(o);else if(i>0&&i>=t)0==t?(e.push(r,...n),n.length=0,r=o):n.push(o),i=t;else{let s=gl(r,o);s>=0?r=s:0==i&&0==t?(e.push(r),r=o):(n.push(o),i=t)}}return r>=0&&e.push(r,...n),e}(ml(t))}const wl=".",vl=t=>Array.from(t);function bl(t,e){return t.P.has(e)||t.Q.has(e)}class Al extends Array{get is_emoji(){return!0}}let El,xl,kl,Sl,Nl,Cl,Pl,Tl,Ml,Rl,Bl;function Gl(){if(El)return;let t=Wa("AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX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wDN3WewNmQHdPfsxChU/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 e=()=>Va(t),n=()=>new Set(e()),r=(t,e)=>e.forEach((e=>t.add(e)));El=new Map(Ja(t)),xl=n(),kl=e(),Sl=new Set(e().map((t=>kl[t]))),kl=new Set(kl),Nl=n(),n();let i=Ka(t),s=t();const o=()=>{let t=new Set;return e().forEach((e=>r(t,i[e]))),r(t,e()),t};Cl=qa((e=>{let n=qa(t).map((t=>t+96));if(n.length){let r=e>=s;return n[0]-=32,n=tl(n),r&&(n=`Restricted[${n}]`),{N:n,P:o(),Q:o(),M:!t(),R:r}}})),Pl=n(),Tl=new Map;let a=e().concat(vl(Pl)).sort(((t,e)=>t-e));a.forEach(((e,n)=>{let r=t(),i=a[n]=r?a[n-r]:{V:[],M:new Map};i.V.push(e),Pl.has(e)||Tl.set(e,i)}));for(let{V:u,M:h}of new Set(Tl.values())){let t=[];for(let n of u){let e=Cl.filter((t=>bl(t,n))),i=t.find((({G:t})=>e.some((e=>t.has(e)))));i||(i={G:new Set,V:[]},t.push(i)),i.V.push(n),r(i.G,e)}let e=t.flatMap((t=>vl(t.G)));for(let{G:n,V:r}of t){let t=new Set(e.filter((t=>!n.has(t))));for(let e of r)h.set(e,t)}}Ml=new Set;let l=new Set;const c=t=>Ml.has(t)?l.add(t):Ml.add(t);for(let u of Cl){for(let t of u.P)c(t);for(let t of u.Q)c(t)}for(let u of Ml)Tl.has(u)||l.has(u)||Tl.set(u,1);r(Ml,yl(Ml)),Rl=function(t){let e=[],n=Va(t);return function t({S:n,B:r},i,s){if(!(4&n&&s===i[i.length-1])){2&n&&(s=i[i.length-1]),1&n&&e.push(i);for(let e of r)for(let n of e.Q)t(e,[...i,n],s)}}(function e(r){return{S:t(),B:qa((()=>{let r=Va(t).map((t=>n[t]));if(r.length)return e(r)})),Q:r}}([]),[]),e}(t).map((t=>Al.from(t))).sort(el),Bl=new Map;for(let u of Rl){let t=[Bl];for(let e of u){let n=t.map((t=>{let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}));65039===e?t.push(...n):t=n}for(let e of t)e.V=u}}function Il(t){return(Fl(t)?"":`${Ol(Ll([t]))} `)+$a(t)}function Ol(t){return`"${t}"`}function Ll(t,e=1/0,n=$a){let r=[];var i;i=t[0],Gl(),kl.has(i)&&r.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let s=0,o=t.length;for(let a=0;a<o;a++){let e=t[a];Fl(e)&&(r.push(tl(t.slice(s,a))),r.push(n(e)),s=a+1)}return r.push(tl(t.slice(s,o))),r.join("")}function Fl(t){return Gl(),Nl.has(t)}function Ul(t){return e=function(t,e,n){if(!t)return[];Gl();let r=0;return t.split(wl).map((t=>{let i=function(t){let e=[];for(let n=0,r=t.length;n<r;){let r=t.codePointAt(n);n+=r<65536?1:2,e.push(r)}return e}(t),s={input:i,offset:r};r+=i.length+1;try{let t,r=s.tokens=function(t,e,n){let r=[],i=[];for(t=t.slice().reverse();t.length;){let s=Ql(t);if(s)i.length&&(r.push(e(i)),i=[]),r.push(n(s));else{let e=t.pop();if(Ml.has(e))i.push(e);else{let t=El.get(e);if(t)i.push(...t);else if(!xl.has(e))throw Dl(e)}}}return i.length&&r.push(e(i)),r}(i,e,n),o=r.length;if(!o)throw new Error("empty label");let a=s.output=r.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(a),!(s.emoji=o>1||r[0].is_emoji)&&a.every((t=>t<128)))!function(t){if(t.length>=4&&45==t[2]&&45==t[3])throw new Error(`invalid label extension: "${tl(t.slice(0,4))}"`)}(a),t="ASCII";else{let e=r.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(kl.has(a[0]))throw Hl("leading combining mark");for(let t=1;t<o;t++){let e=r[t];if(!e.is_emoji&&kl.has(e[0]))throw Hl(`emoji + combining mark: "${tl(r[t-1])} + ${Ll([e[0]])}"`)}!function(t){let e=t[0],n=Ha.get(e);if(n)throw Hl(`leading ${n}`);let r=t.length,i=-1;for(let s=1;s<r;s++){e=t[s];let r=Ha.get(e);if(r){if(i==s)throw Hl(`${n} + ${r}`);i=s+1,n=r}}if(i==r)throw Hl(`trailing ${n}`)}(a);let n=vl(new Set(e)),[i]=function(t){let e=Cl;for(let n of t){let t=e.filter((t=>bl(t,n)));if(!t.length)throw Cl.some((t=>bl(t,n)))?jl(e[0],n):Dl(n);if(e=t,1==t.length)break}return e}(n);!function(t,e){for(let n of e)if(!bl(t,n))throw jl(t,n);if(t.M){let t=yl(e);for(let e=1,n=t.length;e<n;e++)if(Sl.has(t[e])){let r=e+1;for(let i;r<n&&Sl.has(i=t[r]);r++)for(let n=e;n<r;n++)if(t[n]==i)throw new Error(`duplicate non-spacing marks: ${Il(i)}`);if(r-e>4)throw new Error(`excessive non-spacing marks: ${Ol(Ll(t.slice(e-1,r)))} (${r-e}/4)`);e=r}}}(i,e),function(t,e){let n,r=[];for(let i of e){let t=Tl.get(i);if(1===t)return;if(t){let e=t.M.get(i);if(n=n?n.filter((t=>e.has(t))):vl(e),!n.length)return}else r.push(i)}if(n)for(let i of n)if(r.every((t=>bl(i,t))))throw new Error(`whole-script confusable: ${t.N}/${i.N}`)}(i,n),t=i.N}else t="Emoji"}s.type=t}catch(o){s.error=o}return s}))}(t,_l,Wl),e.map((({input:t,error:n,output:r})=>{if(n){let r=n.message;throw new Error(1==e.length?r:`Invalid label ${Ol(Ll(t,63))}: ${r}`)}return tl(r)})).join(wl);var e}function Dl(t){return new Error(`disallowed character: ${Il(t)}`)}function jl(t,e){let n=Il(e),r=Cl.find((t=>t.P.has(e)));return r&&(n=`${r.N} ${n}`),new Error(`illegal mixture: ${t.N} + ${n}`)}function Hl(t){return new Error(`illegal placement: ${t}`)}function Wl(t){return t.filter((t=>65039!=t))}function Ql(t,e){let n,r=Bl,i=t.length;for(;i&&(r=r.get(t[--i]),r);){let{V:s}=r;s&&(n=s,e&&e.push(...t.slice(i).reverse()),t.length=i)}return n}const zl=new Uint8Array(32);function Vl(t){return Ln(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Kl(t){const e=_r(function(t){try{if(0===t.length)throw new Error("empty label");return Ul(t)}catch(e){Ln(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),n=[];if(0===t.length)return n;let r=0;for(let i=0;i<e.length;i++){46===e[i]&&(n.push(Vl(e.slice(r,i))),r=i+1)}return Ln(r<e.length,"invalid ENS name; empty component","name",t),n.push(Vl(e.slice(r))),n}function Jl(t){Ln("string"==typeof t,"invalid ENS name; not a string","name",t),Ln(t.length,"invalid ENS name (empty label)","name",t);let e=zl;const n=Kl(t);for(;n.length;)e=vs(Jn([e,vs(n.pop())]));return Kn(e)}function ql(t,e){const n=null!=e?e:63;return Ln(n<=255,"DNS encoded label cannot exceed 255","length",n),Kn(Jn(Kl(t).map((e=>{Ln(e.length<=n,`label ${JSON.stringify(t)} exceeds ${n} bytes`,"name",t);const r=new Uint8Array(e.length+1);return r.set(e,1),r[0]=r.length-1,r}))))+"00"}zl.fill(0);const Zl=new Uint8Array(32);Zl.fill(0);const Yl=BigInt(-1),Xl=BigInt(0),$l=BigInt(1),tc=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const ec=ur($l,32),nc=ur(Xl,32),rc={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},ic=["name","version","chainId","verifyingContract","salt"];function sc(t){return function(e){return Ln("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const oc={name:sc("name"),version:sc("version"),chainId:function(t){const e=sr(t,"domain.chainId");return Ln(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):dr(e)},verifyingContract:function(t){try{return Ko(t).toLowerCase()}catch(e){}Ln(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=Hn(t,"domain.salt");return Ln(32===e.length,'invalid domain value "salt"',"domain.salt",t),Kn(e)}};function ac(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const n=""===e[1],r=parseInt(e[2]);Ln(r%8==0&&0!==r&&r<=256&&e[2]===String(r),"invalid numeric width","type",t);const i=ir(tc,n?r-1:r),s=n?(i+$l)*Yl:Xl;return function(e){const r=sr(e,"value");return Ln(r>=s&&r<=i,`value out-of-bounds for ${t}`,"value",r),ur(n?rr(r,256):r,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const n=parseInt(e[1]);return Ln(0!==n&&n<=32&&e[1]===String(n),"invalid bytes width","type",t),function(e){return Ln(Hn(e).length===n,`invalid length for ${t}`,"value",e),function(t){const e=Hn(t),n=e.length%32;return n?Jn([e,Zl.slice(n)]):Kn(e)}(e)}}}switch(t){case"address":return function(t){return Xn(Ko(t),32)};case"bool":return function(t){return t?ec:nc};case"bytes":return function(t){return vs(t)};case"string":return function(t){return ja(t)}}return null}function lc(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}function cc(t){const e=t.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:t}}Ct=new WeakMap,Pt=new WeakMap,Tt=new WeakMap,Mt=new WeakSet,Rt=function(t){{const e=ac(t);if(e)return e}const e=cc(t).array;if(e){const t=e.prefix,n=this.getEncoder(t);return r=>{Ln(-1===e.count||e.count===r.length,`array length mismatch; expected length ${e.count}`,"value",r);let i=r.map(n);return __privateGet(this,Pt).has(t)&&(i=i.map(vs)),vs(Jn(i))}}const n=this.types[t];if(n){const e=ja(__privateGet(this,Pt).get(t));return t=>{const r=n.map((({name:e,type:n})=>{const r=this.getEncoder(n)(t[e]);return __privateGet(this,Pt).has(n)?vs(r):r}));return r.unshift(e),Jn(r)}}Ln(!1,`unknown type: ${t}`,"type",t)};let uc=class t{constructor(t){__privateAdd(this,Mt),__publicField(this,"primaryType"),__privateAdd(this,Ct,void 0),__privateAdd(this,Pt,void 0),__privateAdd(this,Tt,void 0),__privateSet(this,Pt,new Map),__privateSet(this,Tt,new Map);const e=new Map,n=new Map,r=new Map,i={};Object.keys(t).forEach((s=>{i[s]=t[s].map((({name:e,type:n})=>{let{base:r,index:i}=cc(n);return"int"!==r||t.int||(r="int256"),"uint"!==r||t.uint||(r="uint256"),{name:e,type:r+(i||"")}})),e.set(s,new Set),n.set(s,[]),r.set(s,new Set)})),__privateSet(this,Ct,JSON.stringify(i));for(const o in i){const r=new Set;for(const s of i[o]){Ln(!r.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(o)}`,"types",t),r.add(s.name);const i=cc(s.type).base;Ln(i!==o,`circular type reference to ${JSON.stringify(i)}`,"types",t);ac(i)||(Ln(n.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),n.get(i).push(o),e.get(o).add(i))}}const s=Array.from(n.keys()).filter((t=>0===n.get(t).length));Ln(0!==s.length,"missing primary type","types",t),Ln(1===s.length,`ambiguous primary types or unused types: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Mn(this,{primaryType:s[0]}),function i(s,o){Ln(!o.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),o.add(s);for(const t of e.get(s))if(n.has(t)){i(t,o);for(const e of o)r.get(e).add(t)}o.delete(s)}(this.primaryType,new Set);for(const[o,a]of r){const t=Array.from(a);t.sort(),__privateGet(this,Pt).set(o,lc(o,i[o])+t.map((t=>lc(t,i[t]))).join(""))}}get types(){return JSON.parse(__privateGet(this,Ct))}getEncoder(t){let e=__privateGet(this,Tt).get(t);return e||(e=__privateMethod(this,Mt,Rt).call(this,t),__privateGet(this,Tt).set(t,e)),e}encodeType(t){const e=__privateGet(this,Pt).get(t);return Ln(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return vs(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,n){if(ac(t))return n(t,e);const r=cc(t).array;if(r)return Ln(-1===r.count||r.count===e.length,`array length mismatch; expected length ${r.count}`,"value",e),e.map((t=>this._visit(r.prefix,t,n)));const i=this.types[t];if(i)return i.reduce(((t,{name:r,type:i})=>(t[r]=this._visit(i,e[r],n),t)),{});Ln(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(e){return new t(e)}static getPrimaryType(e){return t.from(e).primaryType}static hashStruct(e,n,r){return t.from(n).hashStruct(e,r)}static hashDomain(e){const n=[];for(const t in e){if(null==e[t])continue;const r=rc[t];Ln(r,`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",e),n.push({name:t,type:r})}return n.sort(((t,e)=>ic.indexOf(t.name)-ic.indexOf(e.name))),t.hashStruct("EIP712Domain",{EIP712Domain:n},e)}static encode(e,n,r){return Jn(["0x1901",t.hashDomain(e),t.from(n).hash(r)])}static hash(e,n,r){return vs(t.encode(e,n,r))}static resolveNames(e,n,r,i){return __async(this,null,(function*(){e=Object.assign({},e);for(const t in e)null==e[t]&&delete e[t];const s={};e.verifyingContract&&!Qn(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=t.from(n);o.visit(r,((t,e)=>("address"!==t||Qn(e,20)||(s[e]="0x"),e)));for(const t in s)s[t]=yield i(t);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:e,value:r}}))}static getPayload(e,n,r){t.hashDomain(e);const i={},s=[];ic.forEach((t=>{const n=e[t];null!=n&&(i[t]=oc[t](n),s.push({name:t,type:rc[t]}))}));const o=t.from(n);n=o.types;const a=Object.assign({},n);return Ln(null==a.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",n),a.EIP712Domain=s,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return Kn(Hn(e));if(t.match(/^u?int/))return sr(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return Ln("string"==typeof e,"invalid string","value",e),e}Ln(!1,"unsupported type","type",t)}))}}};function hc(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const dc=hc("external public payable override".split(" ")),pc="constant external internal payable private public pure view override",fc=hc(pc.split(" ")),gc="constructor error event fallback function receive struct",mc=hc(gc.split(" ")),yc="calldata memory storage payable indexed",_c=hc(yc.split(" ")),wc=hc([gc,yc,"tuple returns",pc].join(" ").split(" ")),vc={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},bc=new RegExp("^(\\s*)"),Ac=new RegExp("^([0-9]+)"),Ec=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),xc=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),kc=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Sc=class t{constructor(t){__privateAdd(this,It),__privateAdd(this,Bt,void 0),__privateAdd(this,Gt,void 0),__privateSet(this,Bt,0),__privateSet(this,Gt,t.slice())}get offset(){return __privateGet(this,Bt)}get length(){return __privateGet(this,Gt).length-__privateGet(this,Bt)}clone(){return new t(__privateGet(this,Gt))}reset(){__privateSet(this,Bt,0)}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=__privateMethod(this,It,Ot).call(this,__privateGet(this,Bt)+1,t.match+1);return __privateSet(this,Bt,t.match+1),e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;__privateGet(this,Bt)<t.match-1;){const t=this.peek().linkNext;e.push(__privateMethod(this,It,Ot).call(this,__privateGet(this,Bt)+1,t)),__privateSet(this,Bt,t)}return __privateSet(this,Bt,t.match+1),e}peek(){if(__privateGet(this,Bt)>=__privateGet(this,Gt).length)throw new Error("out-of-bounds");return __privateGet(this,Gt)[__privateGet(this,Bt)]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return __privateWrapper(this,Bt)._++,t}toString(){const t=[];for(let e=__privateGet(this,Bt);e<__privateGet(this,Gt).length;e++){const n=__privateGet(this,Gt)[e];t.push(`${n.type}:${n.text}`)}return`<TokenString ${t.join(" ")}>`}};Bt=new WeakMap,Gt=new WeakMap,It=new WeakSet,Ot=function(t=0,e=0){return new Sc(__privateGet(this,Gt).slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))};let Nc=Sc;function Cc(t){const e=[],n=e=>{const n=s<t.length?JSON.stringify(t[s]):"$EOI";throw new Error(`invalid token ${n} at ${s}: ${e}`)};let r=[],i=[],s=0;for(;s<t.length;){let o=t.substring(s),a=o.match(bc);a&&(s+=a[1].length,o=t.substring(s));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(l);let c=vc[o[0]]||"";if(c){if(l.type=c,l.text=o[0],s++,"OPEN_PAREN"===c)r.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===r.length&&n("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1;else if("COMMA"===c)l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1,i.push(e.length-1);else if("OPEN_BRACKET"===c)l.type="BRACKET";else if("CLOSE_BRACKET"===c){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const n=e.pop().text;t=n+t,e[e.length-1].value=cr(n)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(a=o.match(Ec),a){if(l.text=a[1],s+=l.text.length,wc.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(kc)){l.type="TYPE";continue}l.type="ID"}else{if(a=o.match(Ac),!a)throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${s}`);l.text=a[1],l.type="NUMBER",s+=l.text.length}}return new Nc(e.map((t=>Object.freeze(t))))}function Pc(t,e){let n=[];for(const r in e.keys())t.has(r)&&n.push(r);if(n.length>1)throw new Error(`conflicting types: ${n.join(", ")}`)}function Tc(t,e){if(e.peekKeyword(mc)){const n=e.pop().text;if(n!==t)throw new Error(`expected ${t}, got ${n}`)}return e.popType("ID")}function Mc(t,e){const n=new Set;for(;;){const r=t.peekType("KEYWORD");if(null==r||e&&!e.has(r))break;if(t.pop(),n.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}function Rc(t){let e=Mc(t,fc);return Pc(e,hc("constant payable nonpayable".split(" "))),Pc(e,hc("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 Bc(t,e){return t.popParams().map((t=>Kc.from(t,e)))}function Gc(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return sr(t.pop().text);throw new Error("invalid gas")}return null}function Ic(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const Oc=new RegExp(/^(.*)\[([0-9]*)\]$/);function Lc(t){const e=t.match(kc);if(Ln(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const n=parseInt(e[2]);Ln(0!==n&&n<=32,"invalid bytes length","type",t)}else if(e[3]){const n=parseInt(e[3]);Ln(0!==n&&n<=256&&n%8==0,"invalid numeric width","type",t)}return t}const Fc={},Uc=Symbol.for("_ethers_internal"),Dc="_ParamTypeInternal",jc="_ErrorInternal",Hc="_EventInternal",Wc="_ConstructorInternal",Qc="_FallbackInternal",zc="_FunctionInternal",Vc="_StructInternal";Lt=new WeakSet,Ft=function(t,e,n,r){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const i=this.arrayChildren,s=e.slice();return s.forEach(((e,r)=>{var o;__privateMethod(o=i,Lt,Ft).call(o,t,e,n,(t=>{s[r]=t}))})),void r(s)}if(this.isTuple()){const i=this.components;let s;if(Array.isArray(e))s=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");s=i.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(s.length!==this.components.length)throw new Error("array is wrong length");return s.forEach(((e,r)=>{var o;__privateMethod(o=i[r],Lt,Ft).call(o,t,e,n,(t=>{s[r]=t}))})),void r(s)}const i=n(this.type,e);i.then?t.push(function(){return __async(this,null,(function*(){r(yield i)}))}()):r(i)};let Kc=class t{constructor(t,e,n,r,i,s,o,a){if(__privateAdd(this,Lt),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),Dn(t,Fc,"ParamType"),Object.defineProperty(this,Uc,{value:Dc}),s&&(s=Object.freeze(s.slice())),"array"===r){if(null==o||null==a)throw new Error("")}else if(null!=o||null!=a)throw new Error("");if("tuple"===r){if(null==s)throw new Error("")}else if(null!=s)throw new Error("");Mn(this,{name:e,type:n,baseType:r,indexed:i,components:s,arrayLength:o,arrayChildren:a})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const n={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(n)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map((t=>n.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map(((t,r)=>n.components[r].walk(t,e)))}return e(this.type,t)}walkAsync(t,e){return __async(this,null,(function*(){const n=[],r=[t];return __privateMethod(this,Lt,Ft).call(this,n,t,e,(t=>{r[0]=t})),n.length&&(yield Promise.all(n)),r[0]}))}static from(e,n){if(t.isParamType(e))return e;if("string"==typeof e)try{return t.from(Cc(e),n)}catch(a){Ln(!1,"invalid param type","obj",e)}else if(e instanceof Nc){let r="",i="",s=null;Mc(e,hc(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(i="tuple",s=e.popParams().map((e=>t.from(e))),r=`tuple(${s.map((t=>t.format())).join(",")})`):(r=Lc(e.popType("TYPE")),i=r);let o=null,a=null;for(;e.length&&e.peekType("BRACKET");){const n=e.pop();o=new t(Fc,"",r,i,null,s,a,o),a=n.value,r+=n.text,i="array",s=null}let l=null;if(Mc(e,_c).has("indexed")){if(!n)throw new Error("");l=!0}const c=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new t(Fc,c,r,i,l,s,a,o)}const r=e.name;Ln(!r||"string"==typeof r&&r.match(xc),"invalid name","obj.name",r);let i=e.indexed;null!=i&&(Ln(n,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,o=s.match(Oc);if(o){const n=parseInt(o[2]||"-1"),a=t.from({type:o[1],components:e.components});return new t(Fc,r||"",s,"array",i,null,n,a)}if("tuple"===s||s.startsWith("tuple(")||s.startsWith("(")){const n=null!=e.components?e.components.map((e=>t.from(e))):null;return new t(Fc,r||"",s,"tuple",i,n,null,null)}return s=Lc(e.type),new t(Fc,r||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Uc]===Dc}};class Jc{constructor(t,e,n){__publicField(this,"type"),__publicField(this,"inputs"),Dn(t,Fc,"Fragment"),Mn(this,{type:e,inputs:n=Object.freeze(n.slice())})}static from(t){if("string"==typeof t){try{Jc.from(JSON.parse(t))}catch(e){}return Jc.from(Cc(t))}if(t instanceof Nc){switch(t.peekKeyword(mc)){case"constructor":return $c.from(t);case"error":return Yc.from(t);case"event":return Xc.from(t);case"fallback":case"receive":return tu.from(t);case"function":return eu.from(t);case"struct":return nu.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return $c.from(t);case"error":return Yc.from(t);case"event":return Xc.from(t);case"fallback":case"receive":return tu.from(t);case"function":return eu.from(t);case"struct":return nu.from(t)}On(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}Ln(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return $c.isFragment(t)}static isError(t){return Yc.isFragment(t)}static isEvent(t){return Xc.isFragment(t)}static isFunction(t){return eu.isFragment(t)}static isStruct(t){return nu.isFragment(t)}}class qc extends Jc{constructor(t,e,n,r){super(t,e,r),__publicField(this,"name"),Ln("string"==typeof n&&n.match(xc),"invalid identifier","name",n),r=Object.freeze(r.slice()),Mn(this,{name:n})}}function Zc(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class Yc extends qc{constructor(t,e,n){super(t,"error",e,n),Object.defineProperty(this,Uc,{value:jc})}get selector(){return ja(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("error"),e.push(this.name+Zc(t,this.inputs)),e.join(" ")}static from(t){if(Yc.isFragment(t))return t;if("string"==typeof t)return Yc.from(Cc(t));if(t instanceof Nc){const e=Tc("error",t),n=Bc(t);return Ic(t),new Yc(Fc,e,n)}return new Yc(Fc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Uc]===jc}}class Xc extends qc{constructor(t,e,n,r){super(t,"event",e,n),__publicField(this,"anonymous"),Object.defineProperty(this,Uc,{value:Hc}),Mn(this,{anonymous:r})}get topicHash(){return ja(this.format("sighash"))}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("event"),e.push(this.name+Zc(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){e=(e||[]).map((t=>Kc.from(t)));return new Xc(Fc,t,e,!1).topicHash}static from(t){if(Xc.isFragment(t))return t;if("string"==typeof t)try{return Xc.from(Cc(t))}catch(e){Ln(!1,"invalid event fragment","obj",t)}else if(t instanceof Nc){const e=Tc("event",t),n=Bc(t,!0),r=!!Mc(t,hc(["anonymous"])).has("anonymous");return Ic(t),new Xc(Fc,e,n,r)}return new Xc(Fc,t.name,t.inputs?t.inputs.map((t=>Kc.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Uc]===Hc}}class $c extends Jc{constructor(t,e,n,r,i){super(t,e,n),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:Wc}),Mn(this,{payable:r,gas:i})}format(t){if(On(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${Zc(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if($c.isFragment(t))return t;if("string"==typeof t)try{return $c.from(Cc(t))}catch(e){Ln(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Nc){Mc(t,hc(["constructor"]));const e=Bc(t),n=!!Mc(t,dc).has("payable"),r=Gc(t);return Ic(t),new $c(Fc,"constructor",e,n,r)}return new $c(Fc,"constructor",t.inputs?t.inputs.map(Kc.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===Wc}}class tu extends Jc{constructor(t,e,n){super(t,"fallback",e),__publicField(this,"payable"),Object.defineProperty(this,Uc,{value:Qc}),Mn(this,{payable:n})}format(t){const e=0===this.inputs.length?"receive":"fallback";if("json"===t){const t=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:t})}return`${e}()${this.payable?" payable":""}`}static from(t){if(tu.isFragment(t))return t;if("string"==typeof t)try{return tu.from(Cc(t))}catch(e){Ln(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Nc){const e=t.toString();Ln(t.peekKeyword(hc(["fallback","receive"])),"type must be fallback or receive","obj",e);if("receive"===t.popKeyword(hc(["fallback","receive"]))){const e=Bc(t);return Ln(0===e.length,"receive cannot have arguments","obj.inputs",e),Mc(t,hc(["payable"])),Ic(t),new tu(Fc,[],!0)}let n=Bc(t);n.length?Ln(1===n.length&&"bytes"===n[0].type,"invalid fallback inputs","obj.inputs",n.map((t=>t.format("minimal"))).join(", ")):n=[Kc.from("bytes")];const r=Rc(t);if(Ln("nonpayable"===r||"payable"===r,"fallback cannot be constants","obj.stateMutability",r),Mc(t,hc(["returns"])).has("returns")){const e=Bc(t);Ln(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Ic(t),new tu(Fc,n,"payable"===r)}if("receive"===t.type)return new tu(Fc,[],!0);if("fallback"===t.type){const e=[Kc.from("bytes")],n="payable"===t.stateMutability;return new tu(Fc,e,n)}Ln(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Uc]===Qc}}class eu extends qc{constructor(t,e,n,r,i,s){super(t,"function",e,r),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:zc});Mn(this,{constant:"view"===n||"pure"===n,gas:s,outputs:i=Object.freeze(i.slice()),payable:"payable"===n,stateMutability:n})}get selector(){return ja(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("function"),e.push(this.name+Zc(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(Zc(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){e=(e||[]).map((t=>Kc.from(t)));return new eu(Fc,t,"view",e,[],null).selector}static from(t){if(eu.isFragment(t))return t;if("string"==typeof t)try{return eu.from(Cc(t))}catch(n){Ln(!1,"invalid function fragment","obj",t)}else if(t instanceof Nc){const e=Tc("function",t),n=Bc(t),r=Rc(t);let i=[];Mc(t,hc(["returns"])).has("returns")&&(i=Bc(t));const s=Gc(t);return Ic(t),new eu(Fc,e,r,n,i,s)}let e=t.stateMutability;return null==e&&(e="payable","boolean"==typeof t.constant?(e="view",t.constant||(e="payable","boolean"!=typeof t.payable||t.payable||(e="nonpayable"))):"boolean"!=typeof t.payable||t.payable||(e="nonpayable")),new eu(Fc,t.name,e,t.inputs?t.inputs.map(Kc.from):[],t.outputs?t.outputs.map(Kc.from):[],null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===zc}}class nu extends qc{constructor(t,e,n){super(t,"struct",e,n),Object.defineProperty(this,Uc,{value:Vc})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return nu.from(Cc(t))}catch(e){Ln(!1,"invalid struct fragment","obj",t)}else if(t instanceof Nc){const e=Tc("struct",t),n=Bc(t);return Ic(t),new nu(Fc,e,n)}return new nu(Fc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Uc]===Vc}}const ru=new Map;ru.set(0,"GENERIC_PANIC"),ru.set(1,"ASSERT_FALSE"),ru.set(17,"OVERFLOW"),ru.set(18,"DIVIDE_BY_ZERO"),ru.set(33,"ENUM_RANGE_ERROR"),ru.set(34,"BAD_STORAGE_DATA"),ru.set(49,"STACK_UNDERFLOW"),ru.set(50,"ARRAY_RANGE_ERROR"),ru.set(65,"OUT_OF_MEMORY"),ru.set(81,"UNINITIALIZED_FUNCTION_CALL");const iu=new RegExp(/^bytes([0-9]*)$/),su=new RegExp(/^(u?int)([0-9]*)$/);let ou=null,au=1024;Ut=new WeakSet,Dt=function(t){if(t.isArray())return new oa(__privateMethod(this,Ut,Dt).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new _a(t.components.map((t=>__privateMethod(this,Ut,Dt).call(this,t))),t.name);switch(t.baseType){case"address":return new na(t.name);case"bool":return new aa(t.name);case"string":return new ya(t.name);case"bytes":return new ca(t.name);case"":return new da(t.name)}let e=t.type.match(su);if(e){let n=parseInt(e[2]||"256");return Ln(0!==n&&n<=256&&n%8==0,"invalid "+e[1]+" bit length","param",t),new ma(n/8,"int"===e[1],t.name)}if(e=t.type.match(iu),e){let n=parseInt(e[1]);return Ln(0!==n&&n<=32,"invalid bytes length","param",t),new ua(n,t.name)}Ln(!1,"invalid type","type",t.type)};let lu=class t{constructor(){__privateAdd(this,Ut)}getDefaultValue(t){const e=t.map((t=>__privateMethod(this,Ut,Dt).call(this,Kc.from(t))));return new _a(e,"_").defaultValue()}encode(t,e){Fn(e.length,t.length,"types/values length mismatch");const n=t.map((t=>__privateMethod(this,Ut,Dt).call(this,Kc.from(t)))),r=new _a(n,"_"),i=new yi;return r.encode(i,e),i.data}decode(t,e,n){const r=t.map((t=>__privateMethod(this,Ut,Dt).call(this,Kc.from(t))));return new _a(r,"_").decode(new _i(e,n,au))}static _setDefaultMaxInflation(t){Ln("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),au=t}static defaultAbiCoder(){return null==ou&&(ou=new t),ou}static getBuiltinCallException(e,n,r){return function(t,e,n,r){let i="missing revert data",s=null,o=null;if(n){i="execution reverted";const t=Hn(n);if(n=Kn(n),0===t.length)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(t.length%32!=4)i+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===Kn(t.slice(0,4)))try{s=r.decode(["string"],t.slice(4))[0],o={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch(l){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===Kn(t.slice(0,4)))try{const e=Number(r.decode(["uint256"],t.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[e]},s=`Panic due to ${ru.get(e)||"UNKNOWN"}(${e})`,i+=`: ${s}`}catch(l){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const a={to:e.to?Ko(e.to):null,data:e.data||"0x"};return e.from&&(a.from=Ko(e.from)),In(i,"CALL_EXCEPTION",{action:t,data:n,reason:s,transaction:a,invocation:null,revert:o})}(e,n,r,t.defaultAbiCoder())}};class cu{constructor(t,e,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const r=t.name,i=t.format();Mn(this,{fragment:t,name:r,signature:i,topic:e,args:n})}}class uu{constructor(t,e,n,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector"),__publicField(this,"value");const i=t.name,s=t.format();Mn(this,{fragment:t,name:i,args:n,signature:s,selector:e,value:r})}}class hu{constructor(t,e,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const r=t.name,i=t.format();Mn(this,{fragment:t,name:r,args:n,signature:i,selector:e})}}class du{constructor(t){__publicField(this,"hash"),__publicField(this,"_isIndexed"),Mn(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!(!t||!t._isIndexed)}}const pu={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"},fu={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:t=>`reverted with reason string ${JSON.stringify(t)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:t=>{let e="unknown panic code";return t>=0&&t<=255&&pu[t.toString()]&&(e=pu[t.toString()]),`reverted with panic code 0x${t.toString(16)} (${e})`}}};jt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,Qt=new WeakMap,zt=new WeakSet,Vt=function(t,e,n){if(Qn(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Wt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const r=[];for(const[e,n]of __privateGet(this,Wt))e.split("(")[0]===t&&r.push(n);if(e){const t=e.length>0?e[e.length-1]:null;let n=e.length,i=!0;ea.isTyped(t)&&"overrides"===t.type&&(i=!1,n--);for(let e=r.length-1;e>=0;e--){const t=r[e].inputs.length;t===n||i&&t===n-1||r.splice(e,1)}for(let s=r.length-1;s>=0;s--){const t=r[s].inputs;for(let n=0;n<e.length;n++)if(ea.isTyped(e[n])){if(n>=t.length){if("overrides"===e[n].type)continue;r.splice(s,1);break}if(e[n].type!==t[n].baseType){r.splice(s,1);break}}}}if(1===r.length&&e&&e.length!==r[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&r.splice(0,1)}if(0===r.length)return null;if(r.length>1&&n){Ln(!1,`ambiguous function description (i.e. matches ${r.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return r[0]}const r=__privateGet(this,Wt).get(eu.from(t).format());return r||null},Kt=new WeakSet,Jt=function(t,e,n){if(Qn(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Ht).values())if(e===t.topicHash)return t;return null}if(-1===t.indexOf("(")){const r=[];for(const[e,n]of __privateGet(this,Ht))e.split("(")[0]===t&&r.push(n);if(e){for(let t=r.length-1;t>=0;t--)r[t].inputs.length<e.length&&r.splice(t,1);for(let t=r.length-1;t>=0;t--){const n=r[t].inputs;for(let i=0;i<e.length;i++)if(ea.isTyped(e[i])&&e[i].type!==n[i].baseType){r.splice(t,1);break}}}if(0===r.length)return null;if(r.length>1&&n){Ln(!1,`ambiguous event description (i.e. matches ${r.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return r[0]}const r=__privateGet(this,Ht).get(Xc.from(t).format());return r||null};let gu=class t{constructor(t){__privateAdd(this,zt),__privateAdd(this,Kt),__publicField(this,"fragments"),__publicField(this,"deploy"),__publicField(this,"fallback"),__publicField(this,"receive"),__privateAdd(this,jt,void 0),__privateAdd(this,Ht,void 0),__privateAdd(this,Wt,void 0),__privateAdd(this,Qt,void 0);let e=[];e="string"==typeof t?JSON.parse(t):t,__privateSet(this,Wt,new Map),__privateSet(this,jt,new Map),__privateSet(this,Ht,new Map);const n=[];for(const o of e)try{n.push(Jc.from(o))}catch(s){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,s.message)}Mn(this,{fragments:Object.freeze(n)});let r=null,i=!1;__privateSet(this,Qt,this.getAbiCoder()),this.fragments.forEach(((t,e)=>{let n;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void Mn(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(Ln(!r||t.payable!==r.payable,"conflicting fallback fragments",`fragments[${e}]`,t),r=t,i=r.payable));case"function":n=__privateGet(this,Wt);break;case"event":n=__privateGet(this,Ht);break;case"error":n=__privateGet(this,jt);break;default:return}const s=t.format();n.has(s)||n.set(s,t)})),this.deploy||Mn(this,{deploy:$c.from("constructor()")}),Mn(this,{fallback:r,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map((t=>t.format(e)))}formatJson(){const t=this.fragments.map((t=>t.format("json")));return JSON.stringify(t.map((t=>JSON.parse(t))))}getAbiCoder(){return lu.defaultAbiCoder()}getFunctionName(t){const e=__privateMethod(this,zt,Vt).call(this,t,null,!1);return Ln(e,"no matching function","key",t),e.name}hasFunction(t){return!!__privateMethod(this,zt,Vt).call(this,t,null,!1)}getFunction(t,e){return __privateMethod(this,zt,Vt).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(__privateGet(this,Wt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let n=0;n<e.length;n++){const r=e[n];t(__privateGet(this,Wt).get(r),n)}}getEventName(t){const e=__privateMethod(this,Kt,Jt).call(this,t,null,!1);return Ln(e,"no matching event","key",t),e.name}hasEvent(t){return!!__privateMethod(this,Kt,Jt).call(this,t,null,!1)}getEvent(t,e){return __privateMethod(this,Kt,Jt).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(__privateGet(this,Ht).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let n=0;n<e.length;n++){const r=e[n];t(__privateGet(this,Ht).get(r),n)}}getError(t,e){if(Qn(t)){const e=t.toLowerCase();if(fu[e])return Yc.from(fu[e].signature);for(const t of __privateGet(this,jt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[n,r]of __privateGet(this,jt))n.split("(")[0]===t&&e.push(r);if(0===e.length)return"Error"===t?Yc.from("error Error(string)"):"Panic"===t?Yc.from("error Panic(uint256)"):null;if(e.length>1){Ln(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t)}return e[0]}if("Error(string)"===(t=Yc.from(t).format()))return Yc.from("error Error(string)");if("Panic(uint256)"===t)return Yc.from("error Panic(uint256)");const n=__privateGet(this,jt).get(t);return n||null}forEachError(t){const e=Array.from(__privateGet(this,jt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let n=0;n<e.length;n++){const r=e[n];t(__privateGet(this,jt).get(r),n)}}_decodeParams(t,e){return __privateGet(this,Qt).decode(t,e)}_encodeParams(t,e){return __privateGet(this,Qt).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Ln(e,"unknown error","fragment",t),t=e}return Ln(Zn(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,Zn(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Ln(e,"unknown error","fragment",t),t=e}return Jn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}return Ln(Zn(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,Zn(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}return Jn([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}let n="invalid length for result data";const r=Wn(e);if(r.length%32==0)try{return __privateGet(this,Qt).decode(t.outputs,r)}catch(i){n="could not decode result data"}On(!1,n,"BAD_DATA",{value:Kn(r),info:{method:t.name,signature:t.format()}})}makeError(t,e){const n=Hn(t,"data"),r=lu.getBuiltinCallException("call",e,n);if(r.message.startsWith("execution reverted (unknown custom error)")){const t=Kn(n.slice(0,4)),e=this.getError(t);if(e)try{const t=__privateGet(this,Qt).decode(e.inputs,n.slice(4));r.revert={name:e.name,signature:e.format(),args:t},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch(s){r.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(r.invocation={method:i.name,signature:i.signature,args:i.args}),r}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Ln(e,"unknown function","fragment",t),t=e}return Kn(__privateGet(this,Qt).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);Ln(e,"unknown event","eventFragment",t),t=e}On(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const n=[];t.anonymous||n.push(t.topicHash);const r=(t,e)=>"string"===t.type?ja(e):"bytes"===t.type?vs(Kn(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=ur(e):t.type.match(/^bytes/)?e=Yn(e,32,!1):"address"===t.type&&__privateGet(this,Qt).encode(["address"],[e]),Xn(Kn(e),32));for(e.forEach(((e,i)=>{const s=t.inputs[i];s.indexed?null==e?n.push(null):"array"===s.baseType||"tuple"===s.baseType?Ln(!1,"filtering with tuples or arrays not supported","contract."+s.name,e):Array.isArray(e)?n.push(e.map((t=>r(s,t)))):n.push(r(s,e)):Ln(null==e,"cannot filter non-indexed parameters; must be null","contract."+s.name,e)}));n.length&&null===n[n.length-1];)n.pop();return n}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);Ln(e,"unknown event","eventFragment",t),t=e}const n=[],r=[],i=[];return t.anonymous||n.push(t.topicHash),Ln(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,s)=>{const o=e[s];if(t.indexed)if("string"===t.type)n.push(ja(o));else if("bytes"===t.type)n.push(vs(o));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");n.push(__privateGet(this,Qt).encode([t.type],[o]))}else r.push(t),i.push(o)})),{data:__privateGet(this,Qt).encode(r,i),topics:n}}decodeEventLog(t,e,n){if("string"==typeof t){const e=this.getEvent(t);Ln(e,"unknown event","eventFragment",t),t=e}if(null!=n&&!t.anonymous){const e=t.topicHash;Ln(Qn(n[0],32)&&n[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const r=[],i=[],s=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(r.push(Kc.from({type:"bytes32",name:t.name})),s.push(!0)):(r.push(t),s.push(!1)):(i.push(t),s.push(!1))}));const o=null!=n?__privateGet(this,Qt).decode(r,Jn(n)):null,a=__privateGet(this,Qt).decode(i,e,!0),l=[],c=[];let u=0,h=0;return t.inputs.forEach(((t,e)=>{let n=null;if(t.indexed)if(null==o)n=new du(null);else if(s[e])n=new du(o[h++]);else try{n=o[h++]}catch(r){n=r}else try{n=a[u++]}catch(r){n=r}l.push(n),c.push(t.name||null)})),fi.fromItems(l,c)}parseTransaction(t){const e=Hn(t.data,"tx.data"),n=sr(null!=t.value?t.value:0,"tx.value"),r=this.getFunction(Kn(e.slice(0,4)));if(!r)return null;const i=__privateGet(this,Qt).decode(r.inputs,e.slice(4));return new uu(r,r.selector,i,n)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new cu(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=Kn(t),n=this.getError(Zn(e,0,4));if(!n)return null;const r=__privateGet(this,Qt).decode(n.inputs,Zn(e,4));return new hu(n,n.selector,r)}static from(e){return e instanceof t?e:"string"==typeof e?new t(JSON.parse(e)):"function"==typeof e.formatJson?new t(e.formatJson()):"function"==typeof e.format?new t(e.format("json")):new t(e)}};const mu=BigInt(0);function yu(t){return null==t?null:t}function _u(t){return null==t?null:t.toString()}class wu{constructor(t,e,n){__publicField(this,"gasPrice"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxPriorityFeePerGas"),Mn(this,{gasPrice:yu(t),maxFeePerGas:yu(e),maxPriorityFeePerGas:yu(n)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:_u(t),maxFeePerGas:_u(e),maxPriorityFeePerGas:_u(n)}}}function vu(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=Kn(t.data));const n="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of n)i in t&&null!=t[i]&&(e[i]=sr(t[i],`request.${i}`));const r="type,nonce".split(/,/);for(const i of r)i in t&&null!=t[i]&&(e[i]=cr(t[i],`request.${i}`));return t.accessList&&(e.accessList=va(t.accessList)),t.authorizationList&&(e.authorizationList=t.authorizationList.slice()),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map((t=>zn(t)?Kn(t):Object.assign({},t)))),e}class bu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"number"),__publicField(this,"hash"),__publicField(this,"timestamp"),__publicField(this,"parentHash"),__publicField(this,"parentBeaconBlockRoot"),__publicField(this,"nonce"),__publicField(this,"difficulty"),__publicField(this,"gasLimit"),__publicField(this,"gasUsed"),__publicField(this,"stateRoot"),__publicField(this,"receiptsRoot"),__publicField(this,"blobGasUsed"),__publicField(this,"excessBlobGas"),__publicField(this,"miner"),__publicField(this,"prevRandao"),__publicField(this,"extraData"),__publicField(this,"baseFeePerGas"),__privateAdd(this,qt,void 0),__privateSet(this,qt,t.transactions.map((t=>"string"!=typeof t?new xu(t,e):t))),Mn(this,{provider:e,hash:yu(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:yu(t.prevRandao),extraData:t.extraData,baseFeePerGas:yu(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return __privateGet(this,qt).map((t=>"string"==typeof t?t:t.hash))}get prefetchedTransactions(){const t=__privateGet(this,qt).slice();return 0===t.length?[]:(On("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:n,gasLimit:r,gasUsed:i,hash:s,miner:o,prevRandao:a,nonce:l,number:c,parentHash:u,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,timestamp:f,transactions:g}=this;return{_type:"Block",baseFeePerGas:_u(t),difficulty:_u(e),extraData:n,gasLimit:_u(r),gasUsed:_u(i),blobGasUsed:_u(this.blobGasUsed),excessBlobGas:_u(this.excessBlobGas),hash:s,miner:o,prevRandao:a,nonce:l,number:c,parentHash:u,timestamp:f,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,transactions:g}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return __privateGet(this,qt).length}get date(){return null==this.timestamp?null:new Date(1e3*this.timestamp)}getTransaction(t){return __async(this,null,(function*(){let e;if("number"==typeof t)e=__privateGet(this,qt)[t];else{const n=t.toLowerCase();for(const t of __privateGet(this,qt)){if("string"==typeof t){if(t!==n)continue;e=t;break}if(t.hash===n){e=t;break}}}if(null==e)throw new Error("no such tx");return"string"==typeof e?yield this.provider.getTransaction(e):e}))}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if("number"==typeof t)return e[t];t=t.toLowerCase();for(const n of e)if(n.hash===t)return n;Ln(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return{orphan:"drop-block",hash:(t=this).hash,number:t.number};var t}}qt=new WeakMap;class Au{constructor(t,e){__publicField(this,"provider"),__publicField(this,"transactionHash"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"removed"),__publicField(this,"address"),__publicField(this,"data"),__publicField(this,"topics"),__publicField(this,"index"),__publicField(this,"transactionIndex"),this.provider=e;const n=Object.freeze(t.topics.slice());Mn(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:n,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:s,topics:o,transactionHash:a,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:n,data:r,index:i,removed:s,topics:o,transactionHash:a,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);return On(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.transactionHash);return On(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransactionReceipt(){return __async(this,null,(function*(){const t=yield this.provider.getTransactionReceipt(this.transactionHash);return On(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}))}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class Eu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"contractAddress"),__publicField(this,"hash"),__publicField(this,"index"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"logsBloom"),__publicField(this,"gasUsed"),__publicField(this,"blobGasUsed"),__publicField(this,"cumulativeGasUsed"),__publicField(this,"gasPrice"),__publicField(this,"blobGasPrice"),__publicField(this,"type"),__publicField(this,"status"),__publicField(this,"root"),__privateAdd(this,Zt,void 0),__privateSet(this,Zt,Object.freeze(t.logs.map((t=>new Au(t,e)))));let n=mu;null!=t.effectiveGasPrice?n=t.effectiveGasPrice:null!=t.gasPrice&&(n=t.gasPrice),Mn(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:n,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return __privateGet(this,Zt)}toJSON(){const{to:t,from:e,contractAddress:n,hash:r,index:i,blockHash:s,blockNumber:o,logsBloom:a,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:s,blockNumber:o,contractAddress:n,cumulativeGasUsed:_u(this.cumulativeGasUsed),from:e,gasPrice:_u(this.gasPrice),blobGasUsed:_u(this.blobGasUsed),blobGasPrice:_u(this.blobGasPrice),gasUsed:_u(this.gasUsed),hash:r,index:i,logs:l,logsBloom:a,root:u,status:c,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);if(null==t)throw new Error("TODO");return t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.hash);if(null==t)throw new Error("TODO");return t}))}getResult(){return __async(this,null,(function*(){return yield this.provider.getTransactionResult(this.hash)}))}confirmations(){return __async(this,null,(function*(){return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}removedEvent(){return Su(this)}reorderedEvent(t){return On(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ku(this,t)}}Zt=new WeakMap;Yt=new WeakMap;let xu=class t{constructor(t,e){__publicField(this,"provider"),__publicField(this,"blockNumber"),__publicField(this,"blockHash"),__publicField(this,"index"),__publicField(this,"hash"),__publicField(this,"type"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"nonce"),__publicField(this,"gasLimit"),__publicField(this,"gasPrice"),__publicField(this,"maxPriorityFeePerGas"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxFeePerBlobGas"),__publicField(this,"data"),__publicField(this,"value"),__publicField(this,"chainId"),__publicField(this,"signature"),__publicField(this,"accessList"),__publicField(this,"blobVersionedHashes"),__publicField(this,"authorizationList"),__privateAdd(this,Yt,void 0),this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.authorizationList=null!=t.authorizationList?t.authorizationList:null,__privateSet(this,Yt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:n,hash:r,type:i,to:s,from:o,nonce:a,data:l,signature:c,accessList:u,blobVersionedHashes:h}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:t,blockHash:e,blobVersionedHashes:h,chainId:_u(this.chainId),data:l,from:o,gasLimit:_u(this.gasLimit),gasPrice:_u(this.gasPrice),hash:r,maxFeePerGas:_u(this.maxFeePerGas),maxPriorityFeePerGas:_u(this.maxPriorityFeePerGas),maxFeePerBlobGas:_u(this.maxFeePerBlobGas),nonce:a,signature:c,to:s,index:n,type:i,value:_u(this.value)}}getBlock(){return __async(this,null,(function*(){let t=this.blockNumber;if(null==t){const e=yield this.getTransaction();e&&(t=e.blockNumber)}if(null==t)return null;const e=this.provider.getBlock(t);if(null==e)throw new Error("TODO");return e}))}getTransaction(){return __async(this,null,(function*(){return this.provider.getTransaction(this.hash)}))}confirmations(){return __async(this,null,(function*(){if(null==this.blockNumber){const{tx:t,blockNumber:e}=yield Tn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==t||null==t.blockNumber?0:e-t.blockNumber+1}return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}wait(t,e){return __async(this,null,(function*(){const n=null==t?1:t,r=null==e?0:e;let i=__privateGet(this,Yt),s=-1,o=-1===i;const a=()=>__async(this,null,(function*(){if(o)return null;const{blockNumber:t,nonce:e}=yield Tn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(o)return null;const r=yield this.getTransaction();if(!r||null==r.blockNumber)for(-1===s&&(s=i-3,s<__privateGet(this,Yt)&&(s=__privateGet(this,Yt)));s<=t;){if(o)return null;const e=yield this.provider.getBlock(s,!0);if(null==e)return;for(const t of e)if(t===this.hash)return;for(let r=0;r<e.length;r++){const s=yield e.getTransaction(r);if(s.from===this.from&&s.nonce===this.nonce){if(o)return null;const e=yield this.provider.getTransactionReceipt(s.hash);if(null==e)return;if(t-e.blockNumber+1<n)return;let r="replaced";s.data===this.data&&s.to===this.to&&s.value===this.value?r="repriced":"0x"===s.data&&s.from===s.to&&s.value===mu&&(r="cancelled"),On(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===r||"cancelled"===r,reason:r,replacement:s.replaceableTransaction(i),hash:s.hash,receipt:e})}}s++}})),l=t=>{if(null==t||0!==t.status)return t;On(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:t.to,from:t.from,data:""},receipt:t})},c=yield this.provider.getTransactionReceipt(this.hash);if(0===n)return l(c);if(c){if(1===n||(yield c.confirmations())>=n)return l(c)}else if(yield a(),0===n)return null;const u=new Promise(((t,e)=>{const s=[],c=()=>{s.forEach((t=>t()))};if(s.push((()=>{o=!0})),r>0){const t=setTimeout((()=>{c(),e(In("wait for transaction timeout","TIMEOUT"))}),r);s.push((()=>{clearTimeout(t)}))}const u=r=>__async(this,null,(function*(){if((yield r.confirmations())>=n){c();try{t(l(r))}catch(i){e(i)}}}));if(s.push((()=>{this.provider.off(this.hash,u)})),this.provider.on(this.hash,u),i>=0){const t=()=>__async(this,null,(function*(){try{yield a()}catch(n){if(Bn(n,"TRANSACTION_REPLACED"))return c(),void e(n)}o||this.provider.once("block",t)}));s.push((()=>{this.provider.off("block",t)})),this.provider.once("block",t)}}));return yield u}))}isMined(){return null!=this.blockHash}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}removedEvent(){return On(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Su(this)}reorderedEvent(t){return On(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),On(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ku(this,t)}replaceableTransaction(e){Ln(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const n=new t(this,this.provider);return __privateSet(n,Yt,e),n}};function ku(t,e){return{orphan:"reorder-transaction",tx:t,other:e}}function Su(t){return{orphan:"drop-transaction",tx:t}}class Nu extends Au{constructor(t,e,n){super(t,t.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");Mn(this,{args:e.decodeEventLog(n,t.data,t.topics),fragment:n,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Cu extends Au{constructor(t,e){super(t,t.provider),__publicField(this,"error"),Mn(this,{error:e})}}class Pu extends Eu{constructor(t,e,n){super(n,e),__privateAdd(this,Xt,void 0),__privateSet(this,Xt,t)}get logs(){return super.logs.map((t=>{const e=t.topics.length?__privateGet(this,Xt).getEvent(t.topics[0]):null;if(e)try{return new Nu(t,__privateGet(this,Xt),e)}catch(n){return new Cu(t,n)}return t}))}}Xt=new WeakMap;$t=new WeakMap;let Tu=class t extends xu{constructor(t,e,n){super(n,e),__privateAdd(this,$t,void 0),__privateSet(this,$t,t)}wait(e,n){return __async(this,null,(function*(){const r=yield __superGet(t.prototype,this,"wait").call(this,e,n);return null==r?null:new Pu(__privateGet(this,$t),this.provider,r)}))}};class Mu extends gr{constructor(t,e,n,r){super(t,e,n),__publicField(this,"log"),Mn(this,{log:r})}getBlock(){return __async(this,null,(function*(){return yield this.log.getBlock()}))}getTransaction(){return __async(this,null,(function*(){return yield this.log.getTransaction()}))}getTransactionReceipt(){return __async(this,null,(function*(){return yield this.log.getTransactionReceipt()}))}}class Ru extends Mu{constructor(t,e,n,r,i){super(t,e,n,new Nu(i,t.interface,r));Mn(this,{args:t.interface.decodeEventLog(r,this.log.data,this.log.topics),fragment:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Bu=BigInt(0);function Gu(t){return t&&"function"==typeof t.call}function Iu(t){return t&&"function"==typeof t.estimateGas}function Ou(t){return t&&"function"==typeof t.resolveName}function Lu(t){return t&&"function"==typeof t.sendTransaction}function Fu(t){if(null!=t){if(Ou(t))return t;if(t.provider)return t.provider}}class Uu{constructor(t,e,n){if(__privateAdd(this,te,void 0),__publicField(this,"fragment"),Mn(this,{fragment:e}),e.inputs.length<n.length)throw new Error("too many arguments");const r=Du(t.runner,"resolveName"),i=Ou(r)?r:null;__privateSet(this,te,function(){return __async(this,null,(function*(){const r=yield Promise.all(e.inputs.map(((t,e)=>null==n[e]?null:t.walkAsync(n[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>Zo(t,i)))):Zo(e,i):e)))));return t.interface.encodeFilterTopics(e,r)}))}())}getTopicFilter(){return __privateGet(this,te)}}function Du(t,e){return null==t?null:"function"==typeof t[e]?t:t.provider&&"function"==typeof t.provider[e]?t.provider:null}function ju(t){return null==t?null:t.provider||null}function Hu(t,e){return __async(this,null,(function*(){const n=ea.dereference(t,"overrides");Ln("object"==typeof n,"invalid overrides parameter","overrides",t);const r=vu(n);return Ln(null==r.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),Ln(null==r.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}))}function Wu(t){const e=function(e){return __async(this,null,(function*(){const n=yield Hu(e,["data"]);n.to=yield t.getAddress(),n.from&&(n.from=yield Zo(n.from,Fu(t.runner)));const r=t.interface,i=sr(n.value||Bu,"overrides.value")===Bu,s="0x"===(n.data||"0x");!r.fallback||r.fallback.payable||!r.receive||s||i||Ln(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),Ln(r.fallback||s,"cannot send data to receive-only contract","overrides.data",n.data);return Ln(r.receive||r.fallback&&r.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",n.value),Ln(r.fallback||s,"cannot send data to receive-only contract","overrides.data",n.data),n}))},n=function(n){return __async(this,null,(function*(){const r=t.runner;On(Lu(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield r.sendTransaction(yield e(n)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},r=t=>__async(this,null,(function*(){return yield n(t)}));return Mn(r,{_contract:t,estimateGas:function(n){return __async(this,null,(function*(){const r=Du(t.runner,"estimateGas");return On(Iu(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield e(n))}))},populateTransaction:e,send:n,staticCall:function(n){return __async(this,null,(function*(){const r=Du(t.runner,"call");On(Gu(r),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield e(n);try{return yield r.call(i)}catch(s){if(Gn(s)&&s.data)throw t.interface.makeError(s.data,i);throw s}}))}}),r}function Qu(t,e){const n=function(...n){const r=t.interface.getFunction(e,n);return On(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:n}}),r},r=function(...e){return __async(this,null,(function*(){const r=n(...e);let i={};if(r.inputs.length+1===e.length&&(i=yield Hu(e.pop()),i.from&&(i.from=yield Zo(i.from,Fu(t.runner)))),r.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const s=yield function(t,e,n){return __async(this,null,(function*(){const r=Du(t,"resolveName"),i=Ou(r)?r:null;return yield Promise.all(e.map(((t,e)=>t.walkAsync(n[e],((t,e)=>(e=ea.dereference(e,t),"address"===t?Zo(e,i):e))))))}))}(t.runner,r.inputs,e);return Object.assign({},i,yield Tn({to:t.getAddress(),data:t.interface.encodeFunctionData(r,s)}))}))},i=function(...t){return __async(this,null,(function*(){const e=yield o(...t);return 1===e.length?e[0]:e}))},s=function(...e){return __async(this,null,(function*(){const n=t.runner;On(Lu(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield n.sendTransaction(yield r(...e)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},o=function(...e){return __async(this,null,(function*(){const i=Du(t.runner,"call");On(Gu(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield r(...e);let o="0x";try{o=yield i.call(s)}catch(l){if(Gn(l)&&l.data)throw t.interface.makeError(l.data,s);throw l}const a=n(...e);return t.interface.decodeFunctionResult(a,o)}))},a=(...t)=>__async(this,null,(function*(){return n(...t).constant?yield i(...t):yield s(...t)}));return Mn(a,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:n,estimateGas:function(...e){return __async(this,null,(function*(){const n=Du(t.runner,"estimateGas");return On(Iu(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield r(...e))}))},populateTransaction:r,send:s,staticCall:i,staticCallResult:o}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const n=t.interface.getFunction(e);return On(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),n}}),a}te=new WeakMap;const zu=Symbol.for("_ethersInternal_contract"),Vu=new WeakMap;function Ku(t){return Vu.get(t[zu])}function Ju(t,e){return __async(this,null,(function*(){let n,r=null;if(Array.isArray(e)){const r=function(e){if(Qn(e,32))return e;const n=t.interface.getEvent(e);return Ln(n,"unknown fragment","name",e),n.topicHash};n=e.map((t=>null==t?null:Array.isArray(t)?t.map(r):r(t)))}else"*"===e?n=[null]:"string"==typeof e?Qn(e,32)?n=[e]:(r=t.interface.getEvent(e),Ln(r,"unknown fragment","event",e),n=[r.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?n=yield e.getTopicFilter():"fragment"in e?(r=e.fragment,n=[r.topicHash]):Ln(!1,"unknown event name","event",e);var i;n=n.map((t=>{if(null==t)return null;if(Array.isArray(t)){const e=Array.from(new Set(t.map((t=>t.toLowerCase()))).values());return 1===e.length?e[0]:(e.sort(),e)}return t.toLowerCase()}));return{fragment:r,tag:n.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:n}}))}function qu(t,e){return __async(this,null,(function*(){const{subs:n}=Ku(t);return n.get((yield Ju(t,e)).tag)||null}))}function Zu(t,e,n){return __async(this,null,(function*(){const r=ju(t.runner);On(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:o}=yield Ju(t,n),{addr:a,subs:l}=Ku(t);let c=l.get(s);if(!c){const e={address:a||t,topics:o},u=e=>{let r=i;if(null==r)try{r=t.interface.getEvent(e.topics[0])}catch(s){}if(r){const s=r,o=i?t.interface.decodeEventLog(i,e.data,e.topics):[];Xu(t,n,o,(r=>new Ru(t,r,n,s,e)))}else Xu(t,n,[],(r=>new Mu(t,r,n,e)))};let h=[];c={tag:s,listeners:[],start:()=>{h.length||h.push(r.on(e,u))},stop:()=>__async(this,null,(function*(){if(0==h.length)return;let t=h;h=[],yield Promise.all(t),r.off(e,u)}))},l.set(s,c)}return c}))}let Yu=Promise.resolve();function Xu(t,e,n,r){return __async(this,null,(function*(){try{yield Yu}catch(s){}const i=function(t,e,n,r){return __async(this,null,(function*(){yield Yu;const i=yield qu(t,e);if(!i)return!1;const o=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const o=Array.from(n);r&&o.push(r(i?null:e));try{e.call(t,...o)}catch(s){}return!i})),0===i.listeners.length&&(i.stop(),Ku(t).subs.delete(i.tag)),o>0}))}(t,e,n,r);return Yu=i,yield i}))}const $u=["then"];ee=zu;let th=class t{constructor(t,e,n,r){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),Ln("string"==typeof t||Jo(t),"invalid value for Contract target","target",t),null==n&&(n=null);const i=gu.from(e);let s;Mn(this,{target:t,runner:n,interface:i}),Object.defineProperty(this,zu,{value:{}});let o=null,a=null;if(r){const t=ju(n);a=new Tu(this.interface,t,r)}let l=new Map;if("string"==typeof t)if(Qn(t))o=t,s=Promise.resolve(t);else{const e=Du(n,"resolveName");if(!Ou(e))throw In("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw In("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Ku(this).addr=e,e}))}else s=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return Ku(this).addr=t,t}));var c,u;c=this,u={addrPromise:s,addr:o,deployTx:a,subs:l},Vu.set(c[zu],u);return Mn(this,{filters:new Proxy({},{get:(t,e,n)=>{if("symbol"==typeof e||$u.indexOf(e)>=0)return Reflect.get(t,e,n);try{return this.getEvent(e)}catch(r){if(!Bn(r,"INVALID_ARGUMENT")||"key"!==r.argument)throw r}},has:(t,e)=>$u.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))})}),Mn(this,{fallback:i.receive||i.fallback?Wu(this):null}),new Proxy(this,{get:(t,e,n)=>{if("symbol"==typeof e||e in t||$u.indexOf(e)>=0)return Reflect.get(t,e,n);try{return t.getFunction(e)}catch(r){if(!Bn(r,"INVALID_ARGUMENT")||"key"!==r.argument)throw r}},has:(t,e)=>"symbol"==typeof e||e in t||$u.indexOf(e)>=0?Reflect.has(t,e):t.interface.hasFunction(e)})}connect(e){return new t(this.target,this.interface,e)}attach(e){return new t(e,this.interface,this.runner)}getAddress(){return __async(this,null,(function*(){return yield Ku(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const t=ju(this.runner);On(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=yield t.getCode(yield this.getAddress());return"0x"===e?null:e}))}waitForDeployment(){return __async(this,null,(function*(){const t=this.deploymentTransaction();if(t)return yield t.wait(),this;if(null!=(yield this.getDeployedCode()))return this;const e=ju(this.runner);return On(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,n)=>{const r=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return t(this);e.once("block",r)}catch(i){n(i)}}));r()}))}))}deploymentTransaction(){return Ku(this).deployTx}getFunction(t){"string"!=typeof t&&(t=t.format());return Qu(this,t)}getEvent(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const n=function(...n){const r=t.interface.getEvent(e,n);return On(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:n}}),r},r=function(...e){return new Uu(t,n(...e),e)};return Mn(r,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:n}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const n=t.interface.getEvent(e);return On(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),n}}),r}(this,t)}queryTransaction(t){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(t,e,n){return __async(this,null,(function*(){null==e&&(e=0),null==n&&(n="latest");const{addr:r,addrPromise:i}=Ku(this),s=r||(yield i),{fragment:o,topics:a}=yield Ju(this,t),l={address:s,topics:a,fromBlock:e,toBlock:n},c=ju(this.runner);return On(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((t=>{let e=o;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(n){}if(e)try{return new Nu(t,this.interface,e)}catch(n){return new Cu(t,n)}return new Au(t,c)}))}))}on(t,e){return __async(this,null,(function*(){const n=yield Zu(this,"on",t);return n.listeners.push({listener:e,once:!1}),n.start(),this}))}once(t,e){return __async(this,null,(function*(){const n=yield Zu(this,"once",t);return n.listeners.push({listener:e,once:!0}),n.start(),this}))}emit(t,...e){return __async(this,null,(function*(){return yield Xu(this,t,e,null)}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield qu(this,t);return e?e.listeners.length:0}const{subs:e}=Ku(this);let n=0;for(const{listeners:t}of e.values())n+=t.length;return n}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield qu(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}const{subs:e}=Ku(this);let n=[];for(const{listeners:t}of e.values())n=n.concat(t.map((({listener:t})=>t)));return n}))}off(t,e){return __async(this,null,(function*(){const n=yield qu(this,t);if(!n)return this;if(e){const t=n.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&n.listeners.splice(t,1)}return null!=e&&0!==n.listeners.length||(n.stop(),Ku(this).subs.delete(n.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const e=yield qu(this,t);if(!e)return this;e.stop(),Ku(this).subs.delete(e.tag)}else{const{subs:t}=Ku(this);for(const{tag:e,stop:n}of t.values())n(),t.delete(e)}return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return yield this.off(t,e)}))}static buildClass(e){return class extends t{constructor(t,n=null){super(t,e,n)}}}static from(t,e,n){null==n&&(n=null);return new this(t,e,n)}};class eh extends(function(){return th}()){}function nh(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):Ln(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class rh{constructor(t){__publicField(this,"name"),Mn(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}encodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}decodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}}const ih=new RegExp("^(ipfs)://(.*)$","i"),sh=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),ih,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],oh=class t{constructor(t,e,n){__privateAdd(this,ie),__publicField(this,"provider"),__publicField(this,"address"),__publicField(this,"name"),__privateAdd(this,ne,void 0),__privateAdd(this,re,void 0),Mn(this,{provider:t,address:e,name:n}),__privateSet(this,ne,null),__privateSet(this,re,new eh(e,["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)"],t))}supportsWildcard(){return __async(this,null,(function*(){return null==__privateGet(this,ne)&&__privateSet(this,ne,(()=>__async(this,null,(function*(){try{return yield __privateGet(this,re).supportsInterface("0x9061b923")}catch(t){if(Bn(t,"CALL_EXCEPTION"))return!1;throw __privateSet(this,ne,null),t}})))()),yield __privateGet(this,ne)}))}getAddress(t){return __async(this,null,(function*(){if(null==t&&(t=60),60===t)try{const t=yield __privateMethod(this,ie,se).call(this,"addr(bytes32)");return null==t||t===Po?null:t}catch(i){if(Bn(i,"CALL_EXCEPTION"))return null;throw i}if(t>=0&&t<2147483648){let e=t+2147483648;const n=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[e]);if(Qn(n,20))return Ko(n)}let e=null;for(const s of this.provider.plugins)if(s instanceof rh&&s.supportsCoinType(t)){e=s;break}if(null==e)return null;const n=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[t]);if(null==n||"0x"===n)return null;const r=yield e.decodeAddress(t,n);if(null!=r)return r;On(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:n}})}))}getText(t){return __async(this,null,(function*(){const e=yield __privateMethod(this,ie,se).call(this,"text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}))}getContentHash(){return __async(this,null,(function*(){const t=yield __privateMethod(this,ie,se).call(this,"contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",n=parseInt(e[4],16);if(e[5].length===2*n)return`${t}://${function(t){const e=Hn(t);let n=lr(e),r="";for(;n;)r=pr[Number(n%fr)]+r,n/=fr;for(let i=0;i<e.length&&!e[i];i++)r=pr[0]+r;return r}("0x"+e[2])}`}const n=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&64===n[1].length)return`bzz://${n[1]}`;On(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}))}getAvatar(){return __async(this,null,(function*(){return(yield this._getAvatar()).url}))}_getAvatar(){return __async(this,null,(function*(){const t=[{type:"name",value:this.name}];try{const r=yield this.getText("avatar");if(null==r)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:r});for(let i=0;i<sh.length;i++){const s=r.match(sh[i]);if(null==s)continue;const o=s[1].toLowerCase();switch(o){case"https":case"data":return t.push({type:"url",value:r}),{linkage:t,url:r};case"ipfs":{const e=nh(r);return t.push({type:"ipfs",value:r}),t.push({type:"url",value:e}),{linkage:t,url:e}}case"erc721":case"erc1155":{const i="erc721"===o?"tokenURI(uint256)":"uri(uint256)";t.push({type:o,value:r});const a=yield this.getAddress();if(null==a)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const l=(s[2]||"").split("/");if(2!==l.length)return t.push({type:`!${o}caip`,value:s[2]||""}),{url:null,linkage:t};const c=l[1],u=new eh(l[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("erc721"===o){const e=yield u.ownerOf(c);if(a!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===o){const e=yield u.balanceOf(a,c);if(!e)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:e.toString()})}let h=yield u[i](c);if(null==h||"0x"===h)return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:h}),"erc1155"===o&&(h=h.replace("{id}",ur(c,32).substring(2)),t.push({type:"metadata-url-expanded",value:h})),h.match(/^ipfs:/i)&&(h=nh(h)),t.push({type:"metadata-url",value:h});let d={};const p=yield new Rr(h).send();p.assertOk();try{d=p.bodyJson}catch(e){try{t.push({type:"!metadata",value:p.bodyText})}catch(n){const e=p.body;return e&&t.push({type:"!metadata",value:Kn(e)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!d)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(d)});let f=d.image;if("string"!=typeof f)return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(f.match(/^(https:\/\/|data:)/i));else{if(null==f.match(ih))return t.push({type:"!imageUrl-ipfs",value:f}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:f}),f=nh(f)}return t.push({type:"url",value:f}),{linkage:t,url:f}}}}}catch(e){}return{linkage:t,url:null}}))}static getEnsAddress(t){return __async(this,null,(function*(){const e=yield t.getNetwork(),n=e.getPlugin("org.ethers.plugins.network.Ens");return On(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),n.address}))}static fromName(e,n){return __async(this,null,(function*(){var r;let i=n;for(;;){if(""===i||"."===i)return null;if("eth"!==n&&"eth"===i)return null;const s=yield __privateMethod(r=t,oe,ae).call(r,e,i);if(null!=s){const r=new t(e,s,n);return i===n||(yield r.supportsWildcard())?r:null}i=i.split(".").slice(1).join(".")}}))}};ne=new WeakMap,re=new WeakMap,ie=new WeakSet,se=function(t,e){return __async(this,null,(function*(){e=(e||[]).slice();const n=__privateGet(this,re).interface;e.unshift(Jl(this.name));let r=null;(yield this.supportsWildcard())&&(r=n.getFunction(t),On(r,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[ql(this.name,255),n.encodeFunctionData(r,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=yield __privateGet(this,re)[t](...e);return r?n.decodeFunctionResult(r,i)[0]:i}catch(i){if(!Bn(i,"CALL_EXCEPTION"))throw i}return null}))},oe=new WeakSet,ae=function(t,e){return __async(this,null,(function*(){const n=yield oh.getEnsAddress(t);try{const r=new eh(n,["function resolver(bytes32) view returns (address)"],t),i=yield r.resolver(Jl(e),{enableCcipRead:!0});return i===Po?null:i}catch(r){throw r}return null}))},__privateAdd(oh,oe);let ah=oh;const lh=BigInt(0);function ch(t,e){return function(n){return null==n?e:t(n)}}function uh(t,e){return n=>{if(e&&null==n)return null;if(!Array.isArray(n))throw new Error("not an array");return n.map((e=>t(e)))}}function hh(t,e){return n=>{const r={};for(const s in t){let o=s;if(e&&s in e&&!(o in n))for(const t of e[s])if(t in n){o=t;break}try{const e=t[s](n[o]);void 0!==e&&(r[s]=e)}catch(i){On(!1,`invalid value for value.${s} (${i instanceof Error?i.message:"not-an-error"})`,"BAD_DATA",{value:n})}}return r}}function dh(t){return Ln(Qn(t,!0),"invalid data","value",t),t}function ph(t){return Ln(Qn(t,32),"invalid hash","value",t),t}const fh=hh({address:Ko,blockHash:ph,blockNumber:cr,data:dh,index:cr,removed:ch((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}Ln(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:uh(ph),transactionHash:ph,transactionIndex:cr},{index:["logIndex"]});const gh=hh({hash:ch(ph),parentHash:ph,parentBeaconBlockRoot:ch(ph,null),number:cr,timestamp:cr,nonce:ch(dh),difficulty:sr,gasLimit:sr,gasUsed:sr,stateRoot:ch(ph,null),receiptsRoot:ch(ph,null),blobGasUsed:ch(sr,null),excessBlobGas:ch(sr,null),miner:ch(Ko),prevRandao:ch(ph,null),extraData:dh,baseFeePerGas:ch(sr)},{prevRandao:["mixHash"]});const mh=hh({transactionIndex:cr,blockNumber:cr,transactionHash:ph,address:Ko,topics:uh(ph),data:dh,index:cr,blockHash:ph},{index:["logIndex"]});const yh=hh({to:ch(Ko,null),from:ch(Ko,null),contractAddress:ch(Ko,null),index:cr,root:ch(Kn),gasUsed:sr,blobGasUsed:ch(sr,null),logsBloom:ch(dh),blockHash:ph,hash:ph,logs:uh((function(t){return mh(t)})),blockNumber:cr,cumulativeGasUsed:sr,effectiveGasPrice:ch(sr),blobGasPrice:ch(sr,null),status:ch(cr),type:ch(cr,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function _h(t){t.to&&sr(t.to)===lh&&(t.to="0x0000000000000000000000000000000000000000");const e=hh({hash:ph,index:ch(cr,void 0),type:t=>"0x"===t||null==t?0:cr(t),accessList:ch(va,null),blobVersionedHashes:ch(uh(ph,!0),null),authorizationList:ch(uh((t=>{let e;if(t.signature)e=t.signature;else{let n=t.yParity;"0x1b"===n?n=0:"0x1c"===n&&(n=1),e=Object.assign({},t,{yParity:n})}return{address:Ko(t.address),chainId:sr(t.chainId),nonce:sr(t.nonce),signature:Do.from(e)}}),!1),null),blockHash:ch(ph,null),blockNumber:ch(cr,null),transactionIndex:ch(cr,null),from:Ko,gasPrice:ch(sr),maxPriorityFeePerGas:ch(sr),maxFeePerGas:ch(sr),maxFeePerBlobGas:ch(sr,null),gasLimit:sr,to:ch(Ko,null),value:sr,nonce:cr,data:dh,creates:ch(Ko,null),chainId:ch(sr,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=Ko(t.from);let n=sr(t.nonce,"tx.nonce").toString(16);return n="0"===n?"0x":n.length%2?"0x0"+n:"0x"+n,Ko(Zn(vs(ei([e,n])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=Do.from(t.signature):e.signature=Do.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&sr(e.blockHash)===lh&&(e.blockHash=null),e}class wh{constructor(t){__publicField(this,"name"),Mn(this,{name:t})}clone(){return new wh(this.name)}}class vh extends wh{constructor(t,e){null==t&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`),__publicField(this,"effectiveBlock"),__publicField(this,"txBase"),__publicField(this,"txCreate"),__publicField(this,"txDataZero"),__publicField(this,"txDataNonzero"),__publicField(this,"txAccessListStorageKey"),__publicField(this,"txAccessListAddress");const n={effectiveBlock:t};function r(t,r){let i=(e||{})[t];null==i&&(i=r),Ln("number"==typeof i,`invalud value for ${t}`,"costs",e),n[t]=i}r("txBase",21e3),r("txCreate",32e3),r("txDataZero",4),r("txDataNonzero",16),r("txAccessListStorageKey",1900),r("txAccessListAddress",2400),Mn(this,n)}clone(){return new vh(this.effectiveBlock,this)}}class bh extends wh{constructor(t,e){super("org.ethers.plugins.network.Ens"),__publicField(this,"address"),__publicField(this,"targetNetwork"),Mn(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new bh(this.address,this.targetNetwork)}}class Ah extends wh{constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),__privateAdd(this,le,void 0),__privateAdd(this,ce,void 0),__privateSet(this,le,t),__privateSet(this,ce,e)}get url(){return __privateGet(this,le)}get processFunc(){return __privateGet(this,ce)}clone(){return this}}le=new WeakMap,ce=new WeakMap;const Eh=new Map;ue=new WeakMap,he=new WeakMap,de=new WeakMap;let xh=class t{constructor(t,e){__privateAdd(this,ue,void 0),__privateAdd(this,he,void 0),__privateAdd(this,de,void 0),__privateSet(this,ue,t),__privateSet(this,he,sr(e)),__privateSet(this,de,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return __privateGet(this,ue)}set name(t){__privateSet(this,ue,t)}get chainId(){return __privateGet(this,he)}set chainId(t){__privateSet(this,he,sr(t,"chainId"))}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===sr(t)}catch(e){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===sr(t)}catch(e){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===sr(t.chainId)}catch(e){}return!1}return null!=t.name&&this.name===t.name}return!1}get plugins(){return Array.from(__privateGet(this,de).values())}attachPlugin(t){if(__privateGet(this,de).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,de).set(t.name,t.clone()),this}getPlugin(t){return __privateGet(this,de).get(t)||null}getPlugins(t){return this.plugins.filter((e=>e.name.split("#")[0]===t))}clone(){const e=new t(this.name,this.chainId);return this.plugins.forEach((t=>{e.attachPlugin(t.clone())})),e}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new vh;let n=e.txBase;if(null==t.to&&(n+=e.txCreate),t.data)for(let r=2;r<t.data.length;r+=2)"00"===t.data.substring(r,r+2)?n+=e.txDataZero:n+=e.txDataNonzero;if(t.accessList){const r=va(t.accessList);for(const t in r)n+=e.txAccessListAddress+e.txAccessListStorageKey*r[t].storageKeys.length}return n}static from(e){if(function(){if(Nh)return;function t(t,e,n){const r=function(){const r=new xh(t,e);return null!=n.ensNetwork&&r.attachPlugin(new bh(null,n.ensNetwork)),r.attachPlugin(new vh),(n.plugins||[]).forEach((t=>{r.attachPlugin(t)})),r};xh.register(t,r),xh.register(e,r),n.altNames&&n.altNames.forEach((t=>{xh.register(t,r)}))}Nh=!0,t("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),t("ropsten",3,{ensNetwork:3}),t("rinkeby",4,{ensNetwork:4}),t("goerli",5,{ensNetwork:5}),t("kovan",42,{ensNetwork:42}),t("sepolia",11155111,{ensNetwork:11155111}),t("holesky",17e3,{ensNetwork:17e3}),t("classic",61,{}),t("classicKotti",6,{}),t("arbitrum",42161,{ensNetwork:1}),t("arbitrum-goerli",421613,{}),t("arbitrum-sepolia",421614,{}),t("base",8453,{ensNetwork:1}),t("base-goerli",84531,{}),t("base-sepolia",84532,{}),t("bnb",56,{ensNetwork:1}),t("bnbt",97,{}),t("linea",59144,{ensNetwork:1}),t("linea-goerli",59140,{}),t("linea-sepolia",59141,{}),t("matic",137,{ensNetwork:1,plugins:[Sh("https://gasstation.polygon.technology/v2")]}),t("matic-amoy",80002,{}),t("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Sh("https://gasstation-testnet.polygon.technology/v2")]}),t("optimism",10,{ensNetwork:1,plugins:[]}),t("optimism-goerli",420,{}),t("optimism-sepolia",11155420,{}),t("xdai",100,{ensNetwork:1})}(),null==e)return t.from("mainnet");if("number"==typeof e&&(e=BigInt(e)),"string"==typeof e||"bigint"==typeof e){const n=Eh.get(e);if(n)return n();if("bigint"==typeof e)return new t("unknown",e);Ln(!1,"unknown network","network",e)}if("function"==typeof e.clone){return e.clone()}if("object"==typeof e){Ln("string"==typeof e.name&&"number"==typeof e.chainId,"invalid network object name or chainId","network",e);const n=new t(e.name,e.chainId);return(e.ensAddress||null!=e.ensNetwork)&&n.attachPlugin(new bh(e.ensAddress,e.ensNetwork)),n}Ln(!1,"invalid network","network",e)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const n=Eh.get(t);n&&Ln(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",t),Eh.set(t,e)}};function kh(t,e){const n=String(t);if(!n.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const r=n.split(".");if(1===r.length&&r.push(""),2!==r.length)throw new Error(`invalid gwei value: ${t}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let t=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||t++,r[1]=t.toString()}return BigInt(r[0]+r[1])}function Sh(t){return new Ah(t,((t,e,n)=>__async(this,null,(function*(){let e;n.setHeader("User-Agent","ethers");try{const[r,i]=yield Promise.all([n.send(),t()]);e=r;const s=e.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:kh(s.maxFee,9),maxPriorityFeePerGas:kh(s.maxPriorityFee,9)}}catch(r){On(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:e,error:r})}}))))}let Nh=!1;function Ch(t){return JSON.parse(JSON.stringify(t))}class Ph{constructor(t){__privateAdd(this,ye),__privateAdd(this,pe,void 0),__privateAdd(this,fe,void 0),__privateAdd(this,ge,void 0),__privateAdd(this,me,void 0),__privateSet(this,pe,t),__privateSet(this,fe,null),__privateSet(this,ge,4e3),__privateSet(this,me,-2)}get pollingInterval(){return __privateGet(this,ge)}set pollingInterval(t){__privateSet(this,ge,t)}start(){__privateGet(this,fe)||(__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,ye,_e).bind(this),__privateGet(this,ge))),__privateMethod(this,ye,_e).call(this))}stop(){__privateGet(this,fe)&&(__privateGet(this,pe)._clearTimeout(__privateGet(this,fe)),__privateSet(this,fe,null))}pause(t){this.stop(),t&&__privateSet(this,me,-2)}resume(){this.start()}}pe=new WeakMap,fe=new WeakMap,ge=new WeakMap,me=new WeakMap,ye=new WeakSet,_e=function(){return __async(this,null,(function*(){try{const t=yield __privateGet(this,pe).getBlockNumber();if(-2===__privateGet(this,me))return void __privateSet(this,me,t);if(t!==__privateGet(this,me)){for(let e=__privateGet(this,me)+1;e<=t;e++){if(null==__privateGet(this,fe))return;yield __privateGet(this,pe).emit("block",e)}__privateSet(this,me,t)}}catch(t){}null!=__privateGet(this,fe)&&__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,ye,_e).bind(this),__privateGet(this,ge)))}))};class Th{constructor(t){__privateAdd(this,we,void 0),__privateAdd(this,ve,void 0),__privateAdd(this,be,void 0),__privateSet(this,we,t),__privateSet(this,be,!1),__privateSet(this,ve,(t=>{this._poll(t,__privateGet(this,we))}))}_poll(t,e){return __async(this,null,(function*(){throw new Error("sub-classes must override this")}))}start(){__privateGet(this,be)||(__privateSet(this,be,!0),__privateGet(this,ve).call(this,-2),__privateGet(this,we).on("block",__privateGet(this,ve)))}stop(){__privateGet(this,be)&&(__privateSet(this,be,!1),__privateGet(this,we).off("block",__privateGet(this,ve)))}pause(t){this.stop()}resume(){this.start()}}we=new WeakMap,ve=new WeakMap,be=new WeakMap;class Mh extends Th{constructor(t,e){super(t),__privateAdd(this,Ae,void 0),__privateAdd(this,Ee,void 0),__privateSet(this,Ae,e),__privateSet(this,Ee,-2)}pause(t){t&&__privateSet(this,Ee,-2),super.pause(t)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getBlock(__privateGet(this,Ae));null!=t&&(-2===__privateGet(this,Ee)?__privateSet(this,Ee,t.number):t.number>__privateGet(this,Ee)&&(e.emit(__privateGet(this,Ae),t.number),__privateSet(this,Ee,t.number)))}))}}Ae=new WeakMap,Ee=new WeakMap;class Rh extends Th{constructor(t,e){super(t),__privateAdd(this,xe,void 0),__privateSet(this,xe,Ch(e))}_poll(t,e){return __async(this,null,(function*(){throw new Error("@TODO")}))}}xe=new WeakMap;class Bh extends Th{constructor(t,e){super(t),__privateAdd(this,ke,void 0),__privateSet(this,ke,e)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getTransactionReceipt(__privateGet(this,ke));t&&e.emit(__privateGet(this,ke),t)}))}}ke=new WeakMap;class Gh{constructor(t,e){__privateAdd(this,Me),__privateAdd(this,Se,void 0),__privateAdd(this,Ne,void 0),__privateAdd(this,Ce,void 0),__privateAdd(this,Pe,void 0),__privateAdd(this,Te,void 0),__privateSet(this,Se,t),__privateSet(this,Ne,Ch(e)),__privateSet(this,Ce,__privateMethod(this,Me,Re).bind(this)),__privateSet(this,Pe,!1),__privateSet(this,Te,-2)}start(){__privateGet(this,Pe)||(__privateSet(this,Pe,!0),-2===__privateGet(this,Te)&&__privateGet(this,Se).getBlockNumber().then((t=>{__privateSet(this,Te,t)})),__privateGet(this,Se).on("block",__privateGet(this,Ce)))}stop(){__privateGet(this,Pe)&&(__privateSet(this,Pe,!1),__privateGet(this,Se).off("block",__privateGet(this,Ce)))}pause(t){this.stop(),t&&__privateSet(this,Te,-2)}resume(){this.start()}}Se=new WeakMap,Ne=new WeakMap,Ce=new WeakMap,Pe=new WeakMap,Te=new WeakMap,Me=new WeakSet,Re=function(t){return __async(this,null,(function*(){if(-2===__privateGet(this,Te))return;const e=Ch(__privateGet(this,Ne));e.fromBlock=__privateGet(this,Te)+1,e.toBlock=t;const n=yield __privateGet(this,Se).getLogs(e);if(0!==n.length)for(const t of n)__privateGet(this,Se).emit(__privateGet(this,Ne),t),__privateSet(this,Te,t.blockNumber);else __privateGet(this,Te)<t-60&&__privateSet(this,Te,t-60)}))};const Ih=BigInt(2);function Oh(t){return t&&"function"==typeof t.then}function Lh(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,n)=>(t[n]=e[n],t)),{})}return e}))}class Fh{constructor(t){__publicField(this,"name"),Mn(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function Uh(t){return(t=Array.from(new Set(t).values())).sort(),t}function Dh(t,e){return __async(this,null,(function*(){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if(Qn(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:Lh("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:Lh("orphan",e),filter:(n=e,JSON.parse(JSON.stringify(n)))}}var n;if(t.address||t.topics){const n=t,r={topics:(n.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(n.address){const t=[],i=[],s=n=>{Qn(n)?t.push(n):i.push((()=>__async(this,null,(function*(){t.push(yield Zo(n,e))})))())};Array.isArray(n.address)?n.address.forEach(s):s(n.address),i.length&&(yield Promise.all(i)),r.address=Uh(t.map((t=>t.toLowerCase())))}return{filter:r,tag:Lh("event",r),type:"event"}}Ln(!1,"unknown ProviderEvent","event",t)}))}function jh(){return(new Date).getTime()}const Hh={cacheTimeout:250,pollingInterval:4e3};class Wh{constructor(t,e){if(__privateAdd(this,ze),__privateAdd(this,Ke),__privateAdd(this,qe),__privateAdd(this,Ye),__privateAdd(this,$e),__privateAdd(this,en),__privateAdd(this,rn),__privateAdd(this,Be,void 0),__privateAdd(this,Ge,void 0),__privateAdd(this,Ie,void 0),__privateAdd(this,Oe,void 0),__privateAdd(this,Le,void 0),__privateAdd(this,Fe,void 0),__privateAdd(this,Ue,void 0),__privateAdd(this,De,void 0),__privateAdd(this,je,void 0),__privateAdd(this,He,void 0),__privateAdd(this,We,void 0),__privateAdd(this,Qe,void 0),__privateSet(this,Qe,Object.assign({},Hh,e||{})),"any"===t)__privateSet(this,Fe,!0),__privateSet(this,Le,null);else if(t){const e=xh.from(t);__privateSet(this,Fe,!1),__privateSet(this,Le,Promise.resolve(e)),setTimeout((()=>{this.emit("network",e,null)}),0)}else __privateSet(this,Fe,!1),__privateSet(this,Le,null);__privateSet(this,De,-1),__privateSet(this,Ue,new Map),__privateSet(this,Be,new Map),__privateSet(this,Ge,new Map),__privateSet(this,Ie,null),__privateSet(this,Oe,!1),__privateSet(this,je,1),__privateSet(this,He,new Map),__privateSet(this,We,!1)}get pollingInterval(){return __privateGet(this,Qe).pollingInterval}get provider(){return this}get plugins(){return Array.from(__privateGet(this,Ge).values())}attachPlugin(t){if(__privateGet(this,Ge).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,Ge).set(t.name,t.connect(this)),this}getPlugin(t){return __privateGet(this,Ge).get(t)||null}get disableCcipRead(){return __privateGet(this,We)}set disableCcipRead(t){__privateSet(this,We,!!t)}ccipReadFetch(t,e,n){return __async(this,null,(function*(){if(this.disableCcipRead||0===n.length||null==t.to)return null;const r=t.to.toLowerCase(),i=e.toLowerCase(),s=[];for(let e=0;e<n.length;e++){const a=n[e],l=a.replace("{sender}",r).replace("{data}",i),c=new Rr(l);-1===a.indexOf("{data}")&&(c.body={data:i,sender:r}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:c,index:e,urls:n});let u,h="unknown error";try{u=yield c.send()}catch(o){s.push(o.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:{error:o}});continue}try{const t=u.bodyJson;if(t.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:c,result:t}),t.data;t.message&&(h=t.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:t})}catch(o){}On(u.statusCode<400||u.statusCode>=500,`response not found during CCIP fetch: ${h}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:a,errorMessage:h}}),s.push(h)}On(!1,`error encountered during CCIP fetch: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:n,errorMessages:s}})}))}_wrapBlock(t,e){return new bu(function(t){const e=gh(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:_h(t))),e}(t),this)}_wrapLog(t,e){return new Au(function(t){return fh(t)}(t),this)}_wrapTransactionReceipt(t,e){return new Eu(function(t){return yh(t)}(t),this)}_wrapTransactionResponse(t,e){return new xu(_h(t),this)}_detectNetwork(){On(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}_perform(t){return __async(this,null,(function*(){On(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}))}getBlockNumber(){return __async(this,null,(function*(){const t=cr(yield __privateMethod(this,ze,Ve).call(this,{method:"getBlockNumber"}),"%response");return __privateGet(this,De)>=0&&__privateSet(this,De,t),t}))}_getAddress(t){return Zo(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return Qn(t)?Qn(t,32)?t:dr(t):("bigint"==typeof t&&(t=cr(t,"blockTag")),"number"==typeof t?t>=0?dr(t):__privateGet(this,De)>=0?dr(__privateGet(this,De)+t):this.getBlockNumber().then((e=>dr(e+t))):void Ln(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase())),n="blockHash"in t?t.blockHash:void 0,r=(t,r,i)=>{let s;switch(t.length){case 0:break;case 1:s=t[0];break;default:t.sort(),s=t}if(n&&(null!=r||null!=i))throw new Error("invalid filter");const o={};return s&&(o.address=s),e.length&&(o.topics=e),r&&(o.fromBlock=r),i&&(o.toBlock=i),n&&(o.blockHash=n),o};let i,s,o=[];if(t.address)if(Array.isArray(t.address))for(const a of t.address)o.push(this._getAddress(a));else o.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(s=this._getBlockTag(t.toBlock)),o.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=s&&"string"!=typeof s?Promise.all([Promise.all(o),i,s]).then((t=>r(t[0],t[1],t[2]))):r(o,i,s)}_getTransactionRequest(t){const e=vu(t),n=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const r=Zo(e[t],this);Oh(r)?n.push(function(){return __async(this,null,(function*(){e[t]=yield r}))}()):e[t]=r})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);Oh(t)?n.push(function(){return __async(this,null,(function*(){e.blockTag=yield t}))}()):e.blockTag=t}return n.length?function(){return __async(this,null,(function*(){return yield Promise.all(n),e}))}():e}getNetwork(){return __async(this,null,(function*(){if(null==__privateGet(this,Le)){const t=(()=>__async(this,null,(function*(){try{const t=yield this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw __privateGet(this,Le)===t&&__privateSet(this,Le,null),e}})))();return __privateSet(this,Le,t),(yield t).clone()}const t=__privateGet(this,Le),[e,n]=yield Promise.all([t,this._detectNetwork()]);return e.chainId!==n.chainId&&(__privateGet(this,Fe)?(this.emit("network",n,e),__privateGet(this,Le)===t&&__privateSet(this,Le,Promise.resolve(n))):On(!1,`network changed: ${e.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}))}getFeeData(){return __async(this,null,(function*(){const t=yield this.getNetwork(),e=()=>__async(this,null,(function*(){const{_block:e,gasPrice:n,priorityFee:r}=yield Tn({_block:__privateMethod(this,$e,tn).call(this,"latest",!1),gasPrice:(()=>__async(this,null,(function*(){try{return sr(yield __privateMethod(this,ze,Ve).call(this,{method:"getGasPrice"}),"%response")}catch(t){}return null})))(),priorityFee:(()=>__async(this,null,(function*(){try{return sr(yield __privateMethod(this,ze,Ve).call(this,{method:"getPriorityFee"}),"%response")}catch(t){}return null})))()});let i=null,s=null;const o=this._wrapBlock(e,t);return o&&o.baseFeePerGas&&(s=null!=r?r:BigInt("1000000000"),i=o.baseFeePerGas*Ih+s),new wu(n,i,s)})),n=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const t=new Rr(n.url),r=yield n.processFunc(e,this,t);return new wu(r.gasPrice,r.maxFeePerGas,r.maxPriorityFeePerGas)}return yield e()}))}estimateGas(t){return __async(this,null,(function*(){let e=this._getTransactionRequest(t);return Oh(e)&&(e=yield e),sr(yield __privateMethod(this,ze,Ve).call(this,{method:"estimateGas",transaction:e}),"%response")}))}call(t){return __async(this,null,(function*(){const{tx:e,blockTag:n}=yield Tn({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,Ke,Je).call(this,e,n,t.enableCcipRead?0:-1))}))}getBalance(t,e){return __async(this,null,(function*(){return sr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getBalance"},t,e),"%response")}))}getTransactionCount(t,e){return __async(this,null,(function*(){return cr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getTransactionCount"},t,e),"%response")}))}getCode(t,e){return __async(this,null,(function*(){return Kn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getCode"},t,e))}))}getStorage(t,e,n){return __async(this,null,(function*(){const r=sr(e,"position");return Kn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getStorage",position:r},t,n))}))}broadcastTransaction(t){return __async(this,null,(function*(){const{blockNumber:e,hash:n,network:r}=yield Tn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=Da.from(t);if(i.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,r).replaceableTransaction(e)}))}getBlock(t,e){return __async(this,null,(function*(){const{network:n,params:r}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,$e,tn).call(this,t,!!e)});return null==r?null:this._wrapBlock(r,n)}))}getTransaction(t){return __async(this,null,(function*(){const{network:e,params:n}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t})});return null==n?null:this._wrapTransactionResponse(n,e)}))}getTransactionReceipt(t){return __async(this,null,(function*(){const{network:e,params:n}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionReceipt",hash:t})});if(null==n)return null;if(null==n.gasPrice&&null==n.effectiveGasPrice){const e=yield __privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(n,e)}))}getTransactionResult(t){return __async(this,null,(function*(){const{result:e}=yield Tn({network:this.getNetwork(),result:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionResult",hash:t})});return null==e?null:Kn(e)}))}getLogs(t){return __async(this,null,(function*(){let e=this._getFilter(t);Oh(e)&&(e=yield e);const{network:n,params:r}=yield Tn({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getLogs",filter:e})});return r.map((t=>this._wrapLog(t,n)))}))}_getProvider(t){On(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}getResolver(t){return __async(this,null,(function*(){return yield ah.fromName(this,t)}))}getAvatar(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAvatar():null}))}resolveName(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAddress():null}))}lookupAddress(t){return __async(this,null,(function*(){const e=Jl((t=Ko(t)).substring(2).toLowerCase()+".addr.reverse");try{const n=yield ah.getEnsAddress(this),r=new eh(n,["function resolver(bytes32) view returns (address)"],this),i=yield r.resolver(e);if(null==i||i===Po)return null;const s=new eh(i,["function name(bytes32) view returns (string)"],this),o=yield s.name(e);return(yield this.resolveName(o))!==t?null:o}catch(n){if(Bn(n,"BAD_DATA")&&"0x"===n.value)return null;if(Bn(n,"CALL_EXCEPTION"))return null;throw n}return null}))}waitForTransaction(t,e,n){return __async(this,null,(function*(){const r=null!=e?e:1;return 0===r?this.getTransactionReceipt(t):new Promise(((e,i)=>__async(this,null,(function*(){let s=null;const o=n=>__async(this,null,(function*(){try{const i=yield this.getTransactionReceipt(t);if(null!=i&&n-i.blockNumber+1>=r)return e(i),void(s&&(clearTimeout(s),s=null))}catch(i){console.log("EEE",i)}this.once("block",o)}));null!=n&&(s=setTimeout((()=>{null!=s&&(s=null,this.off("block",o),i(In("timeout","TIMEOUT",{reason:"timeout"})))}),n)),o(yield this.getBlockNumber())}))))}))}waitForBlock(t){return __async(this,null,(function*(){On(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}))}_clearTimeout(t){const e=__privateGet(this,He).get(t);e&&(e.timer&&clearTimeout(e.timer),__privateGet(this,He).delete(t))}_setTimeout(t,e){null==e&&(e=0);const n=__privateWrapper(this,je)._++,r=()=>{__privateGet(this,He).delete(n),t()};if(this.paused)__privateGet(this,He).set(n,{timer:null,func:r,time:e});else{const t=setTimeout(r,e);__privateGet(this,He).set(n,{timer:t,func:r,time:jh()})}return n}_forEachSubscriber(t){for(const e of __privateGet(this,Be).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Fh(t.type);case"block":{const t=new Ph(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Mh(this,t.type);case"event":return new Gh(this,t.filter);case"transaction":return new Bh(this,t.hash);case"orphan":return new Rh(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const n of __privateGet(this,Be).values())if(n.subscriber===t){n.started&&n.subscriber.stop(),n.subscriber=e,n.started&&e.start(),null!=__privateGet(this,Ie)&&e.pause(__privateGet(this,Ie));break}}on(t,e){return __async(this,null,(function*(){const n=yield __privateMethod(this,rn,sn).call(this,t);return n.listeners.push({listener:e,once:!1}),n.started||(n.subscriber.start(),n.started=!0,null!=__privateGet(this,Ie)&&n.subscriber.pause(__privateGet(this,Ie))),this}))}once(t,e){return __async(this,null,(function*(){const n=yield __privateMethod(this,rn,sn).call(this,t);return n.listeners.push({listener:e,once:!0}),n.started||(n.subscriber.start(),n.started=!0,null!=__privateGet(this,Ie)&&n.subscriber.pause(__privateGet(this,Ie))),this}))}emit(t,...e){return __async(this,null,(function*(){const n=yield __privateMethod(this,en,nn).call(this,t,e);if(!n||0===n.listeners.length)return!1;const r=n.listeners.length;return n.listeners=n.listeners.filter((({listener:n,once:r})=>{const i=new gr(this,r?null:n,t);try{n.call(this,...e,i)}catch(s){}return!r})),0===n.listeners.length&&(n.started&&n.subscriber.stop(),__privateGet(this,Be).delete(n.tag)),r>0}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,en,nn).call(this,t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of __privateGet(this,Be).values())e+=t.length;return e}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,en,nn).call(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of __privateGet(this,Be).values())e=e.concat(t.map((({listener:t})=>t)));return e}))}off(t,e){return __async(this,null,(function*(){const n=yield __privateMethod(this,en,nn).call(this,t);if(!n)return this;if(e){const t=n.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&n.listeners.splice(t,1)}return e&&0!==n.listeners.length||(n.started&&n.subscriber.stop(),__privateGet(this,Be).delete(n.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const{tag:e,started:n,subscriber:r}=yield __privateMethod(this,rn,sn).call(this,t);n&&r.stop(),__privateGet(this,Be).delete(e)}else for(const[t,{started:e,subscriber:n}]of __privateGet(this,Be))e&&n.stop(),__privateGet(this,Be).delete(t);return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return this.off(t,e)}))}get destroyed(){return __privateGet(this,Oe)}destroy(){this.removeAllListeners();for(const t of __privateGet(this,He).keys())this._clearTimeout(t);__privateSet(this,Oe,!0)}get paused(){return null!=__privateGet(this,Ie)}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(__privateSet(this,De,-1),null!=__privateGet(this,Ie)){if(__privateGet(this,Ie)==!!t)return;On(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),__privateSet(this,Ie,!!t);for(const e of __privateGet(this,He).values())e.timer&&clearTimeout(e.timer),e.time=jh()-e.time}resume(){if(null!=__privateGet(this,Ie)){this._forEachSubscriber((t=>t.resume())),__privateSet(this,Ie,null);for(const t of __privateGet(this,He).values()){let e=t.time;e<0&&(e=0),t.time=jh(),setTimeout(t.func,e)}}}}function Qh(t,e){try{const n=zh(t,e);if(n)return wr(n)}catch(n){}return null}function zh(t,e){if("0x"===t)return null;try{const n=cr(Zn(t,e,e+32)),r=cr(Zn(t,n,n+32));return Zn(t,n+32,n+32+r)}catch(n){}return null}function Vh(t){const e=hr(t);if(e.length>32)throw new Error("internal; should not happen");const n=new Uint8Array(32);return n.set(e,32-e.length),n}function Kh(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}Be=new WeakMap,Ge=new WeakMap,Ie=new WeakMap,Oe=new WeakMap,Le=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,De=new WeakMap,je=new WeakMap,He=new WeakMap,We=new WeakMap,Qe=new WeakMap,ze=new WeakSet,Ve=function(t){return __async(this,null,(function*(){const e=__privateGet(this,Qe).cacheTimeout;if(e<0)return yield this._perform(t);const n=Lh(t.method,t);let r=__privateGet(this,Ue).get(n);return r||(r=this._perform(t),__privateGet(this,Ue).set(n,r),setTimeout((()=>{__privateGet(this,Ue).get(n)===r&&__privateGet(this,Ue).delete(n)}),e)),yield r}))},Ke=new WeakSet,Je=function(t,e,n){return __async(this,null,(function*(){On(n<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const r=vu(t);try{return Kn(yield this._perform({method:"call",transaction:r,blockTag:e}))}catch(i){if(!this.disableCcipRead&&Gn(i)&&i.data&&n>=0&&"latest"===e&&null!=r.to&&"0x556f1830"===Zn(i.data,0,4)){const t=i.data,o=yield Zo(r.to,this);let a;try{a=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};On(qn(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const n=Zn(t,0,32);On(Zn(n,0,12)===Zn(Zh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Zn(n,12);try{const n=[],r=cr(Zn(t,32,64)),i=cr(Zn(t,r,r+32)),s=Zn(t,r+32);for(let t=0;t<i;t++){const e=Qh(s,32*t);if(null==e)throw new Error("abort");n.push(e)}e.urls=n}catch(i){On(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=zh(t,64);if(null==n)throw new Error("abort");e.calldata=n}catch(i){On(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}On(Zn(t,100,128)===Zn(Zh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Zn(t,96,100);try{const n=zh(t,128);if(null==n)throw new Error("abort");e.extraData=n}catch(i){On(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(Zn(i.data,4))}catch(s){On(!1,s.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:r,info:{data:t}})}On(a.sender.toLowerCase()===o.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:t,reason:"OffchainLookup",transaction:r,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:a.errorArgs}});const l=yield this.ccipReadFetch(r,a.calldata,a.urls);On(null!=l,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:r,info:{data:i.data,errorArgs:a.errorArgs}});const c={to:o,data:Jn([a.selector,qh([l,a.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=yield __privateMethod(this,Ke,Je).call(this,c,e,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},c),result:t}),t}catch(s){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},c),error:s}),s}}throw i}}))},qe=new WeakSet,Ze=function(t){return __async(this,null,(function*(){const{value:e}=yield Tn({network:this.getNetwork(),value:t});return e}))},Ye=new WeakSet,Xe=function(t,e,n){return __async(this,null,(function*(){let r=this._getAddress(e),i=this._getBlockTag(n);return"string"==typeof r&&"string"==typeof i||([r,i]=yield Promise.all([r,i])),yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,ze,Ve).call(this,Object.assign(t,{address:r,blockTag:i})))}))},$e=new WeakSet,tn=function(t,e){return __async(this,null,(function*(){if(Qn(t,32))return yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let n=this._getBlockTag(t);return"string"!=typeof n&&(n=yield n),yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockTag:n,includeTransactions:e})}))},en=new WeakSet,nn=function(t,e){return __async(this,null,(function*(){let n=yield Dh(t,this);return"event"===n.type&&e&&e.length>0&&!0===e[0].removed&&(n=yield Dh({orphan:"drop-log",log:e[0]},this)),__privateGet(this,Be).get(n.tag)||null}))},rn=new WeakSet,sn=function(t){return __async(this,null,(function*(){const e=yield Dh(t,this),n=e.tag;let r=__privateGet(this,Be).get(n);if(!r){r={subscriber:this._getSubscriber(e),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},__privateGet(this,Be).set(n,r)}return r}))};const Jh=new Uint8Array([]);function qh(t){const e=[];let n=0;for(let r=0;r<t.length;r++)e.push(Jh),n+=32;for(let r=0;r<t.length;r++){const i=Hn(t[r]);e[r]=Vh(n),e.push(Vh(i.length)),e.push(Kh(i)),n+=32+32*Math.ceil(i.length/32)}return Jn(e)}const Zh="0x0000000000000000000000000000000000000000000000000000000000000000";function Yh(t,e){if(t.provider)return t.provider;On(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}function Xh(t,e){return __async(this,null,(function*(){let n=vu(e);if(null!=n.to&&(n.to=Zo(n.to,t)),null!=n.from){const e=n.from;n.from=Promise.all([t.getAddress(),Zo(e,t)]).then((([t,e])=>(Ln(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else n.from=t.getAddress();return yield Tn(n)}))}class $h{constructor(t){__publicField(this,"provider"),Mn(this,{provider:t||null})}getNonce(t){return __async(this,null,(function*(){return Yh(this,"getTransactionCount").getTransactionCount(yield this.getAddress(),t)}))}populateCall(t){return __async(this,null,(function*(){return yield Xh(this,t)}))}populateTransaction(t){return __async(this,null,(function*(){const e=Yh(this,"populateTransaction"),n=yield Xh(this,t);null==n.nonce&&(n.nonce=yield this.getNonce("pending")),null==n.gasLimit&&(n.gasLimit=yield this.estimateGas(n));const r=yield this.provider.getNetwork();if(null!=n.chainId){Ln(sr(n.chainId)===r.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else n.chainId=r.chainId;const i=null!=n.maxFeePerGas||null!=n.maxPriorityFeePerGas;if(null==n.gasPrice||2!==n.type&&!i?0!==n.type&&1!==n.type||!i||Ln(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):Ln(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==n.type&&null!=n.type||null==n.maxFeePerGas||null==n.maxPriorityFeePerGas)if(0===n.type||1===n.type){const t=yield e.getFeeData();On(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==n.gasPrice&&(n.gasPrice=t.gasPrice)}else{const t=yield e.getFeeData();if(null==n.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(n.authorizationList&&n.authorizationList.length?n.type=4:n.type=2,null!=n.gasPrice){const t=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=t,n.maxPriorityFeePerGas=t}else null==n.maxFeePerGas&&(n.maxFeePerGas=t.maxFeePerGas),null==n.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(On(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==n.gasPrice&&(n.gasPrice=t.gasPrice),n.type=0):On(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==n.type&&3!==n.type&&4!==n.type||(null==n.maxFeePerGas&&(n.maxFeePerGas=t.maxFeePerGas),null==n.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else n.type=2;return yield Tn(n)}))}populateAuthorization(t){return __async(this,null,(function*(){const e=Object.assign({},t);return null==e.chainId&&(e.chainId=(yield Yh(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=yield this.getNonce()),e}))}estimateGas(t){return __async(this,null,(function*(){return Yh(this,"estimateGas").estimateGas(yield this.populateCall(t))}))}call(t){return __async(this,null,(function*(){return Yh(this,"call").call(yield this.populateCall(t))}))}resolveName(t){return __async(this,null,(function*(){const e=Yh(this,"resolveName");return yield e.resolveName(t)}))}sendTransaction(t){return __async(this,null,(function*(){const e=Yh(this,"sendTransaction"),n=yield this.populateTransaction(t);delete n.from;const r=Da.from(n);return yield e.broadcastTransaction(yield this.signTransaction(r))}))}authorize(t){On(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class td{constructor(t){__privateAdd(this,dn),__privateAdd(this,fn),__privateAdd(this,on,void 0),__privateAdd(this,an,void 0),__privateAdd(this,ln,void 0),__privateAdd(this,cn,void 0),__privateAdd(this,un,void 0),__privateAdd(this,hn,void 0),__privateSet(this,on,t),__privateSet(this,an,null),__privateSet(this,ln,__privateMethod(this,dn,pn).bind(this)),__privateSet(this,cn,!1),__privateSet(this,un,null),__privateSet(this,hn,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){__privateGet(this,cn)||(__privateSet(this,cn,!0),__privateMethod(this,dn,pn).call(this,-2))}stop(){__privateGet(this,cn)&&(__privateSet(this,cn,!1),__privateSet(this,hn,!0),__privateMethod(this,fn,gn).call(this),__privateGet(this,on).off("block",__privateGet(this,ln)))}pause(t){t&&__privateMethod(this,fn,gn).call(this),__privateGet(this,on).off("block",__privateGet(this,ln))}resume(){this.start()}}on=new WeakMap,an=new WeakMap,ln=new WeakMap,cn=new WeakMap,un=new WeakMap,hn=new WeakMap,dn=new WeakSet,pn=function(t){return __async(this,null,(function*(){try{null==__privateGet(this,an)&&__privateSet(this,an,this._subscribe(__privateGet(this,on)));let e=null;try{e=yield __privateGet(this,an)}catch(t){if(!Bn(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==e)return __privateSet(this,an,null),void __privateGet(this,on)._recoverSubscriber(this,this._recover(__privateGet(this,on)));const n=yield __privateGet(this,on).getNetwork();if(__privateGet(this,un)||__privateSet(this,un,n),__privateGet(this,un).chainId!==n.chainId)throw new Error("chaid changed");if(__privateGet(this,hn))return;const r=yield __privateGet(this,on).send("eth_getFilterChanges",[e]);yield this._emitResults(__privateGet(this,on),r)}catch(t){console.log("@TODO",t)}__privateGet(this,on).once("block",__privateGet(this,ln))}))},fn=new WeakSet,gn=function(){const t=__privateGet(this,an);t&&(__privateSet(this,an,null),t.then((t=>{__privateGet(this,on).destroyed||__privateGet(this,on).send("eth_uninstallFilter",[t])})))};class ed extends td{constructor(t,e){var n;super(t),__privateAdd(this,mn,void 0),__privateSet(this,mn,(n=e,JSON.parse(JSON.stringify(n))))}_recover(t){return new Gh(t,__privateGet(this,mn))}_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newFilter",[__privateGet(this,mn)])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const n of e)t.emit(__privateGet(this,mn),t._wrapLog(n,t._network))}))}}mn=new WeakMap;class nd extends td{_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newPendingTransactionFilter",[])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const n of e)t.emit("pending",n)}))}}const rd="bigint,boolean,function,number,string,symbol".split(/,/g);function id(t){if(null==t||rd.indexOf(typeof t)>=0)return t;if("function"==typeof t.getAddress)return t;if(Array.isArray(t))return t.map(id);if("object"==typeof t)return Object.keys(t).reduce(((e,n)=>(e[n]=t[n],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function sd(t){return new Promise((e=>{setTimeout(e,t)}))}function od(t){return t?t.toLowerCase():t}function ad(t){return t&&"number"==typeof t.pollingInterval}const ld={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class cd extends $h{constructor(t,e){super(t),__publicField(this,"address"),Mn(this,{address:e=Ko(e)})}connect(t){On(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}getAddress(){return __async(this,null,(function*(){return this.address}))}populateTransaction(t){return __async(this,null,(function*(){return yield this.populateCall(t)}))}sendUncheckedTransaction(t){return __async(this,null,(function*(){const e=id(t),n=[];if(e.from){const r=e.from;n.push((()=>__async(this,null,(function*(){const n=yield Zo(r,this.provider);Ln(null!=n&&n.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=n})))())}else e.from=this.address;if(null==e.gasLimit&&n.push((()=>__async(this,null,(function*(){e.gasLimit=yield this.provider.estimateGas(__spreadProps(__spreadValues({},e),{from:this.address}))})))()),null!=e.to){const t=e.to;n.push((()=>__async(this,null,(function*(){e.to=yield Zo(t,this.provider)})))())}n.length&&(yield Promise.all(n));const r=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[r])}))}sendTransaction(t){return __async(this,null,(function*(){const e=yield this.provider.getBlockNumber(),n=yield this.sendUncheckedTransaction(t);return yield new Promise(((t,r)=>{const i=[1e3,100];let s=0;const o=()=>__async(this,null,(function*(){try{const r=yield this.provider.getTransaction(n);if(null!=r)return void t(r.replaceableTransaction(e))}catch(a){if(Bn(a,"CANCELLED")||Bn(a,"BAD_DATA")||Bn(a,"NETWORK_ERROR")||Bn(a,"UNSUPPORTED_OPERATION"))return null==a.info&&(a.info={}),a.info.sendTransactionHash=n,void r(a);if(Bn(a,"INVALID_ARGUMENT")&&(s++,null==a.info&&(a.info={}),a.info.sendTransactionHash=n,s>10))return void r(a);this.provider.emit("error",In("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:a}))}this.provider._setTimeout((()=>{o()}),i.pop()||4e3)}));o()}))}))}signTransaction(t){return __async(this,null,(function*(){const e=id(t);if(e.from){const n=yield Zo(e.from,this.provider);Ln(null!=n&&n.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=n}else e.from=this.address;const n=this.provider.getRpcTransaction(e);return yield this.provider.send("eth_signTransaction",[n])}))}signMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?_r(t):t;return yield this.provider.send("personal_sign",[Kn(e),this.address.toLowerCase()])}))}signTypedData(t,e,n){return __async(this,null,(function*(){const r=id(n),i=yield uc.resolveNames(t,e,r,(t=>__async(this,null,(function*(){const e=yield Zo(t);return Ln(null!=e,"TypedData does not support null address","value",t),e}))));return yield this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(uc.getPayload(i.domain,e,i.value))])}))}unlock(t){return __async(this,null,(function*(){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}))}_legacySignMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?_r(t):t;return yield this.provider.send("eth_sign",[this.address.toLowerCase(),Kn(e)])}))}}yn=new WeakMap,_n=new WeakMap,wn=new WeakMap,vn=new WeakMap,bn=new WeakMap,An=new WeakMap,En=new WeakMap,xn=new WeakSet,kn=function(){if(__privateGet(this,vn))return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");__privateSet(this,vn,setTimeout((()=>{__privateSet(this,vn,null);const t=__privateGet(this,wn);for(__privateSet(this,wn,[]);t.length;){const e=[t.shift()];for(;t.length&&e.length!==__privateGet(this,yn).batchMaxCount;){e.push(t.shift());if(JSON.stringify(e.map((t=>t.payload))).length>__privateGet(this,yn).batchMaxSize){t.unshift(e.pop());break}}(()=>{__async(this,null,(function*(){const t=1===e.length?e[0].payload:e.map((t=>t.payload));this.emit("debug",{action:"sendRpcPayload",payload:t});try{const n=yield this._send(t);this.emit("debug",{action:"receiveRpcResult",result:n});for(const{resolve:t,reject:r,payload:i}of e){if(this.destroyed){r(In("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=n.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?r(this.getRpcError(i,e)):t(e.result);else{const t=In("missing response for request","BAD_DATA",{value:n,info:{payload:i}});this.emit("error",t),r(t)}}}catch(n){this.emit("debug",{action:"receiveRpcError",error:n});for(const{reject:t}of e)t(n)}}))})()}}),t))};let ud=class t extends Wh{constructor(t,e){super(t,e),__privateAdd(this,xn),__privateAdd(this,yn,void 0),__privateAdd(this,_n,void 0),__privateAdd(this,wn,void 0),__privateAdd(this,vn,void 0),__privateAdd(this,bn,void 0),__privateAdd(this,An,void 0),__privateAdd(this,En,void 0),__privateSet(this,_n,1),__privateSet(this,yn,Object.assign({},ld,e||{})),__privateSet(this,wn,[]),__privateSet(this,vn,null),__privateSet(this,An,null),__privateSet(this,En,null);{let t=null;const e=new Promise((e=>{t=e}));__privateSet(this,bn,{promise:e,resolve:t})}const n=this._getOption("staticNetwork");"boolean"==typeof n?(Ln(!n||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),n&&null!=t&&__privateSet(this,An,xh.from(t))):n&&(Ln(null==t||n.matches(t),"staticNetwork MUST match network object","options",e),__privateSet(this,An,n))}_getOption(t){return __privateGet(this,yn)[t]}get _network(){return On(__privateGet(this,An),"network is not available yet","NETWORK_ERROR"),__privateGet(this,An)}_perform(e){return __async(this,null,(function*(){if("call"===e.method||"estimateGas"===e.method){let t=e.transaction;if(t&&null!=t.type&&sr(t.type)&&null==t.maxFeePerGas&&null==t.maxPriorityFeePerGas){const n=yield this.getFeeData();null==n.maxFeePerGas&&null==n.maxPriorityFeePerGas&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}const n=this.getRpcRequest(e);return null!=n?yield this.send(n.method,n.args):__superGet(t.prototype,this,"_perform").call(this,e)}))}_detectNetwork(){return __async(this,null,(function*(){const t=this._getOption("staticNetwork");if(t){if(!0!==t)return t;if(__privateGet(this,An))return __privateGet(this,An)}return __privateGet(this,En)?yield __privateGet(this,En):this.ready?(__privateSet(this,En,(()=>__async(this,null,(function*(){try{const t=xh.from(sr(yield this.send("eth_chainId",[])));return __privateSet(this,En,null),t}catch(t){throw __privateSet(this,En,null),t}})))()),yield __privateGet(this,En)):(__privateSet(this,En,(()=>__async(this,null,(function*(){const t={id:__privateWrapper(this,_n)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};let e;this.emit("debug",{action:"sendRpcPayload",payload:t});try{e=(yield this._send(t))[0],__privateSet(this,En,null)}catch(n){throw __privateSet(this,En,null),this.emit("debug",{action:"receiveRpcError",error:n}),n}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return xh.from(sr(e.result));throw this.getRpcError(t,e)})))()),yield __privateGet(this,En))}))}_start(){null!=__privateGet(this,bn)&&null!=__privateGet(this,bn).resolve&&(__privateGet(this,bn).resolve(),__privateSet(this,bn,null),(()=>{__async(this,null,(function*(){for(;null==__privateGet(this,An)&&!this.destroyed;)try{__privateSet(this,An,yield 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",In("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),yield sd(1e3)}__privateMethod(this,xn,kn).call(this)}))})())}_waitUntilReady(){return __async(this,null,(function*(){if(null!=__privateGet(this,bn))return yield __privateGet(this,bn).promise}))}_getSubscriber(t){return"pending"===t.type?new nd(this):"event"===t.type?this._getOption("polling")?new Gh(this,t.filter):new ed(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new Fh("orphan"):super._getSubscriber(t)}get ready(){return null==__privateGet(this,bn)}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((n=>{if(null==t[n])return;let r=n;"gasLimit"===n&&(r="gas"),e[r]=dr(sr(t[n],`tx.${n}`))})),["from","to","data"].forEach((n=>{null!=t[n]&&(e[n]=Kn(t[n]))})),t.accessList&&(e.accessList=va(t.accessList)),t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.map((t=>t.toLowerCase()))),t.authorizationList&&(e.authorizationList=t.authorizationList.map((t=>{const e=ba(t);return{address:e.address,nonce:dr(e.nonce),chainId:dr(e.chainId),yParity:dr(e.signature.yParity),r:dr(e.signature.r),s:dr(e.signature.s)}}))),e}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:[od(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[od(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[od(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[od(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&&null!=t.filter.address&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(od):t.filter.address=od(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:n}=t,{error:r}=e;if("eth_estimateGas"===n&&r.message){const e=r.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return In("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:r}});if(e.match(/nonce/i)&&e.match(/too low/i))return In("nonce has already been used","NONCE_EXPIRED",{transaction:t.params[0],info:{payload:t,error:r}})}if("eth_call"===n||"eth_estimateGas"===n){const e=dd(r),i=lu.getBuiltinCallException("eth_call"===n?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:r,payload:t},i}const i=JSON.stringify(function(t){const e=[];return pd(t,e),e}(r));if("string"==typeof r.message&&r.message.match(/user denied|ethers-user-denied/i)){return In("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"}[n]||"unknown",reason:"rejected",info:{payload:t,error:r}})}if("eth_sendRawTransaction"===n||"eth_sendTransaction"===n){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return In("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:r}});if(i.match(/nonce/i)&&i.match(/too low/i))return In("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:r}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return In("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:r}});if(i.match(/only replay-protected/i))return In("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:n,info:{transaction:e,info:{error:r}}})}let s=!!i.match(/the method .* does not exist/i);return s||r&&r.details&&r.details.startsWith("Unauthorized method:")&&(s=!0),s?In("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:r,payload:t}}):In("could not coalesce error","UNKNOWN_ERROR",{error:r,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(In("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const n=__privateWrapper(this,_n)._++,r=new Promise(((r,i)=>{__privateGet(this,wn).push({resolve:r,reject:i,payload:{method:t,params:e,id:n,jsonrpc:"2.0"}})}));return __privateMethod(this,xn,kn).call(this),r}getSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const n=yield e;if(t>=n.length)throw new Error("no such account");return new cd(this,n[t])}const{accounts:n}=yield Tn({network:this.getNetwork(),accounts:e});t=Ko(t);for(const r of n)if(Ko(r)===t)return new cd(this,t);throw new Error("invalid account")}))}listAccounts(){return __async(this,null,(function*(){return(yield this.send("eth_accounts",[])).map((t=>new cd(this,t)))}))}destroy(){__privateGet(this,vn)&&(clearTimeout(__privateGet(this,vn)),__privateSet(this,vn,null));for(const{payload:t,reject:e}of __privateGet(this,wn))e(In("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));__privateSet(this,wn,[]),super.destroy()}};class hd extends ud{constructor(t,e){super(t,e),__privateAdd(this,Sn,void 0);let n=this._getOption("pollingInterval");null==n&&(n=ld.pollingInterval),__privateSet(this,Sn,n)}_getSubscriber(t){const e=super._getSubscriber(t);return ad(e)&&(e.pollingInterval=__privateGet(this,Sn)),e}get pollingInterval(){return __privateGet(this,Sn)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");__privateSet(this,Sn,t),this._forEachSubscriber((t=>{ad(t)&&(t.pollingInterval=__privateGet(this,Sn))}))}}function dd(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&Qn(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const n=dd(t[e]);if(n)return n}return null}if("string"==typeof t)try{return dd(JSON.parse(t))}catch(e){}return null}function pd(t,e){if(null!=t){if("string"==typeof t.message&&e.push(t.message),"object"==typeof t)for(const n in t)pd(t[n],e);if("string"==typeof t)try{return pd(JSON.parse(t),e)}catch(n){}}}Sn=new WeakMap;Nn=new WeakMap,Cn=new WeakMap;let fd=class t extends hd{constructor(t,e,n){const r=Object.assign({},null!=n?n:{},{batchMaxCount:1});Ln(t&&t.request,"invalid EIP-1193 provider","ethereum",t),super(e,r),__privateAdd(this,Nn,void 0),__privateAdd(this,Cn,void 0),__privateSet(this,Cn,null),n&&n.providerInfo&&__privateSet(this,Cn,n.providerInfo),__privateSet(this,Nn,((e,n)=>__async(this,null,(function*(){const r={method:e,params:n};this.emit("debug",{action:"sendEip1193Request",payload:r});try{const e=yield t.request(r);return this.emit("debug",{action:"receiveEip1193Result",result:e}),e}catch(i){const t=new Error(i.message);throw t.code=i.code,t.data=i.data,t.payload=r,this.emit("debug",{action:"receiveEip1193Error",error:t}),t}}))))}get providerInfo(){return __privateGet(this,Cn)}send(e,n){return __async(this,null,(function*(){return yield this._start(),yield __superGet(t.prototype,this,"send").call(this,e,n)}))}_send(t){return __async(this,null,(function*(){Ln(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const e=yield __privateGet(this,Nn).call(this,t.method,t.params||[]);return[{id:t.id,result:e}]}catch(e){return[{id:t.id,error:{code:e.code,data:e.data,message:e.message}}]}}))}getRpcError(t,e){switch((e=JSON.parse(JSON.stringify(e))).error.code||-1){case 4001:e.error.message=`ethers-user-denied: ${e.error.message}`;break;case 4200:e.error.message=`ethers-unsupported: ${e.error.message}`}return super.getRpcError(t,e)}hasSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=yield this.send("eth_accounts",[]);return"number"==typeof t?e.length>t:(t=t.toLowerCase(),0!==e.filter((e=>e.toLowerCase()===t)).length)}))}getSigner(e){return __async(this,null,(function*(){if(null==e&&(e=0),!(yield this.hasSigner(e)))try{yield __privateGet(this,Nn).call(this,"eth_requestAccounts",[])}catch(n){const t=n.payload;throw this.getRpcError(t,{id:t.id,error:n})}return yield __superGet(t.prototype,this,"getSigner").call(this,e)}))}static discover(e){return __async(this,null,(function*(){if(null==e&&(e={}),e.provider)return new t(e.provider);const n=e.window?e.window:"undefined"!=typeof window?window:null;if(null==n)return null;const r=e.anyProvider;if(r&&n.ethereum)return new t(n.ethereum);if(!("addEventListener"in n&&"dispatchEvent"in n&&"removeEventListener"in n))return null;const i=e.timeout?e.timeout:300;return 0===i?null:yield new Promise(((s,o)=>{let a=[];const l=t=>{a.push(t.detail),r&&c()},c=()=>{if(clearTimeout(u),a.length)if(e&&e.filter){const n=e.filter(a.map((t=>Object.assign({},t.info))));if(null==n)s(null);else if(n instanceof t)s(n);else{let e=null;if(n.uuid){e=a.filter((t=>n.uuid===t.info.uuid))[0]}if(e){const{provider:n,info:r}=e;s(new t(n,void 0,{providerInfo:r}))}else o(In("filter returned unknown info","UNSUPPORTED_OPERATION",{value:n}))}}else{const{provider:e,info:n}=a[0];s(new t(e,void 0,{providerInfo:n}))}else s(null);n.removeEventListener("eip6963:announceProvider",l)},u=setTimeout((()=>{c()}),i);n.addEventListener("eip6963:announceProvider",l),n.dispatchEvent(new Event("eip6963:requestProvider"))}))}))}};const gd={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trustwallet",LUTE:"lute"},md={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},yd={[md.ETHEREUM]:{name:"Ethereum Mainnet",chainId:1,symbol:"ETH",decimals:18,rpcUrl:"https://mainnet.infura.io/v3/your-infura-key",blockExplorerUrl:"https://etherscan.io"},[md.BSC]:{name:"Binance Smart Chain",chainId:56,symbol:"BNB",decimals:18,rpcUrl:"https://bsc-dataseed.binance.org/",blockExplorerUrl:"https://bscscan.com"},[md.TRON]:{name:"TRON Mainnet",symbol:"TRX",decimals:6,rpcUrl:"https://api.trongrid.io",blockExplorerUrl:"https://tronscan.org"},[md.ALGORAND]:{name:"Algorand Mainnet",symbol:"ALGO",decimals:6,rpcUrl:"https://mainnet-api.algonode.cloud",blockExplorerUrl:"https://algoexplorer.io"}},_d={USDT:{ethereum:{contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,symbol:"USDT"},bsc:{contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,symbol:"USDT"},tron:{contractAddress:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",decimals:6,symbol:"USDT"},algorand:{assetId:312769,decimals:6,symbol:"USDT"}},USDC:{ethereum:{contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,symbol:"USDC"},bsc:{contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,symbol:"USDC"},tron:{contractAddress:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",decimals:6,symbol:"USDC"},algorand:{assetId:31566704,decimals:6,symbol:"USDC"}},BNB:{bsc:{decimals:18,symbol:"BNB",isNative:!0}},ETH:{ethereum:{decimals:18,symbol:"ETH",isNative:!0}},TRX:{tron:{decimals:6,symbol:"TRX",isNative:!0}},ALGO:{algorand:{decimals:6,symbol:"ALGO",isNative:!0}}},wd={[md.ETHEREUM]:[gd.METAMASK,gd.TRUST_WALLET],[md.BSC]:[gd.METAMASK,gd.TRUST_WALLET],[md.TRON]:[gd.TRONLINK],[md.ALGORAND]:[gd.LUTE]},vd=t=>({[gd.METAMASK]:"https://metamask.io/download/",[gd.TRONLINK]:"https://www.tronlink.org/download/",[gd.TRUST_WALLET]:"https://trustwallet.com/download/",[gd.LUTE]:"https://lute.app/download/"}[t]||""),bd=()=>{if("undefined"==typeof window)return!1;return[()=>void 0!==window.lute,()=>void 0!==window.algorand,()=>void 0!==window.AlgoSigner,()=>void 0!==window.luteWallet,()=>null!==document.querySelector('[data-wallet="lute"]'),()=>window.postMessage&&"true"===document.documentElement.getAttribute("data-lute-extension")].some((t=>{try{return t()}catch(e){return console.warn("Lute detection method failed:",e),!1}}))},Ad=()=>{const t={[gd.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum&&window.ethereum.isMetaMask,[gd.TRONLINK]:"undefined"!=typeof window&&void 0!==window.tronWeb,[gd.TRUST_WALLET]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isTrust,[gd.LUTE]:bd()};return"undefined"!=typeof window&&(console.log("=== LUTE WALLET DETECTION DEBUG ==="),console.log("window.lute:",Boolean(window.lute)),console.log("window.algorand:",Boolean(window.algorand)),console.log("window.AlgoSigner:",Boolean(window.AlgoSigner)),console.log("window.luteWallet:",Boolean(window.luteWallet)),console.log("Lute detected overall:",t[gd.LUTE]),console.log("=== END LUTE DETECTION DEBUG ===")),t},Ed=(t=5,e=1e3)=>__async(this,null,(function*(){let n=0,r=Ad();for(;n<t;){r=Ad();if(Object.values(r).some((t=>!0===t))||n>=t-1)break;console.log(`Wallet detection attempt ${n+1}/${t}...`),console.log("Current detection results:",r),yield new Promise((t=>setTimeout(t,e))),n++}if(!r[gd.LUTE]&&(console.log("Performing extended Lute wallet detection..."),"undefined"!=typeof window))try{const t=new CustomEvent("lute-wallet-detect",{detail:{source:"coinley-sdk"}});window.dispatchEvent(t),yield new Promise((t=>setTimeout(t,500))),r[gd.LUTE]=bd()}catch(i){console.warn("Extended Lute detection failed:",i)}return console.log("Final wallet detection results:",r),r})),xd=()=>__async(this,null,(function*(){if(console.log("Connecting to MetaMask wallet..."),!window.ethereum||!window.ethereum.isMetaMask)throw console.error("MetaMask not found."),new Error("MetaMask not detected. Please install MetaMask extension.");try{const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],n=yield window.ethereum.request({method:"eth_chainId"}),r=parseInt(n,16);let i;switch(r){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${r}`}const s=new fd(window.ethereum);return{walletType:gd.METAMASK,address:e,provider:s,network:i,isConnected:!0,chainId:r}}catch(t){throw console.error("Error connecting to MetaMask:",t),t}})),kd=()=>__async(this,null,(function*(){if(console.log("Connecting to Trust Wallet..."),!window.ethereum||!window.ethereum.isTrust)throw console.error("Trust Wallet not found."),new Error("Trust Wallet not detected. Please install Trust Wallet.");try{const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],n=yield window.ethereum.request({method:"eth_chainId"}),r=parseInt(n,16);let i;switch(r){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${r}`}const s=new fd(window.ethereum);return{walletType:gd.TRUST_WALLET,address:e,provider:s,network:i,isConnected:!0,chainId:r}}catch(t){throw console.error("Error connecting to Trust Wallet:",t),t}})),Sd=()=>__async(this,null,(function*(){if(console.log("Connecting to TronLink wallet..."),!window.tronWeb)throw console.error("TronWeb not found. Is TronLink installed?"),new Error("TronLink not detected. Please install TronLink extension.");const t=(t=10,e=500)=>__async(this,null,(function*(){for(let n=0;n<t;n++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${n+1}/${t}`),yield new Promise((t=>setTimeout(t,e)))}throw new Error("TronWeb took too long to be ready")}));try{const n=yield t();if(!n.defaultAddress||!n.defaultAddress.base58)try{yield window.tronWeb.request({method:"tron_requestAccounts"})}catch(e){throw console.error("Failed to get permission from TronLink:",e),new Error("Please unlock TronLink and approve connection")}const r=n.defaultAddress.base58;return console.log("Connected to TronLink wallet:",r),{walletType:gd.TRONLINK,address:r,provider:n,network:md.TRON,isConnected:!0}}catch(n){throw console.error("Error connecting to TronLink:",n),n}})),Nd=()=>__async(this,null,(function*(){var t;console.log("Connecting to Lute wallet...");let e=null,n="";if(window.lute?(e=window.lute,n="Lute"):window.algorand?(e=window.algorand,n="Algorand Provider"):window.AlgoSigner?(e=window.AlgoSigner,n="AlgoSigner"):window.luteWallet&&(e=window.luteWallet,n="Lute Wallet"),!e)throw console.error("No Algorand wallet detected."),console.log("Available window properties:",Object.keys(window).filter((t=>t.toLowerCase().includes("lute")||t.toLowerCase().includes("algo")||t.toLowerCase().includes("wallet")))),new Error("Lute wallet not detected. Please install Lute extension or another Algorand wallet.");console.log(`Found ${n} wallet provider:`,e);try{let r=null;if(e.connect){console.log("Using connect() method...");const t=yield e.connect();r=t.address||t}else if(e.enable){console.log("Using enable() method...");const t=yield e.enable();r=t[0]||t}else if(e.requestAccounts){console.log("Using requestAccounts() method...");r=(yield e.requestAccounts())[0]}else if(e.connect&&"AlgoSigner"===n){console.log("Using AlgoSigner connect..."),yield e.connect();r=null==(t=(yield e.accounts({ledger:"MainNet"}))[0])?void 0:t.address}if(!r)throw new Error(`No address returned from ${n}. Please unlock your wallet and try again.`);return console.log(`Connected to ${n} wallet:`,r),{walletType:gd.LUTE,address:r,provider:e,network:md.ALGORAND,isConnected:!0,walletName:n}}catch(r){throw console.error(`Error connecting to ${n}:`,r),r.message&&r.message.includes("User rejected")?new Error("Connection rejected by user. Please approve the connection in your wallet."):r.message&&r.message.includes("locked")?new Error("Wallet is locked. Please unlock your wallet and try again."):new Error(`Failed to connect to ${n}: ${r.message||"Unknown error"}`)}})),Cd=t=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",t),t){case gd.METAMASK:return xd();case gd.TRONLINK:return Sd();case gd.TRUST_WALLET:return kd();case gd.LUTE:return Nd();default:throw new Error(`Unsupported wallet type: ${t}`)}})),Pd=t=>wd[t]||[],Td=(t,e,n)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:e,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");try{let r;switch(t.walletType){case gd.METAMASK:case gd.TRUST_WALLET:const i=t.provider,s=yield i.getSigner(),o=n.toString(),a=ii(o,18);console.log("Sending ETH/BNB:",{to:e,value:a.toString()});const l=yield i.estimateGas({to:e,value:a,from:yield s.getAddress()});console.log("Gas estimate:",l.toString());const c=l*BigInt(110)/BigInt(100);console.log("Using gas limit:",c.toString()),r=yield s.sendTransaction({to:e,value:a,gasLimit:c});break;case gd.TRONLINK:const u=t.provider;if(!u||!u.ready)throw new Error("TronWeb not initialized");const h=u.toSun(n.toString());console.log("Sending TRX:",{to:e,value:h}),r=yield u.trx.sendTransaction(e,h);break;case gd.LUTE:const d=t.provider,p=Math.floor(1e6*parseFloat(n));if(console.log("Sending Algos:",{to:e,amount:p,walletName:t.walletName}),d.sendPayment)r=yield d.sendPayment({recipient:e,amount:p});else{if(!d.signTransaction)throw new Error(`Unsupported Algorand wallet API for ${t.walletName}`);{const t={to:e,fee:1e3,amount:p,firstRound:1e3,lastRound:2e3,type:"pay"};r=yield d.signTransaction(t)}}break;default:throw new Error(`Unsupported wallet type: ${t.walletType}`)}console.log("Transaction sent:",r);const i=r.hash||r.txID||r.txId||r;return console.log("Transaction hash:",i),i}catch(r){throw console.error("Native transaction error:",r),r}})),Md=(t,e)=>__async(this,null,(function*(){var n;if(console.log("Sending transaction with:",e),!t)throw new Error("Wallet not connected");const{to:r,amount:i,tokenAddress:s,currency:o,network:a}=e;if(!r)throw new Error("Recipient address not provided");const l=null==(n=_d[o])?void 0:n[a];return l&&l.isNative?Td(t,r,i):l?Rd(t,l,r,i):Td(t,r,i)})),Rd=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending token transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Token configuration not provided");if(!n)throw new Error("Recipient address not provided");if(!r||isNaN(parseFloat(r))||parseFloat(r)<=0)throw new Error("Invalid amount");const{contractAddress:i,decimals:s,symbol:o}=e;switch(console.log(`Token: ${o}, Decimals: ${s}, Contract: ${i}`),t.walletType){case gd.TRONLINK:return Gd(t,e,n,r);case gd.LUTE:return Id(t,e,n,r);default:return Bd(t,e,n,r)}})),Bd=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending ERC20/BEP20 transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");const i=t.provider,s=yield i.getSigner(),{contractAddress:o,decimals:a,symbol:l}=e,c=parseFloat(r),u=parseInt(a),h=ii(c.toString(),u);console.log(`Sending ${c} ${l} (${h.toString()} base units) to ${n}`),console.log("Token config:",{contractAddress:o,decimals:a,symbol:l});try{const t=new eh(o,["function transfer(address to, uint256 amount) returns (bool)","function balanceOf(address owner) view returns (uint256)","function decimals() view returns (uint8)"],s),e=yield s.getAddress(),r=yield t.balanceOf(e);if(console.log(`User ${l} balance:`,ri(r,a)),r<h)throw new Error(`Insufficient ${l} balance. Required: ${c}, Available: ${ri(r,a)}`);try{const e=yield t.transfer.estimateGas(n,h);let r;console.log("Gas estimate:",e.toString()),r="USDC"===l?BigInt(150):"USDT"===l?BigInt(130):BigInt(120);const i=e*r/BigInt(100);console.log("Using gas limit:",i.toString());const s=yield t.transfer(n,h,{gasLimit:i});return console.log("Transaction sent:",s),s.hash}catch(d){let e;console.error("Gas estimation failed:",d),e="USDC"===l?BigInt(2e5):"USDT"===l?BigInt(18e4):BigInt(15e4),console.log(`Trying ${l} transaction with fixed gas limit:`,e.toString());const r=yield t.transfer(n,h,{gasLimit:e});return console.log("Transaction sent with fixed gas limit:",r),r.hash}}catch(p){throw console.error("ERC20 transaction error:",p),p.message&&p.message.includes("user rejected")?new Error("Transaction rejected by user"):p.message&&p.message.includes("insufficient funds")?new Error("Insufficient funds for transaction"):(p.message&&p.message.includes("Insufficient"),p)}})),Gd=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending TRC20 transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Tron wallet not connected");const i=t.provider;if(!i||!i.ready)throw new Error("TronWeb not initialized");if(!e||!e.contractAddress)throw new Error("Invalid token configuration");const{contractAddress:s,decimals:o,symbol:a}=e,l=parseFloat(r),c=parseInt(o),u=(l*Math.pow(10,c)).toString();console.log(`Sending ${l} ${a} (${u} base units) to ${n}`);try{const t=yield i.contract().at(s);if(!t.transfer)throw new Error("Invalid TRC-20 contract");const e=yield t.transfer(n,u).send({feeLimit:1e8,callValue:0,shouldPollResponse:!1});return console.log("TRC20 transaction sent:",e),e}catch(h){throw console.error("TRC20 transaction failed:",h),h.message&&h.message.includes("User rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("bandwidth")?new Error("Insufficient energy or bandwidth. Make sure you have enough TRX for fees."):h.message&&h.message.includes("balance")?new Error("Insufficient token balance for transfer"):new Error(`Transaction failed: ${h.message||"Unknown error"}`)}})),Id=(t,e,n,r)=>__async(this,null,(function*(){if(console.log("Sending Algorand asset transaction with:",{tokenConfig:e,toAddress:n,amount:r}),!t||!t.provider)throw new Error("Algorand wallet not connected");const i=t.provider;if(!e||!e.assetId)throw new Error("Invalid token configuration - missing assetId");const{assetId:s,decimals:o,symbol:a}=e,l=parseFloat(r),c=parseInt(o),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${a} (${u} base units) to ${n}`),console.log(`Using wallet: ${t.walletName||"Unknown"}`);try{let e;if(i.sendAssetTransfer)console.log("Using sendAssetTransfer method..."),e=yield i.sendAssetTransfer({recipient:n,assetId:s,amount:u});else{if(!i.signTransaction)throw new Error(`Unsupported Algorand wallet API for asset transfers in ${t.walletName||"this wallet"}`);{console.log("Using signTransaction method for asset transfer...");const r={type:"axfer",from:t.address,to:n,amount:u,assetIndex:s,fee:1e3,firstRound:1e3,lastRound:2e3};e=yield i.signTransaction(r)}}return console.log("Algorand asset transaction sent:",e),e.txId||e.txID||e}catch(h){throw console.error("Algorand asset transaction error:",h),h.message&&h.message.includes("rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("balance")?new Error("Insufficient asset balance"):h.message&&h.message.includes("opted")?new Error("Account not opted in to this asset. Please opt in first."):h}}));let Od={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{},authToken:null};const Ld=t=>__async(this,null,(function*(){Od=__spreadValues(__spreadValues({},Od),t),console.log("API initialized with:",{apiUrl:Od.apiUrl,apiKey:Od.apiKey?`${Od.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Od.merchantWalletAddresses||{}).length>0});try{yield Fd()}catch(e){console.error("Failed to fetch merchant wallets during initialization:",e)}})),Fd=()=>__async(this,null,(function*(){try{console.log("Authenticating and fetching merchant wallets...");const t=btoa(`${Od.apiKey}:${Od.apiSecret}`),e=yield fetch(`${Od.apiUrl}/api/merchants/dashboard`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,"x-api-key":Od.apiKey,"x-api-secret":Od.apiSecret}});if(e.ok){const t=yield e.json();if(console.log("Merchant dashboard data received:",t),t.merchant){const e={};return t.merchant.walletAddress&&(e.ethereum=t.merchant.walletAddress),t.merchant.solWalletAddress&&(e.solana=t.merchant.solWalletAddress),t.merchant.merchantWallets&&Object.assign(e,t.merchant.merchantWallets),Od.merchantWalletAddresses=e,console.log("Merchant wallet addresses retrieved:",e),e}}else console.error("Failed to fetch merchant dashboard:",e.status)}catch(t){console.error("Error fetching merchant wallets:",t)}return{}})),Ud=()=>__async(this,null,(function*(){return 0===Object.keys(Od.merchantWalletAddresses).length&&(yield Fd()),Od.merchantWalletAddresses})),Dd=()=>({"Content-Type":"application/json","x-api-key":Od.apiKey,"x-api-secret":Od.apiSecret,Authorization:Od.authToken?`Bearer ${Od.authToken}`:void 0}),jd=t=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",t),!t.amount)throw new Error("Payment amount is required");const n=yield Ud();console.log("Using merchant wallets:",n);const r=__spreadProps(__spreadValues({},t),{merchantWalletAddresses:__spreadValues(__spreadValues({},n),t.merchantWalletAddresses)});console.log("Enhanced payment data:",r);const i=yield fetch(`${Od.apiUrl}/api/payments/create`,{method:"POST",headers:Dd(),body:JSON.stringify(r)});if(console.log("Create payment response status:",i.status),!i.ok){let t;try{t=yield i.json()}catch(e){throw new Error(`Failed to create payment: ${i.status} ${i.statusText}`)}throw console.error("Error creating payment:",t),new Error(t.error||`Failed to create payment: ${i.status}`)}const s=yield i.json();return console.log("Payment created successfully:",s),s}catch(n){throw console.error("Create payment error:",n),n}})),Hd=t=>__async(this,null,(function*(){try{if(console.log("Processing payment with data:",t),!t.paymentId)throw new Error("Payment ID is required");if(!t.transactionHash)throw new Error("Transaction hash is required");const n=yield fetch(`${Od.apiUrl}/api/payments/process`,{method:"POST",headers:Dd(),body:JSON.stringify(t)});if(console.log("Process payment response status:",n.status),!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to process payment: ${n.status} ${n.statusText}`)}throw console.error("Error processing payment:",t),new Error(t.error||`Failed to process payment: ${n.status}`)}const r=yield n.json();return console.log("Process payment response data:",r),r}catch(n){throw console.error("Process payment error:",n),n}}));var Wd={exports:{}},Qd={},zd=e,Vd=Symbol.for("react.element"),Kd=Symbol.for("react.fragment"),Jd=Object.prototype.hasOwnProperty,qd=zd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Zd={key:!0,ref:!0,__self:!0,__source:!0};function Yd(t,e,n){var r,i={},s=null,o=null;for(r in void 0!==n&&(s=""+n),void 0!==e.key&&(s=""+e.key),void 0!==e.ref&&(o=e.ref),e)Jd.call(e,r)&&!Zd.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps)void 0===i[r]&&(i[r]=e[r]);return{$$typeof:Vd,type:t,key:s,ref:o,props:i,_owner:qd.current}}Qd.Fragment=Kd,Qd.jsx=Yd,Qd.jsxs=Yd,Wd.exports=Qd;var Xd=Wd.exports;const $d=e.createContext(),tp=e.createContext(),ep=()=>e.useContext(tp);var np,rp,ip=Object.defineProperty,sp=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,lp=(t,e,n)=>e in t?ip(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,cp=(t,e)=>{for(var n in e||(e={}))op.call(e,n)&&lp(t,n,e[n]);if(sp)for(var n of sp(e))ap.call(e,n)&&lp(t,n,e[n]);return t},up=(t,e)=>{var n={};for(var r in t)op.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&sp)for(var r of sp(t))e.indexOf(r)<0&&ap.call(t,r)&&(n[r]=t[r]);return n};(t=>{const e=class e{constructor(t,n,r,s){if(this.version=t,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version value out of range");if(s<-1||s>7)throw new RangeError("Mask value out of range");this.size=4*t+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();const a=this.addEccAndInterleave(r);if(this.drawCodewords(a),-1==s){let t=1e9;for(let e=0;e<8;e++){this.applyMask(e),this.drawFormatBits(e);const n=this.getPenaltyScore();n<t&&(s=e,t=n),this.applyMask(e)}}i(0<=s&&s<=7),this.mask=s,this.applyMask(s),this.drawFormatBits(s),this.isFunction=[]}static encodeText(n,r){const i=t.QrSegment.makeSegments(n);return e.encodeSegments(i,r)}static encodeBinary(n,r){const i=t.QrSegment.makeBytes(n);return e.encodeSegments([i],r)}static encodeSegments(t,r,s=1,a=40,l=-1,c=!0){if(!(e.MIN_VERSION<=s&&s<=a&&a<=e.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,h;for(u=s;;u++){const n=8*e.getNumDataCodewords(u,r),i=o.getTotalBits(t,u);if(i<=n){h=i;break}if(u>=a)throw new RangeError("Data too long")}for(const n of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])c&&h<=8*e.getNumDataCodewords(u,n)&&(r=n);let d=[];for(const e of t){n(e.mode.modeBits,4,d),n(e.numChars,e.mode.numCharCountBits(u),d);for(const t of e.getData())d.push(t)}i(d.length==h);const p=8*e.getNumDataCodewords(u,r);i(d.length<=p),n(0,Math.min(4,p-d.length),d),n(0,(8-d.length%8)%8,d),i(d.length%8==0);for(let e=236;d.length<p;e^=253)n(e,8,d);let f=[];for(;8*f.length<d.length;)f.push(0);return d.forEach(((t,e)=>f[e>>>3]|=t<<7-(7&e))),new e(u,r,f,l)}getModule(t,e){return 0<=t&&t<this.size&&0<=e&&e<this.size&&this.modules[e][t]}getModules(){return this.modules}drawFunctionPatterns(){for(let n=0;n<this.size;n++)this.setFunctionModule(6,n,n%2==0),this.setFunctionModule(n,6,n%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),e=t.length;for(let n=0;n<e;n++)for(let r=0;r<e;r++)0==n&&0==r||0==n&&r==e-1||n==e-1&&0==r||this.drawAlignmentPattern(t[n],t[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.errorCorrectionLevel.formatBits<<3|t;let n=e;for(let r=0;r<10;r++)n=n<<1^1335*(n>>>9);const s=21522^(e<<10|n);i(s>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,r(s,i));this.setFunctionModule(8,7,r(s,6)),this.setFunctionModule(8,8,r(s,7)),this.setFunctionModule(7,8,r(s,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,r(s,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,r(s,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,r(s,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let n=0;n<12;n++)t=t<<1^7973*(t>>>11);const e=this.version<<12|t;i(e>>>18==0);for(let n=0;n<18;n++){const t=r(e,n),i=this.size-11+n%3,s=Math.floor(n/3);this.setFunctionModule(i,s,t),this.setFunctionModule(s,i,t)}}drawFinderPattern(t,e){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){const i=Math.max(Math.abs(r),Math.abs(n)),s=t+r,o=e+n;0<=s&&s<this.size&&0<=o&&o<this.size&&this.setFunctionModule(s,o,2!=i&&4!=i)}}drawAlignmentPattern(t,e){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(t+r,e+n,1!=Math.max(Math.abs(r),Math.abs(n)))}setFunctionModule(t,e,n){this.modules[e][t]=n,this.isFunction[e][t]=!0}addEccAndInterleave(t){const n=this.version,r=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(n,r))throw new RangeError("Invalid argument");const s=e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],a=Math.floor(e.getNumRawDataModules(n)/8),l=s-a%s,c=Math.floor(a/s);let u=[];const h=e.reedSolomonComputeDivisor(o);for(let i=0,p=0;i<s;i++){let n=t.slice(p,p+c-o+(i<l?0:1));p+=n.length;const r=e.reedSolomonComputeRemainder(n,h);i<l&&n.push(0),u.push(n.concat(r))}let d=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-o||n>=l)&&d.push(t[e])}));return i(d.length==a),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let e=this.size-1;e>=1;e-=2){6==e&&(e=5);for(let i=0;i<this.size;i++)for(let s=0;s<2;s++){const o=e-s,a=!(e+1&2)?this.size-1-i:i;!this.isFunction[a][o]&&n<8*t.length&&(this.modules[a][o]=r(t[n>>>3],7-(7&n)),n++)}}i(n==8*t.length)}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let n=0;n<this.size;n++){let r;switch(t){case 0:r=(n+e)%2==0;break;case 1:r=e%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+e)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(e/2))%2==0;break;case 5:r=n*e%2+n*e%3==0;break;case 6:r=(n*e%2+n*e%3)%2==0;break;case 7:r=((n+e)%2+n*e%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[e][n]&&r&&(this.modules[e][n]=!this.modules[e][n])}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let n=!1,r=0,s=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[i][o]==n?(r++,5==r?t+=e.PENALTY_N1:r>5&&t++):(this.finderPenaltyAddHistory(r,s),n||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),n=this.modules[i][o],r=1);t+=this.finderPenaltyTerminateAndCount(n,r,s)*e.PENALTY_N3}for(let i=0;i<this.size;i++){let n=!1,r=0,s=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][i]==n?(r++,5==r?t+=e.PENALTY_N1:r>5&&t++):(this.finderPenaltyAddHistory(r,s),n||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),n=this.modules[o][i],r=1);t+=this.finderPenaltyTerminateAndCount(n,r,s)*e.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let n=0;n<this.size-1;n++){const r=this.modules[i][n];r==this.modules[i][n+1]&&r==this.modules[i+1][n]&&r==this.modules[i+1][n+1]&&(t+=e.PENALTY_N2)}let n=0;for(const e of this.modules)n=e.reduce(((t,e)=>t+(e?1:0)),n);const r=this.size*this.size,s=Math.ceil(Math.abs(20*n-10*r)/r)-1;return i(0<=s&&s<=9),t+=s*e.PENALTY_N4,i(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(1==this.version)return[];{const t=Math.floor(this.version/7)+2,e=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*t-2));let n=[6];for(let r=this.size-7;n.length<t;r-=e)n.splice(1,0,r);return n}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(t,n){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let n=[];for(let e=0;e<t-1;e++)n.push(0);n.push(1);let r=1;for(let i=0;i<t;i++){for(let t=0;t<n.length;t++)n[t]=e.reedSolomonMultiply(n[t],r),t+1<n.length&&(n[t]^=n[t+1]);r=e.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(t,n){let r=n.map((t=>0));for(const i of t){const t=i^r.shift();r.push(0),n.forEach(((n,i)=>r[i]^=e.reedSolomonMultiply(n,t)))}return r}static reedSolomonMultiply(t,e){if(t>>>8!=0||e>>>8!=0)throw new RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^285*(n>>>7),n^=(e>>>r&1)*t;return i(n>>>8==0),n}finderPenaltyCountPatterns(t){const e=t[1];i(e<=3*this.size);const n=e>0&&t[2]==e&&t[3]==3*e&&t[4]==e&&t[5]==e;return(n&&t[0]>=4*e&&t[6]>=e?1:0)+(n&&t[6]>=4*e&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,n){return t&&(this.finderPenaltyAddHistory(e,n),e=0),e+=this.size,this.finderPenaltyAddHistory(e,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(t,e){0==e[0]&&(t+=this.size),e.pop(),e.unshift(t)}};function n(t,e,n){if(e<0||e>31||t>>>e!=0)throw new RangeError("Value out of range");for(let r=e-1;r>=0;r--)n.push(t>>>r&1)}function r(t,e){return!!(t>>>e&1)}function i(t){if(!t)throw new Error("Assertion error")}e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=e;const s=class t{constructor(t,e,n){if(this.mode=t,this.numChars=e,this.bitData=n,e<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}static makeBytes(e){let r=[];for(const t of e)n(t,8,r);return new t(t.Mode.BYTE,e.length,r)}static makeNumeric(e){if(!t.isNumeric(e))throw new RangeError("String contains non-numeric characters");let r=[];for(let t=0;t<e.length;){const i=Math.min(e.length-t,3);n(parseInt(e.substring(t,t+i),10),3*i+1,r),t+=i}return new t(t.Mode.NUMERIC,e.length,r)}static makeAlphanumeric(e){if(!t.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let r,i=[];for(r=0;r+2<=e.length;r+=2){let s=45*t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r));s+=t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r+1)),n(s,11,i)}return r<e.length&&n(t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r)),6,i),new t(t.Mode.ALPHANUMERIC,e.length,i)}static makeSegments(e){return""==e?[]:t.isNumeric(e)?[t.makeNumeric(e)]:t.isAlphanumeric(e)?[t.makeAlphanumeric(e)]:[t.makeBytes(t.toUtf8ByteArray(e))]}static makeEci(e){let r=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)n(e,8,r);else if(e<16384)n(2,2,r),n(e,14,r);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");n(6,3,r),n(e,21,r)}return new t(t.Mode.ECI,0,r)}static isNumeric(e){return t.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return t.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(t,e){let n=0;for(const r of t){const t=r.mode.numCharCountBits(e);if(r.numChars>=1<<t)return 1/0;n+=4+t+r.bitData.length}return n}static toUtf8ByteArray(t){t=encodeURI(t);let e=[];for(let n=0;n<t.length;n++)"%"!=t.charAt(n)?e.push(t.charCodeAt(n)):(e.push(parseInt(t.substring(n+1,n+3),16)),n+=2);return e}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=s;t.QrSegment=s})(np||(np={})),(t=>{const e=class{constructor(t,e){this.ordinal=t,this.formatBits=e}};e.LOW=new e(0,1),e.MEDIUM=new e(1,0),e.QUARTILE=new e(2,3),e.HIGH=new e(3,2),t.Ecc=e})((rp=np||(np={})).QrCode||(rp.QrCode={})),(t=>{(t=>{const e=class{constructor(t,e){this.modeBits=t,this.numBitsCharCount=e}numCharCountBits(t){return this.numBitsCharCount[Math.floor((t+7)/17)]}};e.NUMERIC=new e(1,[10,12,14]),e.ALPHANUMERIC=new e(2,[9,11,13]),e.BYTE=new e(4,[8,16,16]),e.KANJI=new e(8,[8,10,12]),e.ECI=new e(7,[0,0,0]),t.Mode=e})(t.QrSegment||(t.QrSegment={}))})(np||(np={}));var hp=np,dp={L:hp.QrCode.Ecc.LOW,M:hp.QrCode.Ecc.MEDIUM,Q:hp.QrCode.Ecc.QUARTILE,H:hp.QrCode.Ecc.HIGH},pp=128,fp="L",gp="#FFFFFF",mp="#000000",yp=!1,_p=1;
|
12
12
|
/**
|
13
13
|
* @license qrcode.react
|
14
14
|
* Copyright (c) Paul O'Shannessy
|
15
15
|
* SPDX-License-Identifier: ISC
|
16
|
-
*/function wp(t,e=0){const n=[];return t.forEach((function(t,r){let i=null;t.forEach((function(s,o){if(!s&&null!==i)return n.push(`M${i+e} ${r+e}h${o-i}v1H${i+e}z`),void(i=null);if(o!==t.length-1)s&&null===i&&(i=o);else{if(!s)return;null===i?n.push(`M${o+e},${r+e} h1v1H${o+e}z`):n.push(`M${i+e},${r+e} h${o+1-i}v1H${i+e}z`)}}))})),n.join("")}function vp(t,e){return t.slice().map(((t,n)=>n<e.y||n>=e.y+e.h?t:t.map(((t,n)=>(n<e.x||n>=e.x+e.w)&&t))))}function bp({value:t,level:n,minVersion:r,includeMargin:i,marginSize:s,imageSettings:o,size:a,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...hp.QrSegment.makeSegments(e)),t)),[]);return hp.QrCode.encodeSegments(e,dp[n],r,void 0,void 0,l)}),[t,n,r,l]);const{cells:u,margin:h,numCells:d,calculatedImageSettings:p}=e.useMemo((()=>{let t=c.getModules();const e=function(t,e){return null!=e?Math.max(Math.floor(e),0):t?4:0}(i,s),n=t.length+2*e,r=function(t,e,n,r){if(null==r)return null;const i=t.length+2*n,s=Math.floor(.1*e),o=i/e,a=(r.width||s)*o,l=(r.height||s)*o,c=null==r.x?t.length/2-a/2:r.x*o,u=null==r.y?t.length/2-l/2:r.y*o,h=null==r.opacity?1:r.opacity;let d=null;if(r.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(a+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:a,excavation:d,opacity:h,crossOrigin:r.crossOrigin}}(t,a,e,o);return{cells:t,margin:e,numCells:n,calculatedImageSettings:r}}),[c,a,o,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var Ap=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:o=fp,bgColor:a=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,marginSize:d,imageSettings:p}=r,f=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=up(f,["style"]),_=null==p?void 0:p.src,y=e.useRef(null),w=e.useRef(null),v=e.useCallback((t=>{y.current=t,"function"==typeof n?n(t):n&&(n.current=t)}),[n]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=bp({value:i,level:o,minVersion:u,boostLevel:h,includeMargin:c,marginSize:d,imageSettings:p,size:s});e.useEffect((()=>{if(null!=y.current){const t=y.current,e=t.getContext("2d");if(!e)return;let n=x;const r=w.current,i=null!=S&&null!==r&&r.complete&&0!==r.naturalHeight&&0!==r.naturalWidth;i&&null!=S.excavation&&(n=vp(x,S.excavation));const o=window.devicePixelRatio||1;t.height=t.width=s*o;const c=s/k*o;e.scale(c,c),e.fillStyle=a,e.fillRect(0,0,k,k),e.fillStyle=l,Ap?e.fill(new Path2D(wp(n,E))):x.forEach((function(t,n){t.forEach((function(t,r){t&&e.fillRect(r+E,n+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(r,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[_]);const N=cp({height:s,width:s},g);let C=null;return null!=_&&(C=e.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{A(!0)},ref:w,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",cp({style:N,height:s,width:s,ref:v,role:"img"},m)),C)})).displayName="QRCodeCanvas";var Ep=e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:o=fp,bgColor:a=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,title:d,marginSize:p,imageSettings:f}=r,g=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:_,numCells:y,calculatedImageSettings:w}=bp({value:i,level:o,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let v=_,b=null;null!=f&&null!=w&&(null!=w.excavation&&(v=vp(_,w.excavation)),b=e.createElement("image",{href:f.src,height:w.h,width:w.w,x:w.x+m,y:w.y+m,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const A=wp(v,m);return e.createElement("svg",cp({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:n,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:a,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));Ep.displayName="QRCodeSVG";const xp=({walletAddress:t,amount:n,currency:r,network:i,theme:s="light",size:o=200})=>{const[a,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"algorand":e=h(t,n,r);break;case"tron":e="TRX"===r?`tronlink://transfer?to=${t}&amount=${n}`:t;break;case"bsc":if("BNB"===r)e=`ethereum:${t}@56?value=${g(n)}`;else{const i=p(r,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${f(n,r)}@56`:t}break;default:if("ETH"===r)e=`ethereum:${t}@1?value=${g(n)}`;else{const i=p(r,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${f(n,r)}`:t}}l(e),u(null),console.log("=== QR CODE DEBUG ==="),console.log("Network:",i),console.log("Currency:",r),console.log("Amount:",n),console.log("Wallet Address:",t),console.log("Generated QR Data:",e),console.log("QR Data Length:",e.length),console.log("=== END QR DEBUG ===")}catch(e){console.error("Error generating QR code:",e),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[t,n,r,i]);const h=(t,e,n)=>{try{if(!t||t.includes("No wallet address"))return t;const r=parseFloat(e);if("ALGO"===n){return`algorand://${t}?amount=${Math.floor(1e6*r)}`}{const e=d(n,"algorand");if(e&&e.assetId){return`algorand://${t}?amount=${Math.floor(r*Math.pow(10,e.decimals))}&asset=${e.assetId}`}return console.warn(`Token config not found for ${n} on Algorand`),t}}catch(r){return console.error("Error generating Algorand QR:",r),t}},d=(t,e)=>{var n;return null==(n={algorand:{USDC:{assetId:31566704,decimals:6},USDT:{assetId:312769,decimals:6},ALGO:{decimals:6,isNative:!0}}}[e])?void 0:n[t.toUpperCase()]},p=(t,e)=>{var n;return(null==(n={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:n[t])||""},f=(t,e)=>{const n="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,n)).toString()},g=t=>Math.floor(1e18*parseFloat(t)).toString(),m=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Xd.jsxs("div",{className:"flex flex-col items-center",children:[c?Xd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsx("p",{className:"font-medium",children:c})]}):Xd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:a&&Xd.jsx(Ep,{value:a,size:o,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Xd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Xd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",r]}),Xd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",m(i)," wallet app"]})]}),Xd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Xd.jsxs("div",{className:"flex justify-between items-center",children:[Xd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Xd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[n," ",r]})]}),Xd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Xd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Xd.jsx("span",{className:"text-xs font-medium text-gray-700",children:m(i)})]})]}),Xd.jsx("div",{className:"w-full",children:Xd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Xd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment Instructions"]}),Xd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Xd.jsxs("li",{children:["1. Open your crypto wallet app (",(_=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[_]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Xd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Xd.jsxs("li",{children:["3. Send exactly ",Xd.jsxs("strong",{children:[n," ",r]})," on ",m(i)," network"]}),Xd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Xd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Xd.jsxs("p",{className:"text-xs text-yellow-800",children:[Xd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",m(i),") and using the exact amount shown above."]})})]})})]});var _},kp=({status:t,message:n,theme:r="light",payment:i=null,transactionHash:s=null,selectedPaymentMethod:o=null,merchantName:a="Merchant",onClose:l=null,processingStartTime:c=null,paymentNetwork:u=null,pendingBackendConfirmation:h=!1})=>{const[d,p]=e.useState(!1),[f,g]=e.useState(0),[m,_]=e.useState(!1),[y,w]=e.useState(1);e.useEffect((()=>{let e;return"processing"===t&&c&&(e=setInterval((()=>{const t=Math.floor((Date.now()-c)/1e3);g(t),t>=5&&1===y&&w(2),t>=15&&2===y&&w(3),t>=30&&!m&&_(!0)}),1e3)),()=>clearInterval(e)}),[t,c,y,m]);const v=()=>__async(this,null,(function*(){if(s)try{yield navigator.clipboard.writeText(s),p(!0),setTimeout((()=>p(!1)),2e3)}catch(t){console.error("Failed to copy transaction hash:",t)}})),b=()=>{console.log("Payment success screen close button clicked"),l&&l()},A=()=>{switch(t){case"processing":return Xd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Xd.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Xd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}},E=()=>{switch(t){case"processing":return"dark"===r?"text-blue-300":"text-blue-600";case"success":return"dark"===r?"text-green-300":"text-green-600";case"error":return"dark"===r?"text-red-300":"text-red-600";default:return"dark"===r?"text-gray-300":"text-gray-600"}};return"success"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-6",children:A()}),Xd.jsx("h3",{className:"text-2xl font-bold mb-3 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Successful!"}),i&&o&&Xd.jsxs("p",{className:"text-center max-w-[235px] mb-6 "+("dark"===r?"text-gray-300":"text-gray-600"),children:["Your payment of ",Xd.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[i.totalAmount||i.amount," ",o.currency]})," has been completed."]}),h&&Xd.jsxs("div",{className:"flex items-center justify-center mb-4 text-xs text-gray-500 bg-gray-50 rounded-full px-3 py-1",children:[Xd.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-3 w-3 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Xd.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Verifying on blockchain"]}),s&&Xd.jsxs("div",{className:"w-full mb-6",children:[Xd.jsx("p",{className:"text-sm font-medium mb-2 "+("dark"===r?"text-gray-300":"text-gray-700"),children:"Transaction Hash:"}),Xd.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors "+("dark"===r?"bg-gray-700 border-gray-600 hover:bg-gray-600":"bg-gray-50 border-gray-200 hover:bg-gray-100"),onClick:v,children:[Xd.jsx("span",{className:"font-mono text-sm "+("dark"===r?"text-gray-300":"text-gray-700"),children:(S=s,S?S.length<=16?S:`${S.slice(0,8)}...${S.slice(-8)}`:"")}),Xd.jsxs("div",{className:"flex items-center",children:[d?Xd.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 "+("dark"===r?"text-gray-400":"text-gray-500"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]})]}),Xd.jsx("div",{className:"w-full p-4 rounded-lg border mb-6 "+("dark"===r?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:Xd.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Merchant ID:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:a})]}),Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Network:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:o?(k=o.network,{ethereum:"Ethereum",bsc:"BSC",tron:"TRON",algorand:"Algorand"}[k]||k):"N/A"})]}),Xd.jsxs("div",{className:"col-span-2",children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Recipient:"}),Xd.jsx("p",{className:"text-sm font-mono "+("dark"===r?"text-gray-300":"text-gray-700"),children:(null==i?void 0:i.recipientWallet)?(x=i.recipientWallet,x?x.length<=16?x:`${x.slice(0,6)}...${x.slice(-4)}`:"N/A"):"N/A"})]})]})}),l&&Xd.jsx("button",{onClick:b,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-medium rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{borderRadius:"1.5rem"},children:"Close"})]}):"error"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Failed"}),Xd.jsx("p",{className:`text-center ${E()}`,children:n}),Xd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Xd.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Please try again or contact support if the problem persists."})})]}):Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful!";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Xd.jsx("p",{className:`text-center ${E()}`,children:n})]});var x,k,S},Sp=({size:t=24})=>Xd.jsxs("svg",{width:t,height:t,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsxs("g",{clipPath:"url(#clip0_2786_457)",children:[Xd.jsx("path",{d:"M15.9979 5L15.845 5.52398V20.7287L15.9979 20.8826L22.9958 16.7107L15.9979 5Z",fill:"#343434"}),Xd.jsx("path",{d:"M15.9979 5L9 16.7107L15.9979 20.8826V13.5027V5Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 22.2186L15.9117 22.3245V27.7408L15.9979 27.9945L23 18.0488L15.9979 22.2186Z",fill:"#3C3C3B"}),Xd.jsx("path",{d:"M15.9979 27.9945V22.2186L9 18.0488L15.9979 27.9945Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 20.8818L22.9957 16.7099L15.9979 13.502V20.8818Z",fill:"#141414"}),Xd.jsx("path",{d:"M9.00006 16.7099L15.9979 20.8818V13.502L9.00006 16.7099Z",fill:"#393939"})]}),Xd.jsx("defs",{children:Xd.jsx("clipPath",{id:"clip0_2786_457",children:Xd.jsx("rect",{width:"14",height:"23",fill:"white",transform:"translate(9 5)"})})})]}),Np=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.42 8.68534C8.48853 8.61041 8.57583 8.55514 8.67287 8.52525C8.76992 8.49536 8.87319 8.49194 8.972 8.51534L20.875 11.4293C20.947 11.445 21.0146 11.4765 21.073 11.5213L23.495 13.2883C23.6127 13.3751 23.6923 13.5039 23.7173 13.6479C23.7422 13.792 23.7106 13.9401 23.629 14.0613L15.297 26.2523C15.2385 26.3388 15.1571 26.4074 15.0619 26.4503C14.9667 26.4932 14.8614 26.5088 14.7579 26.4953C14.6543 26.4818 14.5566 26.4398 14.4755 26.3739C14.3945 26.308 14.3334 26.2209 14.299 26.1223L8.306 9.25234C8.27276 9.15648 8.2657 9.05348 8.28557 8.95398C8.30543 8.85448 8.3515 8.76209 8.419 8.68634M10.383 11.7293L14.543 23.4413L15.227 17.3723L10.383 11.7293ZM16.341 17.5673L15.646 23.7423L21.529 15.1323L16.341 17.5673ZM22.06 13.6373L18.269 15.4173L20.809 12.7263L22.06 13.6373ZM19.664 12.2943L10.411 10.0303L15.836 16.3483L19.664 12.2943Z",fill:"black"})}),Cp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M17.2512 9.5H19.7036L20.7785 13.4753H23.3083L21.5804 16.4753L24 25.4973H21.4916L19.8625 19.446L16.3592 25.4987H13.5597L18.9725 16.1313L18.1018 12.8793L10.8022 25.5H8L17.2512 9.5Z",fill:"black"})}),Pp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.52513 16.0195H20.7032C20.843 16.0195 20.9713 16.0794 21.0762 16.1873L22.8479 18.0574C23.1742 18.4051 22.9411 18.9925 22.4749 18.9925H11.2968C11.157 18.9925 11.0287 18.9326 10.9238 18.8247L9.15214 16.9545C8.82577 16.6069 9.05889 16.0195 9.52513 16.0195ZM9.15214 13.538L10.9238 11.6678C11.0171 11.5599 11.157 11.5 11.2968 11.5H22.4632C22.9295 11.5 23.1626 12.0874 22.8362 12.4351L21.0762 14.3052C20.9829 14.4131 20.843 14.473 20.7032 14.473H9.52513C9.05889 14.473 8.82577 13.8856 9.15214 13.538ZM22.8362 21.462L21.0645 23.3322C20.9596 23.4401 20.8314 23.5 20.6915 23.5H9.52513C9.05889 23.5 8.82577 22.9126 9.15214 22.5649L10.9238 20.6948C11.0171 20.5869 11.157 20.527 11.2968 20.527H22.4632C22.9295 20.527 23.1626 21.1144 22.8362 21.462Z",fill:"black"})}),Tp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M19.0827 18.7809L20.8947 20.5933L15.9927 25.5L11.0907 20.594L12.902 18.7809L15.9927 21.8905L19.0827 18.7809ZM22.174 15.6873L24 17.4997L22.19 19.3121L20.3787 17.4997L22.174 15.6873ZM15.9927 15.6873L17.8033 17.4837L15.992 19.2967L14.1813 17.4997L15.9927 15.6873ZM9.81067 15.6873L11.6067 17.4997L9.812 19.2961L8 17.4997L9.81067 15.6873ZM15.9933 9.5L20.8933 14.39L19.082 16.2018L15.9933 13.1088L12.9027 16.2184L11.0913 14.406L15.9933 9.5Z",fill:"black"})}),Mp=({size:t=32})=>Xd.jsx("svg",{width:t-4,height:t-4,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.36266 4.256C8.38876 4.0477 8.48986 3.85605 8.64705 3.7169C8.80423 3.57775 9.00673 3.50064 9.21666 3.5H17.0847C17.9472 3.55674 18.7895 3.78654 19.5613 4.1757C20.3331 4.56486 21.0187 5.10541 21.5772 5.76515C22.1357 6.42489 22.5557 7.19031 22.8121 8.0158C23.0685 8.84129 23.1561 9.70994 23.0697 10.57C22.6847 15.659 18.6737 17.5 16.5807 17.5H13.8367L12.6677 23.786C12.6333 23.987 12.5285 24.1693 12.372 24.3001C12.2156 24.431 12.0176 24.5018 11.8137 24.5H6.61966C6.49561 24.4979 6.3734 24.4696 6.26099 24.4171C6.14859 24.3646 6.04851 24.289 5.96728 24.1952C5.88604 24.1014 5.82548 23.9916 5.78954 23.8728C5.75359 23.7541 5.74307 23.6291 5.75866 23.506L7.05366 14H5.76566C5.65113 13.9998 5.53775 13.9771 5.43205 13.933C5.32635 13.8888 5.23041 13.8243 5.14975 13.743C5.06909 13.6616 5.00529 13.5652 4.96203 13.4591C4.91877 13.3531 4.89689 13.2395 4.89766 13.125C4.89766 12.642 5.28266 12.25 5.76566 12.25H7.29166L7.76066 8.75H5.76566C5.65113 8.74985 5.53775 8.72706 5.43205 8.68295C5.32635 8.63884 5.23041 8.57427 5.14975 8.49296C5.06909 8.41164 5.00529 8.31519 4.96203 8.20914C4.91877 8.10309 4.89689 7.98953 4.89766 7.875C4.89612 7.76084 4.91723 7.64751 4.95978 7.54157C5.00233 7.43563 5.06547 7.33918 5.14554 7.2578C5.22562 7.17643 5.32104 7.11174 5.42628 7.06749C5.53152 7.02324 5.6445 7.0003 5.75866 7H7.99166L8.36266 4.256ZM9.50366 8.75L9.02766 12.25H15.2787C15.51 12.2579 15.7404 12.218 15.9555 12.1326C16.1707 12.0473 16.3659 11.9185 16.5289 11.7541C16.6919 11.5898 16.8191 11.3936 16.9027 11.1778C16.9863 10.962 17.0244 10.7312 17.0147 10.5C17.0244 10.2688 16.9863 10.038 16.9027 9.82219C16.8191 9.60638 16.6919 9.41017 16.5289 9.24586C16.3659 9.08155 16.1707 8.95269 15.9555 8.86736C15.7404 8.78203 15.51 8.74208 15.2787 8.75H9.50366ZM8.79666 14H15.2787C15.738 14.0048 16.1936 13.9173 16.6184 13.7426C17.0433 13.568 17.4287 13.3098 17.7519 12.9833C18.0751 12.6569 18.3294 12.2689 18.4998 11.8423C18.6701 11.4157 18.7531 10.9593 18.7437 10.5C18.7437 8.54 17.2457 7 15.2787 7H9.74166L9.97266 5.25H16.9727C17.6045 5.28987 18.2218 5.45727 18.7872 5.74209C19.3527 6.02692 19.8546 6.42329 20.2627 6.90731C20.6709 7.39132 20.9768 7.95297 21.1621 8.55839C21.3473 9.16381 21.4081 9.80047 21.3407 10.43C21.0397 14.441 17.9457 15.75 16.5807 15.75H13.1157C12.9126 15.7514 12.7163 15.8234 12.5605 15.9537C12.4047 16.084 12.299 16.2644 12.2617 16.464L11.0997 22.75H7.61366L8.79666 14Z",fill:"#3B6FEF"})}),Rp=({size:t=32})=>Xd.jsxs("svg",{width:t-5,height:t-5,viewBox:"0 0 27 27",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsx("path",{d:"M13.5 27C20.9558 27 27 20.9558 27 13.5C27 6.04416 20.9558 0 13.5 0C6.04416 0 0 6.04416 0 13.5C0 20.9558 6.04416 27 13.5 27Z",fill:"#398260"}),Xd.jsx("path",{d:"M15.6963 5.83207C17.1627 6.86735 18.6899 6.98294 20.6432 7.34238C22.4201 7.67229 22.7973 9.48719 21.9856 11.7974C21.9365 11.7143 21.8859 11.6322 21.8337 11.551L21.9856 11.7974C23.2234 13.9 23.2141 16.1773 20.5352 17.3425C15.7655 19.4181 15.4811 23.5061 10.973 21.3056C10.3338 20.991 9.75978 20.5585 9.28125 20.0307L9.10575 19.8307L8.9429 19.8029C5.91722 19.2671 3.93103 17.6269 5.76872 13.4419C7.39462 9.74369 5.94253 6.1046 10.9291 6.2666H10.9308C12.3044 4.97819 13.8881 4.55885 15.6954 5.83207H15.6963ZM11.0497 9.57157C8.95894 11.0726 8.27044 13.8679 9.66262 16.0389C9.99149 16.5546 10.4192 17 10.921 17.3496C11.4228 17.6992 11.9889 17.946 12.5866 18.0758C13.1842 18.2056 13.8017 18.2159 14.4033 18.1059C15.0049 17.996 15.5789 17.7681 16.092 17.4353C18.2503 16.0347 18.5456 13.3178 17.4791 10.9663C16.3865 8.55569 13.3869 7.89335 11.0497 9.57157Z",fill:"white"})]}),Bp=({onSelect:t,selected:n,theme:r="light",supportedNetworks:i=[]})=>{var s;const[o,a]=e.useState(md.ETHEREUM),[l,c]=e.useState(null),[u,h]=e.useState({}),[d,p]=e.useState(!1),f=[{id:md.ETHEREUM,name:"Ethereum",icon:Sp},{id:md.TRON,name:"Tron",icon:Np},{id:md.ALGORAND,name:"Algorand",icon:Cp},{id:"solana",name:"Solana",icon:Pp},{id:md.BSC,name:"Binance Smart Chain",icon:Tp}],[g,m]=e.useState(!1),_=e.useRef(null);e.useEffect((()=>{function t(t){_.current&&!_.current.contains(t.target)&&m(!1)}return g?document.addEventListener("mousedown",t):document.removeEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)}),[g]),e.useEffect((()=>{h(Ad())}),[]);const y=(t=>{const e=[];switch(t){case md.ETHEREUM:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:Mp,network:md.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:Rp,network:md.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:md.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"/eth.png",network:md.ETHEREUM});break;case md.BSC:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:md.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"/bnb.png",network:md.BSC});break;case md.TRON:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:md.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:md.TRON});break;case md.ALGORAND:e.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:md.ALGORAND})}return e})(o),w=d?y:y.slice(0,4);function v(t){switch(t){case md.ETHEREUM:case md.BSC:return gd.METAMASK;case md.TRON:return gd.TRONLINK;case md.ALGORAND:return gd.LUTE;default:return gd.METAMASK}}return Xd.jsxs("div",{className:"",children:[Xd.jsxs("div",{className:"mb-6",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===r?"text-white":"text-gray-700"),children:"Blockchain Network"}),Xd.jsxs("div",{className:"relative",ref:_,children:[Xd.jsxs("button",{type:"button",className:"w-full flex items-center justify-between py-4 bg-white rounded-2xl shadow border border-gray-200 text-gray-900 text-base font-normal focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50 transition",onClick:()=>m((t=>!t)),style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-3",children:[(()=>{const t=f.find((t=>t.id===o));return Xd.jsx(t.icon,{size:32})})(),Xd.jsx("span",{className:"text-base font-normal",children:null==(s=f.find((t=>t.id===o)))?void 0:s.name})]}),Xd.jsx("svg",{className:"w-5 h-5 ml-2 transition-transform "+(g?"rotate-180":""),fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),g&&Xd.jsx("div",{className:"absolute left-0 mt-2 px-2 w-full bg-white rounded-2xl shadow-lg border border-gray-100 z-20",style:{minWidth:"100%"},children:f.filter((t=>0===i.length||i.includes(t.id))).map((t=>Xd.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 mt-1 mb-1 px-2 py-2 text-gray-900 text-base font-normal rounded-2xl transition hover:bg-gray-100 "+(o===t.id?"bg-gray-50":""),onClick:()=>{var e;m(!1),e=t.id,a(e),p(!1),c(null)},style:{minHeight:"48px"},children:[Xd.jsx(t.icon,{size:32}),Xd.jsx("span",{children:t.name})]},t.id)))})]})]}),Xd.jsxs("div",{className:"mb-4",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===r?"text-white":"text-gray-700"),children:"Select Stablecoin"}),Xd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:w.map((t=>{const e=(null==l?void 0:l.currency)===t.id&&(null==l?void 0:l.network)===o;return Xd.jsxs("button",{onClick:()=>(t=>{var e;const n={currency:t.id,network:o,tokenConfig:null==(e=yd[t.id])?void 0:e[o],method:t};c(n)})(t),className:`group flex items-center justify-between w-full px-2 py-2 rounded-2xl border text-left transition-all duration-200 font-medium text-base\n ${e?"bg-[#E9DDFC] border-transparent shadow-none":"bg-white border-gray-200 hover:bg-[#F6F2FF] hover:border-[#E9DDFC]"}\n `,style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-x-2",children:["function"==typeof t.logo?Xd.jsx(t.logo,{size:24}):Xd.jsx("img",{src:t.logo,alt:t.name,className:"h-4 w-4"}),Xd.jsxs("span",{className:"font-medium text-sm text-gray-900",children:[t.description," (",t.name,")"]})]}),e&&Xd.jsx("span",{className:"ml-2 flex items-center justify-center w-6 h-6 rounded-full bg-[#7042D2]",children:Xd.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M4 8.5L7 11.5L12 6.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},`${t.id}-${t.network}`)}))}),y.length>4&&Xd.jsx("button",{onClick:()=>p(!d),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===r?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:d?"Show Less":`Show More (${y.length-4} more)`})]}),Xd.jsx("div",{className:"p-3 rounded-lg text-sm mb-6 "+("dark"===r?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(u[v(o)]?"bg-green-500":"bg-red-500")}),Xd.jsx("span",{className:"text-xs",children:function(t){const e=v(t),n=u[e],r={[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"};return n?`${r[e]} detected - Ready to pay`:`${r[e]} required - Please install to continue`}(o)})]})}),Xd.jsx("button",{onClick:()=>{l&&t(l)},disabled:!l,className:"w-full py-3 px-4 font-medium rounded-2xl text-lg shadow-md transition-colors "+(l?"bg-[#7042D2] text-white hover:bg-[#5b34b1]":"bg-gray-300 text-gray-500 cursor-not-allowed"),style:{borderRadius:"1.5rem"},children:"Proceed"})]})},Ip=({isOpen:t,onClose:n,payment:r,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:o,onPayment:a,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:_={},supportedWallets:y=[],step:w="select-currency",merchantWalletAddresses:v={},debug:b=!1,processingStartTime:A=null,pendingBackendConfirmation:E=!1,paymentNetwork:x=null})=>{const[k,S]=e.useState("wallet"),N=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t),C=t=>({[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"}[t]||t),P=t=>({[gd.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[gd.TRONLINK]:"https://www.tronlink.org/images/logo.png",[gd.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[gd.LUTE]:"https://lute.app/logo.png"}[t]||"");return t?Xd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:Xd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Xd.jsxs("div",{className:"coinley-modal relative py-6 px-2 w-full max-w-md mx-auto shadow-xl bg-gray-100 rounded-3xl",children:[Xd.jsxs("div",{className:"bg-white flex justify-between items-center mb-6 mr-3 ml-3 py-4 px-2 rounded-full",children:[Xd.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Xd.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAbCAYAAABm409WAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMFSURBVHgBpVZBVtswEJXk7JsjmAM0hF13dWDTHeEEhF13MScgOQHmBIQT1Oy6KXFPACEHIDdouux7WNM/kuxIdvJeXpj3iOSR9P9oRjODFHtIevp6y2P21LsO9MlzLFQ0x3SKtdm2s0rsJ0PGS08XaXg6usFvjL+vuw7uS+BE3sDqLs/cOLJ6+rvrRMf/sFdWQ6F1nhUnqw2uXAmiGLMurObbzEQUJYLqHasGDvZ1xkK/P4Y3kGqCn1uAvKWny5taT3rh7bLuIEpqjdYv1fQ6WY75PDYAK4pDAtIz72OC4N47gHyjpr4z5thp1rhtYSyHUaQoMzclWmVFLw8IzEYpC081YpJAL2XXEcVuT16BW6stKYwd8KQd5PL9gtkbJCPopw547YjsqMupid0GHDpxXcWwRYAFy05U+xVgY+eGK0HyzhkyBfjAAEWd+9pyKS7gmll9lIMCv6XGb+ZqeBGSHo3flRrh+9IQz4+PxA5JB4tnQOFseRW8PibA9f848C0iJ9nTZ3ZB19zsAIm+HH3/B6BvO9YTrMts3v8pDhSVPR1n8OURfP4g2EVN0UiyD4hsKtJkmQjlnqAu80NdExDY1OaAynNoEm8dAceT+9XLxYHS8Upu3L4PdLYkHEyg8IZ/CFty28K5oP3ycQgB6d9tYFEIrpj8tlX0jKf8VpXpbcINKT17HW5bq2LABawCWKHUXgapz6LLEzNGUcwxwZkE866b99mQKm9aBL64zM7CG6E2cfngWBEtkNVDZO8MJeSciTl7bbeT3Fozv7UGtYgDDvCJaN/zwTQiEyv5yVvh12faqMknQWx96veSRrEzIN2G9S84PAHw2JLRwpG6/JCXVXzsPibhXmJJGh1N9ENwBBuucTGKjU5LV2WrkQ1C+3RiSHSJkq9HHKdmR8vM02RgLsXz3sBksoo84rKwROUmN5TXPoUp+blrOOtOY4GtOhEt4TYpzY2qcszE6dmysIkYxKXCMvv2+7eFXFxIPAT6usvtSNS9CUw/pju/Uzkrba+uAr9F/gPbu3s2LSnvkAAAAABJRU5ErkJggg==",className:"w-auto h-auto",alt:"Coinley Logo"}),Xd.jsx("span",{className:"text-lg font-semibold text-gray-800",children:"Payment Details"})]}),"success"!==w&&"processing"!==w&&Xd.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r&&"success"!==w&&Xd.jsx("div",{className:"mb-6",children:Xd.jsxs("div",{className:"text-center",children:[Xd.jsx("div",{className:"text-sm text-gray-600",children:"Total amount"}),Xd.jsxs("div",{className:"coinley-amount-display text-2xl md:text-4xl lg:text-6xl font-bold text-[#7042D2] mt-2 leading-tight tracking-tight",children:["$",(T=r.totalAmount||r.amount,parseFloat(T).toFixed(2))]}),Xd.jsx("div",{className:"text-sm text-gray-600 mt-4",children:"Payment to:"}),Xd.jsxs("div",{className:"coinley-merchant-name text-base font-semibold mt-1 flex gap-2 items-center justify-center",children:[Xd.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),h]})]})}),"select-currency"===w&&Xd.jsx("div",{className:"pb-6 pt-6 px-6 bg-white rounded-t-2xl blockchain-network",children:Xd.jsx(Bp,{onSelect:o,selected:s,theme:u,supportedNetworks:m})}),"confirm"===w&&s&&r&&Xd.jsxs("div",{children:[Xd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Xd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Xd.jsxs("div",{className:"space-y-2",children:[Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Currency:"}),Xd.jsx("span",{className:"font-medium",children:s.currency})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Network:"}),Xd.jsx("span",{className:"font-medium",children:N(s.network)})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Fee:"}),Xd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Xd.jsx("div",{className:"mb-4",children:Xd.jsxs("div",{className:"flex border-b border-gray-200",children:[Xd.jsx("button",{onClick:()=>S("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Xd.jsx("button",{onClick:()=>S("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Xd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"bg-purple-600 rounded-full p-2 mr-3",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Xd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===k?Xd.jsx("div",{className:"mb-4",children:Xd.jsx(xp,{walletAddress:(()=>{if(!s)return"No network selected";const t=v[s.network];return t||((null==r?void 0:r.recipientWallet)?r.recipientWallet:"No wallet address configured for this network")})(),amount:r.totalAmount||r.amount,currency:s.currency,network:s.network,theme:u})}):Xd.jsxs("div",{className:"space-y-3 mb-4",children:[0===y.length?Xd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",N(s.network)," network"]})]})]})}):y.map((t=>Xd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("img",{src:P(t),alt:C(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:C(t)}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",C(t)]})]})]}),(null==p?void 0:p.walletType)===t?Xd.jsxs("div",{className:"flex items-center space-x-2",children:[Xd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Xd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Xd.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",t),f(t)},className:"coinley-button-primary py-2 px-4 font-medium rounded-md text-sm",children:"Connect"})]})},t))),Xd.jsx("div",{className:"space-y-2",children:Object.entries(_).filter((([t,e])=>!e)).map((([t])=>Xd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("span",{className:"text-sm text-gray-600",children:[C(t)," not detected"]}),Xd.jsx("a",{href:vd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-purple-600 hover:underline",children:"Install"})]})},t)))})]}),c&&Xd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Xd.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[Xd.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-purple-600 font-medium rounded-md",children:"Back"}),Xd.jsx("button",{type:"button",onClick:()=>a("qrcode"===k),className:"coinley-button-primary w-full py-2 px-4 font-medium rounded-md",disabled:!g&&"wallet"===k&&!p,children:"qrcode"===k?"I have sent the payment":"Pay Now"})]})]}),"processing"===w&&Xd.jsx(kp,{status:"processing",theme:u,message:"Processing your payment...",processingStartTime:A,paymentNetwork:x||(null==s?void 0:s.network),transactionHash:d}),"success"===w&&Xd.jsx(kp,{status:"success",theme:u,message:"Payment successful!",payment:r,transactionHash:d,selectedPaymentMethod:s,merchantName:h,onClose:()=>{console.log("Success screen close button clicked"),n&&n()},pendingBackendConfirmation:E}),"error"===w&&Xd.jsxs("div",{children:[Xd.jsx(kp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Xd.jsx("button",{type:"button",onClick:l,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]}),"success"!==w&&Xd.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-[12px] ",children:[Xd.jsxs("p",{children:["Powered by ",Xd.jsx("span",{className:"text-purple-600",children:"Coinley"})," - Secure Cryptocurrency Payments"]}),Xd.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Xd.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})}):null;var T},Gp=e.forwardRef((({apiKey:t,apiSecret:n,apiUrl:r,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:o={},onSuccess:a,onError:l,onClose:c,theme:u,autoOpen:h=!1,debug:d=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:g=md.ETHEREUM,preferredWallet:m=gd.METAMASK,confirmations:_=1,fastMode:y=!0},w)=>{const v=ep(),{theme:b}=e.useContext($d),[A,E]=e.useState(h),[x,k]=e.useState(null),[S,N]=e.useState("idle"),[C,P]=e.useState(null),[T,M]=e.useState(null),[R,B]=e.useState(null),[I,G]=e.useState(null),[O,L]=e.useState({}),[F,U]=e.useState("select-currency"),[D,j]=e.useState({}),[H,W]=e.useState(null),[Q,z]=e.useState(null),V=e.useRef(null),[K,J]=e.useState(!1),q=t||(null==v?void 0:v.apiKey),Z=n||(null==v?void 0:v.apiSecret);r||null==v||v.apiUrl;const Y=u||b,X=d||(null==v?void 0:v.debug),$=f.length>0?f:[md.ETHEREUM,md.BSC,md.TRON,md.ALGORAND],tt=(t,e)=>{X&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{q&&Z&&(()=>{__async(this,null,(function*(){try{tt("Fetching merchant wallet addresses from backend...");const t=yield Ud();j(t),tt("Merchant wallets fetched successfully:",t)}catch(t){console.error("Failed to fetch merchant wallets:",t),j(o)}}))})()}),[q,Z,o]),e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield Ed(3,1e3);L(t),tt("Available wallets detected:",t)})))()}}),[X]),e.useEffect((()=>()=>{V.current&&clearTimeout(V.current),Q&&clearInterval(Q)}),[Q]),e.useEffect((()=>{if(R&&K&&"loading"===S){const t=setInterval((()=>__async(this,null,(function*(){try{tt("Checking payment status with backend...");"success"===(yield Hd({paymentId:x.id,transactionHash:R,network:C.network,currency:C.currency,senderAddress:null==I?void 0:I.address,confirmations:_,check:!0})).status&&(tt("Payment confirmed by backend!"),clearInterval(t),z(null),J(!1),N("success"))}catch(e){tt("Error checking payment status:",e)}}))),1e4);return z(t),()=>{clearInterval(t)}}}),[R,K,S,x,C,I,_]);const et=()=>__async(this,null,(function*(){if(x&&C&&R)try{tt("Processing payment with backend...");const t=yield Hd({paymentId:x.id,transactionHash:R,network:C.network,currency:C.currency,senderAddress:null==I?void 0:I.address,confirmations:_});tt("Payment processed successfully:",t),J(!1),a&&(tt("Calling onSuccess callback..."),a(x.id,R,{network:C.network,currency:C.currency,amount:x.totalAmount||x.amount}))}catch(t){tt("Payment processing initial attempt failed, will retry in background:",t),J(!0)}}));e.useImperativeHandle(w,(()=>({open:t=>{nt(t)},close:()=>{rt()},getPayment:()=>x,getWalletConnection:()=>I,debugWallets:()=>(()=>{var t;if(console.log("=== WALLET ENVIRONMENT DEBUG ==="),console.log("ethereum:","undefined"!=typeof window?Boolean(window.ethereum):"Not in browser"),console.log("tronWeb:","undefined"!=typeof window?Boolean(window.tronWeb):"Not in browser"),console.log("lute:","undefined"!=typeof window?Boolean(window.lute):"Not in browser"),console.log("algorand:","undefined"!=typeof window?Boolean(window.algorand):"Not in browser"),console.log("AlgoSigner:","undefined"!=typeof window?Boolean(window.AlgoSigner):"Not in browser"),"undefined"!=typeof window&&window.ethereum&&console.log("ethereum details:",{isTrust:window.ethereum.isTrust,isMetaMask:window.ethereum.isMetaMask,chainId:window.ethereum.chainId}),"undefined"!=typeof window&&window.tronWeb&&console.log("tronWeb details:",{ready:window.tronWeb.ready,fullNode:null==(t=window.tronWeb.fullNode)?void 0:t.host,defaultAddress:window.tronWeb.defaultAddress}),"undefined"!=typeof window){console.log("All window wallet properties:");const t=Object.keys(window).filter((t=>t.toLowerCase().includes("lute")||t.toLowerCase().includes("algo")||t.toLowerCase().includes("wallet")));console.log("Potential wallet properties:",t)}const e=Ad();console.log("Detected wallets:",e),console.log("=== END WALLET ENVIRONMENT DEBUG ===")})(),getMerchantWallets:()=>D})));const nt=t=>__async(this,null,(function*(){if(!t||!t.amount)return M("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));N("loading"),E(!0),U("select-currency");try{tt("Creating payment with details:",t);let e=D;0===Object.keys(e).length&&(tt("No wallet addresses found, fetching from backend..."),e=yield Ud(),j(e)),tt("Using wallet addresses:",e);const n=yield jd({amount:t.amount,currency:t.currency||"USDT",network:t.network||g,customerEmail:t.customerEmail||i,callbackUrl:t.callbackUrl,metadata:__spreadProps(__spreadValues({},t.metadata),{merchantWalletAddresses:e}),merchantWalletAddresses:e});tt("Payment created:",n),k(n.payment),N("idle"),M(null),tt("Payment created and state updated")}catch(e){tt("Error creating payment:",e),M(e.message||"Failed to create payment"),N("error"),l&&l(e)}})),rt=()=>{Q&&(clearInterval(Q),z(null)),V.current&&(clearTimeout(V.current),V.current=null),E(!1),B(null),G(null),P(null),U("select-currency"),W(null),J(!1),c&&c()};return Xd.jsx(Xd.Fragment,{children:A&&Xd.jsx(Ip,{isOpen:A,onClose:rt,payment:x,paymentStatus:S,selectedPaymentMethod:C,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",F),tt("Payment method selected:",t),P(t),U("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>__async(this,null,(function*(){var t,e;if(x&&C)if(I||p){tt("Starting payment process..."),N("loading"),B(null),U("processing"),W(Date.now());try{let n;if(p)tt("Test mode: Generating mock transaction..."),n=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`,yield new Promise((t=>setTimeout(t,1e3)));else{let r;if(x.recipientWallet)r=x.recipientWallet;else{if(!D[C.network])throw new Error(`No merchant wallet address found for ${C.network} network`);r=D[C.network]}tt("Using merchant address for payment:",r),tt("Sending transaction through wallet..."),n=yield Md(I,{to:r,amount:x.totalAmount||x.amount,tokenAddress:null==(t=C.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=C.tokenConfig)?void 0:e.decimals,currency:C.currency,network:C.network})}tt("Transaction hash obtained:",n),B(n),U("success"),et()}catch(n){tt("Payment error:",n),M(n.message||"Failed to process payment"),N("error"),U("error"),l&&l(n)}}else M("Please connect your wallet first");else M("Missing payment information")})),onBack:()=>{"confirm"===F?(U("select-currency"),G(null)):"error"===F&&U("confirm")},error:T,theme:Y,merchantName:s,transactionHash:R,walletConnection:I,onConnectWallet:t=>__async(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",t),console.log("2. Selected payment method:",C),console.log("3. Available wallets:",O),console.log("4. Current step:",F),!C)return console.error("No payment method selected"),void M("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),M(null),tt("Connecting wallet:",{walletType:t,network:C.network});const e=yield Cd(t,C.network);G(e),M(null),console.log("6. Connection successful:",e),tt("Wallet connected successfully:",e)}catch(e){console.error("7. Connection failed:",e),tt("Wallet connection error:",e),M(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:$,availableWallets:O,supportedWallets:C?Pd(C.network):[],step:F,merchantWalletAddresses:D,debug:X,processingStartTime:H,pendingBackendConfirmation:K,paymentNetwork:null==C?void 0:C.network})})}));Gp.displayName="CoinleyCheckout";t.CoinleyCheckout=Gp,t.CoinleyModal=Ip,t.CoinleyProvider=({apiKey:t,apiSecret:n,apiUrl:r="https://coinleyserver-production.up.railway.app",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:o=!1,children:a})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null),[f,g]=e.useState({});e.useEffect((()=>{if(!t||!n)return void h("API key and secret are required");(()=>{__async(this,null,(function*(){try{yield Ld({apiKey:t,apiSecret:n,apiUrl:r,debug:o});const e=yield Ud(),a=__spreadValues(__spreadValues(__spreadValues({},e),i&&{ethereum:i}),s&&{solana:s});g(a),c(!0),o&&console.log("Coinley SDK initialized successfully with wallets:",a)}catch(e){h(e.message),o&&console.error("Coinley SDK initialization error:",e)}}))})()}),[t,n,r,i,s,o]);const m={apiKey:t,apiSecret:n,apiUrl:r,merchantWalletAddress:i,merchantSolWalletAddress:s,merchantWallets:f,isInitialized:l,error:u,debug:o,paymentData:d,storePaymentData:t=>(p(t),t),refreshMerchantWallets:()=>__async(this,null,(function*(){try{const t=yield Ud();return g(t),t}catch(t){return console.error("Failed to refresh merchant wallets:",t),f}}))};return Xd.jsx(tp.Provider,{value:m,children:a})},t.DEFAULT_CONFIG={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},t.NETWORK_CONFIG=_d,t.NETWORK_TYPES=md,t.PaymentMethods=Bp,t.PaymentStatus=kp,t.QRCode=xp,t.TOKEN_CONFIG=yd,t.ThemeProvider=({initialTheme:t="light",children:n})=>{const[r,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(r)}),[r]),Xd.jsx($d.Provider,{value:{theme:r,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:n})},t.WALLET_TYPES=gd,t.connectWallet=Cd,t.createPayment=jd,t.detectWallets=Ad,t.generateMockTransactionHash=(t="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[t]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,t.getMerchantWallets=Ud,t.getPayment=t=>__async(this,null,(function*(){try{if(console.log("Getting payment:",t),!t)throw new Error("Payment ID is required");const n=yield fetch(`${Od.apiUrl}/api/payments/${t}`,{method:"GET",headers:Dd()});if(!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to get payment: ${n.status} ${n.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${n.status}`)}const r=yield n.json();return console.log("Get payment response:",r),r}catch(n){throw console.error("Get payment error:",n),n}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Od.apiUrl}/api/networks`,{method:"GET",headers:Dd()});if(!e.ok){let n;try{n=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(n.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),t.getSupportedWalletsForNetwork=Pd,t.getWalletInstallUrl=vd,t.processPayment=Hd,t.sendTransaction=Md,t.useCoinley=ep,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const r=yield fetch(`${Od.apiUrl}/api/wallets/validate`,{method:"POST",headers:Dd(),body:JSON.stringify({address:t,network:e})});if(!r.ok){let t;try{t=yield r.json()}catch(n){throw new Error(`Failed to validate address: ${r.status} ${r.statusText}`)}throw new Error(t.error||`Failed to validate address: ${r.status}`)}return yield r.json()}catch(r){throw console.error("Validate wallet address error:",r),r}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
16
|
+
*/function wp(t,e=0){const n=[];return t.forEach((function(t,r){let i=null;t.forEach((function(s,o){if(!s&&null!==i)return n.push(`M${i+e} ${r+e}h${o-i}v1H${i+e}z`),void(i=null);if(o!==t.length-1)s&&null===i&&(i=o);else{if(!s)return;null===i?n.push(`M${o+e},${r+e} h1v1H${o+e}z`):n.push(`M${i+e},${r+e} h${o+1-i}v1H${i+e}z`)}}))})),n.join("")}function vp(t,e){return t.slice().map(((t,n)=>n<e.y||n>=e.y+e.h?t:t.map(((t,n)=>(n<e.x||n>=e.x+e.w)&&t))))}function bp({value:t,level:n,minVersion:r,includeMargin:i,marginSize:s,imageSettings:o,size:a,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...hp.QrSegment.makeSegments(e)),t)),[]);return hp.QrCode.encodeSegments(e,dp[n],r,void 0,void 0,l)}),[t,n,r,l]);const{cells:u,margin:h,numCells:d,calculatedImageSettings:p}=e.useMemo((()=>{let t=c.getModules();const e=function(t,e){return null!=e?Math.max(Math.floor(e),0):t?4:0}(i,s),n=t.length+2*e,r=function(t,e,n,r){if(null==r)return null;const i=t.length+2*n,s=Math.floor(.1*e),o=i/e,a=(r.width||s)*o,l=(r.height||s)*o,c=null==r.x?t.length/2-a/2:r.x*o,u=null==r.y?t.length/2-l/2:r.y*o,h=null==r.opacity?1:r.opacity;let d=null;if(r.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(a+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:a,excavation:d,opacity:h,crossOrigin:r.crossOrigin}}(t,a,e,o);return{cells:t,margin:e,numCells:n,calculatedImageSettings:r}}),[c,a,o,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var Ap=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:o=fp,bgColor:a=gp,fgColor:l=mp,includeMargin:c=yp,minVersion:u=_p,boostLevel:h,marginSize:d,imageSettings:p}=r,f=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=up(f,["style"]),y=null==p?void 0:p.src,_=e.useRef(null),w=e.useRef(null),v=e.useCallback((t=>{_.current=t,"function"==typeof n?n(t):n&&(n.current=t)}),[n]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=bp({value:i,level:o,minVersion:u,boostLevel:h,includeMargin:c,marginSize:d,imageSettings:p,size:s});e.useEffect((()=>{if(null!=_.current){const t=_.current,e=t.getContext("2d");if(!e)return;let n=x;const r=w.current,i=null!=S&&null!==r&&r.complete&&0!==r.naturalHeight&&0!==r.naturalWidth;i&&null!=S.excavation&&(n=vp(x,S.excavation));const o=window.devicePixelRatio||1;t.height=t.width=s*o;const c=s/k*o;e.scale(c,c),e.fillStyle=a,e.fillRect(0,0,k,k),e.fillStyle=l,Ap?e.fill(new Path2D(wp(n,E))):x.forEach((function(t,n){t.forEach((function(t,r){t&&e.fillRect(r+E,n+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(r,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[y]);const N=cp({height:s,width:s},g);let C=null;return null!=y&&(C=e.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{A(!0)},ref:w,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",cp({style:N,height:s,width:s,ref:v,role:"img"},m)),C)})).displayName="QRCodeCanvas";var Ep=e.forwardRef((function(t,n){const r=t,{value:i,size:s=pp,level:o=fp,bgColor:a=gp,fgColor:l=mp,includeMargin:c=yp,minVersion:u=_p,boostLevel:h,title:d,marginSize:p,imageSettings:f}=r,g=up(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:y,numCells:_,calculatedImageSettings:w}=bp({value:i,level:o,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let v=y,b=null;null!=f&&null!=w&&(null!=w.excavation&&(v=vp(y,w.excavation)),b=e.createElement("image",{href:f.src,height:w.h,width:w.w,x:w.x+m,y:w.y+m,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const A=wp(v,m);return e.createElement("svg",cp({height:s,width:s,viewBox:`0 0 ${_} ${_}`,ref:n,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:a,d:`M0,0 h${_}v${_}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));Ep.displayName="QRCodeSVG";const xp=({walletAddress:t,amount:n,currency:r,network:i,theme:s="light",size:o=200})=>{const[a,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"algorand":e=h(t,n,r);break;case"tron":e="TRX"===r?`tronlink://transfer?to=${t}&amount=${n}`:t;break;case"bsc":if("BNB"===r)e=`ethereum:${t}@56?value=${g(n)}`;else{const i=p(r,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${f(n,r)}@56`:t}break;default:if("ETH"===r)e=`ethereum:${t}@1?value=${g(n)}`;else{const i=p(r,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${f(n,r)}`:t}}l(e),u(null),console.log("=== QR CODE DEBUG ==="),console.log("Network:",i),console.log("Currency:",r),console.log("Amount:",n),console.log("Wallet Address:",t),console.log("Generated QR Data:",e),console.log("QR Data Length:",e.length),console.log("=== END QR DEBUG ===")}catch(e){console.error("Error generating QR code:",e),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[t,n,r,i]);const h=(t,e,n)=>{try{const t="5OY4UMMWLFQWB7SZZ4YZCANFSESHAURQGEJWJFV2SRLGUDSSBOWXJOEPDM",r=parseFloat(e);if("ALGO"===n){return`https://perawallet.app/qr-code-generator/?receiver=${t}&amount=${Math.floor(1e6*r)}¬e=Demo%20Payment`}{const e=d(n,"algorand");if(e&&e.assetId){return`https://perawallet.app/qr-code-generator/?receiver=${t}&amount=${Math.floor(r*Math.pow(10,e.decimals))}&asset=${e.assetId}¬e=${n}%20Demo%20Payment`}return t}}catch(r){return console.error("Error generating demo Algorand QR:",r),"5OY4UMMWLFQWB7SZZ4YZCANFSESHAURQGEJWJFV2SRLGUDSSBOWXJOEPDM"}},d=(t,e)=>{var n;return null==(n={algorand:{USDC:{assetId:31566704,decimals:6},USDT:{assetId:312769,decimals:6},ALGO:{decimals:6,isNative:!0}}}[e])?void 0:n[t.toUpperCase()]},p=(t,e)=>{var n;return(null==(n={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:n[t])||""},f=(t,e)=>{const n="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,n)).toString()},g=t=>Math.floor(1e18*parseFloat(t)).toString(),m=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Xd.jsxs("div",{className:"flex flex-col items-center",children:[c?Xd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsx("p",{className:"font-medium",children:c})]}):Xd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:a&&Xd.jsx(Ep,{value:a,size:o,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Xd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Xd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",r]}),Xd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",m(i)," wallet app"]})]}),Xd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Xd.jsxs("div",{className:"flex justify-between items-center",children:[Xd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Xd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[n," ",r]})]}),Xd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Xd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Xd.jsx("span",{className:"text-xs font-medium text-gray-700",children:m(i)})]})]}),Xd.jsx("div",{className:"w-full",children:Xd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Xd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment Instructions"]}),Xd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Xd.jsxs("li",{children:["1. Open your crypto wallet app (",(y=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[y]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Xd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Xd.jsxs("li",{children:["3. Send exactly ",Xd.jsxs("strong",{children:[n," ",r]})," on ",m(i)," network"]}),Xd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Xd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Xd.jsxs("p",{className:"text-xs text-yellow-800",children:[Xd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",m(i),") and using the exact amount shown above."]})})]})})]});var y},kp=({status:t,message:n,theme:r="light",payment:i=null,transactionHash:s=null,selectedPaymentMethod:o=null,merchantName:a="Merchant",onClose:l=null,processingStartTime:c=null,paymentNetwork:u=null,pendingBackendConfirmation:h=!1})=>{const[d,p]=e.useState(!1),[f,g]=e.useState(0),[m,y]=e.useState(!1),[_,w]=e.useState(1);e.useEffect((()=>{let e;return"processing"===t&&c&&(e=setInterval((()=>{const t=Math.floor((Date.now()-c)/1e3);g(t),t>=5&&1===_&&w(2),t>=15&&2===_&&w(3),t>=30&&!m&&y(!0)}),1e3)),()=>clearInterval(e)}),[t,c,_,m]);const v=()=>__async(this,null,(function*(){if(s)try{yield navigator.clipboard.writeText(s),p(!0),setTimeout((()=>p(!1)),2e3)}catch(t){console.error("Failed to copy transaction hash:",t)}})),b=()=>{console.log("Payment success screen close button clicked"),l&&l()},A=()=>{switch(t){case"processing":return Xd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Xd.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Xd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}},E=()=>{switch(t){case"processing":return"dark"===r?"text-blue-300":"text-blue-600";case"success":return"dark"===r?"text-green-300":"text-green-600";case"error":return"dark"===r?"text-red-300":"text-red-600";default:return"dark"===r?"text-gray-300":"text-gray-600"}};return"success"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-6",children:A()}),Xd.jsx("h3",{className:"text-2xl font-bold mb-3 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Successful!"}),i&&o&&Xd.jsxs("p",{className:"text-center max-w-[235px] mb-6 "+("dark"===r?"text-gray-300":"text-gray-600"),children:["Your payment of ",Xd.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[i.totalAmount||i.amount," ",o.currency]})," has been completed."]}),h&&Xd.jsxs("div",{className:"flex items-center justify-center mb-4 text-xs text-gray-500 bg-gray-50 rounded-full px-3 py-1",children:[Xd.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-3 w-3 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),Xd.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Verifying on blockchain"]}),s&&Xd.jsxs("div",{className:"w-full mb-6",children:[Xd.jsx("p",{className:"text-sm font-medium mb-2 "+("dark"===r?"text-gray-300":"text-gray-700"),children:"Transaction Hash:"}),Xd.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors "+("dark"===r?"bg-gray-700 border-gray-600 hover:bg-gray-600":"bg-gray-50 border-gray-200 hover:bg-gray-100"),onClick:v,children:[Xd.jsx("span",{className:"font-mono text-sm "+("dark"===r?"text-gray-300":"text-gray-700"),children:(S=s,S?S.length<=16?S:`${S.slice(0,8)}...${S.slice(-8)}`:"")}),Xd.jsxs("div",{className:"flex items-center",children:[d?Xd.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 "+("dark"===r?"text-gray-400":"text-gray-500"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]})]}),Xd.jsx("div",{className:"w-full p-4 rounded-lg border mb-6 "+("dark"===r?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:Xd.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Merchant ID:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:a})]}),Xd.jsxs("div",{children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Network:"}),Xd.jsx("p",{className:"text-sm font-medium "+("dark"===r?"text-gray-300":"text-gray-700"),children:o?(k=o.network,{ethereum:"Ethereum",bsc:"BSC",tron:"TRON",algorand:"Algorand"}[k]||k):"N/A"})]}),Xd.jsxs("div",{className:"col-span-2",children:[Xd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===r?"text-gray-400":"text-gray-500"),children:"Recipient:"}),Xd.jsx("p",{className:"text-sm font-mono "+("dark"===r?"text-gray-300":"text-gray-700"),children:(null==i?void 0:i.recipientWallet)?(x=i.recipientWallet,x?x.length<=16?x:`${x.slice(0,6)}...${x.slice(-4)}`:"N/A"):"N/A"})]})]})}),l&&Xd.jsx("button",{onClick:b,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-medium rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{borderRadius:"1.5rem"},children:"Close"})]}):"error"===t?Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:"Payment Failed"}),Xd.jsx("p",{className:`text-center ${E()}`,children:n}),Xd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Xd.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Please try again or contact support if the problem persists."})})]}):Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:A()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful!";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Xd.jsx("p",{className:`text-center ${E()}`,children:n})]});var x,k,S},Sp=({size:t=24})=>Xd.jsxs("svg",{width:t,height:t,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsxs("g",{clipPath:"url(#clip0_2786_457)",children:[Xd.jsx("path",{d:"M15.9979 5L15.845 5.52398V20.7287L15.9979 20.8826L22.9958 16.7107L15.9979 5Z",fill:"#343434"}),Xd.jsx("path",{d:"M15.9979 5L9 16.7107L15.9979 20.8826V13.5027V5Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 22.2186L15.9117 22.3245V27.7408L15.9979 27.9945L23 18.0488L15.9979 22.2186Z",fill:"#3C3C3B"}),Xd.jsx("path",{d:"M15.9979 27.9945V22.2186L9 18.0488L15.9979 27.9945Z",fill:"#8C8C8C"}),Xd.jsx("path",{d:"M15.9979 20.8818L22.9957 16.7099L15.9979 13.502V20.8818Z",fill:"#141414"}),Xd.jsx("path",{d:"M9.00006 16.7099L15.9979 20.8818V13.502L9.00006 16.7099Z",fill:"#393939"})]}),Xd.jsx("defs",{children:Xd.jsx("clipPath",{id:"clip0_2786_457",children:Xd.jsx("rect",{width:"14",height:"23",fill:"white",transform:"translate(9 5)"})})})]}),Np=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.42 8.68534C8.48853 8.61041 8.57583 8.55514 8.67287 8.52525C8.76992 8.49536 8.87319 8.49194 8.972 8.51534L20.875 11.4293C20.947 11.445 21.0146 11.4765 21.073 11.5213L23.495 13.2883C23.6127 13.3751 23.6923 13.5039 23.7173 13.6479C23.7422 13.792 23.7106 13.9401 23.629 14.0613L15.297 26.2523C15.2385 26.3388 15.1571 26.4074 15.0619 26.4503C14.9667 26.4932 14.8614 26.5088 14.7579 26.4953C14.6543 26.4818 14.5566 26.4398 14.4755 26.3739C14.3945 26.308 14.3334 26.2209 14.299 26.1223L8.306 9.25234C8.27276 9.15648 8.2657 9.05348 8.28557 8.95398C8.30543 8.85448 8.3515 8.76209 8.419 8.68634M10.383 11.7293L14.543 23.4413L15.227 17.3723L10.383 11.7293ZM16.341 17.5673L15.646 23.7423L21.529 15.1323L16.341 17.5673ZM22.06 13.6373L18.269 15.4173L20.809 12.7263L22.06 13.6373ZM19.664 12.2943L10.411 10.0303L15.836 16.3483L19.664 12.2943Z",fill:"black"})}),Cp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M17.2512 9.5H19.7036L20.7785 13.4753H23.3083L21.5804 16.4753L24 25.4973H21.4916L19.8625 19.446L16.3592 25.4987H13.5597L18.9725 16.1313L18.1018 12.8793L10.8022 25.5H8L17.2512 9.5Z",fill:"black"})}),Pp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.52513 16.0195H20.7032C20.843 16.0195 20.9713 16.0794 21.0762 16.1873L22.8479 18.0574C23.1742 18.4051 22.9411 18.9925 22.4749 18.9925H11.2968C11.157 18.9925 11.0287 18.9326 10.9238 18.8247L9.15214 16.9545C8.82577 16.6069 9.05889 16.0195 9.52513 16.0195ZM9.15214 13.538L10.9238 11.6678C11.0171 11.5599 11.157 11.5 11.2968 11.5H22.4632C22.9295 11.5 23.1626 12.0874 22.8362 12.4351L21.0762 14.3052C20.9829 14.4131 20.843 14.473 20.7032 14.473H9.52513C9.05889 14.473 8.82577 13.8856 9.15214 13.538ZM22.8362 21.462L21.0645 23.3322C20.9596 23.4401 20.8314 23.5 20.6915 23.5H9.52513C9.05889 23.5 8.82577 22.9126 9.15214 22.5649L10.9238 20.6948C11.0171 20.5869 11.157 20.527 11.2968 20.527H22.4632C22.9295 20.527 23.1626 21.1144 22.8362 21.462Z",fill:"black"})}),Tp=({size:t=32})=>Xd.jsx("svg",{width:t,height:t+1,viewBox:"0 0 32 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M19.0827 18.7809L20.8947 20.5933L15.9927 25.5L11.0907 20.594L12.902 18.7809L15.9927 21.8905L19.0827 18.7809ZM22.174 15.6873L24 17.4997L22.19 19.3121L20.3787 17.4997L22.174 15.6873ZM15.9927 15.6873L17.8033 17.4837L15.992 19.2967L14.1813 17.4997L15.9927 15.6873ZM9.81067 15.6873L11.6067 17.4997L9.812 19.2961L8 17.4997L9.81067 15.6873ZM15.9933 9.5L20.8933 14.39L19.082 16.2018L15.9933 13.1088L12.9027 16.2184L11.0913 14.406L15.9933 9.5Z",fill:"black"})}),Mp=({size:t=32})=>Xd.jsx("svg",{width:t-4,height:t-4,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.36266 4.256C8.38876 4.0477 8.48986 3.85605 8.64705 3.7169C8.80423 3.57775 9.00673 3.50064 9.21666 3.5H17.0847C17.9472 3.55674 18.7895 3.78654 19.5613 4.1757C20.3331 4.56486 21.0187 5.10541 21.5772 5.76515C22.1357 6.42489 22.5557 7.19031 22.8121 8.0158C23.0685 8.84129 23.1561 9.70994 23.0697 10.57C22.6847 15.659 18.6737 17.5 16.5807 17.5H13.8367L12.6677 23.786C12.6333 23.987 12.5285 24.1693 12.372 24.3001C12.2156 24.431 12.0176 24.5018 11.8137 24.5H6.61966C6.49561 24.4979 6.3734 24.4696 6.26099 24.4171C6.14859 24.3646 6.04851 24.289 5.96728 24.1952C5.88604 24.1014 5.82548 23.9916 5.78954 23.8728C5.75359 23.7541 5.74307 23.6291 5.75866 23.506L7.05366 14H5.76566C5.65113 13.9998 5.53775 13.9771 5.43205 13.933C5.32635 13.8888 5.23041 13.8243 5.14975 13.743C5.06909 13.6616 5.00529 13.5652 4.96203 13.4591C4.91877 13.3531 4.89689 13.2395 4.89766 13.125C4.89766 12.642 5.28266 12.25 5.76566 12.25H7.29166L7.76066 8.75H5.76566C5.65113 8.74985 5.53775 8.72706 5.43205 8.68295C5.32635 8.63884 5.23041 8.57427 5.14975 8.49296C5.06909 8.41164 5.00529 8.31519 4.96203 8.20914C4.91877 8.10309 4.89689 7.98953 4.89766 7.875C4.89612 7.76084 4.91723 7.64751 4.95978 7.54157C5.00233 7.43563 5.06547 7.33918 5.14554 7.2578C5.22562 7.17643 5.32104 7.11174 5.42628 7.06749C5.53152 7.02324 5.6445 7.0003 5.75866 7H7.99166L8.36266 4.256ZM9.50366 8.75L9.02766 12.25H15.2787C15.51 12.2579 15.7404 12.218 15.9555 12.1326C16.1707 12.0473 16.3659 11.9185 16.5289 11.7541C16.6919 11.5898 16.8191 11.3936 16.9027 11.1778C16.9863 10.962 17.0244 10.7312 17.0147 10.5C17.0244 10.2688 16.9863 10.038 16.9027 9.82219C16.8191 9.60638 16.6919 9.41017 16.5289 9.24586C16.3659 9.08155 16.1707 8.95269 15.9555 8.86736C15.7404 8.78203 15.51 8.74208 15.2787 8.75H9.50366ZM8.79666 14H15.2787C15.738 14.0048 16.1936 13.9173 16.6184 13.7426C17.0433 13.568 17.4287 13.3098 17.7519 12.9833C18.0751 12.6569 18.3294 12.2689 18.4998 11.8423C18.6701 11.4157 18.7531 10.9593 18.7437 10.5C18.7437 8.54 17.2457 7 15.2787 7H9.74166L9.97266 5.25H16.9727C17.6045 5.28987 18.2218 5.45727 18.7872 5.74209C19.3527 6.02692 19.8546 6.42329 20.2627 6.90731C20.6709 7.39132 20.9768 7.95297 21.1621 8.55839C21.3473 9.16381 21.4081 9.80047 21.3407 10.43C21.0397 14.441 17.9457 15.75 16.5807 15.75H13.1157C12.9126 15.7514 12.7163 15.8234 12.5605 15.9537C12.4047 16.084 12.299 16.2644 12.2617 16.464L11.0997 22.75H7.61366L8.79666 14Z",fill:"#3B6FEF"})}),Rp=({size:t=32})=>Xd.jsxs("svg",{width:t-5,height:t-5,viewBox:"0 0 27 27",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Xd.jsx("path",{d:"M13.5 27C20.9558 27 27 20.9558 27 13.5C27 6.04416 20.9558 0 13.5 0C6.04416 0 0 6.04416 0 13.5C0 20.9558 6.04416 27 13.5 27Z",fill:"#398260"}),Xd.jsx("path",{d:"M15.6963 5.83207C17.1627 6.86735 18.6899 6.98294 20.6432 7.34238C22.4201 7.67229 22.7973 9.48719 21.9856 11.7974C21.9365 11.7143 21.8859 11.6322 21.8337 11.551L21.9856 11.7974C23.2234 13.9 23.2141 16.1773 20.5352 17.3425C15.7655 19.4181 15.4811 23.5061 10.973 21.3056C10.3338 20.991 9.75978 20.5585 9.28125 20.0307L9.10575 19.8307L8.9429 19.8029C5.91722 19.2671 3.93103 17.6269 5.76872 13.4419C7.39462 9.74369 5.94253 6.1046 10.9291 6.2666H10.9308C12.3044 4.97819 13.8881 4.55885 15.6954 5.83207H15.6963ZM11.0497 9.57157C8.95894 11.0726 8.27044 13.8679 9.66262 16.0389C9.99149 16.5546 10.4192 17 10.921 17.3496C11.4228 17.6992 11.9889 17.946 12.5866 18.0758C13.1842 18.2056 13.8017 18.2159 14.4033 18.1059C15.0049 17.996 15.5789 17.7681 16.092 17.4353C18.2503 16.0347 18.5456 13.3178 17.4791 10.9663C16.3865 8.55569 13.3869 7.89335 11.0497 9.57157Z",fill:"white"})]}),Bp=({onSelect:t,selected:n,theme:r="light",supportedNetworks:i=[]})=>{var s;const[o,a]=e.useState(md.ETHEREUM),[l,c]=e.useState(null),[u,h]=e.useState({}),[d,p]=e.useState(!1),f=[{id:md.ETHEREUM,name:"Ethereum",icon:Sp},{id:md.TRON,name:"Tron",icon:Np},{id:md.ALGORAND,name:"Algorand",icon:Cp},{id:"solana",name:"Solana",icon:Pp},{id:md.BSC,name:"Binance Smart Chain",icon:Tp}],[g,m]=e.useState(!1),y=e.useRef(null);e.useEffect((()=>{function t(t){y.current&&!y.current.contains(t.target)&&m(!1)}return g?document.addEventListener("mousedown",t):document.removeEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)}),[g]),e.useEffect((()=>{h(Ad())}),[]);const _=(t=>{const e=[];switch(t){case md.ETHEREUM:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:Mp,network:md.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:Rp,network:md.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:md.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"/eth.png",network:md.ETHEREUM});break;case md.BSC:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:md.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:md.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"/bnb.png",network:md.BSC});break;case md.TRON:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:md.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:md.TRON});break;case md.ALGORAND:e.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:md.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:md.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:md.ALGORAND})}return e})(o),w=d?_:_.slice(0,4);function v(t){switch(t){case md.ETHEREUM:case md.BSC:return gd.METAMASK;case md.TRON:return gd.TRONLINK;case md.ALGORAND:return gd.LUTE;default:return gd.METAMASK}}return Xd.jsxs("div",{className:"",children:[Xd.jsxs("div",{className:"mb-6",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===r?"text-white":"text-gray-700"),children:"Blockchain Network"}),Xd.jsxs("div",{className:"relative",ref:y,children:[Xd.jsxs("button",{type:"button",className:"w-full flex items-center justify-between py-4 bg-white rounded-2xl shadow border border-gray-200 text-gray-900 text-base font-normal focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50 transition",onClick:()=>m((t=>!t)),style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-3",children:[(()=>{const t=f.find((t=>t.id===o));return Xd.jsx(t.icon,{size:32})})(),Xd.jsx("span",{className:"text-base font-normal",children:null==(s=f.find((t=>t.id===o)))?void 0:s.name})]}),Xd.jsx("svg",{className:"w-5 h-5 ml-2 transition-transform "+(g?"rotate-180":""),fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),g&&Xd.jsx("div",{className:"absolute left-0 mt-2 px-2 w-full bg-white rounded-2xl shadow-lg border border-gray-100 z-20",style:{minWidth:"100%"},children:f.filter((t=>0===i.length||i.includes(t.id))).map((t=>Xd.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 mt-1 mb-1 px-2 py-2 text-gray-900 text-base font-normal rounded-2xl transition hover:bg-gray-100 "+(o===t.id?"bg-gray-50":""),onClick:()=>{var e;m(!1),e=t.id,a(e),p(!1),c(null)},style:{minHeight:"48px"},children:[Xd.jsx(t.icon,{size:32}),Xd.jsx("span",{children:t.name})]},t.id)))})]})]}),Xd.jsxs("div",{className:"mb-4",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===r?"text-white":"text-gray-700"),children:"Select Stablecoin"}),Xd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:w.map((t=>{const e=(null==l?void 0:l.currency)===t.id&&(null==l?void 0:l.network)===o;return Xd.jsxs("button",{onClick:()=>(t=>{var e;const n={currency:t.id,network:o,tokenConfig:null==(e=_d[t.id])?void 0:e[o],method:t};c(n)})(t),className:`group flex items-center justify-between w-full px-2 py-2 rounded-2xl border text-left transition-all duration-200 font-medium text-base\n ${e?"bg-[#E9DDFC] border-transparent shadow-none":"bg-white border-gray-200 hover:bg-[#F6F2FF] hover:border-[#E9DDFC]"}\n `,style:{minHeight:"56px",padding:"0.5rem"},children:[Xd.jsxs("span",{className:"flex items-center gap-x-2",children:["function"==typeof t.logo?Xd.jsx(t.logo,{size:24}):Xd.jsx("img",{src:t.logo,alt:t.name,className:"h-4 w-4"}),Xd.jsxs("span",{className:"font-medium text-sm text-gray-900",children:[t.description," (",t.name,")"]})]}),e&&Xd.jsx("span",{className:"ml-2 flex items-center justify-center w-6 h-6 rounded-full bg-[#7042D2]",children:Xd.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M4 8.5L7 11.5L12 6.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},`${t.id}-${t.network}`)}))}),_.length>4&&Xd.jsx("button",{onClick:()=>p(!d),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===r?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:d?"Show Less":`Show More (${_.length-4} more)`})]}),Xd.jsx("div",{className:"p-3 rounded-lg text-sm mb-6 "+("dark"===r?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(u[v(o)]?"bg-green-500":"bg-red-500")}),Xd.jsx("span",{className:"text-xs",children:function(t){const e=v(t),n=u[e],r={[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"};return n?`${r[e]} detected - Ready to pay`:`${r[e]} required - Please install to continue`}(o)})]})}),Xd.jsx("button",{onClick:()=>{l&&t(l)},disabled:!l,className:"w-full py-3 px-4 font-medium rounded-2xl text-lg shadow-md transition-colors "+(l?"bg-[#7042D2] text-white hover:bg-[#5b34b1]":"bg-gray-300 text-gray-500 cursor-not-allowed"),style:{borderRadius:"1.5rem"},children:"Proceed"})]})},Gp=({isOpen:t,onClose:n,payment:r,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:o,onPayment:a,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:y={},supportedWallets:_=[],step:w="select-currency",merchantWalletAddresses:v={},debug:b=!1,processingStartTime:A=null,pendingBackendConfirmation:E=!1,paymentNetwork:x=null})=>{const[k,S]=e.useState("wallet"),N=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t),C=t=>({[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"}[t]||t),P=t=>({[gd.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[gd.TRONLINK]:"https://www.tronlink.org/images/logo.png",[gd.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[gd.LUTE]:"https://lute.app/logo.png"}[t]||"");return t?Xd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:Xd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Xd.jsxs("div",{className:"coinley-modal relative py-6 px-2 w-full max-w-md mx-auto shadow-xl bg-gray-100 rounded-3xl",children:[Xd.jsxs("div",{className:"bg-white flex justify-between items-center mb-6 mr-3 ml-3 py-4 px-2 rounded-full",children:[Xd.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Xd.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAbCAYAAABm409WAAAACXBIWXMAAAsTAAAL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SnvkAAAAABJRU5ErkJggg==",className:"w-auto h-auto",alt:"Coinley Logo"}),Xd.jsx("span",{className:"text-lg font-semibold text-gray-800",children:"Payment Details"})]}),"success"!==w&&"processing"!==w&&Xd.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r&&"success"!==w&&Xd.jsx("div",{className:"mb-6",children:Xd.jsxs("div",{className:"text-center",children:[Xd.jsx("div",{className:"text-sm text-gray-600",children:"Total amount"}),Xd.jsxs("div",{className:"coinley-amount-display text-2xl md:text-4xl lg:text-6xl font-bold text-[#7042D2] mt-2 leading-tight tracking-tight",children:["$",(T=r.totalAmount||r.amount,parseFloat(T).toFixed(2))]}),Xd.jsx("div",{className:"text-sm text-gray-600 mt-4",children:"Payment to:"}),Xd.jsxs("div",{className:"coinley-merchant-name text-base font-semibold mt-1 flex gap-2 items-center justify-center",children:[Xd.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Xd.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),h]})]})}),"select-currency"===w&&Xd.jsx("div",{className:"pb-6 pt-6 px-6 bg-white rounded-t-2xl blockchain-network",children:Xd.jsx(Bp,{onSelect:o,selected:s,theme:u,supportedNetworks:m})}),"confirm"===w&&s&&r&&Xd.jsxs("div",{children:[Xd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Xd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Xd.jsxs("div",{className:"space-y-2",children:[Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Currency:"}),Xd.jsx("span",{className:"font-medium",children:s.currency})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Network:"}),Xd.jsx("span",{className:"font-medium",children:N(s.network)})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-purple-600 font-semibold",children:"Fee:"}),Xd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Xd.jsx("div",{className:"mb-4",children:Xd.jsxs("div",{className:"flex border-b border-gray-200",children:[Xd.jsx("button",{onClick:()=>S("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Xd.jsx("button",{onClick:()=>S("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===k?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Xd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"bg-purple-600 rounded-full p-2 mr-3",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Xd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===k?Xd.jsx("div",{className:"mb-4",children:Xd.jsx(xp,{walletAddress:(()=>{if(!s)return"No network selected";const t=v[s.network];return t||((null==r?void 0:r.recipientWallet)?r.recipientWallet:"No wallet address configured for this network")})(),amount:r.totalAmount||r.amount,currency:s.currency,network:s.network,theme:u})}):Xd.jsxs("div",{className:"space-y-3 mb-4",children:[0===_.length?Xd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",N(s.network)," network"]})]})]})}):_.map((t=>Xd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("img",{src:P(t),alt:C(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:C(t)}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",C(t)]})]})]}),(null==p?void 0:p.walletType)===t?Xd.jsxs("div",{className:"flex items-center space-x-2",children:[Xd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Xd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Xd.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",t),f(t)},className:"coinley-button-primary py-2 px-4 font-medium rounded-md text-sm",children:"Connect"})]})},t))),Xd.jsx("div",{className:"space-y-2",children:Object.entries(y).filter((([t,e])=>!e)).map((([t])=>Xd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("span",{className:"text-sm text-gray-600",children:[C(t)," not detected"]}),Xd.jsx("a",{href:vd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-purple-600 hover:underline",children:"Install"})]})},t)))})]}),c&&Xd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Xd.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[Xd.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-purple-600 font-medium rounded-md",children:"Back"}),Xd.jsx("button",{type:"button",onClick:()=>a("qrcode"===k),className:"coinley-button-primary w-full py-2 px-4 font-medium rounded-md",disabled:!g&&"wallet"===k&&!p,children:"qrcode"===k?"I have sent the payment":"Pay Now"})]})]}),"processing"===w&&Xd.jsx(kp,{status:"processing",theme:u,message:"Processing your payment...",processingStartTime:A,paymentNetwork:x||(null==s?void 0:s.network),transactionHash:d}),"success"===w&&Xd.jsx(kp,{status:"success",theme:u,message:"Payment successful!",payment:r,transactionHash:d,selectedPaymentMethod:s,merchantName:h,onClose:()=>{console.log("Success screen close button clicked"),n&&n()},pendingBackendConfirmation:E}),"error"===w&&Xd.jsxs("div",{children:[Xd.jsx(kp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Xd.jsx("button",{type:"button",onClick:l,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]}),"success"!==w&&Xd.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-[12px] ",children:[Xd.jsxs("p",{children:["Powered by ",Xd.jsx("span",{className:"text-purple-600",children:"Coinley"})," - Secure Cryptocurrency Payments"]}),Xd.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[Xd.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Xd.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})}):null;var T},Ip=e.forwardRef((({apiKey:t,apiSecret:n,apiUrl:r,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:o={},onSuccess:a,onError:l,onClose:c,theme:u,autoOpen:h=!1,debug:d=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:g=md.ETHEREUM,preferredWallet:m=gd.METAMASK,confirmations:y=1,fastMode:_=!0},w)=>{const v=ep(),{theme:b}=e.useContext($d),[A,E]=e.useState(h),[x,k]=e.useState(null),[S,N]=e.useState("idle"),[C,P]=e.useState(null),[T,M]=e.useState(null),[R,B]=e.useState(null),[G,I]=e.useState(null),[O,L]=e.useState({}),[F,U]=e.useState("select-currency"),[D,j]=e.useState({}),[H,W]=e.useState(null),[Q,z]=e.useState(null),V=e.useRef(null),[K,J]=e.useState(!1),q=t||(null==v?void 0:v.apiKey),Z=n||(null==v?void 0:v.apiSecret);r||null==v||v.apiUrl;const Y=u||b,X=d||(null==v?void 0:v.debug),$=f.length>0?f:[md.ETHEREUM,md.BSC,md.TRON,md.ALGORAND],tt=(t,e)=>{X&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{q&&Z&&(()=>{__async(this,null,(function*(){try{tt("Fetching merchant wallet addresses from backend...");const t=yield Ud();j(t),tt("Merchant wallets fetched successfully:",t)}catch(t){console.error("Failed to fetch merchant wallets:",t),j(o)}}))})()}),[q,Z,o]),e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield Ed(3,1e3);L(t),tt("Available wallets detected:",t)})))()}}),[X]),e.useEffect((()=>()=>{V.current&&clearTimeout(V.current),Q&&clearInterval(Q)}),[Q]),e.useEffect((()=>{if(R&&K&&"loading"===S){const t=setInterval((()=>__async(this,null,(function*(){try{tt("Checking payment status with backend...");"success"===(yield Hd({paymentId:x.id,transactionHash:R,network:C.network,currency:C.currency,senderAddress:null==G?void 0:G.address,confirmations:y,check:!0})).status&&(tt("Payment confirmed by backend!"),clearInterval(t),z(null),J(!1),N("success"))}catch(e){tt("Error checking payment status:",e)}}))),1e4);return z(t),()=>{clearInterval(t)}}}),[R,K,S,x,C,G,y]);const et=()=>__async(this,null,(function*(){if(x&&C&&R)try{tt("Processing payment with backend...");const t=yield Hd({paymentId:x.id,transactionHash:R,network:C.network,currency:C.currency,senderAddress:null==G?void 0:G.address,confirmations:y});tt("Payment processed successfully:",t),J(!1),a&&(tt("Calling onSuccess callback..."),a(x.id,R,{network:C.network,currency:C.currency,amount:x.totalAmount||x.amount}))}catch(t){tt("Payment processing initial attempt failed, will retry in background:",t),J(!0)}}));e.useImperativeHandle(w,(()=>({open:t=>{nt(t)},close:()=>{rt()},getPayment:()=>x,getWalletConnection:()=>G,debugWallets:()=>(()=>{var t;if(console.log("=== WALLET ENVIRONMENT DEBUG ==="),console.log("ethereum:","undefined"!=typeof window?Boolean(window.ethereum):"Not in browser"),console.log("tronWeb:","undefined"!=typeof window?Boolean(window.tronWeb):"Not in browser"),console.log("lute:","undefined"!=typeof window?Boolean(window.lute):"Not in browser"),console.log("algorand:","undefined"!=typeof window?Boolean(window.algorand):"Not in browser"),console.log("AlgoSigner:","undefined"!=typeof window?Boolean(window.AlgoSigner):"Not in browser"),"undefined"!=typeof window&&window.ethereum&&console.log("ethereum details:",{isTrust:window.ethereum.isTrust,isMetaMask:window.ethereum.isMetaMask,chainId:window.ethereum.chainId}),"undefined"!=typeof window&&window.tronWeb&&console.log("tronWeb details:",{ready:window.tronWeb.ready,fullNode:null==(t=window.tronWeb.fullNode)?void 0:t.host,defaultAddress:window.tronWeb.defaultAddress}),"undefined"!=typeof window){console.log("All window wallet properties:");const t=Object.keys(window).filter((t=>t.toLowerCase().includes("lute")||t.toLowerCase().includes("algo")||t.toLowerCase().includes("wallet")));console.log("Potential wallet properties:",t)}const e=Ad();console.log("Detected wallets:",e),console.log("=== END WALLET ENVIRONMENT DEBUG ===")})(),getMerchantWallets:()=>D})));const nt=t=>__async(this,null,(function*(){if(!t||!t.amount)return M("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));N("loading"),E(!0),U("select-currency");try{tt("Creating payment with details:",t);let e=D;0===Object.keys(e).length&&(tt("No wallet addresses found, fetching from backend..."),e=yield Ud(),j(e)),tt("Using wallet addresses:",e);const n=yield jd({amount:t.amount,currency:t.currency||"USDT",network:t.network||g,customerEmail:t.customerEmail||i,callbackUrl:t.callbackUrl,metadata:__spreadProps(__spreadValues({},t.metadata),{merchantWalletAddresses:e}),merchantWalletAddresses:e});tt("Payment created:",n),k(n.payment),N("idle"),M(null),tt("Payment created and state updated")}catch(e){tt("Error creating payment:",e),M(e.message||"Failed to create payment"),N("error"),l&&l(e)}})),rt=()=>{Q&&(clearInterval(Q),z(null)),V.current&&(clearTimeout(V.current),V.current=null),E(!1),B(null),I(null),P(null),U("select-currency"),W(null),J(!1),c&&c()};return Xd.jsx(Xd.Fragment,{children:A&&Xd.jsx(Gp,{isOpen:A,onClose:rt,payment:x,paymentStatus:S,selectedPaymentMethod:C,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",F),tt("Payment method selected:",t),P(t),U("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>__async(this,null,(function*(){var t,e;if(x&&C)if(G||p){tt("Starting payment process..."),N("loading"),B(null),U("processing"),W(Date.now());try{let n;if(p)tt("Test mode: Generating mock transaction..."),n=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`,yield new Promise((t=>setTimeout(t,1e3)));else{let r;if(x.recipientWallet)r=x.recipientWallet;else{if(!D[C.network])throw new Error(`No merchant wallet address found for ${C.network} network`);r=D[C.network]}tt("Using merchant address for payment:",r),tt("Sending transaction through wallet..."),n=yield Md(G,{to:r,amount:x.totalAmount||x.amount,tokenAddress:null==(t=C.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=C.tokenConfig)?void 0:e.decimals,currency:C.currency,network:C.network})}tt("Transaction hash obtained:",n),B(n),U("success"),et()}catch(n){tt("Payment error:",n),M(n.message||"Failed to process payment"),N("error"),U("error"),l&&l(n)}}else M("Please connect your wallet first");else M("Missing payment information")})),onBack:()=>{"confirm"===F?(U("select-currency"),I(null)):"error"===F&&U("confirm")},error:T,theme:Y,merchantName:s,transactionHash:R,walletConnection:G,onConnectWallet:t=>__async(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",t),console.log("2. Selected payment method:",C),console.log("3. Available wallets:",O),console.log("4. Current step:",F),!C)return console.error("No payment method selected"),void M("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),M(null),tt("Connecting wallet:",{walletType:t,network:C.network});const e=yield Cd(t,C.network);I(e),M(null),console.log("6. Connection successful:",e),tt("Wallet connected successfully:",e)}catch(e){console.error("7. Connection failed:",e),tt("Wallet connection error:",e),M(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:$,availableWallets:O,supportedWallets:C?Pd(C.network):[],step:F,merchantWalletAddresses:D,debug:X,processingStartTime:H,pendingBackendConfirmation:K,paymentNetwork:null==C?void 0:C.network})})}));Ip.displayName="CoinleyCheckout";t.CoinleyCheckout=Ip,t.CoinleyModal=Gp,t.CoinleyProvider=({apiKey:t,apiSecret:n,apiUrl:r="https://coinleyserver-production.up.railway.app",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:o=!1,children:a})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null),[f,g]=e.useState({});e.useEffect((()=>{if(!t||!n)return void h("API key and secret are required");(()=>{__async(this,null,(function*(){try{yield Ld({apiKey:t,apiSecret:n,apiUrl:r,debug:o});const e=yield Ud(),a=__spreadValues(__spreadValues(__spreadValues({},e),i&&{ethereum:i}),s&&{solana:s});g(a),c(!0),o&&console.log("Coinley SDK initialized successfully with wallets:",a)}catch(e){h(e.message),o&&console.error("Coinley SDK initialization error:",e)}}))})()}),[t,n,r,i,s,o]);const m={apiKey:t,apiSecret:n,apiUrl:r,merchantWalletAddress:i,merchantSolWalletAddress:s,merchantWallets:f,isInitialized:l,error:u,debug:o,paymentData:d,storePaymentData:t=>(p(t),t),refreshMerchantWallets:()=>__async(this,null,(function*(){try{const t=yield Ud();return g(t),t}catch(t){return console.error("Failed to refresh merchant wallets:",t),f}}))};return Xd.jsx(tp.Provider,{value:m,children:a})},t.DEFAULT_CONFIG={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},t.NETWORK_CONFIG=yd,t.NETWORK_TYPES=md,t.PaymentMethods=Bp,t.PaymentStatus=kp,t.QRCode=xp,t.TOKEN_CONFIG=_d,t.ThemeProvider=({initialTheme:t="light",children:n})=>{const[r,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(r)}),[r]),Xd.jsx($d.Provider,{value:{theme:r,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:n})},t.WALLET_TYPES=gd,t.connectWallet=Cd,t.createPayment=jd,t.detectWallets=Ad,t.generateMockTransactionHash=(t="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[t]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,t.getMerchantWallets=Ud,t.getPayment=t=>__async(this,null,(function*(){try{if(console.log("Getting payment:",t),!t)throw new Error("Payment ID is required");const n=yield fetch(`${Od.apiUrl}/api/payments/${t}`,{method:"GET",headers:Dd()});if(!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to get payment: ${n.status} ${n.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${n.status}`)}const r=yield n.json();return console.log("Get payment response:",r),r}catch(n){throw console.error("Get payment error:",n),n}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Od.apiUrl}/api/networks`,{method:"GET",headers:Dd()});if(!e.ok){let n;try{n=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(n.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),t.getSupportedWalletsForNetwork=Pd,t.getWalletInstallUrl=vd,t.processPayment=Hd,t.sendTransaction=Md,t.useCoinley=ep,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const r=yield fetch(`${Od.apiUrl}/api/wallets/validate`,{method:"POST",headers:Dd(),body:JSON.stringify({address:t,network:e})});if(!r.ok){let t;try{t=yield r.json()}catch(n){throw new Error(`Failed to validate address: ${r.status} ${r.statusText}`)}throw new Error(t.error||`Failed to validate address: ${r.status}`)}return yield r.json()}catch(r){throw console.error("Validate wallet address error:",r),r}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
17
17
|
//# sourceMappingURL=coinley-checkout.umd.js.map
|