coinley-checkout 0.6.0 → 0.6.2
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,r)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,__spreadValues=(t,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(t,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(t,r,e[r]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__publicField=(t,e,r)=>(__defNormalProp(t,"symbol"!=typeof e?e+"":e,r),r),__accessCheck=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},__privateGet=(t,e,r)=>(__accessCheck(t,e,"read from private field"),r?r.call(t):e.get(t)),__privateAdd=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},__privateSet=(t,e,r,n)=>(__accessCheck(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),__privateWrapper=(t,e,r,n)=>({set _(n){__privateSet(t,e,n,r)},get _(){return __privateGet(t,e,n)}}),__privateMethod=(t,e,r)=>(__accessCheck(t,e,"access private method"),r),__superGet=(t,e,r)=>__reflectGet(__getProtoOf(t),r,e),__async=(t,e,r)=>new Promise(((n,i)=>{var s=t=>{try{o(r.next(t))}catch(e){i(e)}},a=t=>{try{o(r.throw(t))}catch(e){i(e)}},o=t=>t.done?n(t.value):Promise.resolve(t.value).then(s,a);o((r=r.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 r,n,i,s,a,o,l,c,u,h,d,p,f,g,m,_,y,v,w,b,A,E,x,k,S,N,P,C,T,R,M,G,B,I,O,F,U,L,D,j,H,W,Q,z,V,K,J,q,Y,Z,X,$,tt,et,rt,nt,it,st,at,ot,lt,ct,ut,ht,dt,pt,ft,gt,mt,_t,yt,vt,wt,bt,At,Et,xt,kt,St,Nt,Pt,Ct,Tt,Rt,Mt,Gt,Bt,It,Ot,Ft,Ut,Lt,Dt,jt,Ht,Wt,Qt,zt,Vt,Kt,Jt,qt,Yt,Zt,Xt,$t,te,ee,re,ne,ie,se,ae,oe,le,ce,ue,he,de,pe,fe,ge,me,_e,ye,ve,we,be,Ae,Ee,xe,ke,Se,Ne,Pe,Ce,Te,Re,Me,Ge,Be,Ie,Oe,Fe,Ue,Le,De,je,He,We,Qe,ze,Ve,Ke,Je,qe,Ye,Ze,Xe,$e,tr,er,rr,nr,ir,sr,ar,or,lr,cr,ur,hr,dr,pr,fr,gr,mr,_r,yr,vr,wr,br,Ar,Er,xr,kr,Sr,Nr;function Pr(t,e,r){const n=e.split("|").map((t=>t.trim()));for(let s=0;s<n.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.${r}`,i.value=t,i}function Cr(t){return __async(this,null,(function*(){const e=Object.keys(t);return(yield Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,r,n)=>(t[e[n]]=r,t)),{})}))}function Tr(t,e,r){for(let n in e){let i=e[n];const s=r?r[n]:null;s&&Pr(i,s,n),Object.defineProperty(t,n,{enumerable:!0,value:i,writable:!1})}}function Rr(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=>Rr(t,e))).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let r="0x";for(let n=0;n<t.length;n++)r+=e[t[n]>>4],r+=e[15&t[n]];return r}if("object"==typeof t&&"function"==typeof t.toJSON)return Rr(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 r=Object.keys(t);return r.sort(),"{ "+r.map((r=>`${Rr(r,e)}: ${Rr(t[r],e)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Mr(t,e){return t&&t.code===e}function Gr(t){return Mr(t,"CALL_EXCEPTION")}function Br(t,e,r){let n,i=t;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${Rr(r)}`);for(const t in r){if("shortMessage"===t)continue;const e=r[t];n.push(t+"="+Rr(e))}}n.push(`code=${e}`),n.push("version=6.14.3"),n.length&&(t+=" ("+n.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":n=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(t);break;default:n=new Error(t)}return Tr(n,{code:e}),r&&Object.assign(n,r),null==n.shortMessage&&Tr(n,{shortMessage:i}),n}function Ir(t,e,r,n){if(!t)throw Br(e,r,n)}function Or(t,e,r,n){Ir(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}function Fr(t,e,r){null==r&&(r=""),r&&(r=": "+r),Ir(t>=e,"missing argument"+r,"MISSING_ARGUMENT",{count:t,expectedCount:e}),Ir(t<=e,"too many arguments"+r,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const Ur=["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(r){}return t}),[]);function Lr(t,e,r){if(null==r&&(r=""),t!==e){let t=r,e="new";r&&(t+=".",e+=" "+r),Ir(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function Dr(t,e,r){if(t instanceof Uint8Array)return r?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 r=2;for(let n=0;n<e.length;n++)e[n]=parseInt(t.substring(r,r+2),16),r+=2;return e}Or(!1,"invalid BytesLike value",e||"value",t)}function jr(t,e){return Dr(t,e,!1)}function Hr(t,e){return Dr(t,e,!0)}function Wr(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 Qr(t){return Wr(t,!0)||t instanceof Uint8Array}const zr="0123456789abcdef";function Vr(t){const e=jr(t);let r="0x";for(let n=0;n<e.length;n++){const t=e[n];r+=zr[(240&t)>>4]+zr[15&t]}return r}function Kr(t){return"0x"+t.map((t=>Vr(t).substring(2))).join("")}function Jr(t){return Wr(t,!0)?(t.length-2)/2:jr(t).length}function qr(t,e,r){const n=jr(t);return null!=r&&r>n.length&&Ir(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),Vr(n.slice(null==e?0:e,null==r?n.length:r))}function Yr(t,e,r){const n=jr(t);Ir(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),r?i.set(n,e-n.length):i.set(n,0),Vr(i)}function Zr(t,e){return Yr(t,e,!0)}const Xr=BigInt(0),$r=BigInt(1),tn=9007199254740991;function en(t,e){const r=an(t,"value"),n=BigInt(cn(e,"width"));if(Ir(r>>n===Xr,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),r>>n-$r){return-((~r&($r<<n)-$r)+$r)}return r}function rn(t,e){let r=sn(t,"value");const n=BigInt(cn(e,"width")),i=$r<<n-$r;if(r<Xr){r=-r,Ir(r<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return(~r&($r<<n)-$r)+$r}return Ir(r<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),r}function nn(t,e){const r=an(t,"value"),n=BigInt(cn(e,"bits"));return r&($r<<n)-$r}function sn(t,e){switch(typeof t){case"bigint":return t;case"number":return Or(Number.isInteger(t),"underflow",e||"value",t),Or(t>=-tn&&t<=tn,"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(r){Or(!1,`invalid BigNumberish string: ${r.message}`,e||"value",t)}}Or(!1,"invalid BigNumberish value",e||"value",t)}function an(t,e){const r=sn(t,e);return Ir(r>=Xr,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),r}const on="0123456789abcdef";function ln(t){if(t instanceof Uint8Array){let e="0x0";for(const r of t)e+=on[r>>4],e+=on[15&r];return BigInt(e)}return sn(t)}function cn(t,e){switch(typeof t){case"bigint":return Or(t>=-tn&&t<=tn,"overflow",e||"value",t),Number(t);case"number":return Or(Number.isInteger(t),"underflow",e||"value",t),Or(t>=-tn&&t<=tn,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return cn(BigInt(t),e)}catch(r){Or(!1,`invalid numeric string: ${r.message}`,e||"value",t)}}Or(!1,"invalid numeric value",e||"value",t)}function un(t,e){let r=an(t,"value").toString(16);if(null==e)r.length%2&&(r="0"+r);else{const n=cn(e,"width");for(Ir(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<2*n;)r="0"+r}return"0x"+r}function hn(t){const e=an(t,"value");if(e===Xr)return new Uint8Array([]);let r=e.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let i=0;i<n.length;i++){const t=2*i;n[i]=parseInt(r.substring(t,t+2),16)}return n}function dn(t){let e=Vr(Qr(t)?t:hn(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const pn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const fn=BigInt(58);class gn{constructor(t,e,n){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,r,void 0),__privateSet(this,r,e),Tr(this,{emitter:t,filter:n})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,r)&&(yield this.emitter.off(this.filter,__privateGet(this,r)))}))}}function mn(t,e,r,n,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return"OVERRUN"===t?r.length-e-1:0}r=new WeakMap;const _n=Object.freeze({error:function(t,e,r,n,i){Or(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:mn,replace:function(t,e,r,n,i){return"OVERLONG"===t?(Or("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),mn(t,e,r))}});function yn(t,e){Or("string"==typeof t,"invalid string value","str",t),null!=e&&(!function(t){Ir(Ur.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let r=[];for(let n=0;n<t.length;n++){const e=t.charCodeAt(n);if(e<128)r.push(e);else if(e<2048)r.push(e>>6|192),r.push(63&e|128);else if(55296==(64512&e)){n++;const i=t.charCodeAt(n);Or(n<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const s=65536+((1023&e)<<10)+(1023&i);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(e>>12|224),r.push(e>>6&63|128),r.push(63&e|128)}return new Uint8Array(r)}function vn(t,e){return r=function(t,e){null==e&&(e=_n.error);const r=jr(t,"bytes"),n=[];let i=0;for(;i<r.length;){const t=r[i++];if(!(t>>7)){n.push(t);continue}let s=null,a=null;if(192==(224&t))s=1,a=127;else if(224==(240&t))s=2,a=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,r,n);continue}s=3,a=65535}if(i-1+s>=r.length){i+=e("OVERRUN",i-1,r,n);continue}let o=t&(1<<8-s-1)-1;for(let l=0;l<s;l++){let t=r[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,r,n),o=null;break}o=o<<6|63&t,i++}null!==o&&(o>1114111?i+=e("OUT_OF_RANGE",i-1-s,r,n,o):o>=55296&&o<=57343?i+=e("UTF16_SURROGATE",i-1-s,r,n,o):o<=a?i+=e("OVERLONG",i-1-s,r,n,o):n.push(o))}return n}(t,e),r.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("");var r}function wn(t){return function(e,r){return __async(this,null,(function*(){Ir(null==r||!r.cancelled,"request cancelled before sending","CANCELLED");const n=e.url.split(":")[0].toLowerCase();Ir("http"===n||"https"===n,`unsupported protocol ${n}`,"UNSUPPORTED_OPERATION",{info:{protocol:n},operation:"request"}),Ir("https"===n||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const s=new AbortController,a=setTimeout((()=>{i=Br("request timeout","TIMEOUT"),s.abort()}),e.timeout);r&&r.addListener((()=>{i=Br("request cancelled","CANCELLED"),s.abort()}));const o=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,o)}catch(d){if(clearTimeout(a),i)throw i;throw d}clearTimeout(a);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 bn=wn();const An=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),En=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let xn=!1;function kn(t,e){return __async(this,null,(function*(){try{const e=t.match(An);if(!e)throw new Error("invalid data");return new Bn(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return jr(e)}(e[3]):yn(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new Bn(599,"BAD REQUEST (invalid data: URI)",{},null,new Mn(t))}}))}function Sn(t){return function(e,r){return __async(this,null,(function*(){try{const r=e.match(En);if(!r)throw new Error("invalid link");return new Mn(`${t}${r[2]}`)}catch(r){return new Bn(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Mn(e))}}))}}const Nn={data:kn,ipfs:Sn("https://gateway.ipfs.io/ipfs/")},Pn=new WeakMap;class Cn{constructor(t){__privateAdd(this,n,void 0),__privateAdd(this,i,void 0),__privateSet(this,n,[]),__privateSet(this,i,!1),Pn.set(t,(()=>{if(!__privateGet(this,i)){__privateSet(this,i,!0);for(const t of __privateGet(this,n))setTimeout((()=>{t()}),0);__privateSet(this,n,[])}}))}addListener(t){Ir(!__privateGet(this,i),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),__privateGet(this,n).push(t)}get cancelled(){return __privateGet(this,i)}checkSignal(){Ir(!this.cancelled,"cancelled","CANCELLED",{})}}function Tn(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}n=new WeakMap,i=new WeakMap;const Rn=class t{constructor(t){__privateAdd(this,w),__privateAdd(this,s,void 0),__privateAdd(this,a,void 0),__privateAdd(this,o,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,v,void 0),__privateSet(this,u,String(t)),__privateSet(this,s,!1),__privateSet(this,a,!0),__privateSet(this,o,{}),__privateSet(this,l,""),__privateSet(this,c,3e5),__privateSet(this,y,{slotInterval:250,maxAttempts:12}),__privateSet(this,v,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,yn(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,yn(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,o));return __privateGet(this,p)&&(t.authorization=`Basic ${function(t){const e=jr(t);let r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return btoa(r)}(yn(__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,o)[String(t).toLowerCase()]=String(e)}clearHeaders(){__privateSet(this,o,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return __privateGet(this,p)||null}setCredentials(t,e){Or(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),__privateSet(this,p,`${t}:${e}`)}get allowGzip(){return __privateGet(this,a)}set allowGzip(t){__privateSet(this,a,!!t)}get allowInsecureAuthentication(){return!!__privateGet(this,s)}set allowInsecureAuthentication(t){__privateSet(this,s,!!t)}get timeout(){return __privateGet(this,c)}set timeout(t){Or(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,v)||bn}set getUrlFunc(t){__privateSet(this,v,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${__privateGet(this,h)?Vr(__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 Ir(null==__privateGet(this,_),"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),__privateSet(this,_,new Cn(this)),__privateMethod(this,w,b).call(this,0,In()+this.timeout,0,this,new Bn(0,"",{},null,this))}cancel(){Ir(null!=__privateGet(this,_),"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Pn.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(e){const r=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();Ir("GET"===this.method&&("https"!==r||"http"!==n)&&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,o,Object.assign({},__privateGet(this,o))),__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,o,Object.assign({},__privateGet(this,o))),__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,v,__privateGet(this,v)),e}static lockConfig(){xn=!0}static getGateway(t){return Nn[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(xn)throw new Error("gateways locked");Nn[t]=e}static registerGetUrl(t){if(xn)throw new Error("gateways locked");bn=t}static createGetUrlFunc(t){return wn(t)}static createDataGateway(){return kn}static createIpfsGatewayFunc(t){return Sn(t)}};s=new WeakMap,a=new WeakMap,o=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,v=new WeakMap,w=new WeakSet,b=function(t,e,r,n,i){return __async(this,null,(function*(){var s,a,o;if(t>=__privateGet(this,y).maxAttempts)return i.makeServerError("exceeded maximum retry limit");Ir(In()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:n}),r>0&&(yield function(t){return new Promise((e=>setTimeout(e,t)))}(r));let l=this.clone();const c=(l.url.split(":")[0]||"").toLowerCase();if(c in Nn){const t=yield Nn[c](l.url,Tn(__privateGet(n,_)));if(t instanceof Bn){let e=t;if(this.processFunc){Tn(__privateGet(n,_));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,Tn(__privateGet(n,_)));let h=new Bn(u.statusCode,u.statusMessage,u.headers,u.body,n);if(301===h.statusCode||302===h.statusCode){try{const r=h.headers.location||"";return __privateMethod(s=l.redirect(r),w,b).call(s,t+1,e,0,n,h)}catch(d){}return h}if(429===h.statusCode&&(null==this.retryFunc||(yield this.retryFunc(l,h,t)))){const r=h.headers["retry-after"];let i=__privateGet(this,y).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof r&&r.match(/^[1-9][0-9]*$/)&&(i=parseInt(r)),__privateMethod(a=l.clone(),w,b).call(a,t+1,e,i,n,h)}if(this.processFunc){Tn(__privateGet(n,_));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 r=__privateGet(this,y).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return d.stall>=0&&(r=d.stall),__privateMethod(o=l.clone(),w,b).call(o,t+1,e,r,n,h)}}return h}))};let Mn=Rn;const Gn=class t{constructor(t,e,r,n,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(r).reduce(((t,e)=>(t[e.toLowerCase()]=String(r[e]),t)),{})),__privateSet(this,k,null==n?null:new Uint8Array(n)),__privateSet(this,S,i||null),__privateSet(this,N,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${__privateGet(this,k)?Vr(__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)?"":vn(__privateGet(this,k))}catch(t){Ir(!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){Ir(!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 r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,r){let n;n=e?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:`CLIENT ESCALATED SERVER ERROR (${e=`${this.statusCode} ${this.statusMessage}`})`;const i=new t(599,n,this.headers,this.body,__privateGet(this,S)||void 0);return __privateSet(i,N,{message:e,error:r}),i}throwThrottleError(t,e){null==e?e=-1:Or(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw Tr(r,{stall:e,throttle:!0}),r}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 r=null;this.request&&(r=this.request.url);let n=null;try{__privateGet(this,k)&&(n=vn(__privateGet(this,k)))}catch(i){}Ir(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:n,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};A=new WeakMap,E=new WeakMap,x=new WeakMap,k=new WeakMap,S=new WeakMap,N=new WeakMap;let Bn=Gn;function In(){return(new Date).getTime()}const On=BigInt(-1),Fn=BigInt(0),Un=BigInt(1),Ln=BigInt(5),Dn={};let jn="0000";for(;jn.length<80;)jn+=jn;function Hn(t){let e=jn;for(;e.length<t;)e+=e;return BigInt("1"+e.substring(0,t))}function Wn(t,e,r){const n=BigInt(e.width);if(e.signed){const e=Un<<n-Un;Ir(null==r||t>=-e&&t<e,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:t}),t=t>Fn?en(nn(t,n),n):-en(nn(-t,n),n)}else{const e=Un<<n;Ir(null==r||t>=0&&t<e,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:t}),t=(t%e+e)%e&e-Un}return t}function Qn(t){"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,r=128,n=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]+)$/);Or(i,"invalid fixed format","format",t),e="u"!==i[1],r=parseInt(i[2]),n=parseInt(i[3])}else if(t){const i=t,s=(t,e,r)=>null==i[t]?r:(Or(typeof i[t]===e,"invalid fixed format ("+t+" not "+e+")","format."+t,i[t]),i[t]);e=s("signed","boolean",e),r=s("width","number",r),n=s("decimals","number",n)}Or(r%8==0,"invalid FixedNumber width (not byte aligned)","format.width",r),Or(n<=80,"invalid FixedNumber decimals (too large)","format.decimals",n);return{signed:e,width:r,decimals:n,name:(e?"":"u")+"fixed"+String(r)+"x"+String(n)}}const zn=class t{constructor(t,e,r){__privateAdd(this,R),__privateAdd(this,G),__privateAdd(this,I),__privateAdd(this,F),__privateAdd(this,L),__privateAdd(this,j),__publicField(this,"format"),__privateAdd(this,P,void 0),__privateAdd(this,C,void 0),__privateAdd(this,T,void 0),__publicField(this,"_value"),Lr(t,Dn,"FixedNumber"),__privateSet(this,C,e),__privateSet(this,P,r);const n=function(t,e){let r="";t<Fn&&(r="-",t*=On);let n=t.toString();if(0===e)return r+n;for(;n.length<=e;)n=jn+n;const i=n.length-e;for(n=n.substring(0,i)+"."+n.substring(i);"0"===n[0]&&"."!==n[1];)n=n.substring(1);for(;"0"===n[n.length-1]&&"."!==n[n.length-2];)n=n.substring(0,n.length-1);return r+n}(e,r.decimals);Tr(this,{format:r.name,_value:n}),__privateSet(this,T,Hn(r.decimals))}get signed(){return __privateGet(this,P).signed}get width(){return __privateGet(this,P).width}get decimals(){return __privateGet(this,P).decimals}get value(){return __privateGet(this,C)}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,F,U).call(this,t)}sub(t){return __privateMethod(this,F,U).call(this,t,"sub")}mulUnsafe(t){return __privateMethod(this,L,D).call(this,t)}mul(t){return __privateMethod(this,L,D).call(this,t,"mul")}mulSignal(t){__privateMethod(this,R,M).call(this,t);const e=__privateGet(this,C)*__privateGet(t,C);return Ir(e%__privateGet(this,T)===Fn,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,G,B).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){Ir(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,M).call(this,t);const e=__privateGet(this,C)*__privateGet(this,T);return Ir(e%__privateGet(t,C)===Fn,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,G,B).call(this,e/__privateGet(t,C),"divSignal")}cmp(t){let e=this.value,r=t.value;const n=this.decimals-t.decimals;return n>0?r*=Hn(n):n<0&&(e*=Hn(-n)),e<r?-1:e>r?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,C);return __privateGet(this,C)<Fn&&(t-=__privateGet(this,T)-Un),t=__privateGet(this,C)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,G,B).call(this,t,"floor")}ceiling(){let t=__privateGet(this,C);return __privateGet(this,C)>Fn&&(t+=__privateGet(this,T)-Un),t=__privateGet(this,C)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,G,B).call(this,t,"ceiling")}round(e){if(null==e&&(e=0),e>=this.decimals)return this;const r=this.decimals-e,n=Ln*Hn(r-1);let i=this.value+n;const s=Hn(r);return i=i/s*s,Wn(i,__privateGet(this,P),"round"),new t(Dn,i,__privateGet(this,P))}isZero(){return __privateGet(this,C)===Fn}isNegative(){return __privateGet(this,C)<Fn}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return t.fromString(this.toString(),e)}static fromValue(e,r,n){const i=null==r?0:cn(r),s=Qn(n);let a=sn(e,"value");const o=i-s.decimals;if(o>0){const t=Hn(o);Ir(a%t===Fn,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),a/=t}else o<0&&(a*=Hn(-o));return Wn(a,s,"fromValue"),new t(Dn,a,s)}static fromString(e,r){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Or(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const i=Qn(r);let s=n[2]||"0",a=n[3]||"";for(;a.length<i.decimals;)a+=jn;Ir(a.substring(i.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),a=a.substring(0,i.decimals);const o=BigInt(n[1]+s+a);return Wn(o,i,"fromString"),new t(Dn,o,i)}static fromBytes(e,r){let n=ln(jr(e,"value"));const i=Qn(r);return i.signed&&(n=en(n,i.width)),Wn(n,i,"fromBytes"),new t(Dn,n,i)}};P=new WeakMap,C=new WeakMap,T=new WeakMap,R=new WeakSet,M=function(t){Or(this.format===t.format,"incompatible format; use fixedNumber.toFormat","other",t)},G=new WeakSet,B=function(t,e){return t=Wn(t,__privateGet(this,P),e),new zn(Dn,t,__privateGet(this,P))},I=new WeakSet,O=function(t,e){return __privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)+__privateGet(t,C),e)},F=new WeakSet,U=function(t,e){return __privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)-__privateGet(t,C),e)},L=new WeakSet,D=function(t,e){return __privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)*__privateGet(t,C)/__privateGet(this,T),e)},j=new WeakSet,H=function(t,e){return Ir(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)*__privateGet(this,T)/__privateGet(t,C),e)};let Vn=zn;function Kn(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Jn(t,e,r){let n=0;for(let i=0;i<r;i++)n=256*n+t[e+i];return n}function qn(t,e,r,n){const i=[];for(;r<e+1+n;){const s=Yn(t,r);i.push(s.result),Ir((r+=s.consumed)<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:t,length:n,offset:e})}return{consumed:1+n,result:i}}function Yn(t,e){Ir(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const r=e=>{Ir(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const n=t[e]-247;r(e+1+n);const i=Jn(t,e+1,n);return r(e+1+n+i),qn(t,e,e+1+n,n+i)}if(t[e]>=192){const n=t[e]-192;return r(e+1+n),qn(t,e,e+1,n)}if(t[e]>=184){const n=t[e]-183;r(e+1+n);const i=Jn(t,e+1,n);r(e+1+n+i);return{consumed:1+n+i,result:Vr(t.slice(e+1+n,e+1+n+i))}}if(t[e]>=128){const n=t[e]-128;r(e+1+n);return{consumed:1+n,result:Vr(t.slice(e+1,e+1+n))}}return{consumed:1,result:Kn(t[e])}}function Zn(t){const e=jr(t,"data"),r=Yn(e,0);return Or(r.consumed===e.length,"unexpected junk after rlp payload","data",t),r.result}function Xn(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function $n(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat($n(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=Xn(e.length);return r.unshift(247+r.length),r.concat(e)}const e=Array.prototype.slice.call(jr(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=Xn(e.length);return r.unshift(183+r.length),r.concat(e)}const ti="0123456789abcdef";function ei(t){let e="0x";for(const r of $n(t))e+=ti[r>>4],e+=ti[15&r];return e}const ri=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ni(t,e){let r=18;if("string"==typeof e){const t=ri.indexOf(e);Or(t>=0,"invalid unit","unit",e),r=3*t}else null!=e&&(r=cn(e,"unit"));return Vn.fromValue(t,r,{decimals:r,width:512}).toString()}function ii(t,e){Or("string"==typeof t,"value must be a string","value",t);let r=18;if("string"==typeof e){const t=ri.indexOf(e);Or(t>=0,"invalid unit","unit",e),r=3*t}else null!=e&&(r=cn(e,"unit"));return Vn.fromString(t,{decimals:r,width:512}).value}const si=32,ai=new Uint8Array(si),oi=["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 r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw r.error=e,r}function pi(t,e,r){return t.indexOf(null)>=0?e.map(((t,e)=>t instanceof fi?pi(ui(t),t,r):t)):t.reduce(((t,n,i)=>{let s=e.getValue(n);return n in t||(r&&s instanceof fi&&(s=pi(ui(s),s,r)),t[n]=s),t}),{})}W=new WeakMap;let fi=class t extends Array{constructor(...t){const e=t[0];let r=t[1],n=(t[2]||[]).slice(),i=!0;e!==li&&(r=t,n=[],i=!1),super(r.length),__privateAdd(this,W,void 0),r.forEach(((t,e)=>{this[e]=t}));const s=n.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(hi(this,Object.freeze(r.map(((t,e)=>{const r=n[e];return null!=r&&1===s.get(r)?r:null})))),__privateSet(this,W,[]),null==__privateGet(this,W)&&__privateGet(this,W),!i)return;Object.freeze(this);const a=new Proxy(this,{get:(t,e,r)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const r=cn(e,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=t[r];return n instanceof Error&&di(`index ${r}`,n),n}if(oi.indexOf(e)>=0)return Reflect.get(t,e,r);const n=t[e];if(n instanceof Function)return function(...e){return n.apply(this===r?t:this,e)};if(!(e in t))return t.getValue.apply(this===r?t:this,[e])}return Reflect.get(t,e,r)}});return hi(a,ui(this)),a}toArray(e){const r=[];return this.forEach(((n,i)=>{n instanceof Error&&di(`index ${i}`,n),e&&n instanceof t&&(n=n.toArray(e)),r.push(n)})),r}toObject(t){const e=ui(this);return e.reduce(((r,n,i)=>(Ir(null!=n,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),pi(e,this,t))),{})}slice(e,r){null==e&&(e=0),e<0&&(e+=this.length)<0&&(e=0),null==r&&(r=this.length),r<0&&(r+=this.length)<0&&(r=0),r>this.length&&(r=this.length);const n=ui(this),i=[],s=[];for(let t=e;t<r;t++)i.push(this[t]),s.push(n[t]);return new t(li,i,s)}filter(e,r){const n=ui(this),i=[],s=[];for(let t=0;t<this.length;t++){const a=this[t];a instanceof Error&&di(`index ${t}`,a),e.call(r,a,t,this)&&(i.push(a),s.push(n[t]))}return new t(li,i,s)}map(t,e){const r=[];for(let n=0;n<this.length;n++){const i=this[n];i instanceof Error&&di(`index ${n}`,i),r.push(t.call(e,i,n,this))}return r}getValue(t){const e=ui(this).indexOf(t);if(-1===e)return;const r=this[e];return r instanceof Error&&di(`property ${JSON.stringify(t)}`,r.error),r}static fromItems(e,r){return new t(li,e,r)}};function gi(t){let e=hn(t);return Ir(e.length<=si,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:si,offset:e.length}),e.length!==si&&(e=Hr(Kr([ai.slice(e.length%si),e]))),e}class mi{constructor(t,e,r,n){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),Tr(this,{name:t,type:e,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){Or(!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 Kr(__privateGet(this,Q))}get length(){return __privateGet(this,z)}appendWriter(t){return __privateMethod(this,V,K).call(this,Hr(t.data))}writeBytes(t){let e=Hr(t);const r=e.length%si;return r&&(e=Hr(Kr([e,ai.slice(r)]))),__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(ai),__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,Y=new WeakMap,Z=new WeakMap,X=new WeakMap,$=new WeakSet,tt=function(t){var e;if(__privateGet(this,Z))return __privateMethod(e=__privateGet(this,Z),$,tt).call(e,t);__privateSet(this,Y,__privateGet(this,Y)+t),Ir(__privateGet(this,X)<1||__privateGet(this,Y)<=__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:Hr(__privateGet(this,J)),offset:__privateGet(this,q),length:t,info:{bytesRead:__privateGet(this,Y),dataLength:this.dataLength}})},et=new WeakSet,rt=function(t,e,r){let n=Math.ceil(e/si)*si;return __privateGet(this,q)+n>__privateGet(this,J).length&&(this.allowLoose&&r&&__privateGet(this,q)+e<=__privateGet(this,J).length?n=e:Ir(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Hr(__privateGet(this,J)),length:__privateGet(this,J).length,offset:__privateGet(this,q)+n})),__privateGet(this,J).slice(__privateGet(this,q),__privateGet(this,q)+n)};let yi=class t{constructor(t,e,r){__privateAdd(this,$),__privateAdd(this,et),__publicField(this,"allowLoose"),__privateAdd(this,J,void 0),__privateAdd(this,q,void 0),__privateAdd(this,Y,void 0),__privateAdd(this,Z,void 0),__privateAdd(this,X,void 0),Tr(this,{allowLoose:!!e}),__privateSet(this,J,Hr(t)),__privateSet(this,Y,0),__privateSet(this,Z,null),__privateSet(this,X,null!=r?r:1024),__privateSet(this,q,0)}get data(){return Vr(__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 r=new t(__privateGet(this,J).slice(__privateGet(this,q)+e),this.allowLoose,__privateGet(this,X));return __privateSet(r,Z,this),r}readBytes(t,e){let r=__privateMethod(this,et,rt).call(this,0,t,!!e);return __privateMethod(this,$,tt).call(this,t),__privateSet(this,q,__privateGet(this,q)+r.length),r.slice(0,t)}readValue(){return ln(this.readBytes(si))}readIndex(){return cn(ln(this.readBytes(si)))}};function vi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function wi(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){wi(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}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 Pi{clone(){return this._cloneInto()}}function Ci(t){const e=e=>t().update(Ni(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.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 Ri extends Pi{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");vi(t.outputLen),vi(t.blockLen)}(t);const r=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 n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);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),wi(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:r,finished:n,destroyed:i,blockLen:s,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Mi=(t,e,r)=>new Ri(t,e).update(r).digest();Mi.create=(t,e)=>new Ri(t,e);class Gi extends Pi{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,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:r,blockLen:n}=this,i=(t=Ni(t)).length;for(let s=0;s<i;){const a=Math.min(n-this.pos,i-s);if(a!==n)r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=ki(t);for(;n<=i-s;s+=n)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:r,blockLen:n,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let u=s;u<n;u++)e[u]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s),l=n?4:0,c=n?0:4;t.setUint32(e+l,a,n),t.setUint32(e+c,o,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=ki(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=o/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,c[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:s,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=s,n%e&&t.buffer.set(r),t}}const Bi=(t,e,r)=>t&e^t&r^e&r,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]),Fi=new Uint32Array(64);class Ui extends Gi{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:r,D:n,E:i,F:s,G:a,H:o}=this;return[t,e,r,n,i,s,a,o]}set(t,e,r,n,i,s,a,o){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|a,this.H=0|o}process(t,e){for(let h=0;h<16;h++,e+=4)Fi[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){const t=Fi[h-15],e=Fi[h-2],r=Si(t,7)^Si(t,18)^t>>>3,n=Si(e,17)^Si(e,19)^e>>>10;Fi[h]=n+Fi[h-7]+r+Fi[h-16]|0}let{A:r,B:n,C:i,D:s,E:a,F:o,G:l,H:c}=this;for(let h=0;h<64;h++){const t=c+(Si(a,6)^Si(a,11)^Si(a,25))+((u=a)&o^~u&l)+Ii[h]+Fi[h]|0,e=(Si(r,2)^Si(r,13)^Si(r,22))+Bi(r,n,i)|0;c=l,l=o,o=a,a=s+t|0,s=i,i=n,n=r,r=t+e|0}var u;r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,o=o+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(r,n,i,s,a,o,l,c)}roundClean(){Fi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Li=Ci((()=>new Ui)),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 r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:a}=Hi(t[i],e);[r[i],n[i]]=[s,a]}return[r,n]}const Qi=(t,e,r)=>t<<r|e>>>32-r,zi=(t,e,r)=>e<<r|t>>>32-r,Vi=(t,e,r)=>e<<r-32|t>>>64-r,Ki=(t,e,r)=>t<<r-32|e>>>64-r;const Ji={fromBig:Hi,split:Wi,toBig:(t,e)=>BigInt(t>>>0)<<ji|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:Qi,rotlSL:zi,rotlBH:Vi,rotlBL:Ki,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/__pow(2,32)|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/__pow(2,32)|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/__pow(2,32)|0)|0,add5H:(t,e,r,n,i,s)=>e+r+n+i+s+(t/__pow(2,32)|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[qi,Yi]=(()=>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)))))(),Zi=new Uint32Array(80),Xi=new Uint32Array(80);class $i extends Gi{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:r,Bl:n,Ch:i,Cl:s,Dh:a,Dl:o,Eh:l,El:c,Fh:u,Fl:h,Gh:d,Gl:p,Hh:f,Hl:g}=this;return[t,e,r,n,i,s,a,o,l,c,u,h,d,p,f,g]}set(t,e,r,n,i,s,a,o,l,c,u,h,d,p,f,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|a,this.Dl=0|o,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)Zi[y]=t.getUint32(e),Xi[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){const t=0|Zi[y-15],e=0|Xi[y-15],r=Ji.rotrSH(t,e,1)^Ji.rotrSH(t,e,8)^Ji.shrSH(t,e,7),n=Ji.rotrSL(t,e,1)^Ji.rotrSL(t,e,8)^Ji.shrSL(t,e,7),i=0|Zi[y-2],s=0|Xi[y-2],a=Ji.r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this.Gh,0|this.Gl,0|f,0|g)),({h:m,l:_}=Ji.add(0|this.Hh,0|this.Hl,0|m,0|_)),this.set(r,n,i,s,a,o,l,c,u,h,d,p,f,g,m,_)}roundClean(){Zi.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=Ci((()=>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[rs,ns,is]=[[],[],[]],ss=BigInt(0),as=BigInt(1),os=BigInt(2),ls=BigInt(7),cs=BigInt(256),us=BigInt(113);for(let Pp=0,Cp=as,Tp=1,Rp=0;Pp<24;Pp++){[Tp,Rp]=[Rp,(2*Tp+3*Rp)%5],rs.push(2*(5*Rp+Tp)),ns.push((Pp+1)*(Pp+2)/2%64);let t=ss;for(let e=0;e<7;e++)Cp=(Cp<<as^(Cp>>ls)*us)%cs,Cp&os&&(t^=as<<(as<<BigInt(e))-as);is.push(t)}const[hs,ds]=Wi(is,!0),ps=(t,e,r)=>r>32?Vi(t,e,r):Qi(t,e,r),fs=(t,e,r)=>r>32?Ki(t,e,r):zi(t,e,r);class gs extends Pi{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,vi(r),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 r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let n=0;n<10;n++)r[n]=t[n]^t[n+10]^t[n+20]^t[n+30]^t[n+40];for(let n=0;n<10;n+=2){const e=(n+8)%10,i=(n+2)%10,s=r[i],a=r[i+1],o=ps(s,a,1)^r[e],l=fs(s,a,1)^r[e+1];for(let r=0;r<50;r+=10)t[n+r]^=o,t[n+r+1]^=l}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=ns[r],s=ps(e,i,n),a=fs(e,i,n),o=rs[r];e=t[o],i=t[o+1],t[o]=s,t[o+1]=a}for(let n=0;n<50;n+=10){for(let e=0;e<10;e++)r[e]=t[n+e];for(let e=0;e<10;e++)t[n+e]^=~r[(e+2)%10]&r[(e+4)%10]}t[0]^=hs[n],t[1]^=ds[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){bi(this);const{blockLen:e,state:r}=this,n=(t=Ni(t)).length;for(let i=0;i<n;){const s=Math.min(e-this.pos,n-i);for(let e=0;e<s;e++)r[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:r,blockLen:n}=this;t[r]^=e,128&e&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){bi(this,!1),wi(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=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 vi(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:r,outputLen:n,rounds:i,enableXOF:s}=this;return t||(t=new gs(e,r,n,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=s,t.destroyed=this.destroyed,t}}const ms=((t,e,r)=>Ci((()=>new gs(e,t,r))))(1,136,32);let _s=!1;const ys=function(t){return ms(t)};let vs=ys;function ws(t){const e=jr(t,"data");return Vr(vs(e))}ws._=ys,ws.lock=function(){_s=!0},ws.register=function(t){if(_s)throw new TypeError("keccak256 is locked");vs=t},Object.freeze(ws);const bs=function(t){return function(t){switch(t){case"sha256":return Li.create();case"sha512":return ts.create()}Or(!1,"invalid hashing algorithm name","algorithm",t)}("sha256").update(t).digest()};let As=bs,Es=!1;function xs(t){const e=jr(t,"data");return Vr(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,r)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,__spreadValues=(t,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(t,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(t,r,e[r]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__publicField=(t,e,r)=>(__defNormalProp(t,"symbol"!=typeof e?e+"":e,r),r),__accessCheck=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},__privateGet=(t,e,r)=>(__accessCheck(t,e,"read from private field"),r?r.call(t):e.get(t)),__privateAdd=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},__privateSet=(t,e,r,n)=>(__accessCheck(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),__privateWrapper=(t,e,r,n)=>({set _(n){__privateSet(t,e,n,r)},get _(){return __privateGet(t,e,n)}}),__privateMethod=(t,e,r)=>(__accessCheck(t,e,"access private method"),r),__superGet=(t,e,r)=>__reflectGet(__getProtoOf(t),r,e),__async=(t,e,r)=>new Promise(((n,i)=>{var s=t=>{try{o(r.next(t))}catch(e){i(e)}},a=t=>{try{o(r.throw(t))}catch(e){i(e)}},o=t=>t.done?n(t.value):Promise.resolve(t.value).then(s,a);o((r=r.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 r,n,i,s,a,o,l,c,u,h,d,p,f,g,m,y,_,v,w,b,A,E,x,k,S,N,P,C,T,R,M,G,B,I,O,F,U,L,D,j,H,W,Q,z,V,K,J,q,Y,Z,X,$,tt,et,rt,nt,it,st,at,ot,lt,ct,ut,ht,dt,pt,ft,gt,mt,yt,_t,vt,wt,bt,At,Et,xt,kt,St,Nt,Pt,Ct,Tt,Rt,Mt,Gt,Bt,It,Ot,Ft,Ut,Lt,Dt,jt,Ht,Wt,Qt,zt,Vt,Kt,Jt,qt,Yt,Zt,Xt,$t,te,ee,re,ne,ie,se,ae,oe,le,ce,ue,he,de,pe,fe,ge,me,ye,_e,ve,we,be,Ae,Ee,xe,ke,Se,Ne,Pe,Ce,Te,Re,Me,Ge,Be,Ie,Oe,Fe,Ue,Le,De,je,He,We,Qe,ze,Ve,Ke,Je,qe,Ye,Ze,Xe,$e,tr,er,rr,nr,ir,sr,ar,or,lr,cr,ur,hr,dr,pr,fr,gr,mr,yr,_r,vr,wr,br,Ar,Er,xr,kr,Sr,Nr;function Pr(t,e,r){const n=e.split("|").map((t=>t.trim()));for(let s=0;s<n.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.${r}`,i.value=t,i}function Cr(t){return __async(this,null,(function*(){const e=Object.keys(t);return(yield Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,r,n)=>(t[e[n]]=r,t)),{})}))}function Tr(t,e,r){for(let n in e){let i=e[n];const s=r?r[n]:null;s&&Pr(i,s,n),Object.defineProperty(t,n,{enumerable:!0,value:i,writable:!1})}}function Rr(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=>Rr(t,e))).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let r="0x";for(let n=0;n<t.length;n++)r+=e[t[n]>>4],r+=e[15&t[n]];return r}if("object"==typeof t&&"function"==typeof t.toJSON)return Rr(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 r=Object.keys(t);return r.sort(),"{ "+r.map((r=>`${Rr(r,e)}: ${Rr(t[r],e)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Mr(t,e){return t&&t.code===e}function Gr(t){return Mr(t,"CALL_EXCEPTION")}function Br(t,e,r){let n,i=t;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${Rr(r)}`);for(const t in r){if("shortMessage"===t)continue;const e=r[t];n.push(t+"="+Rr(e))}}n.push(`code=${e}`),n.push("version=6.14.3"),n.length&&(t+=" ("+n.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":n=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(t);break;default:n=new Error(t)}return Tr(n,{code:e}),r&&Object.assign(n,r),null==n.shortMessage&&Tr(n,{shortMessage:i}),n}function Ir(t,e,r,n){if(!t)throw Br(e,r,n)}function Or(t,e,r,n){Ir(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}function Fr(t,e,r){null==r&&(r=""),r&&(r=": "+r),Ir(t>=e,"missing argument"+r,"MISSING_ARGUMENT",{count:t,expectedCount:e}),Ir(t<=e,"too many arguments"+r,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const Ur=["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(r){}return t}),[]);function Lr(t,e,r){if(null==r&&(r=""),t!==e){let t=r,e="new";r&&(t+=".",e+=" "+r),Ir(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function Dr(t,e,r){if(t instanceof Uint8Array)return r?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 r=2;for(let n=0;n<e.length;n++)e[n]=parseInt(t.substring(r,r+2),16),r+=2;return e}Or(!1,"invalid BytesLike value",e||"value",t)}function jr(t,e){return Dr(t,e,!1)}function Hr(t,e){return Dr(t,e,!0)}function Wr(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 Qr(t){return Wr(t,!0)||t instanceof Uint8Array}const zr="0123456789abcdef";function Vr(t){const e=jr(t);let r="0x";for(let n=0;n<e.length;n++){const t=e[n];r+=zr[(240&t)>>4]+zr[15&t]}return r}function Kr(t){return"0x"+t.map((t=>Vr(t).substring(2))).join("")}function Jr(t){return Wr(t,!0)?(t.length-2)/2:jr(t).length}function qr(t,e,r){const n=jr(t);return null!=r&&r>n.length&&Ir(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),Vr(n.slice(null==e?0:e,null==r?n.length:r))}function Yr(t,e,r){const n=jr(t);Ir(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),r?i.set(n,e-n.length):i.set(n,0),Vr(i)}function Zr(t,e){return Yr(t,e,!0)}const Xr=BigInt(0),$r=BigInt(1),tn=9007199254740991;function en(t,e){const r=an(t,"value"),n=BigInt(cn(e,"width"));if(Ir(r>>n===Xr,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),r>>n-$r){return-((~r&($r<<n)-$r)+$r)}return r}function rn(t,e){let r=sn(t,"value");const n=BigInt(cn(e,"width")),i=$r<<n-$r;if(r<Xr){r=-r,Ir(r<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return(~r&($r<<n)-$r)+$r}return Ir(r<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),r}function nn(t,e){const r=an(t,"value"),n=BigInt(cn(e,"bits"));return r&($r<<n)-$r}function sn(t,e){switch(typeof t){case"bigint":return t;case"number":return Or(Number.isInteger(t),"underflow",e||"value",t),Or(t>=-tn&&t<=tn,"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(r){Or(!1,`invalid BigNumberish string: ${r.message}`,e||"value",t)}}Or(!1,"invalid BigNumberish value",e||"value",t)}function an(t,e){const r=sn(t,e);return Ir(r>=Xr,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),r}const on="0123456789abcdef";function ln(t){if(t instanceof Uint8Array){let e="0x0";for(const r of t)e+=on[r>>4],e+=on[15&r];return BigInt(e)}return sn(t)}function cn(t,e){switch(typeof t){case"bigint":return Or(t>=-tn&&t<=tn,"overflow",e||"value",t),Number(t);case"number":return Or(Number.isInteger(t),"underflow",e||"value",t),Or(t>=-tn&&t<=tn,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return cn(BigInt(t),e)}catch(r){Or(!1,`invalid numeric string: ${r.message}`,e||"value",t)}}Or(!1,"invalid numeric value",e||"value",t)}function un(t,e){let r=an(t,"value").toString(16);if(null==e)r.length%2&&(r="0"+r);else{const n=cn(e,"width");for(Ir(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<2*n;)r="0"+r}return"0x"+r}function hn(t){const e=an(t,"value");if(e===Xr)return new Uint8Array([]);let r=e.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let i=0;i<n.length;i++){const t=2*i;n[i]=parseInt(r.substring(t,t+2),16)}return n}function dn(t){let e=Vr(Qr(t)?t:hn(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const pn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const fn=BigInt(58);class gn{constructor(t,e,n){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,r,void 0),__privateSet(this,r,e),Tr(this,{emitter:t,filter:n})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,r)&&(yield this.emitter.off(this.filter,__privateGet(this,r)))}))}}function mn(t,e,r,n,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return"OVERRUN"===t?r.length-e-1:0}r=new WeakMap;const yn=Object.freeze({error:function(t,e,r,n,i){Or(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:mn,replace:function(t,e,r,n,i){return"OVERLONG"===t?(Or("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),mn(t,e,r))}});function _n(t,e){Or("string"==typeof t,"invalid string value","str",t),null!=e&&(!function(t){Ir(Ur.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let r=[];for(let n=0;n<t.length;n++){const e=t.charCodeAt(n);if(e<128)r.push(e);else if(e<2048)r.push(e>>6|192),r.push(63&e|128);else if(55296==(64512&e)){n++;const i=t.charCodeAt(n);Or(n<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const s=65536+((1023&e)<<10)+(1023&i);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(e>>12|224),r.push(e>>6&63|128),r.push(63&e|128)}return new Uint8Array(r)}function vn(t,e){return r=function(t,e){null==e&&(e=yn.error);const r=jr(t,"bytes"),n=[];let i=0;for(;i<r.length;){const t=r[i++];if(!(t>>7)){n.push(t);continue}let s=null,a=null;if(192==(224&t))s=1,a=127;else if(224==(240&t))s=2,a=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,r,n);continue}s=3,a=65535}if(i-1+s>=r.length){i+=e("OVERRUN",i-1,r,n);continue}let o=t&(1<<8-s-1)-1;for(let l=0;l<s;l++){let t=r[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,r,n),o=null;break}o=o<<6|63&t,i++}null!==o&&(o>1114111?i+=e("OUT_OF_RANGE",i-1-s,r,n,o):o>=55296&&o<=57343?i+=e("UTF16_SURROGATE",i-1-s,r,n,o):o<=a?i+=e("OVERLONG",i-1-s,r,n,o):n.push(o))}return n}(t,e),r.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("");var r}function wn(t){return function(e,r){return __async(this,null,(function*(){Ir(null==r||!r.cancelled,"request cancelled before sending","CANCELLED");const n=e.url.split(":")[0].toLowerCase();Ir("http"===n||"https"===n,`unsupported protocol ${n}`,"UNSUPPORTED_OPERATION",{info:{protocol:n},operation:"request"}),Ir("https"===n||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const s=new AbortController,a=setTimeout((()=>{i=Br("request timeout","TIMEOUT"),s.abort()}),e.timeout);r&&r.addListener((()=>{i=Br("request cancelled","CANCELLED"),s.abort()}));const o=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,o)}catch(d){if(clearTimeout(a),i)throw i;throw d}clearTimeout(a);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 bn=wn();const An=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),En=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let xn=!1;function kn(t,e){return __async(this,null,(function*(){try{const e=t.match(An);if(!e)throw new Error("invalid data");return new Bn(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return jr(e)}(e[3]):_n(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new Bn(599,"BAD REQUEST (invalid data: URI)",{},null,new Mn(t))}}))}function Sn(t){return function(e,r){return __async(this,null,(function*(){try{const r=e.match(En);if(!r)throw new Error("invalid link");return new Mn(`${t}${r[2]}`)}catch(r){return new Bn(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Mn(e))}}))}}const Nn={data:kn,ipfs:Sn("https://gateway.ipfs.io/ipfs/")},Pn=new WeakMap;class Cn{constructor(t){__privateAdd(this,n,void 0),__privateAdd(this,i,void 0),__privateSet(this,n,[]),__privateSet(this,i,!1),Pn.set(t,(()=>{if(!__privateGet(this,i)){__privateSet(this,i,!0);for(const t of __privateGet(this,n))setTimeout((()=>{t()}),0);__privateSet(this,n,[])}}))}addListener(t){Ir(!__privateGet(this,i),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),__privateGet(this,n).push(t)}get cancelled(){return __privateGet(this,i)}checkSignal(){Ir(!this.cancelled,"cancelled","CANCELLED",{})}}function Tn(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}n=new WeakMap,i=new WeakMap;const Rn=class t{constructor(t){__privateAdd(this,w),__privateAdd(this,s,void 0),__privateAdd(this,a,void 0),__privateAdd(this,o,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,v,void 0),__privateSet(this,u,String(t)),__privateSet(this,s,!1),__privateSet(this,a,!0),__privateSet(this,o,{}),__privateSet(this,l,""),__privateSet(this,c,3e5),__privateSet(this,_,{slotInterval:250,maxAttempts:12}),__privateSet(this,v,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,_n(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,_n(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,o));return __privateGet(this,p)&&(t.authorization=`Basic ${function(t){const e=jr(t);let r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return btoa(r)}(_n(__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,o)[String(t).toLowerCase()]=String(e)}clearHeaders(){__privateSet(this,o,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return __privateGet(this,p)||null}setCredentials(t,e){Or(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),__privateSet(this,p,`${t}:${e}`)}get allowGzip(){return __privateGet(this,a)}set allowGzip(t){__privateSet(this,a,!!t)}get allowInsecureAuthentication(){return!!__privateGet(this,s)}set allowInsecureAuthentication(t){__privateSet(this,s,!!t)}get timeout(){return __privateGet(this,c)}set timeout(t){Or(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,v)||bn}set getUrlFunc(t){__privateSet(this,v,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${__privateGet(this,h)?Vr(__privateGet(this,h)):"null"}>`}setThrottleParams(t){null!=t.slotInterval&&(__privateGet(this,_).slotInterval=t.slotInterval),null!=t.maxAttempts&&(__privateGet(this,_).maxAttempts=t.maxAttempts)}send(){return Ir(null==__privateGet(this,y),"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),__privateSet(this,y,new Cn(this)),__privateMethod(this,w,b).call(this,0,In()+this.timeout,0,this,new Bn(0,"",{},null,this))}cancel(){Ir(null!=__privateGet(this,y),"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Pn.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(e){const r=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();Ir("GET"===this.method&&("https"!==r||"http"!==n)&&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,o,Object.assign({},__privateGet(this,o))),__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,o,Object.assign({},__privateGet(this,o))),__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,v,__privateGet(this,v)),e}static lockConfig(){xn=!0}static getGateway(t){return Nn[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(xn)throw new Error("gateways locked");Nn[t]=e}static registerGetUrl(t){if(xn)throw new Error("gateways locked");bn=t}static createGetUrlFunc(t){return wn(t)}static createDataGateway(){return kn}static createIpfsGatewayFunc(t){return Sn(t)}};s=new WeakMap,a=new WeakMap,o=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,v=new WeakMap,w=new WeakSet,b=function(t,e,r,n,i){return __async(this,null,(function*(){var s,a,o;if(t>=__privateGet(this,_).maxAttempts)return i.makeServerError("exceeded maximum retry limit");Ir(In()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:n}),r>0&&(yield function(t){return new Promise((e=>setTimeout(e,t)))}(r));let l=this.clone();const c=(l.url.split(":")[0]||"").toLowerCase();if(c in Nn){const t=yield Nn[c](l.url,Tn(__privateGet(n,y)));if(t instanceof Bn){let e=t;if(this.processFunc){Tn(__privateGet(n,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,Tn(__privateGet(n,y)));let h=new Bn(u.statusCode,u.statusMessage,u.headers,u.body,n);if(301===h.statusCode||302===h.statusCode){try{const r=h.headers.location||"";return __privateMethod(s=l.redirect(r),w,b).call(s,t+1,e,0,n,h)}catch(d){}return h}if(429===h.statusCode&&(null==this.retryFunc||(yield this.retryFunc(l,h,t)))){const r=h.headers["retry-after"];let i=__privateGet(this,_).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof r&&r.match(/^[1-9][0-9]*$/)&&(i=parseInt(r)),__privateMethod(a=l.clone(),w,b).call(a,t+1,e,i,n,h)}if(this.processFunc){Tn(__privateGet(n,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 r=__privateGet(this,_).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return d.stall>=0&&(r=d.stall),__privateMethod(o=l.clone(),w,b).call(o,t+1,e,r,n,h)}}return h}))};let Mn=Rn;const Gn=class t{constructor(t,e,r,n,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(r).reduce(((t,e)=>(t[e.toLowerCase()]=String(r[e]),t)),{})),__privateSet(this,k,null==n?null:new Uint8Array(n)),__privateSet(this,S,i||null),__privateSet(this,N,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${__privateGet(this,k)?Vr(__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)?"":vn(__privateGet(this,k))}catch(t){Ir(!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){Ir(!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 r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,r){let n;n=e?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:`CLIENT ESCALATED SERVER ERROR (${e=`${this.statusCode} ${this.statusMessage}`})`;const i=new t(599,n,this.headers,this.body,__privateGet(this,S)||void 0);return __privateSet(i,N,{message:e,error:r}),i}throwThrottleError(t,e){null==e?e=-1:Or(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw Tr(r,{stall:e,throttle:!0}),r}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 r=null;this.request&&(r=this.request.url);let n=null;try{__privateGet(this,k)&&(n=vn(__privateGet(this,k)))}catch(i){}Ir(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:n,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};A=new WeakMap,E=new WeakMap,x=new WeakMap,k=new WeakMap,S=new WeakMap,N=new WeakMap;let Bn=Gn;function In(){return(new Date).getTime()}const On=BigInt(-1),Fn=BigInt(0),Un=BigInt(1),Ln=BigInt(5),Dn={};let jn="0000";for(;jn.length<80;)jn+=jn;function Hn(t){let e=jn;for(;e.length<t;)e+=e;return BigInt("1"+e.substring(0,t))}function Wn(t,e,r){const n=BigInt(e.width);if(e.signed){const e=Un<<n-Un;Ir(null==r||t>=-e&&t<e,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:t}),t=t>Fn?en(nn(t,n),n):-en(nn(-t,n),n)}else{const e=Un<<n;Ir(null==r||t>=0&&t<e,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:t}),t=(t%e+e)%e&e-Un}return t}function Qn(t){"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,r=128,n=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]+)$/);Or(i,"invalid fixed format","format",t),e="u"!==i[1],r=parseInt(i[2]),n=parseInt(i[3])}else if(t){const i=t,s=(t,e,r)=>null==i[t]?r:(Or(typeof i[t]===e,"invalid fixed format ("+t+" not "+e+")","format."+t,i[t]),i[t]);e=s("signed","boolean",e),r=s("width","number",r),n=s("decimals","number",n)}Or(r%8==0,"invalid FixedNumber width (not byte aligned)","format.width",r),Or(n<=80,"invalid FixedNumber decimals (too large)","format.decimals",n);return{signed:e,width:r,decimals:n,name:(e?"":"u")+"fixed"+String(r)+"x"+String(n)}}const zn=class t{constructor(t,e,r){__privateAdd(this,R),__privateAdd(this,G),__privateAdd(this,I),__privateAdd(this,F),__privateAdd(this,L),__privateAdd(this,j),__publicField(this,"format"),__privateAdd(this,P,void 0),__privateAdd(this,C,void 0),__privateAdd(this,T,void 0),__publicField(this,"_value"),Lr(t,Dn,"FixedNumber"),__privateSet(this,C,e),__privateSet(this,P,r);const n=function(t,e){let r="";t<Fn&&(r="-",t*=On);let n=t.toString();if(0===e)return r+n;for(;n.length<=e;)n=jn+n;const i=n.length-e;for(n=n.substring(0,i)+"."+n.substring(i);"0"===n[0]&&"."!==n[1];)n=n.substring(1);for(;"0"===n[n.length-1]&&"."!==n[n.length-2];)n=n.substring(0,n.length-1);return r+n}(e,r.decimals);Tr(this,{format:r.name,_value:n}),__privateSet(this,T,Hn(r.decimals))}get signed(){return __privateGet(this,P).signed}get width(){return __privateGet(this,P).width}get decimals(){return __privateGet(this,P).decimals}get value(){return __privateGet(this,C)}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,F,U).call(this,t)}sub(t){return __privateMethod(this,F,U).call(this,t,"sub")}mulUnsafe(t){return __privateMethod(this,L,D).call(this,t)}mul(t){return __privateMethod(this,L,D).call(this,t,"mul")}mulSignal(t){__privateMethod(this,R,M).call(this,t);const e=__privateGet(this,C)*__privateGet(t,C);return Ir(e%__privateGet(this,T)===Fn,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,G,B).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){Ir(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,M).call(this,t);const e=__privateGet(this,C)*__privateGet(this,T);return Ir(e%__privateGet(t,C)===Fn,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,G,B).call(this,e/__privateGet(t,C),"divSignal")}cmp(t){let e=this.value,r=t.value;const n=this.decimals-t.decimals;return n>0?r*=Hn(n):n<0&&(e*=Hn(-n)),e<r?-1:e>r?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,C);return __privateGet(this,C)<Fn&&(t-=__privateGet(this,T)-Un),t=__privateGet(this,C)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,G,B).call(this,t,"floor")}ceiling(){let t=__privateGet(this,C);return __privateGet(this,C)>Fn&&(t+=__privateGet(this,T)-Un),t=__privateGet(this,C)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,G,B).call(this,t,"ceiling")}round(e){if(null==e&&(e=0),e>=this.decimals)return this;const r=this.decimals-e,n=Ln*Hn(r-1);let i=this.value+n;const s=Hn(r);return i=i/s*s,Wn(i,__privateGet(this,P),"round"),new t(Dn,i,__privateGet(this,P))}isZero(){return __privateGet(this,C)===Fn}isNegative(){return __privateGet(this,C)<Fn}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return t.fromString(this.toString(),e)}static fromValue(e,r,n){const i=null==r?0:cn(r),s=Qn(n);let a=sn(e,"value");const o=i-s.decimals;if(o>0){const t=Hn(o);Ir(a%t===Fn,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),a/=t}else o<0&&(a*=Hn(-o));return Wn(a,s,"fromValue"),new t(Dn,a,s)}static fromString(e,r){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Or(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const i=Qn(r);let s=n[2]||"0",a=n[3]||"";for(;a.length<i.decimals;)a+=jn;Ir(a.substring(i.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),a=a.substring(0,i.decimals);const o=BigInt(n[1]+s+a);return Wn(o,i,"fromString"),new t(Dn,o,i)}static fromBytes(e,r){let n=ln(jr(e,"value"));const i=Qn(r);return i.signed&&(n=en(n,i.width)),Wn(n,i,"fromBytes"),new t(Dn,n,i)}};P=new WeakMap,C=new WeakMap,T=new WeakMap,R=new WeakSet,M=function(t){Or(this.format===t.format,"incompatible format; use fixedNumber.toFormat","other",t)},G=new WeakSet,B=function(t,e){return t=Wn(t,__privateGet(this,P),e),new zn(Dn,t,__privateGet(this,P))},I=new WeakSet,O=function(t,e){return __privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)+__privateGet(t,C),e)},F=new WeakSet,U=function(t,e){return __privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)-__privateGet(t,C),e)},L=new WeakSet,D=function(t,e){return __privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)*__privateGet(t,C)/__privateGet(this,T),e)},j=new WeakSet,H=function(t,e){return Ir(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,M).call(this,t),__privateMethod(this,G,B).call(this,__privateGet(this,C)*__privateGet(this,T)/__privateGet(t,C),e)};let Vn=zn;function Kn(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Jn(t,e,r){let n=0;for(let i=0;i<r;i++)n=256*n+t[e+i];return n}function qn(t,e,r,n){const i=[];for(;r<e+1+n;){const s=Yn(t,r);i.push(s.result),Ir((r+=s.consumed)<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:t,length:n,offset:e})}return{consumed:1+n,result:i}}function Yn(t,e){Ir(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const r=e=>{Ir(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const n=t[e]-247;r(e+1+n);const i=Jn(t,e+1,n);return r(e+1+n+i),qn(t,e,e+1+n,n+i)}if(t[e]>=192){const n=t[e]-192;return r(e+1+n),qn(t,e,e+1,n)}if(t[e]>=184){const n=t[e]-183;r(e+1+n);const i=Jn(t,e+1,n);r(e+1+n+i);return{consumed:1+n+i,result:Vr(t.slice(e+1+n,e+1+n+i))}}if(t[e]>=128){const n=t[e]-128;r(e+1+n);return{consumed:1+n,result:Vr(t.slice(e+1,e+1+n))}}return{consumed:1,result:Kn(t[e])}}function Zn(t){const e=jr(t,"data"),r=Yn(e,0);return Or(r.consumed===e.length,"unexpected junk after rlp payload","data",t),r.result}function Xn(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function $n(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat($n(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=Xn(e.length);return r.unshift(247+r.length),r.concat(e)}const e=Array.prototype.slice.call(jr(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=Xn(e.length);return r.unshift(183+r.length),r.concat(e)}const ti="0123456789abcdef";function ei(t){let e="0x";for(const r of $n(t))e+=ti[r>>4],e+=ti[15&r];return e}const ri=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ni(t,e){let r=18;if("string"==typeof e){const t=ri.indexOf(e);Or(t>=0,"invalid unit","unit",e),r=3*t}else null!=e&&(r=cn(e,"unit"));return Vn.fromValue(t,r,{decimals:r,width:512}).toString()}function ii(t,e){Or("string"==typeof t,"value must be a string","value",t);let r=18;if("string"==typeof e){const t=ri.indexOf(e);Or(t>=0,"invalid unit","unit",e),r=3*t}else null!=e&&(r=cn(e,"unit"));return Vn.fromString(t,{decimals:r,width:512}).value}const si=32,ai=new Uint8Array(si),oi=["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 r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw r.error=e,r}function pi(t,e,r){return t.indexOf(null)>=0?e.map(((t,e)=>t instanceof fi?pi(ui(t),t,r):t)):t.reduce(((t,n,i)=>{let s=e.getValue(n);return n in t||(r&&s instanceof fi&&(s=pi(ui(s),s,r)),t[n]=s),t}),{})}W=new WeakMap;let fi=class t extends Array{constructor(...t){const e=t[0];let r=t[1],n=(t[2]||[]).slice(),i=!0;e!==li&&(r=t,n=[],i=!1),super(r.length),__privateAdd(this,W,void 0),r.forEach(((t,e)=>{this[e]=t}));const s=n.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(hi(this,Object.freeze(r.map(((t,e)=>{const r=n[e];return null!=r&&1===s.get(r)?r:null})))),__privateSet(this,W,[]),null==__privateGet(this,W)&&__privateGet(this,W),!i)return;Object.freeze(this);const a=new Proxy(this,{get:(t,e,r)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const r=cn(e,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=t[r];return n instanceof Error&&di(`index ${r}`,n),n}if(oi.indexOf(e)>=0)return Reflect.get(t,e,r);const n=t[e];if(n instanceof Function)return function(...e){return n.apply(this===r?t:this,e)};if(!(e in t))return t.getValue.apply(this===r?t:this,[e])}return Reflect.get(t,e,r)}});return hi(a,ui(this)),a}toArray(e){const r=[];return this.forEach(((n,i)=>{n instanceof Error&&di(`index ${i}`,n),e&&n instanceof t&&(n=n.toArray(e)),r.push(n)})),r}toObject(t){const e=ui(this);return e.reduce(((r,n,i)=>(Ir(null!=n,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),pi(e,this,t))),{})}slice(e,r){null==e&&(e=0),e<0&&(e+=this.length)<0&&(e=0),null==r&&(r=this.length),r<0&&(r+=this.length)<0&&(r=0),r>this.length&&(r=this.length);const n=ui(this),i=[],s=[];for(let t=e;t<r;t++)i.push(this[t]),s.push(n[t]);return new t(li,i,s)}filter(e,r){const n=ui(this),i=[],s=[];for(let t=0;t<this.length;t++){const a=this[t];a instanceof Error&&di(`index ${t}`,a),e.call(r,a,t,this)&&(i.push(a),s.push(n[t]))}return new t(li,i,s)}map(t,e){const r=[];for(let n=0;n<this.length;n++){const i=this[n];i instanceof Error&&di(`index ${n}`,i),r.push(t.call(e,i,n,this))}return r}getValue(t){const e=ui(this).indexOf(t);if(-1===e)return;const r=this[e];return r instanceof Error&&di(`property ${JSON.stringify(t)}`,r.error),r}static fromItems(e,r){return new t(li,e,r)}};function gi(t){let e=hn(t);return Ir(e.length<=si,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:si,offset:e.length}),e.length!==si&&(e=Hr(Kr([ai.slice(e.length%si),e]))),e}class mi{constructor(t,e,r,n){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),Tr(this,{name:t,type:e,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){Or(!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 Kr(__privateGet(this,Q))}get length(){return __privateGet(this,z)}appendWriter(t){return __privateMethod(this,V,K).call(this,Hr(t.data))}writeBytes(t){let e=Hr(t);const r=e.length%si;return r&&(e=Hr(Kr([e,ai.slice(r)]))),__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(ai),__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,Y=new WeakMap,Z=new WeakMap,X=new WeakMap,$=new WeakSet,tt=function(t){var e;if(__privateGet(this,Z))return __privateMethod(e=__privateGet(this,Z),$,tt).call(e,t);__privateSet(this,Y,__privateGet(this,Y)+t),Ir(__privateGet(this,X)<1||__privateGet(this,Y)<=__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:Hr(__privateGet(this,J)),offset:__privateGet(this,q),length:t,info:{bytesRead:__privateGet(this,Y),dataLength:this.dataLength}})},et=new WeakSet,rt=function(t,e,r){let n=Math.ceil(e/si)*si;return __privateGet(this,q)+n>__privateGet(this,J).length&&(this.allowLoose&&r&&__privateGet(this,q)+e<=__privateGet(this,J).length?n=e:Ir(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Hr(__privateGet(this,J)),length:__privateGet(this,J).length,offset:__privateGet(this,q)+n})),__privateGet(this,J).slice(__privateGet(this,q),__privateGet(this,q)+n)};let _i=class t{constructor(t,e,r){__privateAdd(this,$),__privateAdd(this,et),__publicField(this,"allowLoose"),__privateAdd(this,J,void 0),__privateAdd(this,q,void 0),__privateAdd(this,Y,void 0),__privateAdd(this,Z,void 0),__privateAdd(this,X,void 0),Tr(this,{allowLoose:!!e}),__privateSet(this,J,Hr(t)),__privateSet(this,Y,0),__privateSet(this,Z,null),__privateSet(this,X,null!=r?r:1024),__privateSet(this,q,0)}get data(){return Vr(__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 r=new t(__privateGet(this,J).slice(__privateGet(this,q)+e),this.allowLoose,__privateGet(this,X));return __privateSet(r,Z,this),r}readBytes(t,e){let r=__privateMethod(this,et,rt).call(this,0,t,!!e);return __privateMethod(this,$,tt).call(this,t),__privateSet(this,q,__privateGet(this,q)+r.length),r.slice(0,t)}readValue(){return ln(this.readBytes(si))}readIndex(){return cn(ln(this.readBytes(si)))}};function vi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function wi(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){wi(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}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 Pi{clone(){return this._cloneInto()}}function Ci(t){const e=e=>t().update(Ni(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.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 Ri extends Pi{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");vi(t.outputLen),vi(t.blockLen)}(t);const r=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 n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);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),wi(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:r,finished:n,destroyed:i,blockLen:s,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Mi=(t,e,r)=>new Ri(t,e).update(r).digest();Mi.create=(t,e)=>new Ri(t,e);class Gi extends Pi{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,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:r,blockLen:n}=this,i=(t=Ni(t)).length;for(let s=0;s<i;){const a=Math.min(n-this.pos,i-s);if(a!==n)r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=ki(t);for(;n<=i-s;s+=n)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:r,blockLen:n,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let u=s;u<n;u++)e[u]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s),l=n?4:0,c=n?0:4;t.setUint32(e+l,a,n),t.setUint32(e+c,o,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=ki(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=o/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,c[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:s,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=s,n%e&&t.buffer.set(r),t}}const Bi=(t,e,r)=>t&e^t&r^e&r,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]),Fi=new Uint32Array(64);class Ui extends Gi{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:r,D:n,E:i,F:s,G:a,H:o}=this;return[t,e,r,n,i,s,a,o]}set(t,e,r,n,i,s,a,o){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|a,this.H=0|o}process(t,e){for(let h=0;h<16;h++,e+=4)Fi[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){const t=Fi[h-15],e=Fi[h-2],r=Si(t,7)^Si(t,18)^t>>>3,n=Si(e,17)^Si(e,19)^e>>>10;Fi[h]=n+Fi[h-7]+r+Fi[h-16]|0}let{A:r,B:n,C:i,D:s,E:a,F:o,G:l,H:c}=this;for(let h=0;h<64;h++){const t=c+(Si(a,6)^Si(a,11)^Si(a,25))+((u=a)&o^~u&l)+Ii[h]+Fi[h]|0,e=(Si(r,2)^Si(r,13)^Si(r,22))+Bi(r,n,i)|0;c=l,l=o,o=a,a=s+t|0,s=i,i=n,n=r,r=t+e|0}var u;r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,o=o+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(r,n,i,s,a,o,l,c)}roundClean(){Fi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Li=Ci((()=>new Ui)),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 r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:a}=Hi(t[i],e);[r[i],n[i]]=[s,a]}return[r,n]}const Qi=(t,e,r)=>t<<r|e>>>32-r,zi=(t,e,r)=>e<<r|t>>>32-r,Vi=(t,e,r)=>e<<r-32|t>>>64-r,Ki=(t,e,r)=>t<<r-32|e>>>64-r;const Ji={fromBig:Hi,split:Wi,toBig:(t,e)=>BigInt(t>>>0)<<ji|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:Qi,rotlSL:zi,rotlBH:Vi,rotlBL:Ki,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/__pow(2,32)|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/__pow(2,32)|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/__pow(2,32)|0)|0,add5H:(t,e,r,n,i,s)=>e+r+n+i+s+(t/__pow(2,32)|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[qi,Yi]=(()=>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)))))(),Zi=new Uint32Array(80),Xi=new Uint32Array(80);class $i extends Gi{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:r,Bl:n,Ch:i,Cl:s,Dh:a,Dl:o,Eh:l,El:c,Fh:u,Fl:h,Gh:d,Gl:p,Hh:f,Hl:g}=this;return[t,e,r,n,i,s,a,o,l,c,u,h,d,p,f,g]}set(t,e,r,n,i,s,a,o,l,c,u,h,d,p,f,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|a,this.Dl=0|o,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 _=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({h:i,l:s}=Ji.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:a,l:o}=Ji.add(0|this.Ch,0|this.Cl,0|a,0|o)),({h:l,l: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(r,n,i,s,a,o,l,c,u,h,d,p,f,g,m,y)}roundClean(){Zi.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=Ci((()=>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[rs,ns,is]=[[],[],[]],ss=BigInt(0),as=BigInt(1),os=BigInt(2),ls=BigInt(7),cs=BigInt(256),us=BigInt(113);for(let Pp=0,Cp=as,Tp=1,Rp=0;Pp<24;Pp++){[Tp,Rp]=[Rp,(2*Tp+3*Rp)%5],rs.push(2*(5*Rp+Tp)),ns.push((Pp+1)*(Pp+2)/2%64);let t=ss;for(let e=0;e<7;e++)Cp=(Cp<<as^(Cp>>ls)*us)%cs,Cp&os&&(t^=as<<(as<<BigInt(e))-as);is.push(t)}const[hs,ds]=Wi(is,!0),ps=(t,e,r)=>r>32?Vi(t,e,r):Qi(t,e,r),fs=(t,e,r)=>r>32?Ki(t,e,r):zi(t,e,r);class gs extends Pi{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,vi(r),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 r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let n=0;n<10;n++)r[n]=t[n]^t[n+10]^t[n+20]^t[n+30]^t[n+40];for(let n=0;n<10;n+=2){const e=(n+8)%10,i=(n+2)%10,s=r[i],a=r[i+1],o=ps(s,a,1)^r[e],l=fs(s,a,1)^r[e+1];for(let r=0;r<50;r+=10)t[n+r]^=o,t[n+r+1]^=l}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=ns[r],s=ps(e,i,n),a=fs(e,i,n),o=rs[r];e=t[o],i=t[o+1],t[o]=s,t[o+1]=a}for(let n=0;n<50;n+=10){for(let e=0;e<10;e++)r[e]=t[n+e];for(let e=0;e<10;e++)t[n+e]^=~r[(e+2)%10]&r[(e+4)%10]}t[0]^=hs[n],t[1]^=ds[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){bi(this);const{blockLen:e,state:r}=this,n=(t=Ni(t)).length;for(let i=0;i<n;){const s=Math.min(e-this.pos,n-i);for(let e=0;e<s;e++)r[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:r,blockLen:n}=this;t[r]^=e,128&e&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){bi(this,!1),wi(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=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 vi(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:r,outputLen:n,rounds:i,enableXOF:s}=this;return t||(t=new gs(e,r,n,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=s,t.destroyed=this.destroyed,t}}const ms=((t,e,r)=>Ci((()=>new gs(e,t,r))))(1,136,32);let ys=!1;const _s=function(t){return ms(t)};let vs=_s;function ws(t){const e=jr(t,"data");return Vr(vs(e))}ws._=_s,ws.lock=function(){ys=!0},ws.register=function(t){if(ys)throw new TypeError("keccak256 is locked");vs=t},Object.freeze(ws);const bs=function(t){return function(t){switch(t){case"sha256":return Li.create();case"sha512":return ts.create()}Or(!1,"invalid hashing algorithm name","algorithm",t)}("sha256").update(t).digest()};let As=bs,Es=!1;function xs(t){const e=jr(t,"data");return Vr(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
4
|
const ks=BigInt(0),Ss=BigInt(1),Ns=BigInt(2),Ps=t=>t instanceof Uint8Array,Cs=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Ts(t){if(!Ps(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=Cs[t[r]];return e}function Rs(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function Ms(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function Gs(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 r=new Uint8Array(e/2);for(let n=0;n<r.length;n++){const e=2*n,i=t.slice(e,e+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");r[n]=s}return r}function Bs(t){return Ms(Ts(t))}function Is(t){if(!Ps(t))throw new Error("Uint8Array expected");return Ms(Ts(Uint8Array.from(t).reverse()))}function Os(t,e){return Gs(t.toString(16).padStart(2*e,"0"))}function Fs(t,e){return Os(t,e).reverse()}function Us(t,e,r){let n;if("string"==typeof e)try{n=Gs(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else{if(!Ps(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Ls(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!Ps(t))throw new Error("Uint8Array expected");e.set(t,r),r+=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,r){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 r)throw new Error("hmacFn must be a function");let n=js(t),i=js(t),s=0;const a=()=>{n.fill(1),i.fill(0),s=0},o=(...t)=>r(i,n,...t),l=(t=js())=>{i=o(Hs([0]),t),n=o(),0!==t.length&&(i=o(Hs([1]),t),n=o())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=o();const e=n.slice();r.push(e),t+=n.length}return Ls(...r)};return(t,e)=>{let r;for(a(),l(t);!(r=e(c()));)l();return a(),r}}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,r={}){const n=(e,r,n)=>{const i=Qs[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const s=t[e];if(!(n&&void 0===s||i(s,t)))throw new Error(`Invalid param ${String(e)}=${s} (${typeof s}), expected ${r}`)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(r))n(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,r)=>t|(r?Ss:ks)<<BigInt(e),bytesToHex:Ts,bytesToNumberBE:Bs,bytesToNumberLE:Is,concatBytes:Ls,createHmacDrbg:Ws,ensureBytes:Us,equalBytes:function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0},hexToBytes:Gs,hexToNumber:Ms,numberToBytesBE:Os,numberToBytesLE:Fs,numberToHexUnpadded:Rs,numberToVarBytesBE:function(t){return Gs(Rs(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),Ys=BigInt(3),Zs=BigInt(4),Xs=BigInt(5),$s=BigInt(8);
|
5
5
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ta(t,e){const r=t%e;return r>=Ks?r:e+r}function ea(t,e,r){if(r<=Ks||e<Ks)throw new Error("Expected power/modulo > 0");if(r===Js)return Ks;let n=Js;for(;e>Ks;)e&Js&&(n=n*t%r),t=t*t%r,e>>=Js;return n}function ra(t,e,r){let n=t;for(;e-- >Ks;)n*=n,n%=r;return n}function na(t,e){if(t===Ks||e<=Ks)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ta(t,e),n=e,i=Ks,s=Js;for(;r!==Ks;){const t=n%r,e=i-s*(n/r);n=r,r=t,i=s,s=e}if(n!==Js)throw new Error("invert: does not exist");return ta(i,e)}function ia(t){if(t%Zs===Ys){const e=(t+Js)/Zs;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%$s===Xs){const e=(t-Xs)/$s;return function(t,r){const n=t.mul(r,qs),i=t.pow(n,e),s=t.mul(r,i),a=t.mul(t.mul(s,qs),i),o=t.mul(s,t.sub(a,t.ONE));if(!t.eql(t.sqr(o),r))throw new Error("Cannot find square root");return o}}return function(t){const e=(t-Js)/qs;let r,n,i;for(r=t-Js,n=0;r%qs===Ks;r/=qs,n++);for(i=qs;i<t&&ea(i,e,t)!==t-Js;i++);if(1===n){const e=(t+Js)/Zs;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const s=(r+Js)/qs;return function(t,a){if(t.pow(a,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let o=n,l=t.pow(t.mul(t.ONE,i),r),c=t.pow(a,s),u=t.pow(a,r);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let n=t.sqr(u);e<o&&!t.eql(n,t.ONE);e++)n=t.sqr(n);const r=t.pow(l,Js<<BigInt(o-e-1));l=t.sqr(r),c=t.mul(c,r),u=t.mul(u,l),o=e}return c}}(t)}BigInt(9),BigInt(16);const sa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function aa(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function oa(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 la(t){const e=oa(t);return e+Math.ceil(e/2)}
|
6
6
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
7
7
|
const ca=BigInt(0),ua=BigInt(1);function ha(t){return zs(t.Fp,sa.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({},aa(t.n,t.nBitLength)),t),{p:t.Fp.ORDER}))}
|
8
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:da,hexToBytes:pa}=Vs,fa={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=fa;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:da(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=fa,r="string"==typeof t?pa(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=fa._parseInt(r.subarray(2)),{d:a,l:o}=fa._parseInt(s);if(o.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:a}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),s=n.length/2,a=i.length/2,o=r(s),l=r(a);return`30${r(a+s+4)}02${l}${i}02${o}${n}`}},ga=BigInt(0),ma=BigInt(1);BigInt(2);const _a=BigInt(3);function ya(t){const e=function(t){const e=ha(t);zs(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze(__spreadValues({},e))}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return Ls(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function s(t){const{a:n,b:i}=e,s=r.sqr(t),a=r.mul(s,t);return r.add(r.add(a,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(t){return"bigint"==typeof t&&ga<t&&t<e.n}function o(t){if(!a(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:s}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Ts(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let a;try{a="bigint"==typeof t?t:Bs(Us("private key",t,n))}catch(l){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(a=ta(a,s)),o(a),a}const c=new Map;function u(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?h.ZERO:new h(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(Us("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&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),a=s(t);if(!r.eql(i,a))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(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:n,pz:i}=this,{px:s,py:a,pz:o}=t,l=r.eql(r.mul(e,o),r.mul(s,i)),c=r.eql(r.mul(n,o),r.mul(a,i));return l&&c}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,_a),{px:s,py:a,pz:o}=this;let l=r.ZERO,c=r.ZERO,u=r.ZERO,d=r.mul(s,s),p=r.mul(a,a),f=r.mul(o,o),g=r.mul(s,a);return g=r.add(g,g),u=r.mul(s,o),u=r.add(u,u),l=r.mul(t,u),c=r.mul(i,f),c=r.add(l,c),l=r.sub(p,c),c=r.add(p,c),c=r.mul(l,c),l=r.mul(g,l),u=r.mul(i,u),f=r.mul(t,f),g=r.sub(d,f),g=r.mul(t,g),g=r.add(g,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,f),d=r.mul(d,g),c=r.add(c,d),f=r.mul(a,o),f=r.add(f,f),d=r.mul(f,g),l=r.sub(l,d),u=r.mul(f,p),u=r.add(u,u),u=r.add(u,u),new h(l,c,u)}add(t){u(t);const{px:n,py:i,pz:s}=this,{px:a,py:o,pz:l}=t;let c=r.ZERO,d=r.ZERO,p=r.ZERO;const f=e.a,g=r.mul(e.b,_a);let m=r.mul(n,a),_=r.mul(i,o),y=r.mul(s,l),v=r.add(n,i),w=r.add(a,o);v=r.mul(v,w),w=r.add(m,_),v=r.sub(v,w),w=r.add(n,s);let b=r.add(a,l);return w=r.mul(w,b),b=r.add(m,y),w=r.sub(w,b),b=r.add(i,s),c=r.add(o,l),b=r.mul(b,c),c=r.add(_,y),b=r.sub(b,c),p=r.mul(f,w),c=r.mul(g,y),p=r.add(c,p),c=r.sub(_,p),p=r.add(_,p),d=r.mul(c,p),_=r.add(m,m),_=r.add(_,m),y=r.mul(f,y),w=r.mul(g,w),_=r.add(_,y),y=r.sub(m,y),y=r.mul(f,y),w=r.add(w,y),m=r.mul(_,w),d=r.add(d,m),m=r.mul(b,w),c=r.mul(v,c),c=r.sub(c,m),m=r.mul(v,_),p=r.mul(b,p),p=r.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=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(h.fromAffine)}))}multiplyUnsafe(t){const n=h.ZERO;if(t===ga)return n;if(o(t),t===ma)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:a,k2neg:l,k2:c}=i.splitScalar(t),u=n,d=n,f=this;for(;a>ga||c>ga;)a&ma&&(u=u.add(f)),c&ma&&(d=d.add(f)),f=f.double(),a>>=ma,c>>=ma;return s&&(u=u.negate()),l&&(d=d.negate()),d=new h(r.mul(d.px,i.beta),d.py,d.pz),u.add(d)}multiply(t){o(t);let n,i,s=t;const{endo:a}=e;if(a){const{k1neg:t,k1:e,k2neg:o,k2:l}=a.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(o,d),d=new h(r.mul(d.px,a.beta),d.py,d.pz),n=c.add(d),i=u.add(f)}else{const{p:t,f:e}=this.wNAF(s);n=t,i=e}return h.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=h.BASE,i=(t,e)=>e!==ga&&e!==ma&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,r));return s.is0()?void 0:s}toAffine(t){const{px:e,py:n,pz:i}=this,s=this.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(e,t),o=r.mul(n,t),l=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:o}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===ma)return!0;if(r)return r(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===ma?this:r?r(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(h,this,t)}toHex(t=!0){return Ts(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);const d=e.nBitLength,p=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:__pow(2,t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>ca;)r&ua&&(n=n.add(i)),i=i.double(),r>>=ua;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),s=[];let a=t,o=a;for(let n=0;n<r;n++){o=a,s.push(o);for(let t=1;t<i;t++)o=o.add(a),s.push(o);a=o.double()}return s},wNAF(e,i,s){const{windows:a,windowSize:o}=n(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<a;t++){const e=t*o;let n=Number(s&u);s>>=d,n>o&&(n-=h,s+=ua);const a=e,p=e+Math.abs(n)-1,f=t%2!=0,g=n<0;0===n?c=c.add(r(f,i[a])):l=l.add(r(g,i[p]))}return{p:l,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,n(s))),this.wNAF(i,s,r)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:a}}function va(t){const e=function(t){const e=ha(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:r,n:n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function a(t){return ta(t,n)}function o(t){return na(t,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=ya(__spreadProps(__spreadValues({},e),{toBytes(t,e,n){const i=e.toAffine(),s=r.toBytes(i.x),a=Ls;return n?a(Uint8Array.from([e.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],a=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===s&&4===n){return{x:r.fromBytes(a.subarray(0,r.BYTES)),y:r.fromBytes(a.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=Bs(a);if(!(ga<(o=t)&&o<r.ORDER))throw new Error("Point is not on curve");const e=u(t);let i=r.sqrt(e);return!(1&~n)!==((i&ma)===ma)&&(i=r.neg(i)),{x:t,y:i}}var o}})),d=t=>Ts(Os(t,e.nByteLength));function p(t){return t>n>>ma}const f=(t,e,r)=>Bs(t.slice(e,r));class g{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=Us("compactSignature",t,2*r),new g(f(t,0,r),f(t,r,2*r))}static fromDER(t){const{r:e,s:r}=fa.toSig(Us("DER",t));return new g(e,r)}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:n,s:i,recovery:s}=this,c=v(Us("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?n+e.n:n;if(u>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+d(u)),f=o(u),g=a(-c*f),m=a(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,a(-this.s),this.recovery):this}toDERRawBytes(){return Gs(this.toDERHex())}toDERHex(){return fa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gs(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=la(e.n);return function(t,e,r=!1){const n=t.length,i=oa(e),s=la(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const a=ta(r?Bs(t):Is(t),e-Js)+Js;return r?Fs(a,i):Os(a,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,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===s:r?n===2*i||n===2*s:t instanceof l}const y=e.bits2int||function(t){const r=Bs(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},v=e.bits2int_modN||function(t){return a(y(t))},w=Ds(e.nBitLength);function b(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(ga<=t&&t<w))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Os(t,e.nByteLength)}function A(t,n,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=Us("msgHash",t),f&&(t=Us("prehashed msgHash",s(t)));const _=v(t),w=c(n),A=[b(w),b(_)];if(null!=m){const t=!0===m?u(r.BYTES):m;A.push(Us("extraEntropy",t))}const x=Ls(...A),k=_;return{seed:x,k2sig:function(t){const e=y(t);if(!h(e))return;const r=o(e),n=l.BASE.multiply(e).toAffine(),i=a(n.x);if(i===ga)return;const s=a(r*a(k+i*w));if(s===ga)return;let c=(n.x===i?0:2)|Number(n.y&ma),u=s;return d&&p(s)&&(u=function(t){return p(t)?a(-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,r=!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(r)},sign:function(t,r,n=E){const{seed:i,k2sig:s}=A(t,r,n),a=e;return Ws(a.hash.outputLen,a.nByteLength,a.hmac)(i,s)},verify:function(t,r,n,i=x){var s;const c=t;if(r=Us("msgHash",r),n=Us("publicKey",n),"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 fa.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(n)}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&&(r=e.hash(r));const{r:f,s:m}=d,_=v(r),y=o(m),w=a(_*y),b=a(f*y),A=null==(s=l.BASE.multiplyAndAddUnsafe(p,w,b))?void 0:s.toAffine();return!!A&&a(A.x)===f},ProjectivePoint:l,Signature:g,utils:m}}
|
8
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:da,hexToBytes:pa}=Vs,fa={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=fa;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:da(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=fa,r="string"==typeof t?pa(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=fa._parseInt(r.subarray(2)),{d:a,l:o}=fa._parseInt(s);if(o.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:a}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),s=n.length/2,a=i.length/2,o=r(s),l=r(a);return`30${r(a+s+4)}02${l}${i}02${o}${n}`}},ga=BigInt(0),ma=BigInt(1);BigInt(2);const ya=BigInt(3);function _a(t){const e=function(t){const e=ha(t);zs(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze(__spreadValues({},e))}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return Ls(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function s(t){const{a:n,b:i}=e,s=r.sqr(t),a=r.mul(s,t);return r.add(r.add(a,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(t){return"bigint"==typeof t&&ga<t&&t<e.n}function o(t){if(!a(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:s}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Ts(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let a;try{a="bigint"==typeof t?t:Bs(Us("private key",t,n))}catch(l){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(a=ta(a,s)),o(a),a}const c=new Map;function u(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?h.ZERO:new h(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(Us("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&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),a=s(t);if(!r.eql(i,a))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(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:n,pz:i}=this,{px:s,py:a,pz:o}=t,l=r.eql(r.mul(e,o),r.mul(s,i)),c=r.eql(r.mul(n,o),r.mul(a,i));return l&&c}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,ya),{px:s,py:a,pz:o}=this;let l=r.ZERO,c=r.ZERO,u=r.ZERO,d=r.mul(s,s),p=r.mul(a,a),f=r.mul(o,o),g=r.mul(s,a);return g=r.add(g,g),u=r.mul(s,o),u=r.add(u,u),l=r.mul(t,u),c=r.mul(i,f),c=r.add(l,c),l=r.sub(p,c),c=r.add(p,c),c=r.mul(l,c),l=r.mul(g,l),u=r.mul(i,u),f=r.mul(t,f),g=r.sub(d,f),g=r.mul(t,g),g=r.add(g,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,f),d=r.mul(d,g),c=r.add(c,d),f=r.mul(a,o),f=r.add(f,f),d=r.mul(f,g),l=r.sub(l,d),u=r.mul(f,p),u=r.add(u,u),u=r.add(u,u),new h(l,c,u)}add(t){u(t);const{px:n,py:i,pz:s}=this,{px:a,py:o,pz:l}=t;let c=r.ZERO,d=r.ZERO,p=r.ZERO;const f=e.a,g=r.mul(e.b,ya);let m=r.mul(n,a),y=r.mul(i,o),_=r.mul(s,l),v=r.add(n,i),w=r.add(a,o);v=r.mul(v,w),w=r.add(m,y),v=r.sub(v,w),w=r.add(n,s);let b=r.add(a,l);return w=r.mul(w,b),b=r.add(m,_),w=r.sub(w,b),b=r.add(i,s),c=r.add(o,l),b=r.mul(b,c),c=r.add(y,_),b=r.sub(b,c),p=r.mul(f,w),c=r.mul(g,_),p=r.add(c,p),c=r.sub(y,p),p=r.add(y,p),d=r.mul(c,p),y=r.add(m,m),y=r.add(y,m),_=r.mul(f,_),w=r.mul(g,w),y=r.add(y,_),_=r.sub(m,_),_=r.mul(f,_),w=r.add(w,_),m=r.mul(y,w),d=r.add(d,m),m=r.mul(b,w),c=r.mul(v,c),c=r.sub(c,m),m=r.mul(v,y),p=r.mul(b,p),p=r.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=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(h.fromAffine)}))}multiplyUnsafe(t){const n=h.ZERO;if(t===ga)return n;if(o(t),t===ma)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:a,k2neg:l,k2:c}=i.splitScalar(t),u=n,d=n,f=this;for(;a>ga||c>ga;)a&ma&&(u=u.add(f)),c&ma&&(d=d.add(f)),f=f.double(),a>>=ma,c>>=ma;return s&&(u=u.negate()),l&&(d=d.negate()),d=new h(r.mul(d.px,i.beta),d.py,d.pz),u.add(d)}multiply(t){o(t);let n,i,s=t;const{endo:a}=e;if(a){const{k1neg:t,k1:e,k2neg:o,k2:l}=a.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(o,d),d=new h(r.mul(d.px,a.beta),d.py,d.pz),n=c.add(d),i=u.add(f)}else{const{p:t,f:e}=this.wNAF(s);n=t,i=e}return h.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=h.BASE,i=(t,e)=>e!==ga&&e!==ma&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,r));return s.is0()?void 0:s}toAffine(t){const{px:e,py:n,pz:i}=this,s=this.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(e,t),o=r.mul(n,t),l=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:o}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===ma)return!0;if(r)return r(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===ma?this:r?r(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(h,this,t)}toHex(t=!0){return Ts(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);const d=e.nBitLength,p=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:__pow(2,t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>ca;)r&ua&&(n=n.add(i)),i=i.double(),r>>=ua;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),s=[];let a=t,o=a;for(let n=0;n<r;n++){o=a,s.push(o);for(let t=1;t<i;t++)o=o.add(a),s.push(o);a=o.double()}return s},wNAF(e,i,s){const{windows:a,windowSize:o}=n(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<a;t++){const e=t*o;let n=Number(s&u);s>>=d,n>o&&(n-=h,s+=ua);const a=e,p=e+Math.abs(n)-1,f=t%2!=0,g=n<0;0===n?c=c.add(r(f,i[a])):l=l.add(r(g,i[p]))}return{p:l,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,n(s))),this.wNAF(i,s,r)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:a}}function va(t){const e=function(t){const e=ha(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:r,n:n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function a(t){return ta(t,n)}function o(t){return na(t,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=_a(__spreadProps(__spreadValues({},e),{toBytes(t,e,n){const i=e.toAffine(),s=r.toBytes(i.x),a=Ls;return n?a(Uint8Array.from([e.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],a=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===s&&4===n){return{x:r.fromBytes(a.subarray(0,r.BYTES)),y:r.fromBytes(a.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=Bs(a);if(!(ga<(o=t)&&o<r.ORDER))throw new Error("Point is not on curve");const e=u(t);let i=r.sqrt(e);return!(1&~n)!==((i&ma)===ma)&&(i=r.neg(i)),{x:t,y:i}}var o}})),d=t=>Ts(Os(t,e.nByteLength));function p(t){return t>n>>ma}const f=(t,e,r)=>Bs(t.slice(e,r));class g{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=Us("compactSignature",t,2*r),new g(f(t,0,r),f(t,r,2*r))}static fromDER(t){const{r:e,s:r}=fa.toSig(Us("DER",t));return new g(e,r)}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:n,s:i,recovery:s}=this,c=v(Us("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?n+e.n:n;if(u>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+d(u)),f=o(u),g=a(-c*f),m=a(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,a(-this.s),this.recovery):this}toDERRawBytes(){return Gs(this.toDERHex())}toDERHex(){return fa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gs(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=la(e.n);return function(t,e,r=!1){const n=t.length,i=oa(e),s=la(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const a=ta(r?Bs(t):Is(t),e-Js)+Js;return r?Fs(a,i):Os(a,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,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===s:r?n===2*i||n===2*s:t instanceof l}const _=e.bits2int||function(t){const r=Bs(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},v=e.bits2int_modN||function(t){return a(_(t))},w=Ds(e.nBitLength);function b(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(ga<=t&&t<w))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Os(t,e.nByteLength)}function A(t,n,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=Us("msgHash",t),f&&(t=Us("prehashed msgHash",s(t)));const y=v(t),w=c(n),A=[b(w),b(y)];if(null!=m){const t=!0===m?u(r.BYTES):m;A.push(Us("extraEntropy",t))}const x=Ls(...A),k=y;return{seed:x,k2sig:function(t){const e=_(t);if(!h(e))return;const r=o(e),n=l.BASE.multiply(e).toAffine(),i=a(n.x);if(i===ga)return;const s=a(r*a(k+i*w));if(s===ga)return;let c=(n.x===i?0:2)|Number(n.y&ma),u=s;return d&&p(s)&&(u=function(t){return p(t)?a(-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,r=!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(r)},sign:function(t,r,n=E){const{seed:i,k2sig:s}=A(t,r,n),a=e;return Ws(a.hash.outputLen,a.nByteLength,a.hmac)(i,s)},verify:function(t,r,n,i=x){var s;const c=t;if(r=Us("msgHash",r),n=Us("publicKey",n),"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 fa.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(n)}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&&(r=e.hash(r));const{r:f,s:m}=d,y=v(r),_=o(m),w=a(y*_),b=a(f*_),A=null==(s=l.BASE.multiplyAndAddUnsafe(p,w,b))?void 0:s.toAffine();return!!A&&a(A.x)===f},ProjectivePoint:l,Signature:g,utils:m}}
|
9
9
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wa(t){return{hash:t,hmac:(e,...r)=>Mi(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!xi(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}(...r)),randomBytes:Ti}}BigInt(4);
|
10
10
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
11
|
-
const ba=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Aa=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ea=BigInt(1),xa=BigInt(2),ka=(t,e)=>(t+e/xa)/e;const Sa=function(t,e,r=!1,n={}){if(t<=Ks)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=aa(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=ia(t),o=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Ds(i),ZERO:Ks,ONE:Js,create:e=>ta(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=>ta(-e,t),eql:(t,e)=>t===e,sqr:e=>ta(e*e,t),add:(e,r)=>ta(e+r,t),sub:(e,r)=>ta(e-r,t),mul:(e,r)=>ta(e*r,t),pow:(t,e)=>function(t,e,r){if(r<Ks)throw new Error("Expected power > 0");if(r===Ks)return t.ONE;if(r===Js)return e;let n=t.ONE,i=e;for(;r>Ks;)r&Js&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Js;return n}(o,t,e),div:(e,r)=>ta(e*na(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>na(e,t),sqrt:n.sqrt||(t=>a(o,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(o,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?Fs(t,s):Os(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return r?Is(t):Bs(t)}});return Object.freeze(o)}(ba,void 0,void 0,{sqrt:function(t){const e=ba,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),o=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=ra(u,r,e)*u%e,d=ra(h,r,e)*u%e,p=ra(d,xa,e)*c%e,f=ra(p,i,e)*p%e,g=ra(f,s,e)*f%e,m=ra(g,o,e)*g%e,_=ra(m,l,e)*m%e,y=ra(_,o,e)*g%e,v=ra(y,r,e)*u%e,w=ra(v,a,e)*f%e,b=ra(w,n,e)*c%e,A=ra(b,xa,e);if(!Sa.eql(Sa.sqr(A),t))throw new Error("Cannot find square root");return A}}),Na=function(t,e){const r=e=>va(__spreadValues(__spreadValues({},t),wa(e)));return Object.freeze(__spreadProps(__spreadValues({},r(e)),{create:r}))}({a:BigInt(0),b:BigInt(7),Fp:Sa,n:Aa,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Aa,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ea*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),o=ka(s*t,e),l=ka(-n*t,e);let c=ta(t-o*r-l*i,e),u=ta(-o*n-l*s,e);const h=c>a,d=u>a;if(h&&(c=e-c),d&&(u=e-u),c>a||u>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Li);BigInt(0),Na.ProjectivePoint;const Pa="0x0000000000000000000000000000000000000000",Ca="0x0000000000000000000000000000000000000000000000000000000000000000",Ta=BigInt(0),Ra=BigInt(1),Ma=BigInt(2),Ga=BigInt(27),Ba=BigInt(28),Ia=BigInt(35),Oa={};function Fa(t){return Zr(hn(t),32)}const Ua=class t{constructor(t,e,r,n){__privateAdd(this,nt,void 0),__privateAdd(this,it,void 0),__privateAdd(this,st,void 0),__privateAdd(this,at,void 0),Lr(t,Oa,"Signature"),__privateSet(this,nt,e),__privateSet(this,it,r),__privateSet(this,st,n),__privateSet(this,at,null)}get r(){return __privateGet(this,nt)}set r(t){Or(32===Jr(t),"invalid r","value",t),__privateSet(this,nt,Vr(t))}get s(){return __privateGet(this,it)}set s(t){Or(32===Jr(t),"invalid s","value",t);const e=Vr(t);Or(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=cn(t,"value");Or(27===e||28===e,"invalid v","v",t),__privateSet(this,st,e)}get networkV(){return __privateGet(this,at)}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=jr(this.s);return this.yParity&&(t[0]|=128),Vr(t)}get compactSerialized(){return Kr([this.r,this.yParityAndS])}get serialized(){return Kr([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(Oa,this.r,this.s,this.v);return this.networkV&&__privateSet(e,at,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=sn(t,"v");return e==Ga||e==Ba?Ta:(Or(e>=Ia,"invalid EIP-155 v","v",t),(e-Ia)/Ma)}static getChainIdV(t,e){return sn(t)*Ma+BigInt(35+e-27)}static getNormalizedV(t){const e=sn(t);return e===Ta||e===Ga?27:e===Ra||e===Ba?28:(Or(e>=Ia,"invalid v","v",t),e&Ra?27:28)}static from(e){function r(t,r){Or(t,r,"signature",e)}if(null==e)return new t(Oa,Ca,Ca,27);if("string"==typeof e){const n=jr(e,"signature");if(64===n.length){const e=Vr(n.slice(0,32)),r=n.slice(32,64),i=128&r[0]?28:27;return r[0]&=127,new t(Oa,e,Vr(r),i)}if(65===n.length){const e=Vr(n.slice(0,32)),i=n.slice(32,64);r(!(128&i[0]),"non-canonical s");const s=t.getNormalizedV(n[64]);return new t(Oa,e,Vr(i),s)}r(!1,"invalid raw signature length")}if(e instanceof t)return e.clone();const n=e.r;r(null!=n,"missing r");const i=Fa(n),s=function(t,e){if(null!=t)return Fa(t);if(null!=e){r(Wr(e,32),"invalid yParityAndS");const t=jr(e);return t[0]&=127,Vr(t)}r(!1,"missing s")}(e.s,e.yParityAndS);r(!(128&jr(s)[0]),"non-canonical s");const{networkV:a,v:o}=function(e,n,i){if(null!=e){const r=sn(e);return{networkV:r>=Ia?r:void 0,v:t.getNormalizedV(r)}}if(null!=n)return r(Wr(n,32),"invalid yParityAndS"),{v:128&jr(n)[0]?28:27};if(null!=i){switch(cn(i,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}r(!1,"invalid yParity")}r(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new t(Oa,i,s,o);return a&&__privateSet(l,at,a),r(null==e.yParity||cn(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),r(null==e.yParityAndS||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};nt=new WeakMap,it=new WeakMap,st=new WeakMap,at=new WeakMap;let La=Ua;ot=new WeakMap;let Da=class t{constructor(t){__privateAdd(this,ot,void 0),Or(32===Jr(t),"invalid private key","privateKey","[REDACTED]"),__privateSet(this,ot,Vr(t))}get privateKey(){return __privateGet(this,ot)}get publicKey(){return t.computePublicKey(__privateGet(this,ot))}get compressedPublicKey(){return t.computePublicKey(__privateGet(this,ot),!0)}sign(t){Or(32===Jr(t),"invalid digest length","digest",t);const e=Na.sign(Hr(t),Hr(__privateGet(this,ot)),{lowS:!0});return La.from({r:un(e.r,32),s:un(e.s,32),v:e.recovery?28:27})}computeSharedSecret(e){const r=t.computePublicKey(e);return Vr(Na.getSharedSecret(Hr(__privateGet(this,ot)),jr(r),!1))}static computePublicKey(t,e){let r=jr(t,"key");if(32===r.length){return Vr(Na.getPublicKey(r,!!e))}if(64===r.length){const t=new Uint8Array(65);t[0]=4,t.set(r,1),r=t}return Vr(Na.ProjectivePoint.fromHex(r).toRawBytes(e))}static recoverPublicKey(t,e){Or(32===Jr(t),"invalid digest length","digest",t);const r=La.from(e);let n=Na.Signature.fromCompact(Hr(Kr([r.r,r.s])));n=n.addRecoveryBit(r.yParity);const i=n.recoverPublicKey(Hr(t));return Or(null!=i,"invalid signature for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(e,r,n){const i=Na.ProjectivePoint.fromHex(t.computePublicKey(e).substring(2)),s=Na.ProjectivePoint.fromHex(t.computePublicKey(r).substring(2));return"0x"+i.add(s).toHex(!!n)}};const ja=BigInt(0),Ha=BigInt(36);function Wa(t){const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);const n=jr(ws(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(15&n[i>>1])>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const Qa={};for(let Pp=0;Pp<10;Pp++)Qa[String(Pp)]=String(Pp);for(let Pp=0;Pp<26;Pp++)Qa[String.fromCharCode(65+Pp)]=String(10+Pp);const za=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function Va(t){if(Or("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=Wa(t);return Or(!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}$/)){Or(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Qa[t])).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=ja;for(let r=0;r<t.length;r++)e=e*Ha+za[t[r]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Wa("0x"+e)}Or(!1,"invalid address","address",t)}function Ka(t){return t&&"function"==typeof t.getAddress}function Ja(t,e){return __async(this,null,(function*(){const r=yield e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(Ir("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),Or(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),Va(r)}))}function qa(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?Va(t):(Ir(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ja(t,e.resolveName(t))):Ka(t)?Ja(t,t.getAddress()):t&&"function"==typeof t.then?Ja(t,t):void Or(!1,"unsupported addressable value","target",t)}const Ya={};function Za(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new to(Ya,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function Xa(t,e){return new to(Ya,`bytes${e||""}`,t,{size:e})}const $a=Symbol.for("_ethers_typed");lt=new WeakMap;let to=class t{constructor(t,e,r,n){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,lt,void 0),__publicField(this,"_typedSymbol"),null==n&&(n=null),Lr(Ya,t,"Typed"),Tr(this,{_typedSymbol:$a,type:e,value:r}),__privateSet(this,lt,n),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,r){return new t(Ya,e,r)}static uint8(t){return Za(t,8)}static uint16(t){return Za(t,16)}static uint24(t){return Za(t,24)}static uint32(t){return Za(t,32)}static uint40(t){return Za(t,40)}static uint48(t){return Za(t,48)}static uint56(t){return Za(t,56)}static uint64(t){return Za(t,64)}static uint72(t){return Za(t,72)}static uint80(t){return Za(t,80)}static uint88(t){return Za(t,88)}static uint96(t){return Za(t,96)}static uint104(t){return Za(t,104)}static uint112(t){return Za(t,112)}static uint120(t){return Za(t,120)}static uint128(t){return Za(t,128)}static uint136(t){return Za(t,136)}static uint144(t){return Za(t,144)}static uint152(t){return Za(t,152)}static uint160(t){return Za(t,160)}static uint168(t){return Za(t,168)}static uint176(t){return Za(t,176)}static uint184(t){return Za(t,184)}static uint192(t){return Za(t,192)}static uint200(t){return Za(t,200)}static uint208(t){return Za(t,208)}static uint216(t){return Za(t,216)}static uint224(t){return Za(t,224)}static uint232(t){return Za(t,232)}static uint240(t){return Za(t,240)}static uint248(t){return Za(t,248)}static uint256(t){return Za(t,256)}static uint(t){return Za(t,256)}static int8(t){return Za(t,-8)}static int16(t){return Za(t,-16)}static int24(t){return Za(t,-24)}static int32(t){return Za(t,-32)}static int40(t){return Za(t,-40)}static int48(t){return Za(t,-48)}static int56(t){return Za(t,-56)}static int64(t){return Za(t,-64)}static int72(t){return Za(t,-72)}static int80(t){return Za(t,-80)}static int88(t){return Za(t,-88)}static int96(t){return Za(t,-96)}static int104(t){return Za(t,-104)}static int112(t){return Za(t,-112)}static int120(t){return Za(t,-120)}static int128(t){return Za(t,-128)}static int136(t){return Za(t,-136)}static int144(t){return Za(t,-144)}static int152(t){return Za(t,-152)}static int160(t){return Za(t,-160)}static int168(t){return Za(t,-168)}static int176(t){return Za(t,-176)}static int184(t){return Za(t,-184)}static int192(t){return Za(t,-192)}static int200(t){return Za(t,-200)}static int208(t){return Za(t,-208)}static int216(t){return Za(t,-216)}static int224(t){return Za(t,-224)}static int232(t){return Za(t,-232)}static int240(t){return Za(t,-240)}static int248(t){return Za(t,-248)}static int256(t){return Za(t,-256)}static int(t){return Za(t,-256)}static bytes1(t){return Xa(t,1)}static bytes2(t){return Xa(t,2)}static bytes3(t){return Xa(t,3)}static bytes4(t){return Xa(t,4)}static bytes5(t){return Xa(t,5)}static bytes6(t){return Xa(t,6)}static bytes7(t){return Xa(t,7)}static bytes8(t){return Xa(t,8)}static bytes9(t){return Xa(t,9)}static bytes10(t){return Xa(t,10)}static bytes11(t){return Xa(t,11)}static bytes12(t){return Xa(t,12)}static bytes13(t){return Xa(t,13)}static bytes14(t){return Xa(t,14)}static bytes15(t){return Xa(t,15)}static bytes16(t){return Xa(t,16)}static bytes17(t){return Xa(t,17)}static bytes18(t){return Xa(t,18)}static bytes19(t){return Xa(t,19)}static bytes20(t){return Xa(t,20)}static bytes21(t){return Xa(t,21)}static bytes22(t){return Xa(t,22)}static bytes23(t){return Xa(t,23)}static bytes24(t){return Xa(t,24)}static bytes25(t){return Xa(t,25)}static bytes26(t){return Xa(t,26)}static bytes27(t){return Xa(t,27)}static bytes28(t){return Xa(t,28)}static bytes29(t){return Xa(t,29)}static bytes30(t){return Xa(t,30)}static bytes31(t){return Xa(t,31)}static bytes32(t){return Xa(t,32)}static address(e){return new t(Ya,"address",e)}static bool(e){return new t(Ya,"bool",!!e)}static bytes(e){return new t(Ya,"bytes",e)}static string(e){return new t(Ya,"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(Ya,"overrides",Object.assign({},e))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===$a}static dereference(e,r){if(t.isTyped(e)){if(e.type!==r)throw new Error(`invalid type: expecetd ${r}, got ${e.type}`);return e.value}return e}};class eo extends mi{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=to.dereference(e,"string");try{r=Va(r)}catch(n){return this._throwError(n.message,e)}return t.writeValue(r)}decode(t){return Va(un(t.readValue(),20))}}class ro 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 no(t,e,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map((e=>{const n=e.localName;return Ir(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),Ir(!t[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),t[n]=!0,r[n]}))}else Or(!1,"invalid tuple value","tuple",r);Or(e.length===n.length,"types/value length mismatch","tuple",r);let i=new _i,s=new _i,a=[];e.forEach(((t,e)=>{let r=n[e];if(t.dynamic){let e=s.length;t.encode(s,r);let n=i.writeUpdatableValue();a.push((t=>{n(t+e)}))}else t.encode(i,r)})),a.forEach((t=>{t(i.length)}));let o=t.appendWriter(i);return o+=t.appendWriter(s),o}function io(t,e){let r=[],n=[],i=t.subReader(0);return e.forEach((e=>{let s=null;if(e.dynamic){let r=t.readIndex(),n=i.subReader(r);try{s=e.decode(n)}catch(a){if(Mr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}}else try{s=e.decode(t)}catch(a){if(Mr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}if(null==s)throw new Error("investigate");r.push(s),n.push(e.localName||null)})),fi.fromItems(r,n)}class so extends mi{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),__publicField(this,"coder"),__publicField(this,"length"),Tr(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){const r=to.dereference(e,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,t.writeValue(r.length)),Fr(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let s=0;s<r.length;s++)i.push(this.coder);return no(t,i,r)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),Ir(e*si<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*si,length:t.dataLength}));let r=[];for(let n=0;n<e;n++)r.push(new ro(this.coder));return io(t,r)}}class ao extends mi{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=to.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class oo extends mi{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=Hr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class lo extends oo{constructor(t){super("bytes",t)}decode(t){return Vr(super.decode(t))}}class co extends mi{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),__publicField(this,"size"),Tr(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=Hr(to.dereference(e,this.type));return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return Vr(t.readBytes(this.size))}}const uo=new Uint8Array([]);class ho extends mi{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(uo)}decode(t){return t.readBytes(0),null}}const po=BigInt(0),fo=BigInt(1),go=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class mo extends mi{constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),__publicField(this,"size"),__publicField(this,"signed"),Tr(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let r=sn(to.dereference(e,this.type)),n=nn(go,256);if(this.signed){let t=nn(n,8*this.size-1);(r>t||r<-(t+fo))&&this._throwError("value out-of-bounds",e),r=rn(r,256)}else(r<po||r>nn(n,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(r)}decode(t){let e=nn(t.readValue(),8*this.size);return this.signed&&(e=en(e,8*this.size)),e}}class _o extends oo{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,yn(to.dereference(e,"string")))}decode(t){return vn(super.decode(t))}}class yo extends mi{constructor(t,e){let r=!1;const n=[];t.forEach((t=>{t.dynamic&&(r=!0),n.push(t.type)}));super("tuple","tuple("+n.join(",")+")",e,r),__publicField(this,"coders"),Tr(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 r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))})),Object.freeze(t)}encode(t,e){const r=to.dereference(e,"tuple");return no(t,this.coders,r)}decode(t){return io(t,this.coders)}}function vo(t,e){return{address:Va(t),storageKeys:e.map(((t,e)=>(Or(Wr(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function wo(t){if(Array.isArray(t))return t.map(((e,r)=>Array.isArray(e)?(Or(2===e.length,"invalid slot set",`value[${r}]`,e),vo(e[0],e[1])):(Or(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),vo(e.address,e.storageKeys))));Or(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return vo(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function bo(t){return{address:Va(t.address),nonce:sn(null!=t.nonce?t.nonce:0),chainId:sn(null!=t.chainId?t.chainId:0),signature:La.from(t.signature)}}function Ao(t,e){return function(t){let e;return e="string"==typeof t?Da.computePublicKey(t,!1):t.publicKey,Va(ws("0x"+e.substring(4)).substring(26))}(Da.recoverPublicKey(t,e))}const Eo=BigInt(0),xo=BigInt(2),ko=BigInt(27),So=BigInt(28),No=BigInt(35),Po=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Co=131072;function To(t,e){let r=t.toString(16);for(;r.length<2;)r="0"+r;return r+=xs(e).substring(4),"0x"+r}function Ro(t){return"0x"===t?null:Va(t)}function Mo(t,e){try{return wo(t)}catch(r){Or(!1,r.message,e,t)}}function Go(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!Array.isArray(n))throw new Error(`authorization[${r}]: invalid array`);if(6!==n.length)throw new Error(`authorization[${r}]: wrong length`);if(!n[1])throw new Error(`authorization[${r}]: null address`);e.push({address:Ro(n[1]),nonce:Io(n[2],"nonce"),chainId:Io(n[0],"chainId"),signature:La.from({yParity:Bo(n[3],"yParity"),r:Zr(n[4],32),s:Zr(n[5],32)})})}return e}catch(r){Or(!1,r.message,e,t)}}function Bo(t,e){return"0x"===t?0:cn(t,e)}function Io(t,e){if("0x"===t)return Eo;const r=sn(t,e);return Or(r<=Po,"value exceeds uint size",e,r),r}function Oo(t,e){const r=sn(t,"value"),n=hn(r);return Or(n.length<=32,"value too large",`tx.${e}`,r),n}function Fo(t){return wo(t).map((t=>[t.address,t.storageKeys]))}function Uo(t,e){Or(Array.isArray(t),`invalid ${e}`,"value",t);for(let r=0;r<t.length;r++)Or(Wr(t[r],32),"invalid ${ param } hash",`value[${r}]`,t[r]);return t}function Lo(t,e){let r;try{if(r=Bo(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(a){Or(!1,"invalid yParity","yParity",e[0])}const n=Zr(e[1],32),i=Zr(e[2],32),s=La.from({r:n,s:i,yParity:r});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,vt=new WeakMap,wt=new WeakMap,bt=new WeakMap,At=new WeakMap,Et=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakSet,Nt=function(t,e){Ir(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const r=[Oo(t.nonce,"nonce"),Oo(t.gasPrice||0,"gasPrice"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data];let n=Eo;if(t.chainId!=Eo)n=sn(t.chainId,"tx.chainId"),Or(!e||null==e.networkV||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(n=e)}if(!e)return n!==Eo&&(r.push(hn(n)),r.push("0x"),r.push("0x")),ei(r);let i=BigInt(27+e.yParity);return n!==Eo?i=La.getChainIdV(n,e.v):BigInt(e.v)!==i&&Or(!1,"tx.chainId/sig.v mismatch","sig",e),r.push(hn(i)),r.push(hn(e.r)),r.push(hn(e.s)),ei(r)}(this,r);case 1:return function(t,e){const r=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.gasPrice||0,"gasPrice"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data,Fo(t.accessList||[])];return e&&(r.push(Oo(e.yParity,"recoveryParam")),r.push(hn(e.r)),r.push(hn(e.s))),Kr(["0x01",ei(r)])}(this,r);case 2:return function(t,e){const r=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oo(t.maxFeePerGas||0,"maxFeePerGas"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data,Fo(t.accessList||[])];return e&&(r.push(Oo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Kr(["0x02",ei(r)])}(this,r);case 3:return function(t,e,r){const n=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oo(t.maxFeePerGas||0,"maxFeePerGas"),Oo(t.gasLimit,"gasLimit"),t.to||Pa,Oo(t.value,"value"),t.data,Fo(t.accessList||[]),Oo(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Uo(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(Oo(e.yParity,"yParity")),n.push(hn(e.r)),n.push(hn(e.s)),r)?Kr(["0x03",ei([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):Kr(["0x03",ei(n)])}(this,r,e?this.blobs:null);case 4:return function(t,e){const r=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oo(t.maxFeePerGas||0,"maxFeePerGas"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data,Fo(t.accessList||[]),(n=t.authorizationList||[],n.map((t=>[Oo(t.chainId,"chainId"),t.address,Oo(t.nonce,"nonce"),Oo(t.signature.yParity,"yParity"),t.signature.r,t.signature.s])))];var n;return e&&(r.push(Oo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Kr(["0x04",ei(r)])}(this,r)}Ir(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Do=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,vt,void 0),__privateAdd(this,wt,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,Eo),__privateSet(this,ft,null),__privateSet(this,gt,null),__privateSet(this,mt,null),__privateSet(this,ht,"0x"),__privateSet(this,_t,Eo),__privateSet(this,yt,Eo),__privateSet(this,vt,null),__privateSet(this,wt,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:Or(!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?Pa:t}set to(t){__privateSet(this,ut,null==t?null:Va(t))}get nonce(){return __privateGet(this,dt)}set nonce(t){__privateSet(this,dt,cn(t,"value"))}get gasLimit(){return __privateGet(this,pt)}set gasLimit(t){__privateSet(this,pt,sn(t))}get gasPrice(){const t=__privateGet(this,ft);return null!=t||0!==this.type&&1!==this.type?t:Eo}set gasPrice(t){__privateSet(this,ft,null==t?null:sn(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=__privateGet(this,gt);return null==t?2===this.type||3===this.type?Eo:null:t}set maxPriorityFeePerGas(t){__privateSet(this,gt,null==t?null:sn(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=__privateGet(this,mt);return null==t?2===this.type||3===this.type?Eo:null:t}set maxFeePerGas(t){__privateSet(this,mt,null==t?null:sn(t,"maxFeePerGas"))}get data(){return __privateGet(this,ht)}set data(t){__privateSet(this,ht,Vr(t))}get value(){return __privateGet(this,_t)}set value(t){__privateSet(this,_t,sn(t,"value"))}get chainId(){return __privateGet(this,yt)}set chainId(t){__privateSet(this,yt,sn(t))}get signature(){return __privateGet(this,vt)||null}set signature(t){__privateSet(this,vt,null==t?null:La.from(t))}get accessList(){const t=__privateGet(this,wt)||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){__privateSet(this,wt,null==t?null:wo(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=>bo(t))))}get maxFeePerBlobGas(){const t=__privateGet(this,bt);return null==t&&3===this.type?Eo:t}set maxFeePerBlobGas(t){__privateSet(this,bt,null==t?null:sn(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=__privateGet(this,At);return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){Or(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)Or(Wr(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=[],r=[];for(let n=0;n<t.length;n++){const i=t[n];if(Qr(i)){Ir(__privateGet(this,Et),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=jr(i);if(Or(t.length<=Co,"blob is too large",`blobs[${n}]`,i),t.length!==Co){const e=new Uint8Array(Co);e.set(t),t=e}const s=__privateGet(this,Et).blobToKzgCommitment(t),a=Vr(__privateGet(this,Et).computeBlobKzgProof(t,s));e.push({data:Vr(t),commitment:Vr(s),proof:a}),r.push(To(1,s))}else{const t=Vr(i.commitment);e.push({data:Vr(i.data),commitment:t,proof:Vr(i.proof)}),r.push(To(1,t))}}__privateSet(this,xt,e),__privateSet(this,At,r)}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 jr(t.blobToKzgCommitment(Vr(e)))}else if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return jr(t.blobToKzgCommitment(e));if("blobToKZGCommitment"in t&&"function"==typeof t.blobToKZGCommitment)return jr(t.blobToKZGCommitment(Vr(e)));Or(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(e,r)=>"computeBlobProof"in t&&"function"==typeof t.computeBlobProof?jr(t.computeBlobProof(Vr(e),Vr(r))):"computeBlobKzgProof"in t&&"function"==typeof t.computeBlobKzgProof?t.computeBlobKzgProof(e,r):"computeBlobKZGProof"in t&&"function"==typeof t.computeBlobKZGProof?jr(t.computeBlobKZGProof(Vr(e),Vr(r))):void Or(!1,"unsupported KZG library","kzg",t)}}(t))}get hash(){return null==this.signature?null:ws(__privateMethod(this,St,Nt).call(this,!0,!1))}get unsignedHash(){return ws(this.unsignedSerialized)}get from(){return null==this.signature?null:Ao(this.unsignedHash,this.signature)}get fromPublicKey(){return null==this.signature?null:Da.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,r=null!=this.accessList,n=null!=__privateGet(this,bt)||__privateGet(this,At);null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&Ir(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),Ir(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),Ir(0!==this.type||!r,"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),r||i.push(0)):r?(i.push(1),i.push(2)):(n&&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 r=jr(e);if(r[0]>=127)return t.from(function(t){const e=Zn(t);Or(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:Bo(e[0],"nonce"),gasPrice:Io(e[1],"gasPrice"),gasLimit:Io(e[2],"gasLimit"),to:Ro(e[3]),value:Io(e[4],"value"),data:Vr(e[5]),chainId:Eo};if(6===e.length)return r;const n=Io(e[6],"v"),i=Io(e[7],"r"),s=Io(e[8],"s");if(i===Eo&&s===Eo)r.chainId=n;else{let t=(n-No)/xo;t<Eo&&(t=Eo),r.chainId=t,Or(t!==Eo||n===ko||n===So,"non-canonical legacy v","v",e[6]),r.signature=La.from({r:Zr(e[7],32),s:Zr(e[8],32),v:n})}return r}(r));switch(r[0]){case 1:return t.from(function(t){const e=Zn(jr(t).slice(1));Or(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",Vr(t));const r={type:1,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),gasPrice:Io(e[2],"gasPrice"),gasLimit:Io(e[3],"gasLimit"),to:Ro(e[4]),value:Io(e[5],"value"),data:Vr(e[6]),accessList:Mo(e[7],"accessList")};return 8===e.length||Lo(r,e.slice(8)),r}(r));case 2:return t.from(function(t){const e=Zn(jr(t).slice(1));Or(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",Vr(t));const r={type:2,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:Ro(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Mo(e[8],"accessList")};return 9===e.length||Lo(r,e.slice(9)),r}(r));case 3:return t.from(function(t){let e=Zn(jr(t).slice(1)),r="3",n=null;if(4===e.length&&Array.isArray(e[0])){r="3 (network format)";const t=e[1],i=e[2],s=e[3];Or(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),Or(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),Or(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),Or(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),Or(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let r=0;r<e[1].length;r++)n.push({data:t[r],commitment:i[r],proof:s[r]});e=e[0]}Or(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${r}`,"data",Vr(t));const i={type:3,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:Ro(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Mo(e[8],"accessList"),maxFeePerBlobGas:Io(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),Or(null!=i.to,`invalid address for transaction type: ${r}`,"data",t),Or(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let s=0;s<i.blobVersionedHashes.length;s++)Or(Wr(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",t);return 11===e.length||Lo(i,e.slice(11)),i}(r));case 4:return t.from(function(t){const e=Zn(jr(t).slice(1));Or(Array.isArray(e)&&(10===e.length||13===e.length),"invalid field count for transaction type: 4","data",Vr(t));const r={type:4,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:Ro(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Mo(e[8],"accessList"),authorizationList:Go(e[9],"authorizationList")};return 10===e.length||Lo(r,e.slice(10)),r}(r))}Ir(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const r=new t;return null!=e.type&&(r.type=e.type),null!=e.to&&(r.to=e.to),null!=e.nonce&&(r.nonce=e.nonce),null!=e.gasLimit&&(r.gasLimit=e.gasLimit),null!=e.gasPrice&&(r.gasPrice=e.gasPrice),null!=e.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=e.maxPriorityFeePerGas),null!=e.maxFeePerGas&&(r.maxFeePerGas=e.maxFeePerGas),null!=e.maxFeePerBlobGas&&(r.maxFeePerBlobGas=e.maxFeePerBlobGas),null!=e.data&&(r.data=e.data),null!=e.value&&(r.value=e.value),null!=e.chainId&&(r.chainId=e.chainId),null!=e.signature&&(r.signature=La.from(e.signature)),null!=e.accessList&&(r.accessList=e.accessList),null!=e.authorizationList&&(r.authorizationList=e.authorizationList),null!=e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes),null!=e.kzg&&(r.kzg=e.kzg),null!=e.blobs&&(r.blobs=e.blobs),null!=e.hash&&(Or(r.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),Or(r.hash===e.hash,"hash mismatch","tx",e)),null!=e.from&&(Or(r.isSigned(),"unsigned transaction cannot define '.from'","tx",e),Or(r.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),r}};function jo(t){return ws(yn(t))}const Ho=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);function Wo(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let n=r(),i=1,s=[0,1];for(let w=1;w<n;w++)s.push(i+=r());let a=r(),o=e;e+=a;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 w=0;w<31;w++)g=g<<1|u();let m=[],_=0,y=h;for(;;){let t=Math.floor(((g-_+1)*i-1)/y),e=0,r=n;for(;r-e>1;){let n=e+r>>>1;t<s[n]?r=n:e=n}if(0==e)break;m.push(e);let a=_+Math.floor(y*s[e]/i),o=_+Math.floor(y*s[e+1]/i)-1;for(;0==((a^o)&d);)g=g<<1&f|u(),a=a<<1&f,o=o<<1&f|1;for(;a&~o&p;)g=g&d|g<<1&f>>>1|u(),a=a<<1^d,o=(o^d)<<1|d|1;_=a,y=1+o-a}let v=n-4;return m.map((e=>{switch(e-v){case 3:return v+65792+(t[o++]<<16|t[o++]<<8|t[o++]);case 2:return v+256+(t[o++]<<8|t[o++]);case 1:return v+t[o++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,r)=>e[t.charCodeAt(0)]=r));let r=t.length,n=new Uint8Array(6*r>>3);for(let i=0,s=0,a=0,o=0;i<r;i++)o=o<<6|e[t.charCodeAt(i)],a+=6,a>=8&&(n[s++]=o>>(a-=8));return n}(t)))}function Qo(t){return 1&t?~t>>1:t>>1}function zo(t,e){let r=Array(t);for(let n=0,i=0;n<t;n++)r[n]=i+=Qo(e());return r}function Vo(t,e=0){let r=[];for(;;){let n=t(),i=t();if(!i)break;e+=n;for(let t=0;t<i;t++)r.push(e+t);e+=i+1}return r}function Ko(t){return qo((()=>{let e=Vo(t);if(e.length)return e}))}function Jo(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Zo(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(Xo(r,t))}return e.flat()}function qo(t){let e=[];for(;;){let r=t(e.length);if(!r)break;e.push(r)}return e}function Yo(t,e,r){let n=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)zo(t,r).forEach(((t,e)=>n[e].push(t)));return n}function Zo(t,e){let r=1+e(),n=e(),i=qo(e);return Yo(i.length,1+t,e).flatMap(((t,e)=>{let[s,...a]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*n;return[s+e*r,a.map((t=>t+i))]}))}))}function Xo(t,e){return Yo(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function $o(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 r=[];for(let n=0;n<e;)r.push(String.fromCodePoint(...t.slice(n,n+=4096)));return r.join("")}function el(t,e){let r=t.length,n=r-e.length;for(let i=0;0==n&&i<r;i++)n=t[i]-e[i];return n}const rl=44032,nl=4352,il=4449,sl=4519,al=28,ol=588;function ll(t){return t>>24&255}function cl(t){return 16777215&t}let ul,hl,dl,pl;function fl(t){return t>=rl&&t<55204}function gl(t,e){if(t>=nl&&t<4371&&e>=il&&e<4470)return rl+(t-nl)*ol+(e-il)*al;if(fl(t)&&e>sl&&e<4547&&(t-rl)%al==0)return t+(e-sl);{let r=pl.get(t);return r&&(r=r.get(e),r)?r:-1}}function ml(t){ul||function(){let t=Wo("AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4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EqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g");ul=new Map(Ko(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),hl=new Set(Vo(t)),dl=new Map,pl=new Map;for(let[e,r]of Jo(t)){if(!hl.has(e)&&2==r.length){let[t,n]=r,i=pl.get(t);i||(i=new Map,pl.set(t,i)),i.set(n,e)}dl.set(e,r.reverse())}}();let e=[],r=[],n=!1;function i(t){let r=ul.get(t);r&&(n=!0,t|=r),e.push(t)}for(let s of t)for(;;){if(s<128)e.push(s);else if(fl(s)){let t=s-rl,e=t%ol/al|0,r=t%al;i(nl+(t/ol|0)),i(il+e),r>0&&i(sl+r)}else{let t=dl.get(s);t?r.push(...t):i(s)}if(!r.length)break;s=r.pop()}if(n&&e.length>1){let t=ll(e[0]);for(let r=1;r<e.length;r++){let n=ll(e[r]);if(0==n||t<=n){t=n;continue}let i=r-1;for(;;){let r=e[i+1];if(e[i+1]=e[i],e[i]=r,!i)break;if(t=ll(e[--i]),t<=n)break}t=ll(e[r])}}return e}function _l(t){return ml(t).map(cl)}function yl(t){return function(t){let e=[],r=[],n=-1,i=0;for(let s of t){let t=ll(s),a=cl(s);if(-1==n)0==t?n=a:e.push(a);else if(i>0&&i>=t)0==t?(e.push(n,...r),r.length=0,n=a):r.push(a),i=t;else{let s=gl(n,a);s>=0?n=s:0==i&&0==t?(e.push(n),n=a):(r.push(a),i=t)}}return n>=0&&e.push(n,...r),e}(ml(t))}const vl=".",wl=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,Pl,Cl,Tl,Rl,Ml,Gl;function Bl(){if(El)return;let t=Wo("AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3Y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35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI");const e=()=>Vo(t),r=()=>new Set(e()),n=(t,e)=>e.forEach((e=>t.add(e)));El=new Map(Jo(t)),xl=r(),kl=e(),Sl=new Set(e().map((t=>kl[t]))),kl=new Set(kl),Nl=r(),r();let i=Ko(t),s=t();const a=()=>{let t=new Set;return e().forEach((e=>n(t,i[e]))),n(t,e()),t};Pl=qo((e=>{let r=qo(t).map((t=>t+96));if(r.length){let n=e>=s;return r[0]-=32,r=tl(r),n&&(r=`Restricted[${r}]`),{N:r,P:a(),Q:a(),M:!t(),R:n}}})),Cl=r(),Tl=new Map;let o=e().concat(wl(Cl)).sort(((t,e)=>t-e));o.forEach(((e,r)=>{let n=t(),i=o[r]=n?o[r-n]:{V:[],M:new Map};i.V.push(e),Cl.has(e)||Tl.set(e,i)}));for(let{V:u,M:h}of new Set(Tl.values())){let t=[];for(let r of u){let e=Pl.filter((t=>bl(t,r))),i=t.find((({G:t})=>e.some((e=>t.has(e)))));i||(i={G:new Set,V:[]},t.push(i)),i.V.push(r),n(i.G,e)}let e=t.flatMap((t=>wl(t.G)));for(let{G:r,V:n}of t){let t=new Set(e.filter((t=>!r.has(t))));for(let e of n)h.set(e,t)}}Rl=new Set;let l=new Set;const c=t=>Rl.has(t)?l.add(t):Rl.add(t);for(let u of Pl){for(let t of u.P)c(t);for(let t of u.Q)c(t)}for(let u of Rl)Tl.has(u)||l.has(u)||Tl.set(u,1);n(Rl,_l(Rl)),Ml=function(t){let e=[],r=Vo(t);return function t({S:r,B:n},i,s){if(!(4&r&&s===i[i.length-1])){2&r&&(s=i[i.length-1]),1&r&&e.push(i);for(let e of n)for(let r of e.Q)t(e,[...i,r],s)}}(function e(n){return{S:t(),B:qo((()=>{let n=Vo(t).map((t=>r[t]));if(n.length)return e(n)})),Q:n}}([]),[]),e}(t).map((t=>Al.from(t))).sort(el),Gl=new Map;for(let u of Ml){let t=[Gl];for(let e of u){let r=t.map((t=>{let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}));65039===e?t.push(...r):t=r}for(let e of t)e.V=u}}function Il(t){return(Ul(t)?"":`${Ol(Fl([t]))} `)+$o(t)}function Ol(t){return`"${t}"`}function Fl(t,e=1/0,r=$o){let n=[];var i;i=t[0],Bl(),kl.has(i)&&n.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let s=0,a=t.length;for(let o=0;o<a;o++){let e=t[o];Ul(e)&&(n.push(tl(t.slice(s,o))),n.push(r(e)),s=o+1)}return n.push(tl(t.slice(s,a))),n.join("")}function Ul(t){return Bl(),Nl.has(t)}function Ll(t){return e=function(t,e,r){if(!t)return[];Bl();let n=0;return t.split(vl).map((t=>{let i=function(t){let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r);r+=n<65536?1:2,e.push(n)}return e}(t),s={input:i,offset:n};n+=i.length+1;try{let t,n=s.tokens=function(t,e,r){let n=[],i=[];for(t=t.slice().reverse();t.length;){let s=Ql(t);if(s)i.length&&(n.push(e(i)),i=[]),n.push(r(s));else{let e=t.pop();if(Rl.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&&n.push(e(i)),n}(i,e,r),a=n.length;if(!a)throw new Error("empty label");let o=s.output=n.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(o),!(s.emoji=a>1||n[0].is_emoji)&&o.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))}"`)}(o),t="ASCII";else{let e=n.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(kl.has(o[0]))throw Hl("leading combining mark");for(let t=1;t<a;t++){let e=n[t];if(!e.is_emoji&&kl.has(e[0]))throw Hl(`emoji + combining mark: "${tl(n[t-1])} + ${Fl([e[0]])}"`)}!function(t){let e=t[0],r=Ho.get(e);if(r)throw Hl(`leading ${r}`);let n=t.length,i=-1;for(let s=1;s<n;s++){e=t[s];let n=Ho.get(e);if(n){if(i==s)throw Hl(`${r} + ${n}`);i=s+1,r=n}}if(i==n)throw Hl(`trailing ${r}`)}(o);let r=wl(new Set(e)),[i]=function(t){let e=Pl;for(let r of t){let t=e.filter((t=>bl(t,r)));if(!t.length)throw Pl.some((t=>bl(t,r)))?jl(e[0],r):Dl(r);if(e=t,1==t.length)break}return e}(r);!function(t,e){for(let r of e)if(!bl(t,r))throw jl(t,r);if(t.M){let t=_l(e);for(let e=1,r=t.length;e<r;e++)if(Sl.has(t[e])){let n=e+1;for(let i;n<r&&Sl.has(i=t[n]);n++)for(let r=e;r<n;r++)if(t[r]==i)throw new Error(`duplicate non-spacing marks: ${Il(i)}`);if(n-e>4)throw new Error(`excessive non-spacing marks: ${Ol(Fl(t.slice(e-1,n)))} (${n-e}/4)`);e=n}}}(i,e),function(t,e){let r,n=[];for(let i of e){let t=Tl.get(i);if(1===t)return;if(t){let e=t.M.get(i);if(r=r?r.filter((t=>e.has(t))):wl(e),!r.length)return}else n.push(i)}if(r)for(let i of r)if(n.every((t=>bl(i,t))))throw new Error(`whole-script confusable: ${t.N}/${i.N}`)}(i,r),t=i.N}else t="Emoji"}s.type=t}catch(a){s.error=a}return s}))}(t,yl,Wl),e.map((({input:t,error:r,output:n})=>{if(r){let n=r.message;throw new Error(1==e.length?n:`Invalid label ${Ol(Fl(t,63))}: ${n}`)}return tl(n)})).join(vl);var e}function Dl(t){return new Error(`disallowed character: ${Il(t)}`)}function jl(t,e){let r=Il(e),n=Pl.find((t=>t.P.has(e)));return n&&(r=`${n.N} ${r}`),new Error(`illegal mixture: ${t.N} + ${r}`)}function Hl(t){return new Error(`illegal placement: ${t}`)}function Wl(t){return t.filter((t=>65039!=t))}function Ql(t,e){let r,n=Gl,i=t.length;for(;i&&(n=n.get(t[--i]),n);){let{V:s}=n;s&&(r=s,e&&e.push(...t.slice(i).reverse()),t.length=i)}return r}const zl=new Uint8Array(32);function Vl(t){return Or(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Kl(t){const e=yn(function(t){try{if(0===t.length)throw new Error("empty label");return Ll(t)}catch(e){Or(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),r=[];if(0===t.length)return r;let n=0;for(let i=0;i<e.length;i++){46===e[i]&&(r.push(Vl(e.slice(n,i))),n=i+1)}return Or(n<e.length,"invalid ENS name; empty component","name",t),r.push(Vl(e.slice(n))),r}function Jl(t){Or("string"==typeof t,"invalid ENS name; not a string","name",t),Or(t.length,"invalid ENS name (empty label)","name",t);let e=zl;const r=Kl(t);for(;r.length;)e=ws(Kr([e,ws(r.pop())]));return Vr(e)}function ql(t,e){const r=null!=e?e:63;return Or(r<=255,"DNS encoded label cannot exceed 255","length",r),Vr(Kr(Kl(t).map((e=>{Or(e.length<=r,`label ${JSON.stringify(t)} exceeds ${r} bytes`,"name",t);const n=new Uint8Array(e.length+1);return n.set(e,1),n[0]=n.length-1,n}))))+"00"}zl.fill(0);const Yl=new Uint8Array(32);Yl.fill(0);const Zl=BigInt(-1),Xl=BigInt(0),$l=BigInt(1),tc=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const ec=un($l,32),rc=un(Xl,32),nc={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},ic=["name","version","chainId","verifyingContract","salt"];function sc(t){return function(e){return Or("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const ac={name:sc("name"),version:sc("version"),chainId:function(t){const e=sn(t,"domain.chainId");return Or(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):dn(e)},verifyingContract:function(t){try{return Va(t).toLowerCase()}catch(e){}Or(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=jr(t,"domain.salt");return Or(32===e.length,'invalid domain value "salt"',"domain.salt",t),Vr(e)}};function oc(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const r=""===e[1],n=parseInt(e[2]);Or(n%8==0&&0!==n&&n<=256&&e[2]===String(n),"invalid numeric width","type",t);const i=nn(tc,r?n-1:n),s=r?(i+$l)*Zl:Xl;return function(e){const n=sn(e,"value");return Or(n>=s&&n<=i,`value out-of-bounds for ${t}`,"value",n),un(r?rn(n,256):n,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return Or(0!==r&&r<=32&&e[1]===String(r),"invalid bytes width","type",t),function(e){return Or(jr(e).length===r,`invalid length for ${t}`,"value",e),function(t){const e=jr(t),r=e.length%32;return r?Kr([e,Yl.slice(r)]):Vr(e)}(e)}}}switch(t){case"address":return function(t){return Zr(Va(t),32)};case"bool":return function(t){return t?ec:rc};case"bytes":return function(t){return ws(t)};case"string":return function(t){return jo(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}}Pt=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Rt=new WeakSet,Mt=function(t){{const e=oc(t);if(e)return e}const e=cc(t).array;if(e){const t=e.prefix,r=this.getEncoder(t);return n=>{Or(-1===e.count||e.count===n.length,`array length mismatch; expected length ${e.count}`,"value",n);let i=n.map(r);return __privateGet(this,Ct).has(t)&&(i=i.map(ws)),ws(Kr(i))}}const r=this.types[t];if(r){const e=jo(__privateGet(this,Ct).get(t));return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return __privateGet(this,Ct).has(r)?ws(n):n}));return n.unshift(e),Kr(n)}}Or(!1,`unknown type: ${t}`,"type",t)};let uc=class t{constructor(t){__privateAdd(this,Rt),__publicField(this,"primaryType"),__privateAdd(this,Pt,void 0),__privateAdd(this,Ct,void 0),__privateAdd(this,Tt,void 0),__privateSet(this,Ct,new Map),__privateSet(this,Tt,new Map);const e=new Map,r=new Map,n=new Map,i={};Object.keys(t).forEach((s=>{i[s]=t[s].map((({name:e,type:r})=>{let{base:n,index:i}=cc(r);return"int"!==n||t.int||(n="int256"),"uint"!==n||t.uint||(n="uint256"),{name:e,type:n+(i||"")}})),e.set(s,new Set),r.set(s,[]),n.set(s,new Set)})),__privateSet(this,Pt,JSON.stringify(i));for(const a in i){const n=new Set;for(const s of i[a]){Or(!n.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(a)}`,"types",t),n.add(s.name);const i=cc(s.type).base;Or(i!==a,`circular type reference to ${JSON.stringify(i)}`,"types",t);oc(i)||(Or(r.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),r.get(i).push(a),e.get(a).add(i))}}const s=Array.from(r.keys()).filter((t=>0===r.get(t).length));Or(0!==s.length,"missing primary type","types",t),Or(1===s.length,`ambiguous primary types or unused types: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Tr(this,{primaryType:s[0]}),function i(s,a){Or(!a.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),a.add(s);for(const t of e.get(s))if(r.has(t)){i(t,a);for(const e of a)n.get(e).add(t)}a.delete(s)}(this.primaryType,new Set);for(const[a,o]of n){const t=Array.from(o);t.sort(),__privateGet(this,Ct).set(a,lc(a,i[a])+t.map((t=>lc(t,i[t]))).join(""))}}get types(){return JSON.parse(__privateGet(this,Pt))}getEncoder(t){let e=__privateGet(this,Tt).get(t);return e||(e=__privateMethod(this,Rt,Mt).call(this,t),__privateGet(this,Tt).set(t,e)),e}encodeType(t){const e=__privateGet(this,Ct).get(t);return Or(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return ws(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(oc(t))return r(t,e);const n=cc(t).array;if(n)return Or(-1===n.count||n.count===e.length,`array length mismatch; expected length ${n.count}`,"value",e),e.map((t=>this._visit(n.prefix,t,r)));const i=this.types[t];if(i)return i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{});Or(!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,r,n){return t.from(r).hashStruct(e,n)}static hashDomain(e){const r=[];for(const t in e){if(null==e[t])continue;const n=nc[t];Or(n,`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",e),r.push({name:t,type:n})}return r.sort(((t,e)=>ic.indexOf(t.name)-ic.indexOf(e.name))),t.hashStruct("EIP712Domain",{EIP712Domain:r},e)}static encode(e,r,n){return Kr(["0x1901",t.hashDomain(e),t.from(r).hash(n)])}static hash(e,r,n){return ws(t.encode(e,r,n))}static resolveNames(e,r,n,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&&!Wr(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const a=t.from(r);a.visit(n,((t,e)=>("address"!==t||Wr(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]),n=a.visit(n,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:e,value:n}}))}static getPayload(e,r,n){t.hashDomain(e);const i={},s=[];ic.forEach((t=>{const r=e[t];null!=r&&(i[t]=ac[t](r),s.push({name:t,type:nc[t]}))}));const a=t.from(r);r=a.types;const o=Object.assign({},r);return Or(null==o.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",r),o.EIP712Domain=s,a.encode(n),{types:o,domain:i,primaryType:a.primaryType,message:a.visit(n,((t,e)=>{if(t.match(/^bytes(\d*)/))return Vr(jr(e));if(t.match(/^u?int/))return sn(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return Or("string"==typeof e,"invalid string","value",e),e}Or(!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(" ")),vc=hc([gc,_c,"tuple returns",pc].join(" ").split(" ")),wc={"(":"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,Gt,void 0),__privateAdd(this,Bt,void 0),__privateSet(this,Gt,0),__privateSet(this,Bt,t.slice())}get offset(){return __privateGet(this,Gt)}get length(){return __privateGet(this,Bt).length-__privateGet(this,Gt)}clone(){return new t(__privateGet(this,Bt))}reset(){__privateSet(this,Gt,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,Gt)+1,t.match+1);return __privateSet(this,Gt,t.match+1),e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;__privateGet(this,Gt)<t.match-1;){const t=this.peek().linkNext;e.push(__privateMethod(this,It,Ot).call(this,__privateGet(this,Gt)+1,t)),__privateSet(this,Gt,t)}return __privateSet(this,Gt,t.match+1),e}peek(){if(__privateGet(this,Gt)>=__privateGet(this,Bt).length)throw new Error("out-of-bounds");return __privateGet(this,Bt)[__privateGet(this,Gt)]}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,Gt)._++,t}toString(){const t=[];for(let e=__privateGet(this,Gt);e<__privateGet(this,Bt).length;e++){const r=__privateGet(this,Bt)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Gt=new WeakMap,Bt=new WeakMap,It=new WeakSet,Ot=function(t=0,e=0){return new Sc(__privateGet(this,Bt).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 Pc(t){const e=[],r=e=>{const r=s<t.length?JSON.stringify(t[s]):"$EOI";throw new Error(`invalid token ${r} at ${s}: ${e}`)};let n=[],i=[],s=0;for(;s<t.length;){let a=t.substring(s),o=a.match(bc);o&&(s+=o[1].length,a=t.substring(s));const l={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(l);let c=wc[a[0]]||"";if(c){if(l.type=c,l.text=a[0],s++,"OPEN_PAREN"===c)n.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("no matching open bracket"),l.match=n.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 r=e.pop().text;t=r+t,e[e.length-1].value=cn(r)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(o=a.match(Ec),o){if(l.text=o[1],s+=l.text.length,vc.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(kc)){l.type="TYPE";continue}l.type="ID"}else{if(o=a.match(Ac),!o)throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${s}`);l.text=o[1],l.type="NUMBER",s+=l.text.length}}return new Nc(e.map((t=>Object.freeze(t))))}function Cc(t,e){let r=[];for(const n in e.keys())t.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Tc(t,e){if(e.peekKeyword(mc)){const r=e.pop().text;if(r!==t)throw new Error(`expected ${t}, got ${r}`)}return e.popType("ID")}function Rc(t,e){const r=new Set;for(;;){const n=t.peekType("KEYWORD");if(null==n||e&&!e.has(n))break;if(t.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Mc(t){let e=Rc(t,fc);return Cc(e,hc("constant payable nonpayable".split(" "))),Cc(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 Gc(t,e){return t.popParams().map((t=>Kc.from(t,e)))}function Bc(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return sn(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 Fc(t){const e=t.match(kc);if(Or(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const r=parseInt(e[2]);Or(0!==r&&r<=32,"invalid bytes length","type",t)}else if(e[3]){const r=parseInt(e[3]);Or(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",t)}return t}const Uc={},Lc=Symbol.for("_ethers_internal"),Dc="_ParamTypeInternal",jc="_ErrorInternal",Hc="_EventInternal",Wc="_ConstructorInternal",Qc="_FallbackInternal",zc="_FunctionInternal",Vc="_StructInternal";Ft=new WeakSet,Ut=function(t,e,r,n){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,n)=>{var a;__privateMethod(a=i,Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(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,n)=>{var a;__privateMethod(a=i[n],Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(s)}const i=r(this.type,e);i.then?t.push(function(){return __async(this,null,(function*(){n(yield i)}))}()):n(i)};let Kc=class t{constructor(t,e,r,n,i,s,a,o){if(__privateAdd(this,Ft),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),Lr(t,Uc,"ParamType"),Object.defineProperty(this,Lc,{value:Dc}),s&&(s=Object.freeze(s.slice())),"array"===n){if(null==a||null==o)throw new Error("")}else if(null!=a||null!=o)throw new Error("");if("tuple"===n){if(null==s)throw new Error("")}else if(null!=s)throw new Error("");Tr(this,{name:e,type:r,baseType:n,indexed:i,components:s,arrayLength:a,arrayChildren:o})}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 r={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(r)}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 r=this;return t.map((t=>r.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 r=this;return t.map(((t,n)=>r.components[n].walk(t,e)))}return e(this.type,t)}walkAsync(t,e){return __async(this,null,(function*(){const r=[],n=[t];return __privateMethod(this,Ft,Ut).call(this,r,t,e,(t=>{n[0]=t})),r.length&&(yield Promise.all(r)),n[0]}))}static from(e,r){if(t.isParamType(e))return e;if("string"==typeof e)try{return t.from(Pc(e),r)}catch(o){Or(!1,"invalid param type","obj",e)}else if(e instanceof Nc){let n="",i="",s=null;Rc(e,hc(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(i="tuple",s=e.popParams().map((e=>t.from(e))),n=`tuple(${s.map((t=>t.format())).join(",")})`):(n=Fc(e.popType("TYPE")),i=n);let a=null,o=null;for(;e.length&&e.peekType("BRACKET");){const r=e.pop();a=new t(Uc,"",n,i,null,s,o,a),o=r.value,n+=r.text,i="array",s=null}let l=null;if(Rc(e,yc).has("indexed")){if(!r)throw new Error("");l=!0}const c=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new t(Uc,c,n,i,l,s,o,a)}const n=e.name;Or(!n||"string"==typeof n&&n.match(xc),"invalid name","obj.name",n);let i=e.indexed;null!=i&&(Or(r,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,a=s.match(Oc);if(a){const r=parseInt(a[2]||"-1"),o=t.from({type:a[1],components:e.components});return new t(Uc,n||"",s,"array",i,null,r,o)}if("tuple"===s||s.startsWith("tuple(")||s.startsWith("(")){const r=null!=e.components?e.components.map((e=>t.from(e))):null;return new t(Uc,n||"",s,"tuple",i,r,null,null)}return s=Fc(e.type),new t(Uc,n||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Lc]===Dc}};class Jc{constructor(t,e,r){__publicField(this,"type"),__publicField(this,"inputs"),Lr(t,Uc,"Fragment"),Tr(this,{type:e,inputs:r=Object.freeze(r.slice())})}static from(t){if("string"==typeof t){try{Jc.from(JSON.parse(t))}catch(e){}return Jc.from(Pc(t))}if(t instanceof Nc){switch(t.peekKeyword(mc)){case"constructor":return $c.from(t);case"error":return Zc.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 ru.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return $c.from(t);case"error":return Zc.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 ru.from(t)}Ir(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}Or(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return $c.isFragment(t)}static isError(t){return Zc.isFragment(t)}static isEvent(t){return Xc.isFragment(t)}static isFunction(t){return eu.isFragment(t)}static isStruct(t){return ru.isFragment(t)}}class qc extends Jc{constructor(t,e,r,n){super(t,e,n),__publicField(this,"name"),Or("string"==typeof r&&r.match(xc),"invalid identifier","name",r),n=Object.freeze(n.slice()),Tr(this,{name:r})}}function Yc(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class Zc extends qc{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Lc,{value:jc})}get selector(){return jo(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+Yc(t,this.inputs)),e.join(" ")}static from(t){if(Zc.isFragment(t))return t;if("string"==typeof t)return Zc.from(Pc(t));if(t instanceof Nc){const e=Tc("error",t),r=Gc(t);return Ic(t),new Zc(Uc,e,r)}return new Zc(Uc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Lc]===jc}}class Xc extends qc{constructor(t,e,r,n){super(t,"event",e,r),__publicField(this,"anonymous"),Object.defineProperty(this,Lc,{value:Hc}),Tr(this,{anonymous:n})}get topicHash(){return jo(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+Yc(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(Uc,t,e,!1).topicHash}static from(t){if(Xc.isFragment(t))return t;if("string"==typeof t)try{return Xc.from(Pc(t))}catch(e){Or(!1,"invalid event fragment","obj",t)}else if(t instanceof Nc){const e=Tc("event",t),r=Gc(t,!0),n=!!Rc(t,hc(["anonymous"])).has("anonymous");return Ic(t),new Xc(Uc,e,r,n)}return new Xc(Uc,t.name,t.inputs?t.inputs.map((t=>Kc.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Lc]===Hc}}class $c extends Jc{constructor(t,e,r,n,i){super(t,e,r),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Lc,{value:Wc}),Tr(this,{payable:n,gas:i})}format(t){if(Ir(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${Yc(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(Pc(t))}catch(e){Or(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Nc){Rc(t,hc(["constructor"]));const e=Gc(t),r=!!Rc(t,dc).has("payable"),n=Bc(t);return Ic(t),new $c(Uc,"constructor",e,r,n)}return new $c(Uc,"constructor",t.inputs?t.inputs.map(Kc.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Lc]===Wc}}class tu extends Jc{constructor(t,e,r){super(t,"fallback",e),__publicField(this,"payable"),Object.defineProperty(this,Lc,{value:Qc}),Tr(this,{payable:r})}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(Pc(t))}catch(e){Or(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Nc){const e=t.toString();Or(t.peekKeyword(hc(["fallback","receive"])),"type must be fallback or receive","obj",e);if("receive"===t.popKeyword(hc(["fallback","receive"]))){const e=Gc(t);return Or(0===e.length,"receive cannot have arguments","obj.inputs",e),Rc(t,hc(["payable"])),Ic(t),new tu(Uc,[],!0)}let r=Gc(t);r.length?Or(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Kc.from("bytes")];const n=Mc(t);if(Or("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Rc(t,hc(["returns"])).has("returns")){const e=Gc(t);Or(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Ic(t),new tu(Uc,r,"payable"===n)}if("receive"===t.type)return new tu(Uc,[],!0);if("fallback"===t.type){const e=[Kc.from("bytes")],r="payable"===t.stateMutability;return new tu(Uc,e,r)}Or(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Lc]===Qc}}class eu extends qc{constructor(t,e,r,n,i,s){super(t,"function",e,n),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Lc,{value:zc});Tr(this,{constant:"view"===r||"pure"===r,gas:s,outputs:i=Object.freeze(i.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return jo(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+Yc(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(Yc(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(Uc,t,"view",e,[],null).selector}static from(t){if(eu.isFragment(t))return t;if("string"==typeof t)try{return eu.from(Pc(t))}catch(r){Or(!1,"invalid function fragment","obj",t)}else if(t instanceof Nc){const e=Tc("function",t),r=Gc(t),n=Mc(t);let i=[];Rc(t,hc(["returns"])).has("returns")&&(i=Gc(t));const s=Bc(t);return Ic(t),new eu(Uc,e,n,r,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(Uc,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[Lc]===zc}}class ru extends qc{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Lc,{value:Vc})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return ru.from(Pc(t))}catch(e){Or(!1,"invalid struct fragment","obj",t)}else if(t instanceof Nc){const e=Tc("struct",t),r=Gc(t);return Ic(t),new ru(Uc,e,r)}return new ru(Uc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Lc]===Vc}}const nu=new Map;nu.set(0,"GENERIC_PANIC"),nu.set(1,"ASSERT_FALSE"),nu.set(17,"OVERFLOW"),nu.set(18,"DIVIDE_BY_ZERO"),nu.set(33,"ENUM_RANGE_ERROR"),nu.set(34,"BAD_STORAGE_DATA"),nu.set(49,"STACK_UNDERFLOW"),nu.set(50,"ARRAY_RANGE_ERROR"),nu.set(65,"OUT_OF_MEMORY"),nu.set(81,"UNINITIALIZED_FUNCTION_CALL");const iu=new RegExp(/^bytes([0-9]*)$/),su=new RegExp(/^(u?int)([0-9]*)$/);let au=null,ou=1024;Lt=new WeakSet,Dt=function(t){if(t.isArray())return new so(__privateMethod(this,Lt,Dt).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new yo(t.components.map((t=>__privateMethod(this,Lt,Dt).call(this,t))),t.name);switch(t.baseType){case"address":return new eo(t.name);case"bool":return new ao(t.name);case"string":return new _o(t.name);case"bytes":return new lo(t.name);case"":return new ho(t.name)}let e=t.type.match(su);if(e){let r=parseInt(e[2]||"256");return Or(0!==r&&r<=256&&r%8==0,"invalid "+e[1]+" bit length","param",t),new mo(r/8,"int"===e[1],t.name)}if(e=t.type.match(iu),e){let r=parseInt(e[1]);return Or(0!==r&&r<=32,"invalid bytes length","param",t),new co(r,t.name)}Or(!1,"invalid type","type",t.type)};let lu=class t{constructor(){__privateAdd(this,Lt)}getDefaultValue(t){const e=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Kc.from(t))));return new yo(e,"_").defaultValue()}encode(t,e){Fr(e.length,t.length,"types/values length mismatch");const r=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Kc.from(t)))),n=new yo(r,"_"),i=new _i;return n.encode(i,e),i.data}decode(t,e,r){const n=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Kc.from(t))));return new yo(n,"_").decode(new yi(e,r,ou))}static _setDefaultMaxInflation(t){Or("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),ou=t}static defaultAbiCoder(){return null==au&&(au=new t),au}static getBuiltinCallException(e,r,n){return function(t,e,r,n){let i="missing revert data",s=null,a=null;if(r){i="execution reverted";const t=jr(r);if(r=Vr(r),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"===Vr(t.slice(0,4)))try{s=n.decode(["string"],t.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch(l){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===Vr(t.slice(0,4)))try{const e=Number(n.decode(["uint256"],t.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[e]},s=`Panic due to ${nu.get(e)||"UNKNOWN"}(${e})`,i+=`: ${s}`}catch(l){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const o={to:e.to?Va(e.to):null,data:e.data||"0x"};return e.from&&(o.from=Va(e.from)),Br(i,"CALL_EXCEPTION",{action:t,data:r,reason:s,transaction:o,invocation:null,revert:a})}(e,r,n,t.defaultAbiCoder())}};class cu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,signature:i,topic:e,args:r})}}class uu{constructor(t,e,r,n){__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();Tr(this,{fragment:t,name:i,args:r,signature:s,selector:e,value:n})}}class hu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,args:r,signature:i,selector:e})}}class du{constructor(t){__publicField(this,"hash"),__publicField(this,"_isIndexed"),Tr(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,r){if(Wr(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 n=[];for(const[e,r]of __privateGet(this,Wt))e.split("(")[0]===t&&n.push(r);if(e){const t=e.length>0?e[e.length-1]:null;let r=e.length,i=!0;to.isTyped(t)&&"overrides"===t.type&&(i=!1,r--);for(let e=n.length-1;e>=0;e--){const t=n[e].inputs.length;t===r||i&&t===r-1||n.splice(e,1)}for(let s=n.length-1;s>=0;s--){const t=n[s].inputs;for(let r=0;r<e.length;r++)if(to.isTyped(e[r])){if(r>=t.length){if("overrides"===e[r].type)continue;n.splice(s,1);break}if(e[r].type!==t[r].baseType){n.splice(s,1);break}}}}if(1===n.length&&e&&e.length!==n[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&n.splice(0,1)}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous function description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Wt).get(eu.from(t).format());return n||null},Kt=new WeakSet,Jt=function(t,e,r){if(Wr(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 n=[];for(const[e,r]of __privateGet(this,Ht))e.split("(")[0]===t&&n.push(r);if(e){for(let t=n.length-1;t>=0;t--)n[t].inputs.length<e.length&&n.splice(t,1);for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(to.isTyped(e[i])&&e[i].type!==r[i].baseType){n.splice(t,1);break}}}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous event description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Ht).get(Xc.from(t).format());return n||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 r=[];for(const a of e)try{r.push(Jc.from(a))}catch(s){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,s.message)}Tr(this,{fragments:Object.freeze(r)});let n=null,i=!1;__privateSet(this,Qt,this.getAbiCoder()),this.fragments.forEach(((t,e)=>{let r;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void Tr(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(Or(!n||t.payable!==n.payable,"conflicting fallback fragments",`fragments[${e}]`,t),n=t,i=n.payable));case"function":r=__privateGet(this,Wt);break;case"event":r=__privateGet(this,Ht);break;case"error":r=__privateGet(this,jt);break;default:return}const s=t.format();r.has(s)||r.set(s,t)})),this.deploy||Tr(this,{deploy:$c.from("constructor()")}),Tr(this,{fallback:n,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 Or(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 r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Wt).get(n),r)}}getEventName(t){const e=__privateMethod(this,Kt,Jt).call(this,t,null,!1);return Or(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 r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Ht).get(n),r)}}getError(t,e){if(Wr(t)){const e=t.toLowerCase();if(fu[e])return Zc.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[r,n]of __privateGet(this,jt))r.split("(")[0]===t&&e.push(n);if(0===e.length)return"Error"===t?Zc.from("error Error(string)"):"Panic"===t?Zc.from("error Panic(uint256)"):null;if(e.length>1){Or(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t)}return e[0]}if("Error(string)"===(t=Zc.from(t).format()))return Zc.from("error Error(string)");if("Panic(uint256)"===t)return Zc.from("error Panic(uint256)");const r=__privateGet(this,jt).get(t);return r||null}forEachError(t){const e=Array.from(__privateGet(this,jt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,jt).get(n),r)}}_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);Or(e,"unknown error","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Or(e,"unknown error","fragment",t),t=e}return Kr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Kr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}let r="invalid length for result data";const n=Hr(e);if(n.length%32==0)try{return __privateGet(this,Qt).decode(t.outputs,n)}catch(i){r="could not decode result data"}Ir(!1,r,"BAD_DATA",{value:Vr(n),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=jr(t,"data"),n=lu.getBuiltinCallException("call",e,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const t=Vr(r.slice(0,4)),e=this.getError(t);if(e)try{const t=__privateGet(this,Qt).decode(e.inputs,r.slice(4));n.revert={name:e.name,signature:e.format(),args:t},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(s){n.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(n.invocation={method:i.name,signature:i.signature,args:i.args}),n}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Vr(__privateGet(this,Qt).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}Ir(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const n=(t,e)=>"string"===t.type?jo(e):"bytes"===t.type?ws(Vr(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=un(e):t.type.match(/^bytes/)?e=Yr(e,32,!1):"address"===t.type&&__privateGet(this,Qt).encode(["address"],[e]),Zr(Vr(e),32));for(e.forEach(((e,i)=>{const s=t.inputs[i];s.indexed?null==e?r.push(null):"array"===s.baseType||"tuple"===s.baseType?Or(!1,"filtering with tuples or arrays not supported","contract."+s.name,e):Array.isArray(e)?r.push(e.map((t=>n(s,t)))):r.push(n(s,e)):Or(null==e,"cannot filter non-indexed parameters; must be null","contract."+s.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}const r=[],n=[],i=[];return t.anonymous||r.push(t.topicHash),Or(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,s)=>{const a=e[s];if(t.indexed)if("string"===t.type)r.push(jo(a));else if("bytes"===t.type)r.push(ws(a));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(__privateGet(this,Qt).encode([t.type],[a]))}else n.push(t),i.push(a)})),{data:__privateGet(this,Qt).encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}if(null!=r&&!t.anonymous){const e=t.topicHash;Or(Wr(r[0],32)&&r[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],i=[],s=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Kc.from({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))}));const a=null!=r?__privateGet(this,Qt).decode(n,Kr(r)):null,o=__privateGet(this,Qt).decode(i,e,!0),l=[],c=[];let u=0,h=0;return t.inputs.forEach(((t,e)=>{let r=null;if(t.indexed)if(null==a)r=new du(null);else if(s[e])r=new du(a[h++]);else try{r=a[h++]}catch(n){r=n}else try{r=o[u++]}catch(n){r=n}l.push(r),c.push(t.name||null)})),fi.fromItems(l,c)}parseTransaction(t){const e=jr(t.data,"tx.data"),r=sn(null!=t.value?t.value:0,"tx.value"),n=this.getFunction(Vr(e.slice(0,4)));if(!n)return null;const i=__privateGet(this,Qt).decode(n.inputs,e.slice(4));return new uu(n,n.selector,i,r)}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=Vr(t),r=this.getError(qr(e,0,4));if(!r)return null;const n=__privateGet(this,Qt).decode(r.inputs,qr(e,4));return new hu(r,r.selector,n)}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 vu{constructor(t,e,r){__publicField(this,"gasPrice"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxPriorityFeePerGas"),Tr(this,{gasPrice:_u(t),maxFeePerGas:_u(e),maxPriorityFeePerGas:_u(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:yu(t),maxFeePerGas:yu(e),maxPriorityFeePerGas:yu(r)}}}function wu(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=Vr(t.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of r)i in t&&null!=t[i]&&(e[i]=sn(t[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)i in t&&null!=t[i]&&(e[i]=cn(t[i],`request.${i}`));return t.accessList&&(e.accessList=wo(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=>Qr(t)?Vr(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))),Tr(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?[]:(Ir("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:n,gasUsed:i,hash:s,miner:a,prevRandao:o,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:r,gasLimit:yu(n),gasUsed:yu(i),blobGasUsed:yu(this.blobGasUsed),excessBlobGas:yu(this.excessBlobGas),hash:s,miner:a,prevRandao:o,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 r=t.toLowerCase();for(const t of __privateGet(this,qt)){if("string"==typeof t){if(t!==r)continue;e=t;break}if(t.hash===r){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 r of e)if(r.hash===t)return r;Or(!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 r=Object.freeze(t.topics.slice());Tr(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);return Ir(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.transactionHash);return Ir(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransactionReceipt(){return __async(this,null,(function*(){const t=yield this.provider.getTransactionReceipt(this.transactionHash);return Ir(!!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,Yt,void 0),__privateSet(this,Yt,Object.freeze(t.logs.map((t=>new Au(t,e)))));let r=mu;null!=t.effectiveGasPrice?r=t.effectiveGasPrice:null!=t.gasPrice&&(r=t.gasPrice),Tr(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:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return __privateGet(this,Yt)}toJSON(){const{to:t,from:e,contractAddress:r,hash:n,index:i,blockHash:s,blockNumber:a,logsBloom:o,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:s,blockNumber:a,contractAddress:r,cumulativeGasUsed:yu(this.cumulativeGasUsed),from:e,gasPrice:yu(this.gasPrice),blobGasUsed:yu(this.blobGasUsed),blobGasPrice:yu(this.blobGasPrice),gasUsed:yu(this.gasUsed),hash:n,index:i,logs:l,logsBloom:o,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 Ir(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ku(this,t)}}Yt=new WeakMap;Zt=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,Zt,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,Zt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:n,type:i,to:s,from:a,nonce:o,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:a,gasLimit:yu(this.gasLimit),gasPrice:yu(this.gasPrice),hash:n,maxFeePerGas:yu(this.maxFeePerGas),maxPriorityFeePerGas:yu(this.maxPriorityFeePerGas),maxFeePerBlobGas:yu(this.maxFeePerBlobGas),nonce:o,signature:c,to:s,index:r,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 Cr({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 r=null==t?1:t,n=null==e?0:e;let i=__privateGet(this,Zt),s=-1,a=-1===i;const o=()=>__async(this,null,(function*(){if(a)return null;const{blockNumber:t,nonce:e}=yield Cr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(a)return null;const n=yield this.getTransaction();if(!n||null==n.blockNumber)for(-1===s&&(s=i-3,s<__privateGet(this,Zt)&&(s=__privateGet(this,Zt)));s<=t;){if(a)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 n=0;n<e.length;n++){const s=yield e.getTransaction(n);if(s.from===this.from&&s.nonce===this.nonce){if(a)return null;const e=yield this.provider.getTransactionReceipt(s.hash);if(null==e)return;if(t-e.blockNumber+1<r)return;let n="replaced";s.data===this.data&&s.to===this.to&&s.value===this.value?n="repriced":"0x"===s.data&&s.from===s.to&&s.value===mu&&(n="cancelled"),Ir(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:s.replaceableTransaction(i),hash:s.hash,receipt:e})}}s++}})),l=t=>{if(null==t||0!==t.status)return t;Ir(!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===r)return l(c);if(c){if(1===r||(yield c.confirmations())>=r)return l(c)}else if(yield o(),0===r)return null;const u=new Promise(((t,e)=>{const s=[],c=()=>{s.forEach((t=>t()))};if(s.push((()=>{a=!0})),n>0){const t=setTimeout((()=>{c(),e(Br("wait for transaction timeout","TIMEOUT"))}),n);s.push((()=>{clearTimeout(t)}))}const u=n=>__async(this,null,(function*(){if((yield n.confirmations())>=r){c();try{t(l(n))}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 o()}catch(r){if(Mr(r,"TRANSACTION_REPLACED"))return c(),void e(r)}a||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 Ir(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Su(this)}reorderedEvent(t){return Ir(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ir(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ku(this,t)}replaceableTransaction(e){Or(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const r=new t(this,this.provider);return __privateSet(r,Zt,e),r}};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,r){super(t,t.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");Tr(this,{args:e.decodeEventLog(r,t.data,t.topics),fragment:r,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Pu extends Au{constructor(t,e){super(t,t.provider),__publicField(this,"error"),Tr(this,{error:e})}}class Cu extends Eu{constructor(t,e,r){super(r,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(r){return new Pu(t,r)}return t}))}}Xt=new WeakMap;$t=new WeakMap;let Tu=class t extends xu{constructor(t,e,r){super(r,e),__privateAdd(this,$t,void 0),__privateSet(this,$t,t)}wait(e,r){return __async(this,null,(function*(){const n=yield __superGet(t.prototype,this,"wait").call(this,e,r);return null==n?null:new Cu(__privateGet(this,$t),this.provider,n)}))}};class Ru extends gn{constructor(t,e,r,n){super(t,e,r),__publicField(this,"log"),Tr(this,{log:n})}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 Mu extends Ru{constructor(t,e,r,n,i){super(t,e,r,new Nu(i,t.interface,n));Tr(this,{args:t.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Gu=BigInt(0);function Bu(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 Fu(t){return t&&"function"==typeof t.sendTransaction}function Uu(t){if(null!=t){if(Ou(t))return t;if(t.provider)return t.provider}}class Lu{constructor(t,e,r){if(__privateAdd(this,te,void 0),__publicField(this,"fragment"),Tr(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const n=Du(t.runner,"resolveName"),i=Ou(n)?n:null;__privateSet(this,te,function(){return __async(this,null,(function*(){const n=yield Promise.all(e.inputs.map(((t,e)=>null==r[e]?null:t.walkAsync(r[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>qa(t,i)))):qa(e,i):e)))));return t.interface.encodeFilterTopics(e,n)}))}())}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 r=to.dereference(t,"overrides");Or("object"==typeof r,"invalid overrides parameter","overrides",t);const n=wu(r);return Or(null==n.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),Or(null==n.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}))}function Wu(t){const e=function(e){return __async(this,null,(function*(){const r=yield Hu(e,["data"]);r.to=yield t.getAddress(),r.from&&(r.from=yield qa(r.from,Uu(t.runner)));const n=t.interface,i=sn(r.value||Gu,"overrides.value")===Gu,s="0x"===(r.data||"0x");!n.fallback||n.fallback.payable||!n.receive||s||i||Or(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data);return Or(n.receive||n.fallback&&n.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",r.value),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data),r}))},r=function(r){return __async(this,null,(function*(){const n=t.runner;Ir(Fu(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield n.sendTransaction(yield e(r)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},n=t=>__async(this,null,(function*(){return yield r(t)}));return Tr(n,{_contract:t,estimateGas:function(r){return __async(this,null,(function*(){const n=Du(t.runner,"estimateGas");return Ir(Iu(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield e(r))}))},populateTransaction:e,send:r,staticCall:function(r){return __async(this,null,(function*(){const n=Du(t.runner,"call");Ir(Bu(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield e(r);try{return yield n.call(i)}catch(s){if(Gr(s)&&s.data)throw t.interface.makeError(s.data,i);throw s}}))}}),n}function Qu(t,e){const r=function(...r){const n=t.interface.getFunction(e,r);return Ir(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return __async(this,null,(function*(){const n=r(...e);let i={};if(n.inputs.length+1===e.length&&(i=yield Hu(e.pop()),i.from&&(i.from=yield qa(i.from,Uu(t.runner)))),n.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const s=yield function(t,e,r){return __async(this,null,(function*(){const n=Du(t,"resolveName"),i=Ou(n)?n:null;return yield Promise.all(e.map(((t,e)=>t.walkAsync(r[e],((t,e)=>(e=to.dereference(e,t),"address"===t?qa(e,i):e))))))}))}(t.runner,n.inputs,e);return Object.assign({},i,yield Cr({to:t.getAddress(),data:t.interface.encodeFunctionData(n,s)}))}))},i=function(...t){return __async(this,null,(function*(){const e=yield a(...t);return 1===e.length?e[0]:e}))},s=function(...e){return __async(this,null,(function*(){const r=t.runner;Ir(Fu(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield r.sendTransaction(yield n(...e)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},a=function(...e){return __async(this,null,(function*(){const i=Du(t.runner,"call");Ir(Bu(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield n(...e);let a="0x";try{a=yield i.call(s)}catch(l){if(Gr(l)&&l.data)throw t.interface.makeError(l.data,s);throw l}const o=r(...e);return t.interface.decodeFunctionResult(o,a)}))},o=(...t)=>__async(this,null,(function*(){return r(...t).constant?yield i(...t):yield s(...t)}));return Tr(o,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:r,estimateGas:function(...e){return __async(this,null,(function*(){const r=Du(t.runner,"estimateGas");return Ir(Iu(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield n(...e))}))},populateTransaction:n,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(o,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getFunction(e);return Ir(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),o}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 r,n=null;if(Array.isArray(e)){const n=function(e){if(Wr(e,32))return e;const r=t.interface.getEvent(e);return Or(r,"unknown fragment","name",e),r.topicHash};r=e.map((t=>null==t?null:Array.isArray(t)?t.map(n):n(t)))}else"*"===e?r=[null]:"string"==typeof e?Wr(e,32)?r=[e]:(n=t.interface.getEvent(e),Or(n,"unknown fragment","event",e),r=[n.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?r=yield e.getTopicFilter():"fragment"in e?(n=e.fragment,r=[n.topicHash]):Or(!1,"unknown event name","event",e);var i;r=r.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:n,tag:r.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:r}}))}function qu(t,e){return __async(this,null,(function*(){const{subs:r}=Ku(t);return r.get((yield Ju(t,e)).tag)||null}))}function Yu(t,e,r){return __async(this,null,(function*(){const n=ju(t.runner);Ir(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:a}=yield Ju(t,r),{addr:o,subs:l}=Ku(t);let c=l.get(s);if(!c){const e={address:o||t,topics:a},u=e=>{let n=i;if(null==n)try{n=t.interface.getEvent(e.topics[0])}catch(s){}if(n){const s=n,a=i?t.interface.decodeEventLog(i,e.data,e.topics):[];Xu(t,r,a,(n=>new Mu(t,n,r,s,e)))}else Xu(t,r,[],(n=>new Ru(t,n,r,e)))};let h=[];c={tag:s,listeners:[],start:()=>{h.length||h.push(n.on(e,u))},stop:()=>__async(this,null,(function*(){if(0==h.length)return;let t=h;h=[],yield Promise.all(t),n.off(e,u)}))},l.set(s,c)}return c}))}let Zu=Promise.resolve();function Xu(t,e,r,n){return __async(this,null,(function*(){try{yield Zu}catch(s){}const i=function(t,e,r,n){return __async(this,null,(function*(){yield Zu;const i=yield qu(t,e);if(!i)return!1;const a=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const a=Array.from(r);n&&a.push(n(i?null:e));try{e.call(t,...a)}catch(s){}return!i})),0===i.listeners.length&&(i.stop(),Ku(t).subs.delete(i.tag)),a>0}))}(t,e,r,n);return Zu=i,yield i}))}const $u=["then"];ee=zu;let th=class t{constructor(t,e,r,n){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),Or("string"==typeof t||Ka(t),"invalid value for Contract target","target",t),null==r&&(r=null);const i=gu.from(e);let s;Tr(this,{target:t,runner:r,interface:i}),Object.defineProperty(this,zu,{value:{}});let a=null,o=null;if(n){const t=ju(r);o=new Tu(this.interface,t,n)}let l=new Map;if("string"==typeof t)if(Wr(t))a=t,s=Promise.resolve(t);else{const e=Du(r,"resolveName");if(!Ou(e))throw Br("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw Br("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:a,deployTx:o,subs:l},Vu.set(c[zu],u);return Tr(this,{filters:new Proxy({},{get:(t,e,r)=>{if("symbol"==typeof e||$u.indexOf(e)>=0)return Reflect.get(t,e,r);try{return this.getEvent(e)}catch(n){if(!Mr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(t,e)=>$u.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))})}),Tr(this,{fallback:i.receive||i.fallback?Wu(this):null}),new Proxy(this,{get:(t,e,r)=>{if("symbol"==typeof e||e in t||$u.indexOf(e)>=0)return Reflect.get(t,e,r);try{return t.getFunction(e)}catch(n){if(!Mr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},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);Ir(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 Ir(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,r)=>{const n=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return t(this);e.once("block",n)}catch(i){r(i)}}));n()}))}))}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 r=function(...r){const n=t.interface.getEvent(e,r);return Ir(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return new Lu(t,r(...e),e)};return Tr(n,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getEvent(e);return Ir(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),n}(this,t)}queryTransaction(t){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(t,e,r){return __async(this,null,(function*(){null==e&&(e=0),null==r&&(r="latest");const{addr:n,addrPromise:i}=Ku(this),s=n||(yield i),{fragment:a,topics:o}=yield Ju(this,t),l={address:s,topics:o,fromBlock:e,toBlock:r},c=ju(this.runner);return Ir(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((t=>{let e=a;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(r){}if(e)try{return new Nu(t,this.interface,e)}catch(r){return new Pu(t,r)}return new Au(t,c)}))}))}on(t,e){return __async(this,null,(function*(){const r=yield Yu(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}))}once(t,e){return __async(this,null,(function*(){const r=yield Yu(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.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 r=0;for(const{listeners:t}of e.values())r+=t.length;return r}))}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 r=[];for(const{listeners:t}of e.values())r=r.concat(t.map((({listener:t})=>t)));return r}))}off(t,e){return __async(this,null,(function*(){const r=yield qu(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return null!=e&&0!==r.listeners.length||(r.stop(),Ku(this).subs.delete(r.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:r}of t.values())r(),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,r=null){super(t,e,r)}}}static from(t,e,r){null==r&&(r=null);return new this(t,e,r)}};class eh extends(function(){return th}()){}function rh(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):Or(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class nh{constructor(t){__publicField(this,"name"),Tr(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")],ah=class t{constructor(t,e,r){__privateAdd(this,ie),__publicField(this,"provider"),__publicField(this,"address"),__publicField(this,"name"),__privateAdd(this,re,void 0),__privateAdd(this,ne,void 0),Tr(this,{provider:t,address:e,name:r}),__privateSet(this,re,null),__privateSet(this,ne,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,re)&&__privateSet(this,re,(()=>__async(this,null,(function*(){try{return yield __privateGet(this,ne).supportsInterface("0x9061b923")}catch(t){if(Mr(t,"CALL_EXCEPTION"))return!1;throw __privateSet(this,re,null),t}})))()),yield __privateGet(this,re)}))}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===Pa?null:t}catch(i){if(Mr(i,"CALL_EXCEPTION"))return null;throw i}if(t>=0&&t<2147483648){let e=t+2147483648;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[e]);if(Wr(r,20))return Va(r)}let e=null;for(const s of this.provider.plugins)if(s instanceof nh&&s.supportsCoinType(t)){e=s;break}if(null==e)return null;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[t]);if(null==r||"0x"===r)return null;const n=yield e.decodeAddress(t,r);if(null!=n)return n;Ir(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}))}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",r=parseInt(e[4],16);if(e[5].length===2*r)return`${t}://${function(t){const e=jr(t);let r=ln(e),n="";for(;r;)n=pn[Number(r%fn)]+n,r/=fn;for(let i=0;i<e.length&&!e[i];i++)n=pn[0]+n;return n}("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&64===r[1].length)return`bzz://${r[1]}`;Ir(!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 n=yield this.getText("avatar");if(null==n)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:n});for(let i=0;i<sh.length;i++){const s=n.match(sh[i]);if(null==s)continue;const a=s[1].toLowerCase();switch(a){case"https":case"data":return t.push({type:"url",value:n}),{linkage:t,url:n};case"ipfs":{const e=rh(n);return t.push({type:"ipfs",value:n}),t.push({type:"url",value:e}),{linkage:t,url:e}}case"erc721":case"erc1155":{const i="erc721"===a?"tokenURI(uint256)":"uri(uint256)";t.push({type:a,value:n});const o=yield this.getAddress();if(null==o)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const l=(s[2]||"").split("/");if(2!==l.length)return t.push({type:`!${a}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"===a){const e=yield u.ownerOf(c);if(o!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===a){const e=yield u.balanceOf(o,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"===a&&(h=h.replace("{id}",un(c,32).substring(2)),t.push({type:"metadata-url-expanded",value:h})),h.match(/^ipfs:/i)&&(h=rh(h)),t.push({type:"metadata-url",value:h});let d={};const p=yield new Mn(h).send();p.assertOk();try{d=p.bodyJson}catch(e){try{t.push({type:"!metadata",value:p.bodyText})}catch(r){const e=p.body;return e&&t.push({type:"!metadata",value:Vr(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=rh(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(),r=e.getPlugin("org.ethers.plugins.network.Ens");return Ir(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}))}static fromName(e,r){return __async(this,null,(function*(){var n;let i=r;for(;;){if(""===i||"."===i)return null;if("eth"!==r&&"eth"===i)return null;const s=yield __privateMethod(n=t,ae,oe).call(n,e,i);if(null!=s){const n=new t(e,s,r);return i===r||(yield n.supportsWildcard())?n:null}i=i.split(".").slice(1).join(".")}}))}};re=new WeakMap,ne=new WeakMap,ie=new WeakSet,se=function(t,e){return __async(this,null,(function*(){e=(e||[]).slice();const r=__privateGet(this,ne).interface;e.unshift(Jl(this.name));let n=null;(yield this.supportsWildcard())&&(n=r.getFunction(t),Ir(n,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[ql(this.name,255),r.encodeFunctionData(n,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=yield __privateGet(this,ne)[t](...e);return n?r.decodeFunctionResult(n,i)[0]:i}catch(i){if(!Mr(i,"CALL_EXCEPTION"))throw i}return null}))},ae=new WeakSet,oe=function(t,e){return __async(this,null,(function*(){const r=yield ah.getEnsAddress(t);try{const n=new eh(r,["function resolver(bytes32) view returns (address)"],t),i=yield n.resolver(Jl(e),{enableCcipRead:!0});return i===Pa?null:i}catch(n){throw n}return null}))},__privateAdd(ah,ae);let oh=ah;const lh=BigInt(0);function ch(t,e){return function(r){return null==r?e:t(r)}}function uh(t,e){return r=>{if(e&&null==r)return null;if(!Array.isArray(r))throw new Error("not an array");return r.map((e=>t(e)))}}function hh(t,e){return r=>{const n={};for(const s in t){let a=s;if(e&&s in e&&!(a in r))for(const t of e[s])if(t in r){a=t;break}try{const e=t[s](r[a]);void 0!==e&&(n[s]=e)}catch(i){Ir(!1,`invalid value for value.${s} (${i instanceof Error?i.message:"not-an-error"})`,"BAD_DATA",{value:r})}}return n}}function dh(t){return Or(Wr(t,!0),"invalid data","value",t),t}function ph(t){return Or(Wr(t,32),"invalid hash","value",t),t}const fh=hh({address:Va,blockHash:ph,blockNumber:cn,data:dh,index:cn,removed:ch((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}Or(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:uh(ph),transactionHash:ph,transactionIndex:cn},{index:["logIndex"]});const gh=hh({hash:ch(ph),parentHash:ph,parentBeaconBlockRoot:ch(ph,null),number:cn,timestamp:cn,nonce:ch(dh),difficulty:sn,gasLimit:sn,gasUsed:sn,stateRoot:ch(ph,null),receiptsRoot:ch(ph,null),blobGasUsed:ch(sn,null),excessBlobGas:ch(sn,null),miner:ch(Va),prevRandao:ch(ph,null),extraData:dh,baseFeePerGas:ch(sn)},{prevRandao:["mixHash"]});const mh=hh({transactionIndex:cn,blockNumber:cn,transactionHash:ph,address:Va,topics:uh(ph),data:dh,index:cn,blockHash:ph},{index:["logIndex"]});const _h=hh({to:ch(Va,null),from:ch(Va,null),contractAddress:ch(Va,null),index:cn,root:ch(Vr),gasUsed:sn,blobGasUsed:ch(sn,null),logsBloom:ch(dh),blockHash:ph,hash:ph,logs:uh((function(t){return mh(t)})),blockNumber:cn,cumulativeGasUsed:sn,effectiveGasPrice:ch(sn),blobGasPrice:ch(sn,null),status:ch(cn),type:ch(cn,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function yh(t){t.to&&sn(t.to)===lh&&(t.to="0x0000000000000000000000000000000000000000");const e=hh({hash:ph,index:ch(cn,void 0),type:t=>"0x"===t||null==t?0:cn(t),accessList:ch(wo,null),blobVersionedHashes:ch(uh(ph,!0),null),authorizationList:ch(uh((t=>{let e;if(t.signature)e=t.signature;else{let r=t.yParity;"0x1b"===r?r=0:"0x1c"===r&&(r=1),e=Object.assign({},t,{yParity:r})}return{address:Va(t.address),chainId:sn(t.chainId),nonce:sn(t.nonce),signature:La.from(e)}}),!1),null),blockHash:ch(ph,null),blockNumber:ch(cn,null),transactionIndex:ch(cn,null),from:Va,gasPrice:ch(sn),maxPriorityFeePerGas:ch(sn),maxFeePerGas:ch(sn),maxFeePerBlobGas:ch(sn,null),gasLimit:sn,to:ch(Va,null),value:sn,nonce:cn,data:dh,creates:ch(Va,null),chainId:ch(sn,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=Va(t.from);let r=sn(t.nonce,"tx.nonce").toString(16);return r="0"===r?"0x":r.length%2?"0x0"+r:"0x"+r,Va(qr(ws(ei([e,r])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=La.from(t.signature):e.signature=La.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&sn(e.blockHash)===lh&&(e.blockHash=null),e}class vh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}clone(){return new vh(this.name)}}class wh extends vh{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 r={effectiveBlock:t};function n(t,n){let i=(e||{})[t];null==i&&(i=n),Or("number"==typeof i,`invalud value for ${t}`,"costs",e),r[t]=i}n("txBase",21e3),n("txCreate",32e3),n("txDataZero",4),n("txDataNonzero",16),n("txAccessListStorageKey",1900),n("txAccessListAddress",2400),Tr(this,r)}clone(){return new wh(this.effectiveBlock,this)}}class bh extends vh{constructor(t,e){super("org.ethers.plugins.network.Ens"),__publicField(this,"address"),__publicField(this,"targetNetwork"),Tr(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new bh(this.address,this.targetNetwork)}}class Ah extends vh{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,sn(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,sn(t,"chainId"))}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===sn(t)}catch(e){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===sn(t)}catch(e){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===sn(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 wh;let r=e.txBase;if(null==t.to&&(r+=e.txCreate),t.data)for(let n=2;n<t.data.length;n+=2)"00"===t.data.substring(n,n+2)?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const n=wo(t.accessList);for(const t in n)r+=e.txAccessListAddress+e.txAccessListStorageKey*n[t].storageKeys.length}return r}static from(e){if(function(){if(Nh)return;function t(t,e,r){const n=function(){const n=new xh(t,e);return null!=r.ensNetwork&&n.attachPlugin(new bh(null,r.ensNetwork)),n.attachPlugin(new wh),(r.plugins||[]).forEach((t=>{n.attachPlugin(t)})),n};xh.register(t,n),xh.register(e,n),r.altNames&&r.altNames.forEach((t=>{xh.register(t,n)}))}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 r=Eh.get(e);if(r)return r();if("bigint"==typeof e)return new t("unknown",e);Or(!1,"unknown network","network",e)}if("function"==typeof e.clone){return e.clone()}if("object"==typeof e){Or("string"==typeof e.name&&"number"==typeof e.chainId,"invalid network object name or chainId","network",e);const r=new t(e.name,e.chainId);return(e.ensAddress||null!=e.ensNetwork)&&r.attachPlugin(new bh(e.ensAddress,e.ensNetwork)),r}Or(!1,"invalid network","network",e)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const r=Eh.get(t);r&&Or(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Eh.set(t,e)}};function kh(t,e){const r=String(t);if(!r.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const n=r.split(".");if(1===n.length&&n.push(""),2!==n.length)throw new Error(`invalid gwei value: ${t}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let t=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||t++,n[1]=t.toString()}return BigInt(n[0]+n[1])}function Sh(t){return new Ah(t,((t,e,r)=>__async(this,null,(function*(){let e;r.setHeader("User-Agent","ethers");try{const[n,i]=yield Promise.all([r.send(),t()]);e=n;const s=e.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:kh(s.maxFee,9),maxPriorityFeePerGas:kh(s.maxPriorityFee,9)}}catch(n){Ir(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:e,error:n})}}))))}let Nh=!1;function Ph(t){return JSON.parse(JSON.stringify(t))}class Ch{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,ve,void 0),__privateAdd(this,we,void 0),__privateAdd(this,be,void 0),__privateSet(this,ve,t),__privateSet(this,be,!1),__privateSet(this,we,(t=>{this._poll(t,__privateGet(this,ve))}))}_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,we).call(this,-2),__privateGet(this,ve).on("block",__privateGet(this,we)))}stop(){__privateGet(this,be)&&(__privateSet(this,be,!1),__privateGet(this,ve).off("block",__privateGet(this,we)))}pause(t){this.stop()}resume(){this.start()}}ve=new WeakMap,we=new WeakMap,be=new WeakMap;class Rh 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 Mh extends Th{constructor(t,e){super(t),__privateAdd(this,xe,void 0),__privateSet(this,xe,Ph(e))}_poll(t,e){return __async(this,null,(function*(){throw new Error("@TODO")}))}}xe=new WeakMap;class Gh 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 Bh{constructor(t,e){__privateAdd(this,Re),__privateAdd(this,Se,void 0),__privateAdd(this,Ne,void 0),__privateAdd(this,Pe,void 0),__privateAdd(this,Ce,void 0),__privateAdd(this,Te,void 0),__privateSet(this,Se,t),__privateSet(this,Ne,Ph(e)),__privateSet(this,Pe,__privateMethod(this,Re,Me).bind(this)),__privateSet(this,Ce,!1),__privateSet(this,Te,-2)}start(){__privateGet(this,Ce)||(__privateSet(this,Ce,!0),-2===__privateGet(this,Te)&&__privateGet(this,Se).getBlockNumber().then((t=>{__privateSet(this,Te,t)})),__privateGet(this,Se).on("block",__privateGet(this,Pe)))}stop(){__privateGet(this,Ce)&&(__privateSet(this,Ce,!1),__privateGet(this,Se).off("block",__privateGet(this,Pe)))}pause(t){this.stop(),t&&__privateSet(this,Te,-2)}resume(){this.start()}}Se=new WeakMap,Ne=new WeakMap,Pe=new WeakMap,Ce=new WeakMap,Te=new WeakMap,Re=new WeakSet,Me=function(t){return __async(this,null,(function*(){if(-2===__privateGet(this,Te))return;const e=Ph(__privateGet(this,Ne));e.fromBlock=__privateGet(this,Te)+1,e.toBlock=t;const r=yield __privateGet(this,Se).getLogs(e);if(0!==r.length)for(const t of r)__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 Fh(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,r)=>(t[r]=e[r],t)),{})}return e}))}class Uh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function Lh(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(Wr(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:Fh("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:Fh("orphan",e),filter:(r=e,JSON.parse(JSON.stringify(r)))}}var r;if(t.address||t.topics){const r=t,n={topics:(r.topics||[]).map((t=>null==t?null:Array.isArray(t)?Lh(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(r.address){const t=[],i=[],s=r=>{Wr(r)?t.push(r):i.push((()=>__async(this,null,(function*(){t.push(yield qa(r,e))})))())};Array.isArray(r.address)?r.address.forEach(s):s(r.address),i.length&&(yield Promise.all(i)),n.address=Lh(t.map((t=>t.toLowerCase())))}return{filter:n,tag:Fh("event",n),type:"event"}}Or(!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,Ze),__privateAdd(this,$e),__privateAdd(this,er),__privateAdd(this,nr),__privateAdd(this,Ge,void 0),__privateAdd(this,Be,void 0),__privateAdd(this,Ie,void 0),__privateAdd(this,Oe,void 0),__privateAdd(this,Fe,void 0),__privateAdd(this,Ue,void 0),__privateAdd(this,Le,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,Ue,!0),__privateSet(this,Fe,null);else if(t){const e=xh.from(t);__privateSet(this,Ue,!1),__privateSet(this,Fe,Promise.resolve(e)),setTimeout((()=>{this.emit("network",e,null)}),0)}else __privateSet(this,Ue,!1),__privateSet(this,Fe,null);__privateSet(this,De,-1),__privateSet(this,Le,new Map),__privateSet(this,Ge,new Map),__privateSet(this,Be,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,Be).values())}attachPlugin(t){if(__privateGet(this,Be).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,Be).set(t.name,t.connect(this)),this}getPlugin(t){return __privateGet(this,Be).get(t)||null}get disableCcipRead(){return __privateGet(this,We)}set disableCcipRead(t){__privateSet(this,We,!!t)}ccipReadFetch(t,e,r){return __async(this,null,(function*(){if(this.disableCcipRead||0===r.length||null==t.to)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),s=[];for(let e=0;e<r.length;e++){const o=r[e],l=o.replace("{sender}",n).replace("{data}",i),c=new Mn(l);-1===o.indexOf("{data}")&&(c.body={data:i,sender:n}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:c,index:e,urls:r});let u,h="unknown error";try{u=yield c.send()}catch(a){s.push(a.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:{error:a}});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(a){}Ir(u.statusCode<400||u.statusCode>=500,`response not found during CCIP fetch: ${h}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:o,errorMessage:h}}),s.push(h)}Ir(!1,`error encountered during CCIP fetch: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,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(){Ir(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}_perform(t){return __async(this,null,(function*(){Ir(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}))}getBlockNumber(){return __async(this,null,(function*(){const t=cn(yield __privateMethod(this,ze,Ve).call(this,{method:"getBlockNumber"}),"%response");return __privateGet(this,De)>=0&&__privateSet(this,De,t),t}))}_getAddress(t){return qa(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 Wr(t)?Wr(t,32)?t:dn(t):("bigint"==typeof t&&(t=cn(t,"blockTag")),"number"==typeof t?t>=0?dn(t):__privateGet(this,De)>=0?dn(__privateGet(this,De)+t):this.getBlockNumber().then((e=>dn(e+t))):void Or(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?Lh(t.map((t=>t.toLowerCase()))):t.toLowerCase())),r="blockHash"in t?t.blockHash:void 0,n=(t,n,i)=>{let s;switch(t.length){case 0:break;case 1:s=t[0];break;default:t.sort(),s=t}if(r&&(null!=n||null!=i))throw new Error("invalid filter");const a={};return s&&(a.address=s),e.length&&(a.topics=e),n&&(a.fromBlock=n),i&&(a.toBlock=i),r&&(a.blockHash=r),a};let i,s,a=[];if(t.address)if(Array.isArray(t.address))for(const o of t.address)a.push(this._getAddress(o));else a.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(s=this._getBlockTag(t.toBlock)),a.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=s&&"string"!=typeof s?Promise.all([Promise.all(a),i,s]).then((t=>n(t[0],t[1],t[2]))):n(a,i,s)}_getTransactionRequest(t){const e=wu(t),r=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=qa(e[t],this);Oh(n)?r.push(function(){return __async(this,null,(function*(){e[t]=yield n}))}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);Oh(t)?r.push(function(){return __async(this,null,(function*(){e.blockTag=yield t}))}()):e.blockTag=t}return r.length?function(){return __async(this,null,(function*(){return yield Promise.all(r),e}))}():e}getNetwork(){return __async(this,null,(function*(){if(null==__privateGet(this,Fe)){const t=(()=>__async(this,null,(function*(){try{const t=yield this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw __privateGet(this,Fe)===t&&__privateSet(this,Fe,null),e}})))();return __privateSet(this,Fe,t),(yield t).clone()}const t=__privateGet(this,Fe),[e,r]=yield Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(__privateGet(this,Ue)?(this.emit("network",r,e),__privateGet(this,Fe)===t&&__privateSet(this,Fe,Promise.resolve(r))):Ir(!1,`network changed: ${e.chainId} => ${r.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:r,priorityFee:n}=yield Cr({_block:__privateMethod(this,$e,tr).call(this,"latest",!1),gasPrice:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getGasPrice"}),"%response")}catch(t){}return null})))(),priorityFee:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getPriorityFee"}),"%response")}catch(t){}return null})))()});let i=null,s=null;const a=this._wrapBlock(e,t);return a&&a.baseFeePerGas&&(s=null!=n?n:BigInt("1000000000"),i=a.baseFeePerGas*Ih+s),new vu(r,i,s)})),r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Mn(r.url),n=yield r.processFunc(e,this,t);return new vu(n.gasPrice,n.maxFeePerGas,n.maxPriorityFeePerGas)}return yield e()}))}estimateGas(t){return __async(this,null,(function*(){let e=this._getTransactionRequest(t);return Oh(e)&&(e=yield e),sn(yield __privateMethod(this,ze,Ve).call(this,{method:"estimateGas",transaction:e}),"%response")}))}call(t){return __async(this,null,(function*(){const{tx:e,blockTag:r}=yield Cr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return yield __privateMethod(this,qe,Ye).call(this,__privateMethod(this,Ke,Je).call(this,e,r,t.enableCcipRead?0:-1))}))}getBalance(t,e){return __async(this,null,(function*(){return sn(yield __privateMethod(this,Ze,Xe).call(this,{method:"getBalance"},t,e),"%response")}))}getTransactionCount(t,e){return __async(this,null,(function*(){return cn(yield __privateMethod(this,Ze,Xe).call(this,{method:"getTransactionCount"},t,e),"%response")}))}getCode(t,e){return __async(this,null,(function*(){return Vr(yield __privateMethod(this,Ze,Xe).call(this,{method:"getCode"},t,e))}))}getStorage(t,e,r){return __async(this,null,(function*(){const n=sn(e,"position");return Vr(yield __privateMethod(this,Ze,Xe).call(this,{method:"getStorage",position:n},t,r))}))}broadcastTransaction(t){return __async(this,null,(function*(){const{blockNumber:e,hash:r,network:n}=yield Cr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=Do.from(t);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,n).replaceableTransaction(e)}))}getBlock(t,e){return __async(this,null,(function*(){const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,$e,tr).call(this,t,!!e)});return null==n?null:this._wrapBlock(n,r)}))}getTransaction(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t})});return null==r?null:this._wrapTransactionResponse(r,e)}))}getTransactionReceipt(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionReceipt",hash:t})});if(null==r)return null;if(null==r.gasPrice&&null==r.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");r.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(r,e)}))}getTransactionResult(t){return __async(this,null,(function*(){const{result:e}=yield Cr({network:this.getNetwork(),result:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionResult",hash:t})});return null==e?null:Vr(e)}))}getLogs(t){return __async(this,null,(function*(){let e=this._getFilter(t);Oh(e)&&(e=yield e);const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getLogs",filter:e})});return n.map((t=>this._wrapLog(t,r)))}))}_getProvider(t){Ir(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}getResolver(t){return __async(this,null,(function*(){return yield oh.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=Va(t)).substring(2).toLowerCase()+".addr.reverse");try{const r=yield oh.getEnsAddress(this),n=new eh(r,["function resolver(bytes32) view returns (address)"],this),i=yield n.resolver(e);if(null==i||i===Pa)return null;const s=new eh(i,["function name(bytes32) view returns (string)"],this),a=yield s.name(e);return(yield this.resolveName(a))!==t?null:a}catch(r){if(Mr(r,"BAD_DATA")&&"0x"===r.value)return null;if(Mr(r,"CALL_EXCEPTION"))return null;throw r}return null}))}waitForTransaction(t,e,r){return __async(this,null,(function*(){const n=null!=e?e:1;return 0===n?this.getTransactionReceipt(t):new Promise(((e,i)=>__async(this,null,(function*(){let s=null;const a=r=>__async(this,null,(function*(){try{const i=yield this.getTransactionReceipt(t);if(null!=i&&r-i.blockNumber+1>=n)return e(i),void(s&&(clearTimeout(s),s=null))}catch(i){console.log("EEE",i)}this.once("block",a)}));null!=r&&(s=setTimeout((()=>{null!=s&&(s=null,this.off("block",a),i(Br("timeout","TIMEOUT",{reason:"timeout"})))}),r)),a(yield this.getBlockNumber())}))))}))}waitForBlock(t){return __async(this,null,(function*(){Ir(!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 r=__privateWrapper(this,je)._++,n=()=>{__privateGet(this,He).delete(r),t()};if(this.paused)__privateGet(this,He).set(r,{timer:null,func:n,time:e});else{const t=setTimeout(n,e);__privateGet(this,He).set(r,{timer:t,func:n,time:jh()})}return r}_forEachSubscriber(t){for(const e of __privateGet(this,Ge).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Uh(t.type);case"block":{const t=new Ch(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Rh(this,t.type);case"event":return new Bh(this,t.filter);case"transaction":return new Gh(this,t.hash);case"orphan":return new Mh(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of __privateGet(this,Ge).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=__privateGet(this,Ie)&&e.pause(__privateGet(this,Ie));break}}on(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Ie)&&r.subscriber.pause(__privateGet(this,Ie))),this}))}once(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Ie)&&r.subscriber.pause(__privateGet(this,Ie))),this}))}emit(t,...e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t,e);if(!r||0===r.listeners.length)return!1;const n=r.listeners.length;return r.listeners=r.listeners.filter((({listener:r,once:n})=>{const i=new gn(this,n?null:r,t);try{r.call(this,...e,i)}catch(s){}return!n})),0===r.listeners.length&&(r.started&&r.subscriber.stop(),__privateGet(this,Ge).delete(r.tag)),n>0}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of __privateGet(this,Ge).values())e+=t.length;return e}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of __privateGet(this,Ge).values())e=e.concat(t.map((({listener:t})=>t)));return e}))}off(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return e&&0!==r.listeners.length||(r.started&&r.subscriber.stop(),__privateGet(this,Ge).delete(r.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const{tag:e,started:r,subscriber:n}=yield __privateMethod(this,nr,ir).call(this,t);r&&n.stop(),__privateGet(this,Ge).delete(e)}else for(const[t,{started:e,subscriber:r}]of __privateGet(this,Ge))e&&r.stop(),__privateGet(this,Ge).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;Ir(!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 r=zh(t,e);if(r)return vn(r)}catch(r){}return null}function zh(t,e){if("0x"===t)return null;try{const r=cn(qr(t,e,e+32)),n=cn(qr(t,r,r+32));return qr(t,r+32,r+32+n)}catch(r){}return null}function Vh(t){const e=hn(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}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}Ge=new WeakMap,Be=new WeakMap,Ie=new WeakMap,Oe=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,Le=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 r=Fh(t.method,t);let n=__privateGet(this,Le).get(r);return n||(n=this._perform(t),__privateGet(this,Le).set(r,n),setTimeout((()=>{__privateGet(this,Le).get(r)===n&&__privateGet(this,Le).delete(r)}),e)),yield n}))},Ke=new WeakSet,Je=function(t,e,r){return __async(this,null,(function*(){Ir(r<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=wu(t);try{return Vr(yield this._perform({method:"call",transaction:n,blockTag:e}))}catch(i){if(!this.disableCcipRead&&Gr(i)&&i.data&&r>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===qr(i.data,0,4)){const t=i.data,a=yield qa(n.to,this);let o;try{o=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};Ir(Jr(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=qr(t,0,32);Ir(qr(r,0,12)===qr(Yh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=qr(r,12);try{const r=[],n=cn(qr(t,32,64)),i=cn(qr(t,n,n+32)),s=qr(t,n+32);for(let t=0;t<i;t++){const e=Qh(s,32*t);if(null==e)throw new Error("abort");r.push(e)}e.urls=r}catch(i){Ir(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=zh(t,64);if(null==r)throw new Error("abort");e.calldata=r}catch(i){Ir(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}Ir(qr(t,100,128)===qr(Yh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=qr(t,96,100);try{const r=zh(t,128);if(null==r)throw new Error("abort");e.extraData=r}catch(i){Ir(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(qr(i.data,4))}catch(s){Ir(!1,s.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:t}})}Ir(o.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:t,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:o.errorArgs}});const l=yield this.ccipReadFetch(n,o.calldata,o.urls);Ir(null!=l,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:i.data,errorArgs:o.errorArgs}});const c={to:a,data:Kr([o.selector,qh([l,o.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=yield __privateMethod(this,Ke,Je).call(this,c,e,r+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,Ye=function(t){return __async(this,null,(function*(){const{value:e}=yield Cr({network:this.getNetwork(),value:t});return e}))},Ze=new WeakSet,Xe=function(t,e,r){return __async(this,null,(function*(){let n=this._getAddress(e),i=this._getBlockTag(r);return"string"==typeof n&&"string"==typeof i||([n,i]=yield Promise.all([n,i])),yield __privateMethod(this,qe,Ye).call(this,__privateMethod(this,ze,Ve).call(this,Object.assign(t,{address:n,blockTag:i})))}))},$e=new WeakSet,tr=function(t,e){return __async(this,null,(function*(){if(Wr(t,32))return yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return"string"!=typeof r&&(r=yield r),yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})}))},er=new WeakSet,rr=function(t,e){return __async(this,null,(function*(){let r=yield Dh(t,this);return"event"===r.type&&e&&e.length>0&&!0===e[0].removed&&(r=yield Dh({orphan:"drop-log",log:e[0]},this)),__privateGet(this,Ge).get(r.tag)||null}))},nr=new WeakSet,ir=function(t){return __async(this,null,(function*(){const e=yield Dh(t,this),r=e.tag;let n=__privateGet(this,Ge).get(r);if(!n){n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},__privateGet(this,Ge).set(r,n)}return n}))};const Jh=new Uint8Array([]);function qh(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(Jh),r+=32;for(let n=0;n<t.length;n++){const i=jr(t[n]);e[n]=Vh(r),e.push(Vh(i.length)),e.push(Kh(i)),r+=32+32*Math.ceil(i.length/32)}return Kr(e)}const Yh="0x0000000000000000000000000000000000000000000000000000000000000000";function Zh(t,e){if(t.provider)return t.provider;Ir(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}function Xh(t,e){return __async(this,null,(function*(){let r=wu(e);if(null!=r.to&&(r.to=qa(r.to,t)),null!=r.from){const e=r.from;r.from=Promise.all([t.getAddress(),qa(e,t)]).then((([t,e])=>(Or(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else r.from=t.getAddress();return yield Cr(r)}))}class $h{constructor(t){__publicField(this,"provider"),Tr(this,{provider:t||null})}getNonce(t){return __async(this,null,(function*(){return Zh(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=Zh(this,"populateTransaction"),r=yield Xh(this,t);null==r.nonce&&(r.nonce=yield this.getNonce("pending")),null==r.gasLimit&&(r.gasLimit=yield this.estimateGas(r));const n=yield this.provider.getNetwork();if(null!=r.chainId){Or(sn(r.chainId)===n.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=n.chainId;const i=null!=r.maxFeePerGas||null!=r.maxPriorityFeePerGas;if(null==r.gasPrice||2!==r.type&&!i?0!==r.type&&1!==r.type||!i||Or(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):Or(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==r.type&&null!=r.type||null==r.maxFeePerGas||null==r.maxPriorityFeePerGas)if(0===r.type||1===r.type){const t=yield e.getFeeData();Ir(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice)}else{const t=yield e.getFeeData();if(null==r.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(r.authorizationList&&r.authorizationList.length?r.type=4:r.type=2,null!=r.gasPrice){const t=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=t,r.maxPriorityFeePerGas=t}else null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(Ir(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):Ir(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==r.type&&3!==r.type&&4!==r.type||(null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else r.type=2;return yield Cr(r)}))}populateAuthorization(t){return __async(this,null,(function*(){const e=Object.assign({},t);return null==e.chainId&&(e.chainId=(yield Zh(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=yield this.getNonce()),e}))}estimateGas(t){return __async(this,null,(function*(){return Zh(this,"estimateGas").estimateGas(yield this.populateCall(t))}))}call(t){return __async(this,null,(function*(){return Zh(this,"call").call(yield this.populateCall(t))}))}resolveName(t){return __async(this,null,(function*(){const e=Zh(this,"resolveName");return yield e.resolveName(t)}))}sendTransaction(t){return __async(this,null,(function*(){const e=Zh(this,"sendTransaction"),r=yield this.populateTransaction(t);delete r.from;const n=Do.from(r);return yield e.broadcastTransaction(yield this.signTransaction(n))}))}authorize(t){Ir(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class td{constructor(t){__privateAdd(this,hr),__privateAdd(this,pr),__privateAdd(this,sr,void 0),__privateAdd(this,ar,void 0),__privateAdd(this,or,void 0),__privateAdd(this,lr,void 0),__privateAdd(this,cr,void 0),__privateAdd(this,ur,void 0),__privateSet(this,sr,t),__privateSet(this,ar,null),__privateSet(this,or,__privateMethod(this,hr,dr).bind(this)),__privateSet(this,lr,!1),__privateSet(this,cr,null),__privateSet(this,ur,!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,lr)||(__privateSet(this,lr,!0),__privateMethod(this,hr,dr).call(this,-2))}stop(){__privateGet(this,lr)&&(__privateSet(this,lr,!1),__privateSet(this,ur,!0),__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or)))}pause(t){t&&__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or))}resume(){this.start()}}sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,cr=new WeakMap,ur=new WeakMap,hr=new WeakSet,dr=function(t){return __async(this,null,(function*(){try{null==__privateGet(this,ar)&&__privateSet(this,ar,this._subscribe(__privateGet(this,sr)));let e=null;try{e=yield __privateGet(this,ar)}catch(t){if(!Mr(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==e)return __privateSet(this,ar,null),void __privateGet(this,sr)._recoverSubscriber(this,this._recover(__privateGet(this,sr)));const r=yield __privateGet(this,sr).getNetwork();if(__privateGet(this,cr)||__privateSet(this,cr,r),__privateGet(this,cr).chainId!==r.chainId)throw new Error("chaid changed");if(__privateGet(this,ur))return;const n=yield __privateGet(this,sr).send("eth_getFilterChanges",[e]);yield this._emitResults(__privateGet(this,sr),n)}catch(t){console.log("@TODO",t)}__privateGet(this,sr).once("block",__privateGet(this,or))}))},pr=new WeakSet,fr=function(){const t=__privateGet(this,ar);t&&(__privateSet(this,ar,null),t.then((t=>{__privateGet(this,sr).destroyed||__privateGet(this,sr).send("eth_uninstallFilter",[t])})))};class ed extends td{constructor(t,e){var r;super(t),__privateAdd(this,gr,void 0),__privateSet(this,gr,(r=e,JSON.parse(JSON.stringify(r))))}_recover(t){return new Bh(t,__privateGet(this,gr))}_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newFilter",[__privateGet(this,gr)])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const r of e)t.emit(__privateGet(this,gr),t._wrapLog(r,t._network))}))}}gr=new WeakMap;class rd 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 r of e)t.emit("pending",r)}))}}const nd="bigint,boolean,function,number,string,symbol".split(/,/g);function id(t){if(null==t||nd.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,r)=>(e[r]=t[r],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function sd(t){return new Promise((e=>{setTimeout(e,t)}))}function ad(t){return t?t.toLowerCase():t}function od(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"),Tr(this,{address:e=Va(e)})}connect(t){Ir(!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),r=[];if(e.from){const n=e.from;r.push((()=>__async(this,null,(function*(){const r=yield qa(n,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r})))())}else e.from=this.address;if(null==e.gasLimit&&r.push((()=>__async(this,null,(function*(){e.gasLimit=yield this.provider.estimateGas(__spreadProps(__spreadValues({},e),{from:this.address}))})))()),null!=e.to){const t=e.to;r.push((()=>__async(this,null,(function*(){e.to=yield qa(t,this.provider)})))())}r.length&&(yield Promise.all(r));const n=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[n])}))}sendTransaction(t){return __async(this,null,(function*(){const e=yield this.provider.getBlockNumber(),r=yield this.sendUncheckedTransaction(t);return yield new Promise(((t,n)=>{const i=[1e3,100];let s=0;const a=()=>__async(this,null,(function*(){try{const n=yield this.provider.getTransaction(r);if(null!=n)return void t(n.replaceableTransaction(e))}catch(o){if(Mr(o,"CANCELLED")||Mr(o,"BAD_DATA")||Mr(o,"NETWORK_ERROR")||Mr(o,"UNSUPPORTED_OPERATION"))return null==o.info&&(o.info={}),o.info.sendTransactionHash=r,void n(o);if(Mr(o,"INVALID_ARGUMENT")&&(s++,null==o.info&&(o.info={}),o.info.sendTransactionHash=r,s>10))return void n(o);this.provider.emit("error",Br("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:o}))}this.provider._setTimeout((()=>{a()}),i.pop()||4e3)}));a()}))}))}signTransaction(t){return __async(this,null,(function*(){const e=id(t);if(e.from){const r=yield qa(e.from,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r}else e.from=this.address;const r=this.provider.getRpcTransaction(e);return yield this.provider.send("eth_signTransaction",[r])}))}signMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?yn(t):t;return yield this.provider.send("personal_sign",[Vr(e),this.address.toLowerCase()])}))}signTypedData(t,e,r){return __async(this,null,(function*(){const n=id(r),i=yield uc.resolveNames(t,e,n,(t=>__async(this,null,(function*(){const e=yield qa(t);return Or(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?yn(t):t;return yield this.provider.send("eth_sign",[this.address.toLowerCase(),Vr(e)])}))}}mr=new WeakMap,_r=new WeakMap,yr=new WeakMap,vr=new WeakMap,wr=new WeakMap,br=new WeakMap,Ar=new WeakMap,Er=new WeakSet,xr=function(){if(__privateGet(this,vr))return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");__privateSet(this,vr,setTimeout((()=>{__privateSet(this,vr,null);const t=__privateGet(this,yr);for(__privateSet(this,yr,[]);t.length;){const e=[t.shift()];for(;t.length&&e.length!==__privateGet(this,mr).batchMaxCount;){e.push(t.shift());if(JSON.stringify(e.map((t=>t.payload))).length>__privateGet(this,mr).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 r=yield this._send(t);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:t,reject:n,payload:i}of e){if(this.destroyed){n(Br("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=r.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?n(this.getRpcError(i,e)):t(e.result);else{const t=Br("missing response for request","BAD_DATA",{value:r,info:{payload:i}});this.emit("error",t),n(t)}}}catch(r){this.emit("debug",{action:"receiveRpcError",error:r});for(const{reject:t}of e)t(r)}}))})()}}),t))};let ud=class t extends Wh{constructor(t,e){super(t,e),__privateAdd(this,Er),__privateAdd(this,mr,void 0),__privateAdd(this,_r,void 0),__privateAdd(this,yr,void 0),__privateAdd(this,vr,void 0),__privateAdd(this,wr,void 0),__privateAdd(this,br,void 0),__privateAdd(this,Ar,void 0),__privateSet(this,_r,1),__privateSet(this,mr,Object.assign({},ld,e||{})),__privateSet(this,yr,[]),__privateSet(this,vr,null),__privateSet(this,br,null),__privateSet(this,Ar,null);{let t=null;const e=new Promise((e=>{t=e}));__privateSet(this,wr,{promise:e,resolve:t})}const r=this._getOption("staticNetwork");"boolean"==typeof r?(Or(!r||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),r&&null!=t&&__privateSet(this,br,xh.from(t))):r&&(Or(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),__privateSet(this,br,r))}_getOption(t){return __privateGet(this,mr)[t]}get _network(){return Ir(__privateGet(this,br),"network is not available yet","NETWORK_ERROR"),__privateGet(this,br)}_perform(e){return __async(this,null,(function*(){if("call"===e.method||"estimateGas"===e.method){let t=e.transaction;if(t&&null!=t.type&&sn(t.type)&&null==t.maxFeePerGas&&null==t.maxPriorityFeePerGas){const r=yield this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}const r=this.getRpcRequest(e);return null!=r?yield this.send(r.method,r.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,br))return __privateGet(this,br)}return __privateGet(this,Ar)?yield __privateGet(this,Ar):this.ready?(__privateSet(this,Ar,(()=>__async(this,null,(function*(){try{const t=xh.from(sn(yield this.send("eth_chainId",[])));return __privateSet(this,Ar,null),t}catch(t){throw __privateSet(this,Ar,null),t}})))()),yield __privateGet(this,Ar)):(__privateSet(this,Ar,(()=>__async(this,null,(function*(){const t={id:__privateWrapper(this,_r)._++,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,Ar,null)}catch(r){throw __privateSet(this,Ar,null),this.emit("debug",{action:"receiveRpcError",error:r}),r}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return xh.from(sn(e.result));throw this.getRpcError(t,e)})))()),yield __privateGet(this,Ar))}))}_start(){null!=__privateGet(this,wr)&&null!=__privateGet(this,wr).resolve&&(__privateGet(this,wr).resolve(),__privateSet(this,wr,null),(()=>{__async(this,null,(function*(){for(;null==__privateGet(this,br)&&!this.destroyed;)try{__privateSet(this,br,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",Br("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),yield sd(1e3)}__privateMethod(this,Er,xr).call(this)}))})())}_waitUntilReady(){return __async(this,null,(function*(){if(null!=__privateGet(this,wr))return yield __privateGet(this,wr).promise}))}_getSubscriber(t){return"pending"===t.type?new rd(this):"event"===t.type?this._getOption("polling")?new Bh(this,t.filter):new ed(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new Uh("orphan"):super._getSubscriber(t)}get ready(){return null==__privateGet(this,wr)}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((r=>{if(null==t[r])return;let n=r;"gasLimit"===r&&(n="gas"),e[n]=dn(sn(t[r],`tx.${r}`))})),["from","to","data"].forEach((r=>{null!=t[r]&&(e[r]=Vr(t[r]))})),t.accessList&&(e.accessList=wo(t.accessList)),t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.map((t=>t.toLowerCase()))),t.authorizationList&&(e.authorizationList=t.authorizationList.map((t=>{const e=bo(t);return{address:e.address,nonce:dn(e.nonce),chainId:dn(e.chainId),yParity:dn(e.signature.yParity),r:dn(e.signature.r),s:dn(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:[ad(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[ad(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[ad(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[ad(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(ad):t.filter.address=ad(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:r}=t,{error:n}=e;if("eth_estimateGas"===r&&n.message){const e=n.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return Br("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}});if(e.match(/nonce/i)&&e.match(/too low/i))return Br("nonce has already been used","NONCE_EXPIRED",{transaction:t.params[0],info:{payload:t,error:n}})}if("eth_call"===r||"eth_estimateGas"===r){const e=dd(n),i=lu.getBuiltinCallException("eth_call"===r?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:n,payload:t},i}const i=JSON.stringify(function(t){const e=[];return pd(t,e),e}(n));if("string"==typeof n.message&&n.message.match(/user denied|ethers-user-denied/i)){return Br("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"}[r]||"unknown",reason:"rejected",info:{payload:t,error:n}})}if("eth_sendRawTransaction"===r||"eth_sendTransaction"===r){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Br("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return Br("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Br("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return Br("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:r,info:{transaction:e,info:{error:n}}})}let s=!!i.match(/the method .* does not exist/i);return s||n&&n.details&&n.details.startsWith("Unauthorized method:")&&(s=!0),s?Br("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):Br("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Br("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const r=__privateWrapper(this,_r)._++,n=new Promise(((n,i)=>{__privateGet(this,yr).push({resolve:n,reject:i,payload:{method:t,params:e,id:r,jsonrpc:"2.0"}})}));return __privateMethod(this,Er,xr).call(this),n}getSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const r=yield e;if(t>=r.length)throw new Error("no such account");return new cd(this,r[t])}const{accounts:r}=yield Cr({network:this.getNetwork(),accounts:e});t=Va(t);for(const n of r)if(Va(n)===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,vr)&&(clearTimeout(__privateGet(this,vr)),__privateSet(this,vr,null));for(const{payload:t,reject:e}of __privateGet(this,yr))e(Br("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));__privateSet(this,yr,[]),super.destroy()}};class hd extends ud{constructor(t,e){super(t,e),__privateAdd(this,kr,void 0);let r=this._getOption("pollingInterval");null==r&&(r=ld.pollingInterval),__privateSet(this,kr,r)}_getSubscriber(t){const e=super._getSubscriber(t);return od(e)&&(e.pollingInterval=__privateGet(this,kr)),e}get pollingInterval(){return __privateGet(this,kr)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");__privateSet(this,kr,t),this._forEachSubscriber((t=>{od(t)&&(t.pollingInterval=__privateGet(this,kr))}))}}function dd(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&Wr(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const r=dd(t[e]);if(r)return r}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 r in t)pd(t[r],e);if("string"==typeof t)try{return pd(JSON.parse(t),e)}catch(r){}}}kr=new WeakMap;Sr=new WeakMap,Nr=new WeakMap;let fd=class t extends hd{constructor(t,e,r){const n=Object.assign({},null!=r?r:{},{batchMaxCount:1});Or(t&&t.request,"invalid EIP-1193 provider","ethereum",t),super(e,n),__privateAdd(this,Sr,void 0),__privateAdd(this,Nr,void 0),__privateSet(this,Nr,null),r&&r.providerInfo&&__privateSet(this,Nr,r.providerInfo),__privateSet(this,Sr,((e,r)=>__async(this,null,(function*(){const n={method:e,params:r};this.emit("debug",{action:"sendEip1193Request",payload:n});try{const e=yield t.request(n);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=n,this.emit("debug",{action:"receiveEip1193Error",error:t}),t}}))))}get providerInfo(){return __privateGet(this,Nr)}send(e,r){return __async(this,null,(function*(){return yield this._start(),yield __superGet(t.prototype,this,"send").call(this,e,r)}))}_send(t){return __async(this,null,(function*(){Or(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const e=yield __privateGet(this,Sr).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,Sr).call(this,"eth_requestAccounts",[])}catch(r){const t=r.payload;throw this.getRpcError(t,{id:t.id,error:r})}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 r=e.window?e.window:"undefined"!=typeof window?window:null;if(null==r)return null;const n=e.anyProvider;if(n&&r.ethereum)return new t(r.ethereum);if(!("addEventListener"in r&&"dispatchEvent"in r&&"removeEventListener"in r))return null;const i=e.timeout?e.timeout:300;return 0===i?null:yield new Promise(((s,a)=>{let o=[];const l=t=>{o.push(t.detail),n&&c()},c=()=>{if(clearTimeout(u),o.length)if(e&&e.filter){const r=e.filter(o.map((t=>Object.assign({},t.info))));if(null==r)s(null);else if(r instanceof t)s(r);else{let e=null;if(r.uuid){e=o.filter((t=>r.uuid===t.info.uuid))[0]}if(e){const{provider:r,info:n}=e;s(new t(r,void 0,{providerInfo:n}))}else a(Br("filter returned unknown info","UNSUPPORTED_OPERATION",{value:r}))}}else{const{provider:e,info:r}=o[0];s(new t(e,void 0,{providerInfo:r}))}else s(null);r.removeEventListener("eip6963:announceProvider",l)},u=setTimeout((()=>{c()}),i);r.addEventListener("eip6963:announceProvider",l),r.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}}},vd={[md.ETHEREUM]:[gd.METAMASK,gd.TRUST_WALLET],[md.BSC]:[gd.METAMASK,gd.TRUST_WALLET],[md.TRON]:[gd.TRONLINK],[md.ALGORAND]:[gd.LUTE]},wd=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=()=>({[gd.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum,[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]:"undefined"!=typeof window&&void 0!==window.lute}),Ad=(t=3,e=500)=>__async(this,null,(function*(){let r=0,n=bd();const i=Object.values(n).some((t=>!0===t));for(;!i&&r<t;)console.log(`No wallets detected, retrying (${r+1}/${t})...`),yield new Promise((t=>setTimeout(t,e))),n=bd(),r++;return n})),Ed=()=>__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],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${n}`}const s=new fd(window.ethereum);return{walletType:gd.METAMASK,address:e,provider:s,network:i,isConnected:!0,chainId:n}}catch(t){throw console.error("Error connecting to MetaMask:",t),t}})),xd=()=>__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],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${n}`}const s=new fd(window.ethereum);return{walletType:gd.TRUST_WALLET,address:e,provider:s,network:i,isConnected:!0,chainId:n}}catch(t){throw console.error("Error connecting to Trust Wallet:",t),t}})),kd=()=>__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 r=0;r<t;r++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${r+1}/${t}`),yield new Promise((t=>setTimeout(t,e)))}throw new Error("TronWeb took too long to be ready")}));try{const r=yield t();if(!r.defaultAddress||!r.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 n=r.defaultAddress.base58;return console.log("Connected to TronLink wallet:",n),{walletType:gd.TRONLINK,address:n,provider:r,network:md.TRON,isConnected:!0}}catch(r){throw console.error("Error connecting to TronLink:",r),r}})),Sd=()=>__async(this,null,(function*(){if(console.log("Connecting to Lute wallet..."),!window.lute)throw console.error("Lute not found."),new Error("Lute not detected. Please install Lute extension.");try{const{address:t}=yield window.lute.connect();if(!t)throw new Error("No address returned. Please unlock Lute wallet.");return console.log("Connected to Lute wallet:",t),{walletType:gd.LUTE,address:t,provider:window.lute,network:md.ALGORAND,isConnected:!0}}catch(t){throw console.error("Error connecting to Lute wallet:",t),t}})),Nd=t=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",t),t){case gd.METAMASK:return Ed();case gd.TRONLINK:return kd();case gd.TRUST_WALLET:return xd();case gd.LUTE:return Sd();default:throw new Error(`Unsupported wallet type: ${t}`)}})),Pd=t=>vd[t]||[],Cd=(t,e,r)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:e,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Recipient address not provided");if(!r||isNaN(parseFloat(r))||parseFloat(r)<=0)throw new Error("Invalid amount");try{let n;switch(t.walletType){case gd.METAMASK:case gd.TRUST_WALLET:const i=t.provider,s=yield i.getSigner(),a=r.toString(),o=ii(a,18);console.log("Sending ETH/BNB:",{to:e,value:o.toString()});const l=yield i.estimateGas({to:e,value:o,from:yield s.getAddress()});console.log("Gas estimate:",l.toString());const c=l*BigInt(110)/BigInt(100);console.log("Using gas limit:",c.toString()),n=yield s.sendTransaction({to:e,value:o,gasLimit:c});break;case gd.TRONLINK:const u=t.provider;if(!u||!u.ready)throw new Error("TronWeb not initialized");const h=u.toSun(r.toString());console.log("Sending TRX:",{to:e,value:h}),n=yield u.trx.sendTransaction(e,h);break;case gd.LUTE:const d=t.provider,p=Math.floor(1e6*parseFloat(r));console.log("Sending Algos:",{to:e,amount:p}),n=yield d.sendPayment({recipient:e,amount:p});break;default:throw new Error(`Unsupported wallet type: ${t.walletType}`)}console.log("Transaction sent:",n);const i=n.hash||n.txID||n.txId||n;return console.log("Transaction hash:",i),i}catch(n){throw console.error("Native transaction error:",n),n}})),Td=(t,e)=>__async(this,null,(function*(){var r;if(console.log("Sending transaction with:",e),!t)throw new Error("Wallet not connected");const{to:n,amount:i,tokenAddress:s,currency:a,network:o}=e;if(!n)throw new Error("Recipient address not provided");const l=null==(r=yd[a])?void 0:r[o];return l&&l.isNative?Cd(t,n,i):l?Rd(t,l,n,i):Cd(t,n,i)})),Rd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending token transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Token configuration not provided");if(!r)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");const{contractAddress:i,decimals:s,symbol:a}=e;switch(console.log(`Token: ${a}, Decimals: ${s}, Contract: ${i}`),t.walletType){case gd.TRONLINK:return Gd(t,e,r,n);case gd.LUTE:return Bd(t,e,r,n);default:return Md(t,e,r,n)}})),Md=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending ERC20/BEP20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");const i=t.provider,s=yield i.getSigner(),{contractAddress:a,decimals:o,symbol:l}=e,c=parseFloat(n),u=parseInt(o),h=ii(c.toString(),u);console.log(`Sending ${c} ${l} (${h.toString()} base units) to ${r}`),console.log("Token config:",{contractAddress:a,decimals:o,symbol:l});try{const t=new eh(a,["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(),n=yield t.balanceOf(e);if(console.log(`User ${l} balance:`,ni(n,o)),n<h)throw new Error(`Insufficient ${l} balance. Required: ${c}, Available: ${ni(n,o)}`);try{const e=yield t.transfer.estimateGas(r,h);let n;console.log("Gas estimate:",e.toString()),n="USDC"===l?BigInt(150):"USDT"===l?BigInt(130):BigInt(120);const i=e*n/BigInt(100);console.log("Using gas limit:",i.toString());const s=yield t.transfer(r,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 n=yield t.transfer(r,h,{gasLimit:e});return console.log("Transaction sent with fixed gas limit:",n),n.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,r,n)=>__async(this,null,(function*(){if(console.log("Sending TRC20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!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:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=(l*Math.pow(10,c)).toString();console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.contract().at(s);if(!t.transfer)throw new Error("Invalid TRC-20 contract");const e=yield t.transfer(r,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"}`)}})),Bd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending Algorand asset transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!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:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.sendAssetTransfer({recipient:r,assetId:s,amount:u});return console.log("Algorand asset transaction sent:",t),t.txId}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}}));let Id={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{},authToken:null};const Od=t=>__async(this,null,(function*(){Id=__spreadValues(__spreadValues({},Id),t),console.log("API initialized with:",{apiUrl:Id.apiUrl,apiKey:Id.apiKey?`${Id.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Id.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(`${Id.apiKey}:${Id.apiSecret}`),e=yield fetch(`${Id.apiUrl}/api/merchants/dashboard`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,"x-api-key":Id.apiKey,"x-api-secret":Id.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),Id.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(Id.merchantWalletAddresses).length&&(yield Fd()),Id.merchantWalletAddresses})),Ld=()=>({"Content-Type":"application/json","x-api-key":Id.apiKey,"x-api-secret":Id.apiSecret,Authorization:Id.authToken?`Bearer ${Id.authToken}`:void 0}),Dd=t=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",t),!t.amount)throw new Error("Payment amount is required");const r=yield Ud();console.log("Using merchant wallets:",r);const n=__spreadProps(__spreadValues({},t),{merchantWalletAddresses:__spreadValues(__spreadValues({},r),t.merchantWalletAddresses)});console.log("Enhanced payment data:",n);const i=yield fetch(`${Id.apiUrl}/api/payments/create`,{method:"POST",headers:Ld(),body:JSON.stringify(n)});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(r){throw console.error("Create payment error:",r),r}})),jd=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 r=yield fetch(`${Id.apiUrl}/api/payments/process`,{method:"POST",headers:Ld(),body:JSON.stringify(t)});if(console.log("Process payment response status:",r.status),!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to process payment: ${r.status} ${r.statusText}`)}throw console.error("Error processing payment:",t),new Error(t.error||`Failed to process payment: ${r.status}`)}const n=yield r.json();return console.log("Process payment response data:",n),n}catch(r){throw console.error("Process payment error:",r),r}}));var Hd={exports:{}},Wd={},Qd=e,zd=Symbol.for("react.element"),Vd=Symbol.for("react.fragment"),Kd=Object.prototype.hasOwnProperty,Jd=Qd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qd={key:!0,ref:!0,__self:!0,__source:!0};function Yd(t,e,r){var n,i={},s=null,a=null;for(n in void 0!==r&&(s=""+r),void 0!==e.key&&(s=""+e.key),void 0!==e.ref&&(a=e.ref),e)Kd.call(e,n)&&!qd.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===i[n]&&(i[n]=e[n]);return{$$typeof:zd,type:t,key:s,ref:a,props:i,_owner:Jd.current}}Wd.Fragment=Vd,Wd.jsx=Yd,Wd.jsxs=Yd,Hd.exports=Wd;var Zd=Hd.exports;const Xd=e.createContext(),$d=e.createContext(),tp=()=>e.useContext($d);var ep,rp,np=Object.defineProperty,ip=Object.getOwnPropertySymbols,sp=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,op=(t,e,r)=>e in t?np(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,lp=(t,e)=>{for(var r in e||(e={}))sp.call(e,r)&&op(t,r,e[r]);if(ip)for(var r of ip(e))ap.call(e,r)&&op(t,r,e[r]);return t},cp=(t,e)=>{var r={};for(var n in t)sp.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&ip)for(var n of ip(t))e.indexOf(n)<0&&ap.call(t,n)&&(r[n]=t[n]);return r};(t=>{const e=class e{constructor(t,r,n,s){if(this.version=t,this.errorCorrectionLevel=r,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 a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const o=this.addEccAndInterleave(n);if(this.drawCodewords(o),-1==s){let t=1e9;for(let e=0;e<8;e++){this.applyMask(e),this.drawFormatBits(e);const r=this.getPenaltyScore();r<t&&(s=e,t=r),this.applyMask(e)}}i(0<=s&&s<=7),this.mask=s,this.applyMask(s),this.drawFormatBits(s),this.isFunction=[]}static encodeText(r,n){const i=t.QrSegment.makeSegments(r);return e.encodeSegments(i,n)}static encodeBinary(r,n){const i=t.QrSegment.makeBytes(r);return e.encodeSegments([i],n)}static encodeSegments(t,n,s=1,o=40,l=-1,c=!0){if(!(e.MIN_VERSION<=s&&s<=o&&o<=e.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,h;for(u=s;;u++){const r=8*e.getNumDataCodewords(u,n),i=a.getTotalBits(t,u);if(i<=r){h=i;break}if(u>=o)throw new RangeError("Data too long")}for(const r of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])c&&h<=8*e.getNumDataCodewords(u,r)&&(n=r);let d=[];for(const e of t){r(e.mode.modeBits,4,d),r(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,n);i(d.length<=p),r(0,Math.min(4,p-d.length),d),r(0,(8-d.length%8)%8,d),i(d.length%8==0);for(let e=236;d.length<p;e^=253)r(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,n,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 r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%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 r=0;r<e;r++)for(let n=0;n<e;n++)0==r&&0==n||0==r&&n==e-1||r==e-1&&0==n||this.drawAlignmentPattern(t[r],t[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.errorCorrectionLevel.formatBits<<3|t;let r=e;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const s=21522^(e<<10|r);i(s>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,n(s,i));this.setFunctionModule(8,7,n(s,6)),this.setFunctionModule(8,8,n(s,7)),this.setFunctionModule(7,8,n(s,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,n(s,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,n(s,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,n(s,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let r=0;r<12;r++)t=t<<1^7973*(t>>>11);const e=this.version<<12|t;i(e>>>18==0);for(let r=0;r<18;r++){const t=n(e,r),i=this.size-11+r%3,s=Math.floor(r/3);this.setFunctionModule(i,s,t),this.setFunctionModule(s,i,t)}}drawFinderPattern(t,e){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const i=Math.max(Math.abs(n),Math.abs(r)),s=t+n,a=e+r;0<=s&&s<this.size&&0<=a&&a<this.size&&this.setFunctionModule(s,a,2!=i&&4!=i)}}drawAlignmentPattern(t,e){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(t+n,e+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(t,e,r){this.modules[e][t]=r,this.isFunction[e][t]=!0}addEccAndInterleave(t){const r=this.version,n=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const s=e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],o=Math.floor(e.getNumRawDataModules(r)/8),l=s-o%s,c=Math.floor(o/s);let u=[];const h=e.reedSolomonComputeDivisor(a);for(let i=0,p=0;i<s;i++){let r=t.slice(p,p+c-a+(i<l?0:1));p+=r.length;const n=e.reedSolomonComputeRemainder(r,h);i<l&&r.push(0),u.push(r.concat(n))}let d=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,r)=>{(e!=c-a||r>=l)&&d.push(t[e])}));return i(d.length==o),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=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 a=e-s,o=!(e+1&2)?this.size-1-i:i;!this.isFunction[o][a]&&r<8*t.length&&(this.modules[o][a]=n(t[r>>>3],7-(7&r)),r++)}}i(r==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 r=0;r<this.size;r++){let n;switch(t){case 0:n=(r+e)%2==0;break;case 1:n=e%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+e)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(e/2))%2==0;break;case 5:n=r*e%2+r*e%3==0;break;case 6:n=(r*e%2+r*e%3)%2==0;break;case 7:n=((r+e)%2+r*e%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[e][r]&&n&&(this.modules[e][r]=!this.modules[e][r])}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[i][a]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[i][a],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][i]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[a][i],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let r=0;r<this.size-1;r++){const n=this.modules[i][r];n==this.modules[i][r+1]&&n==this.modules[i+1][r]&&n==this.modules[i+1][r+1]&&(t+=e.PENALTY_N2)}let r=0;for(const e of this.modules)r=e.reduce(((t,e)=>t+(e?1:0)),r);const n=this.size*this.size,s=Math.ceil(Math.abs(20*r-10*n)/n)-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 r=[6];for(let n=this.size-7;r.length<t;n-=e)r.splice(1,0,n);return r}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;r-=(25*e-10)*e-55,t>=7&&(r-=36)}return i(208<=r&&r<=29648),r}static getNumDataCodewords(t,r){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let r=[];for(let e=0;e<t-1;e++)r.push(0);r.push(1);let n=1;for(let i=0;i<t;i++){for(let t=0;t<r.length;t++)r[t]=e.reedSolomonMultiply(r[t],n),t+1<r.length&&(r[t]^=r[t+1]);n=e.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(t,r){let n=r.map((t=>0));for(const i of t){const t=i^n.shift();n.push(0),r.forEach(((r,i)=>n[i]^=e.reedSolomonMultiply(r,t)))}return n}static reedSolomonMultiply(t,e){if(t>>>8!=0||e>>>8!=0)throw new RangeError("Byte out of range");let r=0;for(let n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(e>>>n&1)*t;return i(r>>>8==0),r}finderPenaltyCountPatterns(t){const e=t[1];i(e<=3*this.size);const r=e>0&&t[2]==e&&t[3]==3*e&&t[4]==e&&t[5]==e;return(r&&t[0]>=4*e&&t[6]>=e?1:0)+(r&&t[6]>=4*e&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,r){return t&&(this.finderPenaltyAddHistory(e,r),e=0),e+=this.size,this.finderPenaltyAddHistory(e,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(t,e){0==e[0]&&(t+=this.size),e.pop(),e.unshift(t)}};function r(t,e,r){if(e<0||e>31||t>>>e!=0)throw new RangeError("Value out of range");for(let n=e-1;n>=0;n--)r.push(t>>>n&1)}function n(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,r){if(this.mode=t,this.numChars=e,this.bitData=r,e<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(e){let n=[];for(const t of e)r(t,8,n);return new t(t.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!t.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const i=Math.min(e.length-t,3);r(parseInt(e.substring(t,t+i),10),3*i+1,n),t+=i}return new t(t.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!t.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,i=[];for(n=0;n+2<=e.length;n+=2){let s=45*t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n));s+=t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n+1)),r(s,11,i)}return n<e.length&&r(t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)),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 n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,n);else if(e<16384)r(2,2,n),r(e,14,n);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(e,21,n)}return new t(t.Mode.ECI,0,n)}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 r=0;for(const n of t){const t=n.mode.numCharCountBits(e);if(n.numChars>=1<<t)return 1/0;r+=4+t+n.bitData.length}return r}static toUtf8ByteArray(t){t=encodeURI(t);let e=[];for(let r=0;r<t.length;r++)"%"!=t.charAt(r)?e.push(t.charCodeAt(r)):(e.push(parseInt(t.substring(r+1,r+3),16)),r+=2);return e}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=s;t.QrSegment=s})(ep||(ep={})),(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=ep||(ep={})).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={}))})(ep||(ep={}));var up=ep,hp={L:up.QrCode.Ecc.LOW,M:up.QrCode.Ecc.MEDIUM,Q:up.QrCode.Ecc.QUARTILE,H:up.QrCode.Ecc.HIGH},dp=128,pp="L",fp="#FFFFFF",gp="#000000",mp=!1,_p=1;
|
11
|
+
const ba=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Aa=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ea=BigInt(1),xa=BigInt(2),ka=(t,e)=>(t+e/xa)/e;const Sa=function(t,e,r=!1,n={}){if(t<=Ks)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=aa(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=ia(t),o=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Ds(i),ZERO:Ks,ONE:Js,create:e=>ta(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=>ta(-e,t),eql:(t,e)=>t===e,sqr:e=>ta(e*e,t),add:(e,r)=>ta(e+r,t),sub:(e,r)=>ta(e-r,t),mul:(e,r)=>ta(e*r,t),pow:(t,e)=>function(t,e,r){if(r<Ks)throw new Error("Expected power > 0");if(r===Ks)return t.ONE;if(r===Js)return e;let n=t.ONE,i=e;for(;r>Ks;)r&Js&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Js;return n}(o,t,e),div:(e,r)=>ta(e*na(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>na(e,t),sqrt:n.sqrt||(t=>a(o,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(o,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?Fs(t,s):Os(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return r?Is(t):Bs(t)}});return Object.freeze(o)}(ba,void 0,void 0,{sqrt:function(t){const e=ba,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),o=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=ra(u,r,e)*u%e,d=ra(h,r,e)*u%e,p=ra(d,xa,e)*c%e,f=ra(p,i,e)*p%e,g=ra(f,s,e)*f%e,m=ra(g,o,e)*g%e,y=ra(m,l,e)*m%e,_=ra(y,o,e)*g%e,v=ra(_,r,e)*u%e,w=ra(v,a,e)*f%e,b=ra(w,n,e)*c%e,A=ra(b,xa,e);if(!Sa.eql(Sa.sqr(A),t))throw new Error("Cannot find square root");return A}}),Na=function(t,e){const r=e=>va(__spreadValues(__spreadValues({},t),wa(e)));return Object.freeze(__spreadProps(__spreadValues({},r(e)),{create:r}))}({a:BigInt(0),b:BigInt(7),Fp:Sa,n:Aa,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Aa,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ea*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),o=ka(s*t,e),l=ka(-n*t,e);let c=ta(t-o*r-l*i,e),u=ta(-o*n-l*s,e);const h=c>a,d=u>a;if(h&&(c=e-c),d&&(u=e-u),c>a||u>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Li);BigInt(0),Na.ProjectivePoint;const Pa="0x0000000000000000000000000000000000000000",Ca="0x0000000000000000000000000000000000000000000000000000000000000000",Ta=BigInt(0),Ra=BigInt(1),Ma=BigInt(2),Ga=BigInt(27),Ba=BigInt(28),Ia=BigInt(35),Oa={};function Fa(t){return Zr(hn(t),32)}const Ua=class t{constructor(t,e,r,n){__privateAdd(this,nt,void 0),__privateAdd(this,it,void 0),__privateAdd(this,st,void 0),__privateAdd(this,at,void 0),Lr(t,Oa,"Signature"),__privateSet(this,nt,e),__privateSet(this,it,r),__privateSet(this,st,n),__privateSet(this,at,null)}get r(){return __privateGet(this,nt)}set r(t){Or(32===Jr(t),"invalid r","value",t),__privateSet(this,nt,Vr(t))}get s(){return __privateGet(this,it)}set s(t){Or(32===Jr(t),"invalid s","value",t);const e=Vr(t);Or(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=cn(t,"value");Or(27===e||28===e,"invalid v","v",t),__privateSet(this,st,e)}get networkV(){return __privateGet(this,at)}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=jr(this.s);return this.yParity&&(t[0]|=128),Vr(t)}get compactSerialized(){return Kr([this.r,this.yParityAndS])}get serialized(){return Kr([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(Oa,this.r,this.s,this.v);return this.networkV&&__privateSet(e,at,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=sn(t,"v");return e==Ga||e==Ba?Ta:(Or(e>=Ia,"invalid EIP-155 v","v",t),(e-Ia)/Ma)}static getChainIdV(t,e){return sn(t)*Ma+BigInt(35+e-27)}static getNormalizedV(t){const e=sn(t);return e===Ta||e===Ga?27:e===Ra||e===Ba?28:(Or(e>=Ia,"invalid v","v",t),e&Ra?27:28)}static from(e){function r(t,r){Or(t,r,"signature",e)}if(null==e)return new t(Oa,Ca,Ca,27);if("string"==typeof e){const n=jr(e,"signature");if(64===n.length){const e=Vr(n.slice(0,32)),r=n.slice(32,64),i=128&r[0]?28:27;return r[0]&=127,new t(Oa,e,Vr(r),i)}if(65===n.length){const e=Vr(n.slice(0,32)),i=n.slice(32,64);r(!(128&i[0]),"non-canonical s");const s=t.getNormalizedV(n[64]);return new t(Oa,e,Vr(i),s)}r(!1,"invalid raw signature length")}if(e instanceof t)return e.clone();const n=e.r;r(null!=n,"missing r");const i=Fa(n),s=function(t,e){if(null!=t)return Fa(t);if(null!=e){r(Wr(e,32),"invalid yParityAndS");const t=jr(e);return t[0]&=127,Vr(t)}r(!1,"missing s")}(e.s,e.yParityAndS);r(!(128&jr(s)[0]),"non-canonical s");const{networkV:a,v:o}=function(e,n,i){if(null!=e){const r=sn(e);return{networkV:r>=Ia?r:void 0,v:t.getNormalizedV(r)}}if(null!=n)return r(Wr(n,32),"invalid yParityAndS"),{v:128&jr(n)[0]?28:27};if(null!=i){switch(cn(i,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}r(!1,"invalid yParity")}r(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new t(Oa,i,s,o);return a&&__privateSet(l,at,a),r(null==e.yParity||cn(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),r(null==e.yParityAndS||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};nt=new WeakMap,it=new WeakMap,st=new WeakMap,at=new WeakMap;let La=Ua;ot=new WeakMap;let Da=class t{constructor(t){__privateAdd(this,ot,void 0),Or(32===Jr(t),"invalid private key","privateKey","[REDACTED]"),__privateSet(this,ot,Vr(t))}get privateKey(){return __privateGet(this,ot)}get publicKey(){return t.computePublicKey(__privateGet(this,ot))}get compressedPublicKey(){return t.computePublicKey(__privateGet(this,ot),!0)}sign(t){Or(32===Jr(t),"invalid digest length","digest",t);const e=Na.sign(Hr(t),Hr(__privateGet(this,ot)),{lowS:!0});return La.from({r:un(e.r,32),s:un(e.s,32),v:e.recovery?28:27})}computeSharedSecret(e){const r=t.computePublicKey(e);return Vr(Na.getSharedSecret(Hr(__privateGet(this,ot)),jr(r),!1))}static computePublicKey(t,e){let r=jr(t,"key");if(32===r.length){return Vr(Na.getPublicKey(r,!!e))}if(64===r.length){const t=new Uint8Array(65);t[0]=4,t.set(r,1),r=t}return Vr(Na.ProjectivePoint.fromHex(r).toRawBytes(e))}static recoverPublicKey(t,e){Or(32===Jr(t),"invalid digest length","digest",t);const r=La.from(e);let n=Na.Signature.fromCompact(Hr(Kr([r.r,r.s])));n=n.addRecoveryBit(r.yParity);const i=n.recoverPublicKey(Hr(t));return Or(null!=i,"invalid signature for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(e,r,n){const i=Na.ProjectivePoint.fromHex(t.computePublicKey(e).substring(2)),s=Na.ProjectivePoint.fromHex(t.computePublicKey(r).substring(2));return"0x"+i.add(s).toHex(!!n)}};const ja=BigInt(0),Ha=BigInt(36);function Wa(t){const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);const n=jr(ws(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(15&n[i>>1])>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const Qa={};for(let Pp=0;Pp<10;Pp++)Qa[String(Pp)]=String(Pp);for(let Pp=0;Pp<26;Pp++)Qa[String.fromCharCode(65+Pp)]=String(10+Pp);const za=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function Va(t){if(Or("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=Wa(t);return Or(!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}$/)){Or(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Qa[t])).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=ja;for(let r=0;r<t.length;r++)e=e*Ha+za[t[r]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Wa("0x"+e)}Or(!1,"invalid address","address",t)}function Ka(t){return t&&"function"==typeof t.getAddress}function Ja(t,e){return __async(this,null,(function*(){const r=yield e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(Ir("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),Or(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),Va(r)}))}function qa(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?Va(t):(Ir(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ja(t,e.resolveName(t))):Ka(t)?Ja(t,t.getAddress()):t&&"function"==typeof t.then?Ja(t,t):void Or(!1,"unsupported addressable value","target",t)}const Ya={};function Za(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new to(Ya,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function Xa(t,e){return new to(Ya,`bytes${e||""}`,t,{size:e})}const $a=Symbol.for("_ethers_typed");lt=new WeakMap;let to=class t{constructor(t,e,r,n){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,lt,void 0),__publicField(this,"_typedSymbol"),null==n&&(n=null),Lr(Ya,t,"Typed"),Tr(this,{_typedSymbol:$a,type:e,value:r}),__privateSet(this,lt,n),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,r){return new t(Ya,e,r)}static uint8(t){return Za(t,8)}static uint16(t){return Za(t,16)}static uint24(t){return Za(t,24)}static uint32(t){return Za(t,32)}static uint40(t){return Za(t,40)}static uint48(t){return Za(t,48)}static uint56(t){return Za(t,56)}static uint64(t){return Za(t,64)}static uint72(t){return Za(t,72)}static uint80(t){return Za(t,80)}static uint88(t){return Za(t,88)}static uint96(t){return Za(t,96)}static uint104(t){return Za(t,104)}static uint112(t){return Za(t,112)}static uint120(t){return Za(t,120)}static uint128(t){return Za(t,128)}static uint136(t){return Za(t,136)}static uint144(t){return Za(t,144)}static uint152(t){return Za(t,152)}static uint160(t){return Za(t,160)}static uint168(t){return Za(t,168)}static uint176(t){return Za(t,176)}static uint184(t){return Za(t,184)}static uint192(t){return Za(t,192)}static uint200(t){return Za(t,200)}static uint208(t){return Za(t,208)}static uint216(t){return Za(t,216)}static uint224(t){return Za(t,224)}static uint232(t){return Za(t,232)}static uint240(t){return Za(t,240)}static uint248(t){return Za(t,248)}static uint256(t){return Za(t,256)}static uint(t){return Za(t,256)}static int8(t){return Za(t,-8)}static int16(t){return Za(t,-16)}static int24(t){return Za(t,-24)}static int32(t){return Za(t,-32)}static int40(t){return Za(t,-40)}static int48(t){return Za(t,-48)}static int56(t){return Za(t,-56)}static int64(t){return Za(t,-64)}static int72(t){return Za(t,-72)}static int80(t){return Za(t,-80)}static int88(t){return Za(t,-88)}static int96(t){return Za(t,-96)}static int104(t){return Za(t,-104)}static int112(t){return Za(t,-112)}static int120(t){return Za(t,-120)}static int128(t){return Za(t,-128)}static int136(t){return Za(t,-136)}static int144(t){return Za(t,-144)}static int152(t){return Za(t,-152)}static int160(t){return Za(t,-160)}static int168(t){return Za(t,-168)}static int176(t){return Za(t,-176)}static int184(t){return Za(t,-184)}static int192(t){return Za(t,-192)}static int200(t){return Za(t,-200)}static int208(t){return Za(t,-208)}static int216(t){return Za(t,-216)}static int224(t){return Za(t,-224)}static int232(t){return Za(t,-232)}static int240(t){return Za(t,-240)}static int248(t){return Za(t,-248)}static int256(t){return Za(t,-256)}static int(t){return Za(t,-256)}static bytes1(t){return Xa(t,1)}static bytes2(t){return Xa(t,2)}static bytes3(t){return Xa(t,3)}static bytes4(t){return Xa(t,4)}static bytes5(t){return Xa(t,5)}static bytes6(t){return Xa(t,6)}static bytes7(t){return Xa(t,7)}static bytes8(t){return Xa(t,8)}static bytes9(t){return Xa(t,9)}static bytes10(t){return Xa(t,10)}static bytes11(t){return Xa(t,11)}static bytes12(t){return Xa(t,12)}static bytes13(t){return Xa(t,13)}static bytes14(t){return Xa(t,14)}static bytes15(t){return Xa(t,15)}static bytes16(t){return Xa(t,16)}static bytes17(t){return Xa(t,17)}static bytes18(t){return Xa(t,18)}static bytes19(t){return Xa(t,19)}static bytes20(t){return Xa(t,20)}static bytes21(t){return Xa(t,21)}static bytes22(t){return Xa(t,22)}static bytes23(t){return Xa(t,23)}static bytes24(t){return Xa(t,24)}static bytes25(t){return Xa(t,25)}static bytes26(t){return Xa(t,26)}static bytes27(t){return Xa(t,27)}static bytes28(t){return Xa(t,28)}static bytes29(t){return Xa(t,29)}static bytes30(t){return Xa(t,30)}static bytes31(t){return Xa(t,31)}static bytes32(t){return Xa(t,32)}static address(e){return new t(Ya,"address",e)}static bool(e){return new t(Ya,"bool",!!e)}static bytes(e){return new t(Ya,"bytes",e)}static string(e){return new t(Ya,"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(Ya,"overrides",Object.assign({},e))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===$a}static dereference(e,r){if(t.isTyped(e)){if(e.type!==r)throw new Error(`invalid type: expecetd ${r}, got ${e.type}`);return e.value}return e}};class eo extends mi{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=to.dereference(e,"string");try{r=Va(r)}catch(n){return this._throwError(n.message,e)}return t.writeValue(r)}decode(t){return Va(un(t.readValue(),20))}}class ro 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 no(t,e,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map((e=>{const n=e.localName;return Ir(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),Ir(!t[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),t[n]=!0,r[n]}))}else Or(!1,"invalid tuple value","tuple",r);Or(e.length===n.length,"types/value length mismatch","tuple",r);let i=new yi,s=new yi,a=[];e.forEach(((t,e)=>{let r=n[e];if(t.dynamic){let e=s.length;t.encode(s,r);let n=i.writeUpdatableValue();a.push((t=>{n(t+e)}))}else t.encode(i,r)})),a.forEach((t=>{t(i.length)}));let o=t.appendWriter(i);return o+=t.appendWriter(s),o}function io(t,e){let r=[],n=[],i=t.subReader(0);return e.forEach((e=>{let s=null;if(e.dynamic){let r=t.readIndex(),n=i.subReader(r);try{s=e.decode(n)}catch(a){if(Mr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}}else try{s=e.decode(t)}catch(a){if(Mr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}if(null==s)throw new Error("investigate");r.push(s),n.push(e.localName||null)})),fi.fromItems(r,n)}class so extends mi{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),__publicField(this,"coder"),__publicField(this,"length"),Tr(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){const r=to.dereference(e,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,t.writeValue(r.length)),Fr(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let s=0;s<r.length;s++)i.push(this.coder);return no(t,i,r)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),Ir(e*si<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*si,length:t.dataLength}));let r=[];for(let n=0;n<e;n++)r.push(new ro(this.coder));return io(t,r)}}class ao extends mi{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=to.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class oo extends mi{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=Hr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class lo extends oo{constructor(t){super("bytes",t)}decode(t){return Vr(super.decode(t))}}class co extends mi{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),__publicField(this,"size"),Tr(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=Hr(to.dereference(e,this.type));return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return Vr(t.readBytes(this.size))}}const uo=new Uint8Array([]);class ho extends mi{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(uo)}decode(t){return t.readBytes(0),null}}const po=BigInt(0),fo=BigInt(1),go=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class mo extends mi{constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),__publicField(this,"size"),__publicField(this,"signed"),Tr(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let r=sn(to.dereference(e,this.type)),n=nn(go,256);if(this.signed){let t=nn(n,8*this.size-1);(r>t||r<-(t+fo))&&this._throwError("value out-of-bounds",e),r=rn(r,256)}else(r<po||r>nn(n,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(r)}decode(t){let e=nn(t.readValue(),8*this.size);return this.signed&&(e=en(e,8*this.size)),e}}class yo extends oo{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,_n(to.dereference(e,"string")))}decode(t){return vn(super.decode(t))}}class _o extends mi{constructor(t,e){let r=!1;const n=[];t.forEach((t=>{t.dynamic&&(r=!0),n.push(t.type)}));super("tuple","tuple("+n.join(",")+")",e,r),__publicField(this,"coders"),Tr(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 r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))})),Object.freeze(t)}encode(t,e){const r=to.dereference(e,"tuple");return no(t,this.coders,r)}decode(t){return io(t,this.coders)}}function vo(t,e){return{address:Va(t),storageKeys:e.map(((t,e)=>(Or(Wr(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function wo(t){if(Array.isArray(t))return t.map(((e,r)=>Array.isArray(e)?(Or(2===e.length,"invalid slot set",`value[${r}]`,e),vo(e[0],e[1])):(Or(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),vo(e.address,e.storageKeys))));Or(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return vo(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function bo(t){return{address:Va(t.address),nonce:sn(null!=t.nonce?t.nonce:0),chainId:sn(null!=t.chainId?t.chainId:0),signature:La.from(t.signature)}}function Ao(t,e){return function(t){let e;return e="string"==typeof t?Da.computePublicKey(t,!1):t.publicKey,Va(ws("0x"+e.substring(4)).substring(26))}(Da.recoverPublicKey(t,e))}const Eo=BigInt(0),xo=BigInt(2),ko=BigInt(27),So=BigInt(28),No=BigInt(35),Po=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Co=131072;function To(t,e){let r=t.toString(16);for(;r.length<2;)r="0"+r;return r+=xs(e).substring(4),"0x"+r}function Ro(t){return"0x"===t?null:Va(t)}function Mo(t,e){try{return wo(t)}catch(r){Or(!1,r.message,e,t)}}function Go(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!Array.isArray(n))throw new Error(`authorization[${r}]: invalid array`);if(6!==n.length)throw new Error(`authorization[${r}]: wrong length`);if(!n[1])throw new Error(`authorization[${r}]: null address`);e.push({address:Ro(n[1]),nonce:Io(n[2],"nonce"),chainId:Io(n[0],"chainId"),signature:La.from({yParity:Bo(n[3],"yParity"),r:Zr(n[4],32),s:Zr(n[5],32)})})}return e}catch(r){Or(!1,r.message,e,t)}}function Bo(t,e){return"0x"===t?0:cn(t,e)}function Io(t,e){if("0x"===t)return Eo;const r=sn(t,e);return Or(r<=Po,"value exceeds uint size",e,r),r}function Oo(t,e){const r=sn(t,"value"),n=hn(r);return Or(n.length<=32,"value too large",`tx.${e}`,r),n}function Fo(t){return wo(t).map((t=>[t.address,t.storageKeys]))}function Uo(t,e){Or(Array.isArray(t),`invalid ${e}`,"value",t);for(let r=0;r<t.length;r++)Or(Wr(t[r],32),"invalid ${ param } hash",`value[${r}]`,t[r]);return t}function Lo(t,e){let r;try{if(r=Bo(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(a){Or(!1,"invalid yParity","yParity",e[0])}const n=Zr(e[1],32),i=Zr(e[2],32),s=La.from({r:n,s:i,yParity:r});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,vt=new WeakMap,wt=new WeakMap,bt=new WeakMap,At=new WeakMap,Et=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakSet,Nt=function(t,e){Ir(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const r=[Oo(t.nonce,"nonce"),Oo(t.gasPrice||0,"gasPrice"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data];let n=Eo;if(t.chainId!=Eo)n=sn(t.chainId,"tx.chainId"),Or(!e||null==e.networkV||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(n=e)}if(!e)return n!==Eo&&(r.push(hn(n)),r.push("0x"),r.push("0x")),ei(r);let i=BigInt(27+e.yParity);return n!==Eo?i=La.getChainIdV(n,e.v):BigInt(e.v)!==i&&Or(!1,"tx.chainId/sig.v mismatch","sig",e),r.push(hn(i)),r.push(hn(e.r)),r.push(hn(e.s)),ei(r)}(this,r);case 1:return function(t,e){const r=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.gasPrice||0,"gasPrice"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data,Fo(t.accessList||[])];return e&&(r.push(Oo(e.yParity,"recoveryParam")),r.push(hn(e.r)),r.push(hn(e.s))),Kr(["0x01",ei(r)])}(this,r);case 2:return function(t,e){const r=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oo(t.maxFeePerGas||0,"maxFeePerGas"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data,Fo(t.accessList||[])];return e&&(r.push(Oo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Kr(["0x02",ei(r)])}(this,r);case 3:return function(t,e,r){const n=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oo(t.maxFeePerGas||0,"maxFeePerGas"),Oo(t.gasLimit,"gasLimit"),t.to||Pa,Oo(t.value,"value"),t.data,Fo(t.accessList||[]),Oo(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Uo(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(Oo(e.yParity,"yParity")),n.push(hn(e.r)),n.push(hn(e.s)),r)?Kr(["0x03",ei([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):Kr(["0x03",ei(n)])}(this,r,e?this.blobs:null);case 4:return function(t,e){const r=[Oo(t.chainId,"chainId"),Oo(t.nonce,"nonce"),Oo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Oo(t.maxFeePerGas||0,"maxFeePerGas"),Oo(t.gasLimit,"gasLimit"),t.to||"0x",Oo(t.value,"value"),t.data,Fo(t.accessList||[]),(n=t.authorizationList||[],n.map((t=>[Oo(t.chainId,"chainId"),t.address,Oo(t.nonce,"nonce"),Oo(t.signature.yParity,"yParity"),t.signature.r,t.signature.s])))];var n;return e&&(r.push(Oo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Kr(["0x04",ei(r)])}(this,r)}Ir(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Do=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,vt,void 0),__privateAdd(this,wt,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,Eo),__privateSet(this,ft,null),__privateSet(this,gt,null),__privateSet(this,mt,null),__privateSet(this,ht,"0x"),__privateSet(this,yt,Eo),__privateSet(this,_t,Eo),__privateSet(this,vt,null),__privateSet(this,wt,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:Or(!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?Pa:t}set to(t){__privateSet(this,ut,null==t?null:Va(t))}get nonce(){return __privateGet(this,dt)}set nonce(t){__privateSet(this,dt,cn(t,"value"))}get gasLimit(){return __privateGet(this,pt)}set gasLimit(t){__privateSet(this,pt,sn(t))}get gasPrice(){const t=__privateGet(this,ft);return null!=t||0!==this.type&&1!==this.type?t:Eo}set gasPrice(t){__privateSet(this,ft,null==t?null:sn(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=__privateGet(this,gt);return null==t?2===this.type||3===this.type?Eo:null:t}set maxPriorityFeePerGas(t){__privateSet(this,gt,null==t?null:sn(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=__privateGet(this,mt);return null==t?2===this.type||3===this.type?Eo:null:t}set maxFeePerGas(t){__privateSet(this,mt,null==t?null:sn(t,"maxFeePerGas"))}get data(){return __privateGet(this,ht)}set data(t){__privateSet(this,ht,Vr(t))}get value(){return __privateGet(this,yt)}set value(t){__privateSet(this,yt,sn(t,"value"))}get chainId(){return __privateGet(this,_t)}set chainId(t){__privateSet(this,_t,sn(t))}get signature(){return __privateGet(this,vt)||null}set signature(t){__privateSet(this,vt,null==t?null:La.from(t))}get accessList(){const t=__privateGet(this,wt)||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){__privateSet(this,wt,null==t?null:wo(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=>bo(t))))}get maxFeePerBlobGas(){const t=__privateGet(this,bt);return null==t&&3===this.type?Eo:t}set maxFeePerBlobGas(t){__privateSet(this,bt,null==t?null:sn(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=__privateGet(this,At);return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){Or(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)Or(Wr(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=[],r=[];for(let n=0;n<t.length;n++){const i=t[n];if(Qr(i)){Ir(__privateGet(this,Et),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=jr(i);if(Or(t.length<=Co,"blob is too large",`blobs[${n}]`,i),t.length!==Co){const e=new Uint8Array(Co);e.set(t),t=e}const s=__privateGet(this,Et).blobToKzgCommitment(t),a=Vr(__privateGet(this,Et).computeBlobKzgProof(t,s));e.push({data:Vr(t),commitment:Vr(s),proof:a}),r.push(To(1,s))}else{const t=Vr(i.commitment);e.push({data:Vr(i.data),commitment:t,proof:Vr(i.proof)}),r.push(To(1,t))}}__privateSet(this,xt,e),__privateSet(this,At,r)}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 jr(t.blobToKzgCommitment(Vr(e)))}else if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return jr(t.blobToKzgCommitment(e));if("blobToKZGCommitment"in t&&"function"==typeof t.blobToKZGCommitment)return jr(t.blobToKZGCommitment(Vr(e)));Or(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(e,r)=>"computeBlobProof"in t&&"function"==typeof t.computeBlobProof?jr(t.computeBlobProof(Vr(e),Vr(r))):"computeBlobKzgProof"in t&&"function"==typeof t.computeBlobKzgProof?t.computeBlobKzgProof(e,r):"computeBlobKZGProof"in t&&"function"==typeof t.computeBlobKZGProof?jr(t.computeBlobKZGProof(Vr(e),Vr(r))):void Or(!1,"unsupported KZG library","kzg",t)}}(t))}get hash(){return null==this.signature?null:ws(__privateMethod(this,St,Nt).call(this,!0,!1))}get unsignedHash(){return ws(this.unsignedSerialized)}get from(){return null==this.signature?null:Ao(this.unsignedHash,this.signature)}get fromPublicKey(){return null==this.signature?null:Da.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,r=null!=this.accessList,n=null!=__privateGet(this,bt)||__privateGet(this,At);null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&Ir(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),Ir(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),Ir(0!==this.type||!r,"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),r||i.push(0)):r?(i.push(1),i.push(2)):(n&&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 r=jr(e);if(r[0]>=127)return t.from(function(t){const e=Zn(t);Or(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:Bo(e[0],"nonce"),gasPrice:Io(e[1],"gasPrice"),gasLimit:Io(e[2],"gasLimit"),to:Ro(e[3]),value:Io(e[4],"value"),data:Vr(e[5]),chainId:Eo};if(6===e.length)return r;const n=Io(e[6],"v"),i=Io(e[7],"r"),s=Io(e[8],"s");if(i===Eo&&s===Eo)r.chainId=n;else{let t=(n-No)/xo;t<Eo&&(t=Eo),r.chainId=t,Or(t!==Eo||n===ko||n===So,"non-canonical legacy v","v",e[6]),r.signature=La.from({r:Zr(e[7],32),s:Zr(e[8],32),v:n})}return r}(r));switch(r[0]){case 1:return t.from(function(t){const e=Zn(jr(t).slice(1));Or(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",Vr(t));const r={type:1,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),gasPrice:Io(e[2],"gasPrice"),gasLimit:Io(e[3],"gasLimit"),to:Ro(e[4]),value:Io(e[5],"value"),data:Vr(e[6]),accessList:Mo(e[7],"accessList")};return 8===e.length||Lo(r,e.slice(8)),r}(r));case 2:return t.from(function(t){const e=Zn(jr(t).slice(1));Or(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",Vr(t));const r={type:2,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:Ro(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Mo(e[8],"accessList")};return 9===e.length||Lo(r,e.slice(9)),r}(r));case 3:return t.from(function(t){let e=Zn(jr(t).slice(1)),r="3",n=null;if(4===e.length&&Array.isArray(e[0])){r="3 (network format)";const t=e[1],i=e[2],s=e[3];Or(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),Or(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),Or(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),Or(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),Or(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let r=0;r<e[1].length;r++)n.push({data:t[r],commitment:i[r],proof:s[r]});e=e[0]}Or(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${r}`,"data",Vr(t));const i={type:3,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:Ro(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Mo(e[8],"accessList"),maxFeePerBlobGas:Io(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),Or(null!=i.to,`invalid address for transaction type: ${r}`,"data",t),Or(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let s=0;s<i.blobVersionedHashes.length;s++)Or(Wr(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",t);return 11===e.length||Lo(i,e.slice(11)),i}(r));case 4:return t.from(function(t){const e=Zn(jr(t).slice(1));Or(Array.isArray(e)&&(10===e.length||13===e.length),"invalid field count for transaction type: 4","data",Vr(t));const r={type:4,chainId:Io(e[0],"chainId"),nonce:Bo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:Ro(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Mo(e[8],"accessList"),authorizationList:Go(e[9],"authorizationList")};return 10===e.length||Lo(r,e.slice(10)),r}(r))}Ir(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const r=new t;return null!=e.type&&(r.type=e.type),null!=e.to&&(r.to=e.to),null!=e.nonce&&(r.nonce=e.nonce),null!=e.gasLimit&&(r.gasLimit=e.gasLimit),null!=e.gasPrice&&(r.gasPrice=e.gasPrice),null!=e.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=e.maxPriorityFeePerGas),null!=e.maxFeePerGas&&(r.maxFeePerGas=e.maxFeePerGas),null!=e.maxFeePerBlobGas&&(r.maxFeePerBlobGas=e.maxFeePerBlobGas),null!=e.data&&(r.data=e.data),null!=e.value&&(r.value=e.value),null!=e.chainId&&(r.chainId=e.chainId),null!=e.signature&&(r.signature=La.from(e.signature)),null!=e.accessList&&(r.accessList=e.accessList),null!=e.authorizationList&&(r.authorizationList=e.authorizationList),null!=e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes),null!=e.kzg&&(r.kzg=e.kzg),null!=e.blobs&&(r.blobs=e.blobs),null!=e.hash&&(Or(r.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),Or(r.hash===e.hash,"hash mismatch","tx",e)),null!=e.from&&(Or(r.isSigned(),"unsigned transaction cannot define '.from'","tx",e),Or(r.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),r}};function jo(t){return ws(_n(t))}const Ho=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);function Wo(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let n=r(),i=1,s=[0,1];for(let w=1;w<n;w++)s.push(i+=r());let a=r(),o=e;e+=a;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 w=0;w<31;w++)g=g<<1|u();let m=[],y=0,_=h;for(;;){let t=Math.floor(((g-y+1)*i-1)/_),e=0,r=n;for(;r-e>1;){let n=e+r>>>1;t<s[n]?r=n:e=n}if(0==e)break;m.push(e);let a=y+Math.floor(_*s[e]/i),o=y+Math.floor(_*s[e+1]/i)-1;for(;0==((a^o)&d);)g=g<<1&f|u(),a=a<<1&f,o=o<<1&f|1;for(;a&~o&p;)g=g&d|g<<1&f>>>1|u(),a=a<<1^d,o=(o^d)<<1|d|1;y=a,_=1+o-a}let v=n-4;return m.map((e=>{switch(e-v){case 3:return v+65792+(t[o++]<<16|t[o++]<<8|t[o++]);case 2:return v+256+(t[o++]<<8|t[o++]);case 1:return v+t[o++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,r)=>e[t.charCodeAt(0)]=r));let r=t.length,n=new Uint8Array(6*r>>3);for(let i=0,s=0,a=0,o=0;i<r;i++)o=o<<6|e[t.charCodeAt(i)],a+=6,a>=8&&(n[s++]=o>>(a-=8));return n}(t)))}function Qo(t){return 1&t?~t>>1:t>>1}function zo(t,e){let r=Array(t);for(let n=0,i=0;n<t;n++)r[n]=i+=Qo(e());return r}function Vo(t,e=0){let r=[];for(;;){let n=t(),i=t();if(!i)break;e+=n;for(let t=0;t<i;t++)r.push(e+t);e+=i+1}return r}function Ko(t){return qo((()=>{let e=Vo(t);if(e.length)return e}))}function Jo(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Zo(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(Xo(r,t))}return e.flat()}function qo(t){let e=[];for(;;){let r=t(e.length);if(!r)break;e.push(r)}return e}function Yo(t,e,r){let n=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)zo(t,r).forEach(((t,e)=>n[e].push(t)));return n}function Zo(t,e){let r=1+e(),n=e(),i=qo(e);return Yo(i.length,1+t,e).flatMap(((t,e)=>{let[s,...a]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*n;return[s+e*r,a.map((t=>t+i))]}))}))}function Xo(t,e){return Yo(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function $o(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 r=[];for(let n=0;n<e;)r.push(String.fromCodePoint(...t.slice(n,n+=4096)));return r.join("")}function el(t,e){let r=t.length,n=r-e.length;for(let i=0;0==n&&i<r;i++)n=t[i]-e[i];return n}const rl=44032,nl=4352,il=4449,sl=4519,al=28,ol=588;function ll(t){return t>>24&255}function cl(t){return 16777215&t}let ul,hl,dl,pl;function fl(t){return t>=rl&&t<55204}function gl(t,e){if(t>=nl&&t<4371&&e>=il&&e<4470)return rl+(t-nl)*ol+(e-il)*al;if(fl(t)&&e>sl&&e<4547&&(t-rl)%al==0)return t+(e-sl);{let r=pl.get(t);return r&&(r=r.get(e),r)?r:-1}}function ml(t){ul||function(){let t=Wo("AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIg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8bP6FGDbE/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(Ko(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),hl=new Set(Vo(t)),dl=new Map,pl=new Map;for(let[e,r]of Jo(t)){if(!hl.has(e)&&2==r.length){let[t,n]=r,i=pl.get(t);i||(i=new Map,pl.set(t,i)),i.set(n,e)}dl.set(e,r.reverse())}}();let e=[],r=[],n=!1;function i(t){let r=ul.get(t);r&&(n=!0,t|=r),e.push(t)}for(let s of t)for(;;){if(s<128)e.push(s);else if(fl(s)){let t=s-rl,e=t%ol/al|0,r=t%al;i(nl+(t/ol|0)),i(il+e),r>0&&i(sl+r)}else{let t=dl.get(s);t?r.push(...t):i(s)}if(!r.length)break;s=r.pop()}if(n&&e.length>1){let t=ll(e[0]);for(let r=1;r<e.length;r++){let n=ll(e[r]);if(0==n||t<=n){t=n;continue}let i=r-1;for(;;){let r=e[i+1];if(e[i+1]=e[i],e[i]=r,!i)break;if(t=ll(e[--i]),t<=n)break}t=ll(e[r])}}return e}function yl(t){return ml(t).map(cl)}function _l(t){return function(t){let e=[],r=[],n=-1,i=0;for(let s of t){let t=ll(s),a=cl(s);if(-1==n)0==t?n=a:e.push(a);else if(i>0&&i>=t)0==t?(e.push(n,...r),r.length=0,n=a):r.push(a),i=t;else{let s=gl(n,a);s>=0?n=s:0==i&&0==t?(e.push(n),n=a):(r.push(a),i=t)}}return n>=0&&e.push(n,...r),e}(ml(t))}const vl=".",wl=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,Pl,Cl,Tl,Rl,Ml,Gl;function Bl(){if(El)return;let t=Wo("AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0Zk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WewNmQHdPfsxChU/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=()=>Vo(t),r=()=>new Set(e()),n=(t,e)=>e.forEach((e=>t.add(e)));El=new Map(Jo(t)),xl=r(),kl=e(),Sl=new Set(e().map((t=>kl[t]))),kl=new Set(kl),Nl=r(),r();let i=Ko(t),s=t();const a=()=>{let t=new Set;return e().forEach((e=>n(t,i[e]))),n(t,e()),t};Pl=qo((e=>{let r=qo(t).map((t=>t+96));if(r.length){let n=e>=s;return r[0]-=32,r=tl(r),n&&(r=`Restricted[${r}]`),{N:r,P:a(),Q:a(),M:!t(),R:n}}})),Cl=r(),Tl=new Map;let o=e().concat(wl(Cl)).sort(((t,e)=>t-e));o.forEach(((e,r)=>{let n=t(),i=o[r]=n?o[r-n]:{V:[],M:new Map};i.V.push(e),Cl.has(e)||Tl.set(e,i)}));for(let{V:u,M:h}of new Set(Tl.values())){let t=[];for(let r of u){let e=Pl.filter((t=>bl(t,r))),i=t.find((({G:t})=>e.some((e=>t.has(e)))));i||(i={G:new Set,V:[]},t.push(i)),i.V.push(r),n(i.G,e)}let e=t.flatMap((t=>wl(t.G)));for(let{G:r,V:n}of t){let t=new Set(e.filter((t=>!r.has(t))));for(let e of n)h.set(e,t)}}Rl=new Set;let l=new Set;const c=t=>Rl.has(t)?l.add(t):Rl.add(t);for(let u of Pl){for(let t of u.P)c(t);for(let t of u.Q)c(t)}for(let u of Rl)Tl.has(u)||l.has(u)||Tl.set(u,1);n(Rl,yl(Rl)),Ml=function(t){let e=[],r=Vo(t);return function t({S:r,B:n},i,s){if(!(4&r&&s===i[i.length-1])){2&r&&(s=i[i.length-1]),1&r&&e.push(i);for(let e of n)for(let r of e.Q)t(e,[...i,r],s)}}(function e(n){return{S:t(),B:qo((()=>{let n=Vo(t).map((t=>r[t]));if(n.length)return e(n)})),Q:n}}([]),[]),e}(t).map((t=>Al.from(t))).sort(el),Gl=new Map;for(let u of Ml){let t=[Gl];for(let e of u){let r=t.map((t=>{let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}));65039===e?t.push(...r):t=r}for(let e of t)e.V=u}}function Il(t){return(Ul(t)?"":`${Ol(Fl([t]))} `)+$o(t)}function Ol(t){return`"${t}"`}function Fl(t,e=1/0,r=$o){let n=[];var i;i=t[0],Bl(),kl.has(i)&&n.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let s=0,a=t.length;for(let o=0;o<a;o++){let e=t[o];Ul(e)&&(n.push(tl(t.slice(s,o))),n.push(r(e)),s=o+1)}return n.push(tl(t.slice(s,a))),n.join("")}function Ul(t){return Bl(),Nl.has(t)}function Ll(t){return e=function(t,e,r){if(!t)return[];Bl();let n=0;return t.split(vl).map((t=>{let i=function(t){let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r);r+=n<65536?1:2,e.push(n)}return e}(t),s={input:i,offset:n};n+=i.length+1;try{let t,n=s.tokens=function(t,e,r){let n=[],i=[];for(t=t.slice().reverse();t.length;){let s=Ql(t);if(s)i.length&&(n.push(e(i)),i=[]),n.push(r(s));else{let e=t.pop();if(Rl.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&&n.push(e(i)),n}(i,e,r),a=n.length;if(!a)throw new Error("empty label");let o=s.output=n.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(o),!(s.emoji=a>1||n[0].is_emoji)&&o.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))}"`)}(o),t="ASCII";else{let e=n.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(kl.has(o[0]))throw Hl("leading combining mark");for(let t=1;t<a;t++){let e=n[t];if(!e.is_emoji&&kl.has(e[0]))throw Hl(`emoji + combining mark: "${tl(n[t-1])} + ${Fl([e[0]])}"`)}!function(t){let e=t[0],r=Ho.get(e);if(r)throw Hl(`leading ${r}`);let n=t.length,i=-1;for(let s=1;s<n;s++){e=t[s];let n=Ho.get(e);if(n){if(i==s)throw Hl(`${r} + ${n}`);i=s+1,r=n}}if(i==n)throw Hl(`trailing ${r}`)}(o);let r=wl(new Set(e)),[i]=function(t){let e=Pl;for(let r of t){let t=e.filter((t=>bl(t,r)));if(!t.length)throw Pl.some((t=>bl(t,r)))?jl(e[0],r):Dl(r);if(e=t,1==t.length)break}return e}(r);!function(t,e){for(let r of e)if(!bl(t,r))throw jl(t,r);if(t.M){let t=yl(e);for(let e=1,r=t.length;e<r;e++)if(Sl.has(t[e])){let n=e+1;for(let i;n<r&&Sl.has(i=t[n]);n++)for(let r=e;r<n;r++)if(t[r]==i)throw new Error(`duplicate non-spacing marks: ${Il(i)}`);if(n-e>4)throw new Error(`excessive non-spacing marks: ${Ol(Fl(t.slice(e-1,n)))} (${n-e}/4)`);e=n}}}(i,e),function(t,e){let r,n=[];for(let i of e){let t=Tl.get(i);if(1===t)return;if(t){let e=t.M.get(i);if(r=r?r.filter((t=>e.has(t))):wl(e),!r.length)return}else n.push(i)}if(r)for(let i of r)if(n.every((t=>bl(i,t))))throw new Error(`whole-script confusable: ${t.N}/${i.N}`)}(i,r),t=i.N}else t="Emoji"}s.type=t}catch(a){s.error=a}return s}))}(t,_l,Wl),e.map((({input:t,error:r,output:n})=>{if(r){let n=r.message;throw new Error(1==e.length?n:`Invalid label ${Ol(Fl(t,63))}: ${n}`)}return tl(n)})).join(vl);var e}function Dl(t){return new Error(`disallowed character: ${Il(t)}`)}function jl(t,e){let r=Il(e),n=Pl.find((t=>t.P.has(e)));return n&&(r=`${n.N} ${r}`),new Error(`illegal mixture: ${t.N} + ${r}`)}function Hl(t){return new Error(`illegal placement: ${t}`)}function Wl(t){return t.filter((t=>65039!=t))}function Ql(t,e){let r,n=Gl,i=t.length;for(;i&&(n=n.get(t[--i]),n);){let{V:s}=n;s&&(r=s,e&&e.push(...t.slice(i).reverse()),t.length=i)}return r}const zl=new Uint8Array(32);function Vl(t){return Or(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Kl(t){const e=_n(function(t){try{if(0===t.length)throw new Error("empty label");return Ll(t)}catch(e){Or(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),r=[];if(0===t.length)return r;let n=0;for(let i=0;i<e.length;i++){46===e[i]&&(r.push(Vl(e.slice(n,i))),n=i+1)}return Or(n<e.length,"invalid ENS name; empty component","name",t),r.push(Vl(e.slice(n))),r}function Jl(t){Or("string"==typeof t,"invalid ENS name; not a string","name",t),Or(t.length,"invalid ENS name (empty label)","name",t);let e=zl;const r=Kl(t);for(;r.length;)e=ws(Kr([e,ws(r.pop())]));return Vr(e)}function ql(t,e){const r=null!=e?e:63;return Or(r<=255,"DNS encoded label cannot exceed 255","length",r),Vr(Kr(Kl(t).map((e=>{Or(e.length<=r,`label ${JSON.stringify(t)} exceeds ${r} bytes`,"name",t);const n=new Uint8Array(e.length+1);return n.set(e,1),n[0]=n.length-1,n}))))+"00"}zl.fill(0);const Yl=new Uint8Array(32);Yl.fill(0);const Zl=BigInt(-1),Xl=BigInt(0),$l=BigInt(1),tc=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const ec=un($l,32),rc=un(Xl,32),nc={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},ic=["name","version","chainId","verifyingContract","salt"];function sc(t){return function(e){return Or("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const ac={name:sc("name"),version:sc("version"),chainId:function(t){const e=sn(t,"domain.chainId");return Or(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):dn(e)},verifyingContract:function(t){try{return Va(t).toLowerCase()}catch(e){}Or(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=jr(t,"domain.salt");return Or(32===e.length,'invalid domain value "salt"',"domain.salt",t),Vr(e)}};function oc(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const r=""===e[1],n=parseInt(e[2]);Or(n%8==0&&0!==n&&n<=256&&e[2]===String(n),"invalid numeric width","type",t);const i=nn(tc,r?n-1:n),s=r?(i+$l)*Zl:Xl;return function(e){const n=sn(e,"value");return Or(n>=s&&n<=i,`value out-of-bounds for ${t}`,"value",n),un(r?rn(n,256):n,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return Or(0!==r&&r<=32&&e[1]===String(r),"invalid bytes width","type",t),function(e){return Or(jr(e).length===r,`invalid length for ${t}`,"value",e),function(t){const e=jr(t),r=e.length%32;return r?Kr([e,Yl.slice(r)]):Vr(e)}(e)}}}switch(t){case"address":return function(t){return Zr(Va(t),32)};case"bool":return function(t){return t?ec:rc};case"bytes":return function(t){return ws(t)};case"string":return function(t){return jo(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}}Pt=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Rt=new WeakSet,Mt=function(t){{const e=oc(t);if(e)return e}const e=cc(t).array;if(e){const t=e.prefix,r=this.getEncoder(t);return n=>{Or(-1===e.count||e.count===n.length,`array length mismatch; expected length ${e.count}`,"value",n);let i=n.map(r);return __privateGet(this,Ct).has(t)&&(i=i.map(ws)),ws(Kr(i))}}const r=this.types[t];if(r){const e=jo(__privateGet(this,Ct).get(t));return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return __privateGet(this,Ct).has(r)?ws(n):n}));return n.unshift(e),Kr(n)}}Or(!1,`unknown type: ${t}`,"type",t)};let uc=class t{constructor(t){__privateAdd(this,Rt),__publicField(this,"primaryType"),__privateAdd(this,Pt,void 0),__privateAdd(this,Ct,void 0),__privateAdd(this,Tt,void 0),__privateSet(this,Ct,new Map),__privateSet(this,Tt,new Map);const e=new Map,r=new Map,n=new Map,i={};Object.keys(t).forEach((s=>{i[s]=t[s].map((({name:e,type:r})=>{let{base:n,index:i}=cc(r);return"int"!==n||t.int||(n="int256"),"uint"!==n||t.uint||(n="uint256"),{name:e,type:n+(i||"")}})),e.set(s,new Set),r.set(s,[]),n.set(s,new Set)})),__privateSet(this,Pt,JSON.stringify(i));for(const a in i){const n=new Set;for(const s of i[a]){Or(!n.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(a)}`,"types",t),n.add(s.name);const i=cc(s.type).base;Or(i!==a,`circular type reference to ${JSON.stringify(i)}`,"types",t);oc(i)||(Or(r.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),r.get(i).push(a),e.get(a).add(i))}}const s=Array.from(r.keys()).filter((t=>0===r.get(t).length));Or(0!==s.length,"missing primary type","types",t),Or(1===s.length,`ambiguous primary types or unused types: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Tr(this,{primaryType:s[0]}),function i(s,a){Or(!a.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),a.add(s);for(const t of e.get(s))if(r.has(t)){i(t,a);for(const e of a)n.get(e).add(t)}a.delete(s)}(this.primaryType,new Set);for(const[a,o]of n){const t=Array.from(o);t.sort(),__privateGet(this,Ct).set(a,lc(a,i[a])+t.map((t=>lc(t,i[t]))).join(""))}}get types(){return JSON.parse(__privateGet(this,Pt))}getEncoder(t){let e=__privateGet(this,Tt).get(t);return e||(e=__privateMethod(this,Rt,Mt).call(this,t),__privateGet(this,Tt).set(t,e)),e}encodeType(t){const e=__privateGet(this,Ct).get(t);return Or(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return ws(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(oc(t))return r(t,e);const n=cc(t).array;if(n)return Or(-1===n.count||n.count===e.length,`array length mismatch; expected length ${n.count}`,"value",e),e.map((t=>this._visit(n.prefix,t,r)));const i=this.types[t];if(i)return i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{});Or(!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,r,n){return t.from(r).hashStruct(e,n)}static hashDomain(e){const r=[];for(const t in e){if(null==e[t])continue;const n=nc[t];Or(n,`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",e),r.push({name:t,type:n})}return r.sort(((t,e)=>ic.indexOf(t.name)-ic.indexOf(e.name))),t.hashStruct("EIP712Domain",{EIP712Domain:r},e)}static encode(e,r,n){return Kr(["0x1901",t.hashDomain(e),t.from(r).hash(n)])}static hash(e,r,n){return ws(t.encode(e,r,n))}static resolveNames(e,r,n,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&&!Wr(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const a=t.from(r);a.visit(n,((t,e)=>("address"!==t||Wr(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]),n=a.visit(n,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:e,value:n}}))}static getPayload(e,r,n){t.hashDomain(e);const i={},s=[];ic.forEach((t=>{const r=e[t];null!=r&&(i[t]=ac[t](r),s.push({name:t,type:nc[t]}))}));const a=t.from(r);r=a.types;const o=Object.assign({},r);return Or(null==o.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",r),o.EIP712Domain=s,a.encode(n),{types:o,domain:i,primaryType:a.primaryType,message:a.visit(n,((t,e)=>{if(t.match(/^bytes(\d*)/))return Vr(jr(e));if(t.match(/^u?int/))return sn(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return Or("string"==typeof e,"invalid string","value",e),e}Or(!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(" ")),vc=hc([gc,yc,"tuple returns",pc].join(" ").split(" ")),wc={"(":"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,Gt,void 0),__privateAdd(this,Bt,void 0),__privateSet(this,Gt,0),__privateSet(this,Bt,t.slice())}get offset(){return __privateGet(this,Gt)}get length(){return __privateGet(this,Bt).length-__privateGet(this,Gt)}clone(){return new t(__privateGet(this,Bt))}reset(){__privateSet(this,Gt,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,Gt)+1,t.match+1);return __privateSet(this,Gt,t.match+1),e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;__privateGet(this,Gt)<t.match-1;){const t=this.peek().linkNext;e.push(__privateMethod(this,It,Ot).call(this,__privateGet(this,Gt)+1,t)),__privateSet(this,Gt,t)}return __privateSet(this,Gt,t.match+1),e}peek(){if(__privateGet(this,Gt)>=__privateGet(this,Bt).length)throw new Error("out-of-bounds");return __privateGet(this,Bt)[__privateGet(this,Gt)]}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,Gt)._++,t}toString(){const t=[];for(let e=__privateGet(this,Gt);e<__privateGet(this,Bt).length;e++){const r=__privateGet(this,Bt)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Gt=new WeakMap,Bt=new WeakMap,It=new WeakSet,Ot=function(t=0,e=0){return new Sc(__privateGet(this,Bt).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 Pc(t){const e=[],r=e=>{const r=s<t.length?JSON.stringify(t[s]):"$EOI";throw new Error(`invalid token ${r} at ${s}: ${e}`)};let n=[],i=[],s=0;for(;s<t.length;){let a=t.substring(s),o=a.match(bc);o&&(s+=o[1].length,a=t.substring(s));const l={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(l);let c=wc[a[0]]||"";if(c){if(l.type=c,l.text=a[0],s++,"OPEN_PAREN"===c)n.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("no matching open bracket"),l.match=n.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 r=e.pop().text;t=r+t,e[e.length-1].value=cn(r)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(o=a.match(Ec),o){if(l.text=o[1],s+=l.text.length,vc.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(kc)){l.type="TYPE";continue}l.type="ID"}else{if(o=a.match(Ac),!o)throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${s}`);l.text=o[1],l.type="NUMBER",s+=l.text.length}}return new Nc(e.map((t=>Object.freeze(t))))}function Cc(t,e){let r=[];for(const n in e.keys())t.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Tc(t,e){if(e.peekKeyword(mc)){const r=e.pop().text;if(r!==t)throw new Error(`expected ${t}, got ${r}`)}return e.popType("ID")}function Rc(t,e){const r=new Set;for(;;){const n=t.peekType("KEYWORD");if(null==n||e&&!e.has(n))break;if(t.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Mc(t){let e=Rc(t,fc);return Cc(e,hc("constant payable nonpayable".split(" "))),Cc(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 Gc(t,e){return t.popParams().map((t=>Kc.from(t,e)))}function Bc(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return sn(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 Fc(t){const e=t.match(kc);if(Or(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const r=parseInt(e[2]);Or(0!==r&&r<=32,"invalid bytes length","type",t)}else if(e[3]){const r=parseInt(e[3]);Or(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",t)}return t}const Uc={},Lc=Symbol.for("_ethers_internal"),Dc="_ParamTypeInternal",jc="_ErrorInternal",Hc="_EventInternal",Wc="_ConstructorInternal",Qc="_FallbackInternal",zc="_FunctionInternal",Vc="_StructInternal";Ft=new WeakSet,Ut=function(t,e,r,n){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,n)=>{var a;__privateMethod(a=i,Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(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,n)=>{var a;__privateMethod(a=i[n],Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(s)}const i=r(this.type,e);i.then?t.push(function(){return __async(this,null,(function*(){n(yield i)}))}()):n(i)};let Kc=class t{constructor(t,e,r,n,i,s,a,o){if(__privateAdd(this,Ft),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),Lr(t,Uc,"ParamType"),Object.defineProperty(this,Lc,{value:Dc}),s&&(s=Object.freeze(s.slice())),"array"===n){if(null==a||null==o)throw new Error("")}else if(null!=a||null!=o)throw new Error("");if("tuple"===n){if(null==s)throw new Error("")}else if(null!=s)throw new Error("");Tr(this,{name:e,type:r,baseType:n,indexed:i,components:s,arrayLength:a,arrayChildren:o})}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 r={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(r)}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 r=this;return t.map((t=>r.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 r=this;return t.map(((t,n)=>r.components[n].walk(t,e)))}return e(this.type,t)}walkAsync(t,e){return __async(this,null,(function*(){const r=[],n=[t];return __privateMethod(this,Ft,Ut).call(this,r,t,e,(t=>{n[0]=t})),r.length&&(yield Promise.all(r)),n[0]}))}static from(e,r){if(t.isParamType(e))return e;if("string"==typeof e)try{return t.from(Pc(e),r)}catch(o){Or(!1,"invalid param type","obj",e)}else if(e instanceof Nc){let n="",i="",s=null;Rc(e,hc(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(i="tuple",s=e.popParams().map((e=>t.from(e))),n=`tuple(${s.map((t=>t.format())).join(",")})`):(n=Fc(e.popType("TYPE")),i=n);let a=null,o=null;for(;e.length&&e.peekType("BRACKET");){const r=e.pop();a=new t(Uc,"",n,i,null,s,o,a),o=r.value,n+=r.text,i="array",s=null}let l=null;if(Rc(e,_c).has("indexed")){if(!r)throw new Error("");l=!0}const c=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new t(Uc,c,n,i,l,s,o,a)}const n=e.name;Or(!n||"string"==typeof n&&n.match(xc),"invalid name","obj.name",n);let i=e.indexed;null!=i&&(Or(r,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,a=s.match(Oc);if(a){const r=parseInt(a[2]||"-1"),o=t.from({type:a[1],components:e.components});return new t(Uc,n||"",s,"array",i,null,r,o)}if("tuple"===s||s.startsWith("tuple(")||s.startsWith("(")){const r=null!=e.components?e.components.map((e=>t.from(e))):null;return new t(Uc,n||"",s,"tuple",i,r,null,null)}return s=Fc(e.type),new t(Uc,n||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Lc]===Dc}};class Jc{constructor(t,e,r){__publicField(this,"type"),__publicField(this,"inputs"),Lr(t,Uc,"Fragment"),Tr(this,{type:e,inputs:r=Object.freeze(r.slice())})}static from(t){if("string"==typeof t){try{Jc.from(JSON.parse(t))}catch(e){}return Jc.from(Pc(t))}if(t instanceof Nc){switch(t.peekKeyword(mc)){case"constructor":return $c.from(t);case"error":return Zc.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 ru.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return $c.from(t);case"error":return Zc.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 ru.from(t)}Ir(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}Or(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return $c.isFragment(t)}static isError(t){return Zc.isFragment(t)}static isEvent(t){return Xc.isFragment(t)}static isFunction(t){return eu.isFragment(t)}static isStruct(t){return ru.isFragment(t)}}class qc extends Jc{constructor(t,e,r,n){super(t,e,n),__publicField(this,"name"),Or("string"==typeof r&&r.match(xc),"invalid identifier","name",r),n=Object.freeze(n.slice()),Tr(this,{name:r})}}function Yc(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class Zc extends qc{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Lc,{value:jc})}get selector(){return jo(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+Yc(t,this.inputs)),e.join(" ")}static from(t){if(Zc.isFragment(t))return t;if("string"==typeof t)return Zc.from(Pc(t));if(t instanceof Nc){const e=Tc("error",t),r=Gc(t);return Ic(t),new Zc(Uc,e,r)}return new Zc(Uc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Lc]===jc}}class Xc extends qc{constructor(t,e,r,n){super(t,"event",e,r),__publicField(this,"anonymous"),Object.defineProperty(this,Lc,{value:Hc}),Tr(this,{anonymous:n})}get topicHash(){return jo(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+Yc(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(Uc,t,e,!1).topicHash}static from(t){if(Xc.isFragment(t))return t;if("string"==typeof t)try{return Xc.from(Pc(t))}catch(e){Or(!1,"invalid event fragment","obj",t)}else if(t instanceof Nc){const e=Tc("event",t),r=Gc(t,!0),n=!!Rc(t,hc(["anonymous"])).has("anonymous");return Ic(t),new Xc(Uc,e,r,n)}return new Xc(Uc,t.name,t.inputs?t.inputs.map((t=>Kc.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Lc]===Hc}}class $c extends Jc{constructor(t,e,r,n,i){super(t,e,r),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Lc,{value:Wc}),Tr(this,{payable:n,gas:i})}format(t){if(Ir(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${Yc(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(Pc(t))}catch(e){Or(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Nc){Rc(t,hc(["constructor"]));const e=Gc(t),r=!!Rc(t,dc).has("payable"),n=Bc(t);return Ic(t),new $c(Uc,"constructor",e,r,n)}return new $c(Uc,"constructor",t.inputs?t.inputs.map(Kc.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Lc]===Wc}}class tu extends Jc{constructor(t,e,r){super(t,"fallback",e),__publicField(this,"payable"),Object.defineProperty(this,Lc,{value:Qc}),Tr(this,{payable:r})}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(Pc(t))}catch(e){Or(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Nc){const e=t.toString();Or(t.peekKeyword(hc(["fallback","receive"])),"type must be fallback or receive","obj",e);if("receive"===t.popKeyword(hc(["fallback","receive"]))){const e=Gc(t);return Or(0===e.length,"receive cannot have arguments","obj.inputs",e),Rc(t,hc(["payable"])),Ic(t),new tu(Uc,[],!0)}let r=Gc(t);r.length?Or(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Kc.from("bytes")];const n=Mc(t);if(Or("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Rc(t,hc(["returns"])).has("returns")){const e=Gc(t);Or(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Ic(t),new tu(Uc,r,"payable"===n)}if("receive"===t.type)return new tu(Uc,[],!0);if("fallback"===t.type){const e=[Kc.from("bytes")],r="payable"===t.stateMutability;return new tu(Uc,e,r)}Or(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Lc]===Qc}}class eu extends qc{constructor(t,e,r,n,i,s){super(t,"function",e,n),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Lc,{value:zc});Tr(this,{constant:"view"===r||"pure"===r,gas:s,outputs:i=Object.freeze(i.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return jo(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+Yc(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(Yc(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(Uc,t,"view",e,[],null).selector}static from(t){if(eu.isFragment(t))return t;if("string"==typeof t)try{return eu.from(Pc(t))}catch(r){Or(!1,"invalid function fragment","obj",t)}else if(t instanceof Nc){const e=Tc("function",t),r=Gc(t),n=Mc(t);let i=[];Rc(t,hc(["returns"])).has("returns")&&(i=Gc(t));const s=Bc(t);return Ic(t),new eu(Uc,e,n,r,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(Uc,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[Lc]===zc}}class ru extends qc{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Lc,{value:Vc})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return ru.from(Pc(t))}catch(e){Or(!1,"invalid struct fragment","obj",t)}else if(t instanceof Nc){const e=Tc("struct",t),r=Gc(t);return Ic(t),new ru(Uc,e,r)}return new ru(Uc,t.name,t.inputs?t.inputs.map(Kc.from):[])}static isFragment(t){return t&&t[Lc]===Vc}}const nu=new Map;nu.set(0,"GENERIC_PANIC"),nu.set(1,"ASSERT_FALSE"),nu.set(17,"OVERFLOW"),nu.set(18,"DIVIDE_BY_ZERO"),nu.set(33,"ENUM_RANGE_ERROR"),nu.set(34,"BAD_STORAGE_DATA"),nu.set(49,"STACK_UNDERFLOW"),nu.set(50,"ARRAY_RANGE_ERROR"),nu.set(65,"OUT_OF_MEMORY"),nu.set(81,"UNINITIALIZED_FUNCTION_CALL");const iu=new RegExp(/^bytes([0-9]*)$/),su=new RegExp(/^(u?int)([0-9]*)$/);let au=null,ou=1024;Lt=new WeakSet,Dt=function(t){if(t.isArray())return new so(__privateMethod(this,Lt,Dt).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new _o(t.components.map((t=>__privateMethod(this,Lt,Dt).call(this,t))),t.name);switch(t.baseType){case"address":return new eo(t.name);case"bool":return new ao(t.name);case"string":return new yo(t.name);case"bytes":return new lo(t.name);case"":return new ho(t.name)}let e=t.type.match(su);if(e){let r=parseInt(e[2]||"256");return Or(0!==r&&r<=256&&r%8==0,"invalid "+e[1]+" bit length","param",t),new mo(r/8,"int"===e[1],t.name)}if(e=t.type.match(iu),e){let r=parseInt(e[1]);return Or(0!==r&&r<=32,"invalid bytes length","param",t),new co(r,t.name)}Or(!1,"invalid type","type",t.type)};let lu=class t{constructor(){__privateAdd(this,Lt)}getDefaultValue(t){const e=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Kc.from(t))));return new _o(e,"_").defaultValue()}encode(t,e){Fr(e.length,t.length,"types/values length mismatch");const r=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Kc.from(t)))),n=new _o(r,"_"),i=new yi;return n.encode(i,e),i.data}decode(t,e,r){const n=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Kc.from(t))));return new _o(n,"_").decode(new _i(e,r,ou))}static _setDefaultMaxInflation(t){Or("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),ou=t}static defaultAbiCoder(){return null==au&&(au=new t),au}static getBuiltinCallException(e,r,n){return function(t,e,r,n){let i="missing revert data",s=null,a=null;if(r){i="execution reverted";const t=jr(r);if(r=Vr(r),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"===Vr(t.slice(0,4)))try{s=n.decode(["string"],t.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch(l){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===Vr(t.slice(0,4)))try{const e=Number(n.decode(["uint256"],t.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[e]},s=`Panic due to ${nu.get(e)||"UNKNOWN"}(${e})`,i+=`: ${s}`}catch(l){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const o={to:e.to?Va(e.to):null,data:e.data||"0x"};return e.from&&(o.from=Va(e.from)),Br(i,"CALL_EXCEPTION",{action:t,data:r,reason:s,transaction:o,invocation:null,revert:a})}(e,r,n,t.defaultAbiCoder())}};class cu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,signature:i,topic:e,args:r})}}class uu{constructor(t,e,r,n){__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();Tr(this,{fragment:t,name:i,args:r,signature:s,selector:e,value:n})}}class hu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,args:r,signature:i,selector:e})}}class du{constructor(t){__publicField(this,"hash"),__publicField(this,"_isIndexed"),Tr(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,r){if(Wr(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 n=[];for(const[e,r]of __privateGet(this,Wt))e.split("(")[0]===t&&n.push(r);if(e){const t=e.length>0?e[e.length-1]:null;let r=e.length,i=!0;to.isTyped(t)&&"overrides"===t.type&&(i=!1,r--);for(let e=n.length-1;e>=0;e--){const t=n[e].inputs.length;t===r||i&&t===r-1||n.splice(e,1)}for(let s=n.length-1;s>=0;s--){const t=n[s].inputs;for(let r=0;r<e.length;r++)if(to.isTyped(e[r])){if(r>=t.length){if("overrides"===e[r].type)continue;n.splice(s,1);break}if(e[r].type!==t[r].baseType){n.splice(s,1);break}}}}if(1===n.length&&e&&e.length!==n[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&n.splice(0,1)}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous function description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Wt).get(eu.from(t).format());return n||null},Kt=new WeakSet,Jt=function(t,e,r){if(Wr(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 n=[];for(const[e,r]of __privateGet(this,Ht))e.split("(")[0]===t&&n.push(r);if(e){for(let t=n.length-1;t>=0;t--)n[t].inputs.length<e.length&&n.splice(t,1);for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(to.isTyped(e[i])&&e[i].type!==r[i].baseType){n.splice(t,1);break}}}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous event description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Ht).get(Xc.from(t).format());return n||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 r=[];for(const a of e)try{r.push(Jc.from(a))}catch(s){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,s.message)}Tr(this,{fragments:Object.freeze(r)});let n=null,i=!1;__privateSet(this,Qt,this.getAbiCoder()),this.fragments.forEach(((t,e)=>{let r;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void Tr(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(Or(!n||t.payable!==n.payable,"conflicting fallback fragments",`fragments[${e}]`,t),n=t,i=n.payable));case"function":r=__privateGet(this,Wt);break;case"event":r=__privateGet(this,Ht);break;case"error":r=__privateGet(this,jt);break;default:return}const s=t.format();r.has(s)||r.set(s,t)})),this.deploy||Tr(this,{deploy:$c.from("constructor()")}),Tr(this,{fallback:n,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 Or(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 r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Wt).get(n),r)}}getEventName(t){const e=__privateMethod(this,Kt,Jt).call(this,t,null,!1);return Or(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 r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Ht).get(n),r)}}getError(t,e){if(Wr(t)){const e=t.toLowerCase();if(fu[e])return Zc.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[r,n]of __privateGet(this,jt))r.split("(")[0]===t&&e.push(n);if(0===e.length)return"Error"===t?Zc.from("error Error(string)"):"Panic"===t?Zc.from("error Panic(uint256)"):null;if(e.length>1){Or(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t)}return e[0]}if("Error(string)"===(t=Zc.from(t).format()))return Zc.from("error Error(string)");if("Panic(uint256)"===t)return Zc.from("error Panic(uint256)");const r=__privateGet(this,jt).get(t);return r||null}forEachError(t){const e=Array.from(__privateGet(this,jt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,jt).get(n),r)}}_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);Or(e,"unknown error","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Or(e,"unknown error","fragment",t),t=e}return Kr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Kr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}let r="invalid length for result data";const n=Hr(e);if(n.length%32==0)try{return __privateGet(this,Qt).decode(t.outputs,n)}catch(i){r="could not decode result data"}Ir(!1,r,"BAD_DATA",{value:Vr(n),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=jr(t,"data"),n=lu.getBuiltinCallException("call",e,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const t=Vr(r.slice(0,4)),e=this.getError(t);if(e)try{const t=__privateGet(this,Qt).decode(e.inputs,r.slice(4));n.revert={name:e.name,signature:e.format(),args:t},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(s){n.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(n.invocation={method:i.name,signature:i.signature,args:i.args}),n}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Vr(__privateGet(this,Qt).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}Ir(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const n=(t,e)=>"string"===t.type?jo(e):"bytes"===t.type?ws(Vr(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=un(e):t.type.match(/^bytes/)?e=Yr(e,32,!1):"address"===t.type&&__privateGet(this,Qt).encode(["address"],[e]),Zr(Vr(e),32));for(e.forEach(((e,i)=>{const s=t.inputs[i];s.indexed?null==e?r.push(null):"array"===s.baseType||"tuple"===s.baseType?Or(!1,"filtering with tuples or arrays not supported","contract."+s.name,e):Array.isArray(e)?r.push(e.map((t=>n(s,t)))):r.push(n(s,e)):Or(null==e,"cannot filter non-indexed parameters; must be null","contract."+s.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}const r=[],n=[],i=[];return t.anonymous||r.push(t.topicHash),Or(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,s)=>{const a=e[s];if(t.indexed)if("string"===t.type)r.push(jo(a));else if("bytes"===t.type)r.push(ws(a));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(__privateGet(this,Qt).encode([t.type],[a]))}else n.push(t),i.push(a)})),{data:__privateGet(this,Qt).encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}if(null!=r&&!t.anonymous){const e=t.topicHash;Or(Wr(r[0],32)&&r[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],i=[],s=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Kc.from({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))}));const a=null!=r?__privateGet(this,Qt).decode(n,Kr(r)):null,o=__privateGet(this,Qt).decode(i,e,!0),l=[],c=[];let u=0,h=0;return t.inputs.forEach(((t,e)=>{let r=null;if(t.indexed)if(null==a)r=new du(null);else if(s[e])r=new du(a[h++]);else try{r=a[h++]}catch(n){r=n}else try{r=o[u++]}catch(n){r=n}l.push(r),c.push(t.name||null)})),fi.fromItems(l,c)}parseTransaction(t){const e=jr(t.data,"tx.data"),r=sn(null!=t.value?t.value:0,"tx.value"),n=this.getFunction(Vr(e.slice(0,4)));if(!n)return null;const i=__privateGet(this,Qt).decode(n.inputs,e.slice(4));return new uu(n,n.selector,i,r)}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=Vr(t),r=this.getError(qr(e,0,4));if(!r)return null;const n=__privateGet(this,Qt).decode(r.inputs,qr(e,4));return new hu(r,r.selector,n)}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 vu{constructor(t,e,r){__publicField(this,"gasPrice"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxPriorityFeePerGas"),Tr(this,{gasPrice:yu(t),maxFeePerGas:yu(e),maxPriorityFeePerGas:yu(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:_u(t),maxFeePerGas:_u(e),maxPriorityFeePerGas:_u(r)}}}function wu(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=Vr(t.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of r)i in t&&null!=t[i]&&(e[i]=sn(t[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)i in t&&null!=t[i]&&(e[i]=cn(t[i],`request.${i}`));return t.accessList&&(e.accessList=wo(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=>Qr(t)?Vr(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))),Tr(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?[]:(Ir("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:n,gasUsed:i,hash:s,miner:a,prevRandao:o,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:r,gasLimit:_u(n),gasUsed:_u(i),blobGasUsed:_u(this.blobGasUsed),excessBlobGas:_u(this.excessBlobGas),hash:s,miner:a,prevRandao:o,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 r=t.toLowerCase();for(const t of __privateGet(this,qt)){if("string"==typeof t){if(t!==r)continue;e=t;break}if(t.hash===r){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 r of e)if(r.hash===t)return r;Or(!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 r=Object.freeze(t.topics.slice());Tr(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);return Ir(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.transactionHash);return Ir(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransactionReceipt(){return __async(this,null,(function*(){const t=yield this.provider.getTransactionReceipt(this.transactionHash);return Ir(!!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,Yt,void 0),__privateSet(this,Yt,Object.freeze(t.logs.map((t=>new Au(t,e)))));let r=mu;null!=t.effectiveGasPrice?r=t.effectiveGasPrice:null!=t.gasPrice&&(r=t.gasPrice),Tr(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:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return __privateGet(this,Yt)}toJSON(){const{to:t,from:e,contractAddress:r,hash:n,index:i,blockHash:s,blockNumber:a,logsBloom:o,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:s,blockNumber:a,contractAddress:r,cumulativeGasUsed:_u(this.cumulativeGasUsed),from:e,gasPrice:_u(this.gasPrice),blobGasUsed:_u(this.blobGasUsed),blobGasPrice:_u(this.blobGasPrice),gasUsed:_u(this.gasUsed),hash:n,index:i,logs:l,logsBloom:o,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 Ir(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ku(this,t)}}Yt=new WeakMap;Zt=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,Zt,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,Zt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:n,type:i,to:s,from:a,nonce:o,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:a,gasLimit:_u(this.gasLimit),gasPrice:_u(this.gasPrice),hash:n,maxFeePerGas:_u(this.maxFeePerGas),maxPriorityFeePerGas:_u(this.maxPriorityFeePerGas),maxFeePerBlobGas:_u(this.maxFeePerBlobGas),nonce:o,signature:c,to:s,index:r,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 Cr({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 r=null==t?1:t,n=null==e?0:e;let i=__privateGet(this,Zt),s=-1,a=-1===i;const o=()=>__async(this,null,(function*(){if(a)return null;const{blockNumber:t,nonce:e}=yield Cr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(a)return null;const n=yield this.getTransaction();if(!n||null==n.blockNumber)for(-1===s&&(s=i-3,s<__privateGet(this,Zt)&&(s=__privateGet(this,Zt)));s<=t;){if(a)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 n=0;n<e.length;n++){const s=yield e.getTransaction(n);if(s.from===this.from&&s.nonce===this.nonce){if(a)return null;const e=yield this.provider.getTransactionReceipt(s.hash);if(null==e)return;if(t-e.blockNumber+1<r)return;let n="replaced";s.data===this.data&&s.to===this.to&&s.value===this.value?n="repriced":"0x"===s.data&&s.from===s.to&&s.value===mu&&(n="cancelled"),Ir(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:s.replaceableTransaction(i),hash:s.hash,receipt:e})}}s++}})),l=t=>{if(null==t||0!==t.status)return t;Ir(!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===r)return l(c);if(c){if(1===r||(yield c.confirmations())>=r)return l(c)}else if(yield o(),0===r)return null;const u=new Promise(((t,e)=>{const s=[],c=()=>{s.forEach((t=>t()))};if(s.push((()=>{a=!0})),n>0){const t=setTimeout((()=>{c(),e(Br("wait for transaction timeout","TIMEOUT"))}),n);s.push((()=>{clearTimeout(t)}))}const u=n=>__async(this,null,(function*(){if((yield n.confirmations())>=r){c();try{t(l(n))}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 o()}catch(r){if(Mr(r,"TRANSACTION_REPLACED"))return c(),void e(r)}a||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 Ir(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Su(this)}reorderedEvent(t){return Ir(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Ir(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ku(this,t)}replaceableTransaction(e){Or(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const r=new t(this,this.provider);return __privateSet(r,Zt,e),r}};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,r){super(t,t.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");Tr(this,{args:e.decodeEventLog(r,t.data,t.topics),fragment:r,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Pu extends Au{constructor(t,e){super(t,t.provider),__publicField(this,"error"),Tr(this,{error:e})}}class Cu extends Eu{constructor(t,e,r){super(r,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(r){return new Pu(t,r)}return t}))}}Xt=new WeakMap;$t=new WeakMap;let Tu=class t extends xu{constructor(t,e,r){super(r,e),__privateAdd(this,$t,void 0),__privateSet(this,$t,t)}wait(e,r){return __async(this,null,(function*(){const n=yield __superGet(t.prototype,this,"wait").call(this,e,r);return null==n?null:new Cu(__privateGet(this,$t),this.provider,n)}))}};class Ru extends gn{constructor(t,e,r,n){super(t,e,r),__publicField(this,"log"),Tr(this,{log:n})}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 Mu extends Ru{constructor(t,e,r,n,i){super(t,e,r,new Nu(i,t.interface,n));Tr(this,{args:t.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Gu=BigInt(0);function Bu(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 Fu(t){return t&&"function"==typeof t.sendTransaction}function Uu(t){if(null!=t){if(Ou(t))return t;if(t.provider)return t.provider}}class Lu{constructor(t,e,r){if(__privateAdd(this,te,void 0),__publicField(this,"fragment"),Tr(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const n=Du(t.runner,"resolveName"),i=Ou(n)?n:null;__privateSet(this,te,function(){return __async(this,null,(function*(){const n=yield Promise.all(e.inputs.map(((t,e)=>null==r[e]?null:t.walkAsync(r[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>qa(t,i)))):qa(e,i):e)))));return t.interface.encodeFilterTopics(e,n)}))}())}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 r=to.dereference(t,"overrides");Or("object"==typeof r,"invalid overrides parameter","overrides",t);const n=wu(r);return Or(null==n.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),Or(null==n.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}))}function Wu(t){const e=function(e){return __async(this,null,(function*(){const r=yield Hu(e,["data"]);r.to=yield t.getAddress(),r.from&&(r.from=yield qa(r.from,Uu(t.runner)));const n=t.interface,i=sn(r.value||Gu,"overrides.value")===Gu,s="0x"===(r.data||"0x");!n.fallback||n.fallback.payable||!n.receive||s||i||Or(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data);return Or(n.receive||n.fallback&&n.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",r.value),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data),r}))},r=function(r){return __async(this,null,(function*(){const n=t.runner;Ir(Fu(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield n.sendTransaction(yield e(r)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},n=t=>__async(this,null,(function*(){return yield r(t)}));return Tr(n,{_contract:t,estimateGas:function(r){return __async(this,null,(function*(){const n=Du(t.runner,"estimateGas");return Ir(Iu(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield e(r))}))},populateTransaction:e,send:r,staticCall:function(r){return __async(this,null,(function*(){const n=Du(t.runner,"call");Ir(Bu(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield e(r);try{return yield n.call(i)}catch(s){if(Gr(s)&&s.data)throw t.interface.makeError(s.data,i);throw s}}))}}),n}function Qu(t,e){const r=function(...r){const n=t.interface.getFunction(e,r);return Ir(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return __async(this,null,(function*(){const n=r(...e);let i={};if(n.inputs.length+1===e.length&&(i=yield Hu(e.pop()),i.from&&(i.from=yield qa(i.from,Uu(t.runner)))),n.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const s=yield function(t,e,r){return __async(this,null,(function*(){const n=Du(t,"resolveName"),i=Ou(n)?n:null;return yield Promise.all(e.map(((t,e)=>t.walkAsync(r[e],((t,e)=>(e=to.dereference(e,t),"address"===t?qa(e,i):e))))))}))}(t.runner,n.inputs,e);return Object.assign({},i,yield Cr({to:t.getAddress(),data:t.interface.encodeFunctionData(n,s)}))}))},i=function(...t){return __async(this,null,(function*(){const e=yield a(...t);return 1===e.length?e[0]:e}))},s=function(...e){return __async(this,null,(function*(){const r=t.runner;Ir(Fu(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield r.sendTransaction(yield n(...e)),s=ju(t.runner);return new Tu(t.interface,s,i)}))},a=function(...e){return __async(this,null,(function*(){const i=Du(t.runner,"call");Ir(Bu(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield n(...e);let a="0x";try{a=yield i.call(s)}catch(l){if(Gr(l)&&l.data)throw t.interface.makeError(l.data,s);throw l}const o=r(...e);return t.interface.decodeFunctionResult(o,a)}))},o=(...t)=>__async(this,null,(function*(){return r(...t).constant?yield i(...t):yield s(...t)}));return Tr(o,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:r,estimateGas:function(...e){return __async(this,null,(function*(){const r=Du(t.runner,"estimateGas");return Ir(Iu(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield n(...e))}))},populateTransaction:n,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(o,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getFunction(e);return Ir(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),o}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 r,n=null;if(Array.isArray(e)){const n=function(e){if(Wr(e,32))return e;const r=t.interface.getEvent(e);return Or(r,"unknown fragment","name",e),r.topicHash};r=e.map((t=>null==t?null:Array.isArray(t)?t.map(n):n(t)))}else"*"===e?r=[null]:"string"==typeof e?Wr(e,32)?r=[e]:(n=t.interface.getEvent(e),Or(n,"unknown fragment","event",e),r=[n.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?r=yield e.getTopicFilter():"fragment"in e?(n=e.fragment,r=[n.topicHash]):Or(!1,"unknown event name","event",e);var i;r=r.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:n,tag:r.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:r}}))}function qu(t,e){return __async(this,null,(function*(){const{subs:r}=Ku(t);return r.get((yield Ju(t,e)).tag)||null}))}function Yu(t,e,r){return __async(this,null,(function*(){const n=ju(t.runner);Ir(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:a}=yield Ju(t,r),{addr:o,subs:l}=Ku(t);let c=l.get(s);if(!c){const e={address:o||t,topics:a},u=e=>{let n=i;if(null==n)try{n=t.interface.getEvent(e.topics[0])}catch(s){}if(n){const s=n,a=i?t.interface.decodeEventLog(i,e.data,e.topics):[];Xu(t,r,a,(n=>new Mu(t,n,r,s,e)))}else Xu(t,r,[],(n=>new Ru(t,n,r,e)))};let h=[];c={tag:s,listeners:[],start:()=>{h.length||h.push(n.on(e,u))},stop:()=>__async(this,null,(function*(){if(0==h.length)return;let t=h;h=[],yield Promise.all(t),n.off(e,u)}))},l.set(s,c)}return c}))}let Zu=Promise.resolve();function Xu(t,e,r,n){return __async(this,null,(function*(){try{yield Zu}catch(s){}const i=function(t,e,r,n){return __async(this,null,(function*(){yield Zu;const i=yield qu(t,e);if(!i)return!1;const a=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const a=Array.from(r);n&&a.push(n(i?null:e));try{e.call(t,...a)}catch(s){}return!i})),0===i.listeners.length&&(i.stop(),Ku(t).subs.delete(i.tag)),a>0}))}(t,e,r,n);return Zu=i,yield i}))}const $u=["then"];ee=zu;let th=class t{constructor(t,e,r,n){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),Or("string"==typeof t||Ka(t),"invalid value for Contract target","target",t),null==r&&(r=null);const i=gu.from(e);let s;Tr(this,{target:t,runner:r,interface:i}),Object.defineProperty(this,zu,{value:{}});let a=null,o=null;if(n){const t=ju(r);o=new Tu(this.interface,t,n)}let l=new Map;if("string"==typeof t)if(Wr(t))a=t,s=Promise.resolve(t);else{const e=Du(r,"resolveName");if(!Ou(e))throw Br("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw Br("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:a,deployTx:o,subs:l},Vu.set(c[zu],u);return Tr(this,{filters:new Proxy({},{get:(t,e,r)=>{if("symbol"==typeof e||$u.indexOf(e)>=0)return Reflect.get(t,e,r);try{return this.getEvent(e)}catch(n){if(!Mr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(t,e)=>$u.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))})}),Tr(this,{fallback:i.receive||i.fallback?Wu(this):null}),new Proxy(this,{get:(t,e,r)=>{if("symbol"==typeof e||e in t||$u.indexOf(e)>=0)return Reflect.get(t,e,r);try{return t.getFunction(e)}catch(n){if(!Mr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},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);Ir(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 Ir(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,r)=>{const n=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return t(this);e.once("block",n)}catch(i){r(i)}}));n()}))}))}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 r=function(...r){const n=t.interface.getEvent(e,r);return Ir(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return new Lu(t,r(...e),e)};return Tr(n,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getEvent(e);return Ir(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),n}(this,t)}queryTransaction(t){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(t,e,r){return __async(this,null,(function*(){null==e&&(e=0),null==r&&(r="latest");const{addr:n,addrPromise:i}=Ku(this),s=n||(yield i),{fragment:a,topics:o}=yield Ju(this,t),l={address:s,topics:o,fromBlock:e,toBlock:r},c=ju(this.runner);return Ir(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((t=>{let e=a;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(r){}if(e)try{return new Nu(t,this.interface,e)}catch(r){return new Pu(t,r)}return new Au(t,c)}))}))}on(t,e){return __async(this,null,(function*(){const r=yield Yu(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}))}once(t,e){return __async(this,null,(function*(){const r=yield Yu(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.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 r=0;for(const{listeners:t}of e.values())r+=t.length;return r}))}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 r=[];for(const{listeners:t}of e.values())r=r.concat(t.map((({listener:t})=>t)));return r}))}off(t,e){return __async(this,null,(function*(){const r=yield qu(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return null!=e&&0!==r.listeners.length||(r.stop(),Ku(this).subs.delete(r.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:r}of t.values())r(),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,r=null){super(t,e,r)}}}static from(t,e,r){null==r&&(r=null);return new this(t,e,r)}};class eh extends(function(){return th}()){}function rh(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):Or(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class nh{constructor(t){__publicField(this,"name"),Tr(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")],ah=class t{constructor(t,e,r){__privateAdd(this,ie),__publicField(this,"provider"),__publicField(this,"address"),__publicField(this,"name"),__privateAdd(this,re,void 0),__privateAdd(this,ne,void 0),Tr(this,{provider:t,address:e,name:r}),__privateSet(this,re,null),__privateSet(this,ne,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,re)&&__privateSet(this,re,(()=>__async(this,null,(function*(){try{return yield __privateGet(this,ne).supportsInterface("0x9061b923")}catch(t){if(Mr(t,"CALL_EXCEPTION"))return!1;throw __privateSet(this,re,null),t}})))()),yield __privateGet(this,re)}))}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===Pa?null:t}catch(i){if(Mr(i,"CALL_EXCEPTION"))return null;throw i}if(t>=0&&t<2147483648){let e=t+2147483648;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[e]);if(Wr(r,20))return Va(r)}let e=null;for(const s of this.provider.plugins)if(s instanceof nh&&s.supportsCoinType(t)){e=s;break}if(null==e)return null;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[t]);if(null==r||"0x"===r)return null;const n=yield e.decodeAddress(t,r);if(null!=n)return n;Ir(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}))}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",r=parseInt(e[4],16);if(e[5].length===2*r)return`${t}://${function(t){const e=jr(t);let r=ln(e),n="";for(;r;)n=pn[Number(r%fn)]+n,r/=fn;for(let i=0;i<e.length&&!e[i];i++)n=pn[0]+n;return n}("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&64===r[1].length)return`bzz://${r[1]}`;Ir(!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 n=yield this.getText("avatar");if(null==n)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:n});for(let i=0;i<sh.length;i++){const s=n.match(sh[i]);if(null==s)continue;const a=s[1].toLowerCase();switch(a){case"https":case"data":return t.push({type:"url",value:n}),{linkage:t,url:n};case"ipfs":{const e=rh(n);return t.push({type:"ipfs",value:n}),t.push({type:"url",value:e}),{linkage:t,url:e}}case"erc721":case"erc1155":{const i="erc721"===a?"tokenURI(uint256)":"uri(uint256)";t.push({type:a,value:n});const o=yield this.getAddress();if(null==o)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const l=(s[2]||"").split("/");if(2!==l.length)return t.push({type:`!${a}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"===a){const e=yield u.ownerOf(c);if(o!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===a){const e=yield u.balanceOf(o,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"===a&&(h=h.replace("{id}",un(c,32).substring(2)),t.push({type:"metadata-url-expanded",value:h})),h.match(/^ipfs:/i)&&(h=rh(h)),t.push({type:"metadata-url",value:h});let d={};const p=yield new Mn(h).send();p.assertOk();try{d=p.bodyJson}catch(e){try{t.push({type:"!metadata",value:p.bodyText})}catch(r){const e=p.body;return e&&t.push({type:"!metadata",value:Vr(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=rh(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(),r=e.getPlugin("org.ethers.plugins.network.Ens");return Ir(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}))}static fromName(e,r){return __async(this,null,(function*(){var n;let i=r;for(;;){if(""===i||"."===i)return null;if("eth"!==r&&"eth"===i)return null;const s=yield __privateMethod(n=t,ae,oe).call(n,e,i);if(null!=s){const n=new t(e,s,r);return i===r||(yield n.supportsWildcard())?n:null}i=i.split(".").slice(1).join(".")}}))}};re=new WeakMap,ne=new WeakMap,ie=new WeakSet,se=function(t,e){return __async(this,null,(function*(){e=(e||[]).slice();const r=__privateGet(this,ne).interface;e.unshift(Jl(this.name));let n=null;(yield this.supportsWildcard())&&(n=r.getFunction(t),Ir(n,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[ql(this.name,255),r.encodeFunctionData(n,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=yield __privateGet(this,ne)[t](...e);return n?r.decodeFunctionResult(n,i)[0]:i}catch(i){if(!Mr(i,"CALL_EXCEPTION"))throw i}return null}))},ae=new WeakSet,oe=function(t,e){return __async(this,null,(function*(){const r=yield ah.getEnsAddress(t);try{const n=new eh(r,["function resolver(bytes32) view returns (address)"],t),i=yield n.resolver(Jl(e),{enableCcipRead:!0});return i===Pa?null:i}catch(n){throw n}return null}))},__privateAdd(ah,ae);let oh=ah;const lh=BigInt(0);function ch(t,e){return function(r){return null==r?e:t(r)}}function uh(t,e){return r=>{if(e&&null==r)return null;if(!Array.isArray(r))throw new Error("not an array");return r.map((e=>t(e)))}}function hh(t,e){return r=>{const n={};for(const s in t){let a=s;if(e&&s in e&&!(a in r))for(const t of e[s])if(t in r){a=t;break}try{const e=t[s](r[a]);void 0!==e&&(n[s]=e)}catch(i){Ir(!1,`invalid value for value.${s} (${i instanceof Error?i.message:"not-an-error"})`,"BAD_DATA",{value:r})}}return n}}function dh(t){return Or(Wr(t,!0),"invalid data","value",t),t}function ph(t){return Or(Wr(t,32),"invalid hash","value",t),t}const fh=hh({address:Va,blockHash:ph,blockNumber:cn,data:dh,index:cn,removed:ch((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}Or(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:uh(ph),transactionHash:ph,transactionIndex:cn},{index:["logIndex"]});const gh=hh({hash:ch(ph),parentHash:ph,parentBeaconBlockRoot:ch(ph,null),number:cn,timestamp:cn,nonce:ch(dh),difficulty:sn,gasLimit:sn,gasUsed:sn,stateRoot:ch(ph,null),receiptsRoot:ch(ph,null),blobGasUsed:ch(sn,null),excessBlobGas:ch(sn,null),miner:ch(Va),prevRandao:ch(ph,null),extraData:dh,baseFeePerGas:ch(sn)},{prevRandao:["mixHash"]});const mh=hh({transactionIndex:cn,blockNumber:cn,transactionHash:ph,address:Va,topics:uh(ph),data:dh,index:cn,blockHash:ph},{index:["logIndex"]});const yh=hh({to:ch(Va,null),from:ch(Va,null),contractAddress:ch(Va,null),index:cn,root:ch(Vr),gasUsed:sn,blobGasUsed:ch(sn,null),logsBloom:ch(dh),blockHash:ph,hash:ph,logs:uh((function(t){return mh(t)})),blockNumber:cn,cumulativeGasUsed:sn,effectiveGasPrice:ch(sn),blobGasPrice:ch(sn,null),status:ch(cn),type:ch(cn,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function _h(t){t.to&&sn(t.to)===lh&&(t.to="0x0000000000000000000000000000000000000000");const e=hh({hash:ph,index:ch(cn,void 0),type:t=>"0x"===t||null==t?0:cn(t),accessList:ch(wo,null),blobVersionedHashes:ch(uh(ph,!0),null),authorizationList:ch(uh((t=>{let e;if(t.signature)e=t.signature;else{let r=t.yParity;"0x1b"===r?r=0:"0x1c"===r&&(r=1),e=Object.assign({},t,{yParity:r})}return{address:Va(t.address),chainId:sn(t.chainId),nonce:sn(t.nonce),signature:La.from(e)}}),!1),null),blockHash:ch(ph,null),blockNumber:ch(cn,null),transactionIndex:ch(cn,null),from:Va,gasPrice:ch(sn),maxPriorityFeePerGas:ch(sn),maxFeePerGas:ch(sn),maxFeePerBlobGas:ch(sn,null),gasLimit:sn,to:ch(Va,null),value:sn,nonce:cn,data:dh,creates:ch(Va,null),chainId:ch(sn,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=Va(t.from);let r=sn(t.nonce,"tx.nonce").toString(16);return r="0"===r?"0x":r.length%2?"0x0"+r:"0x"+r,Va(qr(ws(ei([e,r])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=La.from(t.signature):e.signature=La.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&sn(e.blockHash)===lh&&(e.blockHash=null),e}class vh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}clone(){return new vh(this.name)}}class wh extends vh{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 r={effectiveBlock:t};function n(t,n){let i=(e||{})[t];null==i&&(i=n),Or("number"==typeof i,`invalud value for ${t}`,"costs",e),r[t]=i}n("txBase",21e3),n("txCreate",32e3),n("txDataZero",4),n("txDataNonzero",16),n("txAccessListStorageKey",1900),n("txAccessListAddress",2400),Tr(this,r)}clone(){return new wh(this.effectiveBlock,this)}}class bh extends vh{constructor(t,e){super("org.ethers.plugins.network.Ens"),__publicField(this,"address"),__publicField(this,"targetNetwork"),Tr(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new bh(this.address,this.targetNetwork)}}class Ah extends vh{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,sn(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,sn(t,"chainId"))}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===sn(t)}catch(e){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===sn(t)}catch(e){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===sn(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 wh;let r=e.txBase;if(null==t.to&&(r+=e.txCreate),t.data)for(let n=2;n<t.data.length;n+=2)"00"===t.data.substring(n,n+2)?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const n=wo(t.accessList);for(const t in n)r+=e.txAccessListAddress+e.txAccessListStorageKey*n[t].storageKeys.length}return r}static from(e){if(function(){if(Nh)return;function t(t,e,r){const n=function(){const n=new xh(t,e);return null!=r.ensNetwork&&n.attachPlugin(new bh(null,r.ensNetwork)),n.attachPlugin(new wh),(r.plugins||[]).forEach((t=>{n.attachPlugin(t)})),n};xh.register(t,n),xh.register(e,n),r.altNames&&r.altNames.forEach((t=>{xh.register(t,n)}))}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 r=Eh.get(e);if(r)return r();if("bigint"==typeof e)return new t("unknown",e);Or(!1,"unknown network","network",e)}if("function"==typeof e.clone){return e.clone()}if("object"==typeof e){Or("string"==typeof e.name&&"number"==typeof e.chainId,"invalid network object name or chainId","network",e);const r=new t(e.name,e.chainId);return(e.ensAddress||null!=e.ensNetwork)&&r.attachPlugin(new bh(e.ensAddress,e.ensNetwork)),r}Or(!1,"invalid network","network",e)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const r=Eh.get(t);r&&Or(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Eh.set(t,e)}};function kh(t,e){const r=String(t);if(!r.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const n=r.split(".");if(1===n.length&&n.push(""),2!==n.length)throw new Error(`invalid gwei value: ${t}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let t=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||t++,n[1]=t.toString()}return BigInt(n[0]+n[1])}function Sh(t){return new Ah(t,((t,e,r)=>__async(this,null,(function*(){let e;r.setHeader("User-Agent","ethers");try{const[n,i]=yield Promise.all([r.send(),t()]);e=n;const s=e.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:kh(s.maxFee,9),maxPriorityFeePerGas:kh(s.maxPriorityFee,9)}}catch(n){Ir(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:e,error:n})}}))))}let Nh=!1;function Ph(t){return JSON.parse(JSON.stringify(t))}class Ch{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,ve,void 0),__privateAdd(this,we,void 0),__privateAdd(this,be,void 0),__privateSet(this,ve,t),__privateSet(this,be,!1),__privateSet(this,we,(t=>{this._poll(t,__privateGet(this,ve))}))}_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,we).call(this,-2),__privateGet(this,ve).on("block",__privateGet(this,we)))}stop(){__privateGet(this,be)&&(__privateSet(this,be,!1),__privateGet(this,ve).off("block",__privateGet(this,we)))}pause(t){this.stop()}resume(){this.start()}}ve=new WeakMap,we=new WeakMap,be=new WeakMap;class Rh 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 Mh extends Th{constructor(t,e){super(t),__privateAdd(this,xe,void 0),__privateSet(this,xe,Ph(e))}_poll(t,e){return __async(this,null,(function*(){throw new Error("@TODO")}))}}xe=new WeakMap;class Gh 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 Bh{constructor(t,e){__privateAdd(this,Re),__privateAdd(this,Se,void 0),__privateAdd(this,Ne,void 0),__privateAdd(this,Pe,void 0),__privateAdd(this,Ce,void 0),__privateAdd(this,Te,void 0),__privateSet(this,Se,t),__privateSet(this,Ne,Ph(e)),__privateSet(this,Pe,__privateMethod(this,Re,Me).bind(this)),__privateSet(this,Ce,!1),__privateSet(this,Te,-2)}start(){__privateGet(this,Ce)||(__privateSet(this,Ce,!0),-2===__privateGet(this,Te)&&__privateGet(this,Se).getBlockNumber().then((t=>{__privateSet(this,Te,t)})),__privateGet(this,Se).on("block",__privateGet(this,Pe)))}stop(){__privateGet(this,Ce)&&(__privateSet(this,Ce,!1),__privateGet(this,Se).off("block",__privateGet(this,Pe)))}pause(t){this.stop(),t&&__privateSet(this,Te,-2)}resume(){this.start()}}Se=new WeakMap,Ne=new WeakMap,Pe=new WeakMap,Ce=new WeakMap,Te=new WeakMap,Re=new WeakSet,Me=function(t){return __async(this,null,(function*(){if(-2===__privateGet(this,Te))return;const e=Ph(__privateGet(this,Ne));e.fromBlock=__privateGet(this,Te)+1,e.toBlock=t;const r=yield __privateGet(this,Se).getLogs(e);if(0!==r.length)for(const t of r)__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 Fh(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,r)=>(t[r]=e[r],t)),{})}return e}))}class Uh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function Lh(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(Wr(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:Fh("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:Fh("orphan",e),filter:(r=e,JSON.parse(JSON.stringify(r)))}}var r;if(t.address||t.topics){const r=t,n={topics:(r.topics||[]).map((t=>null==t?null:Array.isArray(t)?Lh(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(r.address){const t=[],i=[],s=r=>{Wr(r)?t.push(r):i.push((()=>__async(this,null,(function*(){t.push(yield qa(r,e))})))())};Array.isArray(r.address)?r.address.forEach(s):s(r.address),i.length&&(yield Promise.all(i)),n.address=Lh(t.map((t=>t.toLowerCase())))}return{filter:n,tag:Fh("event",n),type:"event"}}Or(!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,Ze),__privateAdd(this,$e),__privateAdd(this,er),__privateAdd(this,nr),__privateAdd(this,Ge,void 0),__privateAdd(this,Be,void 0),__privateAdd(this,Ie,void 0),__privateAdd(this,Oe,void 0),__privateAdd(this,Fe,void 0),__privateAdd(this,Ue,void 0),__privateAdd(this,Le,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,Ue,!0),__privateSet(this,Fe,null);else if(t){const e=xh.from(t);__privateSet(this,Ue,!1),__privateSet(this,Fe,Promise.resolve(e)),setTimeout((()=>{this.emit("network",e,null)}),0)}else __privateSet(this,Ue,!1),__privateSet(this,Fe,null);__privateSet(this,De,-1),__privateSet(this,Le,new Map),__privateSet(this,Ge,new Map),__privateSet(this,Be,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,Be).values())}attachPlugin(t){if(__privateGet(this,Be).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,Be).set(t.name,t.connect(this)),this}getPlugin(t){return __privateGet(this,Be).get(t)||null}get disableCcipRead(){return __privateGet(this,We)}set disableCcipRead(t){__privateSet(this,We,!!t)}ccipReadFetch(t,e,r){return __async(this,null,(function*(){if(this.disableCcipRead||0===r.length||null==t.to)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),s=[];for(let e=0;e<r.length;e++){const o=r[e],l=o.replace("{sender}",n).replace("{data}",i),c=new Mn(l);-1===o.indexOf("{data}")&&(c.body={data:i,sender:n}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:c,index:e,urls:r});let u,h="unknown error";try{u=yield c.send()}catch(a){s.push(a.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:{error:a}});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(a){}Ir(u.statusCode<400||u.statusCode>=500,`response not found during CCIP fetch: ${h}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:o,errorMessage:h}}),s.push(h)}Ir(!1,`error encountered during CCIP fetch: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,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(){Ir(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}_perform(t){return __async(this,null,(function*(){Ir(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}))}getBlockNumber(){return __async(this,null,(function*(){const t=cn(yield __privateMethod(this,ze,Ve).call(this,{method:"getBlockNumber"}),"%response");return __privateGet(this,De)>=0&&__privateSet(this,De,t),t}))}_getAddress(t){return qa(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 Wr(t)?Wr(t,32)?t:dn(t):("bigint"==typeof t&&(t=cn(t,"blockTag")),"number"==typeof t?t>=0?dn(t):__privateGet(this,De)>=0?dn(__privateGet(this,De)+t):this.getBlockNumber().then((e=>dn(e+t))):void Or(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?Lh(t.map((t=>t.toLowerCase()))):t.toLowerCase())),r="blockHash"in t?t.blockHash:void 0,n=(t,n,i)=>{let s;switch(t.length){case 0:break;case 1:s=t[0];break;default:t.sort(),s=t}if(r&&(null!=n||null!=i))throw new Error("invalid filter");const a={};return s&&(a.address=s),e.length&&(a.topics=e),n&&(a.fromBlock=n),i&&(a.toBlock=i),r&&(a.blockHash=r),a};let i,s,a=[];if(t.address)if(Array.isArray(t.address))for(const o of t.address)a.push(this._getAddress(o));else a.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(s=this._getBlockTag(t.toBlock)),a.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=s&&"string"!=typeof s?Promise.all([Promise.all(a),i,s]).then((t=>n(t[0],t[1],t[2]))):n(a,i,s)}_getTransactionRequest(t){const e=wu(t),r=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=qa(e[t],this);Oh(n)?r.push(function(){return __async(this,null,(function*(){e[t]=yield n}))}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);Oh(t)?r.push(function(){return __async(this,null,(function*(){e.blockTag=yield t}))}()):e.blockTag=t}return r.length?function(){return __async(this,null,(function*(){return yield Promise.all(r),e}))}():e}getNetwork(){return __async(this,null,(function*(){if(null==__privateGet(this,Fe)){const t=(()=>__async(this,null,(function*(){try{const t=yield this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw __privateGet(this,Fe)===t&&__privateSet(this,Fe,null),e}})))();return __privateSet(this,Fe,t),(yield t).clone()}const t=__privateGet(this,Fe),[e,r]=yield Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(__privateGet(this,Ue)?(this.emit("network",r,e),__privateGet(this,Fe)===t&&__privateSet(this,Fe,Promise.resolve(r))):Ir(!1,`network changed: ${e.chainId} => ${r.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:r,priorityFee:n}=yield Cr({_block:__privateMethod(this,$e,tr).call(this,"latest",!1),gasPrice:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getGasPrice"}),"%response")}catch(t){}return null})))(),priorityFee:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getPriorityFee"}),"%response")}catch(t){}return null})))()});let i=null,s=null;const a=this._wrapBlock(e,t);return a&&a.baseFeePerGas&&(s=null!=n?n:BigInt("1000000000"),i=a.baseFeePerGas*Ih+s),new vu(r,i,s)})),r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Mn(r.url),n=yield r.processFunc(e,this,t);return new vu(n.gasPrice,n.maxFeePerGas,n.maxPriorityFeePerGas)}return yield e()}))}estimateGas(t){return __async(this,null,(function*(){let e=this._getTransactionRequest(t);return Oh(e)&&(e=yield e),sn(yield __privateMethod(this,ze,Ve).call(this,{method:"estimateGas",transaction:e}),"%response")}))}call(t){return __async(this,null,(function*(){const{tx:e,blockTag:r}=yield Cr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return yield __privateMethod(this,qe,Ye).call(this,__privateMethod(this,Ke,Je).call(this,e,r,t.enableCcipRead?0:-1))}))}getBalance(t,e){return __async(this,null,(function*(){return sn(yield __privateMethod(this,Ze,Xe).call(this,{method:"getBalance"},t,e),"%response")}))}getTransactionCount(t,e){return __async(this,null,(function*(){return cn(yield __privateMethod(this,Ze,Xe).call(this,{method:"getTransactionCount"},t,e),"%response")}))}getCode(t,e){return __async(this,null,(function*(){return Vr(yield __privateMethod(this,Ze,Xe).call(this,{method:"getCode"},t,e))}))}getStorage(t,e,r){return __async(this,null,(function*(){const n=sn(e,"position");return Vr(yield __privateMethod(this,Ze,Xe).call(this,{method:"getStorage",position:n},t,r))}))}broadcastTransaction(t){return __async(this,null,(function*(){const{blockNumber:e,hash:r,network:n}=yield Cr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=Do.from(t);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,n).replaceableTransaction(e)}))}getBlock(t,e){return __async(this,null,(function*(){const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,$e,tr).call(this,t,!!e)});return null==n?null:this._wrapBlock(n,r)}))}getTransaction(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t})});return null==r?null:this._wrapTransactionResponse(r,e)}))}getTransactionReceipt(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionReceipt",hash:t})});if(null==r)return null;if(null==r.gasPrice&&null==r.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");r.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(r,e)}))}getTransactionResult(t){return __async(this,null,(function*(){const{result:e}=yield Cr({network:this.getNetwork(),result:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionResult",hash:t})});return null==e?null:Vr(e)}))}getLogs(t){return __async(this,null,(function*(){let e=this._getFilter(t);Oh(e)&&(e=yield e);const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getLogs",filter:e})});return n.map((t=>this._wrapLog(t,r)))}))}_getProvider(t){Ir(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}getResolver(t){return __async(this,null,(function*(){return yield oh.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=Va(t)).substring(2).toLowerCase()+".addr.reverse");try{const r=yield oh.getEnsAddress(this),n=new eh(r,["function resolver(bytes32) view returns (address)"],this),i=yield n.resolver(e);if(null==i||i===Pa)return null;const s=new eh(i,["function name(bytes32) view returns (string)"],this),a=yield s.name(e);return(yield this.resolveName(a))!==t?null:a}catch(r){if(Mr(r,"BAD_DATA")&&"0x"===r.value)return null;if(Mr(r,"CALL_EXCEPTION"))return null;throw r}return null}))}waitForTransaction(t,e,r){return __async(this,null,(function*(){const n=null!=e?e:1;return 0===n?this.getTransactionReceipt(t):new Promise(((e,i)=>__async(this,null,(function*(){let s=null;const a=r=>__async(this,null,(function*(){try{const i=yield this.getTransactionReceipt(t);if(null!=i&&r-i.blockNumber+1>=n)return e(i),void(s&&(clearTimeout(s),s=null))}catch(i){console.log("EEE",i)}this.once("block",a)}));null!=r&&(s=setTimeout((()=>{null!=s&&(s=null,this.off("block",a),i(Br("timeout","TIMEOUT",{reason:"timeout"})))}),r)),a(yield this.getBlockNumber())}))))}))}waitForBlock(t){return __async(this,null,(function*(){Ir(!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 r=__privateWrapper(this,je)._++,n=()=>{__privateGet(this,He).delete(r),t()};if(this.paused)__privateGet(this,He).set(r,{timer:null,func:n,time:e});else{const t=setTimeout(n,e);__privateGet(this,He).set(r,{timer:t,func:n,time:jh()})}return r}_forEachSubscriber(t){for(const e of __privateGet(this,Ge).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Uh(t.type);case"block":{const t=new Ch(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Rh(this,t.type);case"event":return new Bh(this,t.filter);case"transaction":return new Gh(this,t.hash);case"orphan":return new Mh(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of __privateGet(this,Ge).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=__privateGet(this,Ie)&&e.pause(__privateGet(this,Ie));break}}on(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Ie)&&r.subscriber.pause(__privateGet(this,Ie))),this}))}once(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Ie)&&r.subscriber.pause(__privateGet(this,Ie))),this}))}emit(t,...e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t,e);if(!r||0===r.listeners.length)return!1;const n=r.listeners.length;return r.listeners=r.listeners.filter((({listener:r,once:n})=>{const i=new gn(this,n?null:r,t);try{r.call(this,...e,i)}catch(s){}return!n})),0===r.listeners.length&&(r.started&&r.subscriber.stop(),__privateGet(this,Ge).delete(r.tag)),n>0}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of __privateGet(this,Ge).values())e+=t.length;return e}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of __privateGet(this,Ge).values())e=e.concat(t.map((({listener:t})=>t)));return e}))}off(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return e&&0!==r.listeners.length||(r.started&&r.subscriber.stop(),__privateGet(this,Ge).delete(r.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const{tag:e,started:r,subscriber:n}=yield __privateMethod(this,nr,ir).call(this,t);r&&n.stop(),__privateGet(this,Ge).delete(e)}else for(const[t,{started:e,subscriber:r}]of __privateGet(this,Ge))e&&r.stop(),__privateGet(this,Ge).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;Ir(!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 r=zh(t,e);if(r)return vn(r)}catch(r){}return null}function zh(t,e){if("0x"===t)return null;try{const r=cn(qr(t,e,e+32)),n=cn(qr(t,r,r+32));return qr(t,r+32,r+32+n)}catch(r){}return null}function Vh(t){const e=hn(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}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}Ge=new WeakMap,Be=new WeakMap,Ie=new WeakMap,Oe=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,Le=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 r=Fh(t.method,t);let n=__privateGet(this,Le).get(r);return n||(n=this._perform(t),__privateGet(this,Le).set(r,n),setTimeout((()=>{__privateGet(this,Le).get(r)===n&&__privateGet(this,Le).delete(r)}),e)),yield n}))},Ke=new WeakSet,Je=function(t,e,r){return __async(this,null,(function*(){Ir(r<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=wu(t);try{return Vr(yield this._perform({method:"call",transaction:n,blockTag:e}))}catch(i){if(!this.disableCcipRead&&Gr(i)&&i.data&&r>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===qr(i.data,0,4)){const t=i.data,a=yield qa(n.to,this);let o;try{o=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};Ir(Jr(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=qr(t,0,32);Ir(qr(r,0,12)===qr(Yh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=qr(r,12);try{const r=[],n=cn(qr(t,32,64)),i=cn(qr(t,n,n+32)),s=qr(t,n+32);for(let t=0;t<i;t++){const e=Qh(s,32*t);if(null==e)throw new Error("abort");r.push(e)}e.urls=r}catch(i){Ir(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=zh(t,64);if(null==r)throw new Error("abort");e.calldata=r}catch(i){Ir(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}Ir(qr(t,100,128)===qr(Yh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=qr(t,96,100);try{const r=zh(t,128);if(null==r)throw new Error("abort");e.extraData=r}catch(i){Ir(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(qr(i.data,4))}catch(s){Ir(!1,s.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:t}})}Ir(o.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:t,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:o.errorArgs}});const l=yield this.ccipReadFetch(n,o.calldata,o.urls);Ir(null!=l,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:i.data,errorArgs:o.errorArgs}});const c={to:a,data:Kr([o.selector,qh([l,o.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=yield __privateMethod(this,Ke,Je).call(this,c,e,r+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,Ye=function(t){return __async(this,null,(function*(){const{value:e}=yield Cr({network:this.getNetwork(),value:t});return e}))},Ze=new WeakSet,Xe=function(t,e,r){return __async(this,null,(function*(){let n=this._getAddress(e),i=this._getBlockTag(r);return"string"==typeof n&&"string"==typeof i||([n,i]=yield Promise.all([n,i])),yield __privateMethod(this,qe,Ye).call(this,__privateMethod(this,ze,Ve).call(this,Object.assign(t,{address:n,blockTag:i})))}))},$e=new WeakSet,tr=function(t,e){return __async(this,null,(function*(){if(Wr(t,32))return yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return"string"!=typeof r&&(r=yield r),yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})}))},er=new WeakSet,rr=function(t,e){return __async(this,null,(function*(){let r=yield Dh(t,this);return"event"===r.type&&e&&e.length>0&&!0===e[0].removed&&(r=yield Dh({orphan:"drop-log",log:e[0]},this)),__privateGet(this,Ge).get(r.tag)||null}))},nr=new WeakSet,ir=function(t){return __async(this,null,(function*(){const e=yield Dh(t,this),r=e.tag;let n=__privateGet(this,Ge).get(r);if(!n){n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},__privateGet(this,Ge).set(r,n)}return n}))};const Jh=new Uint8Array([]);function qh(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(Jh),r+=32;for(let n=0;n<t.length;n++){const i=jr(t[n]);e[n]=Vh(r),e.push(Vh(i.length)),e.push(Kh(i)),r+=32+32*Math.ceil(i.length/32)}return Kr(e)}const Yh="0x0000000000000000000000000000000000000000000000000000000000000000";function Zh(t,e){if(t.provider)return t.provider;Ir(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}function Xh(t,e){return __async(this,null,(function*(){let r=wu(e);if(null!=r.to&&(r.to=qa(r.to,t)),null!=r.from){const e=r.from;r.from=Promise.all([t.getAddress(),qa(e,t)]).then((([t,e])=>(Or(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else r.from=t.getAddress();return yield Cr(r)}))}class $h{constructor(t){__publicField(this,"provider"),Tr(this,{provider:t||null})}getNonce(t){return __async(this,null,(function*(){return Zh(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=Zh(this,"populateTransaction"),r=yield Xh(this,t);null==r.nonce&&(r.nonce=yield this.getNonce("pending")),null==r.gasLimit&&(r.gasLimit=yield this.estimateGas(r));const n=yield this.provider.getNetwork();if(null!=r.chainId){Or(sn(r.chainId)===n.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=n.chainId;const i=null!=r.maxFeePerGas||null!=r.maxPriorityFeePerGas;if(null==r.gasPrice||2!==r.type&&!i?0!==r.type&&1!==r.type||!i||Or(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):Or(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==r.type&&null!=r.type||null==r.maxFeePerGas||null==r.maxPriorityFeePerGas)if(0===r.type||1===r.type){const t=yield e.getFeeData();Ir(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice)}else{const t=yield e.getFeeData();if(null==r.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(r.authorizationList&&r.authorizationList.length?r.type=4:r.type=2,null!=r.gasPrice){const t=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=t,r.maxPriorityFeePerGas=t}else null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(Ir(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):Ir(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==r.type&&3!==r.type&&4!==r.type||(null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else r.type=2;return yield Cr(r)}))}populateAuthorization(t){return __async(this,null,(function*(){const e=Object.assign({},t);return null==e.chainId&&(e.chainId=(yield Zh(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=yield this.getNonce()),e}))}estimateGas(t){return __async(this,null,(function*(){return Zh(this,"estimateGas").estimateGas(yield this.populateCall(t))}))}call(t){return __async(this,null,(function*(){return Zh(this,"call").call(yield this.populateCall(t))}))}resolveName(t){return __async(this,null,(function*(){const e=Zh(this,"resolveName");return yield e.resolveName(t)}))}sendTransaction(t){return __async(this,null,(function*(){const e=Zh(this,"sendTransaction"),r=yield this.populateTransaction(t);delete r.from;const n=Do.from(r);return yield e.broadcastTransaction(yield this.signTransaction(n))}))}authorize(t){Ir(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class td{constructor(t){__privateAdd(this,hr),__privateAdd(this,pr),__privateAdd(this,sr,void 0),__privateAdd(this,ar,void 0),__privateAdd(this,or,void 0),__privateAdd(this,lr,void 0),__privateAdd(this,cr,void 0),__privateAdd(this,ur,void 0),__privateSet(this,sr,t),__privateSet(this,ar,null),__privateSet(this,or,__privateMethod(this,hr,dr).bind(this)),__privateSet(this,lr,!1),__privateSet(this,cr,null),__privateSet(this,ur,!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,lr)||(__privateSet(this,lr,!0),__privateMethod(this,hr,dr).call(this,-2))}stop(){__privateGet(this,lr)&&(__privateSet(this,lr,!1),__privateSet(this,ur,!0),__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or)))}pause(t){t&&__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or))}resume(){this.start()}}sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,cr=new WeakMap,ur=new WeakMap,hr=new WeakSet,dr=function(t){return __async(this,null,(function*(){try{null==__privateGet(this,ar)&&__privateSet(this,ar,this._subscribe(__privateGet(this,sr)));let e=null;try{e=yield __privateGet(this,ar)}catch(t){if(!Mr(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==e)return __privateSet(this,ar,null),void __privateGet(this,sr)._recoverSubscriber(this,this._recover(__privateGet(this,sr)));const r=yield __privateGet(this,sr).getNetwork();if(__privateGet(this,cr)||__privateSet(this,cr,r),__privateGet(this,cr).chainId!==r.chainId)throw new Error("chaid changed");if(__privateGet(this,ur))return;const n=yield __privateGet(this,sr).send("eth_getFilterChanges",[e]);yield this._emitResults(__privateGet(this,sr),n)}catch(t){console.log("@TODO",t)}__privateGet(this,sr).once("block",__privateGet(this,or))}))},pr=new WeakSet,fr=function(){const t=__privateGet(this,ar);t&&(__privateSet(this,ar,null),t.then((t=>{__privateGet(this,sr).destroyed||__privateGet(this,sr).send("eth_uninstallFilter",[t])})))};class ed extends td{constructor(t,e){var r;super(t),__privateAdd(this,gr,void 0),__privateSet(this,gr,(r=e,JSON.parse(JSON.stringify(r))))}_recover(t){return new Bh(t,__privateGet(this,gr))}_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newFilter",[__privateGet(this,gr)])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const r of e)t.emit(__privateGet(this,gr),t._wrapLog(r,t._network))}))}}gr=new WeakMap;class rd 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 r of e)t.emit("pending",r)}))}}const nd="bigint,boolean,function,number,string,symbol".split(/,/g);function id(t){if(null==t||nd.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,r)=>(e[r]=t[r],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function sd(t){return new Promise((e=>{setTimeout(e,t)}))}function ad(t){return t?t.toLowerCase():t}function od(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"),Tr(this,{address:e=Va(e)})}connect(t){Ir(!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),r=[];if(e.from){const n=e.from;r.push((()=>__async(this,null,(function*(){const r=yield qa(n,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r})))())}else e.from=this.address;if(null==e.gasLimit&&r.push((()=>__async(this,null,(function*(){e.gasLimit=yield this.provider.estimateGas(__spreadProps(__spreadValues({},e),{from:this.address}))})))()),null!=e.to){const t=e.to;r.push((()=>__async(this,null,(function*(){e.to=yield qa(t,this.provider)})))())}r.length&&(yield Promise.all(r));const n=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[n])}))}sendTransaction(t){return __async(this,null,(function*(){const e=yield this.provider.getBlockNumber(),r=yield this.sendUncheckedTransaction(t);return yield new Promise(((t,n)=>{const i=[1e3,100];let s=0;const a=()=>__async(this,null,(function*(){try{const n=yield this.provider.getTransaction(r);if(null!=n)return void t(n.replaceableTransaction(e))}catch(o){if(Mr(o,"CANCELLED")||Mr(o,"BAD_DATA")||Mr(o,"NETWORK_ERROR")||Mr(o,"UNSUPPORTED_OPERATION"))return null==o.info&&(o.info={}),o.info.sendTransactionHash=r,void n(o);if(Mr(o,"INVALID_ARGUMENT")&&(s++,null==o.info&&(o.info={}),o.info.sendTransactionHash=r,s>10))return void n(o);this.provider.emit("error",Br("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:o}))}this.provider._setTimeout((()=>{a()}),i.pop()||4e3)}));a()}))}))}signTransaction(t){return __async(this,null,(function*(){const e=id(t);if(e.from){const r=yield qa(e.from,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r}else e.from=this.address;const r=this.provider.getRpcTransaction(e);return yield this.provider.send("eth_signTransaction",[r])}))}signMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?_n(t):t;return yield this.provider.send("personal_sign",[Vr(e),this.address.toLowerCase()])}))}signTypedData(t,e,r){return __async(this,null,(function*(){const n=id(r),i=yield uc.resolveNames(t,e,n,(t=>__async(this,null,(function*(){const e=yield qa(t);return Or(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?_n(t):t;return yield this.provider.send("eth_sign",[this.address.toLowerCase(),Vr(e)])}))}}mr=new WeakMap,yr=new WeakMap,_r=new WeakMap,vr=new WeakMap,wr=new WeakMap,br=new WeakMap,Ar=new WeakMap,Er=new WeakSet,xr=function(){if(__privateGet(this,vr))return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");__privateSet(this,vr,setTimeout((()=>{__privateSet(this,vr,null);const t=__privateGet(this,_r);for(__privateSet(this,_r,[]);t.length;){const e=[t.shift()];for(;t.length&&e.length!==__privateGet(this,mr).batchMaxCount;){e.push(t.shift());if(JSON.stringify(e.map((t=>t.payload))).length>__privateGet(this,mr).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 r=yield this._send(t);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:t,reject:n,payload:i}of e){if(this.destroyed){n(Br("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=r.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?n(this.getRpcError(i,e)):t(e.result);else{const t=Br("missing response for request","BAD_DATA",{value:r,info:{payload:i}});this.emit("error",t),n(t)}}}catch(r){this.emit("debug",{action:"receiveRpcError",error:r});for(const{reject:t}of e)t(r)}}))})()}}),t))};let ud=class t extends Wh{constructor(t,e){super(t,e),__privateAdd(this,Er),__privateAdd(this,mr,void 0),__privateAdd(this,yr,void 0),__privateAdd(this,_r,void 0),__privateAdd(this,vr,void 0),__privateAdd(this,wr,void 0),__privateAdd(this,br,void 0),__privateAdd(this,Ar,void 0),__privateSet(this,yr,1),__privateSet(this,mr,Object.assign({},ld,e||{})),__privateSet(this,_r,[]),__privateSet(this,vr,null),__privateSet(this,br,null),__privateSet(this,Ar,null);{let t=null;const e=new Promise((e=>{t=e}));__privateSet(this,wr,{promise:e,resolve:t})}const r=this._getOption("staticNetwork");"boolean"==typeof r?(Or(!r||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),r&&null!=t&&__privateSet(this,br,xh.from(t))):r&&(Or(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),__privateSet(this,br,r))}_getOption(t){return __privateGet(this,mr)[t]}get _network(){return Ir(__privateGet(this,br),"network is not available yet","NETWORK_ERROR"),__privateGet(this,br)}_perform(e){return __async(this,null,(function*(){if("call"===e.method||"estimateGas"===e.method){let t=e.transaction;if(t&&null!=t.type&&sn(t.type)&&null==t.maxFeePerGas&&null==t.maxPriorityFeePerGas){const r=yield this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}const r=this.getRpcRequest(e);return null!=r?yield this.send(r.method,r.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,br))return __privateGet(this,br)}return __privateGet(this,Ar)?yield __privateGet(this,Ar):this.ready?(__privateSet(this,Ar,(()=>__async(this,null,(function*(){try{const t=xh.from(sn(yield this.send("eth_chainId",[])));return __privateSet(this,Ar,null),t}catch(t){throw __privateSet(this,Ar,null),t}})))()),yield __privateGet(this,Ar)):(__privateSet(this,Ar,(()=>__async(this,null,(function*(){const t={id:__privateWrapper(this,yr)._++,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,Ar,null)}catch(r){throw __privateSet(this,Ar,null),this.emit("debug",{action:"receiveRpcError",error:r}),r}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return xh.from(sn(e.result));throw this.getRpcError(t,e)})))()),yield __privateGet(this,Ar))}))}_start(){null!=__privateGet(this,wr)&&null!=__privateGet(this,wr).resolve&&(__privateGet(this,wr).resolve(),__privateSet(this,wr,null),(()=>{__async(this,null,(function*(){for(;null==__privateGet(this,br)&&!this.destroyed;)try{__privateSet(this,br,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",Br("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),yield sd(1e3)}__privateMethod(this,Er,xr).call(this)}))})())}_waitUntilReady(){return __async(this,null,(function*(){if(null!=__privateGet(this,wr))return yield __privateGet(this,wr).promise}))}_getSubscriber(t){return"pending"===t.type?new rd(this):"event"===t.type?this._getOption("polling")?new Bh(this,t.filter):new ed(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new Uh("orphan"):super._getSubscriber(t)}get ready(){return null==__privateGet(this,wr)}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((r=>{if(null==t[r])return;let n=r;"gasLimit"===r&&(n="gas"),e[n]=dn(sn(t[r],`tx.${r}`))})),["from","to","data"].forEach((r=>{null!=t[r]&&(e[r]=Vr(t[r]))})),t.accessList&&(e.accessList=wo(t.accessList)),t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.map((t=>t.toLowerCase()))),t.authorizationList&&(e.authorizationList=t.authorizationList.map((t=>{const e=bo(t);return{address:e.address,nonce:dn(e.nonce),chainId:dn(e.chainId),yParity:dn(e.signature.yParity),r:dn(e.signature.r),s:dn(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:[ad(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[ad(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[ad(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[ad(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(ad):t.filter.address=ad(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:r}=t,{error:n}=e;if("eth_estimateGas"===r&&n.message){const e=n.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return Br("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}});if(e.match(/nonce/i)&&e.match(/too low/i))return Br("nonce has already been used","NONCE_EXPIRED",{transaction:t.params[0],info:{payload:t,error:n}})}if("eth_call"===r||"eth_estimateGas"===r){const e=dd(n),i=lu.getBuiltinCallException("eth_call"===r?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:n,payload:t},i}const i=JSON.stringify(function(t){const e=[];return pd(t,e),e}(n));if("string"==typeof n.message&&n.message.match(/user denied|ethers-user-denied/i)){return Br("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"}[r]||"unknown",reason:"rejected",info:{payload:t,error:n}})}if("eth_sendRawTransaction"===r||"eth_sendTransaction"===r){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Br("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return Br("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Br("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return Br("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:r,info:{transaction:e,info:{error:n}}})}let s=!!i.match(/the method .* does not exist/i);return s||n&&n.details&&n.details.startsWith("Unauthorized method:")&&(s=!0),s?Br("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):Br("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Br("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const r=__privateWrapper(this,yr)._++,n=new Promise(((n,i)=>{__privateGet(this,_r).push({resolve:n,reject:i,payload:{method:t,params:e,id:r,jsonrpc:"2.0"}})}));return __privateMethod(this,Er,xr).call(this),n}getSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const r=yield e;if(t>=r.length)throw new Error("no such account");return new cd(this,r[t])}const{accounts:r}=yield Cr({network:this.getNetwork(),accounts:e});t=Va(t);for(const n of r)if(Va(n)===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,vr)&&(clearTimeout(__privateGet(this,vr)),__privateSet(this,vr,null));for(const{payload:t,reject:e}of __privateGet(this,_r))e(Br("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));__privateSet(this,_r,[]),super.destroy()}};class hd extends ud{constructor(t,e){super(t,e),__privateAdd(this,kr,void 0);let r=this._getOption("pollingInterval");null==r&&(r=ld.pollingInterval),__privateSet(this,kr,r)}_getSubscriber(t){const e=super._getSubscriber(t);return od(e)&&(e.pollingInterval=__privateGet(this,kr)),e}get pollingInterval(){return __privateGet(this,kr)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");__privateSet(this,kr,t),this._forEachSubscriber((t=>{od(t)&&(t.pollingInterval=__privateGet(this,kr))}))}}function dd(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&Wr(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const r=dd(t[e]);if(r)return r}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 r in t)pd(t[r],e);if("string"==typeof t)try{return pd(JSON.parse(t),e)}catch(r){}}}kr=new WeakMap;Sr=new WeakMap,Nr=new WeakMap;let fd=class t extends hd{constructor(t,e,r){const n=Object.assign({},null!=r?r:{},{batchMaxCount:1});Or(t&&t.request,"invalid EIP-1193 provider","ethereum",t),super(e,n),__privateAdd(this,Sr,void 0),__privateAdd(this,Nr,void 0),__privateSet(this,Nr,null),r&&r.providerInfo&&__privateSet(this,Nr,r.providerInfo),__privateSet(this,Sr,((e,r)=>__async(this,null,(function*(){const n={method:e,params:r};this.emit("debug",{action:"sendEip1193Request",payload:n});try{const e=yield t.request(n);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=n,this.emit("debug",{action:"receiveEip1193Error",error:t}),t}}))))}get providerInfo(){return __privateGet(this,Nr)}send(e,r){return __async(this,null,(function*(){return yield this._start(),yield __superGet(t.prototype,this,"send").call(this,e,r)}))}_send(t){return __async(this,null,(function*(){Or(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const e=yield __privateGet(this,Sr).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,Sr).call(this,"eth_requestAccounts",[])}catch(r){const t=r.payload;throw this.getRpcError(t,{id:t.id,error:r})}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 r=e.window?e.window:"undefined"!=typeof window?window:null;if(null==r)return null;const n=e.anyProvider;if(n&&r.ethereum)return new t(r.ethereum);if(!("addEventListener"in r&&"dispatchEvent"in r&&"removeEventListener"in r))return null;const i=e.timeout?e.timeout:300;return 0===i?null:yield new Promise(((s,a)=>{let o=[];const l=t=>{o.push(t.detail),n&&c()},c=()=>{if(clearTimeout(u),o.length)if(e&&e.filter){const r=e.filter(o.map((t=>Object.assign({},t.info))));if(null==r)s(null);else if(r instanceof t)s(r);else{let e=null;if(r.uuid){e=o.filter((t=>r.uuid===t.info.uuid))[0]}if(e){const{provider:r,info:n}=e;s(new t(r,void 0,{providerInfo:n}))}else a(Br("filter returned unknown info","UNSUPPORTED_OPERATION",{value:r}))}}else{const{provider:e,info:r}=o[0];s(new t(e,void 0,{providerInfo:r}))}else s(null);r.removeEventListener("eip6963:announceProvider",l)},u=setTimeout((()=>{c()}),i);r.addEventListener("eip6963:announceProvider",l),r.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}}},vd={[md.ETHEREUM]:[gd.METAMASK,gd.TRUST_WALLET],[md.BSC]:[gd.METAMASK,gd.TRUST_WALLET],[md.TRON]:[gd.TRONLINK],[md.ALGORAND]:[gd.LUTE]},wd=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=()=>({[gd.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum,[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]:"undefined"!=typeof window&&void 0!==window.lute}),Ad=(t=3,e=500)=>__async(this,null,(function*(){let r=0,n=bd();const i=Object.values(n).some((t=>!0===t));for(;!i&&r<t;)console.log(`No wallets detected, retrying (${r+1}/${t})...`),yield new Promise((t=>setTimeout(t,e))),n=bd(),r++;return n})),Ed=()=>__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],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${n}`}const s=new fd(window.ethereum);return{walletType:gd.METAMASK,address:e,provider:s,network:i,isConnected:!0,chainId:n}}catch(t){throw console.error("Error connecting to MetaMask:",t),t}})),xd=()=>__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],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=md.ETHEREUM;break;case 56:i=md.BSC;break;default:i=`unknown-${n}`}const s=new fd(window.ethereum);return{walletType:gd.TRUST_WALLET,address:e,provider:s,network:i,isConnected:!0,chainId:n}}catch(t){throw console.error("Error connecting to Trust Wallet:",t),t}})),kd=()=>__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 r=0;r<t;r++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${r+1}/${t}`),yield new Promise((t=>setTimeout(t,e)))}throw new Error("TronWeb took too long to be ready")}));try{const r=yield t();if(!r.defaultAddress||!r.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 n=r.defaultAddress.base58;return console.log("Connected to TronLink wallet:",n),{walletType:gd.TRONLINK,address:n,provider:r,network:md.TRON,isConnected:!0}}catch(r){throw console.error("Error connecting to TronLink:",r),r}})),Sd=()=>__async(this,null,(function*(){if(console.log("Connecting to Lute wallet..."),!window.lute)throw console.error("Lute not found."),new Error("Lute not detected. Please install Lute extension.");try{const{address:t}=yield window.lute.connect();if(!t)throw new Error("No address returned. Please unlock Lute wallet.");return console.log("Connected to Lute wallet:",t),{walletType:gd.LUTE,address:t,provider:window.lute,network:md.ALGORAND,isConnected:!0}}catch(t){throw console.error("Error connecting to Lute wallet:",t),t}})),Nd=t=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",t),t){case gd.METAMASK:return Ed();case gd.TRONLINK:return kd();case gd.TRUST_WALLET:return xd();case gd.LUTE:return Sd();default:throw new Error(`Unsupported wallet type: ${t}`)}})),Pd=t=>vd[t]||[],Cd=(t,e,r)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:e,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Recipient address not provided");if(!r||isNaN(parseFloat(r))||parseFloat(r)<=0)throw new Error("Invalid amount");try{let n;switch(t.walletType){case gd.METAMASK:case gd.TRUST_WALLET:const i=t.provider,s=yield i.getSigner(),a=r.toString(),o=ii(a,18);console.log("Sending ETH/BNB:",{to:e,value:o.toString()});const l=yield i.estimateGas({to:e,value:o,from:yield s.getAddress()});console.log("Gas estimate:",l.toString());const c=l*BigInt(110)/BigInt(100);console.log("Using gas limit:",c.toString()),n=yield s.sendTransaction({to:e,value:o,gasLimit:c});break;case gd.TRONLINK:const u=t.provider;if(!u||!u.ready)throw new Error("TronWeb not initialized");const h=u.toSun(r.toString());console.log("Sending TRX:",{to:e,value:h}),n=yield u.trx.sendTransaction(e,h);break;case gd.LUTE:const d=t.provider,p=Math.floor(1e6*parseFloat(r));console.log("Sending Algos:",{to:e,amount:p}),n=yield d.sendPayment({recipient:e,amount:p});break;default:throw new Error(`Unsupported wallet type: ${t.walletType}`)}console.log("Transaction sent:",n);const i=n.hash||n.txID||n.txId||n;return console.log("Transaction hash:",i),i}catch(n){throw console.error("Native transaction error:",n),n}})),Td=(t,e)=>__async(this,null,(function*(){var r;if(console.log("Sending transaction with:",e),!t)throw new Error("Wallet not connected");const{to:n,amount:i,tokenAddress:s,currency:a,network:o}=e;if(!n)throw new Error("Recipient address not provided");const l=null==(r=_d[a])?void 0:r[o];return l&&l.isNative?Cd(t,n,i):l?Rd(t,l,n,i):Cd(t,n,i)})),Rd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending token transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Token configuration not provided");if(!r)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");const{contractAddress:i,decimals:s,symbol:a}=e;switch(console.log(`Token: ${a}, Decimals: ${s}, Contract: ${i}`),t.walletType){case gd.TRONLINK:return Gd(t,e,r,n);case gd.LUTE:return Bd(t,e,r,n);default:return Md(t,e,r,n)}})),Md=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending ERC20/BEP20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");const i=t.provider,s=yield i.getSigner(),{contractAddress:a,decimals:o,symbol:l}=e,c=parseFloat(n),u=parseInt(o),h=ii(c.toString(),u);console.log(`Sending ${c} ${l} (${h.toString()} base units) to ${r}`),console.log("Token config:",{contractAddress:a,decimals:o,symbol:l});try{const t=new eh(a,["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(),n=yield t.balanceOf(e);if(console.log(`User ${l} balance:`,ni(n,o)),n<h)throw new Error(`Insufficient ${l} balance. Required: ${c}, Available: ${ni(n,o)}`);try{const e=yield t.transfer.estimateGas(r,h);let n;console.log("Gas estimate:",e.toString()),n="USDC"===l?BigInt(150):"USDT"===l?BigInt(130):BigInt(120);const i=e*n/BigInt(100);console.log("Using gas limit:",i.toString());const s=yield t.transfer(r,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 n=yield t.transfer(r,h,{gasLimit:e});return console.log("Transaction sent with fixed gas limit:",n),n.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,r,n)=>__async(this,null,(function*(){if(console.log("Sending TRC20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!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:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=(l*Math.pow(10,c)).toString();console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.contract().at(s);if(!t.transfer)throw new Error("Invalid TRC-20 contract");const e=yield t.transfer(r,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"}`)}})),Bd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending Algorand asset transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!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:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.sendAssetTransfer({recipient:r,assetId:s,amount:u});return console.log("Algorand asset transaction sent:",t),t.txId}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}}));let Id={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{},authToken:null};const Od=t=>__async(this,null,(function*(){Id=__spreadValues(__spreadValues({},Id),t),console.log("API initialized with:",{apiUrl:Id.apiUrl,apiKey:Id.apiKey?`${Id.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Id.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(`${Id.apiKey}:${Id.apiSecret}`),e=yield fetch(`${Id.apiUrl}/api/merchants/dashboard`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,"x-api-key":Id.apiKey,"x-api-secret":Id.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),Id.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(Id.merchantWalletAddresses).length&&(yield Fd()),Id.merchantWalletAddresses})),Ld=()=>({"Content-Type":"application/json","x-api-key":Id.apiKey,"x-api-secret":Id.apiSecret,Authorization:Id.authToken?`Bearer ${Id.authToken}`:void 0}),Dd=t=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",t),!t.amount)throw new Error("Payment amount is required");const r=yield Ud();console.log("Using merchant wallets:",r);const n=__spreadProps(__spreadValues({},t),{merchantWalletAddresses:__spreadValues(__spreadValues({},r),t.merchantWalletAddresses)});console.log("Enhanced payment data:",n);const i=yield fetch(`${Id.apiUrl}/api/payments/create`,{method:"POST",headers:Ld(),body:JSON.stringify(n)});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(r){throw console.error("Create payment error:",r),r}})),jd=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 r=yield fetch(`${Id.apiUrl}/api/payments/process`,{method:"POST",headers:Ld(),body:JSON.stringify(t)});if(console.log("Process payment response status:",r.status),!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to process payment: ${r.status} ${r.statusText}`)}throw console.error("Error processing payment:",t),new Error(t.error||`Failed to process payment: ${r.status}`)}const n=yield r.json();return console.log("Process payment response data:",n),n}catch(r){throw console.error("Process payment error:",r),r}}));var Hd={exports:{}},Wd={},Qd=e,zd=Symbol.for("react.element"),Vd=Symbol.for("react.fragment"),Kd=Object.prototype.hasOwnProperty,Jd=Qd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qd={key:!0,ref:!0,__self:!0,__source:!0};function Yd(t,e,r){var n,i={},s=null,a=null;for(n in void 0!==r&&(s=""+r),void 0!==e.key&&(s=""+e.key),void 0!==e.ref&&(a=e.ref),e)Kd.call(e,n)&&!qd.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===i[n]&&(i[n]=e[n]);return{$$typeof:zd,type:t,key:s,ref:a,props:i,_owner:Jd.current}}Wd.Fragment=Vd,Wd.jsx=Yd,Wd.jsxs=Yd,Hd.exports=Wd;var Zd=Hd.exports;const Xd=e.createContext(),$d=e.createContext(),tp=()=>e.useContext($d);var ep,rp,np=Object.defineProperty,ip=Object.getOwnPropertySymbols,sp=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,op=(t,e,r)=>e in t?np(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,lp=(t,e)=>{for(var r in e||(e={}))sp.call(e,r)&&op(t,r,e[r]);if(ip)for(var r of ip(e))ap.call(e,r)&&op(t,r,e[r]);return t},cp=(t,e)=>{var r={};for(var n in t)sp.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&ip)for(var n of ip(t))e.indexOf(n)<0&&ap.call(t,n)&&(r[n]=t[n]);return r};(t=>{const e=class e{constructor(t,r,n,s){if(this.version=t,this.errorCorrectionLevel=r,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 a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const o=this.addEccAndInterleave(n);if(this.drawCodewords(o),-1==s){let t=1e9;for(let e=0;e<8;e++){this.applyMask(e),this.drawFormatBits(e);const r=this.getPenaltyScore();r<t&&(s=e,t=r),this.applyMask(e)}}i(0<=s&&s<=7),this.mask=s,this.applyMask(s),this.drawFormatBits(s),this.isFunction=[]}static encodeText(r,n){const i=t.QrSegment.makeSegments(r);return e.encodeSegments(i,n)}static encodeBinary(r,n){const i=t.QrSegment.makeBytes(r);return e.encodeSegments([i],n)}static encodeSegments(t,n,s=1,o=40,l=-1,c=!0){if(!(e.MIN_VERSION<=s&&s<=o&&o<=e.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,h;for(u=s;;u++){const r=8*e.getNumDataCodewords(u,n),i=a.getTotalBits(t,u);if(i<=r){h=i;break}if(u>=o)throw new RangeError("Data too long")}for(const r of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])c&&h<=8*e.getNumDataCodewords(u,r)&&(n=r);let d=[];for(const e of t){r(e.mode.modeBits,4,d),r(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,n);i(d.length<=p),r(0,Math.min(4,p-d.length),d),r(0,(8-d.length%8)%8,d),i(d.length%8==0);for(let e=236;d.length<p;e^=253)r(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,n,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 r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%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 r=0;r<e;r++)for(let n=0;n<e;n++)0==r&&0==n||0==r&&n==e-1||r==e-1&&0==n||this.drawAlignmentPattern(t[r],t[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.errorCorrectionLevel.formatBits<<3|t;let r=e;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const s=21522^(e<<10|r);i(s>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,n(s,i));this.setFunctionModule(8,7,n(s,6)),this.setFunctionModule(8,8,n(s,7)),this.setFunctionModule(7,8,n(s,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,n(s,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,n(s,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,n(s,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let r=0;r<12;r++)t=t<<1^7973*(t>>>11);const e=this.version<<12|t;i(e>>>18==0);for(let r=0;r<18;r++){const t=n(e,r),i=this.size-11+r%3,s=Math.floor(r/3);this.setFunctionModule(i,s,t),this.setFunctionModule(s,i,t)}}drawFinderPattern(t,e){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const i=Math.max(Math.abs(n),Math.abs(r)),s=t+n,a=e+r;0<=s&&s<this.size&&0<=a&&a<this.size&&this.setFunctionModule(s,a,2!=i&&4!=i)}}drawAlignmentPattern(t,e){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(t+n,e+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(t,e,r){this.modules[e][t]=r,this.isFunction[e][t]=!0}addEccAndInterleave(t){const r=this.version,n=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const s=e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],o=Math.floor(e.getNumRawDataModules(r)/8),l=s-o%s,c=Math.floor(o/s);let u=[];const h=e.reedSolomonComputeDivisor(a);for(let i=0,p=0;i<s;i++){let r=t.slice(p,p+c-a+(i<l?0:1));p+=r.length;const n=e.reedSolomonComputeRemainder(r,h);i<l&&r.push(0),u.push(r.concat(n))}let d=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,r)=>{(e!=c-a||r>=l)&&d.push(t[e])}));return i(d.length==o),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=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 a=e-s,o=!(e+1&2)?this.size-1-i:i;!this.isFunction[o][a]&&r<8*t.length&&(this.modules[o][a]=n(t[r>>>3],7-(7&r)),r++)}}i(r==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 r=0;r<this.size;r++){let n;switch(t){case 0:n=(r+e)%2==0;break;case 1:n=e%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+e)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(e/2))%2==0;break;case 5:n=r*e%2+r*e%3==0;break;case 6:n=(r*e%2+r*e%3)%2==0;break;case 7:n=((r+e)%2+r*e%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[e][r]&&n&&(this.modules[e][r]=!this.modules[e][r])}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[i][a]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[i][a],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][i]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[a][i],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let r=0;r<this.size-1;r++){const n=this.modules[i][r];n==this.modules[i][r+1]&&n==this.modules[i+1][r]&&n==this.modules[i+1][r+1]&&(t+=e.PENALTY_N2)}let r=0;for(const e of this.modules)r=e.reduce(((t,e)=>t+(e?1:0)),r);const n=this.size*this.size,s=Math.ceil(Math.abs(20*r-10*n)/n)-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 r=[6];for(let n=this.size-7;r.length<t;n-=e)r.splice(1,0,n);return r}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;r-=(25*e-10)*e-55,t>=7&&(r-=36)}return i(208<=r&&r<=29648),r}static getNumDataCodewords(t,r){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let r=[];for(let e=0;e<t-1;e++)r.push(0);r.push(1);let n=1;for(let i=0;i<t;i++){for(let t=0;t<r.length;t++)r[t]=e.reedSolomonMultiply(r[t],n),t+1<r.length&&(r[t]^=r[t+1]);n=e.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(t,r){let n=r.map((t=>0));for(const i of t){const t=i^n.shift();n.push(0),r.forEach(((r,i)=>n[i]^=e.reedSolomonMultiply(r,t)))}return n}static reedSolomonMultiply(t,e){if(t>>>8!=0||e>>>8!=0)throw new RangeError("Byte out of range");let r=0;for(let n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(e>>>n&1)*t;return i(r>>>8==0),r}finderPenaltyCountPatterns(t){const e=t[1];i(e<=3*this.size);const r=e>0&&t[2]==e&&t[3]==3*e&&t[4]==e&&t[5]==e;return(r&&t[0]>=4*e&&t[6]>=e?1:0)+(r&&t[6]>=4*e&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,r){return t&&(this.finderPenaltyAddHistory(e,r),e=0),e+=this.size,this.finderPenaltyAddHistory(e,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(t,e){0==e[0]&&(t+=this.size),e.pop(),e.unshift(t)}};function r(t,e,r){if(e<0||e>31||t>>>e!=0)throw new RangeError("Value out of range");for(let n=e-1;n>=0;n--)r.push(t>>>n&1)}function n(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,r){if(this.mode=t,this.numChars=e,this.bitData=r,e<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(e){let n=[];for(const t of e)r(t,8,n);return new t(t.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!t.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const i=Math.min(e.length-t,3);r(parseInt(e.substring(t,t+i),10),3*i+1,n),t+=i}return new t(t.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!t.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,i=[];for(n=0;n+2<=e.length;n+=2){let s=45*t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n));s+=t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n+1)),r(s,11,i)}return n<e.length&&r(t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)),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 n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,n);else if(e<16384)r(2,2,n),r(e,14,n);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(e,21,n)}return new t(t.Mode.ECI,0,n)}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 r=0;for(const n of t){const t=n.mode.numCharCountBits(e);if(n.numChars>=1<<t)return 1/0;r+=4+t+n.bitData.length}return r}static toUtf8ByteArray(t){t=encodeURI(t);let e=[];for(let r=0;r<t.length;r++)"%"!=t.charAt(r)?e.push(t.charCodeAt(r)):(e.push(parseInt(t.substring(r+1,r+3),16)),r+=2);return e}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=s;t.QrSegment=s})(ep||(ep={})),(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=ep||(ep={})).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={}))})(ep||(ep={}));var up=ep,hp={L:up.QrCode.Ecc.LOW,M:up.QrCode.Ecc.MEDIUM,Q:up.QrCode.Ecc.QUARTILE,H:up.QrCode.Ecc.HIGH},dp=128,pp="L",fp="#FFFFFF",gp="#000000",mp=!1,yp=1;
|
12
12
|
/**
|
13
13
|
* @license qrcode.react
|
14
14
|
* Copyright (c) Paul O'Shannessy
|
15
15
|
* SPDX-License-Identifier: ISC
|
16
|
-
*/function yp(t,e=0){const r=[];return t.forEach((function(t,n){let i=null;t.forEach((function(s,a){if(!s&&null!==i)return r.push(`M${i+e} ${n+e}h${a-i}v1H${i+e}z`),void(i=null);if(a!==t.length-1)s&&null===i&&(i=a);else{if(!s)return;null===i?r.push(`M${a+e},${n+e} h1v1H${a+e}z`):r.push(`M${i+e},${n+e} h${a+1-i}v1H${i+e}z`)}}))})),r.join("")}function vp(t,e){return t.slice().map(((t,r)=>r<e.y||r>=e.y+e.h?t:t.map(((t,r)=>(r<e.x||r>=e.x+e.w)&&t))))}function wp({value:t,level:r,minVersion:n,includeMargin:i,marginSize:s,imageSettings:a,size:o,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...up.QrSegment.makeSegments(e)),t)),[]);return up.QrCode.encodeSegments(e,hp[r],n,void 0,void 0,l)}),[t,r,n,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),r=t.length+2*e,n=function(t,e,r,n){if(null==n)return null;const i=t.length+2*r,s=Math.floor(.1*e),a=i/e,o=(n.width||s)*a,l=(n.height||s)*a,c=null==n.x?t.length/2-o/2:n.x*a,u=null==n.y?t.length/2-l/2:n.y*a,h=null==n.opacity?1:n.opacity;let d=null;if(n.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(o+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:o,excavation:d,opacity:h,crossOrigin:n.crossOrigin}}(t,o,e,a);return{cells:t,margin:e,numCells:r,calculatedImageSettings:n}}),[c,o,a,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var bp=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,r){const n=t,{value:i,size:s=dp,level:a=pp,bgColor:o=fp,fgColor:l=gp,includeMargin:c=mp,minVersion:u=_p,boostLevel:h,marginSize:d,imageSettings:p}=n,f=cp(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=cp(f,["style"]),_=null==p?void 0:p.src,y=e.useRef(null),v=e.useRef(null),w=e.useCallback((t=>{y.current=t,"function"==typeof r?r(t):r&&(r.current=t)}),[r]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=wp({value:i,level:a,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 r=x;const n=v.current,i=null!=S&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;i&&null!=S.excavation&&(r=vp(x,S.excavation));const a=window.devicePixelRatio||1;t.height=t.width=s*a;const c=s/k*a;e.scale(c,c),e.fillStyle=o,e.fillRect(0,0,k,k),e.fillStyle=l,bp?e.fill(new Path2D(yp(r,E))):x.forEach((function(t,r){t.forEach((function(t,n){t&&e.fillRect(n+E,r+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(n,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[_]);const N=lp({height:s,width:s},g);let P=null;return null!=_&&(P=e.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{A(!0)},ref:v,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",lp({style:N,height:s,width:s,ref:w,role:"img"},m)),P)})).displayName="QRCodeCanvas";var Ap=e.forwardRef((function(t,r){const n=t,{value:i,size:s=dp,level:a=pp,bgColor:o=fp,fgColor:l=gp,includeMargin:c=mp,minVersion:u=_p,boostLevel:h,title:d,marginSize:p,imageSettings:f}=n,g=cp(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:_,numCells:y,calculatedImageSettings:v}=wp({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let w=_,b=null;null!=f&&null!=v&&(null!=v.excavation&&(w=vp(_,v.excavation)),b=e.createElement("image",{href:f.src,height:v.h,width:v.w,x:v.x+m,y:v.y+m,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const A=yp(w,m);return e.createElement("svg",lp({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:r,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:o,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));Ap.displayName="QRCodeSVG";const Ep=({walletAddress:t,amount:r,currency:n,network:i,theme:s="light",size:a=200})=>{const[o,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"tron":e="TRX"===n?`tronlink://transfer?to=${t}&amount=${r}`:t;break;case"algorand":e=`algorand://${t}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)e=`ethereum:${t}@56?value=${p(r)}`;else{const i=h(n,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}@56`:t}break;default:if("ETH"===n)e=`ethereum:${t}@1?value=${p(r)}`;else{const i=h(n,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}`:t}}l(e),u(null)}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,r,n,i]);const h=(t,e)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:r[t])||""},d=(t,e)=>{const r="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,r)).toString()},p=t=>Math.floor(1e18*parseFloat(t)).toString(),f=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Zd.jsxs("div",{className:"flex flex-col items-center",children:[c?Zd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Zd.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:Zd.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"})}),Zd.jsx("p",{className:"font-medium",children:c})]}):Zd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:o&&Zd.jsx(Ap,{value:o,size:a,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Zd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Zd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Zd.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:Zd.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 ",n]}),Zd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(i)," wallet app"]})]}),Zd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Zd.jsxs("div",{className:"flex justify-between items-center",children:[Zd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Zd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),Zd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Zd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Zd.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(i)})]})]}),!c&&Zd.jsxs("div",{className:"w-full mb-4",children:[Zd.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),Zd.jsx("div",{className:"text-xs font-mono p-2 rounded bg-gray-100 text-gray-700 break-all text-center select-all cursor-pointer border",onClick:()=>{var e;return null==(e=navigator.clipboard)?void 0:e.writeText(t)},title:"Click to copy",children:t})]}),Zd.jsx("div",{className:"w-full",children:Zd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Zd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Zd.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:Zd.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"]}),Zd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Zd.jsxs("li",{children:["1. Open your crypto wallet app (",(g=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[g]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Zd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Zd.jsxs("li",{children:["3. Send exactly ",Zd.jsxs("strong",{children:[r," ",n]})," on ",f(i)," network"]}),Zd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Zd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Zd.jsxs("p",{className:"text-xs text-yellow-800",children:[Zd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(i),") and using the exact amount shown above."]})})]})})]});var g},xp=({status:t,message:r,theme:n="light",payment:i=null,transactionHash:s=null,selectedPaymentMethod:a=null,merchantName:o="Merchant",onClose:l=null})=>{const[c,u]=e.useState(!1),h=()=>__async(this,null,(function*(){if(s)try{yield navigator.clipboard.writeText(s),u(!0),setTimeout((()=>u(!1)),2e3)}catch(t){console.error("Failed to copy transaction hash:",t)}})),d=()=>{switch(t){case"processing":return Zd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Zd.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center",children:Zd.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:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Zd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Zd.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:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}};return"success"===t?Zd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Zd.jsx("div",{className:"mb-6",children:d()}),Zd.jsx("h3",{className:"text-2xl font-bold mb-3 "+("dark"===n?"text-white":"text-gray-900"),children:"Payment Successful"}),i&&a&&Zd.jsxs("p",{className:"text-center mb-6 "+("dark"===n?"text-gray-300":"text-gray-600"),children:["Your payment of ",i.totalAmount||i.amount," ",a.currency," has been completed."]}),s&&Zd.jsxs("div",{className:"w-full mb-6",children:[Zd.jsx("p",{className:"text-sm font-medium mb-2 "+("dark"===n?"text-gray-300":"text-gray-700"),children:"Transaction Hash:"}),Zd.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors "+("dark"===n?"bg-gray-700 border-gray-600 hover:bg-gray-600":"bg-gray-50 border-gray-200 hover:bg-gray-100"),onClick:h,children:[Zd.jsx("span",{className:"font-mono text-sm "+("dark"===n?"text-gray-300":"text-gray-700"),children:(g=s,g?g.length<=16?g:`${g.slice(0,8)}...${g.slice(-8)}`:"")}),Zd.jsxs("div",{className:"flex items-center",children:[c?Zd.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Zd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 "+("dark"===n?"text-gray-400":"text-gray-500"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Zd.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"})})]})]})]}),Zd.jsx("div",{className:"w-full p-4 rounded-lg border mb-6 "+("dark"===n?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:Zd.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[Zd.jsxs("div",{children:[Zd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===n?"text-gray-400":"text-gray-500"),children:"Merchant ID:"}),Zd.jsx("p",{className:"text-sm font-medium "+("dark"===n?"text-gray-300":"text-gray-700"),children:o})]}),Zd.jsxs("div",{children:[Zd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===n?"text-gray-400":"text-gray-500"),children:"Network:"}),Zd.jsx("p",{className:"text-sm font-medium "+("dark"===n?"text-gray-300":"text-gray-700"),children:a?(f=a.network,{ethereum:"Ethereum",bsc:"BSC",tron:"TRON",algorand:"Algorand"}[f]||f):"N/A"})]}),Zd.jsxs("div",{className:"col-span-2",children:[Zd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===n?"text-gray-400":"text-gray-500"),children:"Recipient:"}),Zd.jsx("p",{className:"text-sm font-mono "+("dark"===n?"text-gray-300":"text-gray-700"),children:(null==i?void 0:i.recipientWallet)?(p=i.recipientWallet,p?p.length<=16?p:`${p.slice(0,6)}...${p.slice(-4)}`:"N/A"):"N/A"})]})]})}),l&&Zd.jsx("button",{onClick:l,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"})]}):Zd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Zd.jsx("div",{className:"mb-4",children:d()}),Zd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===n?"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"}})()}),Zd.jsx("p",{className:`text-center ${(()=>{switch(t){case"processing":return"dark"===n?"text-blue-300":"text-blue-600";case"success":return"dark"===n?"text-green-300":"text-green-600";case"error":return"dark"===n?"text-red-300":"text-red-600";default:return"dark"===n?"text-gray-300":"text-gray-600"}})()}`,children:r}),"processing"===t&&Zd.jsx("div",{className:"mt-4 text-xs "+("dark"===n?"text-gray-400":"text-gray-500"),children:"This may take a few moments. Please do not close this window."}),"error"===t&&Zd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===n?"bg-gray-700":"bg-gray-100"),children:Zd.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-600"),children:"Please try again or contact support if the problem persists."})})]});var p,f,g},kp=({onSelect:t,selected:r,theme:n="light",supportedNetworks:i=[]})=>{var s,a,o;const[l,c]=e.useState(md.ETHEREUM),[u,h]=e.useState(null),[d,p]=e.useState({}),[f,g]=e.useState(!1),m=[{id:md.ETHEREUM,name:"Ethereum",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/liznxm8l7iouudtrxdpi.png"},{id:md.TRON,name:"Tron",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/mpxxns6gtfiws4rlouxc.png"},{id:md.ALGORAND,name:"Algorand",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/x2lugizoduiphuqn0dej.png"},{id:"solana",name:"Solana",icon:" https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962845/coinley/hmex6qxnlid1gboh4cwc.png"},{id:md.BSC,name:"Binance Smart Chain",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/eoavfddfqmt7qgajjxvb.png"}],[_,y]=e.useState(!1),v=e.useRef(null);e.useEffect((()=>{function t(t){v.current&&!v.current.contains(t.target)&&y(!1)}return _?document.addEventListener("mousedown",t):document.removeEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)}),[_]),e.useEffect((()=>{p(bd())}),[]);const w=(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:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",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:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",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})(l),b=f?w:w.slice(0,4);function A(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 Zd.jsxs("div",{className:"",children:[Zd.jsxs("div",{className:"mb-6",children:[Zd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),Zd.jsxs("div",{className:"relative",ref:v,children:[Zd.jsxs("button",{type:"button",className:"w-full flex items-center justify-between px-5 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:()=>y((t=>!t)),style:{minHeight:"56px"},children:[Zd.jsxs("span",{className:"flex items-center gap-3",children:[Zd.jsx("img",{src:null==(s=m.find((t=>t.id===l)))?void 0:s.icon,alt:null==(a=m.find((t=>t.id===l)))?void 0:a.name,className:"w-6 h-6"}),Zd.jsx("span",{className:"text-base font-normal",children:null==(o=m.find((t=>t.id===l)))?void 0:o.name})]}),Zd.jsx("svg",{className:"w-5 h-5 ml-2 transition-transform "+(_?"rotate-180":""),fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),_&&Zd.jsx("div",{className:"absolute left-0 mt-2 w-full bg-white rounded-2xl shadow-lg border border-gray-100 z-20",style:{minWidth:"100%"},children:m.filter((t=>0===i.length||i.includes(t.id))).map((t=>Zd.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 px-5 py-3 text-gray-900 text-base font-normal rounded-2xl transition hover:bg-gray-100 "+(l===t.id?"bg-gray-50":""),onClick:()=>{var e;y(!1),e=t.id,c(e),g(!1),h(null)},style:{minHeight:"48px"},children:[Zd.jsx("img",{src:t.icon,alt:t.name,className:"w-6 h-6"}),Zd.jsx("span",{children:t.name})]},t.id)))})]})]}),Zd.jsxs("div",{className:"mb-4",children:[Zd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Select Stablecoin"}),Zd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:b.map((t=>{const e=(null==u?void 0:u.currency)===t.id&&(null==u?void 0:u.network)===l;return Zd.jsxs("button",{onClick:()=>(t=>{var e;const r={currency:t.id,network:l,tokenConfig:null==(e=yd[t.id])?void 0:e[l],method:t};h(r)})(t),className:`group flex items-center justify-between w-full px-5 py-4 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"},children:[Zd.jsxs("span",{className:"flex items-center gap-3",children:[Zd.jsx("img",{src:t.logo,alt:t.name,className:"h-6 w-6"}),Zd.jsxs("span",{className:"font-medium text-base text-gray-900",children:[t.description," (",t.name,")"]})]}),e&&Zd.jsx("span",{className:"ml-2 flex items-center justify-center w-6 h-6 rounded-full bg-[#7042D2]",children:Zd.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Zd.jsx("path",{d:"M4 8.5L7 11.5L12 6.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},`${t.id}-${t.network}`)}))}),w.length>4&&Zd.jsx("button",{onClick:()=>g(!f),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===n?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:f?"Show Less":`Show More (${w.length-4} more)`})]}),Zd.jsx("div",{className:"p-3 rounded-lg text-sm mb-6 "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Zd.jsxs("div",{className:"flex items-center",children:[Zd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(d[A(l)]?"bg-green-500":"bg-red-500")}),Zd.jsx("span",{className:"text-xs",children:function(t){const e=A(t),r=d[e],n={[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"};return r?`${n[e]} detected - Ready to pay`:`${n[e]} required - Please install to continue`}(l)})]})}),Zd.jsx("button",{onClick:()=>{u&&t(u)},disabled:!u,className:"w-full py-3 px-4 font-medium rounded-2xl text-lg shadow-md transition-colors "+(u?"bg-[#7042D2] text-white hover:bg-[#5b34b1]":"bg-gray-300 text-gray-500 cursor-not-allowed"),style:{borderRadius:"1.5rem"},children:"Proceed"})]})},Sp=({isOpen:t,onClose:r,payment:n,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:a,onPayment:o,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:_={},supportedWallets:y=[],step:v="select-currency",merchantWalletAddresses:w={},debug:b=!1})=>{const[A,E]=e.useState("wallet"),x=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t),k=t=>({[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"}[t]||t),S=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?Zd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:Zd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Zd.jsxs("div",{className:"coinley-modal relative p-6 max-w-[490px] mx-auto rounded-3xl shadow-xl bg-gray-100",style:{maxWidth:"490px !important",width:"100% !important",minWidth:"320px !important"},children:[Zd.jsxs("div",{className:"bg-white flex justify-between items-center mb-6 py-4 px-2 rounded-full",children:[Zd.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Zd.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"}),Zd.jsx("span",{className:"text-lg font-semibold text-gray-800",children:"Payment Details"})]}),"success"!==v&&Zd.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Zd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),n&&"success"!==v&&Zd.jsx("div",{className:"mb-6",children:Zd.jsxs("div",{className:"text-center",children:[Zd.jsx("div",{className:"text-sm text-gray-600",children:"Total amount"}),Zd.jsxs("div",{className:"coinley-amount-display text-5xl font-bold text-[#7042D2] mt-2",children:["$",(N=n.totalAmount||n.amount,parseFloat(N).toFixed(2))]}),Zd.jsx("div",{className:"text-sm text-gray-600 mt-4",children:"Payment to:"}),Zd.jsx("div",{className:"coinley-merchant-name text-base font-semibold mt-1",children:h})]})}),"select-currency"===v&&Zd.jsx("div",{className:"mb-6",children:Zd.jsx(kp,{onSelect:a,selected:s,theme:u,supportedNetworks:m})}),"confirm"===v&&s&&n&&Zd.jsxs("div",{children:[Zd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Zd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Zd.jsxs("div",{className:"space-y-2",children:[Zd.jsxs("div",{className:"flex justify-between",children:[Zd.jsx("span",{className:"text-purple-600 font-semibold",children:"Currency:"}),Zd.jsx("span",{className:"font-medium",children:s.currency})]}),Zd.jsxs("div",{className:"flex justify-between",children:[Zd.jsx("span",{className:"text-purple-600 font-semibold",children:"Network:"}),Zd.jsx("span",{className:"font-medium",children:x(s.network)})]}),Zd.jsxs("div",{className:"flex justify-between",children:[Zd.jsx("span",{className:"text-purple-600 font-semibold",children:"Fee:"}),Zd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Zd.jsx("div",{className:"mb-4",children:Zd.jsxs("div",{className:"flex border-b border-gray-200",children:[Zd.jsx("button",{onClick:()=>E("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===A?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Zd.jsx("button",{onClick:()=>E("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===A?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Zd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Zd.jsxs("div",{className:"flex items-center",children:[Zd.jsx("div",{className:"bg-purple-600 rounded-full p-2 mr-3",children:Zd.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:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Zd.jsxs("div",{children:[Zd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Zd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===A?Zd.jsx("div",{className:"mb-4",children:Zd.jsx(Ep,{walletAddress:(()=>{if(!s)return"No network selected";const t=w[s.network];return t||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:s.currency,network:s.network,theme:u})}):Zd.jsxs("div",{className:"space-y-3 mb-4",children:[0===y.length?Zd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Zd.jsxs("div",{className:"flex items-center",children:[Zd.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:Zd.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"})}),Zd.jsxs("div",{children:[Zd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Zd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",x(s.network)," network"]})]})]})}):y.map((t=>Zd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Zd.jsxs("div",{className:"flex items-center justify-between",children:[Zd.jsxs("div",{className:"flex items-center",children:[Zd.jsx("img",{src:S(t),alt:k(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Zd.jsxs("div",{children:[Zd.jsx("h3",{className:"font-medium text-gray-800",children:k(t)}),Zd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",k(t)]})]})]}),(null==p?void 0:p.walletType)===t?Zd.jsxs("div",{className:"flex items-center space-x-2",children:[Zd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Zd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Zd.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))),Zd.jsx("div",{className:"space-y-2",children:Object.entries(_).filter((([t,e])=>!e)).map((([t])=>Zd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Zd.jsxs("div",{className:"flex items-center justify-between",children:[Zd.jsxs("span",{className:"text-sm text-gray-600",children:[k(t)," not detected"]}),Zd.jsx("a",{href:wd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-purple-600 hover:underline",children:"Install"})]})},t)))})]}),c&&Zd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Zd.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[Zd.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"}),Zd.jsx("button",{type:"button",onClick:()=>o("qrcode"===A),className:"coinley-button-primary w-full py-2 px-4 font-medium rounded-md",disabled:!g&&"wallet"===A&&!p,children:"qrcode"===A?"I have sent the payment":"Pay Now"})]})]}),"processing"===v&&Zd.jsx(xp,{status:"processing",theme:u,message:"Processing your payment..."}),"success"===v&&Zd.jsx(xp,{status:"success",theme:u,message:"Payment successful!",payment:n,transactionHash:d,selectedPaymentMethod:s,merchantName:h,onClose:()=>{r()}}),"error"===v&&Zd.jsxs("div",{children:[Zd.jsx(xp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Zd.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"!==v&&Zd.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 mt-6",children:[Zd.jsxs("p",{children:["Powered by ",Zd.jsx("span",{className:"text-purple-600",children:"Coinley"})," - Secure Cryptocurrency Payments"]}),Zd.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:[Zd.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Zd.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})}):null;var N},Np=e.forwardRef((({apiKey:t,apiSecret:r,apiUrl:n,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:a={},onSuccess:o,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},_)=>{const y=tp(),{theme:v}=e.useContext(Xd),[w,b]=e.useState(h),[A,E]=e.useState(null),[x,k]=e.useState("idle"),[S,N]=e.useState(null),[P,C]=e.useState(null),[T,R]=e.useState(null),[M,G]=e.useState(null),[B,I]=e.useState({}),[O,F]=e.useState("select-currency"),[U,L]=e.useState({}),D=t||(null==y?void 0:y.apiKey),j=r||(null==y?void 0:y.apiSecret);n||null==y||y.apiUrl;const H=u||v,W=d||(null==y?void 0:y.debug),Q=f.length>0?f:[md.ETHEREUM,md.BSC,md.TRON,md.ALGORAND],z=(t,e)=>{W&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{D&&j&&(()=>{__async(this,null,(function*(){try{z("Fetching merchant wallet addresses from backend...");const t=yield Ud();L(t),z("Merchant wallets fetched successfully:",t)}catch(t){console.error("Failed to fetch merchant wallets:",t),L(a)}}))})()}),[D,j,a]),e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield Ad(3,1e3);I(t),z("Available wallets detected:",t)})))()}}),[W]),e.useImperativeHandle(_,(()=>({open:t=>{V(t)},close:()=>{K()},getPayment:()=>A,getWalletConnection:()=>M,debugWallets:()=>(()=>{var t;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"),"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});const e=bd();console.log("Detected wallets:",e)})(),getMerchantWallets:()=>U})));const V=t=>__async(this,null,(function*(){if(!t||!t.amount)return C("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));k("loading"),b(!0),F("select-currency");try{z("Creating payment with details:",t);let e=U;0===Object.keys(e).length&&(z("No wallet addresses found, fetching from backend..."),e=yield Ud(),L(e)),z("Using wallet addresses:",e);const r=yield Dd({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});z("Payment created:",r),E(r.payment),k("idle"),C(null),z("Payment created and state updated")}catch(e){z("Error creating payment:",e),C(e.message||"Failed to create payment"),k("error"),l&&l(e)}})),K=()=>{b(!1),R(null),G(null),N(null),F("select-currency"),c&&c()};return Zd.jsx(Zd.Fragment,{children:w&&Zd.jsx(Sp,{isOpen:w,onClose:K,payment:A,paymentStatus:x,selectedPaymentMethod:S,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",O),z("Payment method selected:",t),N(t),F("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(A&&S)if(M||p){z("Starting payment process..."),k("loading"),R(null),F("processing");try{let r;if(p)z("Test mode: Generating mock transaction..."),r=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{let n;if(A.recipientWallet)n=A.recipientWallet;else{if(!U[S.network])throw new Error(`No merchant wallet address found for ${S.network} network`);n=U[S.network]}z("Using merchant address for payment:",n),z("Sending transaction through wallet..."),r=yield Td(M,{to:n,amount:A.totalAmount||A.amount,tokenAddress:null==(t=S.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=S.tokenConfig)?void 0:e.decimals,currency:S.currency,network:S.network})}z("Transaction hash:",r),R(r),z("Processing payment with backend...");const n=yield jd({paymentId:A.id,transactionHash:r,network:S.network,currency:S.currency,senderAddress:null==M?void 0:M.address});z("Payment processed successfully:",n),k("success"),F("success"),o&&(z("Calling onSuccess callback..."),o(A.id,r,{network:S.network,currency:S.currency,amount:A.totalAmount||A.amount}))}catch(r){z("Payment error:",r),C(r.message||"Failed to process payment"),k("error"),F("error"),l&&l(r)}}else C("Please connect your wallet first");else C("Missing payment information")})),onBack:()=>{"confirm"===O?(F("select-currency"),G(null)):"error"===O&&F("confirm")},error:P,theme:H,merchantName:s,transactionHash:T,walletConnection:M,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:",S),console.log("3. Available wallets:",B),console.log("4. Current step:",O),!S)return console.error("No payment method selected"),void C("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),C(null),z("Connecting wallet:",{walletType:t,network:S.network});const e=yield Nd(t,S.network);G(e),C(null),console.log("6. Connection successful:",e),z("Wallet connected successfully:",e)}catch(e){console.error("7. Connection failed:",e),z("Wallet connection error:",e),C(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:Q,availableWallets:B,supportedWallets:S?Pd(S.network):[],step:O,merchantWalletAddresses:U,debug:W})})}));Np.displayName="CoinleyCheckout";t.CoinleyCheckout=Np,t.CoinleyModal=Sp,t.CoinleyProvider=({apiKey:t,apiSecret:r,apiUrl:n="https://coinleyserver-production.up.railway.app",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:a=!1,children:o})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null),[f,g]=e.useState({});e.useEffect((()=>{if(!t||!r)return void h("API key and secret are required");(()=>{__async(this,null,(function*(){try{yield Od({apiKey:t,apiSecret:r,apiUrl:n,debug:a});const e=yield Ud(),o=__spreadValues(__spreadValues(__spreadValues({},e),i&&{ethereum:i}),s&&{solana:s});g(o),c(!0),a&&console.log("Coinley SDK initialized successfully with wallets:",o)}catch(e){h(e.message),a&&console.error("Coinley SDK initialization error:",e)}}))})()}),[t,r,n,i,s,a]);const m={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s,merchantWallets:f,isInitialized:l,error:u,debug:a,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 Zd.jsx($d.Provider,{value:m,children:o})},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=kp,t.PaymentStatus=xp,t.QRCode=Ep,t.TOKEN_CONFIG=yd,t.ThemeProvider=({initialTheme:t="light",children:r})=>{const[n,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),Zd.jsx(Xd.Provider,{value:{theme:n,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:r})},t.WALLET_TYPES=gd,t.connectWallet=Nd,t.createPayment=Dd,t.detectWallets=bd,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 r=yield fetch(`${Id.apiUrl}/api/payments/${t}`,{method:"GET",headers:Ld()});if(!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to get payment: ${r.status} ${r.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${r.status}`)}const n=yield r.json();return console.log("Get payment response:",n),n}catch(r){throw console.error("Get payment error:",r),r}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Id.apiUrl}/api/networks`,{method:"GET",headers:Ld()});if(!e.ok){let r;try{r=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(r.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=wd,t.processPayment=jd,t.sendTransaction=Td,t.useCoinley=tp,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const n=yield fetch(`${Id.apiUrl}/api/wallets/validate`,{method:"POST",headers:Ld(),body:JSON.stringify({address:t,network:e})});if(!n.ok){let t;try{t=yield n.json()}catch(r){throw new Error(`Failed to validate address: ${n.status} ${n.statusText}`)}throw new Error(t.error||`Failed to validate address: ${n.status}`)}return yield n.json()}catch(n){throw console.error("Validate wallet address error:",n),n}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
16
|
+
*/function _p(t,e=0){const r=[];return t.forEach((function(t,n){let i=null;t.forEach((function(s,a){if(!s&&null!==i)return r.push(`M${i+e} ${n+e}h${a-i}v1H${i+e}z`),void(i=null);if(a!==t.length-1)s&&null===i&&(i=a);else{if(!s)return;null===i?r.push(`M${a+e},${n+e} h1v1H${a+e}z`):r.push(`M${i+e},${n+e} h${a+1-i}v1H${i+e}z`)}}))})),r.join("")}function vp(t,e){return t.slice().map(((t,r)=>r<e.y||r>=e.y+e.h?t:t.map(((t,r)=>(r<e.x||r>=e.x+e.w)&&t))))}function wp({value:t,level:r,minVersion:n,includeMargin:i,marginSize:s,imageSettings:a,size:o,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...up.QrSegment.makeSegments(e)),t)),[]);return up.QrCode.encodeSegments(e,hp[r],n,void 0,void 0,l)}),[t,r,n,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),r=t.length+2*e,n=function(t,e,r,n){if(null==n)return null;const i=t.length+2*r,s=Math.floor(.1*e),a=i/e,o=(n.width||s)*a,l=(n.height||s)*a,c=null==n.x?t.length/2-o/2:n.x*a,u=null==n.y?t.length/2-l/2:n.y*a,h=null==n.opacity?1:n.opacity;let d=null;if(n.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(o+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:o,excavation:d,opacity:h,crossOrigin:n.crossOrigin}}(t,o,e,a);return{cells:t,margin:e,numCells:r,calculatedImageSettings:n}}),[c,o,a,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var bp=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,r){const n=t,{value:i,size:s=dp,level:a=pp,bgColor:o=fp,fgColor:l=gp,includeMargin:c=mp,minVersion:u=yp,boostLevel:h,marginSize:d,imageSettings:p}=n,f=cp(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=cp(f,["style"]),y=null==p?void 0:p.src,_=e.useRef(null),v=e.useRef(null),w=e.useCallback((t=>{_.current=t,"function"==typeof r?r(t):r&&(r.current=t)}),[r]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=wp({value:i,level:a,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 r=x;const n=v.current,i=null!=S&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;i&&null!=S.excavation&&(r=vp(x,S.excavation));const a=window.devicePixelRatio||1;t.height=t.width=s*a;const c=s/k*a;e.scale(c,c),e.fillStyle=o,e.fillRect(0,0,k,k),e.fillStyle=l,bp?e.fill(new Path2D(_p(r,E))):x.forEach((function(t,r){t.forEach((function(t,n){t&&e.fillRect(n+E,r+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(n,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[y]);const N=lp({height:s,width:s},g);let P=null;return null!=y&&(P=e.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{A(!0)},ref:v,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",lp({style:N,height:s,width:s,ref:w,role:"img"},m)),P)})).displayName="QRCodeCanvas";var Ap=e.forwardRef((function(t,r){const n=t,{value:i,size:s=dp,level:a=pp,bgColor:o=fp,fgColor:l=gp,includeMargin:c=mp,minVersion:u=yp,boostLevel:h,title:d,marginSize:p,imageSettings:f}=n,g=cp(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:y,numCells:_,calculatedImageSettings:v}=wp({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let w=y,b=null;null!=f&&null!=v&&(null!=v.excavation&&(w=vp(y,v.excavation)),b=e.createElement("image",{href:f.src,height:v.h,width:v.w,x:v.x+m,y:v.y+m,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const A=_p(w,m);return e.createElement("svg",lp({height:s,width:s,viewBox:`0 0 ${_} ${_}`,ref:r,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));Ap.displayName="QRCodeSVG";const Ep=({walletAddress:t,amount:r,currency:n,network:i,theme:s="light",size:a=200})=>{const[o,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"tron":e="TRX"===n?`tronlink://transfer?to=${t}&amount=${r}`:t;break;case"algorand":e=`algorand://${t}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)e=`ethereum:${t}@56?value=${p(r)}`;else{const i=h(n,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}@56`:t}break;default:if("ETH"===n)e=`ethereum:${t}@1?value=${p(r)}`;else{const i=h(n,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}`:t}}l(e),u(null)}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,r,n,i]);const h=(t,e)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:r[t])||""},d=(t,e)=>{const r="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,r)).toString()},p=t=>Math.floor(1e18*parseFloat(t)).toString(),f=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Zd.jsxs("div",{className:"flex flex-col items-center",children:[c?Zd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Zd.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:Zd.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"})}),Zd.jsx("p",{className:"font-medium",children:c})]}):Zd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:o&&Zd.jsx(Ap,{value:o,size:a,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Zd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Zd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Zd.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:Zd.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 ",n]}),Zd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(i)," wallet app"]})]}),Zd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Zd.jsxs("div",{className:"flex justify-between items-center",children:[Zd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Zd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),Zd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Zd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Zd.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(i)})]})]}),!c&&Zd.jsxs("div",{className:"w-full mb-4",children:[Zd.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),Zd.jsx("div",{className:"text-xs font-mono p-2 rounded bg-gray-100 text-gray-700 break-all text-center select-all cursor-pointer border",onClick:()=>{var e;return null==(e=navigator.clipboard)?void 0:e.writeText(t)},title:"Click to copy",children:t})]}),Zd.jsx("div",{className:"w-full",children:Zd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Zd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Zd.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:Zd.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"]}),Zd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Zd.jsxs("li",{children:["1. Open your crypto wallet app (",(g=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[g]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Zd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Zd.jsxs("li",{children:["3. Send exactly ",Zd.jsxs("strong",{children:[r," ",n]})," on ",f(i)," network"]}),Zd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Zd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Zd.jsxs("p",{className:"text-xs text-yellow-800",children:[Zd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(i),") and using the exact amount shown above."]})})]})})]});var g},xp=({status:t,message:r,theme:n="light",payment:i=null,transactionHash:s=null,selectedPaymentMethod:a=null,merchantName:o="Merchant",onClose:l=null,processingStartTime:c=null,paymentNetwork:u=null})=>{const[h,d]=e.useState(!1),[p,f]=e.useState(0),[g,m]=e.useState(!1),[y,_]=e.useState(1);e.useEffect((()=>{let e;return"processing"===t&&c&&(e=setInterval((()=>{const t=Math.floor((Date.now()-c)/1e3);f(t),t>=5&&1===y&&_(2),t>=15&&2===y&&_(3),t>=30&&!g&&m(!0)}),1e3)),()=>clearInterval(e)}),[t,c,y,g]);const v=()=>__async(this,null,(function*(){if(s)try{yield navigator.clipboard.writeText(s),d(!0),setTimeout((()=>d(!1)),2e3)}catch(t){console.error("Failed to copy transaction hash:",t)}})),w=()=>{console.log("Payment success screen close button clicked"),l&&l()},b=()=>{l&&l()},A=t=>t?t.length<=16?t:`${t.slice(0,8)}...${t.slice(-8)}`:"",E=t=>({ethereum:"1-2 minutes",bsc:"15-30 seconds",tron:"30-60 seconds",algorand:"5-10 seconds",solana:"10-15 seconds"}[t]||"1-2 minutes"),x=t=>{const e=t%60;return`${Math.floor(t/60)}:${e<10?"0":""}${e}`},k=()=>{switch(t){case"processing":return Zd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Zd.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center",children:Zd.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:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Zd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Zd.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:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}},S=()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}},N=()=>{switch(t){case"processing":return"dark"===n?"text-blue-300":"text-blue-600";case"success":return"dark"===n?"text-green-300":"text-green-600";case"error":return"dark"===n?"text-red-300":"text-red-600";default:return"dark"===n?"text-gray-300":"text-gray-600"}};return"success"===t?Zd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Zd.jsx("div",{className:"mb-6",children:k()}),Zd.jsx("h3",{className:"text-2xl font-bold mb-3 "+("dark"===n?"text-white":"text-gray-900"),children:"Payment Successful"}),i&&a&&Zd.jsxs("p",{className:"text-center mb-6 "+("dark"===n?"text-gray-300":"text-gray-600"),children:["Your payment of ",i.totalAmount||i.amount," ",a.currency," has been completed."]}),s&&Zd.jsxs("div",{className:"w-full mb-6",children:[Zd.jsx("p",{className:"text-sm font-medium mb-2 "+("dark"===n?"text-gray-300":"text-gray-700"),children:"Transaction Hash:"}),Zd.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors "+("dark"===n?"bg-gray-700 border-gray-600 hover:bg-gray-600":"bg-gray-50 border-gray-200 hover:bg-gray-100"),onClick:v,children:[Zd.jsx("span",{className:"font-mono text-sm "+("dark"===n?"text-gray-300":"text-gray-700"),children:A(s)}),Zd.jsxs("div",{className:"flex items-center",children:[h?Zd.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Zd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 "+("dark"===n?"text-gray-400":"text-gray-500"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Zd.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"})})]})]})]}),Zd.jsx("div",{className:"w-full p-4 rounded-lg border mb-6 "+("dark"===n?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:Zd.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[Zd.jsxs("div",{children:[Zd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===n?"text-gray-400":"text-gray-500"),children:"Merchant ID:"}),Zd.jsx("p",{className:"text-sm font-medium "+("dark"===n?"text-gray-300":"text-gray-700"),children:o})]}),Zd.jsxs("div",{children:[Zd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===n?"text-gray-400":"text-gray-500"),children:"Network:"}),Zd.jsx("p",{className:"text-sm font-medium "+("dark"===n?"text-gray-300":"text-gray-700"),children:a?(C=a.network,{ethereum:"Ethereum",bsc:"BSC",tron:"TRON",algorand:"Algorand"}[C]||C):"N/A"})]}),Zd.jsxs("div",{className:"col-span-2",children:[Zd.jsx("p",{className:"text-xs font-medium mb-1 "+("dark"===n?"text-gray-400":"text-gray-500"),children:"Recipient:"}),Zd.jsx("p",{className:"text-sm font-mono "+("dark"===n?"text-gray-300":"text-gray-700"),children:(null==i?void 0:i.recipientWallet)?(P=i.recipientWallet,P?P.length<=16?P:`${P.slice(0,6)}...${P.slice(-4)}`:"N/A"):"N/A"})]})]})}),l&&Zd.jsx("button",{onClick:w,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"})]}):"processing"===t?Zd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Zd.jsx("div",{className:"mb-4",children:k()}),Zd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===n?"text-white":"text-gray-900"),children:S()}),Zd.jsx("p",{className:`text-center ${N()}`,children:r}),Zd.jsx("div",{className:"w-full mt-6 mb-2",children:Zd.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5",children:Zd.jsx("div",{className:"bg-blue-600 h-2.5 rounded-full transition-all duration-500",style:{width:`${Math.min(100,y/3*100)}%`}})})}),Zd.jsxs("div",{className:"w-full grid grid-cols-3 gap-1 mb-4",children:[Zd.jsx("div",{className:"text-xs text-center "+(y>=1?"text-blue-600 font-medium":"text-gray-400"),children:"Submitted"}),Zd.jsx("div",{className:"text-xs text-center "+(y>=2?"text-blue-600 font-medium":"text-gray-400"),children:"Detected"}),Zd.jsx("div",{className:"text-xs text-center "+(y>=3?"text-blue-600 font-medium":"text-gray-400"),children:"Confirming"})]}),s&&Zd.jsxs("div",{className:"w-full my-3 px-4",children:[Zd.jsx("p",{className:"text-xs text-center text-gray-600 mb-2",children:"Transaction ID:"}),Zd.jsx("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-2 text-center",children:Zd.jsx("span",{className:"text-xs font-mono text-gray-700",children:A(s)})})]}),u&&Zd.jsxs("div",{className:"w-full mt-4 mb-2 p-3 bg-blue-50 rounded-md text-center",children:[Zd.jsxs("p",{className:"text-xs text-blue-800",children:[Zd.jsx("span",{className:"font-medium",children:"Estimated confirmation time:"})," ",E(u)]}),Zd.jsxs("p",{className:"text-xs text-blue-600 mt-1",children:["Processing time: ",x(p)]})]}),g&&l&&Zd.jsxs("div",{className:"w-full mt-4",children:[Zd.jsx("div",{className:"mb-2 p-3 bg-yellow-50 rounded-md",children:Zd.jsx("p",{className:"text-xs text-center text-yellow-800",children:"Taking longer than expected? Your payment may already be complete. You can proceed now or continue waiting for confirmation."})}),Zd.jsx("button",{onClick:b,className:"w-full py-2 px-4 bg-gray-200 text-purple-600 font-medium rounded-md hover:bg-gray-300 transition-colors",children:"Continue to Order Confirmation"})]}),Zd.jsx("div",{className:"mt-4 text-xs "+("dark"===n?"text-gray-400":"text-gray-500"),children:"Blockchain transactions can take a few moments to confirm. Please wait..."})]}):"error"===t?Zd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Zd.jsx("div",{className:"mb-4",children:k()}),Zd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===n?"text-white":"text-gray-900"),children:"Payment Failed"}),Zd.jsx("p",{className:`text-center ${N()}`,children:r}),Zd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===n?"bg-gray-700":"bg-gray-100"),children:Zd.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-600"),children:"Please try again or contact support if the problem persists."})})]}):Zd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Zd.jsx("div",{className:"mb-4",children:k()}),Zd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===n?"text-white":"text-gray-900"),children:S()}),Zd.jsx("p",{className:`text-center ${N()}`,children:r})]});var P,C},kp=({onSelect:t,selected:r,theme:n="light",supportedNetworks:i=[]})=>{var s,a,o;const[l,c]=e.useState(md.ETHEREUM),[u,h]=e.useState(null),[d,p]=e.useState({}),[f,g]=e.useState(!1),m=[{id:md.ETHEREUM,name:"Ethereum",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/liznxm8l7iouudtrxdpi.png"},{id:md.TRON,name:"Tron",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/mpxxns6gtfiws4rlouxc.png"},{id:md.ALGORAND,name:"Algorand",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/x2lugizoduiphuqn0dej.png"},{id:"solana",name:"Solana",icon:" https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962845/coinley/hmex6qxnlid1gboh4cwc.png"},{id:md.BSC,name:"Binance Smart Chain",icon:"https://res.cloudinary.com/do3tlu1ph/image/upload/v1748962844/coinley/eoavfddfqmt7qgajjxvb.png"}],[y,_]=e.useState(!1),v=e.useRef(null);e.useEffect((()=>{function t(t){v.current&&!v.current.contains(t.target)&&_(!1)}return y?document.addEventListener("mousedown",t):document.removeEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)}),[y]),e.useEffect((()=>{p(bd())}),[]);const w=(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:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",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:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",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})(l),b=f?w:w.slice(0,4);function A(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 Zd.jsxs("div",{className:"",children:[Zd.jsxs("div",{className:"mb-6",children:[Zd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),Zd.jsxs("div",{className:"relative",ref:v,children:[Zd.jsxs("button",{type:"button",className:"w-full flex items-center justify-between px-5 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:()=>_((t=>!t)),style:{minHeight:"56px"},children:[Zd.jsxs("span",{className:"flex items-center gap-3",children:[Zd.jsx("img",{src:null==(s=m.find((t=>t.id===l)))?void 0:s.icon,alt:null==(a=m.find((t=>t.id===l)))?void 0:a.name,className:"w-6 h-6"}),Zd.jsx("span",{className:"text-base font-normal",children:null==(o=m.find((t=>t.id===l)))?void 0:o.name})]}),Zd.jsx("svg",{className:"w-5 h-5 ml-2 transition-transform "+(y?"rotate-180":""),fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),y&&Zd.jsx("div",{className:"absolute left-0 mt-2 w-full bg-white rounded-2xl shadow-lg border border-gray-100 z-20",style:{minWidth:"100%"},children:m.filter((t=>0===i.length||i.includes(t.id))).map((t=>Zd.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 px-5 py-3 text-gray-900 text-base font-normal rounded-2xl transition hover:bg-gray-100 "+(l===t.id?"bg-gray-50":""),onClick:()=>{var e;_(!1),e=t.id,c(e),g(!1),h(null)},style:{minHeight:"48px"},children:[Zd.jsx("img",{src:t.icon,alt:t.name,className:"w-6 h-6"}),Zd.jsx("span",{children:t.name})]},t.id)))})]})]}),Zd.jsxs("div",{className:"mb-4",children:[Zd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Select Stablecoin"}),Zd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:b.map((t=>{const e=(null==u?void 0:u.currency)===t.id&&(null==u?void 0:u.network)===l;return Zd.jsxs("button",{onClick:()=>(t=>{var e;const r={currency:t.id,network:l,tokenConfig:null==(e=_d[t.id])?void 0:e[l],method:t};h(r)})(t),className:`group flex items-center justify-between w-full px-5 py-4 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"},children:[Zd.jsxs("span",{className:"flex items-center gap-3",children:[Zd.jsx("img",{src:t.logo,alt:t.name,className:"h-6 w-6"}),Zd.jsxs("span",{className:"font-medium text-base text-gray-900",children:[t.description," (",t.name,")"]})]}),e&&Zd.jsx("span",{className:"ml-2 flex items-center justify-center w-6 h-6 rounded-full bg-[#7042D2]",children:Zd.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Zd.jsx("path",{d:"M4 8.5L7 11.5L12 6.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},`${t.id}-${t.network}`)}))}),w.length>4&&Zd.jsx("button",{onClick:()=>g(!f),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===n?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:f?"Show Less":`Show More (${w.length-4} more)`})]}),Zd.jsx("div",{className:"p-3 rounded-lg text-sm mb-6 "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Zd.jsxs("div",{className:"flex items-center",children:[Zd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(d[A(l)]?"bg-green-500":"bg-red-500")}),Zd.jsx("span",{className:"text-xs",children:function(t){const e=A(t),r=d[e],n={[gd.METAMASK]:"MetaMask",[gd.TRONLINK]:"TronLink",[gd.TRUST_WALLET]:"Trust Wallet",[gd.LUTE]:"Lute Wallet"};return r?`${n[e]} detected - Ready to pay`:`${n[e]} required - Please install to continue`}(l)})]})}),Zd.jsx("button",{onClick:()=>{u&&t(u)},disabled:!u,className:"w-full py-3 px-4 font-medium rounded-2xl text-lg shadow-md transition-colors "+(u?"bg-[#7042D2] text-white hover:bg-[#5b34b1]":"bg-gray-300 text-gray-500 cursor-not-allowed"),style:{borderRadius:"1.5rem"},children:"Proceed"})]})},Sp=({isOpen:t,onClose:r,payment:n,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:a,onPayment:o,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:y={},supportedWallets:_=[],step:v="select-currency",merchantWalletAddresses:w={},debug:b=!1,processingStartTime:A=null,transactionDetected:E=!1,paymentNetwork:x=null,onEarlySuccess:k=null})=>{const[S,N]=e.useState("wallet"),P=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),T=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?Zd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:Zd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Zd.jsxs("div",{className:"coinley-modal relative p-6 max-w-[490px] mx-auto rounded-3xl shadow-xl bg-gray-100",style:{maxWidth:"490px !important",width:"100% !important",minWidth:"320px !important"},children:[Zd.jsxs("div",{className:"bg-white flex justify-between items-center mb-6 py-4 px-2 rounded-full",children:[Zd.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Zd.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"}),Zd.jsx("span",{className:"text-lg font-semibold text-gray-800",children:"Payment Details"})]}),"success"!==v&&"processing"!==v&&Zd.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Zd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),n&&"success"!==v&&Zd.jsx("div",{className:"mb-6",children:Zd.jsxs("div",{className:"text-center",children:[Zd.jsx("div",{className:"text-sm text-gray-600",children:"Total amount"}),Zd.jsxs("div",{className:"coinley-amount-display text-5xl font-bold text-[#7042D2] mt-2",children:["$",(R=n.totalAmount||n.amount,parseFloat(R).toFixed(2))]}),Zd.jsx("div",{className:"text-sm text-gray-600 mt-4",children:"Payment to:"}),Zd.jsx("div",{className:"coinley-merchant-name text-base font-semibold mt-1",children:h})]})}),"select-currency"===v&&Zd.jsx("div",{className:"mb-6",children:Zd.jsx(kp,{onSelect:a,selected:s,theme:u,supportedNetworks:m})}),"confirm"===v&&s&&n&&Zd.jsxs("div",{children:[Zd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Zd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Zd.jsxs("div",{className:"space-y-2",children:[Zd.jsxs("div",{className:"flex justify-between",children:[Zd.jsx("span",{className:"text-purple-600 font-semibold",children:"Currency:"}),Zd.jsx("span",{className:"font-medium",children:s.currency})]}),Zd.jsxs("div",{className:"flex justify-between",children:[Zd.jsx("span",{className:"text-purple-600 font-semibold",children:"Network:"}),Zd.jsx("span",{className:"font-medium",children:P(s.network)})]}),Zd.jsxs("div",{className:"flex justify-between",children:[Zd.jsx("span",{className:"text-purple-600 font-semibold",children:"Fee:"}),Zd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Zd.jsx("div",{className:"mb-4",children:Zd.jsxs("div",{className:"flex border-b border-gray-200",children:[Zd.jsx("button",{onClick:()=>N("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===S?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Zd.jsx("button",{onClick:()=>N("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===S?"border-b-2 border-purple-600 text-purple-600":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Zd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Zd.jsxs("div",{className:"flex items-center",children:[Zd.jsx("div",{className:"bg-purple-600 rounded-full p-2 mr-3",children:Zd.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:Zd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Zd.jsxs("div",{children:[Zd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Zd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===S?Zd.jsx("div",{className:"mb-4",children:Zd.jsx(Ep,{walletAddress:(()=>{if(!s)return"No network selected";const t=w[s.network];return t||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:s.currency,network:s.network,theme:u})}):Zd.jsxs("div",{className:"space-y-3 mb-4",children:[0===_.length?Zd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Zd.jsxs("div",{className:"flex items-center",children:[Zd.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:Zd.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"})}),Zd.jsxs("div",{children:[Zd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Zd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",P(s.network)," network"]})]})]})}):_.map((t=>Zd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Zd.jsxs("div",{className:"flex items-center justify-between",children:[Zd.jsxs("div",{className:"flex items-center",children:[Zd.jsx("img",{src:T(t),alt:C(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Zd.jsxs("div",{children:[Zd.jsx("h3",{className:"font-medium text-gray-800",children:C(t)}),Zd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",C(t)]})]})]}),(null==p?void 0:p.walletType)===t?Zd.jsxs("div",{className:"flex items-center space-x-2",children:[Zd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Zd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Zd.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))),Zd.jsx("div",{className:"space-y-2",children:Object.entries(y).filter((([t,e])=>!e)).map((([t])=>Zd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Zd.jsxs("div",{className:"flex items-center justify-between",children:[Zd.jsxs("span",{className:"text-sm text-gray-600",children:[C(t)," not detected"]}),Zd.jsx("a",{href:wd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-purple-600 hover:underline",children:"Install"})]})},t)))})]}),c&&Zd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Zd.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[Zd.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"}),Zd.jsx("button",{type:"button",onClick:()=>o("qrcode"===S),className:"coinley-button-primary w-full py-2 px-4 font-medium rounded-md",disabled:!g&&"wallet"===S&&!p,children:"qrcode"===S?"I have sent the payment":"Pay Now"})]})]}),"processing"===v&&Zd.jsx(xp,{status:"processing",theme:u,message:E?"Transaction detected! Waiting for blockchain confirmation...":"Processing your payment...",processingStartTime:A,paymentNetwork:x||(null==s?void 0:s.network),transactionHash:d,onEarlySuccess:()=>{console.log("Early success button clicked"),k&&k()}}),"success"===v&&Zd.jsx(xp,{status:"success",theme:u,message:"Payment successful!",payment:n,transactionHash:d,selectedPaymentMethod:s,merchantName:h,onClose:()=>{console.log("Success screen close button clicked"),r&&r()}}),"error"===v&&Zd.jsxs("div",{children:[Zd.jsx(xp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Zd.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"!==v&&Zd.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 mt-6",children:[Zd.jsxs("p",{children:["Powered by ",Zd.jsx("span",{className:"text-purple-600",children:"Coinley"})," - Secure Cryptocurrency Payments"]}),Zd.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:[Zd.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Zd.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})}):null;var R},Np=e.forwardRef((({apiKey:t,apiSecret:r,apiUrl:n,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:a={},onSuccess:o,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:_=!1},v)=>{const w=tp(),{theme:b}=e.useContext(Xd),[A,E]=e.useState(h),[x,k]=e.useState(null),[S,N]=e.useState("idle"),[P,C]=e.useState(null),[T,R]=e.useState(null),[M,G]=e.useState(null),[B,I]=e.useState(null),[O,F]=e.useState({}),[U,L]=e.useState("select-currency"),[D,j]=e.useState({}),[H,W]=e.useState(null),[Q,z]=e.useState(!1),[V,K]=e.useState(null),J=e.useRef(null),q=t||(null==w?void 0:w.apiKey),Y=r||(null==w?void 0:w.apiSecret);n||null==w||w.apiUrl;const Z=u||b,X=d||(null==w?void 0:w.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&&Y&&(()=>{__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(a)}}))})()}),[q,Y,a]),e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield Ad(3,1e3);F(t),tt("Available wallets detected:",t)})))()}}),[X]),e.useEffect((()=>()=>{J.current&&clearTimeout(J.current),V&&clearInterval(V)}),[V]),e.useEffect((()=>{if(M&&"loading"===S&&"processing"===U&&!V&&(z(!0),!p)){const t=setInterval((()=>__async(this,null,(function*(){try{const e=Date.now()-H;if(_&&e>et())return tt("Fast mode: Moving to success state early"),clearInterval(t),K(null),void rt()}catch(e){tt("Error checking transaction status:",e)}}))),5e3);K(t)}return()=>{V&&clearInterval(V)}}),[M,S,U,p,H,_]);const et=()=>{if(!P)return 2e4;return{[md.ETHEREUM]:15e3,[md.BSC]:1e4,[md.TRON]:8e3,[md.ALGORAND]:5e3}[P.network]||15e3},rt=()=>__async(this,null,(function*(){if(x&&P&&M){tt("Moving to early success state with transaction:",M);try{const t=yield jd({paymentId:x.id,transactionHash:M,network:P.network,currency:P.currency,senderAddress:null==B?void 0:B.address,early:!0});tt("Early payment processed:",t),N("success"),L("success"),o&&o(x.id,M,{network:P.network,currency:P.currency,amount:x.totalAmount||x.amount})}catch(t){tt("Early success processing error:",t)}}}));e.useImperativeHandle(v,(()=>({open:t=>{nt(t)},close:()=>{it()},getPayment:()=>x,getWalletConnection:()=>B,debugWallets:()=>(()=>{var t;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"),"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});const e=bd();console.log("Detected wallets:",e)})(),getMerchantWallets:()=>D})));const nt=t=>__async(this,null,(function*(){if(!t||!t.amount)return R("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));N("loading"),E(!0),L("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 r=yield Dd({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:",r),k(r.payment),N("idle"),R(null),tt("Payment created and state updated")}catch(e){tt("Error creating payment:",e),R(e.message||"Failed to create payment"),N("error"),l&&l(e)}})),it=()=>{V&&(clearInterval(V),K(null)),J.current&&(clearTimeout(J.current),J.current=null),E(!1),G(null),I(null),C(null),L("select-currency"),W(null),z(!1),c&&c()};return Zd.jsx(Zd.Fragment,{children:A&&Zd.jsx(Sp,{isOpen:A,onClose:it,payment:x,paymentStatus:S,selectedPaymentMethod:P,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",U),tt("Payment method selected:",t),C(t),L("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&&P)if(B||p){tt("Starting payment process..."),N("loading"),G(null),L("processing"),W(Date.now()),z(!1);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,2e3)));else{let r;if(x.recipientWallet)r=x.recipientWallet;else{if(!D[P.network])throw new Error(`No merchant wallet address found for ${P.network} network`);r=D[P.network]}tt("Using merchant address for payment:",r),tt("Sending transaction through wallet..."),n=yield Td(B,{to:r,amount:x.totalAmount||x.amount,tokenAddress:null==(t=P.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=P.tokenConfig)?void 0:e.decimals,currency:P.currency,network:P.network})}if(tt("Transaction hash:",n),G(n),p)return void(J.current=setTimeout((()=>{tt("Test mode: Moving to success state"),N("success"),L("success"),o&&(tt("Calling onSuccess callback..."),o(x.id,n,{network:P.network,currency:P.currency,amount:x.totalAmount||x.amount}))}),2e3));try{tt("Processing payment with backend...");const t=yield jd({paymentId:x.id,transactionHash:n,network:P.network,currency:P.currency,senderAddress:null==B?void 0:B.address,confirmations:y});tt("Payment processed successfully:",t),N("success"),L("success"),o&&(tt("Calling onSuccess callback..."),o(x.id,n,{network:P.network,currency:P.currency,amount:x.totalAmount||x.amount}))}catch(r){tt("Payment processing error, but transaction was sent:",r)}}catch(n){tt("Payment error:",n),R(n.message||"Failed to process payment"),N("error"),L("error"),l&&l(n)}}else R("Please connect your wallet first");else R("Missing payment information")})),onBack:()=>{"confirm"===U?(L("select-currency"),I(null)):"error"===U&&L("confirm")},error:T,theme:Z,merchantName:s,transactionHash:M,walletConnection:B,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:",P),console.log("3. Available wallets:",O),console.log("4. Current step:",U),!P)return console.error("No payment method selected"),void R("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),R(null),tt("Connecting wallet:",{walletType:t,network:P.network});const e=yield Nd(t,P.network);I(e),R(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),R(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:$,availableWallets:O,supportedWallets:P?Pd(P.network):[],step:U,merchantWalletAddresses:D,debug:X,processingStartTime:H,transactionDetected:Q,paymentNetwork:null==P?void 0:P.network,onEarlySuccess:rt})})}));Np.displayName="CoinleyCheckout";t.CoinleyCheckout=Np,t.CoinleyModal=Sp,t.CoinleyProvider=({apiKey:t,apiSecret:r,apiUrl:n="https://coinleyserver-production.up.railway.app",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:a=!1,children:o})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null),[f,g]=e.useState({});e.useEffect((()=>{if(!t||!r)return void h("API key and secret are required");(()=>{__async(this,null,(function*(){try{yield Od({apiKey:t,apiSecret:r,apiUrl:n,debug:a});const e=yield Ud(),o=__spreadValues(__spreadValues(__spreadValues({},e),i&&{ethereum:i}),s&&{solana:s});g(o),c(!0),a&&console.log("Coinley SDK initialized successfully with wallets:",o)}catch(e){h(e.message),a&&console.error("Coinley SDK initialization error:",e)}}))})()}),[t,r,n,i,s,a]);const m={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s,merchantWallets:f,isInitialized:l,error:u,debug:a,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 Zd.jsx($d.Provider,{value:m,children:o})},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=kp,t.PaymentStatus=xp,t.QRCode=Ep,t.TOKEN_CONFIG=_d,t.ThemeProvider=({initialTheme:t="light",children:r})=>{const[n,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),Zd.jsx(Xd.Provider,{value:{theme:n,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:r})},t.WALLET_TYPES=gd,t.connectWallet=Nd,t.createPayment=Dd,t.detectWallets=bd,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 r=yield fetch(`${Id.apiUrl}/api/payments/${t}`,{method:"GET",headers:Ld()});if(!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to get payment: ${r.status} ${r.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${r.status}`)}const n=yield r.json();return console.log("Get payment response:",n),n}catch(r){throw console.error("Get payment error:",r),r}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Id.apiUrl}/api/networks`,{method:"GET",headers:Ld()});if(!e.ok){let r;try{r=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(r.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=wd,t.processPayment=jd,t.sendTransaction=Td,t.useCoinley=tp,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const n=yield fetch(`${Id.apiUrl}/api/wallets/validate`,{method:"POST",headers:Ld(),body:JSON.stringify({address:t,network:e})});if(!n.ok){let t;try{t=yield n.json()}catch(r){throw new Error(`Failed to validate address: ${n.status} ${n.statusText}`)}throw new Error(t.error||`Failed to validate address: ${n.status}`)}return yield n.json()}catch(n){throw console.error("Validate wallet address error:",n),n}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
17
17
|
//# sourceMappingURL=coinley-checkout.umd.js.map
|