coinley-checkout 0.4.6 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coinley-checkout.es.js +6120 -16926
- package/dist/coinley-checkout.es.js.map +1 -1
- package/dist/coinley-checkout.umd.js +3 -12
- package/dist/coinley-checkout.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +5 -3
@@ -1,17 +1,8 @@
|
|
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,A,b,E,x,k,S,N,P,C,T,R,G,M,I,B,O,F,U,L,D,j,H,W,Q,z,V,J,K,q,Z,Y,X,$,tt,et,rt,nt,it,st,at,ot,lt,ct,ut,ht,dt,pt,ft,gt,mt,_t,yt,vt,wt,At,bt,Et,xt,kt,St,Nt,Pt,Ct,Tt,Rt,Gt,Mt,It,Bt,Ot,Ft,Ut,Lt,Dt,jt,Ht,Wt,Qt,zt,Vt,Jt,Kt,qt,Zt,Yt,Xt,$t,te,ee,re,ne,ie,se,ae,oe,le,ce,ue,he,de,pe,fe,ge,me,_e,ye,ve,we,Ae,be,Ee,xe,ke,Se,Ne,Pe,Ce,Te,Re,Ge,Me,Ie,Be,Oe,Fe,Ue,Le,De,je,He,We,Qe,ze,Ve,Je,Ke,qe,Ze,Ye,Xe,$e,tr,er,rr,nr,ir,sr,ar,or,lr,cr,ur,hr,dr,pr,fr,gr,mr,_r,yr,vr,wr,Ar,br,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 Gr(t,e){return t&&t.code===e}function Mr(t){return Gr(t,"CALL_EXCEPTION")}function Ir(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 Br(t,e,r,n){if(!t)throw Ir(e,r,n)}function Or(t,e,r,n){Br(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}function Fr(t,e,r){null==r&&(r=""),r&&(r=": "+r),Br(t>=e,"missing argument"+r,"MISSING_ARGUMENT",{count:t,expectedCount:e}),Br(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),Br(!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 Jr(t){return"0x"+t.map((t=>Vr(t).substring(2))).join("")}function Kr(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&&Br(!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 Zr(t,e,r){const n=jr(t);Br(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 Yr(t,e){return Zr(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(Br(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,Br(r<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return(~r&($r<<n)-$r)+$r}return Br(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 Br(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(Br(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){Br(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*(){Br(null==r||!r.cancelled,"request cancelled before sending","CANCELLED");const n=e.url.split(":")[0].toLowerCase();Br("http"===n||"https"===n,`unsupported protocol ${n}`,"UNSUPPORTED_OPERATION",{info:{protocol:n},operation:"request"}),Br("https"===n||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const s=new AbortController,a=setTimeout((()=>{i=Ir("request timeout","TIMEOUT"),s.abort()}),e.timeout);r&&r.addListener((()=>{i=Ir("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 An=wn();const bn=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(bn);if(!e)throw new Error("invalid data");return new In(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 In(599,"BAD REQUEST (invalid data: URI)",{},null,new Gn(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 Gn(`${t}${r[2]}`)}catch(r){return new In(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Gn(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){Br(!__privateGet(this,i),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),__privateGet(this,n).push(t)}get cancelled(){return __privateGet(this,i)}checkSignal(){Br(!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)||An}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 Br(null==__privateGet(this,_),"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),__privateSet(this,_,new Cn(this)),__privateMethod(this,w,A).call(this,0,Bn()+this.timeout,0,this,new In(0,"",{},null,this))}cancel(){Br(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();Br("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");An=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,A=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");Br(Bn()<=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 In){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 In(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,A).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,A).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,A).call(o,t+1,e,r,n,h)}}return h}))};let Gn=Rn;const Mn=class t{constructor(t,e,r,n,i){__privateAdd(this,b,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,b,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,b)}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){Br(!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){Br(!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){}Br(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:n,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};b=new WeakMap,E=new WeakMap,x=new WeakMap,k=new WeakMap,S=new WeakMap,N=new WeakMap;let In=Mn;function Bn(){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;Br(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;Br(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,M),__privateAdd(this,B),__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,B,O).call(this,t)}add(t){return __privateMethod(this,B,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,G).call(this,t);const e=__privateGet(this,C)*__privateGet(t,C);return Br(e%__privateGet(this,T)===Fn,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,M,I).call(this,e/__privateGet(this,T),"mulSignal")}divUnsafe(t){return __privateMethod(this,j,H).call(this,t)}div(t){return __privateMethod(this,j,H).call(this,t,"div")}divSignal(t){Br(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,G).call(this,t);const e=__privateGet(this,C)*__privateGet(this,T);return Br(e%__privateGet(t,C)===Fn,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,M,I).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,M,I).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,M,I).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);Br(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;Br(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,G=function(t){Or(this.format===t.format,"incompatible format; use fixedNumber.toFormat","other",t)},M=new WeakSet,I=function(t,e){return t=Wn(t,__privateGet(this,P),e),new zn(Dn,t,__privateGet(this,P))},B=new WeakSet,O=function(t,e){return __privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)+__privateGet(t,C),e)},F=new WeakSet,U=function(t,e){return __privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)-__privateGet(t,C),e)},L=new WeakSet,D=function(t,e){return __privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)*__privateGet(t,C)/__privateGet(this,T),e)},j=new WeakSet,H=function(t,e){return Br(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)*__privateGet(this,T)/__privateGet(t,C),e)};let Vn=zn;function Jn(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Kn(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=Zn(t,r);i.push(s.result),Br((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 Zn(t,e){Br(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const r=e=>{Br(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=Kn(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=Kn(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:Jn(t[e])}}function Yn(t){const e=jr(t,"data"),r=Zn(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){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}function ii(t){return ni(t,18)}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)=>(Br(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 Br(e.length<=si,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:si,offset:e.length}),e.length!==si&&(e=Hr(Jr([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 Jr(__privateGet(this,Q))}get length(){return __privateGet(this,z)}appendWriter(t){return __privateMethod(this,V,J).call(this,Hr(t.data))}writeBytes(t){let e=Hr(t);const r=e.length%si;return r&&(e=Hr(Jr([e,ai.slice(r)]))),__privateMethod(this,V,J).call(this,e)}writeValue(t){return __privateMethod(this,V,J).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,J=function(t){return __privateGet(this,Q).push(t),__privateSet(this,z,__privateGet(this,z)+t.length),t.length};K=new WeakMap,q=new WeakMap,Z=new WeakMap,Y=new WeakMap,X=new WeakMap,$=new WeakSet,tt=function(t){var e;if(__privateGet(this,Y))return __privateMethod(e=__privateGet(this,Y),$,tt).call(e,t);__privateSet(this,Z,__privateGet(this,Z)+t),Br(__privateGet(this,X)<1||__privateGet(this,Z)<=__privateGet(this,X)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${__privateGet(this,X)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Hr(__privateGet(this,K)),offset:__privateGet(this,q),length:t,info:{bytesRead:__privateGet(this,Z),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,K).length&&(this.allowLoose&&r&&__privateGet(this,q)+e<=__privateGet(this,K).length?n=e:Br(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Hr(__privateGet(this,K)),length:__privateGet(this,K).length,offset:__privateGet(this,q)+n})),__privateGet(this,K).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,K,void 0),__privateAdd(this,q,void 0),__privateAdd(this,Z,void 0),__privateAdd(this,Y,void 0),__privateAdd(this,X,void 0),Tr(this,{allowLoose:!!e}),__privateSet(this,K,Hr(t)),__privateSet(this,Z,0),__privateSet(this,Y,null),__privateSet(this,X,null!=r?r:1024),__privateSet(this,q,0)}get data(){return Vr(__privateGet(this,K))}get dataLength(){return __privateGet(this,K).length}get consumed(){return __privateGet(this,q)}get bytes(){return new Uint8Array(__privateGet(this,K))}subReader(e){const r=new t(__privateGet(this,K).slice(__privateGet(this,q)+e),this.allowLoose,__privateGet(this,X));return __privateSet(r,Y,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 Ai(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 bi(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 Ai(this),this.iHash.update(t),this}digestInto(t){Ai(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 Gi=(t,e,r)=>new Ri(t,e).update(r).digest();Gi.create=(t,e)=>new Ri(t,e);class Mi 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){Ai(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){Ai(this),bi(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 Ii=(t,e,r)=>t&e^t&r^e&r,Bi=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 Mi{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)+Bi[h]+Fi[h]|0,e=(Si(r,2)^Si(r,13)^Si(r,22))+Ii(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,Ji=(t,e,r)=>t<<r-32|e>>>64-r;const Ki={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:Ji,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,Zi]=(()=>Ki.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))))(),Yi=new Uint32Array(80),Xi=new Uint32Array(80);class $i extends Mi{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)Yi[y]=t.getUint32(e),Xi[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){const t=0|Yi[y-15],e=0|Xi[y-15],r=Ki.rotrSH(t,e,1)^Ki.rotrSH(t,e,8)^Ki.shrSH(t,e,7),n=Ki.rotrSL(t,e,1)^Ki.rotrSL(t,e,8)^Ki.shrSL(t,e,7),i=0|Yi[y-2],s=0|Xi[y-2],a=Ki.rotrSH(i,s,19)^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l,0|f,0|g)),({h:m,l:_}=Ki.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(){Yi.fill(0),Xi.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ts=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 Rp=0,Gp=as,Mp=1,Ip=0;Rp<24;Rp++){[Mp,Ip]=[Ip,(2*Mp+3*Ip)%5],rs.push(2*(5*Ip+Mp)),ns.push((Rp+1)*(Rp+2)/2%64);let t=ss;for(let e=0;e<7;e++)Gp=(Gp<<as^(Gp>>ls)*us)%cs,Gp&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?Ji(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){Ai(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){Ai(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(bi(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 As=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 bs=As,Es=!1;function xs(t){const e=jr(t,"data");return Vr(bs(e))}xs._=As,xs.lock=function(){Es=!0},xs.register=function(t){if(Es)throw new Error("sha256 is locked");bs=t},Object.freeze(xs),Object.freeze(xs);
|
3
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
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 Gs(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function Ms(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 Is(t){return Gs(Ts(t))}function Bs(t){if(!Ps(t))throw new Error("Uint8Array expected");return Gs(Ts(Uint8Array.from(t).reverse()))}function Os(t,e){return Ms(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=Ms(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:Is,bytesToNumberLE:Bs,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:Ms,hexToNumber:Gs,numberToBytesBE:Os,numberToBytesLE:Fs,numberToHexUnpadded:Rs,numberToVarBytesBE:function(t){return Ms(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"})),Js=BigInt(0),Ks=BigInt(1),qs=BigInt(2),Zs=BigInt(3),Ys=BigInt(4),Xs=BigInt(5),$s=BigInt(8);
|
5
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ta(t,e){const r=t%e;return r>=Js?r:e+r}function ea(t,e,r){if(r<=Js||e<Js)throw new Error("Expected power/modulo > 0");if(r===Ks)return Js;let n=Ks;for(;e>Js;)e&Ks&&(n=n*t%r),t=t*t%r,e>>=Ks;return n}function ra(t,e,r){let n=t;for(;e-- >Js;)n*=n,n%=r;return n}function na(t,e){if(t===Js||e<=Js)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ta(t,e),n=e,i=Js,s=Ks;for(;r!==Js;){const t=n%r,e=i-s*(n/r);n=r,r=t,i=s,s=e}if(n!==Ks)throw new Error("invert: does not exist");return ta(i,e)}function ia(t){if(t%Ys===Zs){const e=(t+Ks)/Ys;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-Ks)/qs;let r,n,i;for(r=t-Ks,n=0;r%qs===Js;r/=qs,n++);for(i=qs;i<t&&ea(i,e,t)!==t-Ks;i++);if(1===n){const e=(t+Ks)/Ys;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+Ks)/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,Ks<<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
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
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:Is(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 A=r.add(a,l);return w=r.mul(w,A),A=r.add(m,y),w=r.sub(w,A),A=r.add(i,s),c=r.add(o,l),A=r.mul(A,c),c=r.add(_,y),A=r.sub(A,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(A,w),c=r.mul(v,c),c=r.sub(c,m),m=r.mul(v,_),p=r.mul(A,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=Is(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)=>Is(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 Ms(this.toDERHex())}toDERHex(){return fa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ms(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?Is(t):Bs(t),e-Ks)+Ks;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=Is(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 A(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 b(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),b=[A(w),A(_)];if(null!=m){const t=!0===m?u(r.BYTES):m;b.push(Us("extraEntropy",t))}const x=Ls(...b),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}=b(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),A=a(f*y),b=null==(s=l.BASE.multiplyAndAddUnsafe(p,w,A))?void 0:s.toAffine();return!!b&&a(b.x)===f},ProjectivePoint:l,Signature:g,utils:m}}
|
9
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wa(t){return{hash:t,hmac:(e,...r)=>Gi(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
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
11
|
-
const Aa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ba=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<=Js)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:Js,ONE:Ks,create:e=>ta(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return Js<=e&&e<t},is0:t=>t===Js,isOdd:t=>(t&Ks)===Ks,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<Js)throw new Error("Expected power > 0");if(r===Js)return t.ONE;if(r===Ks)return e;let n=t.ONE,i=e;for(;r>Js;)r&Ks&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Ks;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?Bs(t):Is(t)}});return Object.freeze(o)}(Aa,void 0,void 0,{sqrt:function(t){const e=Aa,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,A=ra(w,n,e)*c%e,b=ra(A,xa,e);if(!Sa.eql(Sa.sqr(b),t))throw new Error("Cannot find square root");return b}}),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:ba,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ba,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),Ga=BigInt(2),Ma=BigInt(27),Ia=BigInt(28),Ba=BigInt(35),Oa={};function Fa(t){return Yr(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===Kr(t),"invalid r","value",t),__privateSet(this,nt,Vr(t))}get s(){return __privateGet(this,it)}set s(t){Or(32===Kr(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 Jr([this.r,this.yParityAndS])}get serialized(){return Jr([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==Ma||e==Ia?Ta:(Or(e>=Ba,"invalid EIP-155 v","v",t),(e-Ba)/Ga)}static getChainIdV(t,e){return sn(t)*Ga+BigInt(35+e-27)}static getNormalizedV(t){const e=sn(t);return e===Ta||e===Ma?27:e===Ra||e===Ia?28:(Or(e>=Ba,"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>=Ba?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===Kr(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===Kr(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===Kr(t),"invalid digest length","digest",t);const r=La.from(e);let n=Na.Signature.fromCompact(Hr(Jr([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 Rp=0;Rp<10;Rp++)Qa[String(Rp)]=String(Rp);for(let Rp=0;Rp<26;Rp++)Qa[String.fromCharCode(65+Rp)]=String(10+Rp);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 Ja(t){return t&&"function"==typeof t.getAddress}function Ka(t,e){return __async(this,null,(function*(){const r=yield e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(Br("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):(Br(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ka(t,e.resolveName(t))):Ja(t)?Ka(t,t.getAddress()):t&&"function"==typeof t.then?Ka(t,t):void Or(!1,"unsupported addressable value","target",t)}const Za={};function Ya(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new to(Za,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function Xa(t,e){return new to(Za,`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(Za,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(Za,e,r)}static uint8(t){return Ya(t,8)}static uint16(t){return Ya(t,16)}static uint24(t){return Ya(t,24)}static uint32(t){return Ya(t,32)}static uint40(t){return Ya(t,40)}static uint48(t){return Ya(t,48)}static uint56(t){return Ya(t,56)}static uint64(t){return Ya(t,64)}static uint72(t){return Ya(t,72)}static uint80(t){return Ya(t,80)}static uint88(t){return Ya(t,88)}static uint96(t){return Ya(t,96)}static uint104(t){return Ya(t,104)}static uint112(t){return Ya(t,112)}static uint120(t){return Ya(t,120)}static uint128(t){return Ya(t,128)}static uint136(t){return Ya(t,136)}static uint144(t){return Ya(t,144)}static uint152(t){return Ya(t,152)}static uint160(t){return Ya(t,160)}static uint168(t){return Ya(t,168)}static uint176(t){return Ya(t,176)}static uint184(t){return Ya(t,184)}static uint192(t){return Ya(t,192)}static uint200(t){return Ya(t,200)}static uint208(t){return Ya(t,208)}static uint216(t){return Ya(t,216)}static uint224(t){return Ya(t,224)}static uint232(t){return Ya(t,232)}static uint240(t){return Ya(t,240)}static uint248(t){return Ya(t,248)}static uint256(t){return Ya(t,256)}static uint(t){return Ya(t,256)}static int8(t){return Ya(t,-8)}static int16(t){return Ya(t,-16)}static int24(t){return Ya(t,-24)}static int32(t){return Ya(t,-32)}static int40(t){return Ya(t,-40)}static int48(t){return Ya(t,-48)}static int56(t){return Ya(t,-56)}static int64(t){return Ya(t,-64)}static int72(t){return Ya(t,-72)}static int80(t){return Ya(t,-80)}static int88(t){return Ya(t,-88)}static int96(t){return Ya(t,-96)}static int104(t){return Ya(t,-104)}static int112(t){return Ya(t,-112)}static int120(t){return Ya(t,-120)}static int128(t){return Ya(t,-128)}static int136(t){return Ya(t,-136)}static int144(t){return Ya(t,-144)}static int152(t){return Ya(t,-152)}static int160(t){return Ya(t,-160)}static int168(t){return Ya(t,-168)}static int176(t){return Ya(t,-176)}static int184(t){return Ya(t,-184)}static int192(t){return Ya(t,-192)}static int200(t){return Ya(t,-200)}static int208(t){return Ya(t,-208)}static int216(t){return Ya(t,-216)}static int224(t){return Ya(t,-224)}static int232(t){return Ya(t,-232)}static int240(t){return Ya(t,-240)}static int248(t){return Ya(t,-248)}static int256(t){return Ya(t,-256)}static int(t){return Ya(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(Za,"address",e)}static bool(e){return new t(Za,"bool",!!e)}static bytes(e){return new t(Za,"bytes",e)}static string(e){return new t(Za,"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(Za,"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 Br(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),Br(!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(Gr(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(Gr(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(),Br(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 Ao(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 bo(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 Go(t,e){try{return wo(t)}catch(r){Or(!1,r.message,e,t)}}function Mo(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:Bo(n[2],"nonce"),chainId:Bo(n[0],"chainId"),signature:La.from({yParity:Io(n[3],"yParity"),r:Yr(n[4],32),s:Yr(n[5],32)})})}return e}catch(r){Or(!1,r.message,e,t)}}function Io(t,e){return"0x"===t?0:cn(t,e)}function Bo(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=Io(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(a){Or(!1,"invalid yParity","yParity",e[0])}const n=Yr(e[1],32),i=Yr(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,At=new WeakMap,bt=new WeakMap,Et=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakSet,Nt=function(t,e){Br(!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))),Jr(["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))),Jr(["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)?Jr(["0x03",ei([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):Jr(["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))),Jr(["0x04",ei(r)])}(this,r)}Br(!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,At,void 0),__privateAdd(this,bt,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,At,null),__privateSet(this,bt,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=>Ao(t))))}get maxFeePerBlobGas(){const t=__privateGet(this,At);return null==t&&3===this.type?Eo:t}set maxFeePerBlobGas(t){__privateSet(this,At,null==t?null:sn(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=__privateGet(this,bt);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,bt,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)){Br(__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,bt,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:bo(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,At)||__privateGet(this,bt);null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&Br(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),Br(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),Br(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=Yn(t);Or(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:Io(e[0],"nonce"),gasPrice:Bo(e[1],"gasPrice"),gasLimit:Bo(e[2],"gasLimit"),to:Ro(e[3]),value:Bo(e[4],"value"),data:Vr(e[5]),chainId:Eo};if(6===e.length)return r;const n=Bo(e[6],"v"),i=Bo(e[7],"r"),s=Bo(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:Yr(e[7],32),s:Yr(e[8],32),v:n})}return r}(r));switch(r[0]){case 1:return t.from(function(t){const e=Yn(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:Bo(e[0],"chainId"),nonce:Io(e[1],"nonce"),gasPrice:Bo(e[2],"gasPrice"),gasLimit:Bo(e[3],"gasLimit"),to:Ro(e[4]),value:Bo(e[5],"value"),data:Vr(e[6]),accessList:Go(e[7],"accessList")};return 8===e.length||Lo(r,e.slice(8)),r}(r));case 2:return t.from(function(t){const e=Yn(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:Bo(e[0],"chainId"),nonce:Io(e[1],"nonce"),maxPriorityFeePerGas:Bo(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Bo(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Bo(e[4],"gasLimit"),to:Ro(e[5]),value:Bo(e[6],"value"),data:Vr(e[7]),accessList:Go(e[8],"accessList")};return 9===e.length||Lo(r,e.slice(9)),r}(r));case 3:return t.from(function(t){let e=Yn(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:Bo(e[0],"chainId"),nonce:Io(e[1],"nonce"),maxPriorityFeePerGas:Bo(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Bo(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Bo(e[4],"gasLimit"),to:Ro(e[5]),value:Bo(e[6],"value"),data:Vr(e[7]),accessList:Go(e[8],"accessList"),maxFeePerBlobGas:Bo(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=Yn(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:Bo(e[0],"chainId"),nonce:Io(e[1],"nonce"),maxPriorityFeePerGas:Bo(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Bo(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Bo(e[4],"gasLimit"),to:Ro(e[5]),value:Bo(e[6],"value"),data:Vr(e[7]),accessList:Go(e[8],"accessList"),authorizationList:Mo(e[9],"authorizationList")};return 10===e.length||Lo(r,e.slice(10)),r}(r))}Br(!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 Jo(t){return qo((()=>{let e=Vo(t);if(e.length)return e}))}function Ko(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Yo(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 Zo(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 Yo(t,e){let r=1+e(),n=e(),i=qo(e);return Zo(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 Zo(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+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogV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51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g");ul=new Map(Jo(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 Ko(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 Al(t,e){return t.P.has(e)||t.Q.has(e)}class bl extends Array{get is_emoji(){return!0}}let El,xl,kl,Sl,Nl,Pl,Cl,Tl,Rl,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7yljwwIWdfQ/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(Ko(t)),xl=r(),kl=e(),Sl=new Set(e().map((t=>kl[t]))),kl=new Set(kl),Nl=r(),r();let i=Jo(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=>Al(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)),Gl=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=>bl.from(t))).sort(el),Ml=new Map;for(let u of Gl){let t=[Ml];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 Bl(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],Il(),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 Il(),Nl.has(t)}function Ll(t){return e=function(t,e,r){if(!t)return[];Il();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=>Al(t,r)));if(!t.length)throw Pl.some((t=>Al(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(!Al(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: ${Bl(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=>Al(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: ${Bl(t)}`)}function jl(t,e){let r=Bl(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=Ml,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 Jl(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 Kl(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=Jl(t);for(;r.length;)e=ws(Jr([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(Jr(Jl(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 Zl=new Uint8Array(32);Zl.fill(0);const Yl=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)*Yl: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?Jr([e,Zl.slice(r)]):Vr(e)}(e)}}}switch(t){case"address":return function(t){return Yr(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,Gt=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(Jr(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),Jr(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,Gt).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 Jr(["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"},Ac=new RegExp("^(\\s*)"),bc=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,Bt),__privateAdd(this,Mt,void 0),__privateAdd(this,It,void 0),__privateSet(this,Mt,0),__privateSet(this,It,t.slice())}get offset(){return __privateGet(this,Mt)}get length(){return __privateGet(this,It).length-__privateGet(this,Mt)}clone(){return new t(__privateGet(this,It))}reset(){__privateSet(this,Mt,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,Bt,Ot).call(this,__privateGet(this,Mt)+1,t.match+1);return __privateSet(this,Mt,t.match+1),e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;__privateGet(this,Mt)<t.match-1;){const t=this.peek().linkNext;e.push(__privateMethod(this,Bt,Ot).call(this,__privateGet(this,Mt)+1,t)),__privateSet(this,Mt,t)}return __privateSet(this,Mt,t.match+1),e}peek(){if(__privateGet(this,Mt)>=__privateGet(this,It).length)throw new Error("out-of-bounds");return __privateGet(this,It)[__privateGet(this,Mt)]}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,Mt)._++,t}toString(){const t=[];for(let e=__privateGet(this,Mt);e<__privateGet(this,It).length;e++){const r=__privateGet(this,It)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Mt=new WeakMap,It=new WeakMap,Bt=new WeakSet,Ot=function(t=0,e=0){return new Sc(__privateGet(this,It).slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))};let Nc=Sc;function 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(Ac);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(bc),!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 Gc(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 Mc(t,e){return t.popParams().map((t=>Jc.from(t,e)))}function Ic(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return sn(t.pop().text);throw new Error("invalid gas")}return null}function Bc(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 Jc=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 Kc{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{Kc.from(JSON.parse(t))}catch(e){}return Kc.from(Pc(t))}if(t instanceof Nc){switch(t.peekKeyword(mc)){case"constructor":return $c.from(t);case"error":return Yc.from(t);case"event":return Xc.from(t);case"fallback":case"receive":return tu.from(t);case"function":return eu.from(t);case"struct":return ru.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return $c.from(t);case"error":return Yc.from(t);case"event":return Xc.from(t);case"fallback":case"receive":return tu.from(t);case"function":return eu.from(t);case"struct":return ru.from(t)}Br(!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 Yc.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 Kc{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 Zc(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class Yc 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+Zc(t,this.inputs)),e.join(" ")}static from(t){if(Yc.isFragment(t))return t;if("string"==typeof t)return Yc.from(Pc(t));if(t instanceof Nc){const e=Tc("error",t),r=Mc(t);return Bc(t),new Yc(Uc,e,r)}return new Yc(Uc,t.name,t.inputs?t.inputs.map(Jc.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+Zc(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){e=(e||[]).map((t=>Jc.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=Mc(t,!0),n=!!Rc(t,hc(["anonymous"])).has("anonymous");return Bc(t),new Xc(Uc,e,r,n)}return new Xc(Uc,t.name,t.inputs?t.inputs.map((t=>Jc.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Lc]===Hc}}class $c extends Kc{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(Br(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${Zc(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if($c.isFragment(t))return t;if("string"==typeof t)try{return $c.from(Pc(t))}catch(e){Or(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Nc){Rc(t,hc(["constructor"]));const e=Mc(t),r=!!Rc(t,dc).has("payable"),n=Ic(t);return Bc(t),new $c(Uc,"constructor",e,r,n)}return new $c(Uc,"constructor",t.inputs?t.inputs.map(Jc.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Lc]===Wc}}class tu extends Kc{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=Mc(t);return Or(0===e.length,"receive cannot have arguments","obj.inputs",e),Rc(t,hc(["payable"])),Bc(t),new tu(Uc,[],!0)}let r=Mc(t);r.length?Or(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Jc.from("bytes")];const n=Gc(t);if(Or("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Rc(t,hc(["returns"])).has("returns")){const e=Mc(t);Or(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Bc(t),new tu(Uc,r,"payable"===n)}if("receive"===t.type)return new tu(Uc,[],!0);if("fallback"===t.type){const e=[Jc.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+Zc(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(Zc(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){e=(e||[]).map((t=>Jc.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=Mc(t),n=Gc(t);let i=[];Rc(t,hc(["returns"])).has("returns")&&(i=Mc(t));const s=Ic(t);return Bc(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(Jc.from):[],t.outputs?t.outputs.map(Jc.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=Mc(t);return Bc(t),new ru(Uc,e,r)}return new ru(Uc,t.name,t.inputs?t.inputs.map(Jc.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,Jc.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,Jc.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,Jc.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)),Ir(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},Jt=new WeakSet,Kt=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,Jt),__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(Kc.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,Jt,Kt).call(this,t,null,!1);return Or(e,"no matching event","key",t),e.name}hasEvent(t){return!!__privateMethod(this,Jt,Kt).call(this,t,null,!1)}getEvent(t,e){return __privateMethod(this,Jt,Kt).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 Yc.from(fu[e].signature);for(const t of __privateGet(this,jt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[r,n]of __privateGet(this,jt))r.split("(")[0]===t&&e.push(n);if(0===e.length)return"Error"===t?Yc.from("error Error(string)"):"Panic"===t?Yc.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=Yc.from(t).format()))return Yc.from("error Error(string)");if("Panic(uint256)"===t)return Yc.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 Jr([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 Jr([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"}Br(!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}Br(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=Zr(e,32,!1):"address"===t.type&&__privateGet(this,Qt).encode(["address"],[e]),Yr(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(Jc.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,Jr(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 Au{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?[]:(Br("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 bu{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 Br(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.transactionHash);return Br(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransactionReceipt(){return __async(this,null,(function*(){const t=yield this.provider.getTransactionReceipt(this.transactionHash);return Br(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}))}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class Eu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"contractAddress"),__publicField(this,"hash"),__publicField(this,"index"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"logsBloom"),__publicField(this,"gasUsed"),__publicField(this,"blobGasUsed"),__publicField(this,"cumulativeGasUsed"),__publicField(this,"gasPrice"),__publicField(this,"blobGasPrice"),__publicField(this,"type"),__publicField(this,"status"),__publicField(this,"root"),__privateAdd(this,Zt,void 0),__privateSet(this,Zt,Object.freeze(t.logs.map((t=>new bu(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,Zt)}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 Br(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ku(this,t)}}Zt=new WeakMap;Yt=new WeakMap;let xu=class t{constructor(t,e){__publicField(this,"provider"),__publicField(this,"blockNumber"),__publicField(this,"blockHash"),__publicField(this,"index"),__publicField(this,"hash"),__publicField(this,"type"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"nonce"),__publicField(this,"gasLimit"),__publicField(this,"gasPrice"),__publicField(this,"maxPriorityFeePerGas"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxFeePerBlobGas"),__publicField(this,"data"),__publicField(this,"value"),__publicField(this,"chainId"),__publicField(this,"signature"),__publicField(this,"accessList"),__publicField(this,"blobVersionedHashes"),__publicField(this,"authorizationList"),__privateAdd(this,Yt,void 0),this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.authorizationList=null!=t.authorizationList?t.authorizationList:null,__privateSet(this,Yt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index: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,Yt),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,Yt)&&(s=__privateGet(this,Yt)));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"),Br(!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;Br(!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(Ir("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(Gr(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 Br(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Su(this)}reorderedEvent(t){return Br(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Br(!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,Yt,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 bu{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 bu{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 Gu 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 Mu=BigInt(0);function Iu(t){return t&&"function"==typeof t.call}function Bu(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||Mu,"overrides.value")===Mu,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;Br(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 Br(Bu(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");Br(Iu(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(Mr(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 Br(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;Br(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");Br(Iu(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(Mr(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 Br(Bu(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 Br(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 Ju(t){return Vu.get(t[zu])}function Ku(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}=Ju(t);return r.get((yield Ku(t,e)).tag)||null}))}function Zu(t,e,r){return __async(this,null,(function*(){const n=ju(t.runner);Br(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:a}=yield Ku(t,r),{addr:o,subs:l}=Ju(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 Gu(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 Yu=Promise.resolve();function Xu(t,e,r,n){return __async(this,null,(function*(){try{yield Yu}catch(s){}const i=function(t,e,r,n){return __async(this,null,(function*(){yield Yu;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(),Ju(t).subs.delete(i.tag)),a>0}))}(t,e,r,n);return Yu=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||Ja(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 Ir("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw Ir("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Ju(this).addr=e,e}))}else s=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return Ju(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(!Gr(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(!Gr(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 Ju(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const t=ju(this.runner);Br(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 Br(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 Ju(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 Br(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 Br(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}=Ju(this),s=n||(yield i),{fragment:a,topics:o}=yield Ku(this,t),l={address:s,topics:o,fromBlock:e,toBlock:r},c=ju(this.runner);return Br(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 bu(t,c)}))}))}on(t,e){return __async(this,null,(function*(){const r=yield Zu(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 Zu(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}=Ju(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}=Ju(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(),Ju(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(),Ju(this).subs.delete(e.tag)}else{const{subs:t}=Ju(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(Gr(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(Gr(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;Br(!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]}`;Br(!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 Gn(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 Br(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(Kl(this.name));let n=null;(yield this.supportsWildcard())&&(n=r.getFunction(t),Br(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(!Gr(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(Kl(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){Br(!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 Ah 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 Ah(this.address,this.targetNetwork)}}class bh 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 Ah(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 Ah(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 bh(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){Br(!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,Ae,void 0),__privateSet(this,ve,t),__privateSet(this,Ae,!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,Ae)||(__privateSet(this,Ae,!0),__privateGet(this,we).call(this,-2),__privateGet(this,ve).on("block",__privateGet(this,we)))}stop(){__privateGet(this,Ae)&&(__privateSet(this,Ae,!1),__privateGet(this,ve).off("block",__privateGet(this,we)))}pause(t){this.stop()}resume(){this.start()}}ve=new WeakMap,we=new WeakMap,Ae=new WeakMap;class Rh extends Th{constructor(t,e){super(t),__privateAdd(this,be,void 0),__privateAdd(this,Ee,void 0),__privateSet(this,be,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,be));null!=t&&(-2===__privateGet(this,Ee)?__privateSet(this,Ee,t.number):t.number>__privateGet(this,Ee)&&(e.emit(__privateGet(this,be),t.number),__privateSet(this,Ee,t.number)))}))}}be=new WeakMap,Ee=new WeakMap;class Gh 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 Mh extends Th{constructor(t,e){super(t),__privateAdd(this,ke,void 0),__privateSet(this,ke,e)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getTransactionReceipt(__privateGet(this,ke));t&&e.emit(__privateGet(this,ke),t)}))}}ke=new WeakMap;class Ih{constructor(t,e){__privateAdd(this,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,Ge).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,Ge=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 Bh=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,Je),__privateAdd(this,qe),__privateAdd(this,Ye),__privateAdd(this,$e),__privateAdd(this,er),__privateAdd(this,nr),__privateAdd(this,Me,void 0),__privateAdd(this,Ie,void 0),__privateAdd(this,Be,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,Me,new Map),__privateSet(this,Ie,new Map),__privateSet(this,Be,null),__privateSet(this,Oe,!1),__privateSet(this,je,1),__privateSet(this,He,new Map),__privateSet(this,We,!1)}get pollingInterval(){return __privateGet(this,Qe).pollingInterval}get provider(){return this}get plugins(){return Array.from(__privateGet(this,Ie).values())}attachPlugin(t){if(__privateGet(this,Ie).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,Ie).set(t.name,t.connect(this)),this}getPlugin(t){return __privateGet(this,Ie).get(t)||null}get disableCcipRead(){return __privateGet(this,We)}set disableCcipRead(t){__privateSet(this,We,!!t)}ccipReadFetch(t,e,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 Gn(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){}Br(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)}Br(!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 Au(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 bu(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(){Br(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}_perform(t){return __async(this,null,(function*(){Br(!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))):Br(!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*Bh+s),new vu(r,i,s)})),r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Gn(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,Ze).call(this,__privateMethod(this,Je,Ke).call(this,e,r,t.enableCcipRead?0:-1))}))}getBalance(t,e){return __async(this,null,(function*(){return sn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getBalance"},t,e),"%response")}))}getTransactionCount(t,e){return __async(this,null,(function*(){return cn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getTransactionCount"},t,e),"%response")}))}getCode(t,e){return __async(this,null,(function*(){return Vr(yield __privateMethod(this,Ye,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,Ye,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){Br(!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=Kl((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(Gr(r,"BAD_DATA")&&"0x"===r.value)return null;if(Gr(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(Ir("timeout","TIMEOUT",{reason:"timeout"})))}),r)),a(yield this.getBlockNumber())}))))}))}waitForBlock(t){return __async(this,null,(function*(){Br(!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,Me).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 Ih(this,t.filter);case"transaction":return new Mh(this,t.hash);case"orphan":return new Gh(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of __privateGet(this,Me).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=__privateGet(this,Be)&&e.pause(__privateGet(this,Be));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,Be)&&r.subscriber.pause(__privateGet(this,Be))),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,Be)&&r.subscriber.pause(__privateGet(this,Be))),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,Me).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,Me).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,Me).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,Me).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,Me).delete(e)}else for(const[t,{started:e,subscriber:r}]of __privateGet(this,Me))e&&r.stop(),__privateGet(this,Me).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,Be)}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(__privateSet(this,De,-1),null!=__privateGet(this,Be)){if(__privateGet(this,Be)==!!t)return;Br(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),__privateSet(this,Be,!!t);for(const e of __privateGet(this,He).values())e.timer&&clearTimeout(e.timer),e.time=jh()-e.time}resume(){if(null!=__privateGet(this,Be)){this._forEachSubscriber((t=>t.resume())),__privateSet(this,Be,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 Jh(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}Me=new WeakMap,Ie=new WeakMap,Be=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}))},Je=new WeakSet,Ke=function(t,e,r){return __async(this,null,(function*(){Br(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&&Mr(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:[]};Br(Kr(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=qr(t,0,32);Br(qr(r,0,12)===qr(Zh,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){Br(!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){Br(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}Br(qr(t,100,128)===qr(Zh,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){Br(!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){Br(!1,s.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:t}})}Br(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);Br(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:Jr([o.selector,qh([l,o.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=yield __privateMethod(this,Je,Ke).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,Ze=function(t){return __async(this,null,(function*(){const{value:e}=yield Cr({network:this.getNetwork(),value:t});return e}))},Ye=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,Ze).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,Me).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,Me).get(r);if(!n){n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},__privateGet(this,Me).set(r,n)}return n}))};const Kh=new Uint8Array([]);function qh(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(Kh),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(Jh(i)),r+=32+32*Math.ceil(i.length/32)}return Jr(e)}const Zh="0x0000000000000000000000000000000000000000000000000000000000000000";function Yh(t,e){if(t.provider)return t.provider;Br(!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 Yh(this,"getTransactionCount").getTransactionCount(yield this.getAddress(),t)}))}populateCall(t){return __async(this,null,(function*(){return yield Xh(this,t)}))}populateTransaction(t){return __async(this,null,(function*(){const e=Yh(this,"populateTransaction"),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();Br(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?(Br(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):Br(!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 Yh(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=yield this.getNonce()),e}))}estimateGas(t){return __async(this,null,(function*(){return Yh(this,"estimateGas").estimateGas(yield this.populateCall(t))}))}call(t){return __async(this,null,(function*(){return Yh(this,"call").call(yield this.populateCall(t))}))}resolveName(t){return __async(this,null,(function*(){const e=Yh(this,"resolveName");return yield e.resolveName(t)}))}sendTransaction(t){return __async(this,null,(function*(){const e=Yh(this,"sendTransaction"),r=yield this.populateTransaction(t);delete r.from;const n=Do.from(r);return yield e.broadcastTransaction(yield this.signTransaction(n))}))}authorize(t){Br(!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(!Gr(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 Ih(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){Br(!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(Gr(o,"CANCELLED")||Gr(o,"BAD_DATA")||Gr(o,"NETWORK_ERROR")||Gr(o,"UNSUPPORTED_OPERATION"))return null==o.info&&(o.info={}),o.info.sendTransactionHash=r,void n(o);if(Gr(o,"INVALID_ARGUMENT")&&(s++,null==o.info&&(o.info={}),o.info.sendTransactionHash=r,s>10))return void n(o);this.provider.emit("error",Ir("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,Ar=new WeakMap,br=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(Ir("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=Ir("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,Ar,void 0),__privateAdd(this,br,void 0),__privateSet(this,_r,1),__privateSet(this,mr,Object.assign({},ld,e||{})),__privateSet(this,yr,[]),__privateSet(this,vr,null),__privateSet(this,Ar,null),__privateSet(this,br,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,Ar,xh.from(t))):r&&(Or(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),__privateSet(this,Ar,r))}_getOption(t){return __privateGet(this,mr)[t]}get _network(){return Br(__privateGet(this,Ar),"network is not available yet","NETWORK_ERROR"),__privateGet(this,Ar)}_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,Ar))return __privateGet(this,Ar)}return __privateGet(this,br)?yield __privateGet(this,br):this.ready?(__privateSet(this,br,(()=>__async(this,null,(function*(){try{const t=xh.from(sn(yield this.send("eth_chainId",[])));return __privateSet(this,br,null),t}catch(t){throw __privateSet(this,br,null),t}})))()),yield __privateGet(this,br)):(__privateSet(this,br,(()=>__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,br,null)}catch(r){throw __privateSet(this,br,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,br))}))}_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,Ar)&&!this.destroyed;)try{__privateSet(this,Ar,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",Ir("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 Ih(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=Ao(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 Ir("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}});if(e.match(/nonce/i)&&e.match(/too low/i))return Ir("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 Ir("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 Ir("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return Ir("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Ir("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return Ir("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?Ir("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):Ir("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Ir("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(Ir("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(Ir("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]||""),Ad=()=>({[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}),bd=(t=3,e=500)=>__async(this,null,(function*(){let r=0,n=Ad();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=Ad(),r++;return n})),Ed=()=>{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=Ad();console.log("Detected wallets:",e)},xd=()=>__async(this,null,(function*(){if(console.log("Connecting to MetaMask wallet..."),!window.ethereum||!window.ethereum.isMetaMask)throw console.error("MetaMask not found."),new Error("MetaMask not detected. Please install MetaMask extension.");try{let e;try{e=new fd(window.ethereum);const t=yield e.send("eth_requestAccounts",[]);if(!t||0===t.length)throw new Error("No accounts found");const r=t[0],n=yield e.getNetwork(),i=Number(n.chainId);let s;switch(i){case 1:s=md.ETHEREUM;break;case 56:s=md.BSC;break;default:s=`unknown-${i}`}return{walletType:gd.METAMASK,address:r,provider:e,network:s,isConnected:!0,chainId:i}}catch(t){if(console.log("Trying fallback ethers provider pattern"),window.ethereum.request){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}`}return{walletType:gd.METAMASK,address:e,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return e})),sendTransaction:t=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:e,to:t.to,value:t.value?t.value.toString():"0x0",gasLimit:t.gasLimit?t.gasLimit.toString():void 0,data:t.data}]})}}))}),estimateGas:t=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:e,to:t.to,value:t.value?t.value:"0x0"}]});return{toString:()=>parseInt(r,16).toString(),mul:t=>({div:e=>({toString:()=>Math.floor(parseInt(r,16)*t/e).toString()})})}}))},network:i,isConnected:!0,chainId:n}}throw new Error("Unsupported wallet interface")}}catch(e){throw console.error("Error connecting to MetaMask:",e),e}})),kd=()=>__async(this,null,(function*(){if(console.log("Connecting to Trust Wallet..."),!window.ethereum||!window.ethereum.isTrust)throw console.error("Trust Wallet not found."),new Error("Trust Wallet not detected. Please install Trust Wallet.");try{if(window.ethereum.request){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}`}return{walletType:gd.TRUST_WALLET,address:e,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return e})),sendTransaction:t=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:e,to:t.to,value:t.value?t.value.toString():"0x0",gasLimit:t.gasLimit?t.gasLimit.toString():void 0,data:t.data}]})}}))}),estimateGas:t=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:e,to:t.to,value:t.value?t.value:"0x0"}]});return{toString:()=>parseInt(r,16).toString(),mul:t=>({div:e=>({toString:()=>Math.floor(parseInt(r,16)*t/e).toString()})})}}))},network:i,isConnected:!0,chainId:n}}throw new Error("Unsupported wallet interface")}catch(t){throw console.error("Error connecting to Trust Wallet:",t),t}})),Sd=()=>__async(this,null,(function*(){if(console.log("Connecting to TronLink wallet..."),!window.tronWeb)throw console.error("TronWeb not found. Is TronLink installed?"),new Error("TronLink not detected. Please install TronLink extension.");const t=(t=10,e=500)=>__async(this,null,(function*(){for(let 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}})),Nd=()=>__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}})),Pd=t=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",t),t){case gd.METAMASK:return xd();case gd.TRONLINK:return Sd();case gd.TRUST_WALLET:return kd();case gd.LUTE:return Nd();default:throw new Error(`Unsupported wallet type: ${t}`)}})),Cd=t=>vd[t]||[],Td=(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=i.getSigner(),a=(t=>{try{if(ii)return ii(t);const e=parseFloat(t)*Math.pow(10,18);return{toString:()=>e.toLocaleString("fullwide",{useGrouping:!1})}}catch(e){const r=parseFloat(t)*Math.pow(10,18);return{toString:()=>r.toLocaleString("fullwide",{useGrouping:!1})}}})(r.toString());console.log("Sending ETH/BNB:",{to:e,value:a.toString()});const o=yield i.estimateGas({to:e,value:a});console.log("Gas estimate:",o.toString());const l="function"==typeof o.mul?o.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(o.toString())).toString()};console.log("Using gas limit:",l.toString()),n=yield s.sendTransaction({to:e,value:a,gasLimit:l});break;case gd.TRONLINK:const c=t.provider;if(!c||!c.ready)throw new Error("TronWeb not initialized");const u=c.toSun(r.toString());console.log("Sending TRX:",{to:e,value:u}),n=yield c.trx.sendTransaction(e,u);break;case gd.LUTE:const h=t.provider,d=Math.floor(1e6*parseFloat(r));console.log("Sending Algos:",{to:e,amount:d}),n=yield h.sendPayment({recipient:e,amount:d});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}})),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 Md(t,e,r,n);case gd.LUTE:return Id(t,e,r,n);default:return Gd(t,e,r,n)}})),Gd=(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.getSigner(),{contractAddress:s,decimals:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=((t,e)=>{try{if(ni)return ni(t,e);const r=parseFloat(t)*Math.pow(10,e);return{toString:()=>r.toLocaleString("fullwide",{useGrouping:!1})}}catch(r){const n=parseFloat(t)*Math.pow(10,e);return{toString:()=>n.toLocaleString("fullwide",{useGrouping:!1})}}})(l.toString(),c);console.log(`Sending ${l} ${o} (${u.toString()} base units) to ${r}`);try{const t=new eh(s,["function transfer(address to, uint256 amount) returns (bool)"],i);try{const e=yield t.estimateGas.transfer(r,u);console.log("Gas estimate:",e.toString());const n="USDC"===o?"function"==typeof e.mul?e.mul(120).div(100):{toString:()=>Math.floor(1.2*parseInt(e.toString())).toString()}:"function"==typeof e.mul?e.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(e.toString())).toString()};console.log("Using gas limit:",n.toString());const i=yield t.transfer(r,u,{gasLimit:n});return console.log("Transaction sent:",i),i.hash}catch(h){if(console.error("Gas estimation failed:",h),"USDC"===o){console.log("Trying USDC transaction with fixed gas limit");const e=yield t.transfer(r,u,{gasLimit:15e4});return console.log("Transaction sent with fixed gas limit:",e),e.hash}throw new Error(`Transaction would likely fail: ${h.message}`)}}catch(d){throw console.error("ERC20 transaction error:",d),d.message&&d.message.includes("user rejected")?new Error("Transaction rejected by user"):d.message&&d.message.includes("insufficient funds")?new Error("Insufficient funds for transaction"):d}})),Md=(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"}`)}})),Id=(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}})),Bd=(t,e)=>__async(this,null,(function*(){if(console.log("sendTransaction called with:",e),!t)throw new Error("Wallet not connected");const{to:r,toAddress:n,amount:i,tokenAddress:s,tokenConfig:a,currency:o,network:l}=e,c=r||n;if(!c)throw new Error("Recipient address not provided");if(!s&&!a)return Td(t,c,i);let u=a;if(!u&&s&&(u={contractAddress:s,decimals:18,symbol:o||"TOKEN"}),!u)throw new Error("Token configuration not provided");return Rd(t,u,c,i)}));let Od={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{}};const Fd=t=>{Od.merchantWalletAddresses=__spreadValues({},t),console.log("Updated merchant wallet addresses:",Od.merchantWalletAddresses)},Ud=()=>({"Content-Type":"application/json","x-api-key":Od.apiKey,"x-api-secret":Od.apiSecret}),Ld=t=>__async(this,null,(function*(){var e;try{if(console.log("Creating payment with data:",t),console.log("API URL:",`${Od.apiUrl}/api/payments/create`),!t.amount)throw new Error("Payment amount is required");const n=__spreadProps(__spreadValues({},t),{recipientAddress:t.recipientAddress||t.toAddress||t.walletAddress,merchantWalletAddresses:__spreadValues(__spreadValues({},Od.merchantWalletAddresses),t.merchantWalletAddresses),walletAddress:t.walletAddress||t.recipientAddress||t.toAddress,toAddress:t.toAddress||t.recipientAddress||t.walletAddress}),i=n.network||"ethereum",s=n.recipientAddress||(null==(e=n.merchantWalletAddresses)?void 0:e[i]);if(!s)throw new Error(`No recipient address provided for network: ${i}. Please configure a wallet address.`);console.log("Enhanced payment data:",{network:i,recipientAddress:s,merchantWalletAddresses:n.merchantWalletAddresses});const a=yield fetch(`${Od.apiUrl}/api/payments/create`,{method:"POST",headers:Ud(),body:JSON.stringify(n)});if(console.log("Create payment response status:",a.status),!a.ok){let t;try{t=yield a.json()}catch(r){throw new Error(`Failed to create payment: ${a.status} ${a.statusText}`)}throw console.error("Error creating payment:",t),new Error(t.error||`Failed to create payment: ${a.status}`)}const o=yield a.json();return console.log("Create payment response data:",o),o.merchantConfig&&o.merchantConfig.walletAddresses&&Fd(o.merchantConfig.walletAddresses),o}catch(n){throw console.error("Create payment error:",n),n}})),Dd=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=__spreadProps(__spreadValues({},t),{processedAt:(new Date).toISOString(),source:"coinley_checkout"});console.log("API URL:",`${Od.apiUrl}/api/payments/process`);const n=yield fetch(`${Od.apiUrl}/api/payments/process`,{method:"POST",headers:Ud(),body:JSON.stringify(r)});if(console.log("Process payment response status:",n.status),!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to process payment: ${n.status} ${n.statusText}`)}throw console.error("Error processing payment:",t),new Error(t.error||`Failed to process payment: ${n.status}`)}const i=yield n.json();return console.log("Process payment response data:",i),i}catch(r){throw console.error("Process payment error:",r),r}})),jd=t=>__async(this,null,(function*(){try{const r=yield fetch(`${Od.apiUrl}/api/merchants/wallets`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to get merchant wallets: ${r.status} ${r.statusText}`)}throw new Error(t.error||`Failed to get merchant wallets: ${r.status}`)}const n=yield r.json();return n.merchantWallets&&Fd(n.merchantWallets),n}catch(r){throw console.error("Get merchant wallets error:",r),r}})),Hd=t=>__async(this,null,(function*(){return jd(t)}));var Wd={exports:{}},Qd={},zd=e,Vd=Symbol.for("react.element"),Jd=Symbol.for("react.fragment"),Kd=Object.prototype.hasOwnProperty,qd=zd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Zd={key:!0,ref:!0,__self:!0,__source:!0};function Yd(t,e,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)&&!Zd.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:Vd,type:t,key:s,ref:a,props:i,_owner:qd.current}}Qd.Fragment=Jd,Qd.jsx=Yd,Qd.jsxs=Yd,Wd.exports=Qd;var Xd=Wd.exports;const $d=e.createContext(),tp=e.createContext(),ep=()=>e.useContext(tp);var rp,np,ip=Object.defineProperty,sp=Object.getOwnPropertySymbols,ap=Object.prototype.hasOwnProperty,op=Object.prototype.propertyIsEnumerable,lp=(t,e,r)=>e in t?ip(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cp=(t,e)=>{for(var r in e||(e={}))ap.call(e,r)&&lp(t,r,e[r]);if(sp)for(var r of sp(e))op.call(e,r)&&lp(t,r,e[r]);return t},up=(t,e)=>{var r={};for(var n in t)ap.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&sp)for(var n of sp(t))e.indexOf(n)<0&&op.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})(rp||(rp={})),(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})((np=rp||(rp={})).QrCode||(np.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={}))})(rp||(rp={}));var hp=rp,dp={L:hp.QrCode.Ecc.LOW,M:hp.QrCode.Ecc.MEDIUM,Q:hp.QrCode.Ecc.QUARTILE,H:hp.QrCode.Ecc.HIGH},pp=128,fp="L",gp="#FFFFFF",mp="#000000",_p=!1,yp=1;
|
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=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n),__accessCheck=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},__privateGet=(e,t,n)=>(__accessCheck(e,t,"read from private field"),n?n.call(e):t.get(e)),__privateAdd=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},__privateSet=(e,t,n,r)=>(__accessCheck(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),__privateWrapper=(e,t,n,r)=>({set _(r){__privateSet(e,t,r,n)},get _(){return __privateGet(e,t,r)}}),__privateMethod=(e,t,n)=>(__accessCheck(e,t,"access private method"),n),__superGet=(e,t,n)=>__reflectGet(__getProtoOf(e),n,t),__async=(e,t,n)=>new Promise(((r,s)=>{var i=e=>{try{a(n.next(e))}catch(t){s(t)}},o=e=>{try{a(n.throw(e))}catch(t){s(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,o);a((n=n.apply(e,t)).next())}));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoinleyCheckout={},e.React)}(this,(function(e,t){var n,r,s,i,o,a,l,c,u,d,h,p,f,m,g,y,_,b,w,v,x,E,N,k,A,T,S,O,R,C,M,P,F,U,j,I,L,G,D,B,W,$,z,V,H,K,q,J,Q,X,Y,Z,ee;function te(e,t,n){const r=t.split("|").map((e=>e.trim()));for(let i=0;i<r.length;i++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof e===t)return}const s=new Error(`invalid value for type ${t}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${n}`,s.value=e,s}function ne(e){return __async(this,null,(function*(){const t=Object.keys(e);return(yield Promise.all(t.map((t=>Promise.resolve(e[t]))))).reduce(((e,n,r)=>(e[t[r]]=n,e)),{})}))}function re(e,t,n){for(let r in t){let s=t[r];const i=n?n[r]:null;i&&te(s,i,r),Object.defineProperty(e,r,{enumerable:!0,value:s,writable:!1})}}function se(e,t){if(null==e)return"null";if(null==t&&(t=new Set),"object"==typeof e){if(t.has(e))return"[Circular]";t.add(e)}if(Array.isArray(e))return"[ "+e.map((e=>se(e,t))).join(", ")+" ]";if(e instanceof Uint8Array){const t="0123456789abcdef";let n="0x";for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[15&e[r]];return n}if("object"==typeof e&&"function"==typeof e.toJSON)return se(e.toJSON(),t);switch(typeof e){case"boolean":case"number":case"symbol":return e.toString();case"bigint":return BigInt(e).toString();case"string":return JSON.stringify(e);case"object":{const n=Object.keys(e);return n.sort(),"{ "+n.map((n=>`${se(n,t)}: ${se(e[n],t)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ie(e,t){return e&&e.code===t}function oe(e){return ie(e,"CALL_EXCEPTION")}function ae(e,t,n){let r,s=e;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${se(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+se(t))}}r.push(`code=${t}`),r.push("version=6.14.3"),r.length&&(e+=" ("+r.join(", ")+")")}switch(t){case"INVALID_ARGUMENT":r=new TypeError(e);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(e);break;default:r=new Error(e)}return re(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&re(r,{shortMessage:s}),r}function le(e,t,n,r){if(!e)throw ae(t,n,r)}function ce(e,t,n,r){le(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function ue(e,t,n){null==n&&(n=""),n&&(n=": "+n),le(e>=t,"missing argument"+n,"MISSING_ARGUMENT",{count:e,expectedCount:t}),le(e<=t,"too many arguments"+n,"UNEXPECTED_ARGUMENT",{count:e,expectedCount:t})}const de=["NFD","NFC","NFKD","NFKC"].reduce(((e,t)=>{try{if("test"!=="test".normalize(t))throw new Error("bad");if("NFD"===t){const e=String.fromCharCode(233).normalize("NFD");if(e!==String.fromCharCode(101,769))throw new Error("broken")}e.push(t)}catch(n){}return e}),[]);function he(e,t,n){if(null==n&&(n=""),e!==t){let e=n,t="new";n&&(e+=".",t+=" "+n),le(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}function pe(e,t,n){if(e instanceof Uint8Array)return n?new Uint8Array(e):e;if("string"==typeof e&&e.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const t=new Uint8Array((e.length-2)/2);let n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}ce(!1,"invalid BytesLike value",t||"value",e)}function fe(e,t){return pe(e,t,!1)}function me(e,t){return pe(e,t,!0)}function ge(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(("number"!=typeof t||e.length===2+2*t)&&(!0!==t||e.length%2==0))}const ye="0123456789abcdef";function _e(e){const t=fe(e);let n="0x";for(let r=0;r<t.length;r++){const e=t[r];n+=ye[(240&e)>>4]+ye[15&e]}return n}function be(e){return"0x"+e.map((e=>_e(e).substring(2))).join("")}function we(e,t,n){const r=fe(e);return null!=n&&n>r.length&&le(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n}),_e(r.slice(null==t?0:t,null==n?r.length:n))}function ve(e,t,n){const r=fe(e);le(t>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:t,offset:t+1});const s=new Uint8Array(t);return s.fill(0),n?s.set(r,t-r.length):s.set(r,0),_e(s)}const xe=BigInt(0),Ee=BigInt(1),Ne=9007199254740991;function ke(e,t){const n=Se(e,"value"),r=BigInt(Ce(t,"width"));if(le(n>>r===xe,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-Ee){return-((~n&(Ee<<r)-Ee)+Ee)}return n}function Ae(e,t){const n=Se(e,"value"),r=BigInt(Ce(t,"bits"));return n&(Ee<<r)-Ee}function Te(e,t){switch(typeof e){case"bigint":return e;case"number":return ce(Number.isInteger(e),"underflow",t||"value",e),ce(e>=-Ne&&e<=Ne,"overflow",t||"value",e),BigInt(e);case"string":try{if(""===e)throw new Error("empty string");return"-"===e[0]&&"-"!==e[1]?-BigInt(e.substring(1)):BigInt(e)}catch(n){ce(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}ce(!1,"invalid BigNumberish value",t||"value",e)}function Se(e,t){const n=Te(e,t);return le(n>=xe,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const Oe="0123456789abcdef";function Re(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=Oe[n>>4],t+=Oe[15&n];return BigInt(t)}return Te(e)}function Ce(e,t){switch(typeof e){case"bigint":return ce(e>=-Ne&&e<=Ne,"overflow",t||"value",e),Number(e);case"number":return ce(Number.isInteger(e),"underflow",t||"value",e),ce(e>=-Ne&&e<=Ne,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return Ce(BigInt(e),t)}catch(n){ce(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}ce(!1,"invalid numeric value",t||"value",e)}function Me(e,t){let n=Se(e,"value").toString(16);if(null==t)n.length%2&&(n="0"+n);else{const r=Ce(t,"width");for(le(2*r>=n.length,`value exceeds width (${r} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:e});n.length<2*r;)n="0"+n}return"0x"+n}class Pe{constructor(e,t,r){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,n,void 0),__privateSet(this,n,t),re(this,{emitter:e,filter:r})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,n)&&(yield this.emitter.off(this.filter,__privateGet(this,n)))}))}}function Fe(e,t,n,r,s){if("BAD_PREFIX"===e||"UNEXPECTED_CONTINUE"===e){let e=0;for(let r=t+1;r<n.length&&n[r]>>6==2;r++)e++;return e}return"OVERRUN"===e?n.length-t-1:0}n=new WeakMap;const Ue=Object.freeze({error:function(e,t,n,r,s){ce(!1,`invalid codepoint at offset ${t}; ${e}`,"bytes",n)},ignore:Fe,replace:function(e,t,n,r,s){return"OVERLONG"===e?(ce("number"==typeof s,"invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),Fe(e,t,n))}});function je(e,t){ce("string"==typeof e,"invalid string value","str",e),null!=t&&(!function(e){le(de.indexOf(e)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:e}})}(t),e=e.normalize(t));let n=[];for(let r=0;r<e.length;r++){const t=e.charCodeAt(r);if(t<128)n.push(t);else if(t<2048)n.push(t>>6|192),n.push(63&t|128);else if(55296==(64512&t)){r++;const s=e.charCodeAt(r);ce(r<e.length&&56320==(64512&s),"invalid surrogate pair","str",e);const i=65536+((1023&t)<<10)+(1023&s);n.push(i>>18|240),n.push(i>>12&63|128),n.push(i>>6&63|128),n.push(63&i|128)}else n.push(t>>12|224),n.push(t>>6&63|128),n.push(63&t|128)}return new Uint8Array(n)}function Ie(e,t){return n=function(e,t){null==t&&(t=Ue.error);const n=fe(e,"bytes"),r=[];let s=0;for(;s<n.length;){const e=n[s++];if(!(e>>7)){r.push(e);continue}let i=null,o=null;if(192==(224&e))i=1,o=127;else if(224==(240&e))i=2,o=2047;else{if(240!=(248&e)){s+=t(128==(192&e)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",s-1,n,r);continue}i=3,o=65535}if(s-1+i>=n.length){s+=t("OVERRUN",s-1,n,r);continue}let a=e&(1<<8-i-1)-1;for(let l=0;l<i;l++){let e=n[s];if(128!=(192&e)){s+=t("MISSING_CONTINUE",s,n,r),a=null;break}a=a<<6|63&e,s++}null!==a&&(a>1114111?s+=t("OUT_OF_RANGE",s-1-i,n,r,a):a>=55296&&a<=57343?s+=t("UTF16_SURROGATE",s-1-i,n,r,a):a<=o?s+=t("OVERLONG",s-1-i,n,r,a):r.push(a))}return r}(e,t),n.map((e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e))))).join("");var n}const Le=BigInt(-1),Ge=BigInt(0),De=BigInt(1),Be=BigInt(5),We={};let $e="0000";for(;$e.length<80;)$e+=$e;function ze(e){let t=$e;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function Ve(e,t,n){const r=BigInt(t.width);if(t.signed){const t=De<<r-De;le(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>Ge?ke(Ae(e,r),r):-ke(Ae(-e,r),r)}else{const t=De<<r;le(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-De}return e}function He(e){"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,n=128,r=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);ce(s,"invalid fixed format","format",e),t="u"!==s[1],n=parseInt(s[2]),r=parseInt(s[3])}else if(e){const s=e,i=(e,t,n)=>null==s[e]?n:(ce(typeof s[e]===t,"invalid fixed format ("+e+" not "+t+")","format."+e,s[e]),s[e]);t=i("signed","boolean",t),n=i("width","number",n),r=i("decimals","number",r)}ce(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),ce(r<=80,"invalid FixedNumber decimals (too large)","format.decimals",r);return{signed:t,width:n,decimals:r,name:(t?"":"u")+"fixed"+String(n)+"x"+String(r)}}const Ke=class e{constructor(e,t,n){__privateAdd(this,o),__privateAdd(this,l),__privateAdd(this,u),__privateAdd(this,h),__privateAdd(this,f),__privateAdd(this,g),__publicField(this,"format"),__privateAdd(this,r,void 0),__privateAdd(this,s,void 0),__privateAdd(this,i,void 0),__publicField(this,"_value"),he(e,We,"FixedNumber"),__privateSet(this,s,t),__privateSet(this,r,n);const a=function(e,t){let n="";e<Ge&&(n="-",e*=Le);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=$e+r;const s=r.length-t;for(r=r.substring(0,s)+"."+r.substring(s);"0"===r[0]&&"."!==r[1];)r=r.substring(1);for(;"0"===r[r.length-1]&&"."!==r[r.length-2];)r=r.substring(0,r.length-1);return n+r}(t,n.decimals);re(this,{format:n.name,_value:a}),__privateSet(this,i,ze(n.decimals))}get signed(){return __privateGet(this,r).signed}get width(){return __privateGet(this,r).width}get decimals(){return __privateGet(this,r).decimals}get value(){return __privateGet(this,s)}addUnsafe(e){return __privateMethod(this,u,d).call(this,e)}add(e){return __privateMethod(this,u,d).call(this,e,"add")}subUnsafe(e){return __privateMethod(this,h,p).call(this,e)}sub(e){return __privateMethod(this,h,p).call(this,e,"sub")}mulUnsafe(e){return __privateMethod(this,f,m).call(this,e)}mul(e){return __privateMethod(this,f,m).call(this,e,"mul")}mulSignal(e){__privateMethod(this,o,a).call(this,e);const t=__privateGet(this,s)*__privateGet(e,s);return le(t%__privateGet(this,i)===Ge,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,l,c).call(this,t/__privateGet(this,i),"mulSignal")}divUnsafe(e){return __privateMethod(this,g,y).call(this,e)}div(e){return __privateMethod(this,g,y).call(this,e,"div")}divSignal(e){le(__privateGet(e,s)!==Ge,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,o,a).call(this,e);const t=__privateGet(this,s)*__privateGet(this,i);return le(t%__privateGet(e,s)===Ge,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,l,c).call(this,t/__privateGet(e,s),"divSignal")}cmp(e){let t=this.value,n=e.value;const r=this.decimals-e.decimals;return r>0?n*=ze(r):r<0&&(t*=ze(-r)),t<n?-1:t>n?1:0}eq(e){return 0===this.cmp(e)}lt(e){return this.cmp(e)<0}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)>0}gte(e){return this.cmp(e)>=0}floor(){let e=__privateGet(this,s);return __privateGet(this,s)<Ge&&(e-=__privateGet(this,i)-De),e=__privateGet(this,s)/__privateGet(this,i)*__privateGet(this,i),__privateMethod(this,l,c).call(this,e,"floor")}ceiling(){let e=__privateGet(this,s);return __privateGet(this,s)>Ge&&(e+=__privateGet(this,i)-De),e=__privateGet(this,s)/__privateGet(this,i)*__privateGet(this,i),__privateMethod(this,l,c).call(this,e,"ceiling")}round(t){if(null==t&&(t=0),t>=this.decimals)return this;const n=this.decimals-t,s=Be*ze(n-1);let i=this.value+s;const o=ze(n);return i=i/o*o,Ve(i,__privateGet(this,r),"round"),new e(We,i,__privateGet(this,r))}isZero(){return __privateGet(this,s)===Ge}isNegative(){return __privateGet(this,s)<Ge}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return e.fromString(this.toString(),t)}static fromValue(t,n,r){const s=null==n?0:Ce(n),i=He(r);let o=Te(t,"value");const a=s-i.decimals;if(a>0){const e=ze(a);le(o%e===Ge,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:t}),o/=e}else a<0&&(o*=ze(-a));return Ve(o,i,"fromValue"),new e(We,o,i)}static fromString(t,n){const r=t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);ce(r&&r[2].length+r[3].length>0,"invalid FixedNumber string value","value",t);const s=He(n);let i=r[2]||"0",o=r[3]||"";for(;o.length<s.decimals;)o+=$e;le(o.substring(s.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:t}),o=o.substring(0,s.decimals);const a=BigInt(r[1]+i+o);return Ve(a,s,"fromString"),new e(We,a,s)}static fromBytes(t,n){let r=Re(fe(t,"value"));const s=He(n);return s.signed&&(r=ke(r,s.width)),Ve(r,s,"fromBytes"),new e(We,r,s)}};r=new WeakMap,s=new WeakMap,i=new WeakMap,o=new WeakSet,a=function(e){ce(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)},l=new WeakSet,c=function(e,t){return e=Ve(e,__privateGet(this,r),t),new Ke(We,e,__privateGet(this,r))},u=new WeakSet,d=function(e,t){return __privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)+__privateGet(e,s),t)},h=new WeakSet,p=function(e,t){return __privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)-__privateGet(e,s),t)},f=new WeakSet,m=function(e,t){return __privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)*__privateGet(e,s)/__privateGet(this,i),t)},g=new WeakSet,y=function(e,t){return le(__privateGet(e,s)!==Ge,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)*__privateGet(this,i)/__privateGet(e,s),t)};let qe=Ke;const Je=["wei","kwei","mwei","gwei","szabo","finney","ether"];const Qe=32,Xe=new Uint8Array(Qe),Ye=["then"],Ze={},et=new WeakMap;function tt(e){return et.get(e)}function nt(e,t){et.set(e,t)}function rt(e,t){const n=new Error(`deferred error during ABI decoding triggered accessing ${e}`);throw n.error=t,n}function st(e,t,n){return e.indexOf(null)>=0?t.map(((e,t)=>e instanceof it?st(tt(e),e,n):e)):e.reduce(((e,r,s)=>{let i=t.getValue(r);return r in e||(n&&i instanceof it&&(i=st(tt(i),i,n)),e[r]=i),e}),{})}_=new WeakMap;let it=class e extends Array{constructor(...e){const t=e[0];let n=e[1],r=(e[2]||[]).slice(),s=!0;t!==Ze&&(n=e,r=[],s=!1),super(n.length),__privateAdd(this,_,void 0),n.forEach(((e,t)=>{this[t]=e}));const i=r.reduce(((e,t)=>("string"==typeof t&&e.set(t,(e.get(t)||0)+1),e)),new Map);if(nt(this,Object.freeze(n.map(((e,t)=>{const n=r[t];return null!=n&&1===i.get(n)?n:null})))),__privateSet(this,_,[]),null==__privateGet(this,_)&&__privateGet(this,_),!s)return;Object.freeze(this);const o=new Proxy(this,{get:(e,t,n)=>{if("string"==typeof t){if(t.match(/^[0-9]+$/)){const n=Ce(t,"%index");if(n<0||n>=this.length)throw new RangeError("out of result range");const r=e[n];return r instanceof Error&&rt(`index ${n}`,r),r}if(Ye.indexOf(t)>=0)return Reflect.get(e,t,n);const r=e[t];if(r instanceof Function)return function(...t){return r.apply(this===n?e:this,t)};if(!(t in e))return e.getValue.apply(this===n?e:this,[t])}return Reflect.get(e,t,n)}});return nt(o,tt(this)),o}toArray(t){const n=[];return this.forEach(((r,s)=>{r instanceof Error&&rt(`index ${s}`,r),t&&r instanceof e&&(r=r.toArray(t)),n.push(r)})),n}toObject(e){const t=tt(this);return t.reduce(((n,r,s)=>(le(null!=r,`value at index ${s} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),st(t,this,e))),{})}slice(t,n){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==n&&(n=this.length),n<0&&(n+=this.length)<0&&(n=0),n>this.length&&(n=this.length);const r=tt(this),s=[],i=[];for(let e=t;e<n;e++)s.push(this[e]),i.push(r[e]);return new e(Ze,s,i)}filter(t,n){const r=tt(this),s=[],i=[];for(let e=0;e<this.length;e++){const o=this[e];o instanceof Error&&rt(`index ${e}`,o),t.call(n,o,e,this)&&(s.push(o),i.push(r[e]))}return new e(Ze,s,i)}map(e,t){const n=[];for(let r=0;r<this.length;r++){const s=this[r];s instanceof Error&&rt(`index ${r}`,s),n.push(e.call(t,s,r,this))}return n}getValue(e){const t=tt(this).indexOf(e);if(-1===t)return;const n=this[t];return n instanceof Error&&rt(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(t,n){return new e(Ze,t,n)}};function ot(e){let t=function(e){const t=Se(e,"value");if(t===xe)return new Uint8Array([]);let n=t.toString(16);n.length%2&&(n="0"+n);const r=new Uint8Array(n.length/2);for(let s=0;s<r.length;s++){const e=2*s;r[s]=parseInt(n.substring(e,e+2),16)}return r}(e);return le(t.length<=Qe,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:Qe,offset:t.length}),t.length!==Qe&&(t=me(be([Xe.slice(t.length%Qe),t]))),t}class at{constructor(e,t,n,r){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),re(this,{name:e,type:t,localName:n,dynamic:r},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){ce(!1,e,this.localName,t)}}class lt{constructor(){__privateAdd(this,v),__privateAdd(this,b,void 0),__privateAdd(this,w,void 0),__privateSet(this,b,[]),__privateSet(this,w,0)}get data(){return be(__privateGet(this,b))}get length(){return __privateGet(this,w)}appendWriter(e){return __privateMethod(this,v,x).call(this,me(e.data))}writeBytes(e){let t=me(e);const n=t.length%Qe;return n&&(t=me(be([t,Xe.slice(n)]))),__privateMethod(this,v,x).call(this,t)}writeValue(e){return __privateMethod(this,v,x).call(this,ot(e))}writeUpdatableValue(){const e=__privateGet(this,b).length;return __privateGet(this,b).push(Xe),__privateSet(this,w,__privateGet(this,w)+Qe),t=>{__privateGet(this,b)[e]=ot(t)}}}b=new WeakMap,w=new WeakMap,v=new WeakSet,x=function(e){return __privateGet(this,b).push(e),__privateSet(this,w,__privateGet(this,w)+e.length),e.length};E=new WeakMap,N=new WeakMap,k=new WeakMap,A=new WeakMap,T=new WeakMap,S=new WeakSet,O=function(e){var t;if(__privateGet(this,A))return __privateMethod(t=__privateGet(this,A),S,O).call(t,e);__privateSet(this,k,__privateGet(this,k)+e),le(__privateGet(this,T)<1||__privateGet(this,k)<=__privateGet(this,T)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${__privateGet(this,T)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:me(__privateGet(this,E)),offset:__privateGet(this,N),length:e,info:{bytesRead:__privateGet(this,k),dataLength:this.dataLength}})},R=new WeakSet,C=function(e,t,n){let r=Math.ceil(t/Qe)*Qe;return __privateGet(this,N)+r>__privateGet(this,E).length&&(this.allowLoose&&n&&__privateGet(this,N)+t<=__privateGet(this,E).length?r=t:le(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:me(__privateGet(this,E)),length:__privateGet(this,E).length,offset:__privateGet(this,N)+r})),__privateGet(this,E).slice(__privateGet(this,N),__privateGet(this,N)+r)};let ct=class e{constructor(e,t,n){__privateAdd(this,S),__privateAdd(this,R),__publicField(this,"allowLoose"),__privateAdd(this,E,void 0),__privateAdd(this,N,void 0),__privateAdd(this,k,void 0),__privateAdd(this,A,void 0),__privateAdd(this,T,void 0),re(this,{allowLoose:!!t}),__privateSet(this,E,me(e)),__privateSet(this,k,0),__privateSet(this,A,null),__privateSet(this,T,null!=n?n:1024),__privateSet(this,N,0)}get data(){return _e(__privateGet(this,E))}get dataLength(){return __privateGet(this,E).length}get consumed(){return __privateGet(this,N)}get bytes(){return new Uint8Array(__privateGet(this,E))}subReader(t){const n=new e(__privateGet(this,E).slice(__privateGet(this,N)+t),this.allowLoose,__privateGet(this,T));return __privateSet(n,A,this),n}readBytes(e,t){let n=__privateMethod(this,R,C).call(this,0,e,!!t);return __privateMethod(this,S,O).call(this,e),__privateSet(this,N,__privateGet(this,N)+n.length),n.slice(0,e)}readValue(){return Re(this.readBytes(Qe))}readIndex(){return Ce(Re(this.readBytes(Qe)))}};function ut(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function dt(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function ht(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function pt(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!(e instanceof Uint8Array))throw new Error("expected Uint8Array, got "+typeof e);return e}class ft{clone(){return this._cloneInto()}}const mt=BigInt(__pow(2,32)-1),gt=BigInt(32);function yt(e,t=!1){return t?{h:Number(e&mt),l:Number(e>>gt&mt)}:{h:0|Number(e>>gt&mt),l:0|Number(e&mt)}}function _t(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:i,l:o}=yt(e[s],t);[n[s],r[s]]=[i,o]}return[n,r]}const[bt,wt,vt]=[[],[],[]],xt=BigInt(0),Et=BigInt(1),Nt=BigInt(2),kt=BigInt(7),At=BigInt(256),Tt=BigInt(113);for(let Ei=0,Ni=Et,ki=1,Ai=0;Ei<24;Ei++){[ki,Ai]=[Ai,(2*ki+3*Ai)%5],bt.push(2*(5*Ai+ki)),wt.push((Ei+1)*(Ei+2)/2%64);let e=xt;for(let t=0;t<7;t++)Ni=(Ni<<Et^(Ni>>kt)*Tt)%At,Ni&Nt&&(e^=Et<<(Et<<BigInt(t))-Et);vt.push(e)}const[St,Ot]=_t(vt,!0),Rt=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),Ct=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class Mt extends ft{constructor(e,t,n,r=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ut(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}keccak(){!function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let r=0;r<10;r++)n[r]=e[r]^e[r+10]^e[r+20]^e[r+30]^e[r+40];for(let r=0;r<10;r+=2){const t=(r+8)%10,s=(r+2)%10,i=n[s],o=n[s+1],a=Rt(i,o,1)^n[t],l=Ct(i,o,1)^n[t+1];for(let n=0;n<50;n+=10)e[r+n]^=a,e[r+n+1]^=l}let t=e[2],s=e[3];for(let n=0;n<24;n++){const r=wt[n],i=Rt(t,s,r),o=Ct(t,s,r),a=bt[n];t=e[a],s=e[a+1],e[a]=i,e[a+1]=o}for(let r=0;r<50;r+=10){for(let t=0;t<10;t++)n[t]=e[r+t];for(let t=0;t<10;t++)e[r+t]^=~n[(t+2)%10]&n[(t+4)%10]}e[0]^=St[r],e[1]^=Ot[r]}n.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){ht(this);const{blockLen:t,state:n}=this,r=(e=pt(e)).length;for(let s=0;s<r;){const i=Math.min(t-this.pos,r-s);for(let t=0;t<i;t++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){ht(this,!1),dt(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ut(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(function(e,t){dt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return e||(e=new Mt(t,n,r,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const Pt=((e,t,n)=>function(e){const t=t=>e().update(pt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}((()=>new Mt(t,e,n))))(1,136,32);let Ft=!1;const Ut=function(e){return Pt(e)};let jt=Ut;function It(e){const t=fe(e,"data");return _e(jt(t))}It._=Ut,It.lock=function(){Ft=!0},It.register=function(e){if(Ft)throw new TypeError("keccak256 is locked");jt=e},Object.freeze(It);const Lt=BigInt(0),Gt=BigInt(36);function Dt(e){const t=(e=e.toLowerCase()).substring(2).split(""),n=new Uint8Array(40);for(let s=0;s<40;s++)n[s]=t[s].charCodeAt(0);const r=fe(It(n));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(15&r[s>>1])>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const Bt={};for(let Ei=0;Ei<10;Ei++)Bt[String(Ei)]=String(Ei);for(let Ei=0;Ei<26;Ei++)Bt[String.fromCharCode(65+Ei)]=String(10+Ei);const Wt=function(){const e={};for(let t=0;t<36;t++){e["0123456789abcdefghijklmnopqrstuvwxyz"[t]]=BigInt(t)}return e}();function $t(e){if(ce("string"==typeof e,"invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/)){e.startsWith("0x")||(e="0x"+e);const t=Dt(e);return ce(!e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===e,"bad address checksum","address",e),t}if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){ce(e.substring(2,4)===function(e){let t=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((e=>Bt[e])).join("");for(;t.length>=15;){let e=t.substring(0,15);t=parseInt(e,10)%97+t.substring(e.length)}let n=String(98-parseInt(t,10)%97);for(;n.length<2;)n="0"+n;return n}(e),"bad icap checksum","address",e);let t=function(e){e=e.toLowerCase();let t=Lt;for(let n=0;n<e.length;n++)t=t*Gt+Wt[e[n]];return t}(e.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return Dt("0x"+t)}ce(!1,"invalid address","address",e)}function zt(e){return e&&"function"==typeof e.getAddress}function Vt(e,t){return __async(this,null,(function*(){const n=yield t;return null!=n&&"0x0000000000000000000000000000000000000000"!==n||(le("string"!=typeof e,"unconfigured name","UNCONFIGURED_NAME",{value:e}),ce(!1,"invalid AddressLike value; did not resolve to a value address","target",e)),$t(n)}))}function Ht(e,t){return"string"==typeof e?e.match(/^0x[0-9a-f]{40}$/i)?$t(e):(le(null!=t,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Vt(e,t.resolveName(e))):zt(e)?Vt(e,e.getAddress()):e&&"function"==typeof e.then?Vt(e,e):void ce(!1,"unsupported addressable value","target",e)}const Kt={};function qt(e,t){let n=!1;return t<0&&(n=!0,t*=-1),new Xt(Kt,`${n?"":"u"}int${t}`,e,{signed:n,width:t})}function Jt(e,t){return new Xt(Kt,`bytes${t||""}`,e,{size:t})}const Qt=Symbol.for("_ethers_typed");M=new WeakMap;let Xt=class e{constructor(e,t,n,r){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,M,void 0),__publicField(this,"_typedSymbol"),null==r&&(r=null),he(Kt,e,"Typed"),re(this,{_typedSymbol:Qt,type:t,value:n}),__privateSet(this,M,r),this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((e=>e.format())).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return __privateGet(this,M)}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===__privateGet(this,M)?-1:!1===__privateGet(this,M)?this.value.length:null}static from(t,n){return new e(Kt,t,n)}static uint8(e){return qt(e,8)}static uint16(e){return qt(e,16)}static uint24(e){return qt(e,24)}static uint32(e){return qt(e,32)}static uint40(e){return qt(e,40)}static uint48(e){return qt(e,48)}static uint56(e){return qt(e,56)}static uint64(e){return qt(e,64)}static uint72(e){return qt(e,72)}static uint80(e){return qt(e,80)}static uint88(e){return qt(e,88)}static uint96(e){return qt(e,96)}static uint104(e){return qt(e,104)}static uint112(e){return qt(e,112)}static uint120(e){return qt(e,120)}static uint128(e){return qt(e,128)}static uint136(e){return qt(e,136)}static uint144(e){return qt(e,144)}static uint152(e){return qt(e,152)}static uint160(e){return qt(e,160)}static uint168(e){return qt(e,168)}static uint176(e){return qt(e,176)}static uint184(e){return qt(e,184)}static uint192(e){return qt(e,192)}static uint200(e){return qt(e,200)}static uint208(e){return qt(e,208)}static uint216(e){return qt(e,216)}static uint224(e){return qt(e,224)}static uint232(e){return qt(e,232)}static uint240(e){return qt(e,240)}static uint248(e){return qt(e,248)}static uint256(e){return qt(e,256)}static uint(e){return qt(e,256)}static int8(e){return qt(e,-8)}static int16(e){return qt(e,-16)}static int24(e){return qt(e,-24)}static int32(e){return qt(e,-32)}static int40(e){return qt(e,-40)}static int48(e){return qt(e,-48)}static int56(e){return qt(e,-56)}static int64(e){return qt(e,-64)}static int72(e){return qt(e,-72)}static int80(e){return qt(e,-80)}static int88(e){return qt(e,-88)}static int96(e){return qt(e,-96)}static int104(e){return qt(e,-104)}static int112(e){return qt(e,-112)}static int120(e){return qt(e,-120)}static int128(e){return qt(e,-128)}static int136(e){return qt(e,-136)}static int144(e){return qt(e,-144)}static int152(e){return qt(e,-152)}static int160(e){return qt(e,-160)}static int168(e){return qt(e,-168)}static int176(e){return qt(e,-176)}static int184(e){return qt(e,-184)}static int192(e){return qt(e,-192)}static int200(e){return qt(e,-200)}static int208(e){return qt(e,-208)}static int216(e){return qt(e,-216)}static int224(e){return qt(e,-224)}static int232(e){return qt(e,-232)}static int240(e){return qt(e,-240)}static int248(e){return qt(e,-248)}static int256(e){return qt(e,-256)}static int(e){return qt(e,-256)}static bytes1(e){return Jt(e,1)}static bytes2(e){return Jt(e,2)}static bytes3(e){return Jt(e,3)}static bytes4(e){return Jt(e,4)}static bytes5(e){return Jt(e,5)}static bytes6(e){return Jt(e,6)}static bytes7(e){return Jt(e,7)}static bytes8(e){return Jt(e,8)}static bytes9(e){return Jt(e,9)}static bytes10(e){return Jt(e,10)}static bytes11(e){return Jt(e,11)}static bytes12(e){return Jt(e,12)}static bytes13(e){return Jt(e,13)}static bytes14(e){return Jt(e,14)}static bytes15(e){return Jt(e,15)}static bytes16(e){return Jt(e,16)}static bytes17(e){return Jt(e,17)}static bytes18(e){return Jt(e,18)}static bytes19(e){return Jt(e,19)}static bytes20(e){return Jt(e,20)}static bytes21(e){return Jt(e,21)}static bytes22(e){return Jt(e,22)}static bytes23(e){return Jt(e,23)}static bytes24(e){return Jt(e,24)}static bytes25(e){return Jt(e,25)}static bytes26(e){return Jt(e,26)}static bytes27(e){return Jt(e,27)}static bytes28(e){return Jt(e,28)}static bytes29(e){return Jt(e,29)}static bytes30(e){return Jt(e,30)}static bytes31(e){return Jt(e,31)}static bytes32(e){return Jt(e,32)}static address(t){return new e(Kt,"address",t)}static bool(t){return new e(Kt,"bool",!!t)}static bytes(t){return new e(Kt,"bytes",t)}static string(t){return new e(Kt,"string",t)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(t){return new e(Kt,"overrides",Object.assign({},t))}static isTyped(e){return e&&"object"==typeof e&&"_typedSymbol"in e&&e._typedSymbol===Qt}static dereference(t,n){if(e.isTyped(t)){if(t.type!==n)throw new Error(`invalid type: expecetd ${n}, got ${t.type}`);return t.value}return t}};class Yt extends at{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=Xt.dereference(t,"string");try{n=$t(n)}catch(r){return this._throwError(r.message,t)}return e.writeValue(n)}decode(e){return $t(Me(e.readValue(),20))}}class Zt extends at{constructor(e){super(e.name,e.type,"_",e.dynamic),__publicField(this,"coder"),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}function en(e,t,n){let r=[];if(Array.isArray(n))r=n;else if(n&&"object"==typeof n){let e={};r=t.map((t=>{const r=t.localName;return le(r,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:t},value:n}),le(!e[r],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:t},value:n}),e[r]=!0,n[r]}))}else ce(!1,"invalid tuple value","tuple",n);ce(t.length===r.length,"types/value length mismatch","tuple",n);let s=new lt,i=new lt,o=[];t.forEach(((e,t)=>{let n=r[t];if(e.dynamic){let t=i.length;e.encode(i,n);let r=s.writeUpdatableValue();o.push((e=>{r(e+t)}))}else e.encode(s,n)})),o.forEach((e=>{e(s.length)}));let a=e.appendWriter(s);return a+=e.appendWriter(i),a}function tn(e,t){let n=[],r=[],s=e.subReader(0);return t.forEach((t=>{let i=null;if(t.dynamic){let n=e.readIndex(),r=s.subReader(n);try{i=t.decode(r)}catch(o){if(ie(o,"BUFFER_OVERRUN"))throw o;i=o,i.baseType=t.name,i.name=t.localName,i.type=t.type}}else try{i=t.decode(e)}catch(o){if(ie(o,"BUFFER_OVERRUN"))throw o;i=o,i.baseType=t.name,i.name=t.localName,i.type=t.type}if(null==i)throw new Error("investigate");n.push(i),r.push(t.localName||null)})),it.fromItems(n,r)}class nn extends at{constructor(e,t,n){super("array",e.type+"["+(t>=0?t:"")+"]",n,-1===t||e.dynamic),__publicField(this,"coder"),__publicField(this,"length"),re(this,{coder:e,length:t})}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){const n=Xt.dereference(t,"array");Array.isArray(n)||this._throwError("expected array value",n);let r=this.length;-1===r&&(r=n.length,e.writeValue(n.length)),ue(n.length,r,"coder array"+(this.localName?" "+this.localName:""));let s=[];for(let i=0;i<n.length;i++)s.push(this.coder);return en(e,s,n)}decode(e){let t=this.length;-1===t&&(t=e.readIndex(),le(t*Qe<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:t*Qe,length:e.dataLength}));let n=[];for(let r=0;r<t;r++)n.push(new Zt(this.coder));return tn(e,n)}}class rn extends at{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=Xt.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class sn extends at{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=me(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class on extends sn{constructor(e){super("bytes",e)}decode(e){return _e(super.decode(e))}}class an extends at{constructor(e,t){let n="bytes"+String(e);super(n,n,t,!1),__publicField(this,"size"),re(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let n=me(Xt.dereference(t,this.type));return n.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(n)}decode(e){return _e(e.readBytes(this.size))}}const ln=new Uint8Array([]);class cn extends at{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes(ln)}decode(e){return e.readBytes(0),null}}const un=BigInt(0),dn=BigInt(1),hn=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class pn extends at{constructor(e,t,n){const r=(t?"int":"uint")+8*e;super(r,r,n,!1),__publicField(this,"size"),__publicField(this,"signed"),re(this,{size:e,signed:t},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,t){let n=Te(Xt.dereference(t,this.type)),r=Ae(hn,256);if(this.signed){let e=Ae(r,8*this.size-1);(n>e||n<-(e+dn))&&this._throwError("value out-of-bounds",t),n=function(e,t){let n=Te(e,"value");const r=BigInt(Ce(t,"width")),s=Ee<<r-Ee;if(n<xe)return n=-n,le(n<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e}),(~n&(Ee<<r)-Ee)+Ee;return le(n<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e}),n}(n,256)}else(n<un||n>Ae(r,8*this.size))&&this._throwError("value out-of-bounds",t);return e.writeValue(n)}decode(e){let t=Ae(e.readValue(),8*this.size);return this.signed&&(t=ke(t,8*this.size)),t}}class fn extends sn{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,je(Xt.dereference(t,"string")))}decode(e){return Ie(super.decode(e))}}class mn extends at{constructor(e,t){let n=!1;const r=[];e.forEach((e=>{e.dynamic&&(n=!0),r.push(e.type)}));super("tuple","tuple("+r.join(",")+")",t,n),__publicField(this,"coders"),re(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});return this.coders.forEach(((n,r)=>{let s=n.localName;s&&1===t[s]&&("length"===s&&(s="_length"),null==e[s]&&(e[s]=e[r]))})),Object.freeze(e)}encode(e,t){const n=Xt.dereference(t,"tuple");return en(e,this.coders,n)}decode(e){return tn(e,this.coders)}}function gn(e,t){return{address:$t(e),storageKeys:t.map(((e,t)=>(ce(ge(e,32),"invalid slot",`storageKeys[${t}]`,e),e.toLowerCase())))}}function yn(e){return It(je(e))}function _n(e){const t=new Set;return e.forEach((e=>t.add(e))),Object.freeze(t)}const bn=_n("external public payable override".split(" ")),wn="constant external internal payable private public pure view override",vn=_n(wn.split(" ")),xn="constructor error event fallback function receive struct",En=_n(xn.split(" ")),Nn="calldata memory storage payable indexed",kn=_n(Nn.split(" ")),An=_n([xn,Nn,"tuple returns",wn].join(" ").split(" ")),Tn={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Sn=new RegExp("^(\\s*)"),On=new RegExp("^([0-9]+)"),Rn=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Cn=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),Mn=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Pn=class e{constructor(e){__privateAdd(this,U),__privateAdd(this,P,void 0),__privateAdd(this,F,void 0),__privateSet(this,P,0),__privateSet(this,F,e.slice())}get offset(){return __privateGet(this,P)}get length(){return __privateGet(this,F).length-__privateGet(this,P)}clone(){return new e(__privateGet(this,F))}reset(){__privateSet(this,P,0)}popKeyword(e){const t=this.peek();if("KEYWORD"!==t.type||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if("OPEN_PAREN"!==e.type)throw new Error("bad start");const t=__privateMethod(this,U,j).call(this,__privateGet(this,P)+1,e.match+1);return __privateSet(this,P,e.match+1),t}popParams(){const e=this.peek();if("OPEN_PAREN"!==e.type)throw new Error("bad start");const t=[];for(;__privateGet(this,P)<e.match-1;){const e=this.peek().linkNext;t.push(__privateMethod(this,U,j).call(this,__privateGet(this,P)+1,e)),__privateSet(this,P,e)}return __privateSet(this,P,e.match+1),t}peek(){if(__privateGet(this,P)>=__privateGet(this,F).length)throw new Error("out-of-bounds");return __privateGet(this,F)[__privateGet(this,P)]}peekKeyword(e){const t=this.peekType("KEYWORD");return null!=t&&e.has(t)?t:null}peekType(e){if(0===this.length)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return __privateWrapper(this,P)._++,e}toString(){const e=[];for(let t=__privateGet(this,P);t<__privateGet(this,F).length;t++){const n=__privateGet(this,F)[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}};P=new WeakMap,F=new WeakMap,U=new WeakSet,j=function(e=0,t=0){return new Pn(__privateGet(this,F).slice(e,t).map((t=>Object.freeze(Object.assign({},t,{match:t.match-e,linkBack:t.linkBack-e,linkNext:t.linkNext-e})))))};let Fn=Pn;function Un(e){const t=[],n=t=>{const n=i<e.length?JSON.stringify(e[i]):"$EOI";throw new Error(`invalid token ${n} at ${i}: ${t}`)};let r=[],s=[],i=0;for(;i<e.length;){let o=e.substring(i),a=o.match(Sn);a&&(i+=a[1].length,o=e.substring(i));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};t.push(l);let c=Tn[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,"OPEN_PAREN"===c)r.push(t.length-1),s.push(t.length-1);else if("CLOSE_PAREN"==c)0===r.length&&n("no matching open bracket"),l.match=r.pop(),t[l.match].match=t.length-1,l.depth--,l.linkBack=s.pop(),t[l.linkBack].linkNext=t.length-1;else if("COMMA"===c)l.linkBack=s.pop(),t[l.linkBack].linkNext=t.length-1,s.push(t.length-1);else if("OPEN_BRACKET"===c)l.type="BRACKET";else if("CLOSE_BRACKET"===c){let e=t.pop().text;if(t.length>0&&"NUMBER"===t[t.length-1].type){const n=t.pop().text;e=n+e,t[t.length-1].value=Ce(n)}if(0===t.length||"BRACKET"!==t[t.length-1].type)throw new Error("missing opening bracket");t[t.length-1].text+=e}}else if(a=o.match(Rn),a){if(l.text=a[1],i+=l.text.length,An.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(Mn)){l.type="TYPE";continue}l.type="ID"}else{if(a=o.match(On),!a)throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`);l.text=a[1],l.type="NUMBER",i+=l.text.length}}return new Fn(t.map((e=>Object.freeze(e))))}function jn(e,t){let n=[];for(const r in t.keys())e.has(r)&&n.push(r);if(n.length>1)throw new Error(`conflicting types: ${n.join(", ")}`)}function In(e,t){if(t.peekKeyword(En)){const n=t.pop().text;if(n!==e)throw new Error(`expected ${e}, got ${n}`)}return t.popType("ID")}function Ln(e,t){const n=new Set;for(;;){const r=e.peekType("KEYWORD");if(null==r||t&&!t.has(r))break;if(e.pop(),n.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}function Gn(e){let t=Ln(e,vn);return jn(t,_n("constant payable nonpayable".split(" "))),jn(t,_n("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function Dn(e,t){return e.popParams().map((e=>er.from(e,t)))}function Bn(e){if(e.peekType("AT")){if(e.pop(),e.peekType("NUMBER"))return Te(e.pop().text);throw new Error("invalid gas")}return null}function Wn(e){if(e.length)throw new Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`)}const $n=new RegExp(/^(.*)\[([0-9]*)\]$/);function zn(e){const t=e.match(Mn);if(ce(t,"invalid type","type",e),"uint"===e)return"uint256";if("int"===e)return"int256";if(t[2]){const n=parseInt(t[2]);ce(0!==n&&n<=32,"invalid bytes length","type",e)}else if(t[3]){const n=parseInt(t[3]);ce(0!==n&&n<=256&&n%8==0,"invalid numeric width","type",e)}return e}const Vn={},Hn=Symbol.for("_ethers_internal"),Kn="_ParamTypeInternal",qn="_ErrorInternal",Jn="_EventInternal",Qn="_ConstructorInternal",Xn="_FallbackInternal",Yn="_FunctionInternal",Zn="_StructInternal";I=new WeakSet,L=function(e,t,n,r){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 s=this.arrayChildren,i=t.slice();return i.forEach(((t,r)=>{var o;__privateMethod(o=s,I,L).call(o,e,t,n,(e=>{i[r]=e}))})),void r(i)}if(this.isTuple()){const s=this.components;let i;if(Array.isArray(t))i=t.slice();else{if(null==t||"object"!=typeof t)throw new Error("invalid tuple value");i=s.map((e=>{if(!e.name)throw new Error("cannot use object value with unnamed components");if(!(e.name in t))throw new Error(`missing value for component ${e.name}`);return t[e.name]}))}if(i.length!==this.components.length)throw new Error("array is wrong length");return i.forEach(((t,r)=>{var o;__privateMethod(o=s[r],I,L).call(o,e,t,n,(e=>{i[r]=e}))})),void r(i)}const s=n(this.type,t);s.then?e.push(function(){return __async(this,null,(function*(){r(yield s)}))}()):r(s)};let er=class e{constructor(e,t,n,r,s,i,o,a){if(__privateAdd(this,I),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),he(e,Vn,"ParamType"),Object.defineProperty(this,Hn,{value:Kn}),i&&(i=Object.freeze(i.slice())),"array"===r){if(null==o||null==a)throw new Error("")}else if(null!=o||null!=a)throw new Error("");if("tuple"===r){if(null==i)throw new Error("")}else if(null!=i)throw new Error("");re(this,{name:t,type:n,baseType:r,indexed:s,components:i,arrayLength:o,arrayChildren:a})}format(e){if(null==e&&(e="sighash"),"json"===e){const t=this.name||"";if(this.isArray()){const e=JSON.parse(this.arrayChildren.format("json"));return e.name=t,e.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(e)}const n={type:"tuple"===this.baseType?"tuple":this.type,name:t};return"boolean"==typeof this.indexed&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(n)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map((t=>t.format(e))).join("full"===e?", ":",")+")":t+=this.type,"sighash"!==e&&(!0===this.indexed&&(t+=" indexed"),"full"===e&&this.name&&(t+=" "+this.name)),t}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(e,t){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 n=this;return e.map((e=>n.arrayChildren.walk(e,t)))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map(((e,r)=>n.components[r].walk(e,t)))}return t(this.type,e)}walkAsync(e,t){return __async(this,null,(function*(){const n=[],r=[e];return __privateMethod(this,I,L).call(this,n,e,t,(e=>{r[0]=e})),n.length&&(yield Promise.all(n)),r[0]}))}static from(t,n){if(e.isParamType(t))return t;if("string"==typeof t)try{return e.from(Un(t),n)}catch(a){ce(!1,"invalid param type","obj",t)}else if(t instanceof Fn){let r="",s="",i=null;Ln(t,_n(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(s="tuple",i=t.popParams().map((t=>e.from(t))),r=`tuple(${i.map((e=>e.format())).join(",")})`):(r=zn(t.popType("TYPE")),s=r);let o=null,a=null;for(;t.length&&t.peekType("BRACKET");){const n=t.pop();o=new e(Vn,"",r,s,null,i,a,o),a=n.value,r+=n.text,s="array",i=null}let l=null;if(Ln(t,kn).has("indexed")){if(!n)throw new Error("");l=!0}const c=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new e(Vn,c,r,s,l,i,a,o)}const r=t.name;ce(!r||"string"==typeof r&&r.match(Cn),"invalid name","obj.name",r);let s=t.indexed;null!=s&&(ce(n,"parameter cannot be indexed","obj.indexed",t.indexed),s=!!s);let i=t.type,o=i.match($n);if(o){const n=parseInt(o[2]||"-1"),a=e.from({type:o[1],components:t.components});return new e(Vn,r||"",i,"array",s,null,n,a)}if("tuple"===i||i.startsWith("tuple(")||i.startsWith("(")){const n=null!=t.components?t.components.map((t=>e.from(t))):null;return new e(Vn,r||"",i,"tuple",s,n,null,null)}return i=zn(t.type),new e(Vn,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Hn]===Kn}};class tr{constructor(e,t,n){__publicField(this,"type"),__publicField(this,"inputs"),he(e,Vn,"Fragment"),re(this,{type:t,inputs:n=Object.freeze(n.slice())})}static from(e){if("string"==typeof e){try{tr.from(JSON.parse(e))}catch(t){}return tr.from(Un(e))}if(e instanceof Fn){switch(e.peekKeyword(En)){case"constructor":return or.from(e);case"error":return sr.from(e);case"event":return ir.from(e);case"fallback":case"receive":return ar.from(e);case"function":return lr.from(e);case"struct":return cr.from(e)}}else if("object"==typeof e){switch(e.type){case"constructor":return or.from(e);case"error":return sr.from(e);case"event":return ir.from(e);case"fallback":case"receive":return ar.from(e);case"function":return lr.from(e);case"struct":return cr.from(e)}le(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}ce(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return or.isFragment(e)}static isError(e){return sr.isFragment(e)}static isEvent(e){return ir.isFragment(e)}static isFunction(e){return lr.isFragment(e)}static isStruct(e){return cr.isFragment(e)}}class nr extends tr{constructor(e,t,n,r){super(e,t,r),__publicField(this,"name"),ce("string"==typeof n&&n.match(Cn),"invalid identifier","name",n),r=Object.freeze(r.slice()),re(this,{name:n})}}function rr(e,t){return"("+t.map((t=>t.format(e))).join("full"===e?", ":",")+")"}class sr extends nr{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,Hn,{value:qn})}get selector(){return yn(this.format("sighash")).substring(0,10)}format(e){if(null==e&&(e="sighash"),"json"===e)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});const t=[];return"sighash"!==e&&t.push("error"),t.push(this.name+rr(e,this.inputs)),t.join(" ")}static from(e){if(sr.isFragment(e))return e;if("string"==typeof e)return sr.from(Un(e));if(e instanceof Fn){const t=In("error",e),n=Dn(e);return Wn(e),new sr(Vn,t,n)}return new sr(Vn,e.name,e.inputs?e.inputs.map(er.from):[])}static isFragment(e){return e&&e[Hn]===qn}}class ir extends nr{constructor(e,t,n,r){super(e,"event",t,n),__publicField(this,"anonymous"),Object.defineProperty(this,Hn,{value:Jn}),re(this,{anonymous:r})}get topicHash(){return yn(this.format("sighash"))}format(e){if(null==e&&(e="sighash"),"json"===e)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});const t=[];return"sighash"!==e&&t.push("event"),t.push(this.name+rr(e,this.inputs)),"sighash"!==e&&this.anonymous&&t.push("anonymous"),t.join(" ")}static getTopicHash(e,t){t=(t||[]).map((e=>er.from(e)));return new ir(Vn,e,t,!1).topicHash}static from(e){if(ir.isFragment(e))return e;if("string"==typeof e)try{return ir.from(Un(e))}catch(t){ce(!1,"invalid event fragment","obj",e)}else if(e instanceof Fn){const t=In("event",e),n=Dn(e,!0),r=!!Ln(e,_n(["anonymous"])).has("anonymous");return Wn(e),new ir(Vn,t,n,r)}return new ir(Vn,e.name,e.inputs?e.inputs.map((e=>er.from(e,!0))):[],!!e.anonymous)}static isFragment(e){return e&&e[Hn]===Jn}}class or extends tr{constructor(e,t,n,r,s){super(e,t,n),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Hn,{value:Qn}),re(this,{payable:r,gas:s})}format(e){if(le(null!=e&&"sighash"!==e,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===e)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((t=>JSON.parse(t.format(e))))});const t=[`constructor${rr(e,this.inputs)}`];return this.payable&&t.push("payable"),null!=this.gas&&t.push(`@${this.gas.toString()}`),t.join(" ")}static from(e){if(or.isFragment(e))return e;if("string"==typeof e)try{return or.from(Un(e))}catch(t){ce(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof Fn){Ln(e,_n(["constructor"]));const t=Dn(e),n=!!Ln(e,bn).has("payable"),r=Bn(e);return Wn(e),new or(Vn,"constructor",t,n,r)}return new or(Vn,"constructor",e.inputs?e.inputs.map(er.from):[],!!e.payable,null!=e.gas?e.gas:null)}static isFragment(e){return e&&e[Hn]===Qn}}class ar extends tr{constructor(e,t,n){super(e,"fallback",t),__publicField(this,"payable"),Object.defineProperty(this,Hn,{value:Xn}),re(this,{payable:n})}format(e){const t=0===this.inputs.length?"receive":"fallback";if("json"===e){const e=this.payable?"payable":"nonpayable";return JSON.stringify({type:t,stateMutability:e})}return`${t}()${this.payable?" payable":""}`}static from(e){if(ar.isFragment(e))return e;if("string"==typeof e)try{return ar.from(Un(e))}catch(t){ce(!1,"invalid fallback fragment","obj",e)}else if(e instanceof Fn){const t=e.toString();ce(e.peekKeyword(_n(["fallback","receive"])),"type must be fallback or receive","obj",t);if("receive"===e.popKeyword(_n(["fallback","receive"]))){const t=Dn(e);return ce(0===t.length,"receive cannot have arguments","obj.inputs",t),Ln(e,_n(["payable"])),Wn(e),new ar(Vn,[],!0)}let n=Dn(e);n.length?ce(1===n.length&&"bytes"===n[0].type,"invalid fallback inputs","obj.inputs",n.map((e=>e.format("minimal"))).join(", ")):n=[er.from("bytes")];const r=Gn(e);if(ce("nonpayable"===r||"payable"===r,"fallback cannot be constants","obj.stateMutability",r),Ln(e,_n(["returns"])).has("returns")){const t=Dn(e);ce(1===t.length&&"bytes"===t[0].type,"invalid fallback outputs","obj.outputs",t.map((e=>e.format("minimal"))).join(", "))}return Wn(e),new ar(Vn,n,"payable"===r)}if("receive"===e.type)return new ar(Vn,[],!0);if("fallback"===e.type){const t=[er.from("bytes")],n="payable"===e.stateMutability;return new ar(Vn,t,n)}ce(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Hn]===Xn}}class lr extends nr{constructor(e,t,n,r,s,i){super(e,"function",t,r),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Hn,{value:Yn});re(this,{constant:"view"===n||"pure"===n,gas:i,outputs:s=Object.freeze(s.slice()),payable:"payable"===n,stateMutability:n})}get selector(){return yn(this.format("sighash")).substring(0,10)}format(e){if(null==e&&(e="sighash"),"json"===e)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((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});const t=[];return"sighash"!==e&&t.push("function"),t.push(this.name+rr(e,this.inputs)),"sighash"!==e&&("nonpayable"!==this.stateMutability&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push("returns"),t.push(rr(e,this.outputs))),null!=this.gas&&t.push(`@${this.gas.toString()}`)),t.join(" ")}static getSelector(e,t){t=(t||[]).map((e=>er.from(e)));return new lr(Vn,e,"view",t,[],null).selector}static from(e){if(lr.isFragment(e))return e;if("string"==typeof e)try{return lr.from(Un(e))}catch(n){ce(!1,"invalid function fragment","obj",e)}else if(e instanceof Fn){const t=In("function",e),n=Dn(e),r=Gn(e);let s=[];Ln(e,_n(["returns"])).has("returns")&&(s=Dn(e));const i=Bn(e);return Wn(e),new lr(Vn,t,r,n,s,i)}let t=e.stateMutability;return null==t&&(t="payable","boolean"==typeof e.constant?(t="view",e.constant||(t="payable","boolean"!=typeof e.payable||e.payable||(t="nonpayable"))):"boolean"!=typeof e.payable||e.payable||(t="nonpayable")),new lr(Vn,e.name,t,e.inputs?e.inputs.map(er.from):[],e.outputs?e.outputs.map(er.from):[],null!=e.gas?e.gas:null)}static isFragment(e){return e&&e[Hn]===Yn}}class cr extends nr{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,Hn,{value:Zn})}format(){throw new Error("@TODO")}static from(e){if("string"==typeof e)try{return cr.from(Un(e))}catch(t){ce(!1,"invalid struct fragment","obj",e)}else if(e instanceof Fn){const t=In("struct",e),n=Dn(e);return Wn(e),new cr(Vn,t,n)}return new cr(Vn,e.name,e.inputs?e.inputs.map(er.from):[])}static isFragment(e){return e&&e[Hn]===Zn}}const ur=new Map;ur.set(0,"GENERIC_PANIC"),ur.set(1,"ASSERT_FALSE"),ur.set(17,"OVERFLOW"),ur.set(18,"DIVIDE_BY_ZERO"),ur.set(33,"ENUM_RANGE_ERROR"),ur.set(34,"BAD_STORAGE_DATA"),ur.set(49,"STACK_UNDERFLOW"),ur.set(50,"ARRAY_RANGE_ERROR"),ur.set(65,"OUT_OF_MEMORY"),ur.set(81,"UNINITIALIZED_FUNCTION_CALL");const dr=new RegExp(/^bytes([0-9]*)$/),hr=new RegExp(/^(u?int)([0-9]*)$/);let pr=null,fr=1024;G=new WeakSet,D=function(e){if(e.isArray())return new nn(__privateMethod(this,G,D).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new mn(e.components.map((e=>__privateMethod(this,G,D).call(this,e))),e.name);switch(e.baseType){case"address":return new Yt(e.name);case"bool":return new rn(e.name);case"string":return new fn(e.name);case"bytes":return new on(e.name);case"":return new cn(e.name)}let t=e.type.match(hr);if(t){let n=parseInt(t[2]||"256");return ce(0!==n&&n<=256&&n%8==0,"invalid "+t[1]+" bit length","param",e),new pn(n/8,"int"===t[1],e.name)}if(t=e.type.match(dr),t){let n=parseInt(t[1]);return ce(0!==n&&n<=32,"invalid bytes length","param",e),new an(n,e.name)}ce(!1,"invalid type","type",e.type)};let mr=class e{constructor(){__privateAdd(this,G)}getDefaultValue(e){const t=e.map((e=>__privateMethod(this,G,D).call(this,er.from(e))));return new mn(t,"_").defaultValue()}encode(e,t){ue(t.length,e.length,"types/values length mismatch");const n=e.map((e=>__privateMethod(this,G,D).call(this,er.from(e)))),r=new mn(n,"_"),s=new lt;return r.encode(s,t),s.data}decode(e,t,n){const r=e.map((e=>__privateMethod(this,G,D).call(this,er.from(e))));return new mn(r,"_").decode(new ct(t,n,fr))}static _setDefaultMaxInflation(e){ce("number"==typeof e&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),fr=e}static defaultAbiCoder(){return null==pr&&(pr=new e),pr}static getBuiltinCallException(t,n,r){return function(e,t,n,r){let s="missing revert data",i=null,o=null;if(n){s="execution reverted";const e=fe(n);if(n=_e(n),0===e.length)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(e.length%32!=4)s+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===_e(e.slice(0,4)))try{i=r.decode(["string"],e.slice(4))[0],o={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch(l){s+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===_e(e.slice(0,4)))try{const t=Number(r.decode(["uint256"],e.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[t]},i=`Panic due to ${ur.get(t)||"UNKNOWN"}(${t})`,s+=`: ${i}`}catch(l){s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const a={to:t.to?$t(t.to):null,data:t.data||"0x"};return t.from&&(a.from=$t(t.from)),ae(s,"CALL_EXCEPTION",{action:e,data:n,reason:i,transaction:a,invocation:null,revert:o})}(t,n,r,e.defaultAbiCoder())}};class gr{constructor(e,t,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const r=e.name,s=e.format();re(this,{fragment:e,name:r,signature:s,topic:t,args:n})}}class yr{constructor(e,t,n,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector"),__publicField(this,"value");const s=e.name,i=e.format();re(this,{fragment:e,name:s,args:n,signature:i,selector:t,value:r})}}class _r{constructor(e,t,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const r=e.name,s=e.format();re(this,{fragment:e,name:r,args:n,signature:s,selector:t})}}class br{constructor(e){__publicField(this,"hash"),__publicField(this,"_isIndexed"),re(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!(!e||!e._isIndexed)}}const wr={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"},vr={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:e=>`reverted with reason string ${JSON.stringify(e)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:e=>{let t="unknown panic code";return e>=0&&e<=255&&wr[e.toString()]&&(t=wr[e.toString()]),`reverted with panic code 0x${e.toString(16)} (${t})`}}};B=new WeakMap,W=new WeakMap,$=new WeakMap,z=new WeakMap,V=new WeakSet,H=function(e,t,n){if(ge(e)){const t=e.toLowerCase();for(const e of __privateGet(this,$).values())if(t===e.selector)return e;return null}if(-1===e.indexOf("(")){const r=[];for(const[t,n]of __privateGet(this,$))t.split("(")[0]===e&&r.push(n);if(t){const e=t.length>0?t[t.length-1]:null;let n=t.length,s=!0;Xt.isTyped(e)&&"overrides"===e.type&&(s=!1,n--);for(let t=r.length-1;t>=0;t--){const e=r[t].inputs.length;e===n||s&&e===n-1||r.splice(t,1)}for(let i=r.length-1;i>=0;i--){const e=r[i].inputs;for(let n=0;n<t.length;n++)if(Xt.isTyped(t[n])){if(n>=e.length){if("overrides"===t[n].type)continue;r.splice(i,1);break}if(t[n].type!==e[n].baseType){r.splice(i,1);break}}}}if(1===r.length&&t&&t.length!==r[0].inputs.length){const e=t[t.length-1];(null==e||Array.isArray(e)||"object"!=typeof e)&&r.splice(0,1)}if(0===r.length)return null;if(r.length>1&&n){ce(!1,`ambiguous function description (i.e. matches ${r.map((e=>JSON.stringify(e.format()))).join(", ")})`,"key",e)}return r[0]}const r=__privateGet(this,$).get(lr.from(e).format());return r||null},K=new WeakSet,q=function(e,t,n){if(ge(e)){const t=e.toLowerCase();for(const e of __privateGet(this,W).values())if(t===e.topicHash)return e;return null}if(-1===e.indexOf("(")){const r=[];for(const[t,n]of __privateGet(this,W))t.split("(")[0]===e&&r.push(n);if(t){for(let e=r.length-1;e>=0;e--)r[e].inputs.length<t.length&&r.splice(e,1);for(let e=r.length-1;e>=0;e--){const n=r[e].inputs;for(let s=0;s<t.length;s++)if(Xt.isTyped(t[s])&&t[s].type!==n[s].baseType){r.splice(e,1);break}}}if(0===r.length)return null;if(r.length>1&&n){ce(!1,`ambiguous event description (i.e. matches ${r.map((e=>JSON.stringify(e.format()))).join(", ")})`,"key",e)}return r[0]}const r=__privateGet(this,W).get(ir.from(e).format());return r||null};let xr=class e{constructor(e){__privateAdd(this,V),__privateAdd(this,K),__publicField(this,"fragments"),__publicField(this,"deploy"),__publicField(this,"fallback"),__publicField(this,"receive"),__privateAdd(this,B,void 0),__privateAdd(this,W,void 0),__privateAdd(this,$,void 0),__privateAdd(this,z,void 0);let t=[];t="string"==typeof e?JSON.parse(e):e,__privateSet(this,$,new Map),__privateSet(this,B,new Map),__privateSet(this,W,new Map);const n=[];for(const o of t)try{n.push(tr.from(o))}catch(i){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,i.message)}re(this,{fragments:Object.freeze(n)});let r=null,s=!1;__privateSet(this,z,this.getAbiCoder()),this.fragments.forEach(((e,t)=>{let n;switch(e.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void re(this,{deploy:e});case"fallback":return void(0===e.inputs.length?s=!0:(ce(!r||e.payable!==r.payable,"conflicting fallback fragments",`fragments[${t}]`,e),r=e,s=r.payable));case"function":n=__privateGet(this,$);break;case"event":n=__privateGet(this,W);break;case"error":n=__privateGet(this,B);break;default:return}const i=e.format();n.has(i)||n.set(i,e)})),this.deploy||re(this,{deploy:or.from("constructor()")}),re(this,{fallback:r,receive:s})}format(e){const t=e?"minimal":"full";return this.fragments.map((e=>e.format(t)))}formatJson(){const e=this.fragments.map((e=>e.format("json")));return JSON.stringify(e.map((e=>JSON.parse(e))))}getAbiCoder(){return mr.defaultAbiCoder()}getFunctionName(e){const t=__privateMethod(this,V,H).call(this,e,null,!1);return ce(t,"no matching function","key",e),t.name}hasFunction(e){return!!__privateMethod(this,V,H).call(this,e,null,!1)}getFunction(e,t){return __privateMethod(this,V,H).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(__privateGet(this,$).keys());t.sort(((e,t)=>e.localeCompare(t)));for(let n=0;n<t.length;n++){const r=t[n];e(__privateGet(this,$).get(r),n)}}getEventName(e){const t=__privateMethod(this,K,q).call(this,e,null,!1);return ce(t,"no matching event","key",e),t.name}hasEvent(e){return!!__privateMethod(this,K,q).call(this,e,null,!1)}getEvent(e,t){return __privateMethod(this,K,q).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(__privateGet(this,W).keys());t.sort(((e,t)=>e.localeCompare(t)));for(let n=0;n<t.length;n++){const r=t[n];e(__privateGet(this,W).get(r),n)}}getError(e,t){if(ge(e)){const t=e.toLowerCase();if(vr[t])return sr.from(vr[t].signature);for(const e of __privateGet(this,B).values())if(t===e.selector)return e;return null}if(-1===e.indexOf("(")){const t=[];for(const[n,r]of __privateGet(this,B))n.split("(")[0]===e&&t.push(r);if(0===t.length)return"Error"===e?sr.from("error Error(string)"):"Panic"===e?sr.from("error Panic(uint256)"):null;if(t.length>1){ce(!1,`ambiguous error description (i.e. ${t.map((e=>JSON.stringify(e.format()))).join(", ")})`,"name",e)}return t[0]}if("Error(string)"===(e=sr.from(e).format()))return sr.from("error Error(string)");if("Panic(uint256)"===e)return sr.from("error Panic(uint256)");const n=__privateGet(this,B).get(e);return n||null}forEachError(e){const t=Array.from(__privateGet(this,B).keys());t.sort(((e,t)=>e.localeCompare(t)));for(let n=0;n<t.length;n++){const r=t[n];e(__privateGet(this,B).get(r),n)}}_decodeParams(e,t){return __privateGet(this,z).decode(e,t)}_encodeParams(e,t){return __privateGet(this,z).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if("string"==typeof e){const t=this.getError(e);ce(t,"unknown error","fragment",e),e=t}return ce(we(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,we(t,4))}encodeErrorResult(e,t){if("string"==typeof e){const t=this.getError(e);ce(t,"unknown error","fragment",e),e=t}return be([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}return ce(we(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,we(t,4))}encodeFunctionData(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}return be([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}let n="invalid length for result data";const r=me(t);if(r.length%32==0)try{return __privateGet(this,z).decode(e.outputs,r)}catch(s){n="could not decode result data"}le(!1,n,"BAD_DATA",{value:_e(r),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=fe(e,"data"),r=mr.getBuiltinCallException("call",t,n);if(r.message.startsWith("execution reverted (unknown custom error)")){const e=_e(n.slice(0,4)),t=this.getError(e);if(t)try{const e=__privateGet(this,z).decode(t.inputs,n.slice(4));r.revert={name:t.name,signature:t.format(),args:e},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch(i){r.message="execution reverted (coult not decode custom error)"}}const s=this.parseTransaction(t);return s&&(r.invocation={method:s.name,signature:s.signature,args:s.args}),r}encodeFunctionResult(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}return _e(__privateGet(this,z).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}le(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const r=(e,t)=>"string"===e.type?yn(t):"bytes"===e.type?It(_e(t)):("bool"===e.type&&"boolean"==typeof t?t=t?"0x01":"0x00":e.type.match(/^u?int/)?t=Me(t):e.type.match(/^bytes/)?t=ve(t,32,!1):"address"===e.type&&__privateGet(this,z).encode(["address"],[t]),function(e,t){return ve(e,t,!0)}(_e(t),32));for(t.forEach(((t,s)=>{const i=e.inputs[s];i.indexed?null==t?n.push(null):"array"===i.baseType||"tuple"===i.baseType?ce(!1,"filtering with tuples or arrays not supported","contract."+i.name,t):Array.isArray(t)?n.push(t.map((e=>r(i,e)))):n.push(r(i,t)):ce(null==t,"cannot filter non-indexed parameters; must be null","contract."+i.name,t)}));n.length&&null===n[n.length-1];)n.pop();return n}encodeEventLog(e,t){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}const n=[],r=[],s=[];return e.anonymous||n.push(e.topicHash),ce(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach(((e,i)=>{const o=t[i];if(e.indexed)if("string"===e.type)n.push(yn(o));else if("bytes"===e.type)n.push(It(o));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");n.push(__privateGet(this,z).encode([e.type],[o]))}else r.push(e),s.push(o)})),{data:__privateGet(this,z).encode(r,s),topics:n}}decodeEventLog(e,t,n){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}if(null!=n&&!e.anonymous){const t=e.topicHash;ce(ge(n[0],32)&&n[0].toLowerCase()===t,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const r=[],s=[],i=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(r.push(er.from({type:"bytes32",name:e.name})),i.push(!0)):(r.push(e),i.push(!1)):(s.push(e),i.push(!1))}));const o=null!=n?__privateGet(this,z).decode(r,be(n)):null,a=__privateGet(this,z).decode(s,t,!0),l=[],c=[];let u=0,d=0;return e.inputs.forEach(((e,t)=>{let n=null;if(e.indexed)if(null==o)n=new br(null);else if(i[t])n=new br(o[d++]);else try{n=o[d++]}catch(r){n=r}else try{n=a[u++]}catch(r){n=r}l.push(n),c.push(e.name||null)})),it.fromItems(l,c)}parseTransaction(e){const t=fe(e.data,"tx.data"),n=Te(null!=e.value?e.value:0,"tx.value"),r=this.getFunction(_e(t.slice(0,4)));if(!r)return null;const s=__privateGet(this,z).decode(r.inputs,t.slice(4));return new yr(r,r.selector,s,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new gr(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=_e(e),n=this.getError(we(t,0,4));if(!n)return null;const r=__privateGet(this,z).decode(n.inputs,we(t,4));return new _r(n,n.selector,r)}static from(t){return t instanceof e?t:"string"==typeof t?new e(JSON.parse(t)):"function"==typeof t.formatJson?new e(t.formatJson()):"function"==typeof t.format?new e(t.format("json")):new e(t)}};const Er=BigInt(0);function Nr(e){return null==e?null:e.toString()}function kr(e){const t={};e.to&&(t.to=e.to),e.from&&(t.from=e.from),e.data&&(t.data=_e(e.data));const n="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of n)s in e&&null!=e[s]&&(t[s]=Te(e[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)s in e&&null!=e[s]&&(t[s]=Ce(e[s],`request.${s}`));return e.accessList&&(t.accessList=function(e){if(Array.isArray(e))return e.map(((t,n)=>Array.isArray(t)?(ce(2===t.length,"invalid slot set",`value[${n}]`,t),gn(t[0],t[1])):(ce(null!=t&&"object"==typeof t,"invalid address-slot set","value",e),gn(t.address,t.storageKeys))));ce(null!=e&&"object"==typeof e,"invalid access list","value",e);const t=Object.keys(e).map((t=>{const n=e[t].reduce(((e,t)=>(e[t]=!0,e)),{});return gn(t,Object.keys(n).sort())}));return t.sort(((e,t)=>e.address.localeCompare(t.address))),t}(e.accessList)),e.authorizationList&&(t.authorizationList=e.authorizationList.slice()),"blockTag"in e&&(t.blockTag=e.blockTag),"enableCcipRead"in e&&(t.enableCcipRead=!!e.enableCcipRead),"customData"in e&&(t.customData=e.customData),"blobVersionedHashes"in e&&e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.slice()),"kzg"in e&&(t.kzg=e.kzg),"blobs"in e&&e.blobs&&(t.blobs=e.blobs.map((e=>{return ge(t=e,!0)||t instanceof Uint8Array?_e(e):Object.assign({},e);var t}))),t}class Ar{constructor(e,t){__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=t;const n=Object.freeze(e.topics.slice());re(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:r,index:s,removed:i,topics:o,transactionHash:a,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:r,index:s,removed:i,topics:o,transactionHash:a,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const e=yield this.provider.getBlock(this.blockHash);return le(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}))}getTransaction(){return __async(this,null,(function*(){const e=yield this.provider.getTransaction(this.transactionHash);return le(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}))}getTransactionReceipt(){return __async(this,null,(function*(){const e=yield this.provider.getTransactionReceipt(this.transactionHash);return le(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}))}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(e=this).transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,address:e.address,data:e.data,topics:Object.freeze(e.topics.slice()),index:e.index}};var e}}class Tr{constructor(e,t){__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,J,void 0),__privateSet(this,J,Object.freeze(e.logs.map((e=>new Ar(e,t)))));let n=Er;null!=e.effectiveGasPrice?n=e.effectiveGasPrice:null!=e.gasPrice&&(n=e.gasPrice),re(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return __privateGet(this,J)}toJSON(){const{to:e,from:t,contractAddress:n,hash:r,index:s,blockHash:i,blockNumber:o,logsBloom:a,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:i,blockNumber:o,contractAddress:n,cumulativeGasUsed:Nr(this.cumulativeGasUsed),from:t,gasPrice:Nr(this.gasPrice),blobGasUsed:Nr(this.blobGasUsed),blobGasPrice:Nr(this.blobGasPrice),gasUsed:Nr(this.gasUsed),hash:r,index:s,logs:l,logsBloom:a,root:u,status:c,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}getBlock(){return __async(this,null,(function*(){const e=yield this.provider.getBlock(this.blockHash);if(null==e)throw new Error("TODO");return e}))}getTransaction(){return __async(this,null,(function*(){const e=yield this.provider.getTransaction(this.hash);if(null==e)throw new Error("TODO");return e}))}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 Rr(this)}reorderedEvent(e){return le(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Or(this,e)}}J=new WeakMap;Q=new WeakMap;let Sr=class e{constructor(e,t){__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,Q,void 0),this.provider=t,this.blockNumber=null!=e.blockNumber?e.blockNumber:null,this.blockHash=null!=e.blockHash?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=null!=e.maxPriorityFeePerGas?e.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=e.maxFeePerGas?e.maxFeePerGas:null,this.maxFeePerBlobGas=null!=e.maxFeePerBlobGas?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=null!=e.accessList?e.accessList:null,this.blobVersionedHashes=null!=e.blobVersionedHashes?e.blobVersionedHashes:null,this.authorizationList=null!=e.authorizationList?e.authorizationList:null,__privateSet(this,Q,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:r,type:s,to:i,from:o,nonce:a,data:l,signature:c,accessList:u,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:Nr(this.chainId),data:l,from:o,gasLimit:Nr(this.gasLimit),gasPrice:Nr(this.gasPrice),hash:r,maxFeePerGas:Nr(this.maxFeePerGas),maxPriorityFeePerGas:Nr(this.maxPriorityFeePerGas),maxFeePerBlobGas:Nr(this.maxFeePerBlobGas),nonce:a,signature:c,to:i,index:n,type:s,value:Nr(this.value)}}getBlock(){return __async(this,null,(function*(){let e=this.blockNumber;if(null==e){const t=yield this.getTransaction();t&&(e=t.blockNumber)}if(null==e)return null;const t=this.provider.getBlock(e);if(null==t)throw new Error("TODO");return t}))}getTransaction(){return __async(this,null,(function*(){return this.provider.getTransaction(this.hash)}))}confirmations(){return __async(this,null,(function*(){if(null==this.blockNumber){const{tx:e,blockNumber:t}=yield ne({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==e||null==e.blockNumber?0:t-e.blockNumber+1}return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}wait(e,t){return __async(this,null,(function*(){const n=null==e?1:e,r=null==t?0:t;let s=__privateGet(this,Q),i=-1,o=-1===s;const a=()=>__async(this,null,(function*(){if(o)return null;const{blockNumber:e,nonce:t}=yield ne({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(t<this.nonce)return void(s=e);if(o)return null;const r=yield this.getTransaction();if(!r||null==r.blockNumber)for(-1===i&&(i=s-3,i<__privateGet(this,Q)&&(i=__privateGet(this,Q)));i<=e;){if(o)return null;const t=yield this.provider.getBlock(i,!0);if(null==t)return;for(const e of t)if(e===this.hash)return;for(let r=0;r<t.length;r++){const i=yield t.getTransaction(r);if(i.from===this.from&&i.nonce===this.nonce){if(o)return null;const t=yield this.provider.getTransactionReceipt(i.hash);if(null==t)return;if(e-t.blockNumber+1<n)return;let r="replaced";i.data===this.data&&i.to===this.to&&i.value===this.value?r="repriced":"0x"===i.data&&i.from===i.to&&i.value===Er&&(r="cancelled"),le(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===r||"cancelled"===r,reason:r,replacement:i.replaceableTransaction(s),hash:i.hash,receipt:t})}}i++}})),l=e=>{if(null==e||0!==e.status)return e;le(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:e.to,from:e.from,data:""},receipt:e})},c=yield this.provider.getTransactionReceipt(this.hash);if(0===n)return l(c);if(c){if(1===n||(yield c.confirmations())>=n)return l(c)}else if(yield a(),0===n)return null;const u=new Promise(((e,t)=>{const i=[],c=()=>{i.forEach((e=>e()))};if(i.push((()=>{o=!0})),r>0){const e=setTimeout((()=>{c(),t(ae("wait for transaction timeout","TIMEOUT"))}),r);i.push((()=>{clearTimeout(e)}))}const u=r=>__async(this,null,(function*(){if((yield r.confirmations())>=n){c();try{e(l(r))}catch(s){t(s)}}}));if(i.push((()=>{this.provider.off(this.hash,u)})),this.provider.on(this.hash,u),s>=0){const e=()=>__async(this,null,(function*(){try{yield a()}catch(n){if(ie(n,"TRANSACTION_REPLACED"))return c(),void t(n)}o||this.provider.once("block",e)}));i.push((()=>{this.provider.off("block",e)})),this.provider.once("block",e)}}));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 le(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Rr(this)}reorderedEvent(e){return le(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),le(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Or(this,e)}replaceableTransaction(t){ce(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const n=new e(this,this.provider);return __privateSet(n,Q,t),n}};function Or(e,t){return{orphan:"reorder-transaction",tx:e,other:t}}function Rr(e){return{orphan:"drop-transaction",tx:e}}class Cr extends Ar{constructor(e,t,n){super(e,e.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");re(this,{args:t.decodeEventLog(n,e.data,e.topics),fragment:n,interface:t})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Mr extends Ar{constructor(e,t){super(e,e.provider),__publicField(this,"error"),re(this,{error:t})}}class Pr extends Tr{constructor(e,t,n){super(n,t),__privateAdd(this,X,void 0),__privateSet(this,X,e)}get logs(){return super.logs.map((e=>{const t=e.topics.length?__privateGet(this,X).getEvent(e.topics[0]):null;if(t)try{return new Cr(e,__privateGet(this,X),t)}catch(n){return new Mr(e,n)}return e}))}}X=new WeakMap;Y=new WeakMap;let Fr=class e extends Sr{constructor(e,t,n){super(n,t),__privateAdd(this,Y,void 0),__privateSet(this,Y,e)}wait(t,n){return __async(this,null,(function*(){const r=yield __superGet(e.prototype,this,"wait").call(this,t,n);return null==r?null:new Pr(__privateGet(this,Y),this.provider,r)}))}};class Ur extends Pe{constructor(e,t,n,r){super(e,t,n),__publicField(this,"log"),re(this,{log:r})}getBlock(){return __async(this,null,(function*(){return yield this.log.getBlock()}))}getTransaction(){return __async(this,null,(function*(){return yield this.log.getTransaction()}))}getTransactionReceipt(){return __async(this,null,(function*(){return yield this.log.getTransactionReceipt()}))}}class jr extends Ur{constructor(e,t,n,r,s){super(e,t,n,new Cr(s,e.interface,r));re(this,{args:e.interface.decodeEventLog(r,this.log.data,this.log.topics),fragment:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Ir=BigInt(0);function Lr(e){return e&&"function"==typeof e.call}function Gr(e){return e&&"function"==typeof e.estimateGas}function Dr(e){return e&&"function"==typeof e.resolveName}function Br(e){return e&&"function"==typeof e.sendTransaction}function Wr(e){if(null!=e){if(Dr(e))return e;if(e.provider)return e.provider}}class $r{constructor(e,t,n){if(__privateAdd(this,Z,void 0),__publicField(this,"fragment"),re(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const r=zr(e.runner,"resolveName"),s=Dr(r)?r:null;__privateSet(this,Z,function(){return __async(this,null,(function*(){const r=yield Promise.all(t.inputs.map(((e,t)=>null==n[t]?null:e.walkAsync(n[t],((e,t)=>"address"===e?Array.isArray(t)?Promise.all(t.map((e=>Ht(e,s)))):Ht(t,s):t)))));return e.interface.encodeFilterTopics(t,r)}))}())}getTopicFilter(){return __privateGet(this,Z)}}function zr(e,t){return null==e?null:"function"==typeof e[t]?e:e.provider&&"function"==typeof e.provider[t]?e.provider:null}function Vr(e){return null==e?null:e.provider||null}function Hr(e,t){return __async(this,null,(function*(){const n=Xt.dereference(e,"overrides");ce("object"==typeof n,"invalid overrides parameter","overrides",e);const r=kr(n);return ce(null==r.to||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),ce(null==r.data||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}))}function Kr(e){const t=function(t){return __async(this,null,(function*(){const n=yield Hr(t,["data"]);n.to=yield e.getAddress(),n.from&&(n.from=yield Ht(n.from,Wr(e.runner)));const r=e.interface,s=Te(n.value||Ir,"overrides.value")===Ir,i="0x"===(n.data||"0x");!r.fallback||r.fallback.payable||!r.receive||i||s||ce(!1,"cannot send data to receive or send value to non-payable fallback","overrides",t),ce(r.fallback||i,"cannot send data to receive-only contract","overrides.data",n.data);return ce(r.receive||r.fallback&&r.fallback.payable||s,"cannot send value to non-payable fallback","overrides.value",n.value),ce(r.fallback||i,"cannot send data to receive-only contract","overrides.data",n.data),n}))},n=function(n){return __async(this,null,(function*(){const r=e.runner;le(Br(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=yield r.sendTransaction(yield t(n)),i=Vr(e.runner);return new Fr(e.interface,i,s)}))},r=e=>__async(this,null,(function*(){return yield n(e)}));return re(r,{_contract:e,estimateGas:function(n){return __async(this,null,(function*(){const r=zr(e.runner,"estimateGas");return le(Gr(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield t(n))}))},populateTransaction:t,send:n,staticCall:function(n){return __async(this,null,(function*(){const r=zr(e.runner,"call");le(Lr(r),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield t(n);try{return yield r.call(s)}catch(i){if(oe(i)&&i.data)throw e.interface.makeError(i.data,s);throw i}}))}}),r}function qr(e,t){const n=function(...n){const r=e.interface.getFunction(t,n);return le(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:n}}),r},r=function(...t){return __async(this,null,(function*(){const r=n(...t);let s={};if(r.inputs.length+1===t.length&&(s=yield Hr(t.pop()),s.from&&(s.from=yield Ht(s.from,Wr(e.runner)))),r.inputs.length!==t.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const i=yield function(e,t,n){return __async(this,null,(function*(){const r=zr(e,"resolveName"),s=Dr(r)?r:null;return yield Promise.all(t.map(((e,t)=>e.walkAsync(n[t],((e,t)=>(t=Xt.dereference(t,e),"address"===e?Ht(t,s):t))))))}))}(e.runner,r.inputs,t);return Object.assign({},s,yield ne({to:e.getAddress(),data:e.interface.encodeFunctionData(r,i)}))}))},s=function(...e){return __async(this,null,(function*(){const t=yield o(...e);return 1===t.length?t[0]:t}))},i=function(...t){return __async(this,null,(function*(){const n=e.runner;le(Br(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=yield n.sendTransaction(yield r(...t)),i=Vr(e.runner);return new Fr(e.interface,i,s)}))},o=function(...t){return __async(this,null,(function*(){const s=zr(e.runner,"call");le(Lr(s),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield r(...t);let o="0x";try{o=yield s.call(i)}catch(l){if(oe(l)&&l.data)throw e.interface.makeError(l.data,i);throw l}const a=n(...t);return e.interface.decodeFunctionResult(a,o)}))},a=(...e)=>__async(this,null,(function*(){return n(...e).constant?yield s(...e):yield i(...e)}));return re(a,{name:e.interface.getFunctionName(t),_contract:e,_key:t,getFragment:n,estimateGas:function(...t){return __async(this,null,(function*(){const n=zr(e.runner,"estimateGas");return le(Gr(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield r(...t))}))},populateTransaction:r,send:i,staticCall:s,staticCallResult:o}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const n=e.interface.getFunction(t);return le(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),n}}),a}Z=new WeakMap;const Jr=Symbol.for("_ethersInternal_contract"),Qr=new WeakMap;function Xr(e){return Qr.get(e[Jr])}function Yr(e,t){return __async(this,null,(function*(){let n,r=null;if(Array.isArray(t)){const r=function(t){if(ge(t,32))return t;const n=e.interface.getEvent(t);return ce(n,"unknown fragment","name",t),n.topicHash};n=t.map((e=>null==e?null:Array.isArray(e)?e.map(r):r(e)))}else"*"===t?n=[null]:"string"==typeof t?ge(t,32)?n=[t]:(r=e.interface.getEvent(t),ce(r,"unknown fragment","event",t),n=[r.topicHash]):(s=t)&&"object"==typeof s&&"getTopicFilter"in s&&"function"==typeof s.getTopicFilter&&s.fragment?n=yield t.getTopicFilter():"fragment"in t?(r=t.fragment,n=[r.topicHash]):ce(!1,"unknown event name","event",t);var s;n=n.map((e=>{if(null==e)return null;if(Array.isArray(e)){const t=Array.from(new Set(e.map((e=>e.toLowerCase()))).values());return 1===t.length?t[0]:(t.sort(),t)}return e.toLowerCase()}));return{fragment:r,tag:n.map((e=>null==e?"null":Array.isArray(e)?e.join("|"):e)).join("&"),topics:n}}))}function Zr(e,t){return __async(this,null,(function*(){const{subs:n}=Xr(e);return n.get((yield Yr(e,t)).tag)||null}))}function es(e,t,n){return __async(this,null,(function*(){const r=Vr(e.runner);le(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:s,tag:i,topics:o}=yield Yr(e,n),{addr:a,subs:l}=Xr(e);let c=l.get(i);if(!c){const t={address:a||e,topics:o},u=t=>{let r=s;if(null==r)try{r=e.interface.getEvent(t.topics[0])}catch(i){}if(r){const i=r,o=s?e.interface.decodeEventLog(s,t.data,t.topics):[];ns(e,n,o,(r=>new jr(e,r,n,i,t)))}else ns(e,n,[],(r=>new Ur(e,r,n,t)))};let d=[];c={tag:i,listeners:[],start:()=>{d.length||d.push(r.on(t,u))},stop:()=>__async(this,null,(function*(){if(0==d.length)return;let e=d;d=[],yield Promise.all(e),r.off(t,u)}))},l.set(i,c)}return c}))}let ts=Promise.resolve();function ns(e,t,n,r){return __async(this,null,(function*(){try{yield ts}catch(i){}const s=function(e,t,n,r){return __async(this,null,(function*(){yield ts;const s=yield Zr(e,t);if(!s)return!1;const o=s.listeners.length;return s.listeners=s.listeners.filter((({listener:t,once:s})=>{const o=Array.from(n);r&&o.push(r(s?null:t));try{t.call(e,...o)}catch(i){}return!s})),0===s.listeners.length&&(s.stop(),Xr(e).subs.delete(s.tag)),o>0}))}(e,t,n,r);return ts=s,yield s}))}const rs=["then"];ee=Jr;let ss=class e{constructor(e,t,n,r){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),ce("string"==typeof e||zt(e),"invalid value for Contract target","target",e),null==n&&(n=null);const s=xr.from(t);let i;re(this,{target:e,runner:n,interface:s}),Object.defineProperty(this,Jr,{value:{}});let o=null,a=null;if(r){const e=Vr(n);a=new Fr(this.interface,e,r)}let l=new Map;if("string"==typeof e)if(ge(e))o=e,i=Promise.resolve(e);else{const t=zr(n,"resolveName");if(!Dr(t))throw ae("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});i=t.resolveName(e).then((t=>{if(null==t)throw ae("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return Xr(this).addr=t,t}))}else i=e.getAddress().then((e=>{if(null==e)throw new Error("TODO");return Xr(this).addr=e,e}));var c,u;c=this,u={addrPromise:i,addr:o,deployTx:a,subs:l},Qr.set(c[Jr],u);return re(this,{filters:new Proxy({},{get:(e,t,n)=>{if("symbol"==typeof t||rs.indexOf(t)>=0)return Reflect.get(e,t,n);try{return this.getEvent(t)}catch(r){if(!ie(r,"INVALID_ARGUMENT")||"key"!==r.argument)throw r}},has:(e,t)=>rs.indexOf(t)>=0?Reflect.has(e,t):Reflect.has(e,t)||this.interface.hasEvent(String(t))})}),re(this,{fallback:s.receive||s.fallback?Kr(this):null}),new Proxy(this,{get:(e,t,n)=>{if("symbol"==typeof t||t in e||rs.indexOf(t)>=0)return Reflect.get(e,t,n);try{return e.getFunction(t)}catch(r){if(!ie(r,"INVALID_ARGUMENT")||"key"!==r.argument)throw r}},has:(e,t)=>"symbol"==typeof t||t in e||rs.indexOf(t)>=0?Reflect.has(e,t):e.interface.hasFunction(t)})}connect(t){return new e(this.target,this.interface,t)}attach(t){return new e(t,this.interface,this.runner)}getAddress(){return __async(this,null,(function*(){return yield Xr(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const e=Vr(this.runner);le(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=yield e.getCode(yield this.getAddress());return"0x"===t?null:t}))}waitForDeployment(){return __async(this,null,(function*(){const e=this.deploymentTransaction();if(e)return yield e.wait(),this;if(null!=(yield this.getDeployedCode()))return this;const t=Vr(this.runner);return le(null!=t,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((e,n)=>{const r=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return e(this);t.once("block",r)}catch(s){n(s)}}));r()}))}))}deploymentTransaction(){return Xr(this).deployTx}getFunction(e){"string"!=typeof e&&(e=e.format());return qr(this,e)}getEvent(e){return"string"!=typeof e&&(e=e.format()),function(e,t){const n=function(...n){const r=e.interface.getEvent(t,n);return le(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:n}}),r},r=function(...t){return new $r(e,n(...t),t)};return re(r,{name:e.interface.getEventName(t),_contract:e,_key:t,getFragment:n}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const n=e.interface.getEvent(t);return le(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),n}}),r}(this,e)}queryTransaction(e){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(e,t,n){return __async(this,null,(function*(){null==t&&(t=0),null==n&&(n="latest");const{addr:r,addrPromise:s}=Xr(this),i=r||(yield s),{fragment:o,topics:a}=yield Yr(this,e),l={address:i,topics:a,fromBlock:t,toBlock:n},c=Vr(this.runner);return le(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((e=>{let t=o;if(null==t)try{t=this.interface.getEvent(e.topics[0])}catch(n){}if(t)try{return new Cr(e,this.interface,t)}catch(n){return new Mr(e,n)}return new Ar(e,c)}))}))}on(e,t){return __async(this,null,(function*(){const n=yield es(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}))}once(e,t){return __async(this,null,(function*(){const n=yield es(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}))}emit(e,...t){return __async(this,null,(function*(){return yield ns(this,e,t,null)}))}listenerCount(e){return __async(this,null,(function*(){if(e){const t=yield Zr(this,e);return t?t.listeners.length:0}const{subs:t}=Xr(this);let n=0;for(const{listeners:e}of t.values())n+=e.length;return n}))}listeners(e){return __async(this,null,(function*(){if(e){const t=yield Zr(this,e);return t?t.listeners.map((({listener:e})=>e)):[]}const{subs:t}=Xr(this);let n=[];for(const{listeners:e}of t.values())n=n.concat(e.map((({listener:e})=>e)));return n}))}off(e,t){return __async(this,null,(function*(){const n=yield Zr(this,e);if(!n)return this;if(t){const e=n.listeners.map((({listener:e})=>e)).indexOf(t);e>=0&&n.listeners.splice(e,1)}return null!=t&&0!==n.listeners.length||(n.stop(),Xr(this).subs.delete(n.tag)),this}))}removeAllListeners(e){return __async(this,null,(function*(){if(e){const t=yield Zr(this,e);if(!t)return this;t.stop(),Xr(this).subs.delete(t.tag)}else{const{subs:e}=Xr(this);for(const{tag:t,stop:n}of e.values())n(),e.delete(t)}return this}))}addListener(e,t){return __async(this,null,(function*(){return yield this.on(e,t)}))}removeListener(e,t){return __async(this,null,(function*(){return yield this.off(e,t)}))}static buildClass(t){return class extends e{constructor(e,n=null){super(e,t,n)}}}static from(e,t,n){null==n&&(n=null);return new this(e,t,n)}};class is extends(function(){return ss}()){}const os={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trustwallet",LUTE:"lute"},as={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},ls={[as.ETHEREUM]:{name:"Ethereum Mainnet",chainId:1,symbol:"ETH",decimals:18,rpcUrl:"https://mainnet.infura.io/v3/your-infura-key",blockExplorerUrl:"https://etherscan.io"},[as.BSC]:{name:"Binance Smart Chain",chainId:56,symbol:"BNB",decimals:18,rpcUrl:"https://bsc-dataseed.binance.org/",blockExplorerUrl:"https://bscscan.com"},[as.TRON]:{name:"TRON Mainnet",symbol:"TRX",decimals:6,rpcUrl:"https://api.trongrid.io",blockExplorerUrl:"https://tronscan.org"},[as.ALGORAND]:{name:"Algorand Mainnet",symbol:"ALGO",decimals:6,rpcUrl:"https://mainnet-api.algonode.cloud",blockExplorerUrl:"https://algoexplorer.io"}},cs={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}}},us={[as.ETHEREUM]:[os.METAMASK,os.TRUST_WALLET],[as.BSC]:[os.METAMASK,os.TRUST_WALLET],[as.TRON]:[os.TRONLINK],[as.ALGORAND]:[os.LUTE]},ds=e=>({[os.METAMASK]:"https://metamask.io/download/",[os.TRONLINK]:"https://www.tronlink.org/download/",[os.TRUST_WALLET]:"https://trustwallet.com/download/",[os.LUTE]:"https://lute.app/download/"}[e]||""),hs=()=>({[os.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum,[os.TRONLINK]:"undefined"!=typeof window&&void 0!==window.tronWeb,[os.TRUST_WALLET]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isTrust,[os.LUTE]:"undefined"!=typeof window&&void 0!==window.lute}),ps=(e=3,t=500)=>__async(this,null,(function*(){let n=0,r=hs();const s=Object.values(r).some((e=>!0===e));for(;!s&&n<e;)console.log(`No wallets detected, retrying (${n+1}/${e})...`),yield new Promise((e=>setTimeout(e,t))),r=hs(),n++;return r})),fs=()=>{var e;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==(e=window.tronWeb.fullNode)?void 0:e.host,defaultAddress:window.tronWeb.defaultAddress});const t=hs();console.log("Detected wallets:",t)},ms=(e,t)=>{try{return function(e,t){ce("string"==typeof e,"value must be a string","value",e);let n=18;if("string"==typeof t){const e=Je.indexOf(t);ce(e>=0,"invalid unit","unit",t),n=3*e}else null!=t&&(n=Ce(t,"unit"));return qe.fromString(e,{decimals:n,width:512}).value}(e.toString(),t)}catch(n){const r=parseFloat(e)*Math.pow(10,t);return{toString:()=>r.toLocaleString("fullwide",{useGrouping:!1}),toBigInt:()=>BigInt(Math.floor(r))}}},gs=()=>__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 e=yield window.ethereum.request({method:"eth_requestAccounts"});if(!e||0===e.length)throw new Error("No accounts found");const t=e[0],n=yield window.ethereum.request({method:"eth_chainId"}),r=parseInt(n,16);let s;switch(r){case 1:s=as.ETHEREUM;break;case 56:s=as.BSC;break;default:s=`unknown-${r}`}return{walletType:os.METAMASK,address:t,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return t})),sendTransaction:e=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:t,to:e.to,value:e.value?e.value.toString():"0x0",gasLimit:e.gasLimit?e.gasLimit.toString():void 0,data:e.data}]})}}))}),estimateGas:e=>__async(this,null,(function*(){const n=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:t,to:e.to,value:e.value?e.value.toString():"0x0"}]}),r=parseInt(n,16);return{toString:()=>r.toString(),mul:e=>({div:t=>({toString:()=>Math.floor(r*e/t).toString()})})}}))},network:s,isConnected:!0,chainId:r}}catch(e){throw console.error("Error connecting to MetaMask:",e),e}})),ys=()=>__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 e=yield window.ethereum.request({method:"eth_requestAccounts"});if(!e||0===e.length)throw new Error("No accounts found");const t=e[0],n=yield window.ethereum.request({method:"eth_chainId"}),r=parseInt(n,16);let s;switch(r){case 1:s=as.ETHEREUM;break;case 56:s=as.BSC;break;default:s=`unknown-${r}`}return{walletType:os.TRUST_WALLET,address:t,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return t})),sendTransaction:e=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:t,to:e.to,value:e.value?e.value.toString():"0x0",gasLimit:e.gasLimit?e.gasLimit.toString():void 0,data:e.data}]})}}))}),estimateGas:e=>__async(this,null,(function*(){const n=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:t,to:e.to,value:e.value?e.value.toString():"0x0"}]}),r=parseInt(n,16);return{toString:()=>r.toString(),mul:e=>({div:t=>({toString:()=>Math.floor(r*e/t).toString()})})}}))},network:s,isConnected:!0,chainId:r}}catch(e){throw console.error("Error connecting to Trust Wallet:",e),e}})),_s=()=>__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 e=(e=10,t=500)=>__async(this,null,(function*(){for(let n=0;n<e;n++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${n+1}/${e}`),yield new Promise((e=>setTimeout(e,t)))}throw new Error("TronWeb took too long to be ready")}));try{const n=yield e();if(!n.defaultAddress||!n.defaultAddress.base58)try{yield window.tronWeb.request({method:"tron_requestAccounts"})}catch(t){throw console.error("Failed to get permission from TronLink:",t),new Error("Please unlock TronLink and approve connection")}const r=n.defaultAddress.base58;return console.log("Connected to TronLink wallet:",r),{walletType:os.TRONLINK,address:r,provider:n,network:as.TRON,isConnected:!0}}catch(n){throw console.error("Error connecting to TronLink:",n),n}})),bs=()=>__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:e}=yield window.lute.connect();if(!e)throw new Error("No address returned. Please unlock Lute wallet.");return console.log("Connected to Lute wallet:",e),{walletType:os.LUTE,address:e,provider:window.lute,network:as.ALGORAND,isConnected:!0}}catch(e){throw console.error("Error connecting to Lute wallet:",e),e}})),ws=e=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",e),e){case os.METAMASK:return gs();case os.TRONLINK:return _s();case os.TRUST_WALLET:return ys();case os.LUTE:return bs();default:throw new Error(`Unsupported wallet type: ${e}`)}})),vs=e=>us[e]||[],xs=(e,t,n)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:t,amount:n}),!e||!e.provider)throw new Error("Wallet not connected");if(!t)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");try{let r;switch(e.walletType){case os.METAMASK:case os.TRUST_WALLET:const s=e.provider,i=s.getSigner(),o=n.toString(),a=ms(o,18);console.log("Sending ETH/BNB:",{to:t,value:a.toString()});const l=yield s.estimateGas({to:t,value:a});console.log("Gas estimate:",l.toString());const c={toString:()=>Math.floor(1.1*parseInt(l.toString())).toString()};console.log("Using gas limit:",c.toString()),r=yield i.sendTransaction({to:t,value:a,gasLimit:c});break;case os.TRONLINK:const u=e.provider;if(!u||!u.ready)throw new Error("TronWeb not initialized");const d=u.toSun(n.toString());console.log("Sending TRX:",{to:t,value:d}),r=yield u.trx.sendTransaction(t,d);break;case os.LUTE:const h=e.provider,p=Math.floor(1e6*parseFloat(n));console.log("Sending Algos:",{to:t,amount:p}),r=yield h.sendPayment({recipient:t,amount:p});break;default:throw new Error(`Unsupported wallet type: ${e.walletType}`)}console.log("Transaction sent:",r);const s=r.hash||r.txID||r.txId||r;return console.log("Transaction hash:",s),s}catch(r){throw console.error("Native transaction error:",r),r}})),Es=(e,t)=>__async(this,null,(function*(){var n;if(console.log("Sending transaction with:",t),!e)throw new Error("Wallet not connected");const{to:r,amount:s,tokenAddress:i,currency:o,network:a}=t;if(!r)throw new Error("Recipient address not provided");const l=null==(n=cs[o])?void 0:n[a];return l&&l.isNative?xs(e,r,s):l?Ns(e,l,r,s):xs(e,r,s)})),Ns=(e,t,n,r)=>__async(this,null,(function*(){if(console.log("Sending token transaction with:",{tokenConfig:t,toAddress:n,amount:r}),!e||!e.provider)throw new Error("Wallet not connected");if(!t)throw new Error("Token configuration not provided");if(!n)throw new Error("Recipient address not provided");if(!r||isNaN(parseFloat(r))||parseFloat(r)<=0)throw new Error("Invalid amount");const{contractAddress:s,decimals:i,symbol:o}=t;switch(console.log(`Token: ${o}, Decimals: ${i}, Contract: ${s}`),e.walletType){case os.TRONLINK:return As(e,t,n,r);case os.LUTE:return Ts(e,t,n,r);default:return ks(e,t,n,r)}})),ks=(e,t,n,r)=>__async(this,null,(function*(){if(console.log("Sending ERC20/BEP20 transaction with:",{tokenConfig:t,toAddress:n,amount:r}),!e||!e.provider)throw new Error("Wallet not connected");const s=e.provider.getSigner(),{contractAddress:i,decimals:o,symbol:a}=t,l=parseFloat(r),c=parseInt(o),u=ms(l.toString(),c);console.log(`Sending ${l} ${a} (${u.toString()} base units) to ${n}`);try{const e=new is(i,["function transfer(address to, uint256 amount) returns (bool)"],s);try{const t=yield e.transfer.estimateGas(n,u);console.log("Gas estimate:",t.toString());const r="USDC"===a?Math.floor(1.2*parseInt(t.toString())).toString():Math.floor(1.1*parseInt(t.toString())).toString();console.log("Using gas limit:",r);const s=yield e.transfer(n,u,{gasLimit:r});return console.log("Transaction sent:",s),s.hash}catch(d){if(console.error("Gas estimation failed:",d),"USDC"===a){console.log("Trying USDC transaction with fixed gas limit");const t=yield e.transfer(n,u,{gasLimit:15e4});return console.log("Transaction sent with fixed gas limit:",t),t.hash}throw new Error(`Transaction would likely fail: ${d.message}`)}}catch(h){throw console.error("ERC20 transaction error:",h),h.message&&h.message.includes("user rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("insufficient funds")?new Error("Insufficient funds for transaction"):h}})),As=(e,t,n,r)=>__async(this,null,(function*(){if(console.log("Sending TRC20 transaction with:",{tokenConfig:t,toAddress:n,amount:r}),!e||!e.provider)throw new Error("Tron wallet not connected");const s=e.provider;if(!s||!s.ready)throw new Error("TronWeb not initialized");if(!t||!t.contractAddress)throw new Error("Invalid token configuration");const{contractAddress:i,decimals:o,symbol:a}=t,l=parseFloat(r),c=parseInt(o),u=(l*Math.pow(10,c)).toString();console.log(`Sending ${l} ${a} (${u} base units) to ${n}`);try{const e=yield s.contract().at(i);if(!e.transfer)throw new Error("Invalid TRC-20 contract");const t=yield e.transfer(n,u).send({feeLimit:1e8,callValue:0,shouldPollResponse:!1});return console.log("TRC20 transaction sent:",t),t}catch(d){throw console.error("TRC20 transaction failed:",d),d.message&&d.message.includes("User rejected")?new Error("Transaction rejected by user"):d.message&&d.message.includes("bandwidth")?new Error("Insufficient energy or bandwidth. Make sure you have enough TRX for fees."):d.message&&d.message.includes("balance")?new Error("Insufficient token balance for transfer"):new Error(`Transaction failed: ${d.message||"Unknown error"}`)}})),Ts=(e,t,n,r)=>__async(this,null,(function*(){if(console.log("Sending Algorand asset transaction with:",{tokenConfig:t,toAddress:n,amount:r}),!e||!e.provider)throw new Error("Algorand wallet not connected");const s=e.provider;if(!t||!t.assetId)throw new Error("Invalid token configuration - missing assetId");const{assetId:i,decimals:o,symbol:a}=t,l=parseFloat(r),c=parseInt(o),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${a} (${u} base units) to ${n}`);try{const e=yield s.sendAssetTransfer({recipient:n,assetId:i,amount:u});return console.log("Algorand asset transaction sent:",e),e.txId}catch(d){throw console.error("Algorand asset transaction error:",d),d.message&&d.message.includes("rejected")?new Error("Transaction rejected by user"):d.message&&d.message.includes("balance")?new Error("Insufficient asset balance"):d}}));let Ss={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{},authToken:null};const Os=e=>__async(this,null,(function*(){Ss=__spreadValues(__spreadValues({},Ss),e),console.log("API initialized with:",{apiUrl:Ss.apiUrl,apiKey:Ss.apiKey?`${Ss.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Ss.merchantWalletAddresses||{}).length>0});try{yield Rs()}catch(t){console.error("Failed to fetch merchant wallets during initialization:",t)}})),Rs=()=>__async(this,null,(function*(){try{console.log("Authenticating and fetching merchant wallets...");const e=btoa(`${Ss.apiKey}:${Ss.apiSecret}`),t=yield fetch(`${Ss.apiUrl}/api/merchants/dashboard`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"x-api-key":Ss.apiKey,"x-api-secret":Ss.apiSecret}});if(t.ok){const e=yield t.json();if(console.log("Merchant dashboard data received:",e),e.merchant){const t={};return e.merchant.walletAddress&&(t.ethereum=e.merchant.walletAddress),e.merchant.solWalletAddress&&(t.solana=e.merchant.solWalletAddress),e.merchant.merchantWallets&&Object.assign(t,e.merchant.merchantWallets),Ss.merchantWalletAddresses=t,console.log("Merchant wallet addresses retrieved:",t),t}}else console.error("Failed to fetch merchant dashboard:",t.status)}catch(e){console.error("Error fetching merchant wallets:",e)}return{}})),Cs=()=>__async(this,null,(function*(){return 0===Object.keys(Ss.merchantWalletAddresses).length&&(yield Rs()),Ss.merchantWalletAddresses})),Ms=()=>({"Content-Type":"application/json","x-api-key":Ss.apiKey,"x-api-secret":Ss.apiSecret,Authorization:Ss.authToken?`Bearer ${Ss.authToken}`:void 0}),Ps=e=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",e),!e.amount)throw new Error("Payment amount is required");const n=yield Cs();console.log("Using merchant wallets:",n);const r=__spreadProps(__spreadValues({},e),{merchantWalletAddresses:__spreadValues(__spreadValues({},n),e.merchantWalletAddresses)});console.log("Enhanced payment data:",r);const s=yield fetch(`${Ss.apiUrl}/api/payments/create`,{method:"POST",headers:Ms(),body:JSON.stringify(r)});if(console.log("Create payment response status:",s.status),!s.ok){let e;try{e=yield s.json()}catch(t){throw new Error(`Failed to create payment: ${s.status} ${s.statusText}`)}throw console.error("Error creating payment:",e),new Error(e.error||`Failed to create payment: ${s.status}`)}const i=yield s.json();return console.log("Payment created successfully:",i),i}catch(n){throw console.error("Create payment error:",n),n}})),Fs=e=>__async(this,null,(function*(){try{if(console.log("Processing payment with data:",e),!e.paymentId)throw new Error("Payment ID is required");if(!e.transactionHash)throw new Error("Transaction hash is required");const n=yield fetch(`${Ss.apiUrl}/api/payments/process`,{method:"POST",headers:Ms(),body:JSON.stringify(e)});if(console.log("Process payment response status:",n.status),!n.ok){let e;try{e=yield n.json()}catch(t){throw new Error(`Failed to process payment: ${n.status} ${n.statusText}`)}throw console.error("Error processing payment:",e),new Error(e.error||`Failed to process payment: ${n.status}`)}const r=yield n.json();return console.log("Process payment response data:",r),r}catch(n){throw console.error("Process payment error:",n),n}}));var Us={exports:{}},js={},Is=t,Ls=Symbol.for("react.element"),Gs=Symbol.for("react.fragment"),Ds=Object.prototype.hasOwnProperty,Bs=Is.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ws={key:!0,ref:!0,__self:!0,__source:!0};function $s(e,t,n){var r,s={},i=null,o=null;for(r in void 0!==n&&(i=""+n),void 0!==t.key&&(i=""+t.key),void 0!==t.ref&&(o=t.ref),t)Ds.call(t,r)&&!Ws.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:Ls,type:e,key:i,ref:o,props:s,_owner:Bs.current}}js.Fragment=Gs,js.jsx=$s,js.jsxs=$s,Us.exports=js;var zs=Us.exports;const Vs=t.createContext(),Hs=t.createContext(),Ks=()=>t.useContext(Hs);var qs,Js,Qs=Object.defineProperty,Xs=Object.getOwnPropertySymbols,Ys=Object.prototype.hasOwnProperty,Zs=Object.prototype.propertyIsEnumerable,ei=(e,t,n)=>t in e?Qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ti=(e,t)=>{for(var n in t||(t={}))Ys.call(t,n)&&ei(e,n,t[n]);if(Xs)for(var n of Xs(t))Zs.call(t,n)&&ei(e,n,t[n]);return e},ni=(e,t)=>{var n={};for(var r in e)Ys.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&Xs)for(var r of Xs(e))t.indexOf(r)<0&&Zs.call(e,r)&&(n[r]=e[r]);return n};(e=>{const t=class t{constructor(e,n,r,i){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let o=[];for(let t=0;t<this.size;t++)o.push(!1);for(let t=0;t<this.size;t++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();const a=this.addEccAndInterleave(r);if(this.drawCodewords(a),-1==i){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const n=this.getPenaltyScore();n<e&&(i=t,e=n),this.applyMask(t)}}s(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}static encodeText(n,r){const s=e.QrSegment.makeSegments(n);return t.encodeSegments(s,r)}static encodeBinary(n,r){const s=e.QrSegment.makeBytes(n);return t.encodeSegments([s],r)}static encodeSegments(e,r,i=1,a=40,l=-1,c=!0){if(!(t.MIN_VERSION<=i&&i<=a&&a<=t.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,d;for(u=i;;u++){const n=8*t.getNumDataCodewords(u,r),s=o.getTotalBits(e,u);if(s<=n){d=s;break}if(u>=a)throw new RangeError("Data too long")}for(const n of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&d<=8*t.getNumDataCodewords(u,n)&&(r=n);let h=[];for(const t of e){n(t.mode.modeBits,4,h),n(t.numChars,t.mode.numCharCountBits(u),h);for(const e of t.getData())h.push(e)}s(h.length==d);const p=8*t.getNumDataCodewords(u,r);s(h.length<=p),n(0,Math.min(4,p-h.length),h),n(0,(8-h.length%8)%8,h),s(h.length%8==0);for(let t=236;h.length<p;t^=253)n(t,8,h);let f=[];for(;8*f.length<h.length;)f.push(0);return h.forEach(((e,t)=>f[t>>>3]|=e<<7-(7&t))),new t(u,r,f,l)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let n=0;n<this.size;n++)this.setFunctionModule(6,n,n%2==0),this.setFunctionModule(n,6,n%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)0==n&&0==r||0==n&&r==t-1||n==t-1&&0==r||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let n=t;for(let r=0;r<10;r++)n=n<<1^1335*(n>>>9);const i=21522^(t<<10|n);s(i>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,r(i,s));this.setFunctionModule(8,7,r(i,6)),this.setFunctionModule(8,8,r(i,7)),this.setFunctionModule(7,8,r(i,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,r(i,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,r(i,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,r(i,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let n=0;n<12;n++)e=e<<1^7973*(e>>>11);const t=this.version<<12|e;s(t>>>18==0);for(let n=0;n<18;n++){const e=r(t,n),s=this.size-11+n%3,i=Math.floor(n/3);this.setFunctionModule(s,i,e),this.setFunctionModule(i,s,e)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){const s=Math.max(Math.abs(r),Math.abs(n)),i=e+r,o=t+n;0<=i&&i<this.size&&0<=o&&o<this.size&&this.setFunctionModule(i,o,2!=s&&4!=s)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,1!=Math.max(Math.abs(r),Math.abs(n)))}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){const n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw new RangeError("Invalid argument");const i=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],a=Math.floor(t.getNumRawDataModules(n)/8),l=i-a%i,c=Math.floor(a/i);let u=[];const d=t.reedSolomonComputeDivisor(o);for(let s=0,p=0;s<i;s++){let n=e.slice(p,p+c-o+(s<l?0:1));p+=n.length;const r=t.reedSolomonComputeRemainder(n,d);s<l&&n.push(0),u.push(n.concat(r))}let h=[];for(let t=0;t<u[0].length;t++)u.forEach(((e,n)=>{(t!=c-o||n>=l)&&h.push(e[t])}));return s(h.length==a),h}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){6==t&&(t=5);for(let s=0;s<this.size;s++)for(let i=0;i<2;i++){const o=t-i,a=!(t+1&2)?this.size-1-s:s;!this.isFunction[a][o]&&n<8*e.length&&(this.modules[a][o]=r(e[n>>>3],7-(7&n)),n++)}}s(n==8*e.length)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let s=0;s<this.size;s++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[s][o]==n?(r++,5==r?e+=t.PENALTY_N1:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),n=this.modules[s][o],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*t.PENALTY_N3}for(let s=0;s<this.size;s++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][s]==n?(r++,5==r?e+=t.PENALTY_N1:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),n=this.modules[o][s],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*t.PENALTY_N3}for(let s=0;s<this.size-1;s++)for(let n=0;n<this.size-1;n++){const r=this.modules[s][n];r==this.modules[s][n+1]&&r==this.modules[s+1][n]&&r==this.modules[s+1][n+1]&&(e+=t.PENALTY_N2)}let n=0;for(const t of this.modules)n=t.reduce(((e,t)=>e+(t?1:0)),n);const r=this.size*this.size,i=Math.ceil(Math.abs(20*n-10*r)/r)-1;return s(0<=i&&i<=9),e+=i*t.PENALTY_N4,s(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(1==this.version)return[];{const e=Math.floor(this.version/7)+2,t=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*e-2));let n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return s(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let s=0;s<e;s++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map((e=>0));for(const s of e){const e=s^r.shift();r.push(0),n.forEach(((n,s)=>r[s]^=t.reedSolomonMultiply(n,e)))}return r}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^285*(n>>>7),n^=(t>>>r&1)*e;return s(n>>>8==0),n}finderPenaltyCountPatterns(e){const t=e[1];s(t<=3*this.size);const n=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(n&&e[0]>=4*t&&e[6]>=t?1:0)+(n&&e[6]>=4*t&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)}};function n(e,t,n){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return!!(e>>>t&1)}function s(e){if(!e)throw new Error("Assertion error")}t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.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]],t.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]],e.QrCode=t;const i=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}static makeBytes(t){let r=[];for(const e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw new RangeError("String contains non-numeric characters");let r=[];for(let e=0;e<t.length;){const s=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+s),10),3*s+1,r),e+=s}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");let r,s=[];for(r=0;r+2<=t.length;r+=2){let i=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r));i+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r+1)),n(i,11,s)}return r<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r)),6,s),new e(e.Mode.ALPHANUMERIC,t.length,s)}static makeSegments(t){return""==t?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else{if(!(t<1e6))throw new RangeError("ECI assignment value out of range");n(6,3,r),n(t,21,r)}return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(const r of e){const e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)"%"!=e.charAt(n)?t.push(e.charCodeAt(n)):(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2);return t}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;e.QrSegment=i})(qs||(qs={})),(e=>{const t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})((Js=qs||(qs={})).QrCode||(Js.QrCode={})),(e=>{(e=>{const t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})(qs||(qs={}));var ri=qs,si={L:ri.QrCode.Ecc.LOW,M:ri.QrCode.Ecc.MEDIUM,Q:ri.QrCode.Ecc.QUARTILE,H:ri.QrCode.Ecc.HIGH},ii=128,oi="L",ai="#FFFFFF",li="#000000",ci=!1,ui=1;
|
12
3
|
/**
|
13
4
|
* @license qrcode.react
|
14
5
|
* Copyright (c) Paul O'Shannessy
|
15
6
|
* SPDX-License-Identifier: ISC
|
16
|
-
*/function vp(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 wp(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 Ap({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(...hp.QrSegment.makeSegments(e)),t)),[]);return hp.QrCode.encodeSegments(e,dp[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=pp,level:a=fp,bgColor:o=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,marginSize:d,imageSettings:p}=n,f=up(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=up(f,["style"]),_=null==p?void 0:p.src,y=e.useRef(null),v=e.useRef(null),w=e.useCallback((t=>{y.current=t,"function"==typeof r?r(t):r&&(r.current=t)}),[r]),[A,b]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=Ap({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=wp(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(vp(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((()=>{b(!1)}),[_]);const N=cp({height:s,width:s},g);let P=null;return null!=_&&(P=e.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{b(!0)},ref:v,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",cp({style:N,height:s,width:s,ref:w,role:"img"},m)),P)})).displayName="QRCodeCanvas";var Ep=e.forwardRef((function(t,r){const n=t,{value:i,size:s=pp,level:a=fp,bgColor:o=gp,fgColor:l=mp,includeMargin:c=_p,minVersion:u=yp,boostLevel:h,title:d,marginSize:p,imageSettings:f}=n,g=up(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:_,numCells:y,calculatedImageSettings:v}=Ap({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let w=_,A=null;null!=f&&null!=v&&(null!=v.excavation&&(w=wp(_,v.excavation)),A=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 b=vp(w,m);return e.createElement("svg",cp({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:b,shapeRendering:"crispEdges"}),A)}));Ep.displayName="QRCodeSVG";const xp=({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 Xd.jsxs("div",{className:"flex flex-col items-center",children:[c?Xd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsx("p",{className:"font-medium",children:c})]}):Xd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:o&&Xd.jsx(Ep,{value:o,size:a,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Xd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Xd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",n]}),Xd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(i)," wallet app"]})]}),Xd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Xd.jsxs("div",{className:"flex justify-between items-center",children:[Xd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Xd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),Xd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Xd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Xd.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(i)})]})]}),!c&&Xd.jsxs("div",{className:"w-full mb-4",children:[Xd.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),Xd.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})]}),Xd.jsx("div",{className:"w-full",children:Xd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Xd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment Instructions"]}),Xd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Xd.jsxs("li",{children:["1. Open your crypto wallet app (",(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(", "),")"]}),Xd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Xd.jsxs("li",{children:["3. Send exactly ",Xd.jsxs("strong",{children:[r," ",n]})," on ",f(i)," network"]}),Xd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Xd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Xd.jsxs("p",{className:"text-xs text-yellow-800",children:[Xd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(i),") and using the exact amount shown above."]})})]})})]});var g},kp=({status:t,message:e,theme:r="light"})=>Xd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Xd.jsx("div",{className:"mb-4",children:(()=>{switch(t){case"processing":return Xd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Xd.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Xd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),Xd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Xd.jsx("p",{className:`text-center ${(()=>{switch(t){case"processing":return"dark"===r?"text-blue-300":"text-blue-600";case"success":return"dark"===r?"text-green-300":"text-green-600";case"error":return"dark"===r?"text-red-300":"text-red-600";default:return"dark"===r?"text-gray-300":"text-gray-600"}})()}`,children:e}),"processing"===t&&Xd.jsx("div",{className:"mt-4 text-xs "+("dark"===r?"text-gray-400":"text-gray-500"),children:"This may take a few moments. Please do not close this window."}),"success"===t&&Xd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Xd.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]}),Sp=({onSelect:t,selected:r,theme:n="light",supportedNetworks:i=[]})=>{const[s,a]=e.useState(md.ETHEREUM),[o,l]=e.useState({}),[c,u]=e.useState(!1);e.useEffect((()=>{l(Ad())}),[]);const h=[{id:md.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:md.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:md.TRON,name:"Tron",description:"TRC-20 tokens"},{id:md.ALGORAND,name:"Algorand",description:"ASA tokens"}],d=(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:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",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:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",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})(s),p=c?d:d.slice(0,4);function f(t){switch(t){case md.ETHEREUM:case md.BSC:return gd.METAMASK;case md.TRON:return gd.TRONLINK;case md.ALGORAND:return gd.LUTE;default:return gd.METAMASK}}return Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===n?"text-white":"text-gray-800"),children:"Select Payment Method"}),Xd.jsxs("div",{className:"mb-6",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),Xd.jsx("select",{value:s,onChange:e=>{return n=e.target.value,a(n),u(!1),void((null==r?void 0:r.network)!==n&&t(null));var n},className:`w-full p-3 rounded-lg border transition-colors ${"dark"===n?"bg-gray-700 border-gray-600 text-white focus:border-[#7042D2]":"bg-white border-gray-300 text-gray-900 focus:border-[#7042D2]"} focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50`,children:h.filter((t=>0===i.length||i.includes(t.id))).map((t=>Xd.jsxs("option",{value:t.id,children:[t.name," - ",t.description]},t.id)))})]}),Xd.jsxs("div",{className:"mb-4",children:[Xd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),Xd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:p.map((e=>Xd.jsx("button",{onClick:()=>(e=>{var r;t({currency:e.id,network:s,tokenConfig:null==(r=yd[e.id])?void 0:r[s],method:e})})(e),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==r?void 0:r.currency)===e.id&&(null==r?void 0:r.network)===s?"dark"===n?"bg-blue-900/30 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"bg-blue-50 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"dark"===n?"bg-gray-700 hover:bg-gray-600 border-gray-600 hover:border-gray-500":"bg-white hover:bg-gray-50 border-gray-200 hover:border-gray-300"),children:Xd.jsxs("div",{className:"flex flex-col items-center text-center",children:[Xd.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:Xd.jsx("img",{src:e.logo,alt:e.name,className:"h-6 w-6"})}),Xd.jsxs("div",{children:[Xd.jsx("h4",{className:"font-medium text-sm "+("dark"===n?"text-white":"text-gray-900"),children:e.name}),Xd.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-500"),children:e.description})]}),(null==r?void 0:r.currency)===e.id&&(null==r?void 0:r.network)===s&&Xd.jsx("div",{className:"mt-2",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:Xd.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})},`${e.id}-${e.network}`)))}),d.length>4&&Xd.jsx("button",{onClick:()=>u(!c),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:c?"Show Less":`Show More (${d.length-4} more)`})]}),Xd.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(o[f(s)]?"bg-green-500":"bg-red-500")}),Xd.jsx("span",{className:"text-xs",children:function(t){const e=f(t),r=o[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`}(s)})]})})]})},Np=({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:A=!1})=>{const[b,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?Xd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:Xd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Xd.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[Xd.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[Xd.jsx("div",{className:"flex items-center",children:Xd.jsx("h2",{className:"text-xl font-bold text-gray-900",children:Xd.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm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x("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Xd.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[n&&Xd.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[Xd.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",h]}),Xd.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[Xd.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),Xd.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(P=n.totalAmount||n.amount,parseFloat(P).toFixed(2))]})]}),Xd.jsx("div",{className:"text-xs mt-1 text-right",children:Xd.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",n.id?n.id.slice(0,8):"","..."]})})]}),A&&Xd.jsx("div",{className:"mb-2 text-right",children:Xd.jsx("button",{onClick:()=>{console.log("=== DEBUG INFO ==="),console.log("Current step:",v),console.log("Payment method:",s),console.log("Wallet connection:",p),Ed()},className:"text-xs bg-gray-200 p-1 rounded",children:"Debug"})}),"select-currency"===v&&Xd.jsxs("div",{children:[Xd.jsx(Sp,{onSelect:a,selected:s,theme:u,supportedNetworks:m}),s&&Xd.jsx("div",{className:"mt-6",children:Xd.jsxs("button",{onClick:()=>{console.log("Proceed button clicked, calling onPaymentMethodSelect"),a(s)},className:"w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",disabled:!s,children:["Proceed with ",s.currency," on ",x(s.network)]})})]}),"confirm"===v&&s&&n&&Xd.jsxs("div",{children:[Xd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Xd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Xd.jsxs("div",{className:"space-y-2",children:[Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),Xd.jsx("span",{className:"font-medium",children:s.currency})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),Xd.jsx("span",{className:"font-medium",children:x(s.network)})]}),Xd.jsxs("div",{className:"flex justify-between",children:[Xd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),Xd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Xd.jsx("div",{className:"mb-4",children:Xd.jsxs("div",{className:"flex border-b border-gray-200",children:[Xd.jsx("button",{onClick:()=>E("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===b?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Xd.jsx("button",{onClick:()=>E("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===b?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Xd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Xd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===b?Xd.jsx("div",{className:"mb-4",children:Xd.jsx(xp,{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})}):Xd.jsxs("div",{className:"space-y-3 mb-4",children:[0===y.length?Xd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Xd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",x(s.network)," network"]})]})]})}):y.map((t=>Xd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("div",{className:"flex items-center",children:[Xd.jsx("img",{src:S(t),alt:k(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Xd.jsxs("div",{children:[Xd.jsx("h3",{className:"font-medium text-gray-800",children:k(t)}),Xd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",k(t)]})]})]}),(null==p?void 0:p.walletType)===t?Xd.jsxs("div",{className:"flex items-center space-x-2",children:[Xd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Xd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Xd.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",t),f(t)},className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",children:"Connect"})]})},t))),Xd.jsx("div",{className:"space-y-2",children:Object.entries(_).filter((([t,e])=>!e)).map((([t])=>Xd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Xd.jsxs("div",{className:"flex items-center justify-between",children:[Xd.jsxs("span",{className:"text-sm text-gray-600",children:[k(t)," not detected"]}),Xd.jsx("a",{href:wd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},t)))})]}),c&&Xd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Xd.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[Xd.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",children:"Back"}),Xd.jsx("button",{type:"button",onClick:()=>o("qrcode"===b),className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!g&&"wallet"===b&&!p,children:"qrcode"===b?"I have sent the payment":"Pay Now"})]})]}),"processing"===v&&Xd.jsx(kp,{status:"processing",theme:u,message:"Processing your payment..."}),"success"===v&&Xd.jsxs("div",{children:[Xd.jsx(kp,{status:"success",theme:u,message:"Payment successful!"}),d&&Xd.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[Xd.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),Xd.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:(N=d,N?N.length<=14?N:`${N.slice(0,8)}...${N.slice(-6)}`:"")}),s&&Xd.jsx("a",{href:`${Pp(s.network)}/${Cp(s.network)}/${d}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===v&&Xd.jsxs("div",{children:[Xd.jsx(kp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Xd.jsx("button",{type:"button",onClick:l,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]})]}),Xd.jsx("div",{className:"text-center text-xs text-gray-500",children:Xd.jsxs("p",{children:["Powered by ",Xd.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var N,P},Pp=t=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[t]||"https://etherscan.io"),Cp=t=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[t]||"tx"),Tp=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=ep(),{theme:v}=e.useContext($d),[w,A]=e.useState(h),[b,E]=e.useState(null),[x,k]=e.useState("idle"),[S,N]=e.useState(null),[P,C]=e.useState(null),[T,R]=e.useState(null),[G,M]=e.useState(null),[I,B]=e.useState({}),[O,F]=e.useState("select-currency"),[U,L]=e.useState({}),[D,j]=e.useState(!1),H=t||(null==y?void 0:y.apiKey),W=r||(null==y?void 0:y.apiSecret);n||null==y||y.apiUrl;const Q=u||v,z=d||(null==y?void 0:y.debug),V=f.length>0?f:[md.ETHEREUM,md.BSC,md.TRON,md.ALGORAND];e.useImperativeHandle(_,(()=>({open:t=>{K(t)},close:()=>{q()},getPayment:()=>b,getWalletConnection:()=>G,getMerchantWallets:()=>U,debugWallets:()=>Ed()})));const J=(t,e)=>{z&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield bd(3,1e3);B(t),J("Available wallets detected:",t)})))()}}),[z]),e.useEffect((()=>{(()=>{__async(this,null,(function*(){if(H&&W){j(!0);try{const t=__spreadValues({},Od);if(t.merchantWalletAddresses&&Object.keys(t.merchantWalletAddresses).length>0)L(t.merchantWalletAddresses),J("Loaded wallet addresses from API config:",t.merchantWalletAddresses);else{const t=yield Hd();t&&Object.keys(t).length>0?(L(t),J("Fetched wallet addresses from API:",t)):J("No wallet addresses found in API response")}a&&Object.keys(a).length>0&&(L((t=>__spreadValues(__spreadValues({},t),a))),J("Added manual wallet addresses:",a))}catch(t){J("Error loading merchant wallet addresses:",t),console.warn("Could not load merchant wallet addresses:",t.message),a&&Object.keys(a).length>0&&(L(a),J("Using fallback manual wallet addresses:",a))}finally{j(!1)}}else J("No API credentials available for wallet address fetching")}))})()}),[H,W,a,z]);const K=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"),A(!0),F("select-currency");try{J("Creating payment with details:",t);let r=__spreadValues({},U);if(0===Object.keys(r).length){J("No wallet addresses available, attempting to fetch...");try{const t=yield Hd();t&&(r=t,L(t))}catch(e){J("Failed to fetch wallet addresses:",e)}}t.merchantWalletAddresses&&(r=__spreadValues(__spreadValues({},r),t.merchantWalletAddresses)),a&&(r=__spreadValues(__spreadValues({},r),a)),J("Final wallet addresses for payment:",r);const n=yield Ld({amount:t.amount,currency:t.currency||"USDT",network:t.network||g,customerEmail:t.customerEmail||i,callbackUrl:t.callbackUrl,metadata:__spreadProps(__spreadValues({},t.metadata),{sdkVersion:"1.0.0",merchantWallets:r}),merchantWalletAddresses:r});if(J("Payment created:",n),!n.payment)throw new Error("Invalid payment response structure");E(n.payment),n.merchantConfig&&n.merchantConfig.walletAddresses&&(L((t=>__spreadValues(__spreadValues({},t),n.merchantConfig.walletAddresses))),J("Updated wallet addresses from payment response:",n.merchantConfig.walletAddresses)),k("idle"),C(null),J("Payment created and state updated successfully")}catch(r){J("Error creating payment:",r),C(r.message||"Failed to create payment"),k("error"),l&&l(r)}})),q=()=>{A(!1),R(null),M(null),N(null),F("select-currency"),C(null),c&&c()},Z=()=>{if(!S)return null;const t=S.network;return b&&b.recipientWallet?b.recipientWallet:U[t]?U[t]:a[t]?a[t]:null};return D?Xd.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:Xd.jsx("div",{className:"bg-white p-6 rounded-lg shadow-xl",children:Xd.jsxs("div",{className:"flex items-center space-x-3",children:[Xd.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-blue-500 border-t-transparent"}),Xd.jsx("span",{className:"text-gray-700",children:"Loading payment gateway..."})]})})}):Xd.jsx(Xd.Fragment,{children:w&&Xd.jsx(Np,{isOpen:w,onClose:q,payment:b,paymentStatus:x,selectedPaymentMethod:S,onPaymentMethodSelect:t=>{J("Payment method selected:",t),N(t),F("confirm")},onPayment:()=>__async(this,null,(function*(){if(!b||!S)return void C("Missing payment information");const t=Z();if(t||p)if(G||p){J("Starting payment process..."),k("loading"),R(null),F("processing");try{let e;if(p)J("Test mode: Generating mock transaction..."),e=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{J("Sending transaction through wallet...",{recipientAddress:t,amount:b.totalAmount||b.amount,network:S.network});const r=b.token||S.tokenConfig;e=yield Bd(G,{to:t,amount:b.totalAmount||b.amount,tokenAddress:null==r?void 0:r.contractAddress,tokenDecimals:null==r?void 0:r.decimals,currency:S.currency,network:S.network,tokenConfig:r})}J("Transaction hash:",e),R(e),J("Processing payment with backend...");const r=yield Dd({paymentId:b.id,transactionHash:e,network:S.network,currency:S.currency,senderAddress:null==G?void 0:G.address});J("Payment processed successfully:",r),k("success"),F("success"),o&&(J("Calling onSuccess callback..."),o(b.id,e,{network:S.network,currency:S.currency,amount:b.totalAmount||b.amount,recipientAddress:t}))}catch(e){J("Payment error:",e);let t=e.message||"Failed to process payment";t.includes("User rejected")||t.includes("user rejected")?t="Transaction was rejected by user":t.includes("insufficient funds")?t="Insufficient funds in wallet":t.includes("network")?t="Network error. Please check your connection and try again":(t.includes("recipient")||t.includes("address"))&&(t="Invalid recipient address. Please contact support"),C(t),k("error"),F("error"),l&&l(new Error(t))}}else C("Please connect your wallet first");else C(`No recipient wallet address configured for ${S.network} network`)})),onBack:()=>{"confirm"===O?(F("select-currency"),M(null),C(null)):"error"===O&&(F("confirm"),C(null))},error:P,theme:Q,merchantName:s,transactionHash:T,walletConnection:G,onConnectWallet:t=>__async(this,null,(function*(){if(S)try{C(null),J("Connecting wallet:",{walletType:t,network:S.network});const e=yield Pd(t,S.network);M(e),C(null),J("Wallet connected successfully:",e)}catch(e){J("Wallet connection error:",e),C(e.message||"Failed to connect wallet")}else C("Please select a payment method first")})),testMode:p,supportedNetworks:V,availableWallets:I,supportedWallets:S?Cd(S.network):[],step:O,merchantWalletAddresses:U,recipientAddress:Z(),debug:z})})}));Tp.displayName="CoinleyCheckout";t.CoinleyCheckout=Tp,t.CoinleyModal=Np,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);e.useEffect((()=>{var e;if(t&&r)try{e={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s},Od=__spreadValues(__spreadValues({},Od),e),console.log("API initialized with:",{apiUrl:Od.apiUrl,apiKey:Od.apiKey?`${Od.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Od.merchantWalletAddresses||{}).length>0}),c(!0),a&&console.log("Coinley SDK initialized with:",{apiKey:t,apiUrl:n,merchantWalletAddress:i?`${i.substring(0,6)}...${i.substring(i.length-4)}`:"Not provided",merchantSolWalletAddress:s?`${s.substring(0,6)}...${s.substring(s.length-4)}`:"Not provided"})}catch(o){h(o.message),a&&console.error("Coinley SDK initialization error:",o)}else h("API key and secret are required")}),[t,r,n,i,s,a]);const f={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s,isInitialized:l,error:u,debug:a,paymentData:d,storePaymentData:t=>(p(t),t)};return Xd.jsx(tp.Provider,{value:f,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=Sp,t.PaymentStatus=kp,t.QRCode=xp,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]),Xd.jsx($d.Provider,{value:{theme:n,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:r})},t.WALLET_TYPES=gd,t.connectWallet=Pd,t.createPayment=Ld,t.detectWallets=Ad,t.generateMockTransactionHash=(t="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[t]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,t.getMerchantProfile=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Od.apiUrl}/api/merchants/profile`,{method:"GET",headers:Ud()});if(!e.ok){let r;try{r=yield e.json()}catch(t){throw new Error(`Failed to get merchant profile: ${e.status} ${e.statusText}`)}throw new Error(r.error||`Failed to get merchant profile: ${e.status}`)}const r=yield e.json();return r.merchant&&r.merchant.walletAddresses&&(Od.merchantWalletAddresses=__spreadValues(__spreadValues({},Od.merchantWalletAddresses),r.merchant.walletAddresses)),r}catch(e){throw console.error("Get merchant profile error:",e),e}})),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(`${Od.apiUrl}/api/payments/${t}`,{method:"GET",headers:Ud()});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(`${Od.apiUrl}/api/networks`,{method:"GET",headers:Ud()});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=Cd,t.getWalletInstallUrl=wd,t.processPayment=Dd,t.sendTransaction=Bd,t.useCoinley=ep,t.validateWalletAddress=(t,e)=>{if(!t||"string"!=typeof t)return!1;switch(e.toLowerCase()){case"ethereum":case"bsc":return/^0x[a-fA-F0-9]{40}$/.test(t);case"tron":return/^T[a-zA-Z0-9]{33}$/.test(t);case"algorand":return/^[A-Z2-7]{58}$/.test(t);case"solana":return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t);default:return t.length>10}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
7
|
+
*/function di(e,t=0){const n=[];return e.forEach((function(e,r){let s=null;e.forEach((function(i,o){if(!i&&null!==s)return n.push(`M${s+t} ${r+t}h${o-s}v1H${s+t}z`),void(s=null);if(o!==e.length-1)i&&null===s&&(s=o);else{if(!i)return;null===s?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${s+t},${r+t} h${o+1-s}v1H${s+t}z`)}}))})),n.join("")}function hi(e,t){return e.slice().map(((e,n)=>n<t.y||n>=t.y+t.h?e:e.map(((e,n)=>(n<t.x||n>=t.x+t.w)&&e))))}function pi({value:e,level:n,minVersion:r,includeMargin:s,marginSize:i,imageSettings:o,size:a,boostLevel:l}){let c=t.useMemo((()=>{const t=(Array.isArray(e)?e:[e]).reduce(((e,t)=>(e.push(...ri.QrSegment.makeSegments(t)),e)),[]);return ri.QrCode.encodeSegments(t,si[n],r,void 0,void 0,l)}),[e,n,r,l]);const{cells:u,margin:d,numCells:h,calculatedImageSettings:p}=t.useMemo((()=>{let e=c.getModules();const t=function(e,t){return null!=t?Math.max(Math.floor(t),0):e?4:0}(s,i),n=e.length+2*t,r=function(e,t,n,r){if(null==r)return null;const s=e.length+2*n,i=Math.floor(.1*t),o=s/t,a=(r.width||i)*o,l=(r.height||i)*o,c=null==r.x?e.length/2-a/2:r.x*o,u=null==r.y?e.length/2-l/2:r.y*o,d=null==r.opacity?1:r.opacity;let h=null;if(r.excavate){let e=Math.floor(c),t=Math.floor(u);h={x:e,y:t,w:Math.ceil(a+c-e),h:Math.ceil(l+u-t)}}return{x:c,y:u,h:l,w:a,excavation:h,opacity:d,crossOrigin:r.crossOrigin}}(e,a,t,o);return{cells:e,margin:t,numCells:n,calculatedImageSettings:r}}),[c,a,o,s,i]);return{qrcode:c,margin:d,cells:u,numCells:h,calculatedImageSettings:p}}var fi=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();t.forwardRef((function(e,n){const r=e,{value:s,size:i=ii,level:o=oi,bgColor:a=ai,fgColor:l=li,includeMargin:c=ci,minVersion:u=ui,boostLevel:d,marginSize:h,imageSettings:p}=r,f=ni(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:m}=f,g=ni(f,["style"]),y=null==p?void 0:p.src,_=t.useRef(null),b=t.useRef(null),w=t.useCallback((e=>{_.current=e,"function"==typeof n?n(e):n&&(n.current=e)}),[n]),[v,x]=t.useState(!1),{margin:E,cells:N,numCells:k,calculatedImageSettings:A}=pi({value:s,level:o,minVersion:u,boostLevel:d,includeMargin:c,marginSize:h,imageSettings:p,size:i});t.useEffect((()=>{if(null!=_.current){const e=_.current,t=e.getContext("2d");if(!t)return;let n=N;const r=b.current,s=null!=A&&null!==r&&r.complete&&0!==r.naturalHeight&&0!==r.naturalWidth;s&&null!=A.excavation&&(n=hi(N,A.excavation));const o=window.devicePixelRatio||1;e.height=e.width=i*o;const c=i/k*o;t.scale(c,c),t.fillStyle=a,t.fillRect(0,0,k,k),t.fillStyle=l,fi?t.fill(new Path2D(di(n,E))):N.forEach((function(e,n){e.forEach((function(e,r){e&&t.fillRect(r+E,n+E,1,1)}))})),A&&(t.globalAlpha=A.opacity),s&&t.drawImage(r,A.x+E,A.y+E,A.w,A.h)}})),t.useEffect((()=>{x(!1)}),[y]);const T=ti({height:i,width:i},m);let S=null;return null!=y&&(S=t.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{x(!0)},ref:b,crossOrigin:null==A?void 0:A.crossOrigin})),t.createElement(t.Fragment,null,t.createElement("canvas",ti({style:T,height:i,width:i,ref:w,role:"img"},g)),S)})).displayName="QRCodeCanvas";var mi=t.forwardRef((function(e,n){const r=e,{value:s,size:i=ii,level:o=oi,bgColor:a=ai,fgColor:l=li,includeMargin:c=ci,minVersion:u=ui,boostLevel:d,title:h,marginSize:p,imageSettings:f}=r,m=ni(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:g,cells:y,numCells:_,calculatedImageSettings:b}=pi({value:s,level:o,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:f,size:i});let w=y,v=null;null!=f&&null!=b&&(null!=b.excavation&&(w=hi(y,b.excavation)),v=t.createElement("image",{href:f.src,height:b.h,width:b.w,x:b.x+g,y:b.y+g,preserveAspectRatio:"none",opacity:b.opacity,crossOrigin:b.crossOrigin}));const x=di(w,g);return t.createElement("svg",ti({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:n,role:"img"},m),!!h&&t.createElement("title",null,h),t.createElement("path",{fill:a,d:`M0,0 h${_}v${_}H0z`,shapeRendering:"crispEdges"}),t.createElement("path",{fill:l,d:x,shapeRendering:"crispEdges"}),v)}));mi.displayName="QRCodeSVG";const gi=({walletAddress:e,amount:n,currency:r,network:s,theme:i="light",size:o=200})=>{const[a,l]=t.useState(""),[c,u]=t.useState(null);t.useEffect((()=>{if(e&&"No address configured"!==e)try{let t;switch(s){case"tron":t="TRX"===r?`tronlink://transfer?to=${e}&amount=${n}`:e;break;case"algorand":t=`algorand://${e}?amount=${Math.floor(1e6*parseFloat(n))}`;break;case"bsc":if("BNB"===r)t=`ethereum:${e}@56?value=${p(n)}`;else{const s=d(r,"bsc");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(n,r)}@56`:e}break;default:if("ETH"===r)t=`ethereum:${e}@1?value=${p(n)}`;else{const s=d(r,"ethereum");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(n,r)}`:e}}l(t),u(null)}catch(t){console.error("Error generating QR code:",t),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[e,n,r,s]);const d=(e,t)=>{var n;return(null==(n={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[t])?void 0:n[e])||""},h=(e,t)=>{const n="USDT"===t||"USDC"===t?6:18;return Math.floor(parseFloat(e)*Math.pow(10,n)).toString()},p=e=>Math.floor(1e18*parseFloat(e)).toString(),f=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e);return zs.jsxs("div",{className:"flex flex-col items-center",children:[c?zs.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[zs.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:zs.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"})}),zs.jsx("p",{className:"font-medium",children:c})]}):zs.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:a&&zs.jsx(mi,{value:a,size:o,bgColor:"dark"===i?"#374151":"#FFFFFF",fgColor:"dark"===i?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),zs.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[zs.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[zs.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:zs.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",r]}),zs.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(s)," wallet app"]})]}),zs.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[zs.jsxs("div",{className:"flex justify-between items-center",children:[zs.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),zs.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[n," ",r]})]}),zs.jsxs("div",{className:"flex justify-between items-center mt-1",children:[zs.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),zs.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(s)})]})]}),!c&&zs.jsxs("div",{className:"w-full mb-4",children:[zs.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),zs.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 t;return null==(t=navigator.clipboard)?void 0:t.writeText(e)},title:"Click to copy",children:e})]}),zs.jsx("div",{className:"w-full",children:zs.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[zs.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[zs.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:zs.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"]}),zs.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[zs.jsxs("li",{children:["1. Open your crypto wallet app (",(m=s,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[m]||["MetaMask","Trust Wallet"]).join(", "),")"]}),zs.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),zs.jsxs("li",{children:["3. Send exactly ",zs.jsxs("strong",{children:[n," ",r]})," on ",f(s)," network"]}),zs.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),zs.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:zs.jsxs("p",{className:"text-xs text-yellow-800",children:[zs.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(s),") and using the exact amount shown above."]})})]})})]});var m},yi=({status:e,message:t,theme:n="light"})=>zs.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[zs.jsx("div",{className:"mb-4",children:(()=>{switch(e){case"processing":return zs.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return zs.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:zs.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:zs.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return zs.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:zs.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:zs.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),zs.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===n?"text-white":"text-gray-900"),children:(()=>{switch(e){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),zs.jsx("p",{className:`text-center ${(()=>{switch(e){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:t}),"processing"===e&&zs.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."}),"success"===e&&zs.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===n?"bg-gray-700":"bg-gray-100"),children:zs.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-600"),children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]}),_i=({onSelect:e,selected:n,theme:r="light",supportedNetworks:s=[]})=>{const[i,o]=t.useState(as.ETHEREUM),[a,l]=t.useState({}),[c,u]=t.useState(!1);t.useEffect((()=>{l(hs())}),[]);const d=[{id:as.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:as.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:as.TRON,name:"Tron",description:"TRC-20 tokens"},{id:as.ALGORAND,name:"Algorand",description:"ASA tokens"}],h=(e=>{const t=[];switch(e){case as.ETHEREUM:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:as.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:as.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",network:as.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:as.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",network:as.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:as.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",network:as.ETHEREUM});break;case as.BSC:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:as.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:as.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:as.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:as.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",network:as.BSC});break;case as.TRON:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:as.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:as.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:as.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:as.TRON});break;case as.ALGORAND:t.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:as.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:as.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:as.ALGORAND})}return t})(i),p=c?h:h.slice(0,4);function f(e){switch(e){case as.ETHEREUM:case as.BSC:return os.METAMASK;case as.TRON:return os.TRONLINK;case as.ALGORAND:return os.LUTE;default:return os.METAMASK}}return zs.jsxs("div",{children:[zs.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===r?"text-white":"text-gray-800"),children:"Select Payment Method"}),zs.jsxs("div",{className:"mb-6",children:[zs.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===r?"text-white":"text-gray-700"),children:"Blockchain Network"}),zs.jsx("select",{value:i,onChange:t=>{return r=t.target.value,o(r),u(!1),void((null==n?void 0:n.network)!==r&&e(null));var r},className:`w-full p-3 rounded-lg border transition-colors ${"dark"===r?"bg-gray-700 border-gray-600 text-white focus:border-[#7042D2]":"bg-white border-gray-300 text-gray-900 focus:border-[#7042D2]"} focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50`,children:d.filter((e=>0===s.length||s.includes(e.id))).map((e=>zs.jsxs("option",{value:e.id,children:[e.name," - ",e.description]},e.id)))})]}),zs.jsxs("div",{className:"mb-4",children:[zs.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===r?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),zs.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:p.map((t=>zs.jsx("button",{onClick:()=>(t=>{var n;e({currency:t.id,network:i,tokenConfig:null==(n=cs[t.id])?void 0:n[i],method:t})})(t),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==n?void 0:n.currency)===t.id&&(null==n?void 0:n.network)===i?"dark"===r?"bg-blue-900/30 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"bg-blue-50 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"dark"===r?"bg-gray-700 hover:bg-gray-600 border-gray-600 hover:border-gray-500":"bg-white hover:bg-gray-50 border-gray-200 hover:border-gray-300"),children:zs.jsxs("div",{className:"flex flex-col items-center text-center",children:[zs.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:zs.jsx("img",{src:t.logo,alt:t.name,className:"h-6 w-6"})}),zs.jsxs("div",{children:[zs.jsx("h4",{className:"font-medium text-sm "+("dark"===r?"text-white":"text-gray-900"),children:t.name}),zs.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-500"),children:t.description})]}),(null==n?void 0:n.currency)===t.id&&(null==n?void 0:n.network)===i&&zs.jsx("div",{className:"mt-2",children:zs.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:zs.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})},`${t.id}-${t.network}`)))}),h.length>4&&zs.jsx("button",{onClick:()=>u(!c),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===r?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:c?"Show Less":`Show More (${h.length-4} more)`})]}),zs.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===r?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:zs.jsxs("div",{className:"flex items-center",children:[zs.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(a[f(i)]?"bg-green-500":"bg-red-500")}),zs.jsx("span",{className:"text-xs",children:function(e){const t=f(e),n=a[t],r={[os.METAMASK]:"MetaMask",[os.TRONLINK]:"TronLink",[os.TRUST_WALLET]:"Trust Wallet",[os.LUTE]:"Lute Wallet"};return n?`${r[t]} detected - Ready to pay`:`${r[t]} required - Please install to continue`}(i)})]})})]})},bi=({isOpen:e,onClose:n,payment:r,paymentStatus:s,selectedPaymentMethod:i,onPaymentMethodSelect:o,onPayment:a,onBack:l,error:c,theme:u="light",merchantName:d,transactionHash:h,walletConnection:p,onConnectWallet:f,testMode:m=!1,supportedNetworks:g=[],availableWallets:y={},supportedWallets:_=[],step:b="select-currency",merchantWalletAddresses:w={},debug:v=!1})=>{const[x,E]=t.useState("wallet"),N=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e),k=e=>({[os.METAMASK]:"MetaMask",[os.TRONLINK]:"TronLink",[os.TRUST_WALLET]:"Trust Wallet",[os.LUTE]:"Lute Wallet"}[e]||e),A=e=>({[os.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[os.TRONLINK]:"https://www.tronlink.org/images/logo.png",[os.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[os.LUTE]:"https://lute.app/logo.png"}[e]||"");return e?zs.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:zs.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:zs.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[zs.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[zs.jsx("div",{className:"flex items-center",children:zs.jsx("h2",{className:"text-xl font-bold text-gray-900",children:zs.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm4FFgMAhAX48ODg4dISOGB4/XKsfObl9e+Y9n3wViHt3QHY5ud2fYId1caDSJyc/V+kMW4q4S2VFFurcCR0Oj+/H3kq9vSv1VyDDKX5s0Fh8VSlTifrcx/cByR046QRbjE6EQmnQok9aGzlQ+QRZluDHh1BJaWFNKsJApQvs0JlQc+e4jzgelqX1HNUczfHjQqCqkRLsUCWU0jL94buHE659LGQ5G51SfafAUcfZn572Sv63hKZL1u6lYeYpk9jBo6HieKysgmulbR6VAX7lEmuSHpLWkU5tIoVW+3q6cxEhdbOaqMcPF4gzNVVEI2VsJXi5oHE4d/JSpY/YwUO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AfD8UD41yo6dHaRgNb0reSzK+aFvNwYU1QIpWJOliHVGNU96DqkML/Bk3RLf6b6h2hvWf9n8IY9XucPhARDxva+FwIhMtQg0rEJiNLGSZI7lyvDMsXhbG1LKLeMvTBTodH9vN0IhVWnP6mNg1gDOaEnc+N+DxsIwQJQ6qBlcOnAZJDRPyMeiJ9QflhSHbuJyazCVze3JE79ZRzpCj6RY7pBH6NRNe5QfvVqgxcy4uIF5hPzCO/JlG2k44pP36g8Ip+qYyM78yZyxdPr1w3g/5yJoqv9apSGfuTX95uYgoRzrHE6hAbkrNtcG3LOVZzhnLbboqaT8aqU17mnermS+KY6Yzv5QBP7LOoOB64WR2MRxGgWsvhakNed+mkbZCzbSACSVR9Vm3BXQWEz3UNqoSquhCmJtTXbg4vjXDQFDjLtZD+pUjPQtA+F0021eRu/40NKz7ADtuMkB8urWtU/Yzq9u1UaQ+pow0WTzdV77hDlGgZgmuQLdT8HBmi1Hjfl3HnO2wbEhT2qWDniAeNIdD+z6jqQlXcuHL6MMHFYpEuDfYo2sSUtsPzQiDs6CQySTQgRldkWU6UKf+KRROxOaR4h5cF0kzk+pm2qdydUJF2D8yXH3NyPP21tf9dbYdOkDAOU3JFtF6R76EraO9PrfJC39hZv5NidG835b085Eb3qi4G/A2inrQKnVgMFAAAAABJRU5ErkJggg==",className:"w-32",alt:"Coinley Logo"})})}),zs.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:zs.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:zs.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),zs.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[r&&zs.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[zs.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",d]}),zs.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[zs.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),zs.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(S=r.totalAmount||r.amount,parseFloat(S).toFixed(2))]})]}),zs.jsx("div",{className:"text-xs mt-1 text-right",children:zs.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",r.id?r.id.slice(0,8):"","..."]})})]}),v&&zs.jsx("div",{className:"mb-2 text-right",children:zs.jsx("button",{onClick:()=>{console.log("=== DEBUG INFO ==="),console.log("Current step:",b),console.log("Payment method:",i),console.log("Wallet connection:",p),fs()},className:"text-xs bg-gray-200 p-1 rounded",children:"Debug"})}),"select-currency"===b&&zs.jsxs("div",{children:[zs.jsx(_i,{onSelect:o,selected:i,theme:u,supportedNetworks:g}),i&&zs.jsx("div",{className:"mt-6",children:zs.jsxs("button",{onClick:()=>{console.log("Proceed button clicked, calling onPaymentMethodSelect"),o(i)},className:"w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",disabled:!i,children:["Proceed with ",i.currency," on ",N(i.network)]})})]}),"confirm"===b&&i&&r&&zs.jsxs("div",{children:[zs.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[zs.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),zs.jsxs("div",{className:"space-y-2",children:[zs.jsxs("div",{className:"flex justify-between",children:[zs.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),zs.jsx("span",{className:"font-medium",children:i.currency})]}),zs.jsxs("div",{className:"flex justify-between",children:[zs.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),zs.jsx("span",{className:"font-medium",children:N(i.network)})]}),zs.jsxs("div",{className:"flex justify-between",children:[zs.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),zs.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),zs.jsx("div",{className:"mb-4",children:zs.jsxs("div",{className:"flex border-b border-gray-200",children:[zs.jsx("button",{onClick:()=>E("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===x?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),zs.jsx("button",{onClick:()=>E("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===x?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),m?zs.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:zs.jsxs("div",{className:"flex items-center",children:[zs.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:zs.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:zs.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),zs.jsxs("div",{children:[zs.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),zs.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===x?zs.jsx("div",{className:"mb-4",children:zs.jsx(gi,{walletAddress:(()=>{if(!i)return"No network selected";const e=w[i.network];return e||((null==r?void 0:r.recipientWallet)?r.recipientWallet:"No wallet address configured for this network")})(),amount:r.totalAmount||r.amount,currency:i.currency,network:i.network,theme:u})}):zs.jsxs("div",{className:"space-y-3 mb-4",children:[0===_.length?zs.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:zs.jsxs("div",{className:"flex items-center",children:[zs.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:zs.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"})}),zs.jsxs("div",{children:[zs.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),zs.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",N(i.network)," network"]})]})]})}):_.map((e=>zs.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:zs.jsxs("div",{className:"flex items-center justify-between",children:[zs.jsxs("div",{className:"flex items-center",children:[zs.jsx("img",{src:A(e),alt:k(e),className:"w-8 h-8 mr-3",onError:e=>{e.target.style.display="none"}}),zs.jsxs("div",{children:[zs.jsx("h3",{className:"font-medium text-gray-800",children:k(e)}),zs.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",k(e)]})]})]}),(null==p?void 0:p.walletType)===e?zs.jsxs("div",{className:"flex items-center space-x-2",children:[zs.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),zs.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):zs.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",e),f(e)},className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",children:"Connect"})]})},e))),zs.jsx("div",{className:"space-y-2",children:Object.entries(y).filter((([e,t])=>!t)).map((([e])=>zs.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:zs.jsxs("div",{className:"flex items-center justify-between",children:[zs.jsxs("span",{className:"text-sm text-gray-600",children:[k(e)," not detected"]}),zs.jsx("a",{href:ds(e),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},e)))})]}),c&&zs.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),zs.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[zs.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",children:"Back"}),zs.jsx("button",{type:"button",onClick:()=>a("qrcode"===x),className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!m&&"wallet"===x&&!p,children:"qrcode"===x?"I have sent the payment":"Pay Now"})]})]}),"processing"===b&&zs.jsx(yi,{status:"processing",theme:u,message:"Processing your payment..."}),"success"===b&&zs.jsxs("div",{children:[zs.jsx(yi,{status:"success",theme:u,message:"Payment successful!"}),h&&zs.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[zs.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),zs.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:(T=h,T?T.length<=14?T:`${T.slice(0,8)}...${T.slice(-6)}`:"")}),i&&zs.jsx("a",{href:`${wi(i.network)}/${vi(i.network)}/${h}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===b&&zs.jsxs("div",{children:[zs.jsx(yi,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),zs.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"})]})]}),zs.jsx("div",{className:"text-center text-xs text-gray-500",children:zs.jsxs("p",{children:["Powered by ",zs.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var T,S},wi=e=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[e]||"https://etherscan.io"),vi=e=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[e]||"tx"),xi=t.forwardRef((({apiKey:e,apiSecret:n,apiUrl:r,customerEmail:s,merchantName:i="Merchant",merchantWalletAddresses:o={},onSuccess:a,onError:l,onClose:c,theme:u,autoOpen:d=!1,debug:h=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:m=as.ETHEREUM,preferredWallet:g=os.METAMASK},y)=>{const _=Ks(),{theme:b}=t.useContext(Vs),[w,v]=t.useState(d),[x,E]=t.useState(null),[N,k]=t.useState("idle"),[A,T]=t.useState(null),[S,O]=t.useState(null),[R,C]=t.useState(null),[M,P]=t.useState(null),[F,U]=t.useState({}),[j,I]=t.useState("select-currency"),[L,G]=t.useState({}),D=e||(null==_?void 0:_.apiKey),B=n||(null==_?void 0:_.apiSecret);r||null==_||_.apiUrl;const W=u||b,$=h||(null==_?void 0:_.debug),z=f.length>0?f:[as.ETHEREUM,as.BSC,as.TRON,as.ALGORAND],V=(e,t)=>{$&&console.log(`[Coinley SDK] ${e}`,t)};t.useEffect((()=>{D&&B&&(()=>{__async(this,null,(function*(){try{V("Fetching merchant wallet addresses from backend...");const e=yield Cs();G(e),V("Merchant wallets fetched successfully:",e)}catch(e){console.error("Failed to fetch merchant wallets:",e),G(o)}}))})()}),[D,B,o]),t.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const e=yield ps(3,1e3);U(e),V("Available wallets detected:",e)})))()}}),[$]),t.useImperativeHandle(y,(()=>({open:e=>{H(e)},close:()=>{K()},getPayment:()=>x,getWalletConnection:()=>M,debugWallets:()=>fs(),getMerchantWallets:()=>L})));const H=e=>__async(this,null,(function*(){if(!e||!e.amount)return O("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));k("loading"),v(!0),I("select-currency");try{V("Creating payment with details:",e);let t=L;0===Object.keys(t).length&&(V("No wallet addresses found, fetching from backend..."),t=yield Cs(),G(t)),V("Using wallet addresses:",t);const n=yield Ps({amount:e.amount,currency:e.currency||"USDT",network:e.network||m,customerEmail:e.customerEmail||s,callbackUrl:e.callbackUrl,metadata:__spreadProps(__spreadValues({},e.metadata),{merchantWalletAddresses:t}),merchantWalletAddresses:t});V("Payment created:",n),E(n.payment),k("idle"),O(null),V("Payment created and state updated")}catch(t){V("Error creating payment:",t),O(t.message||"Failed to create payment"),k("error"),l&&l(t)}})),K=()=>{v(!1),C(null),P(null),T(null),I("select-currency"),c&&c()};return zs.jsx(zs.Fragment,{children:w&&zs.jsx(bi,{isOpen:w,onClose:K,payment:x,paymentStatus:N,selectedPaymentMethod:A,onPaymentMethodSelect:e=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",e),console.log("2. Current step before:",j),V("Payment method selected:",e),T(e),I("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>__async(this,null,(function*(){var e,t;if(x&&A)if(M||p){V("Starting payment process..."),k("loading"),C(null),I("processing");try{let n;if(p)V("Test mode: Generating mock transaction..."),n=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{let r;if(x.recipientWallet)r=x.recipientWallet;else{if(!L[A.network])throw new Error(`No merchant wallet address found for ${A.network} network`);r=L[A.network]}V("Using merchant address for payment:",r),V("Sending transaction through wallet..."),n=yield Es(M,{to:r,amount:x.totalAmount||x.amount,tokenAddress:null==(e=A.tokenConfig)?void 0:e.address,tokenDecimals:null==(t=A.tokenConfig)?void 0:t.decimals,currency:A.currency,network:A.network})}V("Transaction hash:",n),C(n),V("Processing payment with backend...");const r=yield Fs({paymentId:x.id,transactionHash:n,network:A.network,currency:A.currency,senderAddress:null==M?void 0:M.address});V("Payment processed successfully:",r),k("success"),I("success"),a&&(V("Calling onSuccess callback..."),a(x.id,n,{network:A.network,currency:A.currency,amount:x.totalAmount||x.amount}))}catch(n){V("Payment error:",n),O(n.message||"Failed to process payment"),k("error"),I("error"),l&&l(n)}}else O("Please connect your wallet first");else O("Missing payment information")})),onBack:()=>{"confirm"===j?(I("select-currency"),P(null)):"error"===j&&I("confirm")},error:S,theme:W,merchantName:i,transactionHash:R,walletConnection:M,onConnectWallet:e=>__async(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",e),console.log("2. Selected payment method:",A),console.log("3. Available wallets:",F),console.log("4. Current step:",j),!A)return console.error("No payment method selected"),void O("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),O(null),V("Connecting wallet:",{walletType:e,network:A.network});const t=yield ws(e,A.network);P(t),O(null),console.log("6. Connection successful:",t),V("Wallet connected successfully:",t)}catch(t){console.error("7. Connection failed:",t),V("Wallet connection error:",t),O(t.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:z,availableWallets:F,supportedWallets:A?vs(A.network):[],step:j,merchantWalletAddresses:L,debug:$})})}));xi.displayName="CoinleyCheckout";e.CoinleyCheckout=xi,e.CoinleyModal=bi,e.CoinleyProvider=({apiKey:e,apiSecret:n,apiUrl:r="https://coinleyserver-production.up.railway.app",merchantWalletAddress:s=null,merchantSolWalletAddress:i=null,debug:o=!1,children:a})=>{const[l,c]=t.useState(!1),[u,d]=t.useState(null),[h,p]=t.useState(null),[f,m]=t.useState({});t.useEffect((()=>{if(!e||!n)return void d("API key and secret are required");(()=>{__async(this,null,(function*(){try{yield Os({apiKey:e,apiSecret:n,apiUrl:r,debug:o});const t=yield Cs(),a=__spreadValues(__spreadValues(__spreadValues({},t),s&&{ethereum:s}),i&&{solana:i});m(a),c(!0),o&&console.log("Coinley SDK initialized successfully with wallets:",a)}catch(t){d(t.message),o&&console.error("Coinley SDK initialization error:",t)}}))})()}),[e,n,r,s,i,o]);const g={apiKey:e,apiSecret:n,apiUrl:r,merchantWalletAddress:s,merchantSolWalletAddress:i,merchantWallets:f,isInitialized:l,error:u,debug:o,paymentData:h,storePaymentData:e=>(p(e),e),refreshMerchantWallets:()=>__async(this,null,(function*(){try{const e=yield Cs();return m(e),e}catch(e){return console.error("Failed to refresh merchant wallets:",e),f}}))};return zs.jsx(Hs.Provider,{value:g,children:a})},e.DEFAULT_CONFIG={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},e.NETWORK_CONFIG=ls,e.NETWORK_TYPES=as,e.PaymentMethods=_i,e.PaymentStatus=yi,e.QRCode=gi,e.TOKEN_CONFIG=cs,e.ThemeProvider=({initialTheme:e="light",children:n})=>{const[r,s]=t.useState(e);return t.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(r)}),[r]),zs.jsx(Vs.Provider,{value:{theme:r,setTheme:s,toggleTheme:()=>{s((e=>"light"===e?"dark":"light"))}},children:n})},e.WALLET_TYPES=os,e.connectWallet=ws,e.createPayment=Ps,e.detectWallets=hs,e.generateMockTransactionHash=(e="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[e]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,e.getMerchantWallets=Cs,e.getPayment=e=>__async(this,null,(function*(){try{if(console.log("Getting payment:",e),!e)throw new Error("Payment ID is required");const n=yield fetch(`${Ss.apiUrl}/api/payments/${e}`,{method:"GET",headers:Ms()});if(!n.ok){let e;try{e=yield n.json()}catch(t){throw new Error(`Failed to get payment: ${n.status} ${n.statusText}`)}throw console.error("Error getting payment:",e),new Error(e.error||`Failed to get payment: ${n.status}`)}const r=yield n.json();return console.log("Get payment response:",r),r}catch(n){throw console.error("Get payment error:",n),n}})),e.getSupportedNetworks=()=>__async(this,null,(function*(){try{const t=yield fetch(`${Ss.apiUrl}/api/networks`,{method:"GET",headers:Ms()});if(!t.ok){let n;try{n=yield t.json()}catch(e){throw new Error(`Failed to get networks: ${t.status} ${t.statusText}`)}throw new Error(n.error||`Failed to get networks: ${t.status}`)}return yield t.json()}catch(t){throw console.error("Get supported networks error:",t),t}})),e.getSupportedWalletsForNetwork=vs,e.getWalletInstallUrl=ds,e.processPayment=Fs,e.sendTransaction=Es,e.useCoinley=Ks,e.validateWalletAddress=(e,t)=>__async(this,null,(function*(){try{const r=yield fetch(`${Ss.apiUrl}/api/wallets/validate`,{method:"POST",headers:Ms(),body:JSON.stringify({address:e,network:t})});if(!r.ok){let e;try{e=yield r.json()}catch(n){throw new Error(`Failed to validate address: ${r.status} ${r.statusText}`)}throw new Error(e.error||`Failed to validate address: ${r.status}`)}return yield r.json()}catch(r){throw console.error("Validate wallet address error:",r),r}})),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
17
8
|
//# sourceMappingURL=coinley-checkout.umd.js.map
|