coinley-checkout 0.4.5 → 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.
@@ -1,8 +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=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,r)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),r),__accessCheck=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},__privateGet=(e,t,r)=>(__accessCheck(e,t,"read from private field"),r?r.call(e):t.get(e)),__privateAdd=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},__privateSet=(e,t,r,n)=>(__accessCheck(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),__privateWrapper=(e,t,r,n)=>({set _(n){__privateSet(e,t,n,r)},get _(){return __privateGet(e,t,n)}}),__privateMethod=(e,t,r)=>(__accessCheck(e,t,"access private method"),r),__superGet=(e,t,r)=>__reflectGet(__getProtoOf(e),r,t),__async=(e,t,r)=>new Promise(((n,s)=>{var i=e=>{try{a(r.next(e))}catch(t){s(t)}},o=e=>{try{a(r.throw(e))}catch(t){s(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,o);a((r=r.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 r,n,s,i,o,a,l,c,u,d,h,p,f,m,g,y,_,b,w,v,x,E,N,k,A,T,S,R,O,C,P,M,F,j,U,L,I,G,D,B,W,$,z,V,H,K,q,J,Q,X,Y,Z,ee;function te(e,t,r){const n=t.split("|").map((e=>e.trim()));for(let i=0;i<n.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.${r}`,s.value=e,s}function re(e){return __async(this,null,(function*(){const t=Object.keys(e);return(yield Promise.all(t.map((t=>Promise.resolve(e[t]))))).reduce(((e,r,n)=>(e[t[n]]=r,e)),{})}))}function ne(e,t,r){for(let n in t){let s=t[n];const i=r?r[n]:null;i&&te(s,i,n),Object.defineProperty(e,n,{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 r="0x";for(let n=0;n<e.length;n++)r+=t[e[n]>>4],r+=t[15&e[n]];return r}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 r=Object.keys(e);return r.sort(),"{ "+r.map((r=>`${se(r,t)}: ${se(e[r],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,r){let n,s=e;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${se(r)}`);for(const e in r){if("shortMessage"===e)continue;const t=r[e];n.push(e+"="+se(t))}}n.push(`code=${t}`),n.push("version=6.14.3"),n.length&&(e+=" ("+n.join(", ")+")")}switch(t){case"INVALID_ARGUMENT":n=new TypeError(e);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(e);break;default:n=new Error(e)}return ne(n,{code:t}),r&&Object.assign(n,r),null==n.shortMessage&&ne(n,{shortMessage:s}),n}function le(e,t,r,n){if(!e)throw ae(t,r,n)}function ce(e,t,r,n){le(e,t,"INVALID_ARGUMENT",{argument:r,value:n})}function ue(e,t,r){null==r&&(r=""),r&&(r=": "+r),le(e>=t,"missing argument"+r,"MISSING_ARGUMENT",{count:e,expectedCount:t}),le(e<=t,"too many arguments"+r,"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(r){}return e}),[]);function he(e,t,r){if(null==r&&(r=""),e!==t){let e=r,t="new";r&&(e+=".",t+=" "+r),le(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}function pe(e,t,r){if(e instanceof Uint8Array)return r?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 r=2;for(let n=0;n<t.length;n++)t[n]=parseInt(e.substring(r,r+2),16),r+=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 r="0x";for(let n=0;n<t.length;n++){const e=t[n];r+=ye[(240&e)>>4]+ye[15&e]}return r}function be(e){return"0x"+e.map((e=>_e(e).substring(2))).join("")}function we(e,t,r){const n=fe(e);return null!=r&&r>n.length&&le(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),_e(n.slice(null==t?0:t,null==r?n.length:r))}function ve(e,t,r){const n=fe(e);le(t>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:t,offset:t+1});const s=new Uint8Array(t);return s.fill(0),r?s.set(n,t-n.length):s.set(n,0),_e(s)}const xe=BigInt(0),Ee=BigInt(1),Ne=9007199254740991;function ke(e,t){const r=Se(e,"value"),n=BigInt(Ce(t,"width"));if(le(r>>n===xe,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),r>>n-Ee){return-((~r&(Ee<<n)-Ee)+Ee)}return r}function Ae(e,t){const r=Se(e,"value"),n=BigInt(Ce(t,"bits"));return r&(Ee<<n)-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(r){ce(!1,`invalid BigNumberish string: ${r.message}`,t||"value",e)}}ce(!1,"invalid BigNumberish value",t||"value",e)}function Se(e,t){const r=Te(e,t);return le(r>=xe,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),r}const Re="0123456789abcdef";function Oe(e){if(e instanceof Uint8Array){let t="0x0";for(const r of e)t+=Re[r>>4],t+=Re[15&r];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(r){ce(!1,`invalid numeric string: ${r.message}`,t||"value",e)}}ce(!1,"invalid numeric value",t||"value",e)}function Pe(e,t){let r=Se(e,"value").toString(16);if(null==t)r.length%2&&(r="0"+r);else{const n=Ce(t,"width");for(le(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:e});r.length<2*n;)r="0"+r}return"0x"+r}class Me{constructor(e,t,n){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,r,void 0),__privateSet(this,r,t),ne(this,{emitter:e,filter:n})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,r)&&(yield this.emitter.off(this.filter,__privateGet(this,r)))}))}}function Fe(e,t,r,n,s){if("BAD_PREFIX"===e||"UNEXPECTED_CONTINUE"===e){let e=0;for(let n=t+1;n<r.length&&r[n]>>6==2;n++)e++;return e}return"OVERRUN"===e?r.length-t-1:0}r=new WeakMap;const je=Object.freeze({error:function(e,t,r,n,s){ce(!1,`invalid codepoint at offset ${t}; ${e}`,"bytes",r)},ignore:Fe,replace:function(e,t,r,n,s){return"OVERLONG"===e?(ce("number"==typeof s,"invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),Fe(e,t,r))}});function Ue(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 r=[];for(let n=0;n<e.length;n++){const t=e.charCodeAt(n);if(t<128)r.push(t);else if(t<2048)r.push(t>>6|192),r.push(63&t|128);else if(55296==(64512&t)){n++;const s=e.charCodeAt(n);ce(n<e.length&&56320==(64512&s),"invalid surrogate pair","str",e);const i=65536+((1023&t)<<10)+(1023&s);r.push(i>>18|240),r.push(i>>12&63|128),r.push(i>>6&63|128),r.push(63&i|128)}else r.push(t>>12|224),r.push(t>>6&63|128),r.push(63&t|128)}return new Uint8Array(r)}function Le(e,t){return r=function(e,t){null==t&&(t=je.error);const r=fe(e,"bytes"),n=[];let s=0;for(;s<r.length;){const e=r[s++];if(!(e>>7)){n.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,r,n);continue}i=3,o=65535}if(s-1+i>=r.length){s+=t("OVERRUN",s-1,r,n);continue}let a=e&(1<<8-i-1)-1;for(let l=0;l<i;l++){let e=r[s];if(128!=(192&e)){s+=t("MISSING_CONTINUE",s,r,n),a=null;break}a=a<<6|63&e,s++}null!==a&&(a>1114111?s+=t("OUT_OF_RANGE",s-1-i,r,n,a):a>=55296&&a<=57343?s+=t("UTF16_SURROGATE",s-1-i,r,n,a):a<=o?s+=t("OVERLONG",s-1-i,r,n,a):n.push(a))}return n}(e,t),r.map((e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e))))).join("");var r}const Ie=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,r){const n=BigInt(t.width);if(t.signed){const t=De<<n-De;le(null==r||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:e}),e=e>Ge?ke(Ae(e,n),n):-ke(Ae(-e,n),n)}else{const t=De<<n;le(null==r||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:r,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,r=128,n=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],r=parseInt(s[2]),n=parseInt(s[3])}else if(e){const s=e,i=(e,t,r)=>null==s[e]?r:(ce(typeof s[e]===t,"invalid fixed format ("+e+" not "+t+")","format."+e,s[e]),s[e]);t=i("signed","boolean",t),r=i("width","number",r),n=i("decimals","number",n)}ce(r%8==0,"invalid FixedNumber width (not byte aligned)","format.width",r),ce(n<=80,"invalid FixedNumber decimals (too large)","format.decimals",n);return{signed:t,width:r,decimals:n,name:(t?"":"u")+"fixed"+String(r)+"x"+String(n)}}const Ke=class e{constructor(e,t,r){__privateAdd(this,o),__privateAdd(this,l),__privateAdd(this,u),__privateAdd(this,h),__privateAdd(this,f),__privateAdd(this,g),__publicField(this,"format"),__privateAdd(this,n,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,n,r);const a=function(e,t){let r="";e<Ge&&(r="-",e*=Ie);let n=e.toString();if(0===t)return r+n;for(;n.length<=t;)n=$e+n;const s=n.length-t;for(n=n.substring(0,s)+"."+n.substring(s);"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}(t,r.decimals);ne(this,{format:r.name,_value:a}),__privateSet(this,i,ze(r.decimals))}get signed(){return __privateGet(this,n).signed}get width(){return __privateGet(this,n).width}get decimals(){return __privateGet(this,n).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,r=e.value;const n=this.decimals-e.decimals;return n>0?r*=ze(n):n<0&&(t*=ze(-n)),t<r?-1:t>r?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 r=this.decimals-t,s=Be*ze(r-1);let i=this.value+s;const o=ze(r);return i=i/o*o,Ve(i,__privateGet(this,n),"round"),new e(We,i,__privateGet(this,n))}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,r,n){const s=null==r?0:Ce(r),i=He(n);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,r){const n=t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);ce(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",t);const s=He(r);let i=n[2]||"0",o=n[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(n[1]+i+o);return Ve(a,s,"fromString"),new e(We,a,s)}static fromBytes(t,r){let n=Oe(fe(t,"value"));const s=He(r);return s.signed&&(n=ke(n,s.width)),Ve(n,s,"fromBytes"),new e(We,n,s)}};n=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,n),t),new Ke(We,e,__privateGet(this,n))},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"];function Qe(e,t){ce("string"==typeof e,"value must be a string","value",e);let r=18;if("string"==typeof t){const e=Je.indexOf(t);ce(e>=0,"invalid unit","unit",t),r=3*e}else null!=t&&(r=Ce(t,"unit"));return qe.fromString(e,{decimals:r,width:512}).value}function Xe(e){return Qe(e,18)}const Ye=32,Ze=new Uint8Array(Ye),et=["then"],tt={},rt=new WeakMap;function nt(e){return rt.get(e)}function st(e,t){rt.set(e,t)}function it(e,t){const r=new Error(`deferred error during ABI decoding triggered accessing ${e}`);throw r.error=t,r}function ot(e,t,r){return e.indexOf(null)>=0?t.map(((e,t)=>e instanceof at?ot(nt(e),e,r):e)):e.reduce(((e,n,s)=>{let i=t.getValue(n);return n in e||(r&&i instanceof at&&(i=ot(nt(i),i,r)),e[n]=i),e}),{})}_=new WeakMap;let at=class e extends Array{constructor(...e){const t=e[0];let r=e[1],n=(e[2]||[]).slice(),s=!0;t!==tt&&(r=e,n=[],s=!1),super(r.length),__privateAdd(this,_,void 0),r.forEach(((e,t)=>{this[t]=e}));const i=n.reduce(((e,t)=>("string"==typeof t&&e.set(t,(e.get(t)||0)+1),e)),new Map);if(st(this,Object.freeze(r.map(((e,t)=>{const r=n[t];return null!=r&&1===i.get(r)?r:null})))),__privateSet(this,_,[]),null==__privateGet(this,_)&&__privateGet(this,_),!s)return;Object.freeze(this);const o=new Proxy(this,{get:(e,t,r)=>{if("string"==typeof t){if(t.match(/^[0-9]+$/)){const r=Ce(t,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=e[r];return n instanceof Error&&it(`index ${r}`,n),n}if(et.indexOf(t)>=0)return Reflect.get(e,t,r);const n=e[t];if(n instanceof Function)return function(...t){return n.apply(this===r?e:this,t)};if(!(t in e))return e.getValue.apply(this===r?e:this,[t])}return Reflect.get(e,t,r)}});return st(o,nt(this)),o}toArray(t){const r=[];return this.forEach(((n,s)=>{n instanceof Error&&it(`index ${s}`,n),t&&n instanceof e&&(n=n.toArray(t)),r.push(n)})),r}toObject(e){const t=nt(this);return t.reduce(((r,n,s)=>(le(null!=n,`value at index ${s} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),ot(t,this,e))),{})}slice(t,r){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==r&&(r=this.length),r<0&&(r+=this.length)<0&&(r=0),r>this.length&&(r=this.length);const n=nt(this),s=[],i=[];for(let e=t;e<r;e++)s.push(this[e]),i.push(n[e]);return new e(tt,s,i)}filter(t,r){const n=nt(this),s=[],i=[];for(let e=0;e<this.length;e++){const o=this[e];o instanceof Error&&it(`index ${e}`,o),t.call(r,o,e,this)&&(s.push(o),i.push(n[e]))}return new e(tt,s,i)}map(e,t){const r=[];for(let n=0;n<this.length;n++){const s=this[n];s instanceof Error&&it(`index ${n}`,s),r.push(e.call(t,s,n,this))}return r}getValue(e){const t=nt(this).indexOf(e);if(-1===t)return;const r=this[t];return r instanceof Error&&it(`property ${JSON.stringify(e)}`,r.error),r}static fromItems(t,r){return new e(tt,t,r)}};function lt(e){let t=function(e){const t=Se(e,"value");if(t===xe)return new Uint8Array([]);let r=t.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let s=0;s<n.length;s++){const e=2*s;n[s]=parseInt(r.substring(e,e+2),16)}return n}(e);return le(t.length<=Ye,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:Ye,offset:t.length}),t.length!==Ye&&(t=me(be([Ze.slice(t.length%Ye),t]))),t}class ct{constructor(e,t,r,n){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),ne(this,{name:e,type:t,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){ce(!1,e,this.localName,t)}}class ut{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 r=t.length%Ye;return r&&(t=me(be([t,Ze.slice(r)]))),__privateMethod(this,v,x).call(this,t)}writeValue(e){return __privateMethod(this,v,x).call(this,lt(e))}writeUpdatableValue(){const e=__privateGet(this,b).length;return __privateGet(this,b).push(Ze),__privateSet(this,w,__privateGet(this,w)+Ye),t=>{__privateGet(this,b)[e]=lt(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,R=function(e){var t;if(__privateGet(this,A))return __privateMethod(t=__privateGet(this,A),S,R).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}})},O=new WeakSet,C=function(e,t,r){let n=Math.ceil(t/Ye)*Ye;return __privateGet(this,N)+n>__privateGet(this,E).length&&(this.allowLoose&&r&&__privateGet(this,N)+t<=__privateGet(this,E).length?n=t:le(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:me(__privateGet(this,E)),length:__privateGet(this,E).length,offset:__privateGet(this,N)+n})),__privateGet(this,E).slice(__privateGet(this,N),__privateGet(this,N)+n)};let dt=class e{constructor(e,t,r){__privateAdd(this,S),__privateAdd(this,O),__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),ne(this,{allowLoose:!!t}),__privateSet(this,E,me(e)),__privateSet(this,k,0),__privateSet(this,A,null),__privateSet(this,T,null!=r?r: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 r=new e(__privateGet(this,E).slice(__privateGet(this,N)+t),this.allowLoose,__privateGet(this,T));return __privateSet(r,A,this),r}readBytes(e,t){let r=__privateMethod(this,O,C).call(this,0,e,!!t);return __privateMethod(this,S,R).call(this,e),__privateSet(this,N,__privateGet(this,N)+r.length),r.slice(0,e)}readValue(){return Oe(this.readBytes(Ye))}readIndex(){return Ce(Oe(this.readBytes(Ye)))}};function ht(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function pt(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 ft(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 mt(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 gt{clone(){return this._cloneInto()}}const yt=BigInt(__pow(2,32)-1),_t=BigInt(32);function bt(e,t=!1){return t?{h:Number(e&yt),l:Number(e>>_t&yt)}:{h:0|Number(e>>_t&yt),l:0|Number(e&yt)}}function wt(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:i,l:o}=bt(e[s],t);[r[s],n[s]]=[i,o]}return[r,n]}const[vt,xt,Et]=[[],[],[]],Nt=BigInt(0),kt=BigInt(1),At=BigInt(2),Tt=BigInt(7),St=BigInt(256),Rt=BigInt(113);for(let xi=0,Ei=kt,Ni=1,ki=0;xi<24;xi++){[Ni,ki]=[ki,(2*Ni+3*ki)%5],vt.push(2*(5*ki+Ni)),xt.push((xi+1)*(xi+2)/2%64);let e=Nt;for(let t=0;t<7;t++)Ei=(Ei<<kt^(Ei>>Tt)*Rt)%St,Ei&At&&(e^=kt<<(kt<<BigInt(t))-kt);Et.push(e)}const[Ot,Ct]=wt(Et,!0),Pt=(e,t,r)=>r>32?((e,t,r)=>t<<r-32|e>>>64-r)(e,t,r):((e,t,r)=>e<<r|t>>>32-r)(e,t,r),Mt=(e,t,r)=>r>32?((e,t,r)=>e<<r-32|t>>>64-r)(e,t,r):((e,t,r)=>t<<r|e>>>32-r)(e,t,r);class Ft extends gt{constructor(e,t,r,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ht(r),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 r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let n=0;n<10;n++)r[n]=e[n]^e[n+10]^e[n+20]^e[n+30]^e[n+40];for(let n=0;n<10;n+=2){const t=(n+8)%10,s=(n+2)%10,i=r[s],o=r[s+1],a=Pt(i,o,1)^r[t],l=Mt(i,o,1)^r[t+1];for(let r=0;r<50;r+=10)e[n+r]^=a,e[n+r+1]^=l}let t=e[2],s=e[3];for(let r=0;r<24;r++){const n=xt[r],i=Pt(t,s,n),o=Mt(t,s,n),a=vt[r];t=e[a],s=e[a+1],e[a]=i,e[a+1]=o}for(let n=0;n<50;n+=10){for(let t=0;t<10;t++)r[t]=e[n+t];for(let t=0;t<10;t++)e[n+t]^=~r[(t+2)%10]&r[(t+4)%10]}e[0]^=Ot[n],e[1]^=Ct[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){ft(this);const{blockLen:t,state:r}=this,n=(e=mt(e)).length;for(let s=0;s<n;){const i=Math.min(t-this.pos,n-s);for(let t=0;t<i;t++)r[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:r,blockLen:n}=this;e[r]^=t,128&t&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){ft(this,!1),pt(e),this.finish();const t=this.state,{blockLen:r}=this;for(let n=0,s=e.length;n<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-n);e.set(t.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=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 ht(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(function(e,t){pt(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}
|
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:r,outputLen:n,rounds:s,enableXOF:i}=this;return e||(e=new Ft(t,r,n,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=n,e.enableXOF=i,e.destroyed=this.destroyed,e}}const jt=((e,t,r)=>function(e){const t=t=>e().update(mt(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}((()=>new Ft(t,e,r))))(1,136,32);let Ut=!1;const Lt=function(e){return jt(e)};let It=Lt;function Gt(e){const t=fe(e,"data");return _e(It(t))}Gt._=Lt,Gt.lock=function(){Ut=!0},Gt.register=function(e){if(Ut)throw new TypeError("keccak256 is locked");It=e},Object.freeze(Gt);const Dt=BigInt(0),Bt=BigInt(36);function Wt(e){const t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let s=0;s<40;s++)r[s]=t[s].charCodeAt(0);const n=fe(Gt(r));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(15&n[s>>1])>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const $t={};for(let xi=0;xi<10;xi++)$t[String(xi)]=String(xi);for(let xi=0;xi<26;xi++)$t[String.fromCharCode(65+xi)]=String(10+xi);const zt=function(){const e={};for(let t=0;t<36;t++){e["0123456789abcdefghijklmnopqrstuvwxyz"[t]]=BigInt(t)}return e}();function Vt(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=Wt(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=>$t[e])).join("");for(;t.length>=15;){let e=t.substring(0,15);t=parseInt(e,10)%97+t.substring(e.length)}let r=String(98-parseInt(t,10)%97);for(;r.length<2;)r="0"+r;return r}(e),"bad icap checksum","address",e);let t=function(e){e=e.toLowerCase();let t=Dt;for(let r=0;r<e.length;r++)t=t*Bt+zt[e[r]];return t}(e.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return Wt("0x"+t)}ce(!1,"invalid address","address",e)}function Ht(e){return e&&"function"==typeof e.getAddress}function Kt(e,t){return __async(this,null,(function*(){const r=yield t;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(le("string"!=typeof e,"unconfigured name","UNCONFIGURED_NAME",{value:e}),ce(!1,"invalid AddressLike value; did not resolve to a value address","target",e)),Vt(r)}))}function qt(e,t){return"string"==typeof e?e.match(/^0x[0-9a-f]{40}$/i)?Vt(e):(le(null!=t,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Kt(e,t.resolveName(e))):Ht(e)?Kt(e,e.getAddress()):e&&"function"==typeof e.then?Kt(e,e):void ce(!1,"unsupported addressable value","target",e)}const Jt={};function Qt(e,t){let r=!1;return t<0&&(r=!0,t*=-1),new Zt(Jt,`${r?"":"u"}int${t}`,e,{signed:r,width:t})}function Xt(e,t){return new Zt(Jt,`bytes${t||""}`,e,{size:t})}const Yt=Symbol.for("_ethers_typed");P=new WeakMap;let Zt=class e{constructor(e,t,r,n){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,P,void 0),__publicField(this,"_typedSymbol"),null==n&&(n=null),he(Jt,e,"Typed"),ne(this,{_typedSymbol:Yt,type:t,value:r}),__privateSet(this,P,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((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,P)}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===__privateGet(this,P)?-1:!1===__privateGet(this,P)?this.value.length:null}static from(t,r){return new e(Jt,t,r)}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 Xt(e,1)}static bytes2(e){return Xt(e,2)}static bytes3(e){return Xt(e,3)}static bytes4(e){return Xt(e,4)}static bytes5(e){return Xt(e,5)}static bytes6(e){return Xt(e,6)}static bytes7(e){return Xt(e,7)}static bytes8(e){return Xt(e,8)}static bytes9(e){return Xt(e,9)}static bytes10(e){return Xt(e,10)}static bytes11(e){return Xt(e,11)}static bytes12(e){return Xt(e,12)}static bytes13(e){return Xt(e,13)}static bytes14(e){return Xt(e,14)}static bytes15(e){return Xt(e,15)}static bytes16(e){return Xt(e,16)}static bytes17(e){return Xt(e,17)}static bytes18(e){return Xt(e,18)}static bytes19(e){return Xt(e,19)}static bytes20(e){return Xt(e,20)}static bytes21(e){return Xt(e,21)}static bytes22(e){return Xt(e,22)}static bytes23(e){return Xt(e,23)}static bytes24(e){return Xt(e,24)}static bytes25(e){return Xt(e,25)}static bytes26(e){return Xt(e,26)}static bytes27(e){return Xt(e,27)}static bytes28(e){return Xt(e,28)}static bytes29(e){return Xt(e,29)}static bytes30(e){return Xt(e,30)}static bytes31(e){return Xt(e,31)}static bytes32(e){return Xt(e,32)}static address(t){return new e(Jt,"address",t)}static bool(t){return new e(Jt,"bool",!!t)}static bytes(t){return new e(Jt,"bytes",t)}static string(t){return new e(Jt,"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(Jt,"overrides",Object.assign({},t))}static isTyped(e){return e&&"object"==typeof e&&"_typedSymbol"in e&&e._typedSymbol===Yt}static dereference(t,r){if(e.isTyped(t)){if(t.type!==r)throw new Error(`invalid type: expecetd ${r}, got ${t.type}`);return t.value}return t}};class er extends ct{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=Zt.dereference(t,"string");try{r=Vt(r)}catch(n){return this._throwError(n.message,t)}return e.writeValue(r)}decode(e){return Vt(Pe(e.readValue(),20))}}class tr extends ct{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 rr(e,t,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let e={};n=t.map((t=>{const n=t.localName;return le(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:t},value:r}),le(!e[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:t},value:r}),e[n]=!0,r[n]}))}else ce(!1,"invalid tuple value","tuple",r);ce(t.length===n.length,"types/value length mismatch","tuple",r);let s=new ut,i=new ut,o=[];t.forEach(((e,t)=>{let r=n[t];if(e.dynamic){let t=i.length;e.encode(i,r);let n=s.writeUpdatableValue();o.push((e=>{n(e+t)}))}else e.encode(s,r)})),o.forEach((e=>{e(s.length)}));let a=e.appendWriter(s);return a+=e.appendWriter(i),a}function nr(e,t){let r=[],n=[],s=e.subReader(0);return t.forEach((t=>{let i=null;if(t.dynamic){let r=e.readIndex(),n=s.subReader(r);try{i=t.decode(n)}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");r.push(i),n.push(t.localName||null)})),at.fromItems(r,n)}class sr extends ct{constructor(e,t,r){super("array",e.type+"["+(t>=0?t:"")+"]",r,-1===t||e.dynamic),__publicField(this,"coder"),__publicField(this,"length"),ne(this,{coder:e,length:t})}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let r=0;r<this.length;r++)t.push(e);return t}encode(e,t){const r=Zt.dereference(t,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,e.writeValue(r.length)),ue(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let s=[];for(let i=0;i<r.length;i++)s.push(this.coder);return rr(e,s,r)}decode(e){let t=this.length;-1===t&&(t=e.readIndex(),le(t*Ye<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:t*Ye,length:e.dataLength}));let r=[];for(let n=0;n<t;n++)r.push(new tr(this.coder));return nr(e,r)}}class ir extends ct{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=Zt.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class or extends ct{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=me(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class ar extends or{constructor(e){super("bytes",e)}decode(e){return _e(super.decode(e))}}class lr extends ct{constructor(e,t){let r="bytes"+String(e);super(r,r,t,!1),__publicField(this,"size"),ne(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let r=me(Zt.dereference(t,this.type));return r.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(r)}decode(e){return _e(e.readBytes(this.size))}}const cr=new Uint8Array([]);class ur extends ct{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes(cr)}decode(e){return e.readBytes(0),null}}const dr=BigInt(0),hr=BigInt(1),pr=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class fr extends ct{constructor(e,t,r){const n=(t?"int":"uint")+8*e;super(n,n,r,!1),__publicField(this,"size"),__publicField(this,"signed"),ne(this,{size:e,signed:t},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,t){let r=Te(Zt.dereference(t,this.type)),n=Ae(pr,256);if(this.signed){let e=Ae(n,8*this.size-1);(r>e||r<-(e+hr))&&this._throwError("value out-of-bounds",t),r=function(e,t){let r=Te(e,"value");const n=BigInt(Ce(t,"width")),s=Ee<<n-Ee;if(r<xe)return r=-r,le(r<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e}),(~r&(Ee<<n)-Ee)+Ee;return le(r<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e}),r}(r,256)}else(r<dr||r>Ae(n,8*this.size))&&this._throwError("value out-of-bounds",t);return e.writeValue(r)}decode(e){let t=Ae(e.readValue(),8*this.size);return this.signed&&(t=ke(t,8*this.size)),t}}class mr extends or{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Ue(Zt.dereference(t,"string")))}decode(e){return Le(super.decode(e))}}class gr extends ct{constructor(e,t){let r=!1;const n=[];e.forEach((e=>{e.dynamic&&(r=!0),n.push(e.type)}));super("tuple","tuple("+n.join(",")+")",t,r),__publicField(this,"coders"),ne(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 r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});return this.coders.forEach(((r,n)=>{let s=r.localName;s&&1===t[s]&&("length"===s&&(s="_length"),null==e[s]&&(e[s]=e[n]))})),Object.freeze(e)}encode(e,t){const r=Zt.dereference(t,"tuple");return rr(e,this.coders,r)}decode(e){return nr(e,this.coders)}}function yr(e,t){return{address:Vt(e),storageKeys:t.map(((e,t)=>(ce(ge(e,32),"invalid slot",`storageKeys[${t}]`,e),e.toLowerCase())))}}function _r(e){return Gt(Ue(e))}function br(e){const t=new Set;return e.forEach((e=>t.add(e))),Object.freeze(t)}const wr=br("external public payable override".split(" ")),vr="constant external internal payable private public pure view override",xr=br(vr.split(" ")),Er="constructor error event fallback function receive struct",Nr=br(Er.split(" ")),kr="calldata memory storage payable indexed",Ar=br(kr.split(" ")),Tr=br([Er,kr,"tuple returns",vr].join(" ").split(" ")),Sr={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Rr=new RegExp("^(\\s*)"),Or=new RegExp("^([0-9]+)"),Cr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Pr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),Mr=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Fr=class e{constructor(e){__privateAdd(this,j),__privateAdd(this,M,void 0),__privateAdd(this,F,void 0),__privateSet(this,M,0),__privateSet(this,F,e.slice())}get offset(){return __privateGet(this,M)}get length(){return __privateGet(this,F).length-__privateGet(this,M)}clone(){return new e(__privateGet(this,F))}reset(){__privateSet(this,M,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,j,U).call(this,__privateGet(this,M)+1,e.match+1);return __privateSet(this,M,e.match+1),t}popParams(){const e=this.peek();if("OPEN_PAREN"!==e.type)throw new Error("bad start");const t=[];for(;__privateGet(this,M)<e.match-1;){const e=this.peek().linkNext;t.push(__privateMethod(this,j,U).call(this,__privateGet(this,M)+1,e)),__privateSet(this,M,e)}return __privateSet(this,M,e.match+1),t}peek(){if(__privateGet(this,M)>=__privateGet(this,F).length)throw new Error("out-of-bounds");return __privateGet(this,F)[__privateGet(this,M)]}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,M)._++,e}toString(){const e=[];for(let t=__privateGet(this,M);t<__privateGet(this,F).length;t++){const r=__privateGet(this,F)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};M=new WeakMap,F=new WeakMap,j=new WeakSet,U=function(e=0,t=0){return new Fr(__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 jr=Fr;function Ur(e){const t=[],r=t=>{const r=i<e.length?JSON.stringify(e[i]):"$EOI";throw new Error(`invalid token ${r} at ${i}: ${t}`)};let n=[],s=[],i=0;for(;i<e.length;){let o=e.substring(i),a=o.match(Rr);a&&(i+=a[1].length,o=e.substring(i));const l={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};t.push(l);let c=Sr[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,"OPEN_PAREN"===c)n.push(t.length-1),s.push(t.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("no matching open bracket"),l.match=n.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 r=t.pop().text;e=r+e,t[t.length-1].value=Ce(r)}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(Cr),a){if(l.text=a[1],i+=l.text.length,Tr.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(Mr)){l.type="TYPE";continue}l.type="ID"}else{if(a=o.match(Or),!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 jr(t.map((e=>Object.freeze(e))))}function Lr(e,t){let r=[];for(const n in t.keys())e.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Ir(e,t){if(t.peekKeyword(Nr)){const r=t.pop().text;if(r!==e)throw new Error(`expected ${e}, got ${r}`)}return t.popType("ID")}function Gr(e,t){const r=new Set;for(;;){const n=e.peekType("KEYWORD");if(null==n||t&&!t.has(n))break;if(e.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Dr(e){let t=Gr(e,xr);return Lr(t,br("constant payable nonpayable".split(" "))),Lr(t,br("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 Br(e,t){return e.popParams().map((e=>tn.from(e,t)))}function Wr(e){if(e.peekType("AT")){if(e.pop(),e.peekType("NUMBER"))return Te(e.pop().text);throw new Error("invalid gas")}return null}function $r(e){if(e.length)throw new Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`)}const zr=new RegExp(/^(.*)\[([0-9]*)\]$/);function Vr(e){const t=e.match(Mr);if(ce(t,"invalid type","type",e),"uint"===e)return"uint256";if("int"===e)return"int256";if(t[2]){const r=parseInt(t[2]);ce(0!==r&&r<=32,"invalid bytes length","type",e)}else if(t[3]){const r=parseInt(t[3]);ce(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",e)}return e}const Hr={},Kr=Symbol.for("_ethers_internal"),qr="_ParamTypeInternal",Jr="_ErrorInternal",Qr="_EventInternal",Xr="_ConstructorInternal",Yr="_FallbackInternal",Zr="_FunctionInternal",en="_StructInternal";L=new WeakSet,I=function(e,t,r,n){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,n)=>{var o;__privateMethod(o=s,L,I).call(o,e,t,r,(e=>{i[n]=e}))})),void n(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,n)=>{var o;__privateMethod(o=s[n],L,I).call(o,e,t,r,(e=>{i[n]=e}))})),void n(i)}const s=r(this.type,t);s.then?e.push(function(){return __async(this,null,(function*(){n(yield s)}))}()):n(s)};let tn=class e{constructor(e,t,r,n,s,i,o,a){if(__privateAdd(this,L),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),he(e,Hr,"ParamType"),Object.defineProperty(this,Kr,{value:qr}),i&&(i=Object.freeze(i.slice())),"array"===n){if(null==o||null==a)throw new Error("")}else if(null!=o||null!=a)throw new Error("");if("tuple"===n){if(null==i)throw new Error("")}else if(null!=i)throw new Error("");ne(this,{name:t,type:r,baseType:n,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 r={type:"tuple"===this.baseType?"tuple":this.type,name:t};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(r)}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 r=this;return e.map((e=>r.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 r=this;return e.map(((e,n)=>r.components[n].walk(e,t)))}return t(this.type,e)}walkAsync(e,t){return __async(this,null,(function*(){const r=[],n=[e];return __privateMethod(this,L,I).call(this,r,e,t,(e=>{n[0]=e})),r.length&&(yield Promise.all(r)),n[0]}))}static from(t,r){if(e.isParamType(t))return t;if("string"==typeof t)try{return e.from(Ur(t),r)}catch(a){ce(!1,"invalid param type","obj",t)}else if(t instanceof jr){let n="",s="",i=null;Gr(t,br(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(s="tuple",i=t.popParams().map((t=>e.from(t))),n=`tuple(${i.map((e=>e.format())).join(",")})`):(n=Vr(t.popType("TYPE")),s=n);let o=null,a=null;for(;t.length&&t.peekType("BRACKET");){const r=t.pop();o=new e(Hr,"",n,s,null,i,a,o),a=r.value,n+=r.text,s="array",i=null}let l=null;if(Gr(t,Ar).has("indexed")){if(!r)throw new Error("");l=!0}const c=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new e(Hr,c,n,s,l,i,a,o)}const n=t.name;ce(!n||"string"==typeof n&&n.match(Pr),"invalid name","obj.name",n);let s=t.indexed;null!=s&&(ce(r,"parameter cannot be indexed","obj.indexed",t.indexed),s=!!s);let i=t.type,o=i.match(zr);if(o){const r=parseInt(o[2]||"-1"),a=e.from({type:o[1],components:t.components});return new e(Hr,n||"",i,"array",s,null,r,a)}if("tuple"===i||i.startsWith("tuple(")||i.startsWith("(")){const r=null!=t.components?t.components.map((t=>e.from(t))):null;return new e(Hr,n||"",i,"tuple",s,r,null,null)}return i=Vr(t.type),new e(Hr,n||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Kr]===qr}};class rn{constructor(e,t,r){__publicField(this,"type"),__publicField(this,"inputs"),he(e,Hr,"Fragment"),ne(this,{type:t,inputs:r=Object.freeze(r.slice())})}static from(e){if("string"==typeof e){try{rn.from(JSON.parse(e))}catch(t){}return rn.from(Ur(e))}if(e instanceof jr){switch(e.peekKeyword(Nr)){case"constructor":return ln.from(e);case"error":return on.from(e);case"event":return an.from(e);case"fallback":case"receive":return cn.from(e);case"function":return un.from(e);case"struct":return dn.from(e)}}else if("object"==typeof e){switch(e.type){case"constructor":return ln.from(e);case"error":return on.from(e);case"event":return an.from(e);case"fallback":case"receive":return cn.from(e);case"function":return un.from(e);case"struct":return dn.from(e)}le(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}ce(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ln.isFragment(e)}static isError(e){return on.isFragment(e)}static isEvent(e){return an.isFragment(e)}static isFunction(e){return un.isFragment(e)}static isStruct(e){return dn.isFragment(e)}}class nn extends rn{constructor(e,t,r,n){super(e,t,n),__publicField(this,"name"),ce("string"==typeof r&&r.match(Pr),"invalid identifier","name",r),n=Object.freeze(n.slice()),ne(this,{name:r})}}function sn(e,t){return"("+t.map((t=>t.format(e))).join("full"===e?", ":",")+")"}class on extends nn{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Kr,{value:Jr})}get selector(){return _r(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+sn(e,this.inputs)),t.join(" ")}static from(e){if(on.isFragment(e))return e;if("string"==typeof e)return on.from(Ur(e));if(e instanceof jr){const t=Ir("error",e),r=Br(e);return $r(e),new on(Hr,t,r)}return new on(Hr,e.name,e.inputs?e.inputs.map(tn.from):[])}static isFragment(e){return e&&e[Kr]===Jr}}class an extends nn{constructor(e,t,r,n){super(e,"event",t,r),__publicField(this,"anonymous"),Object.defineProperty(this,Kr,{value:Qr}),ne(this,{anonymous:n})}get topicHash(){return _r(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+sn(e,this.inputs)),"sighash"!==e&&this.anonymous&&t.push("anonymous"),t.join(" ")}static getTopicHash(e,t){t=(t||[]).map((e=>tn.from(e)));return new an(Hr,e,t,!1).topicHash}static from(e){if(an.isFragment(e))return e;if("string"==typeof e)try{return an.from(Ur(e))}catch(t){ce(!1,"invalid event fragment","obj",e)}else if(e instanceof jr){const t=Ir("event",e),r=Br(e,!0),n=!!Gr(e,br(["anonymous"])).has("anonymous");return $r(e),new an(Hr,t,r,n)}return new an(Hr,e.name,e.inputs?e.inputs.map((e=>tn.from(e,!0))):[],!!e.anonymous)}static isFragment(e){return e&&e[Kr]===Qr}}class ln extends rn{constructor(e,t,r,n,s){super(e,t,r),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Kr,{value:Xr}),ne(this,{payable:n,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${sn(e,this.inputs)}`];return this.payable&&t.push("payable"),null!=this.gas&&t.push(`@${this.gas.toString()}`),t.join(" ")}static from(e){if(ln.isFragment(e))return e;if("string"==typeof e)try{return ln.from(Ur(e))}catch(t){ce(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof jr){Gr(e,br(["constructor"]));const t=Br(e),r=!!Gr(e,wr).has("payable"),n=Wr(e);return $r(e),new ln(Hr,"constructor",t,r,n)}return new ln(Hr,"constructor",e.inputs?e.inputs.map(tn.from):[],!!e.payable,null!=e.gas?e.gas:null)}static isFragment(e){return e&&e[Kr]===Xr}}class cn extends rn{constructor(e,t,r){super(e,"fallback",t),__publicField(this,"payable"),Object.defineProperty(this,Kr,{value:Yr}),ne(this,{payable:r})}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(cn.isFragment(e))return e;if("string"==typeof e)try{return cn.from(Ur(e))}catch(t){ce(!1,"invalid fallback fragment","obj",e)}else if(e instanceof jr){const t=e.toString();ce(e.peekKeyword(br(["fallback","receive"])),"type must be fallback or receive","obj",t);if("receive"===e.popKeyword(br(["fallback","receive"]))){const t=Br(e);return ce(0===t.length,"receive cannot have arguments","obj.inputs",t),Gr(e,br(["payable"])),$r(e),new cn(Hr,[],!0)}let r=Br(e);r.length?ce(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((e=>e.format("minimal"))).join(", ")):r=[tn.from("bytes")];const n=Dr(e);if(ce("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Gr(e,br(["returns"])).has("returns")){const t=Br(e);ce(1===t.length&&"bytes"===t[0].type,"invalid fallback outputs","obj.outputs",t.map((e=>e.format("minimal"))).join(", "))}return $r(e),new cn(Hr,r,"payable"===n)}if("receive"===e.type)return new cn(Hr,[],!0);if("fallback"===e.type){const t=[tn.from("bytes")],r="payable"===e.stateMutability;return new cn(Hr,t,r)}ce(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Kr]===Yr}}class un extends nn{constructor(e,t,r,n,s,i){super(e,"function",t,n),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Kr,{value:Zr});ne(this,{constant:"view"===r||"pure"===r,gas:i,outputs:s=Object.freeze(s.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return _r(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+sn(e,this.inputs)),"sighash"!==e&&("nonpayable"!==this.stateMutability&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push("returns"),t.push(sn(e,this.outputs))),null!=this.gas&&t.push(`@${this.gas.toString()}`)),t.join(" ")}static getSelector(e,t){t=(t||[]).map((e=>tn.from(e)));return new un(Hr,e,"view",t,[],null).selector}static from(e){if(un.isFragment(e))return e;if("string"==typeof e)try{return un.from(Ur(e))}catch(r){ce(!1,"invalid function fragment","obj",e)}else if(e instanceof jr){const t=Ir("function",e),r=Br(e),n=Dr(e);let s=[];Gr(e,br(["returns"])).has("returns")&&(s=Br(e));const i=Wr(e);return $r(e),new un(Hr,t,n,r,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 un(Hr,e.name,t,e.inputs?e.inputs.map(tn.from):[],e.outputs?e.outputs.map(tn.from):[],null!=e.gas?e.gas:null)}static isFragment(e){return e&&e[Kr]===Zr}}class dn extends nn{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Kr,{value:en})}format(){throw new Error("@TODO")}static from(e){if("string"==typeof e)try{return dn.from(Ur(e))}catch(t){ce(!1,"invalid struct fragment","obj",e)}else if(e instanceof jr){const t=Ir("struct",e),r=Br(e);return $r(e),new dn(Hr,t,r)}return new dn(Hr,e.name,e.inputs?e.inputs.map(tn.from):[])}static isFragment(e){return e&&e[Kr]===en}}const hn=new Map;hn.set(0,"GENERIC_PANIC"),hn.set(1,"ASSERT_FALSE"),hn.set(17,"OVERFLOW"),hn.set(18,"DIVIDE_BY_ZERO"),hn.set(33,"ENUM_RANGE_ERROR"),hn.set(34,"BAD_STORAGE_DATA"),hn.set(49,"STACK_UNDERFLOW"),hn.set(50,"ARRAY_RANGE_ERROR"),hn.set(65,"OUT_OF_MEMORY"),hn.set(81,"UNINITIALIZED_FUNCTION_CALL");const pn=new RegExp(/^bytes([0-9]*)$/),fn=new RegExp(/^(u?int)([0-9]*)$/);let mn=null,gn=1024;G=new WeakSet,D=function(e){if(e.isArray())return new sr(__privateMethod(this,G,D).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new gr(e.components.map((e=>__privateMethod(this,G,D).call(this,e))),e.name);switch(e.baseType){case"address":return new er(e.name);case"bool":return new ir(e.name);case"string":return new mr(e.name);case"bytes":return new ar(e.name);case"":return new ur(e.name)}let t=e.type.match(fn);if(t){let r=parseInt(t[2]||"256");return ce(0!==r&&r<=256&&r%8==0,"invalid "+t[1]+" bit length","param",e),new fr(r/8,"int"===t[1],e.name)}if(t=e.type.match(pn),t){let r=parseInt(t[1]);return ce(0!==r&&r<=32,"invalid bytes length","param",e),new lr(r,e.name)}ce(!1,"invalid type","type",e.type)};let yn=class e{constructor(){__privateAdd(this,G)}getDefaultValue(e){const t=e.map((e=>__privateMethod(this,G,D).call(this,tn.from(e))));return new gr(t,"_").defaultValue()}encode(e,t){ue(t.length,e.length,"types/values length mismatch");const r=e.map((e=>__privateMethod(this,G,D).call(this,tn.from(e)))),n=new gr(r,"_"),s=new ut;return n.encode(s,t),s.data}decode(e,t,r){const n=e.map((e=>__privateMethod(this,G,D).call(this,tn.from(e))));return new gr(n,"_").decode(new dt(t,r,gn))}static _setDefaultMaxInflation(e){ce("number"==typeof e&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),gn=e}static defaultAbiCoder(){return null==mn&&(mn=new e),mn}static getBuiltinCallException(t,r,n){return function(e,t,r,n){let s="missing revert data",i=null,o=null;if(r){s="execution reverted";const e=fe(r);if(r=_e(r),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=n.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(n.decode(["uint256"],e.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[t]},i=`Panic due to ${hn.get(t)||"UNKNOWN"}(${t})`,s+=`: ${i}`}catch(l){s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const a={to:t.to?Vt(t.to):null,data:t.data||"0x"};return t.from&&(a.from=Vt(t.from)),ae(s,"CALL_EXCEPTION",{action:e,data:r,reason:i,transaction:a,invocation:null,revert:o})}(t,r,n,e.defaultAbiCoder())}};class _n{constructor(e,t,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const n=e.name,s=e.format();ne(this,{fragment:e,name:n,signature:s,topic:t,args:r})}}class bn{constructor(e,t,r,n){__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();ne(this,{fragment:e,name:s,args:r,signature:i,selector:t,value:n})}}class wn{constructor(e,t,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const n=e.name,s=e.format();ne(this,{fragment:e,name:n,args:r,signature:s,selector:t})}}class vn{constructor(e){__publicField(this,"hash"),__publicField(this,"_isIndexed"),ne(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!(!e||!e._isIndexed)}}const xn={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"},En={"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&&xn[e.toString()]&&(t=xn[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,r){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 n=[];for(const[t,r]of __privateGet(this,$))t.split("(")[0]===e&&n.push(r);if(t){const e=t.length>0?t[t.length-1]:null;let r=t.length,s=!0;Zt.isTyped(e)&&"overrides"===e.type&&(s=!1,r--);for(let t=n.length-1;t>=0;t--){const e=n[t].inputs.length;e===r||s&&e===r-1||n.splice(t,1)}for(let i=n.length-1;i>=0;i--){const e=n[i].inputs;for(let r=0;r<t.length;r++)if(Zt.isTyped(t[r])){if(r>=e.length){if("overrides"===t[r].type)continue;n.splice(i,1);break}if(t[r].type!==e[r].baseType){n.splice(i,1);break}}}}if(1===n.length&&t&&t.length!==n[0].inputs.length){const e=t[t.length-1];(null==e||Array.isArray(e)||"object"!=typeof e)&&n.splice(0,1)}if(0===n.length)return null;if(n.length>1&&r){ce(!1,`ambiguous function description (i.e. matches ${n.map((e=>JSON.stringify(e.format()))).join(", ")})`,"key",e)}return n[0]}const n=__privateGet(this,$).get(un.from(e).format());return n||null},K=new WeakSet,q=function(e,t,r){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 n=[];for(const[t,r]of __privateGet(this,W))t.split("(")[0]===e&&n.push(r);if(t){for(let e=n.length-1;e>=0;e--)n[e].inputs.length<t.length&&n.splice(e,1);for(let e=n.length-1;e>=0;e--){const r=n[e].inputs;for(let s=0;s<t.length;s++)if(Zt.isTyped(t[s])&&t[s].type!==r[s].baseType){n.splice(e,1);break}}}if(0===n.length)return null;if(n.length>1&&r){ce(!1,`ambiguous event description (i.e. matches ${n.map((e=>JSON.stringify(e.format()))).join(", ")})`,"key",e)}return n[0]}const n=__privateGet(this,W).get(an.from(e).format());return n||null};let Nn=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 r=[];for(const o of t)try{r.push(rn.from(o))}catch(i){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,i.message)}ne(this,{fragments:Object.freeze(r)});let n=null,s=!1;__privateSet(this,z,this.getAbiCoder()),this.fragments.forEach(((e,t)=>{let r;switch(e.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void ne(this,{deploy:e});case"fallback":return void(0===e.inputs.length?s=!0:(ce(!n||e.payable!==n.payable,"conflicting fallback fragments",`fragments[${t}]`,e),n=e,s=n.payable));case"function":r=__privateGet(this,$);break;case"event":r=__privateGet(this,W);break;case"error":r=__privateGet(this,B);break;default:return}const i=e.format();r.has(i)||r.set(i,e)})),this.deploy||ne(this,{deploy:ln.from("constructor()")}),ne(this,{fallback:n,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 yn.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 r=0;r<t.length;r++){const n=t[r];e(__privateGet(this,$).get(n),r)}}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 r=0;r<t.length;r++){const n=t[r];e(__privateGet(this,W).get(n),r)}}getError(e,t){if(ge(e)){const t=e.toLowerCase();if(En[t])return on.from(En[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[r,n]of __privateGet(this,B))r.split("(")[0]===e&&t.push(n);if(0===t.length)return"Error"===e?on.from("error Error(string)"):"Panic"===e?on.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=on.from(e).format()))return on.from("error Error(string)");if("Panic(uint256)"===e)return on.from("error Panic(uint256)");const r=__privateGet(this,B).get(e);return r||null}forEachError(e){const t=Array.from(__privateGet(this,B).keys());t.sort(((e,t)=>e.localeCompare(t)));for(let r=0;r<t.length;r++){const n=t[r];e(__privateGet(this,B).get(n),r)}}_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 r="invalid length for result data";const n=me(t);if(n.length%32==0)try{return __privateGet(this,z).decode(e.outputs,n)}catch(s){r="could not decode result data"}le(!1,r,"BAD_DATA",{value:_e(n),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=fe(e,"data"),n=yn.getBuiltinCallException("call",t,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const e=_e(r.slice(0,4)),t=this.getError(e);if(t)try{const e=__privateGet(this,z).decode(t.inputs,r.slice(4));n.revert={name:t.name,signature:t.format(),args:e},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(i){n.message="execution reverted (coult not decode custom error)"}}const s=this.parseTransaction(t);return s&&(n.invocation={method:s.name,signature:s.signature,args:s.args}),n}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 r=[];e.anonymous||r.push(e.topicHash);const n=(e,t)=>"string"===e.type?_r(t):"bytes"===e.type?Gt(_e(t)):("bool"===e.type&&"boolean"==typeof t?t=t?"0x01":"0x00":e.type.match(/^u?int/)?t=Pe(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?r.push(null):"array"===i.baseType||"tuple"===i.baseType?ce(!1,"filtering with tuples or arrays not supported","contract."+i.name,t):Array.isArray(t)?r.push(t.map((e=>n(i,e)))):r.push(n(i,t)):ce(null==t,"cannot filter non-indexed parameters; must be null","contract."+i.name,t)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(e,t){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}const r=[],n=[],s=[];return e.anonymous||r.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)r.push(_r(o));else if("bytes"===e.type)r.push(Gt(o));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");r.push(__privateGet(this,z).encode([e.type],[o]))}else n.push(e),s.push(o)})),{data:__privateGet(this,z).encode(n,s),topics:r}}decodeEventLog(e,t,r){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}if(null!=r&&!e.anonymous){const t=e.topicHash;ce(ge(r[0],32)&&r[0].toLowerCase()===t,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],s=[],i=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(tn.from({type:"bytes32",name:e.name})),i.push(!0)):(n.push(e),i.push(!1)):(s.push(e),i.push(!1))}));const o=null!=r?__privateGet(this,z).decode(n,be(r)):null,a=__privateGet(this,z).decode(s,t,!0),l=[],c=[];let u=0,d=0;return e.inputs.forEach(((e,t)=>{let r=null;if(e.indexed)if(null==o)r=new vn(null);else if(i[t])r=new vn(o[d++]);else try{r=o[d++]}catch(n){r=n}else try{r=a[u++]}catch(n){r=n}l.push(r),c.push(e.name||null)})),at.fromItems(l,c)}parseTransaction(e){const t=fe(e.data,"tx.data"),r=Te(null!=e.value?e.value:0,"tx.value"),n=this.getFunction(_e(t.slice(0,4)));if(!n)return null;const s=__privateGet(this,z).decode(n.inputs,t.slice(4));return new bn(n,n.selector,s,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new _n(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=_e(e),r=this.getError(we(t,0,4));if(!r)return null;const n=__privateGet(this,z).decode(r.inputs,we(t,4));return new wn(r,r.selector,n)}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 kn=BigInt(0);function An(e){return null==e?null:e.toString()}function Tn(e){const t={};e.to&&(t.to=e.to),e.from&&(t.from=e.from),e.data&&(t.data=_e(e.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of r)s in e&&null!=e[s]&&(t[s]=Te(e[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)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,r)=>Array.isArray(t)?(ce(2===t.length,"invalid slot set",`value[${r}]`,t),yr(t[0],t[1])):(ce(null!=t&&"object"==typeof t,"invalid address-slot set","value",e),yr(t.address,t.storageKeys))));ce(null!=e&&"object"==typeof e,"invalid access list","value",e);const t=Object.keys(e).map((t=>{const r=e[t].reduce(((e,t)=>(e[t]=!0,e)),{});return yr(t,Object.keys(r).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 Sn{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 r=Object.freeze(e.topics.slice());ne(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:n,index:s,removed:i,topics:o,transactionHash:a,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:n,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 Rn{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 Sn(e,t)))));let r=kn;null!=e.effectiveGasPrice?r=e.effectiveGasPrice:null!=e.gasPrice&&(r=e.gasPrice),ne(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:r,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:r,hash:n,index:s,blockHash:i,blockNumber:o,logsBloom:a,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:i,blockNumber:o,contractAddress:r,cumulativeGasUsed:An(this.cumulativeGasUsed),from:t,gasPrice:An(this.gasPrice),blobGasUsed:An(this.blobGasUsed),blobGasPrice:An(this.blobGasPrice),gasUsed:An(this.gasUsed),hash:n,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 Pn(this)}reorderedEvent(e){return le(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Cn(this,e)}}J=new WeakMap;Q=new WeakMap;let On=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:r,hash:n,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:An(this.chainId),data:l,from:o,gasLimit:An(this.gasLimit),gasPrice:An(this.gasPrice),hash:n,maxFeePerGas:An(this.maxFeePerGas),maxPriorityFeePerGas:An(this.maxPriorityFeePerGas),maxFeePerBlobGas:An(this.maxFeePerBlobGas),nonce:a,signature:c,to:i,index:r,type:s,value:An(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 re({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 r=null==e?1:e,n=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 re({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(t<this.nonce)return void(s=e);if(o)return null;const n=yield this.getTransaction();if(!n||null==n.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 n=0;n<t.length;n++){const i=yield t.getTransaction(n);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<r)return;let n="replaced";i.data===this.data&&i.to===this.to&&i.value===this.value?n="repriced":"0x"===i.data&&i.from===i.to&&i.value===kn&&(n="cancelled"),le(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,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===r)return l(c);if(c){if(1===r||(yield c.confirmations())>=r)return l(c)}else if(yield a(),0===r)return null;const u=new Promise(((e,t)=>{const i=[],c=()=>{i.forEach((e=>e()))};if(i.push((()=>{o=!0})),n>0){const e=setTimeout((()=>{c(),t(ae("wait for transaction timeout","TIMEOUT"))}),n);i.push((()=>{clearTimeout(e)}))}const u=n=>__async(this,null,(function*(){if((yield n.confirmations())>=r){c();try{e(l(n))}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(r){if(ie(r,"TRANSACTION_REPLACED"))return c(),void t(r)}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()"}),Pn(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()"}),Cn(this,e)}replaceableTransaction(t){ce(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const r=new e(this,this.provider);return __privateSet(r,Q,t),r}};function Cn(e,t){return{orphan:"reorder-transaction",tx:e,other:t}}function Pn(e){return{orphan:"drop-transaction",tx:e}}class Mn extends Sn{constructor(e,t,r){super(e,e.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");ne(this,{args:t.decodeEventLog(r,e.data,e.topics),fragment:r,interface:t})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Fn extends Sn{constructor(e,t){super(e,e.provider),__publicField(this,"error"),ne(this,{error:t})}}class jn extends Rn{constructor(e,t,r){super(r,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 Mn(e,__privateGet(this,X),t)}catch(r){return new Fn(e,r)}return e}))}}X=new WeakMap;Y=new WeakMap;let Un=class e extends On{constructor(e,t,r){super(r,t),__privateAdd(this,Y,void 0),__privateSet(this,Y,e)}wait(t,r){return __async(this,null,(function*(){const n=yield __superGet(e.prototype,this,"wait").call(this,t,r);return null==n?null:new jn(__privateGet(this,Y),this.provider,n)}))}};class Ln extends Me{constructor(e,t,r,n){super(e,t,r),__publicField(this,"log"),ne(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 In extends Ln{constructor(e,t,r,n,s){super(e,t,r,new Mn(s,e.interface,n));ne(this,{args:e.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Gn=BigInt(0);function Dn(e){return e&&"function"==typeof e.call}function Bn(e){return e&&"function"==typeof e.estimateGas}function Wn(e){return e&&"function"==typeof e.resolveName}function $n(e){return e&&"function"==typeof e.sendTransaction}function zn(e){if(null!=e){if(Wn(e))return e;if(e.provider)return e.provider}}class Vn{constructor(e,t,r){if(__privateAdd(this,Z,void 0),__publicField(this,"fragment"),ne(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const n=Hn(e.runner,"resolveName"),s=Wn(n)?n:null;__privateSet(this,Z,function(){return __async(this,null,(function*(){const n=yield Promise.all(t.inputs.map(((e,t)=>null==r[t]?null:e.walkAsync(r[t],((e,t)=>"address"===e?Array.isArray(t)?Promise.all(t.map((e=>qt(e,s)))):qt(t,s):t)))));return e.interface.encodeFilterTopics(t,n)}))}())}getTopicFilter(){return __privateGet(this,Z)}}function Hn(e,t){return null==e?null:"function"==typeof e[t]?e:e.provider&&"function"==typeof e.provider[t]?e.provider:null}function Kn(e){return null==e?null:e.provider||null}function qn(e,t){return __async(this,null,(function*(){const r=Zt.dereference(e,"overrides");ce("object"==typeof r,"invalid overrides parameter","overrides",e);const n=Tn(r);return ce(null==n.to||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),ce(null==n.data||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}))}function Jn(e){const t=function(t){return __async(this,null,(function*(){const r=yield qn(t,["data"]);r.to=yield e.getAddress(),r.from&&(r.from=yield qt(r.from,zn(e.runner)));const n=e.interface,s=Te(r.value||Gn,"overrides.value")===Gn,i="0x"===(r.data||"0x");!n.fallback||n.fallback.payable||!n.receive||i||s||ce(!1,"cannot send data to receive or send value to non-payable fallback","overrides",t),ce(n.fallback||i,"cannot send data to receive-only contract","overrides.data",r.data);return ce(n.receive||n.fallback&&n.fallback.payable||s,"cannot send value to non-payable fallback","overrides.value",r.value),ce(n.fallback||i,"cannot send data to receive-only contract","overrides.data",r.data),r}))},r=function(r){return __async(this,null,(function*(){const n=e.runner;le($n(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=yield n.sendTransaction(yield t(r)),i=Kn(e.runner);return new Un(e.interface,i,s)}))},n=e=>__async(this,null,(function*(){return yield r(e)}));return ne(n,{_contract:e,estimateGas:function(r){return __async(this,null,(function*(){const n=Hn(e.runner,"estimateGas");return le(Bn(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield t(r))}))},populateTransaction:t,send:r,staticCall:function(r){return __async(this,null,(function*(){const n=Hn(e.runner,"call");le(Dn(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield t(r);try{return yield n.call(s)}catch(i){if(oe(i)&&i.data)throw e.interface.makeError(i.data,s);throw i}}))}}),n}function Qn(e,t){const r=function(...r){const n=e.interface.getFunction(t,r);return le(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:r}}),n},n=function(...t){return __async(this,null,(function*(){const n=r(...t);let s={};if(n.inputs.length+1===t.length&&(s=yield qn(t.pop()),s.from&&(s.from=yield qt(s.from,zn(e.runner)))),n.inputs.length!==t.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const i=yield function(e,t,r){return __async(this,null,(function*(){const n=Hn(e,"resolveName"),s=Wn(n)?n:null;return yield Promise.all(t.map(((e,t)=>e.walkAsync(r[t],((e,t)=>(t=Zt.dereference(t,e),"address"===e?qt(t,s):t))))))}))}(e.runner,n.inputs,t);return Object.assign({},s,yield re({to:e.getAddress(),data:e.interface.encodeFunctionData(n,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 r=e.runner;le($n(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=yield r.sendTransaction(yield n(...t)),i=Kn(e.runner);return new Un(e.interface,i,s)}))},o=function(...t){return __async(this,null,(function*(){const s=Hn(e.runner,"call");le(Dn(s),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield n(...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=r(...t);return e.interface.decodeFunctionResult(a,o)}))},a=(...e)=>__async(this,null,(function*(){return r(...e).constant?yield s(...e):yield i(...e)}));return ne(a,{name:e.interface.getFunctionName(t),_contract:e,_key:t,getFragment:r,estimateGas:function(...t){return __async(this,null,(function*(){const r=Hn(e.runner,"estimateGas");return le(Bn(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield n(...t))}))},populateTransaction:n,send:i,staticCall:s,staticCallResult:o}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=e.interface.getFunction(t);return le(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),r}}),a}Z=new WeakMap;const Xn=Symbol.for("_ethersInternal_contract"),Yn=new WeakMap;function Zn(e){return Yn.get(e[Xn])}function es(e,t){return __async(this,null,(function*(){let r,n=null;if(Array.isArray(t)){const n=function(t){if(ge(t,32))return t;const r=e.interface.getEvent(t);return ce(r,"unknown fragment","name",t),r.topicHash};r=t.map((e=>null==e?null:Array.isArray(e)?e.map(n):n(e)))}else"*"===t?r=[null]:"string"==typeof t?ge(t,32)?r=[t]:(n=e.interface.getEvent(t),ce(n,"unknown fragment","event",t),r=[n.topicHash]):(s=t)&&"object"==typeof s&&"getTopicFilter"in s&&"function"==typeof s.getTopicFilter&&s.fragment?r=yield t.getTopicFilter():"fragment"in t?(n=t.fragment,r=[n.topicHash]):ce(!1,"unknown event name","event",t);var s;r=r.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:n,tag:r.map((e=>null==e?"null":Array.isArray(e)?e.join("|"):e)).join("&"),topics:r}}))}function ts(e,t){return __async(this,null,(function*(){const{subs:r}=Zn(e);return r.get((yield es(e,t)).tag)||null}))}function rs(e,t,r){return __async(this,null,(function*(){const n=Kn(e.runner);le(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:s,tag:i,topics:o}=yield es(e,r),{addr:a,subs:l}=Zn(e);let c=l.get(i);if(!c){const t={address:a||e,topics:o},u=t=>{let n=s;if(null==n)try{n=e.interface.getEvent(t.topics[0])}catch(i){}if(n){const i=n,o=s?e.interface.decodeEventLog(s,t.data,t.topics):[];ss(e,r,o,(n=>new In(e,n,r,i,t)))}else ss(e,r,[],(n=>new Ln(e,n,r,t)))};let d=[];c={tag:i,listeners:[],start:()=>{d.length||d.push(n.on(t,u))},stop:()=>__async(this,null,(function*(){if(0==d.length)return;let e=d;d=[],yield Promise.all(e),n.off(t,u)}))},l.set(i,c)}return c}))}let ns=Promise.resolve();function ss(e,t,r,n){return __async(this,null,(function*(){try{yield ns}catch(i){}const s=function(e,t,r,n){return __async(this,null,(function*(){yield ns;const s=yield ts(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(r);n&&o.push(n(s?null:t));try{t.call(e,...o)}catch(i){}return!s})),0===s.listeners.length&&(s.stop(),Zn(e).subs.delete(s.tag)),o>0}))}(e,t,r,n);return ns=s,yield s}))}const is=["then"];ee=Xn;let os=class e{constructor(e,t,r,n){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),ce("string"==typeof e||Ht(e),"invalid value for Contract target","target",e),null==r&&(r=null);const s=Nn.from(t);let i;ne(this,{target:e,runner:r,interface:s}),Object.defineProperty(this,Xn,{value:{}});let o=null,a=null;if(n){const e=Kn(r);a=new Un(this.interface,e,n)}let l=new Map;if("string"==typeof e)if(ge(e))o=e,i=Promise.resolve(e);else{const t=Hn(r,"resolveName");if(!Wn(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 Zn(this).addr=t,t}))}else i=e.getAddress().then((e=>{if(null==e)throw new Error("TODO");return Zn(this).addr=e,e}));var c,u;c=this,u={addrPromise:i,addr:o,deployTx:a,subs:l},Yn.set(c[Xn],u);return ne(this,{filters:new Proxy({},{get:(e,t,r)=>{if("symbol"==typeof t||is.indexOf(t)>=0)return Reflect.get(e,t,r);try{return this.getEvent(t)}catch(n){if(!ie(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(e,t)=>is.indexOf(t)>=0?Reflect.has(e,t):Reflect.has(e,t)||this.interface.hasEvent(String(t))})}),ne(this,{fallback:s.receive||s.fallback?Jn(this):null}),new Proxy(this,{get:(e,t,r)=>{if("symbol"==typeof t||t in e||is.indexOf(t)>=0)return Reflect.get(e,t,r);try{return e.getFunction(t)}catch(n){if(!ie(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(e,t)=>"symbol"==typeof t||t in e||is.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 Zn(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const e=Kn(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=Kn(this.runner);return le(null!=t,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((e,r)=>{const n=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return e(this);t.once("block",n)}catch(s){r(s)}}));n()}))}))}deploymentTransaction(){return Zn(this).deployTx}getFunction(e){"string"!=typeof e&&(e=e.format());return Qn(this,e)}getEvent(e){return"string"!=typeof e&&(e=e.format()),function(e,t){const r=function(...r){const n=e.interface.getEvent(t,r);return le(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:r}}),n},n=function(...t){return new Vn(e,r(...t),t)};return ne(n,{name:e.interface.getEventName(t),_contract:e,_key:t,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=e.interface.getEvent(t);return le(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),r}}),n}(this,e)}queryTransaction(e){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(e,t,r){return __async(this,null,(function*(){null==t&&(t=0),null==r&&(r="latest");const{addr:n,addrPromise:s}=Zn(this),i=n||(yield s),{fragment:o,topics:a}=yield es(this,e),l={address:i,topics:a,fromBlock:t,toBlock:r},c=Kn(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(r){}if(t)try{return new Mn(e,this.interface,t)}catch(r){return new Fn(e,r)}return new Sn(e,c)}))}))}on(e,t){return __async(this,null,(function*(){const r=yield rs(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}))}once(e,t){return __async(this,null,(function*(){const r=yield rs(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}))}emit(e,...t){return __async(this,null,(function*(){return yield ss(this,e,t,null)}))}listenerCount(e){return __async(this,null,(function*(){if(e){const t=yield ts(this,e);return t?t.listeners.length:0}const{subs:t}=Zn(this);let r=0;for(const{listeners:e}of t.values())r+=e.length;return r}))}listeners(e){return __async(this,null,(function*(){if(e){const t=yield ts(this,e);return t?t.listeners.map((({listener:e})=>e)):[]}const{subs:t}=Zn(this);let r=[];for(const{listeners:e}of t.values())r=r.concat(e.map((({listener:e})=>e)));return r}))}off(e,t){return __async(this,null,(function*(){const r=yield ts(this,e);if(!r)return this;if(t){const e=r.listeners.map((({listener:e})=>e)).indexOf(t);e>=0&&r.listeners.splice(e,1)}return null!=t&&0!==r.listeners.length||(r.stop(),Zn(this).subs.delete(r.tag)),this}))}removeAllListeners(e){return __async(this,null,(function*(){if(e){const t=yield ts(this,e);if(!t)return this;t.stop(),Zn(this).subs.delete(t.tag)}else{const{subs:e}=Zn(this);for(const{tag:t,stop:r}of e.values())r(),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,r=null){super(e,t,r)}}}static from(e,t,r){null==r&&(r=null);return new this(e,t,r)}};class as extends(function(){return os}()){}const ls={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trustwallet",LUTE:"lute"},cs={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},us={[cs.ETHEREUM]:{name:"Ethereum Mainnet",chainId:1,symbol:"ETH",decimals:18,rpcUrl:"https://mainnet.infura.io/v3/your-infura-key",blockExplorerUrl:"https://etherscan.io"},[cs.BSC]:{name:"Binance Smart Chain",chainId:56,symbol:"BNB",decimals:18,rpcUrl:"https://bsc-dataseed.binance.org/",blockExplorerUrl:"https://bscscan.com"},[cs.TRON]:{name:"TRON Mainnet",symbol:"TRX",decimals:6,rpcUrl:"https://api.trongrid.io",blockExplorerUrl:"https://tronscan.org"},[cs.ALGORAND]:{name:"Algorand Mainnet",symbol:"ALGO",decimals:6,rpcUrl:"https://mainnet-api.algonode.cloud",blockExplorerUrl:"https://algoexplorer.io"}},ds={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}},DAI:{ethereum:{contractAddress:"0x6B175474E89094C44Da98b954EedeAC495271d0F",decimals:18,symbol:"DAI"}},FRAX:{ethereum:{contractAddress:"0x853d955aCEf822Db058eb8505911ED77F175b99e",decimals:18,symbol:"FRAX"},bsc:{contractAddress:"0x90C97F71E18723b0Cf0dfa30ee176Ab653E89F40",decimals:18,symbol:"FRAX"}},PYUSD:{ethereum:{contractAddress:"0x6c3ea9036406852006290770BEdFcAbA0e23A0e8",decimals:6,symbol:"PYUSD"}},BUSD:{bsc:{contractAddress:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",decimals:18,symbol:"BUSD"}},USDJ:{tron:{contractAddress:"TMwFHYXLJaRUPeW6421aqXL4ZEzPRFGkGT",decimals:18,symbol:"USDJ"}}},hs={[cs.ETHEREUM]:[ls.METAMASK,ls.TRUST_WALLET],[cs.BSC]:[ls.METAMASK,ls.TRUST_WALLET],[cs.TRON]:[ls.TRONLINK],[cs.ALGORAND]:[ls.LUTE]},ps=e=>({[ls.METAMASK]:"https://metamask.io/download/",[ls.TRONLINK]:"https://www.tronlink.org/download/",[ls.TRUST_WALLET]:"https://trustwallet.com/download/",[ls.LUTE]:"https://lute.app/download/"}[e]||""),fs=()=>({[ls.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isMetaMask,[ls.TRONLINK]:"undefined"!=typeof window&&void 0!==window.tronWeb,[ls.TRUST_WALLET]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isTrust,[ls.LUTE]:"undefined"!=typeof window&&void 0!==window.lute}),ms=(e=3,t=500)=>__async(this,null,(function*(){let r=0,n=fs();const s=Object.values(n).some((e=>!0===e));for(;!s&&r<e;)console.log(`No wallets detected, retrying (${r+1}/${e})...`),yield new Promise((e=>setTimeout(e,t))),n=fs(),r++;return n})),gs=()=>{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=fs();console.log("Detected wallets:",t)},ys=()=>__async(this,null,(function*(){if(console.log("Connecting to MetaMask wallet..."),!window.ethereum||!window.ethereum.isMetaMask)throw 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. Please unlock MetaMask.");const t=e[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let s;switch(n){case 1:s=cs.ETHEREUM;break;case 56:s=cs.BSC;break;default:s=`unknown-${n}`}const i={request:e=>window.ethereum.request(e),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?"string"==typeof e.value?e.value:e.value.toString():"0x0",gasLimit:e.gasLimit?"string"==typeof e.gasLimit?e.gasLimit:e.gasLimit.toString():void 0,data:e.data||"0x"}]})}}))}),estimateGas:e=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:t,to:e.to,value:e.value?"string"==typeof e.value?e.value:e.value.toString():"0x0",data:e.data||"0x"}]}),n=parseInt(r,16);return{toString:()=>n.toString(),mul:e=>({div:t=>({toString:()=>Math.floor(n*e/t).toString()})})}}))};return console.log("MetaMask connected successfully:",{address:t,chainId:n,networkType:s}),{walletType:ls.METAMASK,address:t,provider:i,network:s,isConnected:!0,chainId:n}}catch(e){throw console.error("MetaMask connection error:",e),e}})),_s=()=>__async(this,null,(function*(){if(console.log("Connecting to TronLink wallet..."),!window.tronWeb)throw new Error("TronLink not detected. Please install TronLink extension.");const e=(e=10,t=500)=>__async(this,null,(function*(){for(let r=0;r<e;r++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${r+1}/${e}`),yield new Promise((e=>setTimeout(e,t)))}throw new Error("TronWeb took too long to be ready")}));try{const r=yield e();if(!r.defaultAddress||!r.defaultAddress.base58)try{yield window.tronWeb.request({method:"tron_requestAccounts"})}catch(t){throw new Error("Please unlock TronLink and approve connection")}const n=r.defaultAddress.base58;return console.log("TronLink connected successfully:",n),{walletType:ls.TRONLINK,address:n,provider:r,network:cs.TRON,isConnected:!0}}catch(r){throw console.error("TronLink connection error:",r),r}})),bs=()=>__async(this,null,(function*(){if(console.log("Connecting to Trust Wallet..."),!window.ethereum||!window.ethereum.isTrust)throw 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. Please unlock Trust Wallet.");const t=e[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let s;switch(n){case 1:s=cs.ETHEREUM;break;case 56:s=cs.BSC;break;default:s=`unknown-${n}`}return{walletType:ls.TRUST_WALLET,address:t,provider:{request:e=>window.ethereum.request(e),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?"string"==typeof e.value?e.value:e.value.toString():"0x0",gasLimit:e.gasLimit?"string"==typeof e.gasLimit?e.gasLimit:e.gasLimit.toString():void 0,data:e.data||"0x"}]})}}))}),estimateGas:e=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:t,to:e.to,value:e.value?"string"==typeof e.value?e.value:e.value.toString():"0x0",data:e.data||"0x"}]}),n=parseInt(r,16);return{toString:()=>n.toString(),mul:e=>({div:t=>({toString:()=>Math.floor(n*e/t).toString()})})}}))},network:s,isConnected:!0,chainId:n}}catch(e){throw console.error("Trust Wallet connection error:",e),e}})),ws=()=>__async(this,null,(function*(){if(console.log("Connecting to Lute wallet..."),!window.lute)throw 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("Lute wallet connected successfully:",e),{walletType:ls.LUTE,address:e,provider:window.lute,network:cs.ALGORAND,isConnected:!0}}catch(e){throw console.error("Lute wallet connection error:",e),e}})),vs=(e,t,r=1)=>__async(this,null,(function*(){console.log("Connecting to wallet:",{walletType:e,network:t});for(let t=0;t<r;t++)try{switch(e){case ls.METAMASK:return yield ys();case ls.TRONLINK:return yield _s();case ls.TRUST_WALLET:return yield bs();case ls.LUTE:return yield ws();default:throw new Error(`Unsupported wallet type: ${e}`)}}catch(n){if(console.log(`Wallet connection attempt ${t+1} failed:`,n.message),t===r-1)throw n;yield new Promise((e=>setTimeout(e,1e3)))}})),xs=e=>hs[e]||[],Es=(e,t)=>__async(this,null,(function*(){if(console.log("Sending transaction:",{walletConnection:e,transactionParams:t}),!e)throw new Error("Wallet not connected");const{to:r,amount:n,tokenAddress:s,tokenDecimals:i,currency:o,network:a,tokenConfig:l}=t;if(!r)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");return!s||null===s?Ns(e,r,n):ks(e,{contractAddress:s,decimals:i,symbol:o},r,n)})),Ns=(e,t,r)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:t,amount:r}),!e||!e.provider)throw new Error("Wallet not connected");try{let n;switch(e.walletType){case ls.METAMASK:case ls.TRUST_WALLET:const s=e.provider,i=s.getSigner(),o=Xe?Xe(r.toString()):(void 0).parseEther(r.toString()),a=yield s.estimateGas({to:t,value:o}),l="function"==typeof a.mul?a.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(a.toString())).toString()};n=yield i.sendTransaction({to:t,value:o,gasLimit:l});break;case ls.TRONLINK:const c=e.provider;if(!c||!c.ready)throw new Error("TronWeb not initialized");const u=c.toSun(r.toString());n=yield c.trx.sendTransaction(t,u);break;case ls.LUTE:const d=e.provider,h=Math.floor(1e6*parseFloat(r));n=yield d.sendPayment({recipient:t,amount:h});break;default:throw new Error(`Unsupported wallet type: ${e.walletType}`)}const s=n.hash||n.txID||n.txId||n;return console.log("Native transaction sent:",s),s}catch(n){throw console.error("Native transaction error:",n),n}})),ks=(e,t,r,n)=>__async(this,null,(function*(){if(console.log("Sending token transaction:",{tokenConfig:t,toAddress:r,amount:n}),!e||!e.provider)throw new Error("Wallet not connected");if(!t||!t.contractAddress)throw new Error("Token configuration missing");switch(e.walletType){case ls.TRONLINK:return Ts(e,t,r,n);case ls.LUTE:return Ss(e,t,r,n);default:return As(e,t,r,n)}})),As=(e,t,r,n)=>__async(this,null,(function*(){console.log("Sending ERC20/BEP20 transaction:",{tokenConfig:t,toAddress:r,amount:n});const s=e.provider.getSigner(),{contractAddress:i,decimals:o,symbol:a}=t,l=parseFloat(n),c=parseInt(o);let u;try{u=Qe?Qe(l.toString(),c):(void 0).parseUnits(l.toString(),c)}catch(d){const e=l*Math.pow(10,c);u={toString:()=>e.toLocaleString("fullwide",{useGrouping:!1})}}console.log(`Sending ${l} ${a} (${u.toString()} base units) to ${r}`);try{const e=new as(i,["function transfer(address to, uint256 amount) returns (bool)"],s),t="USDC"===a?1.5:1.2,n=yield e.transfer(r,u,{gasLimit:Math.floor(2e5*t)});return console.log("ERC20 transaction sent:",n),n.hash}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}})),Ts=(e,t,r,n)=>__async(this,null,(function*(){console.log("Sending TRC20 transaction:",{tokenConfig:t,toAddress:r,amount:n});const s=e.provider;if(!s||!s.ready)throw new Error("TronWeb not initialized");const{contractAddress:i,decimals:o,symbol:a}=t,l=parseFloat(n),c=parseInt(o),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${a} (${u} base units) to ${r}`);try{const e=yield s.contract().at(i);if(!e.transfer)throw new Error("Invalid TRC-20 contract");const t=yield e.transfer(r,u.toString()).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."):new Error(`Transaction failed: ${d.message||"Unknown error"}`)}})),Ss=(e,t,r,n)=>__async(this,null,(function*(){console.log("Sending Algorand asset transaction:",{tokenConfig:t,toAddress:r,amount:n});const s=e.provider,{assetId:i,decimals:o,symbol:a}=t,l=parseFloat(n),c=parseInt(o),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${a} (${u} base units) to ${r}`);try{const e=yield s.sendAssetTransfer({recipient:r,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}}));let Rs={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{}};const Os=()=>({"Content-Type":"application/json","x-api-key":Rs.apiKey,"x-api-secret":Rs.apiSecret}),Cs=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Rs.apiUrl}/api/merchants/wallets`,{method:"GET",headers:Os()});if(!e.ok)throw new Error(`Failed to fetch wallet addresses: ${e.status}`);const t=yield e.json(),r={};return t.success&&t.wallets&&t.wallets.forEach((e=>{e.walletAddress&&e.networkShortName&&(r[e.networkShortName]=e.walletAddress)})),r}catch(e){throw console.error("Error fetching merchant wallet addresses:",e),e}})),Ps=e=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",e),!e.amount)throw new Error("Payment amount is required");let n=Rs.merchantWalletAddresses||{};if(0===Object.keys(n).length)try{n=yield Cs(),Rs.merchantWalletAddresses=n}catch(t){console.warn("Could not fetch merchant wallet addresses:",t.message)}const s=__spreadProps(__spreadValues({},e),{merchantWalletAddresses:__spreadValues(__spreadValues({},n),e.merchantWalletAddresses)});console.log("Enhanced payment data:",__spreadProps(__spreadValues({},s),{merchantWalletAddresses:s.merchantWalletAddresses}));const i=yield fetch(`${Rs.apiUrl}/api/payments/create`,{method:"POST",headers:Os(),body:JSON.stringify(s)});if(console.log("Create payment response status:",i.status),!i.ok){let e;try{e=yield i.json()}catch(r){throw new Error(`Failed to create payment: ${i.status} ${i.statusText}`)}throw console.error("Error creating payment:",e),new Error(e.error||`Failed to create payment: ${i.status}`)}const o=yield i.json();return console.log("Create payment response data:",o),o.merchantConfig&&o.merchantConfig.walletAddresses&&(Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),o.merchantConfig.walletAddresses)),o}catch(n){throw console.error("Create payment error:",n),n}})),Ms=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 r=yield fetch(`${Rs.apiUrl}/api/payments/process`,{method:"POST",headers:Os(),body:JSON.stringify(e)});if(console.log("Process payment response status:",r.status),!r.ok){let e;try{e=yield r.json()}catch(t){throw new Error(`Failed to process payment: ${r.status} ${r.statusText}`)}throw console.error("Error processing payment:",e),new Error(e.error||`Failed to process payment: ${r.status}`)}const n=yield r.json();return console.log("Process payment response data:",n),n}catch(r){throw console.error("Process payment error:",r),r}}));var Fs={exports:{}},js={},Us=t,Ls=Symbol.for("react.element"),Is=Symbol.for("react.fragment"),Gs=Object.prototype.hasOwnProperty,Ds=Us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Bs={key:!0,ref:!0,__self:!0,__source:!0};function Ws(e,t,r){var n,s={},i=null,o=null;for(n in void 0!==r&&(i=""+r),void 0!==t.key&&(i=""+t.key),void 0!==t.ref&&(o=t.ref),t)Gs.call(t,n)&&!Bs.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:Ls,type:e,key:i,ref:o,props:s,_owner:Ds.current}}js.Fragment=Is,js.jsx=Ws,js.jsxs=Ws,Fs.exports=js;var $s=Fs.exports;const zs=t.createContext(),Vs=t.createContext(),Hs=()=>t.useContext(Vs);var Ks,qs,Js=Object.defineProperty,Qs=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,Zs=(e,t,r)=>t in e?Js(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ei=(e,t)=>{for(var r in t||(t={}))Xs.call(t,r)&&Zs(e,r,t[r]);if(Qs)for(var r of Qs(t))Ys.call(t,r)&&Zs(e,r,t[r]);return e},ti=(e,t)=>{var r={};for(var n in e)Xs.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Qs)for(var n of Qs(e))t.indexOf(n)<0&&Ys.call(e,n)&&(r[n]=e[n]);return r};(e=>{const t=class t{constructor(e,r,n,i){if(this.version=e,this.errorCorrectionLevel=r,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(n);if(this.drawCodewords(a),-1==i){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const r=this.getPenaltyScore();r<e&&(i=t,e=r),this.applyMask(t)}}s(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}static encodeText(r,n){const s=e.QrSegment.makeSegments(r);return t.encodeSegments(s,n)}static encodeBinary(r,n){const s=e.QrSegment.makeBytes(r);return t.encodeSegments([s],n)}static encodeSegments(e,n,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 r=8*t.getNumDataCodewords(u,n),s=o.getTotalBits(e,u);if(s<=r){d=s;break}if(u>=a)throw new RangeError("Data too long")}for(const r of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&d<=8*t.getNumDataCodewords(u,r)&&(n=r);let h=[];for(const t of e){r(t.mode.modeBits,4,h),r(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,n);s(h.length<=p),r(0,Math.min(4,p-h.length),h),r(0,(8-h.length%8)%8,h),s(h.length%8==0);for(let t=236;h.length<p;t^=253)r(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,n,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 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 e=this.getAlignmentPatternPositions(),t=e.length;for(let r=0;r<t;r++)for(let n=0;n<t;n++)0==r&&0==n||0==r&&n==t-1||r==t-1&&0==n||this.drawAlignmentPattern(e[r],e[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let r=t;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const i=21522^(t<<10|r);s(i>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,n(i,s));this.setFunctionModule(8,7,n(i,6)),this.setFunctionModule(8,8,n(i,7)),this.setFunctionModule(7,8,n(i,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,n(i,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,n(i,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,n(i,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^7973*(e>>>11);const t=this.version<<12|e;s(t>>>18==0);for(let r=0;r<18;r++){const e=n(t,r),s=this.size-11+r%3,i=Math.floor(r/3);this.setFunctionModule(s,i,e),this.setFunctionModule(i,s,e)}}drawFinderPattern(e,t){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const s=Math.max(Math.abs(n),Math.abs(r)),i=e+n,o=t+r;0<=i&&i<this.size&&0<=o&&o<this.size&&this.setFunctionModule(i,o,2!=s&&4!=s)}}drawAlignmentPattern(e,t){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(e+n,t+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(e,t,r){this.modules[t][e]=r,this.isFunction[t][e]=!0}addEccAndInterleave(e){const r=this.version,n=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const i=t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],o=t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],a=Math.floor(t.getNumRawDataModules(r)/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 r=e.slice(p,p+c-o+(s<l?0:1));p+=r.length;const n=t.reedSolomonComputeRemainder(r,d);s<l&&r.push(0),u.push(r.concat(n))}let h=[];for(let t=0;t<u[0].length;t++)u.forEach(((e,r)=>{(t!=c-o||r>=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 r=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]&&r<8*e.length&&(this.modules[a][o]=n(e[r>>>3],7-(7&r)),r++)}}s(r==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 r=0;r<this.size;r++){let n;switch(e){case 0:n=(r+t)%2==0;break;case 1:n=t%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+t)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(t/2))%2==0;break;case 5:n=r*t%2+r*t%3==0;break;case 6:n=(r*t%2+r*t%3)%2==0;break;case 7:n=((r+t)%2+r*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][r]&&n&&(this.modules[t][r]=!this.modules[t][r])}}getPenaltyScore(){let e=0;for(let s=0;s<this.size;s++){let r=!1,n=0,i=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[s][o]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,i),r||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),r=this.modules[s][o],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,i)*t.PENALTY_N3}for(let s=0;s<this.size;s++){let r=!1,n=0,i=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][s]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,i),r||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),r=this.modules[o][s],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,i)*t.PENALTY_N3}for(let s=0;s<this.size-1;s++)for(let r=0;r<this.size-1;r++){const n=this.modules[s][r];n==this.modules[s][r+1]&&n==this.modules[s+1][r]&&n==this.modules[s+1][r+1]&&(e+=t.PENALTY_N2)}let r=0;for(const t of this.modules)r=t.reduce(((e,t)=>e+(t?1:0)),r);const n=this.size*this.size,i=Math.ceil(Math.abs(20*r-10*n)/n)-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 r=[6];for(let n=this.size-7;r.length<e;n-=t)r.splice(1,0,n);return r}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;r-=(25*t-10)*t-55,e>=7&&(r-=36)}return s(208<=r&&r<=29648),r}static getNumDataCodewords(e,r){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let r=[];for(let t=0;t<e-1;t++)r.push(0);r.push(1);let n=1;for(let s=0;s<e;s++){for(let e=0;e<r.length;e++)r[e]=t.reedSolomonMultiply(r[e],n),e+1<r.length&&(r[e]^=r[e+1]);n=t.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(e,r){let n=r.map((e=>0));for(const s of e){const e=s^n.shift();n.push(0),r.forEach(((r,s)=>n[s]^=t.reedSolomonMultiply(r,e)))}return n}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>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^=(t>>>n&1)*e;return s(r>>>8==0),r}finderPenaltyCountPatterns(e){const t=e[1];s(t<=3*this.size);const r=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(r&&e[0]>=4*t&&e[6]>=t?1:0)+(r&&e[6]>=4*t&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)}};function r(e,t,r){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let n=t-1;n>=0;n--)r.push(e>>>n&1)}function n(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,r){if(this.mode=e,this.numChars=t,this.bitData=r,t<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(t){let n=[];for(const e of t)r(e,8,n);return new e(e.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!e.isNumeric(t))throw new RangeError("String contains non-numeric characters");let n=[];for(let e=0;e<t.length;){const s=Math.min(t.length-e,3);r(parseInt(t.substring(e,e+s),10),3*s+1,n),e+=s}return new e(e.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,s=[];for(n=0;n+2<=t.length;n+=2){let i=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n));i+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n+1)),r(i,11,s)}return n<t.length&&r(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)),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 n=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)r(t,8,n);else if(t<16384)r(2,2,n),r(t,14,n);else{if(!(t<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(t,21,n)}return new e(e.Mode.ECI,0,n)}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 r=0;for(const n of e){const e=n.mode.numCharCountBits(t);if(n.numChars>=1<<e)return 1/0;r+=4+e+n.bitData.length}return r}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let r=0;r<e.length;r++)"%"!=e.charAt(r)?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return t}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;e.QrSegment=i})(Ks||(Ks={})),(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})((qs=Ks||(Ks={})).QrCode||(qs.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={}))})(Ks||(Ks={}));var ri=Ks,ni={L:ri.QrCode.Ecc.LOW,M:ri.QrCode.Ecc.MEDIUM,Q:ri.QrCode.Ecc.QUARTILE,H:ri.QrCode.Ecc.HIGH},si=128,ii="L",oi="#FFFFFF",ai="#000000",li=!1,ci=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;
|
3
3
|
/**
|
4
4
|
* @license qrcode.react
|
5
5
|
* Copyright (c) Paul O'Shannessy
|
6
6
|
* SPDX-License-Identifier: ISC
|
7
|
-
*/function ui(e,t=0){const r=[];return e.forEach((function(e,n){let s=null;e.forEach((function(i,o){if(!i&&null!==s)return r.push(`M${s+t} ${n+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?r.push(`M${o+t},${n+t} h1v1H${o+t}z`):r.push(`M${s+t},${n+t} h${o+1-s}v1H${s+t}z`)}}))})),r.join("")}function di(e,t){return e.slice().map(((e,r)=>r<t.y||r>=t.y+t.h?e:e.map(((e,r)=>(r<t.x||r>=t.x+t.w)&&e))))}function hi({value:e,level:r,minVersion:n,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,ni[r],n,void 0,void 0,l)}),[e,r,n,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),r=e.length+2*t,n=function(e,t,r,n){if(null==n)return null;const s=e.length+2*r,i=Math.floor(.1*t),o=s/t,a=(n.width||i)*o,l=(n.height||i)*o,c=null==n.x?e.length/2-a/2:n.x*o,u=null==n.y?e.length/2-l/2:n.y*o,d=null==n.opacity?1:n.opacity;let h=null;if(n.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:n.crossOrigin}}(e,a,t,o);return{cells:e,margin:t,numCells:r,calculatedImageSettings:n}}),[c,a,o,s,i]);return{qrcode:c,margin:d,cells:u,numCells:h,calculatedImageSettings:p}}var pi=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();t.forwardRef((function(e,r){const n=e,{value:s,size:i=si,level:o=ii,bgColor:a=oi,fgColor:l=ai,includeMargin:c=li,minVersion:u=ci,boostLevel:d,marginSize:h,imageSettings:p}=n,f=ti(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:m}=f,g=ti(f,["style"]),y=null==p?void 0:p.src,_=t.useRef(null),b=t.useRef(null),w=t.useCallback((e=>{_.current=e,"function"==typeof r?r(e):r&&(r.current=e)}),[r]),[v,x]=t.useState(!1),{margin:E,cells:N,numCells:k,calculatedImageSettings:A}=hi({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 r=N;const n=b.current,s=null!=A&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;s&&null!=A.excavation&&(r=di(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,pi?t.fill(new Path2D(ui(r,E))):N.forEach((function(e,r){e.forEach((function(e,n){e&&t.fillRect(n+E,r+E,1,1)}))})),A&&(t.globalAlpha=A.opacity),s&&t.drawImage(n,A.x+E,A.y+E,A.w,A.h)}})),t.useEffect((()=>{x(!1)}),[y]);const T=ei({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",ei({style:T,height:i,width:i,ref:w,role:"img"},g)),S)})).displayName="QRCodeCanvas";var fi=t.forwardRef((function(e,r){const n=e,{value:s,size:i=si,level:o=ii,bgColor:a=oi,fgColor:l=ai,includeMargin:c=li,minVersion:u=ci,boostLevel:d,title:h,marginSize:p,imageSettings:f}=n,m=ti(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:g,cells:y,numCells:_,calculatedImageSettings:b}=hi({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=di(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=ui(w,g);return t.createElement("svg",ei({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:r,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)}));fi.displayName="QRCodeSVG";const mi=({walletAddress:e,amount:r,currency:n,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"===n?`tronlink://transfer?to=${e}&amount=${r}`:e;break;case"algorand":t=`algorand://${e}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)t=`ethereum:${e}@56?value=${p(r)}`;else{const s=d(n,"bsc");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}@56`:e}break;default:if("ETH"===n)t=`ethereum:${e}@1?value=${p(r)}`;else{const s=d(n,"ethereum");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}`: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,r,n,s]);const d=(e,t)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[t])?void 0:r[e])||""},h=(e,t)=>{const r="USDT"===t||"USDC"===t?6:18;return Math.floor(parseFloat(e)*Math.pow(10,r)).toString()},p=e=>Math.floor(1e18*parseFloat(e)).toString(),f=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e);return $s.jsxs("div",{className:"flex flex-col items-center",children:[c?$s.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[$s.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:$s.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"})}),$s.jsx("p",{className:"font-medium",children:c})]}):$s.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:a&&$s.jsx(fi,{value:a,size:o,bgColor:"dark"===i?"#374151":"#FFFFFF",fgColor:"dark"===i?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),$s.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[$s.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[$s.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:$s.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]}),$s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(s)," wallet app"]})]}),$s.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[$s.jsxs("div",{className:"flex justify-between items-center",children:[$s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),$s.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),$s.jsxs("div",{className:"flex justify-between items-center mt-1",children:[$s.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),$s.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(s)})]})]}),!c&&$s.jsxs("div",{className:"w-full mb-4",children:[$s.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),$s.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})]}),$s.jsx("div",{className:"w-full",children:$s.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[$s.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[$s.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:$s.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"]}),$s.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[$s.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(", "),")"]}),$s.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),$s.jsxs("li",{children:["3. Send exactly ",$s.jsxs("strong",{children:[r," ",n]})," on ",f(s)," network"]}),$s.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),$s.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:$s.jsxs("p",{className:"text-xs text-yellow-800",children:[$s.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(s),") and using the exact amount shown above."]})})]})})]});var m},gi=({status:e,message:t,theme:r="light"})=>$s.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[$s.jsx("div",{className:"mb-4",children:(()=>{switch(e){case"processing":return $s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return $s.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:$s.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:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return $s.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:$s.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:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),$s.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"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"}})()}),$s.jsx("p",{className:`text-center ${(()=>{switch(e){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:t}),"processing"===e&&$s.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"===e&&$s.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:$s.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."})})]}),yi=({onSelect:e,selected:r,theme:n="light",supportedNetworks:s=[]})=>{const[i,o]=t.useState(cs.ETHEREUM),[a,l]=t.useState({}),[c,u]=t.useState(!1);t.useEffect((()=>{l(fs())}),[]);const d=[{id:cs.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:cs.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:cs.TRON,name:"Tron",description:"TRC-20 tokens"},{id:cs.ALGORAND,name:"Algorand",description:"ASA tokens"}],h=(e=>{const t=[];switch(e){case cs.ETHEREUM:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:cs.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",network:cs.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:cs.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",network:cs.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:cs.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",network:cs.ETHEREUM});break;case cs.BSC:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:cs.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:cs.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:cs.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",network:cs.BSC});break;case cs.TRON:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:cs.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:cs.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:cs.TRON});break;case cs.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:cs.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:cs.ALGORAND})}return t})(i),p=c?h:h.slice(0,4);function f(e){switch(e){case cs.ETHEREUM:case cs.BSC:return ls.METAMASK;case cs.TRON:return ls.TRONLINK;case cs.ALGORAND:return ls.LUTE;default:return ls.METAMASK}}return $s.jsxs("div",{children:[$s.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===n?"text-white":"text-gray-800"),children:"Select Payment Method"}),$s.jsxs("div",{className:"mb-6",children:[$s.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),$s.jsx("select",{value:i,onChange:t=>{return n=t.target.value,o(n),u(!1),void((null==r?void 0:r.network)!==n&&e(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:d.filter((e=>0===s.length||s.includes(e.id))).map((e=>$s.jsxs("option",{value:e.id,children:[e.name," - ",e.description]},e.id)))})]}),$s.jsxs("div",{className:"mb-4",children:[$s.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),$s.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:p.map((t=>$s.jsx("button",{onClick:()=>(t=>{var r;e({currency:t.id,network:i,tokenConfig:null==(r=ds[t.id])?void 0:r[i],method:t})})(t),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===i?"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:$s.jsxs("div",{className:"flex flex-col items-center text-center",children:[$s.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:$s.jsx("img",{src:t.logo,alt:t.name,className:"h-6 w-6"})}),$s.jsxs("div",{children:[$s.jsx("h4",{className:"font-medium text-sm "+("dark"===n?"text-white":"text-gray-900"),children:t.name}),$s.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-500"),children:t.description})]}),(null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===i&&$s.jsx("div",{className:"mt-2",children:$s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:$s.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&&$s.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 (${h.length-4} more)`})]}),$s.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:$s.jsxs("div",{className:"flex items-center",children:[$s.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(a[f(i)]?"bg-green-500":"bg-red-500")}),$s.jsx("span",{className:"text-xs",children:function(e){const t=f(e),r=a[t],n={[ls.METAMASK]:"MetaMask",[ls.TRONLINK]:"TronLink",[ls.TRUST_WALLET]:"Trust Wallet",[ls.LUTE]:"Lute Wallet"};return r?`${n[t]} detected - Ready to pay`:`${n[t]} required - Please install to continue`}(i)})]})})]})},_i=({isOpen:e,onClose:r,payment:n,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=>({[ls.METAMASK]:"MetaMask",[ls.TRONLINK]:"TronLink",[ls.TRUST_WALLET]:"Trust Wallet",[ls.LUTE]:"Lute Wallet"}[e]||e),A=e=>({[ls.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[ls.TRONLINK]:"https://www.tronlink.org/images/logo.png",[ls.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[ls.LUTE]:"https://lute.app/logo.png"}[e]||"");return e?$s.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:$s.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:$s.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[$s.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[$s.jsx("div",{className:"flex items-center",children:$s.jsx("h2",{className:"text-xl font-bold text-gray-900",children:$s.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm4FFgMAhAX48ODg4dISOGB4/XKsfObl9e+Y9n3wViHt3QHY5ud2fYId1caDSJyc/V+kMW4q4S2VFFurcCR0Oj+/H3kq9vSv1VyDDKX5s0Fh8VSlTifrcx/cByR046QRbjE6EQmnQok9aGzlQ+QRZluDHh1BJaWFNKsJApQvs0JlQc+e4jzgelqX1HNUczfHjQqCqkRLsUCWU0jL94buHE659LGQ5G51SfafAUcfZn572Sv63hKZL1u6lYeYpk9jBo6HieKysgmulbR6VAX7lEmuSHpLWkU5tIoVW+3q6cxEhdbOaqMcPF4gzNVVEI2VsJXi5oHE4d/JSpY/YwUOoRYkwA1qxWWPcIvtSlhDbc/FBWc5i+RbblR8ZsGaKzDIJPKV42Rir9EqlNzZJ7OCzoRZTlG0lTYalBlosbsr1o33zg4JQijBKm6V0WLgRtN1hm+DSaruXDq6x//XY4wX0oJWNo9R5VF61xL1rRY4jIsrw6F4iioQuz7JX5nz8Wh2bulGU0o+2kziZMqSTu7X9UwLGCBZOGWnEFOWXoQk0ZZ945FCS+D4QKN873W8Kv122Kv6Jfmns+QrJITl89+09cwH0LakOkS3OEPWuS42yrHiQiydjX8Q9IqVw6kjVdh1bI1FphPoV1RTGvpFryklVulTpJnD+jrX/aK9NeET5YR7Z+7lC+Jr0sD9gvQeeoF2/PjrXIfI9orxqpfEboxmkGFyn6yzsNnj664MiAH9rBLkKlJa6IU+4LsnyNyu7t7/n6rxUBvgAxj9jizWZSMNJdAd1lgjMH6IPA5gBGgXOX7SUk9hrbsK/JFpcM3eUruq47NIvd3xIEVyyOp/QDu9Z/nJJKL0K4ys6RYAlcZaItAdcabGh0kSHk3R/rIsXi4nO39p8FBU3paa5NclEA9V1oMeokoo0xBDdMLTt1oHZPWhGv0NdLr9rv8YoxmfiuY8E9aDzgpWle+RzUiu7T8pQpgq0V0dkmJmVGL6oPTu1zfJA+ZG2m3I7CZp0M+eYmF5otCyji821xlrPZqI378BTnqr0qz2mAXjv6eBYJdKcNG3R4A1q5Ejb/n+oDia128QemoTRBtLKy/fphFOH+jJEe4JcoNovaa+T2uuIwLXGMH1PbUqccyNbFgLfWpvq6yqyZA3p0U5f2tfU1iG5IcflAGavzE00LYia+o9O3T9smfDIoXpJQI5gcvLk1r9j5wbOOV/bKfz7fX0Ue4LufedIPPft3ie/zgThfUWqfx2Ql3hk1T1D3kc9g8T5iqwGQqWr4fG3Ea3w2i73N+QWGLG8RGHg+jCFMWzz4zf2NyQnDcgJXWeE1SBRaDkOKuMLFXqQr9EMfj8pjGab19yHa5ATBAwZUlTHI6Ql+QpSwi5eYmt8f0YjsvH/j39r08lNgVS0YGX0kJuIStPuIczAUd18t95F0yoQ8Hu/E6wWVdA0vr7l/Bs0Y8Dy5y3a+Izw3Ljm90lTpK+/3BhP84M9q0kGaoqa2s1dv/GrbKqf7/7zO54PguVTtF9Su6tTbn9JFMv7JqQobKscCcKuhDo5TZDoZownLD8PlPswD8iawthkOYly49ztb+7jcrEk8tIPZT3bqbV9DhS5hGKRUAa7uvhilnu+nxGcCPdYDYLlJbrhVyZDYDvQ9+TvsBqEc0zay51KScm4hDph1y5p15IfypBpj8hEKu29dhH04lOVPw1EHzwnNmGTESTWwyYWG5vA97qPCcpjnaCs9U5Z/dL0WfihlNFNEQYmGkAbY8bwyjLSFAO7n/ecg8kJtCn77aBj/Z9YXmI7sKkXjMuiY25L5VOcQHVKTd1MTJpHbbN8JaMb9ax/7jdTsvwJVsOM5QW69SVheYntAO8XEYH2VaMV0ismi9uIpJVye8rFFGw8YqV5RlYLNUBvqWzyrWhCCh4h2t7ZN0BhF8w8ctou/0cok2+Odgb2c0Bi9fFpQopyP/OVMp/uvvCG8TJqIATtMc8o+uD18Ojh7uzdt1b7PMMkGPXZFr6HRw+4ifxU5wrl/Sq+TKaBP22QQ+fHrKzr6u57w7cHJ9AMqtdEvnNPm8TJS3jGg/xQHz3OTao8VcpQOQkjaSIsFUPV9kyWZZNW/qg4O9DBebS1szpoq4O/heRVpvsRrG4Cs8oZO2V0TJ2eoDpVTeHfN6NrXKDqWpBo5+d5TnADOl/pDQL1875N7O9jTd0UPC6uer6CyM2QRsk3cL2BcTkWT+RgnKnzVxSqQnt6tv6Fyp8tZRzdf1VkVRolGk9u/7vqw6A3KbTjL+1vH367iAbk0NZLEF5W59OiQPgNJw+8+0Z2DV9JUQ8uL2+ToHzfEmWnJ72w1x55VC9f0vdR7Of1PfVCTtQxwubBITwxXCW3gUOmfpBMeTSmiXU6QRwnVtSJzke9q6Lu4oOdMsd6Fbka6G0KkVEgbGQTQdztkxThuG8a6ARhMlG7bZvuctB9+cZHwH5DCaOFEvjJdIQwuAbMMUMgINAfD8UD41yo6dHaRgNb0reSzK+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"})})}),$s.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:$s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),$s.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[n&&$s.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[$s.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",d]}),$s.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[$s.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),$s.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(S=n.totalAmount||n.amount,parseFloat(S).toFixed(2))]})]}),$s.jsx("div",{className:"text-xs mt-1 text-right",children:$s.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",n.id?n.id.slice(0,8):"","..."]})})]}),v&&$s.jsx("div",{className:"mb-2 text-right",children:$s.jsx("button",{onClick:()=>{console.log("=== DEBUG INFO ==="),console.log("Current step:",b),console.log("Payment method:",i),console.log("Wallet connection:",p),gs()},className:"text-xs bg-gray-200 p-1 rounded",children:"Debug"})}),"select-currency"===b&&$s.jsxs("div",{children:[$s.jsx(yi,{onSelect:o,selected:i,theme:u,supportedNetworks:g}),i&&$s.jsx("div",{className:"mt-6",children:$s.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&&n&&$s.jsxs("div",{children:[$s.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[$s.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),$s.jsxs("div",{className:"space-y-2",children:[$s.jsxs("div",{className:"flex justify-between",children:[$s.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),$s.jsx("span",{className:"font-medium",children:i.currency})]}),$s.jsxs("div",{className:"flex justify-between",children:[$s.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),$s.jsx("span",{className:"font-medium",children:N(i.network)})]}),$s.jsxs("div",{className:"flex justify-between",children:[$s.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),$s.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),$s.jsx("div",{className:"mb-4",children:$s.jsxs("div",{className:"flex border-b border-gray-200",children:[$s.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"}),$s.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?$s.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:$s.jsxs("div",{className:"flex items-center",children:[$s.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:$s.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:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),$s.jsxs("div",{children:[$s.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),$s.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===x?$s.jsx("div",{className:"mb-4",children:$s.jsx(mi,{walletAddress:(()=>{if(!i)return"No network selected";const e=w[i.network];return e||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:i.currency,network:i.network,theme:u})}):$s.jsxs("div",{className:"space-y-3 mb-4",children:[0===_.length?$s.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:$s.jsxs("div",{className:"flex items-center",children:[$s.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:$s.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"})}),$s.jsxs("div",{children:[$s.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),$s.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",N(i.network)," network"]})]})]})}):_.map((e=>$s.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:$s.jsxs("div",{className:"flex items-center justify-between",children:[$s.jsxs("div",{className:"flex items-center",children:[$s.jsx("img",{src:A(e),alt:k(e),className:"w-8 h-8 mr-3",onError:e=>{e.target.style.display="none"}}),$s.jsxs("div",{children:[$s.jsx("h3",{className:"font-medium text-gray-800",children:k(e)}),$s.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",k(e)]})]})]}),(null==p?void 0:p.walletType)===e?$s.jsxs("div",{className:"flex items-center space-x-2",children:[$s.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),$s.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):$s.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))),$s.jsx("div",{className:"space-y-2",children:Object.entries(y).filter((([e,t])=>!t)).map((([e])=>$s.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:$s.jsxs("div",{className:"flex items-center justify-between",children:[$s.jsxs("span",{className:"text-sm text-gray-600",children:[k(e)," not detected"]}),$s.jsx("a",{href:ps(e),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},e)))})]}),c&&$s.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),$s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[$s.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"}),$s.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&&$s.jsx(gi,{status:"processing",theme:u,message:"Processing your payment..."}),"success"===b&&$s.jsxs("div",{children:[$s.jsx(gi,{status:"success",theme:u,message:"Payment successful!"}),h&&$s.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[$s.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),$s.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&&$s.jsx("a",{href:`${bi(i.network)}/${wi(i.network)}/${h}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===b&&$s.jsxs("div",{children:[$s.jsx(gi,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),$s.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"})]})]}),$s.jsx("div",{className:"text-center text-xs text-gray-500",children:$s.jsxs("p",{children:["Powered by ",$s.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var T,S},bi=e=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[e]||"https://etherscan.io"),wi=e=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[e]||"tx"),vi=t.forwardRef((({apiKey:e,apiSecret:r,apiUrl:n,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=cs.ETHEREUM,preferredWallet:g=ls.METAMASK},y)=>{const _=Hs(),{theme:b}=t.useContext(zs),[w,v]=t.useState(d),[x,E]=t.useState(null),[N,k]=t.useState("idle"),[A,T]=t.useState(null),[S,R]=t.useState(null),[O,C]=t.useState(null),[P,M]=t.useState(null),[F,j]=t.useState({}),[U,L]=t.useState("select-currency"),[I,G]=t.useState({}),[D,B]=t.useState(!1),W=e||(null==_?void 0:_.apiKey),$=r||(null==_?void 0:_.apiSecret);n||null==_||_.apiUrl;const z=u||b,V=h||(null==_?void 0:_.debug),H=f.length>0?f:[cs.ETHEREUM,cs.BSC,cs.TRON,cs.ALGORAND];t.useImperativeHandle(y,(()=>({open:e=>{q(e)},close:()=>{J()},getPayment:()=>x,getWalletConnection:()=>P,getMerchantWallets:()=>I,debugWallets:()=>gs()})));const K=(e,t)=>{V&&console.log(`[Coinley SDK] ${e}`,t)};t.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const e=yield ms(3,1e3);j(e),K("Available wallets detected:",e)})))()}}),[V]),t.useEffect((()=>{(()=>{__async(this,null,(function*(){if(W&&$){B(!0);try{const e=__spreadProps(__spreadValues({},Rs),{merchantWalletAddresses:__spreadValues({},Rs.merchantWalletAddresses)});if(e.merchantWalletAddresses&&Object.keys(e.merchantWalletAddresses).length>0)G(e.merchantWalletAddresses),K("Loaded wallet addresses from API config:",e.merchantWalletAddresses);else{const e=yield Cs();e&&Object.keys(e).length>0?(G(e),K("Fetched wallet addresses from API:",e)):K("No wallet addresses found in API response")}o&&Object.keys(o).length>0&&(G((e=>__spreadValues(__spreadValues({},e),o))),K("Added manual wallet addresses:",o))}catch(e){K("Error loading merchant wallet addresses:",e),console.warn("Could not load merchant wallet addresses:",e.message),o&&Object.keys(o).length>0&&(G(o),K("Using fallback manual wallet addresses:",o))}finally{B(!1)}}else K("No API credentials available for wallet address fetching")}))})()}),[W,$,o,V]);const q=e=>__async(this,null,(function*(){if(!e||!e.amount)return R("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));k("loading"),v(!0),L("select-currency");try{K("Creating payment with details:",e);let r=__spreadValues({},I);if(0===Object.keys(r).length){K("No wallet addresses available, attempting to fetch...");try{const e=yield Cs();e&&(r=e,G(e))}catch(t){K("Failed to fetch wallet addresses:",t)}}e.merchantWalletAddresses&&(r=__spreadValues(__spreadValues({},r),e.merchantWalletAddresses)),o&&(r=__spreadValues(__spreadValues({},r),o)),K("Final wallet addresses for payment:",r);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),{sdkVersion:"1.0.0",merchantWallets:r}),merchantWalletAddresses:r});if(K("Payment created:",n),!n.payment)throw new Error("Invalid payment response structure");E(n.payment),n.merchantConfig&&n.merchantConfig.walletAddresses&&(G((e=>__spreadValues(__spreadValues({},e),n.merchantConfig.walletAddresses))),K("Updated wallet addresses from payment response:",n.merchantConfig.walletAddresses)),k("idle"),R(null),K("Payment created and state updated successfully")}catch(r){K("Error creating payment:",r),R(r.message||"Failed to create payment"),k("error"),l&&l(r)}})),J=()=>{v(!1),C(null),M(null),T(null),L("select-currency"),R(null),c&&c()},Q=()=>{if(!A)return null;const e=A.network;return x&&x.recipientWallet?x.recipientWallet:I[e]?I[e]:o[e]?o[e]:null};return D?$s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:$s.jsx("div",{className:"bg-white p-6 rounded-lg shadow-xl",children:$s.jsxs("div",{className:"flex items-center space-x-3",children:[$s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-blue-500 border-t-transparent"}),$s.jsx("span",{className:"text-gray-700",children:"Loading payment gateway..."})]})})}):$s.jsx($s.Fragment,{children:w&&$s.jsx(_i,{isOpen:w,onClose:J,payment:x,paymentStatus:N,selectedPaymentMethod:A,onPaymentMethodSelect:e=>{K("Payment method selected:",e),T(e),L("confirm")},onPayment:()=>__async(this,null,(function*(){if(!x||!A)return void R("Missing payment information");const e=Q();if(e||p)if(P||p){K("Starting payment process..."),k("loading"),C(null),L("processing");try{let t;if(p)K("Test mode: Generating mock transaction..."),t=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{K("Sending transaction through wallet...",{recipientAddress:e,amount:x.totalAmount||x.amount,network:A.network});const r=x.token||A.tokenConfig;t=yield Es(P,{to:e,amount:x.totalAmount||x.amount,tokenAddress:null==r?void 0:r.contractAddress,tokenDecimals:null==r?void 0:r.decimals,currency:A.currency,network:A.network,tokenConfig:r})}K("Transaction hash:",t),C(t),K("Processing payment with backend...");const r=yield Ms({paymentId:x.id,transactionHash:t,network:A.network,currency:A.currency,senderAddress:null==P?void 0:P.address});K("Payment processed successfully:",r),k("success"),L("success"),a&&(K("Calling onSuccess callback..."),a(x.id,t,{network:A.network,currency:A.currency,amount:x.totalAmount||x.amount,recipientAddress:e}))}catch(t){K("Payment error:",t);let e=t.message||"Failed to process payment";e.includes("User rejected")||e.includes("user rejected")?e="Transaction was rejected by user":e.includes("insufficient funds")?e="Insufficient funds in wallet":e.includes("network")?e="Network error. Please check your connection and try again":(e.includes("recipient")||e.includes("address"))&&(e="Invalid recipient address. Please contact support"),R(e),k("error"),L("error"),l&&l(new Error(e))}}else R("Please connect your wallet first");else R(`No recipient wallet address configured for ${A.network} network`)})),onBack:()=>{"confirm"===U?(L("select-currency"),M(null),R(null)):"error"===U&&(L("confirm"),R(null))},error:S,theme:z,merchantName:i,transactionHash:O,walletConnection:P,onConnectWallet:e=>__async(this,null,(function*(){if(A)try{R(null),K("Connecting wallet:",{walletType:e,network:A.network});const t=yield vs(e,A.network,2);M(t),R(null),K("Wallet connected successfully:",t)}catch(t){K("Wallet connection error:",t),R(t.message||"Failed to connect wallet")}else R("Please select a payment method first")})),testMode:p,supportedNetworks:H,availableWallets:F,supportedWallets:A?xs(A.network):[],step:U,merchantWalletAddresses:I,recipientAddress:Q(),debug:V})})}));vi.displayName="CoinleyCheckout";e.CoinleyCheckout=vi,e.CoinleyModal=_i,e.CoinleyProvider=({apiKey:e,apiSecret:r,apiUrl:n="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);t.useEffect((()=>{var t;if(e&&r)try{t={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:i},Rs=__spreadValues(__spreadValues({},Rs),t),console.log("API initialized with:",{apiUrl:Rs.apiUrl,apiKey:Rs.apiKey?`${Rs.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Rs.merchantWalletAddresses||{}).length>0}),Rs.apiKey&&Rs.apiSecret&&Cs().then((e=>{e&&(Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),e),console.log("Auto-fetched merchant wallet addresses:",e))})).catch((e=>{console.warn("Could not auto-fetch merchant wallet addresses:",e.message)})),c(!0),o&&console.log("Coinley SDK initialized with:",{apiKey:e,apiUrl:n,merchantWalletAddress:s?`${s.substring(0,6)}...${s.substring(s.length-4)}`:"Not provided",merchantSolWalletAddress:i?`${i.substring(0,6)}...${i.substring(i.length-4)}`:"Not provided"})}catch(a){d(a.message),o&&console.error("Coinley SDK initialization error:",a)}else d("API key and secret are required")}),[e,r,n,s,i,o]);const f={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:i,isInitialized:l,error:u,debug:o,paymentData:h,storePaymentData:e=>(p(e),e)};return $s.jsx(Vs.Provider,{value:f,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=us,e.NETWORK_TYPES=cs,e.PaymentMethods=yi,e.PaymentStatus=gi,e.QRCode=mi,e.TOKEN_CONFIG=ds,e.ThemeProvider=({initialTheme:e="light",children:r})=>{const[n,s]=t.useState(e);return t.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),$s.jsx(zs.Provider,{value:{theme:n,setTheme:s,toggleTheme:()=>{s((e=>"light"===e?"dark":"light"))}},children:r})},e.WALLET_TYPES=ls,e.connectWallet=vs,e.createPayment=Ps,e.detectWallets=fs,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.getMerchantProfile=()=>__async(this,null,(function*(){try{const t=yield fetch(`${Rs.apiUrl}/api/merchants/dashboard`,{method:"GET",headers:Os()});if(!t.ok){let r;try{r=yield t.json()}catch(e){throw new Error(`Failed to get merchant profile: ${t.status} ${t.statusText}`)}throw new Error(r.error||`Failed to get merchant profile: ${t.status}`)}const r=yield t.json();if(r.merchant){const e={};r.merchant.walletAddress&&(e.ethereum=r.merchant.walletAddress),r.merchant.solWalletAddress&&(e.solana=r.merchant.solWalletAddress),r.merchant.merchantWallets&&Object.assign(e,r.merchant.merchantWallets),Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),e)}return r}catch(t){throw console.error("Get merchant profile error:",t),t}})),e.getPayment=e=>__async(this,null,(function*(){try{if(console.log("Getting payment:",e),!e)throw new Error("Payment ID is required");const r=yield fetch(`${Rs.apiUrl}/api/payments/${e}`,{method:"GET",headers:Os()});if(!r.ok){let e;try{e=yield r.json()}catch(t){throw new Error(`Failed to get payment: ${r.status} ${r.statusText}`)}throw console.error("Error getting payment:",e),new Error(e.error||`Failed to get payment: ${r.status}`)}const n=yield r.json();return console.log("Get payment response:",n),n.payment&&n.payment.merchantWallets&&(Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),n.payment.merchantWallets)),n}catch(r){throw console.error("Get payment error:",r),r}})),e.getSupportedNetworks=()=>__async(this,null,(function*(){try{const t=yield fetch(`${Rs.apiUrl}/api/networks`,{method:"GET",headers:Os()});if(!t.ok){let r;try{r=yield t.json()}catch(e){throw new Error(`Failed to get networks: ${t.status} ${t.statusText}`)}throw new Error(r.error||`Failed to get networks: ${t.status}`)}return yield t.json()}catch(t){throw console.error("Get supported networks error:",t),t}})),e.getSupportedWalletsForNetwork=xs,e.getWalletInstallUrl=ps,e.processPayment=Ms,e.sendTransaction=Es,e.useCoinley=Hs,e.validateWalletAddress=(e,t)=>__async(this,null,(function*(){try{const n=yield fetch(`${Rs.apiUrl}/api/wallets/validate`,{method:"POST",headers:Os(),body:JSON.stringify({address:e,network:t})});if(!n.ok){let e;try{e=yield n.json()}catch(r){throw new Error(`Failed to validate address: ${n.status} ${n.statusText}`)}throw new Error(e.error||`Failed to validate address: ${n.status}`)}return yield n.json()}catch(n){throw console.error("Validate wallet address error:",n),n}})),Object.defineProperty(e,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/YwUOoRYkwA1qxWWPcIvtSlhDbc/FBWc5i+RbblR8ZsGaKzDIJPKV42Rir9EqlNzZJ7OCzoRZTlG0lTYalBlosbsr1o33zg4JQijBKm6V0WLgRtN1hm+DSaruXDq6x//XY4wX0oJWNo9R5VF61xL1rRY4jIsrw6F4iioQuz7JX5nz8Wh2bulGU0o+2kziZMqSTu7X9UwLGCBZOGWnEFOWXoQk0ZZ945FCS+D4QKN873W8Kv122Kv6Jfmns+QrJITl89+09cwH0LakOkS3OEPWuS42yrHiQiydjX8Q9IqVw6kjVdh1bI1FphPoV1RTGvpFryklVulTpJnD+jrX/aK9NeET5YR7Z+7lC+Jr0sD9gvQeeoF2/PjrXIfI9orxqpfEboxmkGFyn6yzsNnj664MiAH9rBLkKlJa6IU+4LsnyNyu7t7/n6rxUBvgAxj9jizWZSMNJdAd1lgjMH6IPA5gBGgXOX7SUk9hrbsK/JFpcM3eUruq47NIvd3xIEVyyOp/QDu9Z/nJJKL0K4ys6RYAlcZaItAdcabGh0kSHk3R/rIsXi4nO39p8FBU3paa5NclEA9V1oMeokoo0xBDdMLTt1oHZPWhGv0NdLr9rv8YoxmfiuY8E9aDzgpWle+RzUiu7T8pQpgq0V0dkmJmVGL6oPTu1zfJA+ZG2m3I7CZp0M+eYmF5otCyji821xlrPZqI378BTnqr0qz2mAXjv6eBYJdKcNG3R4A1q5Ejb/n+oDia128QemoTRBtLKy/fphFOH+jJEe4JcoNovaa+T2uuIwLXGMH1PbUqccyNbFgLfWpvq6yqyZA3p0U5f2tfU1iG5IcflAGavzE00LYia+o9O3T9smfDIoXpJQI5gcvLk1r9j5wbOOV/bKfz7fX0Ue4LufedIPPft3ie/zgThfUWqfx2Ql3hk1T1D3kc9g8T5iqwGQqWr4fG3Ea3w2i73N+QWGLG8RGHg+jCFMWzz4zf2NyQnDcgJXWeE1SBRaDkOKuMLFXqQr9EMfj8pjGab19yHa5ATBAwZUlTHI6Ql+QpSwi5eYmt8f0YjsvH/j39r08lNgVS0YGX0kJuIStPuIczAUd18t95F0yoQ8Hu/E6wWVdA0vr7l/Bs0Y8Dy5y3a+Izw3Ljm90lTpK+/3BhP84M9q0kGaoqa2s1dv/GrbKqf7/7zO54PguVTtF9Su6tTbn9JFMv7JqQobKscCcKuhDo5TZDoZownLD8PlPswD8iawthkOYly49ztb+7jcrEk8tIPZT3bqbV9DhS5hGKRUAa7uvhilnu+nxGcCPdYDYLlJbrhVyZDYDvQ9+TvsBqEc0zay51KScm4hDph1y5p15IfypBpj8hEKu29dhH04lOVPw1EHzwnNmGTESTWwyYWG5vA97qPCcpjnaCs9U5Z/dL0WfihlNFNEQYmGkAbY8bwyjLSFAO7n/ecg8kJtCn77aBj/Z9YXmI7sKkXjMuiY25L5VOcQHVKTd1MTJpHbbN8JaMb9ax/7jdTsvwJVsOM5QW69SVheYntAO8XEYH2VaMV0ismi9uIpJVye8rFFGw8YqV5RlYLNUBvqWzyrWhCCh4h2t7ZN0BhF8w8ctou/0cok2+Odgb2c0Bi9fFpQopyP/OVMp/uvvCG8TJqIATtMc8o+uD18Ojh7uzdt1b7PMMkGPXZFr6HRw+4ifxU5wrl/Sq+TKaBP22QQ+fHrKzr6u57w7cHJ9AMqtdEvnNPm8TJS3jGg/xQHz3OTao8VcpQOQkjaSIsFUPV9kyWZZNW/qg4O9DBebS1szpoq4O/heRVpvsRrG4Cs8oZO2V0TJ2eoDpVTeHfN6NrXKDqWpBo5+d5TnADOl/pDQL1875N7O9jTd0UPC6uer6CyM2QRsk3cL2BcTkWT+RgnKnzVxSqQnt6tv6Fyp8tZRzdf1VkVRolGk9u/7vqw6A3KbTjL+1vH367iAbk0NZLEF5W59OiQPgNJw+8+0Z2DV9JUQ8uL2+ToHzfEmWnJ72w1x55VC9f0vdR7Of1PfVCTtQxwubBITwxXCW3gUOmfpBMeTSmiXU6QRwnVtSJzke9q6Lu4oOdMsd6Fbka6G0KkVEgbGQTQdztkxThuG8a6ARhMlG7bZvuctB9+cZHwH5DCaOFEvjJdIQwuAbMMUMgINAfD8UD41yo6dHaRgNb0reSzK+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"})}));
|
8
8
|
//# sourceMappingURL=coinley-checkout.umd.js.map
|