(function(zr,me){typeof exports=="object"&&typeof module<"u"?me(exports):typeof define=="function"&&define.amd?define(["exports"],me):(zr=typeof globalThis<"u"?globalThis:zr||self,me(zr.Decom={}))})(this,function(zr){"use strict";const me="https://api.decompay.xyz";let so="";const X1=r=>{so=r};if(typeof process<"u"&&process.env.NODE_ENV==="production"&&me==="http://localhost:3000")throw new Error("API_URL is not set");const BA=async r=>Pr(`${me}/invoice/create`,r),FA=async r=>Pr(`${me}/invoice/create/pay`,r),MA=async r=>Pr(`${me}/subscription/create`,r),jA=async r=>Pr(`${me}/subscription/create/subscribe`,r),tm=async(r,t)=>ki(`${me}/subscription/create/tx/${t}?network=${r}`),em=async(r,t)=>ki(`${me}/invoice/create/tx/${t}?network=${r}`),HA=async r=>Pr(`${me}/subscription`,r),zA=async r=>Pr(`${me}/subscription/update`,r),VA=async r=>Pr(`${me}/subscription/subscribe`,r),GA=async r=>Pr(`${me}/subscription/unsubscribe`,r),qA=async r=>Pr(`${me}/invoice/payment`,r),WA=async r=>ki(`${me}/merchant/subscription/${r.creator}?network=${r.network}`),rm=async r=>ki(`${me}/merchant/invoice/${r.creator}?network=${r.network}`),KA=async r=>Pr(`${me}/invoice`,r),QA=async r=>Pr(`${me}/subscription/subscribers`,r),JA=async r=>Pr(`${me}/subscription/payments`,r),YA=async r=>Pr(`${me}/merchant/fee`,r),ZA=async r=>Pr(`${me}/merchant/fee/update`,r),nm=async r=>Pr(`${me}/cryptos/allowance`,r),na=async r=>Pr(`${me}/cryptos/approve`,r),XA=async r=>Pr(`${me}/withdraw`,r),t5=async r=>ki(r?`${me}/cryptos?network=${r}`:`${me}/cryptos`),e5=async r=>ki(`${me}/networks/${r}/details`),r5=async()=>ki(`${me}/networks`),n5=async r=>Pr(`${me}/merchant/webhook`,r),i5=async r=>ki(`${me}/merchant/webhook?network=${r.network}&address=${r.address}`),s5=async(r,t)=>Pr(`${me}/merchant/webhook/${r}`,t),o5=async r=>a5(`${me}/merchant/webhook/${r}`),Pr=async(r,t)=>{if(so==="")throw new Error("Must call setAuthToken before calling SDK methods");return(await fetch(r,{mode:"cors",method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json","x-token":so}})).json()},ki=async r=>{if(so==="")throw new Error("Must call setAuthToken before calling SDK methods");return(await fetch(r,{mode:"cors",headers:{"Content-Type":"application/json","x-token":so}})).json()},a5=async r=>{if(so==="")throw new Error("Must call setAuthToken before calling SDK methods");return(await fetch(r,{mode:"cors",method:"DELETE",headers:{"Content-Type":"application/json","x-token":so}})).json()};class ia{static async allowance(t,e,n,i=!0){const{error:s,wei:a,eth:l}=await nm({network:e,crypto:n,address:t});if(s)throw new Error(s);return i?l:a}static async approve(t,e,n,i){const{error:s,to:a,data:l,chainId:u}=await na({network:e,crypto:n,amount:i});if(s)throw new Error(s);return t.sendTransaction({to:a,data:l,chainId:u})}static async tokenDecimals(t,e){const n=await t5(t),i=Object.values(n)[0].find(s=>s.symbol===e||s.address===e);if(!i)throw new Error("Token not found");return i.decimals}}class Ui{data;constructor(t){this.data=t}get id(){return this.data.id}get price(){return this.data.price}get fiat(){return(this.price/100).toFixed(2)}get network(){return this.data.chainId}get title(){return this.data.title}get description(){return this.data.description}get token(){return this.data.token}get chainId(){return this.data.chainId}static async create(t,e){const{error:n,to:i,data:s,chainId:a}=await BA(e);if(n)throw new Error(n);const l={to:i,data:s,chainId:a},u=await t.sendTransaction(l);function f(){let d=0;return new Promise(async(w,m)=>{if(!u.hash)return m("Transaction failed");const b=setInterval(async()=>{if(d>15)return clearInterval(b),m("Transaction failed");if(!u.hash)return m("Transaction failed");if((await u.wallet.provider?.getTransaction(u.hash))?.blockNumber){clearInterval(b);const{error:C,id:R}=await em(e.network,u.hash);return C?m(C):w(Ui.byId(e.network,R))}d++},2e3)})}return{hash:u.hash,wait:f}}static async createAndPay(t,e){const{error:n,to:i,data:s,chainId:a,token:l}=await FA(e);if(n)throw new Error(n);const u={to:i,data:s,chainId:a};if(l){const w=await ia.tokenDecimals(e.network,l),m=e.price/100*10**w,b=await t.allowance(e.network,l,!1);if(Number(b){if(!f.hash)return b("Transaction failed");const E=setInterval(async()=>{if(w>15)return clearInterval(E),b("Transaction failed");if(!f.hash)return b("Transaction failed");if((await f.wallet.provider?.getTransaction(f.hash))?.blockNumber){clearInterval(E);const{error:R,id:k}=await em(e.network,f.hash);return R?b(R):m(Ui.byId(e.network,k))}w++},2e3)})}return{hash:f.hash,wait:d}}static async byId(t,e){const{error:n,invoice:i}=await KA({network:t,id:e});if(n)throw new Error(n);return new Ui(i)}static async byCreator(t,e){const{error:n,invoices:i}=await rm({network:t,creator:e});if(n)throw new Error(n);return i.map(s=>new Ui(s))}static async byMerchant(t,e){const{error:n,invoices:i}=await rm({network:t,creator:e});if(n)throw new Error(n);return i.map(s=>new Ui(s))}async payment(t){const{error:e,to:n,data:i,chainId:s,token:a}=await qA({id:this.data.id,network:this.data.chainId});if(e)throw new Error(e);const l={to:n,data:i,chainId:s};if(a){const f=await ia.tokenDecimals(this.network,a),d=this.price/100*10**f,w=await t.allowance(this.network,a,!1);if(Number(w){if(!u.hash)return m("Transaction failed");const b=setInterval(async()=>{if(d>15)return clearInterval(b),m("Transaction failed");if(!u.hash)return m("Transaction failed");if((await u.wallet.provider?.getTransaction(u.hash))?.blockNumber){clearInterval(b);const{error:C,id:R}=await tm(e.network,u.hash);return C?m(C):w(Bi.byId(e.network,R))}d++},2e3)})}return{hash:u.hash,wait:f}}static async createAndSubscribe(t,e){const{error:n,to:i,data:s,chainId:a,token:l}=await jA(e);if(n)throw new Error(n);const u={to:i,data:s,chainId:a};if(l){const w=await ia.tokenDecimals(e.network,l),m=e.price/100*10**w,b=await t.allowance(e.network,l,!1);if(Number(b){if(!f.hash)return b("Transaction failed");const E=setInterval(async()=>{if(w>15)return clearInterval(E),b("Transaction failed");if(!f.hash)return b("Transaction failed");if((await f.wallet.provider?.getTransaction(f.hash))?.blockNumber){clearInterval(E);const{error:R,id:k}=await tm(e.network,f.hash);return R?b(R):m(Bi.byId(e.network,k))}w++},2e3)})}return{hash:f.hash,wait:d}}static async from(t,e){const{error:n,subs:i}=await WA({creator:t,network:e});if(n)throw new Error(n);return i.map(s=>new Bi(s))}static async byId(t,e){const{error:n,subscription:i}=await HA({id:e,network:t});if(n)throw new Error(n);return new Bi(i)}async update(t,e){const{error:n,to:i,data:s,chainId:a}=await zA({...e,id:this.id});if(n)throw new Error(n);const l={to:i,data:s,chainId:a},u=await t.sendTransaction(l);if(!u)throw new Error("Transaction failed");return u}async subscribe(t){const{error:e,to:n,data:i,chainId:s,token:a}=await VA({network:this.chainId,id:this.id,address:t.address});if(e)throw new Error(e);const l={to:n,data:i,chainId:s};if(a){const f=await ia.tokenDecimals(this.network,a),d=this.price/100*10**f,w=await t.allowance(this.network,a,!1);if(Number(w)s.trim());for(let s=0;sPromise.resolve(r[n])))).reduce((n,i,s)=>(n[t[s]]=i,n),{})}function Nt(r,t,e){for(let n in t){let i=t[n];const s=e?e[n]:null;s&&l5(i,s,n),Object.defineProperty(r,n,{enumerable:!0,value:i,writable:!1})}}function sa(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(sa).join(", ")+" ]";if(r instanceof Uint8Array){const t="0123456789abcdef";let e="0x";for(let n=0;n>4],e+=t[r[n]&15];return e}if(typeof r=="object"&&typeof r.toJSON=="function")return sa(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const t=Object.keys(r);return t.sort(),"{ "+t.map(e=>`${sa(e)}: ${sa(r[e])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Gn(r,t){return r&&r.code===t}function ad(r){return Gn(r,"CALL_EXCEPTION")}function Dr(r,t,e){{const i=[];if(e){if("message"in e||"code"in e||"name"in e)throw new Error(`value will overwrite populated values: ${sa(e)}`);for(const s in e){const a=e[s];i.push(s+"="+sa(a))}}i.push(`code=${t}`),i.push(`version=${c5}`),i.length&&(r+=" ("+i.join(", ")+")")}let n;switch(t){case"INVALID_ARGUMENT":n=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(r);break;default:n=new Error(r)}return Nt(n,{code:t}),e&&Object.assign(n,e),n}function ct(r,t,e,n){if(!r)throw Dr(t,e,n)}function q(r,t,e,n){ct(r,t,"INVALID_ARGUMENT",{argument:e,value:n})}function im(r,t,e){e==null&&(e=""),e&&(e=": "+e),ct(r>=t,"missing arguemnt"+e,"MISSING_ARGUMENT",{count:r,expectedCount:t}),ct(r<=t,"too many arguemnts"+e,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:t})}const u5=["NFD","NFC","NFKD","NFKC"].reduce((r,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"){const e=String.fromCharCode(233).normalize("NFD"),n=String.fromCharCode(101,769);if(e!==n)throw new Error("broken")}r.push(t)}catch{}return r},[]);function h5(r){ct(u5.indexOf(r)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:r}})}function mu(r,t,e){if(e==null&&(e=""),r!==t){let n=e,i="new";e&&(n+=".",i+=" "+e),ct(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function sm(r,t,e){if(r instanceof Uint8Array)return e?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x([0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let i=2;for(let s=0;s>4]+om[i&15]}return e}function br(r){return"0x"+r.map(t=>At(t).substring(2)).join("")}function oa(r){return Qe(r,!0)?(r.length-2)/2:ve(r).length}function rr(r,t,e){const n=ve(r);return e!=null&&e>n.length&&ct(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:e}),At(n.slice(t??0,e??n.length))}function am(r,t,e){const n=ve(r);ct(t>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:t,offset:t+1});const i=new Uint8Array(t);return i.fill(0),e?i.set(n,t-n.length):i.set(n,0),At(i)}function oo(r,t){return am(r,t,!0)}function d5(r,t){return am(r,t,!1)}const wu=BigInt(0),li=BigInt(1),aa=9007199254740991;function p5(r,t){const e=yu(r,"value"),n=BigInt(se(t,"width"));if(ct(e>>n===wu,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),e>>n-li){const i=(li<=-aa&&r<=aa,"overflow",t||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(e){q(!1,`invalid BigNumberish string: ${e.message}`,t||"value",r)}}q(!1,"invalid BigNumberish value",t||"value",r)}function yu(r,t){const e=It(r,t);return ct(e>=wu,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),e}const lm="0123456789abcdef";function cd(r){if(r instanceof Uint8Array){let t="0x0";for(const e of r)t+=lm[e>>4],t+=lm[e&15];return BigInt(t)}return It(r)}function se(r,t){switch(typeof r){case"bigint":return q(r>=-aa&&r<=aa,"overflow",t||"value",r),Number(r);case"number":return q(Number.isInteger(r),"underflow",t||"value",r),q(r>=-aa&&r<=aa,"overflow",t||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return se(BigInt(r),t)}catch(e){q(!1,`invalid numeric string: ${e.message}`,t||"value",r)}}q(!1,"invalid numeric value",t||"value",r)}function g5(r){return se(cd(r))}function ms(r,t){let n=yu(r,"value").toString(16);if(t==null)n.length%2&&(n="0"+n);else{const i=se(t,"width");for(ct(i*2>=n.length,`value exceeds width (${i} bits)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length>6===2;a++)s++;return s}return r==="OVERRUN"?e.length-t-1:0}function E5(r,t,e,n,i){return r==="OVERLONG"?(q(typeof i=="number","invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),fm(r,t,e))}const _5=Object.freeze({error:v5,ignore:fm,replace:E5});function A5(r,t){t==null&&(t=_5.error);const e=ve(r,"bytes"),n=[];let i=0;for(;i>7)){n.push(s);continue}let a=null,l=null;if((s&224)===192)a=1,l=127;else if((s&240)===224)a=2,l=2047;else if((s&248)===240)a=3,l=65535;else{(s&192)===128?i+=t("UNEXPECTED_CONTINUE",i-1,e,n):i+=t("BAD_PREFIX",i-1,e,n);continue}if(i-1+a>=e.length){i+=t("OVERRUN",i-1,e,n);continue}let u=s&(1<<8-a-1)-1;for(let f=0;f1114111){i+=t("OUT_OF_RANGE",i-1-a,e,n,u);continue}if(u>=55296&&u<=57343){i+=t("UTF16_SURROGATE",i-1-a,e,n,u);continue}if(u<=l){i+=t("OVERLONG",i-1-a,e,n,u);continue}n.push(u)}}return n}function Fi(r,t){t!=null&&(h5(t),r=r.normalize(t));let e=[];for(let n=0;n>6|192),e.push(i&63|128);else if((i&64512)==55296){n++;const s=r.charCodeAt(n);q(n>18|240),e.push(a>>12&63|128),e.push(a>>6&63|128),e.push(a&63|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(i&63|128)}return new Uint8Array(e)}function x5(r){return r.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function ld(r,t){return x5(A5(r,t))}async function I5(r,t){const e=r.url.split(":")[0].toLowerCase();ct(e==="http"||e==="https",`unsupported protocol ${e}`,"UNSUPPORTED_OPERATION",{info:{protocol:e},operation:"request"}),ct(e==="https"||!r.credentials||r.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let n;if(t){const f=new AbortController;n=f.signal,t.addListener(()=>{f.abort()})}const i={method:r.method,headers:new Headers(Array.from(r)),body:r.body||void 0,signal:n},s=await fetch(r.url,i),a={};s.headers.forEach((f,d)=>{a[d.toLowerCase()]=f});const l=await s.arrayBuffer(),u=l==null?null:new Uint8Array(l);return{statusCode:s.status,statusMessage:s.statusText,headers:a,body:u}}const C5=12,S5=250;let dm=I5;const O5=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),P5=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let ud=!1;async function pm(r,t){try{const e=r.match(O5);if(!e)throw new Error("invalid data");return new ws(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?y5(e[3]):T5(e[3]))}catch{return new ws(599,"BAD REQUEST (invalid data: URI)",{},null,new Mi(r))}}function gm(r){async function t(e,n){try{const i=e.match(P5);if(!i)throw new Error("invalid link");return new Mi(`${r}${i[2]}`)}catch{return new ws(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Mi(e))}}return t}const bu={data:pm,ipfs:gm("https://gateway.ipfs.io/ipfs/")},mm=new WeakMap;class D5{#t;#e;constructor(t){this.#t=[],this.#e=!1,mm.set(t,()=>{if(!this.#e){this.#e=!0;for(const e of this.#t)setTimeout(()=>{e()},0);this.#t=[]}})}addListener(t){ct(!this.#e,"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),this.#t.push(t)}get cancelled(){return this.#e}checkSignal(){ct(!this.cancelled,"cancelled","CANCELLED",{})}}function vu(r){if(r==null)throw new Error("missing signal; should not happen");return r.checkSignal(),r}class Mi{#t;#e;#r;#n;#i;#s;#o;#a;#u;#l;#h;#f;#c;#d;get url(){return this.#s}set url(t){this.#s=String(t)}get body(){return this.#o==null?null:new Uint8Array(this.#o)}set body(t){if(t==null)this.#o=void 0,this.#a=void 0;else if(typeof t=="string")this.#o=Fi(t),this.#a="text/plain";else if(t instanceof Uint8Array)this.#o=t,this.#a="application/octet-stream";else if(typeof t=="object")this.#o=Fi(JSON.stringify(t)),this.#a="application/json";else throw new Error("invalid body")}hasBody(){return this.#o!=null}get method(){return this.#n?this.#n:this.hasBody()?"POST":"GET"}set method(t){t==null&&(t=""),this.#n=String(t).toUpperCase()}get headers(){const t=Object.assign({},this.#r);return this.#u&&(t.authorization=`Basic ${b5(Fi(this.#u))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),t["content-type"]==null&&this.#a&&(t["content-type"]=this.#a),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){this.#r[String(t).toLowerCase()]=String(e)}clearHeaders(){this.#r={}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let n=0;return{next:()=>{if(n=0,"timeout must be non-zero","timeout",t),this.#i=t}get preflightFunc(){return this.#l||null}set preflightFunc(t){this.#l=t}get processFunc(){return this.#h||null}set processFunc(t){this.#h=t}get retryFunc(){return this.#f||null}set retryFunc(t){this.#f=t}constructor(t){this.#s=String(t),this.#t=!1,this.#e=!0,this.#r={},this.#n="",this.#i=3e5,this.#d={slotInterval:S5,maxAttempts:C5}}toString(){return``}setThrottleParams(t){t.slotInterval!=null&&(this.#d.slotInterval=t.slotInterval),t.maxAttempts!=null&&(this.#d.maxAttempts=t.maxAttempts)}async#p(t,e,n,i,s){if(t>=this.#d.maxAttempts)return s.makeServerError("exceeded maximum retry limit");ct(wm()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:i}),n>0&&await N5(n);let a=this.clone();const l=(a.url.split(":")[0]||"").toLowerCase();if(l in bu){const d=await bu[l](a.url,vu(i.#c));if(d instanceof ws){let w=d;if(this.processFunc){vu(i.#c);try{w=await this.processFunc(a,w)}catch(m){(m.throttle==null||typeof m.stall!="number")&&w.makeServerError("error in post-processing function",m).assertOk()}}return w}a=d}this.preflightFunc&&(a=await this.preflightFunc(a));const u=await dm(a,vu(i.#c));let f=new ws(u.statusCode,u.statusMessage,u.headers,u.body,i);if(f.statusCode===301||f.statusCode===302){try{const d=f.headers.location||"";return a.redirect(d).#p(t+1,e,0,i,f)}catch{}return f}else if(f.statusCode===429&&(this.retryFunc==null||await this.retryFunc(a,f,t))){const d=f.headers["retry-after"];let w=this.#d.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return typeof d=="string"&&d.match(/^[1-9][0-9]*$/)&&(w=parseInt(d)),a.clone().#p(t+1,e,w,i,f)}if(this.processFunc){vu(i.#c);try{f=await this.processFunc(a,f)}catch(d){(d.throttle==null||typeof d.stall!="number")&&f.makeServerError("error in post-processing function",d).assertOk();let w=this.#d.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return d.stall>=0&&(w=d.stall),a.clone().#p(t+1,e,w,i,f)}}return f}send(){return ct(this.#c==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),this.#c=new D5(this),this.#p(0,wm()+this.timeout,0,this,new ws(0,"",{},null,this))}cancel(){ct(this.#c!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=mm.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),n=t.split(":")[0].toLowerCase();ct(this.method==="GET"&&(e!=="https"||n!=="http")&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const i=new Mi(t);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,i.#r=Object.assign({},this.#r),this.#o&&(i.#o=new Uint8Array(this.#o)),i.#a=this.#a,i}clone(){const t=new Mi(this.url);return t.#n=this.#n,this.#o&&(t.#o=this.#o),t.#a=this.#a,t.#r=Object.assign({},this.#r),t.#u=this.#u,this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),t.#l=this.#l,t.#h=this.#h,t.#f=this.#f,t}static lockConfig(){ud=!0}static getGateway(t){return bu[t.toLowerCase()]||null}static registerGateway(t,e){if(t=t.toLowerCase(),t==="http"||t==="https")throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(ud)throw new Error("gateways locked");bu[t]=e}static registerGetUrl(t){if(ud)throw new Error("gateways locked");dm=t}static createDataGateway(){return pm}static createIpfsGatewayFunc(t){return gm(t)}}class ws{#t;#e;#r;#n;#i;#s;toString(){return``}get statusCode(){return this.#t}get statusMessage(){return this.#e}get headers(){return Object.assign({},this.#r)}get body(){return this.#n==null?null:new Uint8Array(this.#n)}get bodyText(){try{return this.#n==null?"":ld(this.#n)}catch{ct(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ct(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let n=0;return{next:()=>{if(n(a[l.toLowerCase()]=String(n[l]),a),{}),this.#n=i==null?null:new Uint8Array(i),this.#i=s||null,this.#s={message:""}}makeServerError(t,e){let n;t?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:(t=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${t})`);const i=new ws(599,n,this.headers,this.body,this.#i||void 0);return i.#s={message:t,error:e},i}throwThrottleError(t,e){e==null?e=-1:q(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const n=new Error(t||"throttling requests");throw Nt(n,{stall:e,throttle:!0}),n}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return this.#n!=null}get request(){return this.#i}ok(){return this.#s.message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=this.#s;t===""&&(t=`server response ${this.statusCode} ${this.statusMessage}`),ct(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e})}}function wm(){return new Date().getTime()}function T5(r){return Fi(r.replace(/%([0-9a-f][0-9a-f])/gi,(t,e)=>String.fromCharCode(parseInt(e,16))))}function N5(r){return new Promise(t=>setTimeout(t,r))}function R5(r){let t=r.toString(16);for(;t.length<2;)t="0"+t;return"0x"+t}function ym(r,t,e){let n=0;for(let i=0;i{ct(n<=r.length,"data short segment too short","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n})};if(r[t]>=248){const n=r[t]-247;e(t+1+n);const i=ym(r,t+1,n);return e(t+1+n+i),bm(r,t,t+1+n,n+i)}else if(r[t]>=192){const n=r[t]-192;return e(t+1+n),bm(r,t,t+1,n)}else if(r[t]>=184){const n=r[t]-183;e(t+1+n);const i=ym(r,t+1,n);e(t+1+n+i);const s=At(r.slice(t+1+n,t+1+n+i));return{consumed:1+n+i,result:s}}else if(r[t]>=128){const n=r[t]-128;e(t+1+n);const i=At(r.slice(t+1,t+1+n));return{consumed:1+n,result:i}}return{consumed:1,result:R5(r[t])}}function hd(r){const t=ve(r,"data"),e=vm(t,0);return q(e.consumed===t.length,"unexpected junk after rlp payload","data",r),e.result}function Em(r){const t=[];for(;r;)t.unshift(r&255),r>>=8;return t}function _m(r){if(Array.isArray(r)){let n=[];if(r.forEach(function(s){n=n.concat(_m(s))}),n.length<=55)return n.unshift(192+n.length),n;const i=Em(n.length);return i.unshift(247+i.length),i.concat(n)}const t=Array.prototype.slice.call(ve(r,"object"));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const e=Em(t.length);return e.unshift(183+e.length),e.concat(t)}const Am="0123456789abcdef";function _c(r){let t="0x";for(const e of _m(r))t+=Am[e>>4],t+=Am[e&15];return t}const Yr=32,fd=new Uint8Array(Yr),L5=["then"],Eu={};function Ac(r,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw e.error=t,e}class la extends Array{#t;constructor(...t){const e=t[0];let n=t[1],i=(t[2]||[]).slice(),s=!0;e!==Eu&&(n=t,i=[],s=!1),super(n.length),n.forEach((l,u)=>{this[u]=l});const a=i.reduce((l,u)=>(typeof u=="string"&&l.set(u,(l.get(u)||0)+1),l),new Map);if(this.#t=Object.freeze(n.map((l,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null})),!!s)return Object.freeze(this),new Proxy(this,{get:(l,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const w=se(u,"%index");if(w<0||w>=this.length)throw new RangeError("out of result range");const m=l[w];return m instanceof Error&&Ac(`index ${w}`,m),m}if(L5.indexOf(u)>=0)return Reflect.get(l,u,f);const d=l[u];if(d instanceof Function)return function(...w){return d.apply(this===f?l:this,w)};if(!(u in l))return l.getValue.apply(this===f?l:this,[u])}return Reflect.get(l,u,f)}})}toArray(){const t=[];return this.forEach((e,n)=>{e instanceof Error&&Ac(`index ${n}`,e),t.push(e)}),t}toObject(){return this.#t.reduce((t,e,n)=>(ct(e!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),e in t||(t[e]=this.getValue(e)),t),{})}slice(t,e){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),e==null&&(e=this.length),e<0&&(e+=this.length,e<0&&(e=0)),e>this.length&&(e=this.length);const n=[],i=[];for(let s=t;s{this.#t[t]=xm(e)}}}class pd{allowLoose;#t;#e;constructor(t,e){Nt(this,{allowLoose:!!e}),this.#t=fn(t),this.#e=0}get data(){return At(this.#t)}get dataLength(){return this.#t.length}get consumed(){return this.#e}get bytes(){return new Uint8Array(this.#t)}#r(t,e,n){let i=Math.ceil(e/Yr)*Yr;return this.#e+i>this.#t.length&&(this.allowLoose&&n&&this.#e+e<=this.#t.length?i=e:ct(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:fn(this.#t),length:this.#t.length,offset:this.#e+i})),this.#t.slice(this.#e,this.#e+i)}subReader(t){return new pd(this.#t.slice(this.#e+t),this.allowLoose)}readBytes(t,e){let n=this.#r(0,t,!!e);return this.#e+=n.length,n.slice(0,t)}readValue(){return cd(this.readBytes(Yr))}readIndex(){return g5(this.readBytes(Yr))}}const Te=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{};function gd(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function $5(r){if(typeof r!="boolean")throw new Error(`Expected boolean, not ${r}`)}function Im(r,...t){if(!(r instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function k5(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");gd(r.outputLen),gd(r.blockLen)}function U5(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function B5(r,t){Im(r);const e=t.outputLen;if(r.lengthnew Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),md=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),vi=(r,t)=>r<<32-t|r>>>t;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function M5(r){if(typeof r!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof r}`);return new TextEncoder().encode(r)}function xc(r){if(typeof r=="string"&&(r=M5(r)),!(r instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof r})`);return r}class _u{clone(){return this._cloneInto()}}function Ic(r){const t=n=>r().update(xc(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function j5(r){const t=(n,i)=>r(i).update(xc(n)).digest(),e=r({});return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}let Cm=class extends _u{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Dn.hash(t);const n=xc(e);if(this.iHash=t.create(),!(this.iHash instanceof _u))throw new TypeError("Expected instance of class which extends utils.Hash");const i=this.blockLen=this.iHash.blockLen;this.outputLen=this.iHash.outputLen;const s=new Uint8Array(i);s.set(n.length>this.iHash.blockLen?t.create().update(n).digest():n);for(let a=0;anew Cm(r,t).update(e).digest();Sm.create=(r,t)=>new Cm(r,t);function H5(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);const i=BigInt(32),s=BigInt(4294967295),a=Number(e>>i&s),l=Number(e&s),u=n?4:0,f=n?0:4;r.setUint32(t+u,a,n),r.setUint32(t+f,l,n)}class Om extends _u{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=md(this.buffer)}update(t){Dn.exists(this);const{view:e,buffer:n,blockLen:i}=this;t=xc(t);const s=t.length;for(let a=0;ai-a&&(this.process(n,0),a=0);for(let u=a;ul.setUint32(4*f,u,s))}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:i,finished:s,destroyed:a,pos:l}=this;return t.length=i,t.pos=l,t.finished=s,t.destroyed=a,i%e&&t.buffer.set(n),t}}const z5=(r,t,e)=>r&t^~r&e,V5=(r,t,e)=>r&t^r&e^t&e,G5=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ys=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),bs=new Uint32Array(64);class q5 extends Om{constructor(){super(64,32,8,!1),this.A=ys[0]|0,this.B=ys[1]|0,this.C=ys[2]|0,this.D=ys[3]|0,this.E=ys[4]|0,this.F=ys[5]|0,this.G=ys[6]|0,this.H=ys[7]|0}get(){const{A:t,B:e,C:n,D:i,E:s,F:a,G:l,H:u}=this;return[t,e,n,i,s,a,l,u]}set(t,e,n,i,s,a,l,u){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=l|0,this.H=u|0}process(t,e){for(let w=0;w<16;w++,e+=4)bs[w]=t.getUint32(e,!1);for(let w=16;w<64;w++){const m=bs[w-15],b=bs[w-2],E=vi(m,7)^vi(m,18)^m>>>3,C=vi(b,17)^vi(b,19)^b>>>10;bs[w]=C+bs[w-7]+E+bs[w-16]|0}let{A:n,B:i,C:s,D:a,E:l,F:u,G:f,H:d}=this;for(let w=0;w<64;w++){const m=vi(l,6)^vi(l,11)^vi(l,25),b=d+m+z5(l,u,f)+G5[w]+bs[w]|0,C=(vi(n,2)^vi(n,13)^vi(n,22))+V5(n,i,s)|0;d=f,f=u,u=l,l=a+b|0,a=s,s=i,i=n,n=b+C|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+this.D|0,l=l+this.E|0,u=u+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,a,l,u,f,d)}roundClean(){bs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const W5=Ic(()=>new q5),Au=BigInt(2**32-1),wd=BigInt(32);function Pm(r,t=!1){return t?{h:Number(r&Au),l:Number(r>>wd&Au)}:{h:Number(r>>wd&Au)|0,l:Number(r&Au)|0}}function K5(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;iBigInt(r>>>0)<>>0),J5=(r,t,e)=>r>>>e,Y5=(r,t,e)=>r<<32-e|t>>>e,Z5=(r,t,e)=>r>>>e|t<<32-e,X5=(r,t,e)=>r<<32-e|t>>>e,t6=(r,t,e)=>r<<64-e|t>>>e-32,e6=(r,t,e)=>r>>>e-32|t<<64-e,r6=(r,t)=>t,n6=(r,t)=>r,i6=(r,t,e)=>r<>>32-e,s6=(r,t,e)=>t<>>32-e,o6=(r,t,e)=>t<>>64-e,a6=(r,t,e)=>r<>>64-e;function c6(r,t,e,n){const i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}const Ut={fromBig:Pm,split:K5,toBig:Q5,shrSH:J5,shrSL:Y5,rotrSH:Z5,rotrSL:X5,rotrBH:t6,rotrBL:e6,rotr32H:r6,rotr32L:n6,rotlSH:i6,rotlSL:s6,rotlBH:o6,rotlBL:a6,add:c6,add3L:(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),add3H:(r,t,e,n)=>t+e+n+(r/2**32|0)|0,add4L:(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),add4H:(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,add5H:(r,t,e,n,i,s)=>t+e+n+i+s+(r/2**32|0)|0,add5L:(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0)},[l6,u6]=Ut.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),vs=new Uint32Array(80),Es=new Uint32Array(80);class yd extends Om{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:n,Bl:i,Ch:s,Cl:a,Dh:l,Dl:u,Eh:f,El:d,Fh:w,Fl:m,Gh:b,Gl:E,Hh:C,Hl:R}=this;return[t,e,n,i,s,a,l,u,f,d,w,m,b,E,C,R]}set(t,e,n,i,s,a,l,u,f,d,w,m,b,E,C,R){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=a|0,this.Dh=l|0,this.Dl=u|0,this.Eh=f|0,this.El=d|0,this.Fh=w|0,this.Fl=m|0,this.Gh=b|0,this.Gl=E|0,this.Hh=C|0,this.Hl=R|0}process(t,e){for(let P=0;P<16;P++,e+=4)vs[P]=t.getUint32(e),Es[P]=t.getUint32(e+=4);for(let P=16;P<80;P++){const I=vs[P-15]|0,T=Es[P-15]|0,A=Ut.rotrSH(I,T,1)^Ut.rotrSH(I,T,8)^Ut.shrSH(I,T,7),p=Ut.rotrSL(I,T,1)^Ut.rotrSL(I,T,8)^Ut.shrSL(I,T,7),_=vs[P-2]|0,M=Es[P-2]|0,F=Ut.rotrSH(_,M,19)^Ut.rotrBH(_,M,61)^Ut.shrSH(_,M,6),K=Ut.rotrSL(_,M,19)^Ut.rotrBL(_,M,61)^Ut.shrSL(_,M,6),st=Ut.add4L(p,K,Es[P-7],Es[P-16]),lt=Ut.add4H(st,A,F,vs[P-7],vs[P-16]);vs[P]=lt|0,Es[P]=st|0}let{Ah:n,Al:i,Bh:s,Bl:a,Ch:l,Cl:u,Dh:f,Dl:d,Eh:w,El:m,Fh:b,Fl:E,Gh:C,Gl:R,Hh:k,Hl:D}=this;for(let P=0;P<80;P++){const I=Ut.rotrSH(w,m,14)^Ut.rotrSH(w,m,18)^Ut.rotrBH(w,m,41),T=Ut.rotrSL(w,m,14)^Ut.rotrSL(w,m,18)^Ut.rotrBL(w,m,41),A=w&b^~w&C,p=m&E^~m&R,_=Ut.add5L(D,T,p,u6[P],Es[P]),M=Ut.add5H(_,k,I,A,l6[P],vs[P]),F=_|0,K=Ut.rotrSH(n,i,28)^Ut.rotrBH(n,i,34)^Ut.rotrBH(n,i,39),st=Ut.rotrSL(n,i,28)^Ut.rotrBL(n,i,34)^Ut.rotrBL(n,i,39),lt=n&s^n&l^s&l,S=i&a^i&u^a&u;k=C|0,D=R|0,C=b|0,R=E|0,b=w|0,E=m|0,{h:w,l:m}=Ut.add(f|0,d|0,M|0,F|0),f=l|0,d=u|0,l=s|0,u=a|0,s=n|0,a=i|0;const $=Ut.add3L(F,st,S);n=Ut.add3H($,M,K,lt),i=$|0}({h:n,l:i}=Ut.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:a}=Ut.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:l,l:u}=Ut.add(this.Ch|0,this.Cl|0,l|0,u|0),{h:f,l:d}=Ut.add(this.Dh|0,this.Dl|0,f|0,d|0),{h:w,l:m}=Ut.add(this.Eh|0,this.El|0,w|0,m|0),{h:b,l:E}=Ut.add(this.Fh|0,this.Fl|0,b|0,E|0),{h:C,l:R}=Ut.add(this.Gh|0,this.Gl|0,C|0,R|0),{h:k,l:D}=Ut.add(this.Hh|0,this.Hl|0,k|0,D|0),this.set(n,i,s,a,l,u,f,d,w,m,b,E,C,R,k,D)}roundClean(){vs.fill(0),Es.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class h6 extends yd{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class f6 extends yd{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const d6=Ic(()=>new yd);Ic(()=>new h6),Ic(()=>new f6);function p6(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof Te<"u")return Te;throw new Error("unable to locate global object")}const Dm=p6();Dm.crypto||Dm.msCrypto;function g6(r,t){const e={sha256:W5,sha512:d6}[r];return q(e!=null,"invalid hmac algorithm","algorithm",r),Sm.create(e,t)}let Tm=!1;const Nm=function(r,t,e){return g6(r,t).update(e).digest()};let Rm=Nm;function Cc(r,t,e){const n=ve(t,"key"),i=ve(e,"data");return At(Rm(r,n,i))}Cc._=Nm,Cc.lock=function(){Tm=!0},Cc.register=function(r){if(Tm)throw new Error("computeHmac is locked");Rm=r},Object.freeze(Cc);const[Lm,$m,km]=[[],[],[]],m6=BigInt(0),Sc=BigInt(1),w6=BigInt(2),y6=BigInt(7),b6=BigInt(256),v6=BigInt(113);for(let r=0,t=Sc,e=1,n=0;r<24;r++){[e,n]=[n,(2*e+3*n)%5],Lm.push(2*(5*n+e)),$m.push((r+1)*(r+2)/2%64);let i=m6;for(let s=0;s<7;s++)t=(t<>y6)*v6)%b6,t&w6&&(i^=Sc<<(Sc<e>32?Ut.rotlBH(r,t,e):Ut.rotlSH(r,t,e),Bm=(r,t,e)=>e>32?Ut.rotlBL(r,t,e):Ut.rotlSL(r,t,e);function A6(r,t=24){const e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let a=0;a<10;a++)e[a]=r[a]^r[a+10]^r[a+20]^r[a+30]^r[a+40];for(let a=0;a<10;a+=2){const l=(a+8)%10,u=(a+2)%10,f=e[u],d=e[u+1],w=Um(f,d,1)^e[l],m=Bm(f,d,1)^e[l+1];for(let b=0;b<50;b+=10)r[a+b]^=w,r[a+b+1]^=m}let i=r[2],s=r[3];for(let a=0;a<24;a++){const l=$m[a],u=Um(i,s,l),f=Bm(i,s,l),d=Lm[a];i=r[d],s=r[d+1],r[d]=u,r[d+1]=f}for(let a=0;a<50;a+=10){for(let l=0;l<10;l++)e[l]=r[a+l];for(let l=0;l<10;l++)r[a+l]^=~e[(l+2)%10]&e[(l+4)%10]}r[0]^=E6[n],r[1]^=_6[n]}e.fill(0)}class xu extends _u{constructor(t,e,n,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Dn.number(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=F5(this.state)}keccak(){A6(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Dn.exists(this);const{blockLen:e,state:n}=this;t=xc(t);const i=t.length;for(let s=0;s=n&&this.keccak();const a=Math.min(n-this.posOut,s-i);t.set(e.subarray(this.posOut,this.posOut+a),i),this.posOut+=a,i+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Dn.number(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Dn.output(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:i,rounds:s,enableXOF:a}=this;return t||(t=new xu(e,n,i,a,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=i,t.enableXOF=a,t.destroyed=this.destroyed,t}}const _s=(r,t,e)=>Ic(()=>new xu(t,r,e));_s(6,144,224/8),_s(6,136,256/8),_s(6,104,384/8),_s(6,72,512/8),_s(1,144,224/8);const x6=_s(1,136,256/8);_s(1,104,384/8),_s(1,72,512/8);const Fm=(r,t,e)=>j5((n={})=>new xu(t,r,n.dkLen===void 0?e:n.dkLen,!0));Fm(31,168,128/8),Fm(31,136,256/8);let Mm=!1;const jm=function(r){return x6(r)};let Hm=jm;function Je(r){const t=ve(r,"data");return At(Hm(t))}Je._=jm,Je.lock=function(){Mm=!0},Je.register=function(r){if(Mm)throw new TypeError("keccak256 is locked");Hm=r},Object.freeze(Je);const zm=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const Ee=BigInt(0),ze=BigInt(1),As=BigInt(2),Oc=BigInt(3),Vm=BigInt(8),fr=Object.freeze({a:Ee,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:ze,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Gm=(r,t)=>(r+t/As)/t,Iu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(r){const{n:t}=fr,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ze*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,a=BigInt("0x100000000000000000000000000000000"),l=Gm(s*r,t),u=Gm(-n*r,t);let f=bt(r-l*e-u*i,t),d=bt(-l*n-u*s,t);const w=f>a,m=d>a;if(w&&(f=t-f),m&&(d=t-d),f>a||d>a)throw new Error("splitScalarEndo: Endomorphism failed, k="+r);return{k1neg:w,k1:f,k2neg:m,k2:d}}},ui=32,ua=32,I6=32,Cu=ui+1,Su=2*ui+1;function qm(r){const{a:t,b:e}=fr,n=bt(r*r),i=bt(n*r);return bt(i+t*r+e)}const Ou=fr.a===Ee;class Wm extends Error{constructor(t){super(t)}}function Km(r){if(!(r instanceof Ae))throw new TypeError("JacobianPoint expected")}class Ae{constructor(t,e,n){this.x=t,this.y=e,this.z=n}static fromAffine(t){if(!(t instanceof Se))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(Se.ZERO)?Ae.ZERO:new Ae(t.x,t.y,ze)}static toAffineBatch(t){const e=D6(t.map(n=>n.z));return t.map((n,i)=>n.toAffine(e[i]))}static normalizeZ(t){return Ae.toAffineBatch(t).map(Ae.fromAffine)}equals(t){Km(t);const{x:e,y:n,z:i}=this,{x:s,y:a,z:l}=t,u=bt(i*i),f=bt(l*l),d=bt(e*f),w=bt(s*u),m=bt(bt(n*l)*f),b=bt(bt(a*i)*u);return d===w&&m===b}negate(){return new Ae(this.x,bt(-this.y),this.z)}double(){const{x:t,y:e,z:n}=this,i=bt(t*t),s=bt(e*e),a=bt(s*s),l=t+s,u=bt(As*(bt(l*l)-i-a)),f=bt(Oc*i),d=bt(f*f),w=bt(d-As*u),m=bt(f*(u-w)-Vm*a),b=bt(As*e*n);return new Ae(w,m,b)}add(t){Km(t);const{x:e,y:n,z:i}=this,{x:s,y:a,z:l}=t;if(s===Ee||a===Ee)return this;if(e===Ee||n===Ee)return t;const u=bt(i*i),f=bt(l*l),d=bt(e*f),w=bt(s*u),m=bt(bt(n*l)*f),b=bt(bt(a*i)*u),E=bt(w-d),C=bt(b-m);if(E===Ee)return C===Ee?this.double():Ae.ZERO;const R=bt(E*E),k=bt(E*R),D=bt(d*R),P=bt(C*C-k-As*D),I=bt(C*(D-P)-m*k),T=bt(i*l*E);return new Ae(P,I,T)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=Ae.ZERO;if(typeof t=="bigint"&&t===Ee)return e;let n=Ym(t);if(n===ze)return this;if(!Ou){let w=e,m=this;for(;n>Ee;)n&ze&&(w=w.add(m)),m=m.double(),n>>=ze;return w}let{k1neg:i,k1:s,k2neg:a,k2:l}=Iu.splitScalar(n),u=e,f=e,d=this;for(;s>Ee||l>Ee;)s&ze&&(u=u.add(d)),l&ze&&(f=f.add(d)),d=d.double(),s>>=ze,l>>=ze;return i&&(u=u.negate()),a&&(f=f.negate()),f=new Ae(bt(f.x*Iu.beta),f.y,f.z),u.add(f)}precomputeWindow(t){const e=Ou?128/t+1:256/t+1,n=[];let i=this,s=i;for(let a=0;a>=w,E>u&&(E-=d,t+=ze);const C=b,R=b+Math.abs(E)-1,k=m%2!==0,D=E<0;E===0?a=a.add(Pu(k,i[C])):s=s.add(Pu(D,i[R]))}return{p:s,f:a}}multiply(t,e){let n=Ym(t),i,s;if(Ou){const{k1neg:a,k1:l,k2neg:u,k2:f}=Iu.splitScalar(n);let{p:d,f:w}=this.wNAF(l,e),{p:m,f:b}=this.wNAF(f,e);d=Pu(a,d),m=Pu(u,m),m=new Ae(bt(m.x*Iu.beta),m.y,m.z),i=d.add(m),s=w.add(b)}else{const{p:a,f:l}=this.wNAF(n,e);i=a,s=l}return Ae.normalizeZ([i,s])[0]}toAffine(t){const{x:e,y:n,z:i}=this,s=this.equals(Ae.ZERO);t==null&&(t=s?Vm:Tc(i));const a=t,l=bt(a*a),u=bt(l*a),f=bt(e*l),d=bt(n*u),w=bt(i*a);if(s)return Se.ZERO;if(w!==ze)throw new Error("invZ was invalid");return new Se(f,d)}}Ae.BASE=new Ae(fr.Gx,fr.Gy,ze),Ae.ZERO=new Ae(Ee,ze,Ee);function Pu(r,t){const e=t.negate();return r?e:t}const bd=new WeakMap;class Se{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,bd.delete(this)}hasEvenY(){return this.y%As===Ee}static fromCompressedHex(t){const e=t.length===32,n=Is(e?t:t.subarray(1));if(!Ed(n))throw new Error("Point is not on curve");const i=qm(n);let s=P6(i);const a=(s&ze)===ze;e?a&&(s=bt(-s)):(t[0]&1)===1!==a&&(s=bt(-s));const l=new Se(n,s);return l.assertValidity(),l}static fromUncompressedHex(t){const e=Is(t.subarray(1,ui+1)),n=Is(t.subarray(ui+1,ui*2+1)),i=new Se(e,n);return i.assertValidity(),i}static fromHex(t){const e=Dc(t),n=e.length,i=e[0];if(n===ui)return this.fromCompressedHex(e);if(n===Cu&&(i===2||i===3))return this.fromCompressedHex(e);if(n===Su&&i===4)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${Cu} compressed bytes or ${Su} uncompressed bytes, not ${n}`)}static fromPrivateKey(t){return Se.BASE.multiply(Lc(t))}static fromSignature(t,e,n){const{r:i,s}=$6(e);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const a=Zm(Dc(t)),{n:l}=fr,u=n===2||n===3?i+l:i,f=Tc(u,l),d=bt(-a*f,l),w=bt(s*f,l),m=n&1?"03":"02",b=Se.fromHex(m+da(u)),E=Se.BASE.multiplyAndAddUnsafe(b,d,w);if(!E)throw new Error("Cannot recover signature: point at infinify");return E.assertValidity(),E}toRawBytes(t=!1){return ao(this.toHex(t))}toHex(t=!1){const e=da(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${da(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:n}=this;if(!Ed(e)||!Ed(n))throw new Error(t);const i=bt(n*n),s=qm(e);if(bt(i-s)!==Ee)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new Se(this.x,bt(-this.y))}double(){return Ae.fromAffine(this).double().toAffine()}add(t){return Ae.fromAffine(this).add(Ae.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return Ae.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,n){const i=Ae.fromAffine(this),s=e===Ee||e===ze||this!==Se.BASE?i.multiplyUnsafe(e):i.multiply(e),a=Ae.fromAffine(t).multiplyUnsafe(n),l=s.add(a);return l.equals(Ae.ZERO)?void 0:l.toAffine()}}Se.BASE=new Se(fr.Gx,fr.Gy),Se.ZERO=new Se(Ee,Ee);function Qm(r){return Number.parseInt(r[0],16)>=8?"00"+r:r}function Jm(r){if(r.length<2||r[0]!==2)throw new Error(`Invalid signature integer tag: ${fa(r)}`);const t=r[1],e=r.subarray(2,t+2);if(!t||e.length!==t)throw new Error("Invalid signature integer: wrong length");if(e[0]===0&&e[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Is(e),left:r.subarray(t+2)}}function C6(r){if(r.length<2||r[0]!=48)throw new Error(`Invalid signature tag: ${fa(r)}`);if(r[1]!==r.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:e}=Jm(r.subarray(2)),{data:n,left:i}=Jm(e);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${fa(i)}`);return{r:t,s:n}}let ha=class od{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,n="Signature.fromCompact";if(typeof t!="string"&&!e)throw new TypeError(`${n}: Expected string or Uint8Array`);const i=e?fa(t):t;if(i.length!==128)throw new Error(`${n}: Expected 64-byte hex`);return new od(Du(i.slice(0,64)),Du(i.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if(typeof t!="string"&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:i}=C6(e?t:ao(t));return new od(n,i)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!Rc(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Rc(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=fr.n>>ze;return this.s>t}normalizeS(){return this.hasHighS()?new od(this.r,bt(-this.s,fr.n)):this}toDERRawBytes(){return ao(this.toDERHex())}toDERHex(){const t=Qm(Pc(this.s)),e=Qm(Pc(this.r)),n=t.length/2,i=e.length/2,s=Pc(n),a=Pc(i);return`30${Pc(i+n+4)}02${a}${e}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return ao(this.toCompactHex())}toCompactHex(){return da(this.r)+da(this.s)}};function xs(...r){if(!r.every(n=>n instanceof Uint8Array))throw new Error("Uint8Array list expected");if(r.length===1)return r[0];const t=r.reduce((n,i)=>n+i.length,0),e=new Uint8Array(t);for(let n=0,i=0;nt.toString(16).padStart(2,"0"));function fa(r){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let e=0;e0)return BigInt(r);if(typeof r=="bigint"&&Rc(r))return r;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function bt(r,t=fr.P){const e=r%t;return e>=Ee?e:t+e}function qn(r,t){const{P:e}=fr;let n=r;for(;t-- >Ee;)n*=n,n%=e;return n}function P6(r){const{P:t}=fr,e=BigInt(6),n=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),u=r*r*r%t,f=u*u*r%t,d=qn(f,Oc)*f%t,w=qn(d,Oc)*f%t,m=qn(w,As)*u%t,b=qn(m,n)*m%t,E=qn(b,i)*b%t,C=qn(E,a)*E%t,R=qn(C,l)*C%t,k=qn(R,a)*E%t,D=qn(k,Oc)*f%t,P=qn(D,s)*b%t,I=qn(P,e)*u%t,T=qn(I,As);if(T*T%t!==r)throw new Error("Cannot find square root");return T}function Tc(r,t=fr.P){if(r===Ee||t<=Ee)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=bt(r,t),n=t,i=Ee,s=ze;for(;e!==Ee;){const l=n/e,u=n%e,f=i-s*l;n=e,e=u,i=s,s=f}if(n!==ze)throw new Error("invert: does not exist");return bt(i,t)}function D6(r,t=fr.P){const e=new Array(r.length),n=r.reduce((s,a,l)=>a===Ee?s:(e[l]=s,bt(s*a,t)),ze),i=Tc(n,t);return r.reduceRight((s,a,l)=>a===Ee?s:(e[l]=bt(s*e[l],t),bt(s*a,t)),i),e}function T6(r){const t=r.length*8-ua*8,e=Is(r);return t>0?e>>BigInt(t):e}function Zm(r,t=!1){const e=T6(r);if(t)return e;const{n}=fr;return e>=n?e-n:e}let pa,Nc;class N6{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return Cs.hmacSha256(this.k,...t)}hmacSync(...t){return Nc(this.k,...t)}checkSync(){if(typeof Nc!="function")throw new Wm("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),t.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),t.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t0)t=BigInt(r);else if(typeof r=="string"){if(r.length!==2*ua)throw new Error("Expected 32 bytes of private key");t=Du(r)}else if(r instanceof Uint8Array){if(r.length!==ua)throw new Error("Expected 32 bytes of private key");t=Is(r)}else throw new TypeError("Expected valid private key");if(!Rc(t))throw new Error("Expected private key: 0 < key < n");return t}function L6(r){return r instanceof Se?(r.assertValidity(),r):Se.fromHex(r)}function $6(r){if(r instanceof ha)return r.assertValidity(),r;try{return ha.fromDER(r)}catch{return ha.fromCompact(r)}}function k6(r,t=!1){return Se.fromPrivateKey(r).toRawBytes(t)}function U6(r,t,e,n=!1){return Se.fromSignature(r,t,e).toRawBytes(n)}function Xm(r){const t=r instanceof Uint8Array,e=typeof r=="string",n=(t||e)&&r.length;return t?n===Cu||n===Su:e?n===Cu*2||n===Su*2:r instanceof Se}function B6(r,t,e=!1){if(Xm(r))throw new TypeError("getSharedSecret: first arg must be private key");if(!Xm(t))throw new TypeError("getSharedSecret: second arg must be public key");const n=L6(t);return n.assertValidity(),n.multiply(Lc(r)).toRawBytes(e)}function tw(r){const t=r.length>ui?r.slice(0,ui):r;return Is(t)}function F6(r){const t=tw(r),e=bt(t,fr.n);return ew(e{r=Dc(r);const t=ua+8;if(r.length1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const e=bt(Is(r),fr.n-ze)+ze;return vd(e)},randomBytes:(r=32)=>{if(Tn.web)return Tn.web.getRandomValues(new Uint8Array(r));if(Tn.node){const{randomBytes:t}=Tn.node;return Uint8Array.from(t(r))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Cs.hashToPrivateKey(Cs.randomBytes(ua+8)),precompute(r=8,t=Se.BASE){const e=t===Se.BASE?t:new Se(t.x,t.y);return e._setWindowSize(r),e.multiply(Oc),e},sha256:async(...r)=>{if(Tn.web){const t=await Tn.web.subtle.digest("SHA-256",xs(...r));return new Uint8Array(t)}else if(Tn.node){const{createHash:t}=Tn.node,e=t("sha256");return r.forEach(n=>e.update(n)),Uint8Array.from(e.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(r,...t)=>{if(Tn.web){const e=await Tn.web.subtle.importKey("raw",r,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=xs(...t),i=await Tn.web.subtle.sign("HMAC",e,n);return new Uint8Array(i)}else if(Tn.node){const{createHmac:e}=Tn.node,n=e("sha256",r);return t.forEach(i=>n.update(i)),Uint8Array.from(n.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(r,...t)=>{let e=Tu[r];if(e===void 0){const n=await Cs.sha256(Uint8Array.from(r,i=>i.charCodeAt(0)));e=xs(n,n),Tu[r]=e}return Cs.sha256(e,...t)},taggedHashSync:(r,...t)=>{if(typeof pa!="function")throw new Wm("sha256Sync is undefined, you need to set it");let e=Tu[r];if(e===void 0){const n=pa(Uint8Array.from(r,i=>i.charCodeAt(0)));e=xs(n,n),Tu[r]=e}return pa(e,...t)},_JacobianPoint:Ae};Object.defineProperties(Cs,{sha256Sync:{configurable:!1,get(){return pa},set(r){pa||(pa=r)}},hmacSha256Sync:{configurable:!1,get(){return Nc},set(r){Nc||(Nc=r)}}});const _d="0x0000000000000000000000000000000000000000",rw="0x0000000000000000000000000000000000000000000000000000000000000000",nw=BigInt(0),iw=BigInt(1),sw=BigInt(2),ow=BigInt(27),aw=BigInt(28),Nu=BigInt(35),ga={};function cw(r){return oo(Pn(r),32)}class Tr{#t;#e;#r;#n;get r(){return this.#t}set r(t){q(oa(t)===32,"invalid r","value",t),this.#t=At(t)}get s(){return this.#e}set s(t){q(oa(t)===32,"invalid s","value",t);const e=At(t);q(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),this.#e=e}get v(){return this.#r}set v(t){const e=se(t,"value");q(e===27||e===28,"invalid v","v",t),this.#r=e}get networkV(){return this.#n}get legacyChainId(){const t=this.networkV;return t==null?null:Tr.getChainId(t)}get yParity(){return this.v===27?0:1}get yParityAndS(){const t=ve(this.s);return this.yParity&&(t[0]|=128),At(t)}get compactSerialized(){return br([this.r,this.yParityAndS])}get serialized(){return br([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(t,e,n,i){mu(t,ga,"Signature"),this.#t=e,this.#e=n,this.#r=i,this.#n=null}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const t=new Tr(ga,this.r,this.s,this.v);return this.networkV&&(t.#n=this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:t!=null?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=It(t,"v");return e==ow||e==aw?nw:(q(e>=Nu,"invalid EIP-155 v","v",t),(e-Nu)/sw)}static getChainIdV(t,e){return It(t)*sw+BigInt(35+e-27)}static getNormalizedV(t){const e=It(t);return e===nw||e===ow?27:e===iw||e===aw?28:(q(e>=Nu,"invalid v","v",t),e&iw?27:28)}static from(t){function e(f,d){q(f,d,"signature",t)}if(t==null)return new Tr(ga,rw,rw,27);if(typeof t=="string"){const f=ve(t,"signature");if(f.length===64){const d=At(f.slice(0,32)),w=f.slice(32,64),m=w[0]&128?28:27;return w[0]&=127,new Tr(ga,d,At(w),m)}if(f.length===65){const d=At(f.slice(0,32)),w=f.slice(32,64);e((w[0]&128)===0,"non-canonical s");const m=Tr.getNormalizedV(f[64]);return new Tr(ga,d,At(w),m)}e(!1,"invalid raw signature length")}if(t instanceof Tr)return t.clone();const n=t.r;e(n!=null,"missing r");const i=cw(n),s=function(f,d){if(f!=null)return cw(f);if(d!=null){e(Qe(d,32),"invalid yParityAndS");const w=ve(d);return w[0]&=127,At(w)}e(!1,"missing s")}(t.s,t.yParityAndS);e((ve(s)[0]&128)==0,"non-canonical s");const{networkV:a,v:l}=function(f,d,w){if(f!=null){const m=It(f);return{networkV:m>=Nu?m:void 0,v:Tr.getNormalizedV(m)}}if(d!=null)return e(Qe(d,32),"invalid yParityAndS"),{v:ve(d)[0]&128?28:27};if(w!=null){switch(se(w,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),u=new Tr(ga,i,s,l);return a&&(u.#n=a),e(t.yParity==null||se(t.yParity,"sig.yParity")===u.yParity,"yParity mismatch"),e(t.yParityAndS==null||t.yParityAndS===u.yParityAndS,"yParityAndS mismatch"),u}}Cs.hmacSha256Sync=function(r,...t){return ve(Cc("sha256",r,br(t)))};class Hi{#t;constructor(t){q(oa(t)===32,"invalid private key","privateKey","[REDACTED]"),this.#t=At(t)}get privateKey(){return this.#t}get publicKey(){return Hi.computePublicKey(this.#t)}get compressedPublicKey(){return Hi.computePublicKey(this.#t,!0)}sign(t){q(oa(t)===32,"invalid digest length","digest",t);const[e,n]=H6(fn(t),fn(this.#t),{recovered:!0,canonical:!0}),i=ha.fromHex(e);return Tr.from({r:ms("0x"+i.r.toString(16),32),s:ms("0x"+i.s.toString(16),32),v:n?28:27})}computeSharedSecret(t){const e=Hi.computePublicKey(t);return At(B6(fn(this.#t),ve(e)))}static computePublicKey(t,e){let n=ve(t,"key");if(n.length===32){const s=k6(n,!!e);return At(s)}if(n.length===64){const s=new Uint8Array(65);s[0]=4,s.set(n,1),n=s}const i=Se.fromHex(n);return At(i.toRawBytes(e))}static recoverPublicKey(t,e){q(oa(t)===32,"invalid digest length","digest",t);const n=Tr.from(e),i=ha.fromCompact(fn(br([n.r,n.s]))).toDERRawBytes(),s=U6(fn(t),i,n.yParity);return q(s!=null,"invalid signature for digest","signature",e),At(s)}static addPoints(t,e,n){const i=Se.fromHex(Hi.computePublicKey(t).substring(2)),s=Se.fromHex(Hi.computePublicKey(e).substring(2));return"0x"+i.add(s).toHex(!!n)}}const z6=BigInt(0),V6=BigInt(36);function lw(r){r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let i=0;i<40;i++)e[i]=t[i].charCodeAt(0);const n=ve(Je(e));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(n[i>>1]&15)>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}const Ad={};for(let r=0;r<10;r++)Ad[String(r)]=String(r);for(let r=0;r<26;r++)Ad[String.fromCharCode(65+r)]=String(10+r);const uw=15;function G6(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(n=>Ad[n]).join("");for(;t.length>=uw;){let n=t.substring(0,uw);t=parseInt(n,10)%97+t.substring(n.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}const q6=function(){const r={};for(let t=0;t<36;t++){const e="0123456789abcdefghijklmnopqrstuvwxyz"[t];r[e]=BigInt(t)}return r}();function W6(r){r=r.toLowerCase();let t=z6;for(let e=0;et.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return this.#t}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return this.#t===!0?-1:this.#t===!1?this.value.length:null}static from(t,e){return new nr(zi,t,e)}static uint8(t){return vt(t,8)}static uint16(t){return vt(t,16)}static uint24(t){return vt(t,24)}static uint32(t){return vt(t,32)}static uint40(t){return vt(t,40)}static uint48(t){return vt(t,48)}static uint56(t){return vt(t,56)}static uint64(t){return vt(t,64)}static uint72(t){return vt(t,72)}static uint80(t){return vt(t,80)}static uint88(t){return vt(t,88)}static uint96(t){return vt(t,96)}static uint104(t){return vt(t,104)}static uint112(t){return vt(t,112)}static uint120(t){return vt(t,120)}static uint128(t){return vt(t,128)}static uint136(t){return vt(t,136)}static uint144(t){return vt(t,144)}static uint152(t){return vt(t,152)}static uint160(t){return vt(t,160)}static uint168(t){return vt(t,168)}static uint176(t){return vt(t,176)}static uint184(t){return vt(t,184)}static uint192(t){return vt(t,192)}static uint200(t){return vt(t,200)}static uint208(t){return vt(t,208)}static uint216(t){return vt(t,216)}static uint224(t){return vt(t,224)}static uint232(t){return vt(t,232)}static uint240(t){return vt(t,240)}static uint248(t){return vt(t,248)}static uint256(t){return vt(t,256)}static uint(t){return vt(t,256)}static int8(t){return vt(t,-8)}static int16(t){return vt(t,-16)}static int24(t){return vt(t,-24)}static int32(t){return vt(t,-32)}static int40(t){return vt(t,-40)}static int48(t){return vt(t,-48)}static int56(t){return vt(t,-56)}static int64(t){return vt(t,-64)}static int72(t){return vt(t,-72)}static int80(t){return vt(t,-80)}static int88(t){return vt(t,-88)}static int96(t){return vt(t,-96)}static int104(t){return vt(t,-104)}static int112(t){return vt(t,-112)}static int120(t){return vt(t,-120)}static int128(t){return vt(t,-128)}static int136(t){return vt(t,-136)}static int144(t){return vt(t,-144)}static int152(t){return vt(t,-152)}static int160(t){return vt(t,-160)}static int168(t){return vt(t,-168)}static int176(t){return vt(t,-176)}static int184(t){return vt(t,-184)}static int192(t){return vt(t,-192)}static int200(t){return vt(t,-200)}static int208(t){return vt(t,-208)}static int216(t){return vt(t,-216)}static int224(t){return vt(t,-224)}static int232(t){return vt(t,-232)}static int240(t){return vt(t,-240)}static int248(t){return vt(t,-248)}static int256(t){return vt(t,-256)}static int(t){return vt(t,-256)}static bytes1(t){return _e(t,1)}static bytes2(t){return _e(t,2)}static bytes3(t){return _e(t,3)}static bytes4(t){return _e(t,4)}static bytes5(t){return _e(t,5)}static bytes6(t){return _e(t,6)}static bytes7(t){return _e(t,7)}static bytes8(t){return _e(t,8)}static bytes9(t){return _e(t,9)}static bytes10(t){return _e(t,10)}static bytes11(t){return _e(t,11)}static bytes12(t){return _e(t,12)}static bytes13(t){return _e(t,13)}static bytes14(t){return _e(t,14)}static bytes15(t){return _e(t,15)}static bytes16(t){return _e(t,16)}static bytes17(t){return _e(t,17)}static bytes18(t){return _e(t,18)}static bytes19(t){return _e(t,19)}static bytes20(t){return _e(t,20)}static bytes21(t){return _e(t,21)}static bytes22(t){return _e(t,22)}static bytes23(t){return _e(t,23)}static bytes24(t){return _e(t,24)}static bytes25(t){return _e(t,25)}static bytes26(t){return _e(t,26)}static bytes27(t){return _e(t,27)}static bytes28(t){return _e(t,28)}static bytes29(t){return _e(t,29)}static bytes30(t){return _e(t,30)}static bytes31(t){return _e(t,31)}static bytes32(t){return _e(t,32)}static address(t){return new nr(zi,"address",t)}static bool(t){return new nr(zi,"bool",!!t)}static bytes(t){return new nr(zi,"bytes",t)}static string(t){return new nr(zi,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new nr(zi,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===fw}static dereference(t,e){if(nr.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}}class Q6 extends ji{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=nr.dereference(e,"string");try{n=xe(n)}catch(i){return this._throwError(i.message,e)}return t.writeValue(n)}decode(t){return xe(ms(t.readValue(),20))}}class J6 extends ji{coder;constructor(t){super(t.name,t.type,"_",t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function dw(r,t,e){let n=[];if(Array.isArray(e))n=e;else if(e&&typeof e=="object"){let u={};n=t.map(f=>{const d=f.localName;return ct(d,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),ct(!u[d],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:f},value:e}),u[d]=!0,e[d]})}else q(!1,"invalid tuple value","tuple",e);q(t.length===n.length,"types/value length mismatch","tuple",e);let i=new dd,s=new dd,a=[];t.forEach((u,f)=>{let d=n[f];if(u.dynamic){let w=s.length;u.encode(s,d);let m=i.writeUpdatableValue();a.push(b=>{m(b+w)})}else u.encode(i,d)}),a.forEach(u=>{u(i.length)});let l=r.appendWriter(i);return l+=r.appendWriter(s),l}function pw(r,t){let e=[],n=[],i=r.subReader(0);return t.forEach(s=>{let a=null;if(s.dynamic){let l=r.readIndex(),u=i.subReader(l);try{a=s.decode(u)}catch(f){if(Gn(f,"BUFFER_OVERRUN"))throw f;a=f,a.baseType=s.name,a.name=s.localName,a.type=s.type}}else try{a=s.decode(r)}catch(l){if(Gn(l,"BUFFER_OVERRUN"))throw l;a=l,a.baseType=s.name,a.name=s.localName,a.type=s.type}if(a==null)throw new Error("investigate");e.push(a),n.push(s.localName||null)}),la.fromItems(e,n)}class Y6 extends ji{coder;length;constructor(t,e,n){const i=t.type+"["+(e>=0?e:"")+"]",s=e===-1||t.dynamic;super("array",i,n,s),Nt(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let n=0;ns||n<-(s+ix))&&this._throwError("value out-of-bounds",e),n=cm(n,8*Yr)}else(nEc(i,this.size*8))&&this._throwError("value out-of-bounds",e);return t.writeValue(n)}decode(t){let e=Ec(t.readValue(),this.size*8);return this.signed&&(e=p5(e,this.size*8)),e}}class ax extends gw{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Fi(nr.dereference(e,"string")))}decode(t){return ld(super.decode(t))}}class Ru extends ji{coders;constructor(t,e){let n=!1;const i=[];t.forEach(a=>{a.dynamic&&(n=!0),i.push(a.type)});const s="tuple("+i.join(",")+")";super("tuple",s,e,n),Nt(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(n=>{t.push(n.defaultValue())});const e=this.coders.reduce((n,i)=>{const s=i.localName;return s&&(n[s]||(n[s]=0),n[s]++),n},{});return this.coders.forEach((n,i)=>{let s=n.localName;!s||e[s]!==1||(s==="length"&&(s="_length"),t[s]==null&&(t[s]=t[i]))}),Object.freeze(t)}encode(t,e){const n=nr.dereference(e,"tuple");return dw(t,this.coders,n)}decode(t){return pw(t,this.coders)}}function co(r){return Je(Fi(r))}function cx(r){let t=0;function e(){return r[t++]<<8|r[t++]}let n=e(),i=1,s=[0,1];for(let T=1;T>--u&1}const w=31,m=2**w,b=m>>>1,E=b>>1,C=m-1;let R=0;for(let T=0;T1;){let F=A+p>>>1;T>>1|d(),_=_<<1^b,M=(M^b)<<1|b|1;D=_,P=1+M-_}let I=n-4;return k.map(T=>{switch(T-I){case 3:return I+65792+(r[l++]<<16|r[l++]<<8|r[l++]);case 2:return I+256+(r[l++]<<8|r[l++]);case 1:return I+r[l++];default:return T-1}})}function lx(r){let t=0;return()=>r[t++]}function mw(r){return lx(cx(ux(r)))}function ux(r){let t=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((i,s)=>t[i.charCodeAt(0)]=s);let e=r.length,n=new Uint8Array(6*e>>3);for(let i=0,s=0,a=0,l=0;i=8&&(n[s++]=l>>(a-=8));return n}function hx(r){return r&1?~r>>1:r>>1}function fx(r,t){let e=Array(r);for(let n=0,i=0;n{let t=Ss(r);if(t.length)return t})}function yw(r){let t=[];for(;;){let e=r();if(e==0)break;t.push(dx(e,r))}for(;;){let e=r()-1;if(e<0)break;t.push(px(e,r))}return t.flat()}function $c(r){let t=[];for(;;){let e=r(t.length);if(!e)break;t.push(e)}return t}function bw(r,t,e){let n=Array(r).fill().map(()=>[]);for(let i=0;in[a].push(s));return n}function dx(r,t){let e=1+t(),n=t(),i=$c(t);return bw(i.length,1+r,t).flatMap((a,l)=>{let[u,...f]=a;return Array(i[l]).fill().map((d,w)=>{let m=w*n;return[u+w*e,f.map(b=>b+m)]})})}function px(r,t){let e=1+t();return bw(e,1+r,t).map(i=>[i[0],i.slice(1)])}var Nn=mw("AEgSbwjEDVYByQKaAQsBOQDpATQAngDUAHsAoABoANQAagCNAEQAhABMAHIAOwA9ACsANgAmAGIAHgAvACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGAAeABMAFwAXAA0ADgAWAA8AFAAVBFsF1QEXE0o3xAXUALIArkABaACmAgPGAK6AMDAwMAE/qAYK7P4HQAblMgVYBVkAPSw5Afa3EgfJwgAPA8meNALGCjACjqIChtk/j2+KAsXMAoPzASDgCgDyrgFCAi6OCkCQAOQA4woWABjVuskNDD6eBBx4AP4COhi+D+wKBirqBgSCaA0cBy4ArABqku+mnIAAXAaUJAbqABwAPAyUFvyp/Mo8INAIvCoDshQ8APcubKQAon4ZABgEJtgXAR4AuhnOBPsKIE04CZgJiR8cVlpM5INDABQADQAWAA9sVQAiAA8ASO8W2T30OVnKluYvChEeX05ZPe0AFAANABYAD2wgXUCYAMPsABwAOgzGFryp/AHauQVcBeMC0KACxLEKTR2kZhR0Gm5M9gC8DmgC4gAMLjSKF8qSAoF8ARMcAL4OaALiAAwuAUlQJpJMCwMt/AUpCthqGK4B2EQAciwSeAIyFiIDKCi6OGwAOuIB9iYAyA7MtgEcZIIAsgYABgCK1EoFHNZsGACoKNIBogAAAAAAKy4DnABoAQoaPu43dQQZGACrAcgCIgDgLBJ0OvRQsTOiKDVJBfsoBVoFWbC5BWo7XkITO1hCmHuUZmCh+QwUA8YIJvJ4JASkTAJUVAJ2HKwoAZCkpjZcA0YYBIRiCgDSBqxAMCQHKgI6XgBsAWIgcgCEHhoAlgFKuAAoahgBsMYDOC4iRFQBcFoGZgJmAPJKGAMqAgYASkIArABeAHQALLYGCPTwGo6AAAAKIgAqALQcSAHSAdwIDDKXeYHpAAsAEgA1AD4AOTR3etTBEGAQXQJNCkxtOxUMAq0PpwvmERYM0irM09kANKoH7ANUB+wDVANUB+wH7ANUB+wDVANUA1QDVBwL8BvUwRBgD0kEbgWPBYwE1wiEJkoRggcpCNNUDnQfHEgDRgD9IyZJHTuUMwwlQ0wNTQQH/TZDbKh9OQNIMaxU9pCjA8wyUDltAh5yEqEAKw90HTW2Tn96SHGhCkxPr7WASWNOaAK/Oqk/+QoiCZRvvHdPBj4QGCeiEPQMMAGyATgN6kvVBO4GOATGH3oZFg/KlZkIoi3aDOom4C6egFcj8iqABepL8TzaC0pRZQ9WC2IJ4DpggUsDHgEKIogK2g02CGoQ8ArGaA3iEUIHNgPSSZcAogb+Cw4dMhWyJg1iqQsGOXQG+BrzC4wmrBMmevkF0BoeBkoBJhr8AMwu5IWtWi5cGU9cBgALIiPEFKVQHQ0iQLR4RRoYBxIlpgKOQ21KhFEzHpAh8zw6DWMuEFF5B/I8AhlMC348m0aoRQsRzz6KPUUiRkwpBDJ8LCwniAnMD4IMtnxvAVYJHgmuDG4TLhEUN8IINgcWKpchJxIIHkaSYJcE9JwD8BPOAwgFPAk+BxADshwqEysVJgUKgSHUAvA20i6wAoxWfQEUBcgPIh/cEE1H3Q7mCJgCYgOAJegAKhUeABQimAhAYABcj9VTAi7ICMRqaSNxA2QU5F4RcAeODlQHpBwwFbwc3nDFXgiGBSigrAlYAXIJlgFcBOAIBjVYjJ0gPmdQi1UYmCBeQTxd+QIuDGIVnES6h3UCiA9oEhgBMgFwBzYM/gJ0EeoRaBCSCOiGATWyM/U6IgRMIYAgDgokA0xsywskJvYM9WYBoBJfAwk0OnfrZ6hgsyEX+gcWMsJBXSHuC49PygyZGr4YP1QrGeEHvAPwGvAn50FUBfwDoAAQOkoz6wS6C2YIiAk8AEYOoBQH1BhnCm6MzQEuiAG0lgNUjoACbIwGNAcIAGQIhAV24gAaAqQIoAACAMwDVAA2AqoHmgAWAII+AToDJCwBHuICjAOQCC7IAZIsAfAmBBjADBIA9DRuRwLDrgKAZ2afBdpVAosCRjIBSiIEAktETgOsbt4A2ABIBhDcRAESqEfIF+BAAdxsKADEAPgAAjIHAj4BygHwagC0AVwLLgmfsLIBSuYmAIAAEmgB1AKGANoAMgB87gFQAEoFVvYF0AJMRgEOLhUoVF4BuAMcATABCgB2BsiKosYEHARqB9ACEBgV3gLvKweyAyLcE8pCwgK921IAMhMKNQqkCqNgWF0wAy5vPU0ACx+lPsQ/SwVOO1A7VTtQO1U7UDtVO1A7VTtQO1UDlLzfvN8KaV9CYegMow3RRMU6RhPYYE5gLxPFLbQUvhXLJVMZOhq5JwIl4VUGDwEt0GYtCCk0che5ADwpZYM+Y4MeLQpIHORTjlT1LRgArkufM6wNqRsSRD0FRHXqYicWCwofAmR+AmI/WEqsWDcdAqH0AmiVAmYGAp+BOBgIAmY4AmYjBGsEfAN/EAN+jzkDOXQUOX86ICACbBoCMjM4BwJtxAJtq+yHMGRCKAFkANsA3gBHAgeVDIoA+wi/AAqyAncsAnafPAJ5SEACeLcaWdhFq0bwAnw8AnrFAn0GAnztR/1IemAhACgSSVVKWBIUSskC0P4C0MlLJAOITAOH40TCkS8C8p5dAAMDq0vLTCoiAMxNSU2sAos8AorVvhgEGkBkArQCjjQCjlk9lH4CjtYCjll1UbFTMgdS0VSCApP4ApMJAOYAGVUbVaxVzQMsGCmSgzLeeGNFODYCl5wC769YHqUAViIClowClnmZAKZZqVoGfkoAOAKWsgKWS1xBXM4CmcgCmWFcx10EFgKcmDm/OpoCnBMCn5gCnrWHABoMLicMAp3uAp6PALI6YTFh7AKe0AKgawGmAp6cHAKeS6JjxWQkIigCJ6wCJnsCoPgCoEnUAqYsAqXLAqf8AHoCp+9oeWiuAABGahlqzgKs4AKsqwKtZAKs/wJXGgJV2QKx3tQDH0tslAKyugoCsuUUbN1tYG1FXAMlygK2WTg8bo0DKUICuFsCuUQSArkndHAzcN4CvRYDLa8DMg4CvoVx/wMzbgK+F3Mfc0wCw8gCwwFzf3RIMkJ03QM8pAM8lwM9vALFeQLGRALGDYYCyGZOAshBAslMAskrAmSaAt3PeHZeeKt5IkvNAxigZv8CYfEZ8JUhewhej164DgLPaALPaSxIUM/wEJwAw6oCz3ABJucDTg9+SAIC3CQC24cC0kwDUlkDU1wA/gNViYCGPMgT6l1CcoLLg4oC2sQC2duEDYRGpzkDhqIALANkC4ZuVvYAUgLfYgLetXB0AuIs7REB8y0kAfSYAfLPhALr8ALpbXYC6vYC6uEA9kQBtgLuhgLrmZanlwAC7jwDhd2YdnDdcZ4C8wAAZgOOE5mQAvcQA5FrA5KEAveVAvnWAvhjmhmaqLg0mxsDnYAC/vcBGAA2nxmfsAMFigOmZwOm1gDOwgMGZ6GFogIGAwxGAQwBHAdqBl62ZAIAuARovA6IHrAKABRyNgAgAzASSgOGfAFgJB4AjOwAHgDmoAScjgi0BhygwgCoBRK86h4+PxZ5BWk4P0EsQiJCtV9yEl+9AJbGBTMAkE0am7o7J2AzErrQDjAYxxiKyfcFWAVZBVgFWQVkBVkFWAVZBVgFWQVYBVkFWAVZRxYI2IZoAwMDCmVe6iwEygOyBjC8vAC8BKi8AOhBKhazBUc+aj5xQkBCt192OF/pAFgSM6wAjP/MbMv9puhGez4nJAUsFyg3Nn5u32vB8hnDLGoBbNdvMRgFYAVrycLJuQjQSlwBAQEKfV5+jL8AND+CAAQW0gbmriQGAIzEDAMCDgDlZh4+JSBLQrJCvUI5JF8oYDcoOSQJwj4KRT9EPnk+gj5xPnICikK9SkM8X8xPUGtOCy1sVTBrDG8gX+E0OxwJaJwKYyQsPR4nQqxCvSzMAsv9X8oPIC8KCQoAACN+nt9rOy5LGMmsya0JZsLMzQphQWAP5hCkEgCTjh5GQiYbqm06zjkKND9EPnFCQBwICx5NSG1cLS5a4rwTCn7uHixCQBxeCUsKDzRVREM4BTtEnC0KghwuQkAb9glUIyQZMTIBBo9i8F8KcmTKYAxgLiRvAERgGjoDHB9gtAcDbBFmT2BOEgIAZOhgFmCWYH5gtGBMYJJpFhgGtg/cVqq8WwtDF6wBvCzOwgMgFgEdBB8BegJtMDGWU4EBiwq5SBsA5SR0jwvLDqdN6wGcAoidUAVBYAD4AD4LATUXWHsMpg0lILuwSABQDTUAFhO4NVUC0wxLZhEcANlPBnYECx9bADIAtwKbKAsWcKwzOaAaAVwBhwn9A9ruEAarBksGugAey1aqWwq7YhOKCy1ADrwBvAEjA0hbKSkpIR8gIi0TJwciDY4AVQJvWJFKlgJvIA9ySAHUdRDPUiEaqrFN6wcSBU1gAPgAPgsBewAHJW0LiAymOTEuyLBXDgwAYL0MAGRKaFAiIhzAADIAtwKbKC08D88CkRh8ULxYyXRzjtilnA72mhU+G+0S2hIHDxwByAk7EJQGESwNNwwAPAC0zwEDAKUA4gCbizAAFQBcG8cvbXcrDsIRAzwlRNTiHR8MG34CfATCC6vxbQA4Oi4Opzkuz6IdB7wKABA7Ls8SGgB9rNsdD7wbSBzOoncfAT4qYB0C7KAJBE3z5R9mDL0M+wg9Cj8ABcELPgJMDbwIvQ09CT0KvS7PoisOvAaYAhwPjBriBBwLvBY8AKELPBC8BRihe90AO2wMPQACpwm9BRzR9QYFB2/LBnwAB7wSXBISvQECAOsCAAB1FVwHFswV/HAXvBg8AC68AuyovAAevAJWISuAAAG8AALkFT0VvCvso7zJqDwEAp8nTAACXADn3hm8CaVcD7/FAPUafAiiBQv/cQDfvKe8GNwavKOMeXMG/KmchAASvAcbDAADlABtvAcAC7ynPAIaPLsIopzLDvwHwak8AOF8L7dtvwNJAAPsABW8AAb8AAm8AGmMABq8AA68Axi8jmoV/AABXAAObAAuTB8ABrwAF7wIIgANSwC6vCcAA7wADpwq7ACyWwAcHAAbvAAB7AqiAAXHCxYV3AAHnABCvAEDAGm8AAt8AB28AAi8CaIABcsAbqAZ1gCSCCIABcsAATwAB9wAHZwIIgAGmwAJfAAbLABtHADmvIEACFwACDwAFLwAaPwJIgAGywDjjAAJPAuiDsX7YAAHPABunUBJAEgACrwFAAM8AAmuAzgABxwAGXwAAgym/AAKHAAKPAAJ/KfsBrwACRwAAwwAEDwBABQ8ABFsAA+MAA3sAA28ABkMBxYcABU8AG6cFrQBvAC7ABM8BABpLAsA4UwAAjwABFMAF3wFHAAG0QAYvB8BfClTADpGALAJBw4McwApK3EBpQYIXwJtJA0ACghwTG1gK4oggRVjLjcDogq1AALZABcC/ARvAXdzSFMVIgNQAhY/AS0GBHRHvnxTe0EAKgAyAvwAVAvcAHyRLQEsAHfmDhIzRwJLAFgGAAJRAQiLzQB5PAQhpgBbANcWAJZpOCCMAM5ssgDQ1RcJw3Z0HBlXHgrSAYmRrCNUVE5JEz3DivoAgB04QSos4RKYUABzASosMSlDGhADMVYE+MbvAExm3QBrAnICQBF7Osh4LzXWBhETIAUVCK6v/xPNACYAAQIbAIYAiQCONgDjALQA1QCdPQC7AKsApgChAOcAnwDTAJwA4AEBAPwAwAB6AFsAywDNAPwA1wDrAIkAogEqAOMA2ADVBAIIKzTT09PTtb/bzM/NQjEWAUsBVS5GAVMBYgFhAVQBRUpCRGcMAUwUBgkEMzcMBwAgDSQmKCs3OTk8PDw9Pg0/HVBQUFBSUlFSKFNUVlVVHFxgYF9hYCNlZ29ucXFxcXFxc3Nzc3Nzc3Nzc3N1dXZ1dFsAPesAQgCTAHEAKwBf8QCHAFAAUAAwAm/oAIT+8fEAXQCM6wCYAEgAWwBd+PipAH4AfgBiAE8AqgAdAK8AfAI5AjwA9QDgAPcA9wDhAPgA4gDiAOEA3wAoAnQBSgE5ATcBTQE3ATcBNwEyATEBMQExARUBURAAKgkBAEwYCxcEFhcPAIcAjwCfAEoAYxkCKgBvAGgAkAMOAyArAxpCP0gqAIoCSADAAlACnQC5Ao8CjwKPAo8CjwKPAoQCjwKPAo8CjwKPAo8CjgKOApECmQKQAo8CjwKNAo0CjQKNAosCjgJuAc0CkAKYAo8CjwKOF3oMAPcGA5gCWgIzGAFNETYC2xILLBQBRzgUTpIBdKU9AWJaAP4DOkgA/wCSKh4ZkGsAKmEAagAvAIoDlcyM8K+FWwa7LA/DEgKe1nUrCwQkWwGzAN5/gYB/gX+Cg4N/hIeFf4aJh4GIg4mDin+Lf4x/jYuOf49/kIORf5J/k3+Uf5WElomXg5h/AIMloQCEBDwEOQQ7BD4EPARCBD8EOgRABEIEQQQ9BD8EQgCkA4gAylIA0AINAPdbAPcBGgD3APUA9QD2APXVhSRmvwD3APUA9QD2APUdAIpbAPcAigEaAPcAigLtAPcAitWFJGa/HQD4WwEaAPcA9wD1APUA9gD1APgA9QD1APYA9dWFJGa/HQCKWwEaAPcAigD3AIoC7QD3AIrVhSRmvx0CRAE3AksBOgJMwgOfAu0Dn9WFJGa/HQCKWwEaA58AigOfAIoC7QOfAIrVhSRmvx0EMQCKBDIAigeOMm4hLQCKAT9vBCQA/gDHWwMAVVv/FDMDAIoDPtkASgMAigMAl2dBtv/TrfLzakaPh3aztmIuZQrR3ER2n5Yo+qNR2jK/aP/V04UK1njIJXLgkab9PjOxyJDVbIN3R/FZLoZVl2kYFQIZ7V6LpRqGDt9OdDohnJKp5yX/HLj0voPpLrneDaN11t5W3sSM4ALscgSw8fyWLVkKa/cNcQmjYOgTLZUgOLi2F05g4TR0RfgZ4PBdntxdV3qvdxQt8DeaMMgjJMgwUxYN3tUNpUNx21AvwADDAIa0+raTWaoBXmShAl5AThpMi282o+WzOKMlxjHj7a+DI6AM6VI9w+xyh3Eyg/1XvPmbqjeg2MGXugHt8wW03DQMRTd5iqqOhjLvyOCcKtViGwAHVLyl86KqvxVX7MxSW8HLq6KCrLpB8SspAOHO9IuOwCh9poLoMEha9CHCxlRAXJNDobducWjqhFHqCkzjTM2V9CHslwq4iU19IxqhIFZMve15lDTiMVZIPdADXGxTqzSTv0dDWyk1ht430yvaYCy9qY0MQ3cC5c1uw4mHcTGkMHTAGC99TkNXFAiLQgw9ZWhwKJjGCe+J5FIaMpYhhyUnEgfrF3zEtzn40DdgCIJUJfZ0mo3eXsDwneJ8AYCr7Vx2eHFnt2H6ZEyAHs9JoQ4Lzh5zBoGOGwAz37NOPuqSNmZf51hBEovtpm2T1wI79OBWDyvCFYkONqAKGVYgIL0F+uxTcMLSPtFbiNDbBPFgip8MGDmLLHbSyGXdCMO6f7teiW9EEmorZ+75KzanZwvUySgjoUQBTfHlOIerJs6Y9wLlgDw18AB1ne0tZRNgGjcrqHbtubSUooEpy4hWpDzTSrmvqw0H9AoXQLolMt9eOM+l9RitBB1OBnrdC1XL4yLFyXqZSgZhv7FnnDEXLUeffb4nVDqYTLY6X7gHVaK4ZZlepja2Oe6OhLDI/Ve5SQTCmJdH3HJeb14cw99XsBQAlDy5s5kil2sGezZA3tFok2IsNja7QuFgM30Hff3NGSsSVFYZLOcTBOvlPx8vLhjJrSI7xrNMA/BOzpBIJrdR1+v+zw4RZ7ry6aq4/tFfvPQxQCPDsXlcRvIZYl+E5g3kJ+zLMZon0yElBvEOQTh6SaAdIO6BwdqJqfvgU+e8Y65FQhdiHkZMVt9/39N2jGd26J6cNjq8cQIyp6RonRPgVn2fl89uRDcQ27GacaN0MPrcNyRlbUWelKfDfyrNVVGBG5sjd3jXzTx06ywyzuWn5jbvEfPPCTbpClkgEu9oPLKICxU5HuDe3jA1XnvU85IYYhaEtOU1YVWYhEFsa4/TQj3rHdsU2da2eVbF8YjSI0m619/8bLMZu3xildwqM7zf1cjn4Whx0PSYXcY5bR7wEQfGC7CTOXwZdmsdTO8q3uGm7Rh/RfCWwpzBHCAaVfjxgibL5vUeL0pH6bzDmI9yCXKC/okkmbc28OJvI87L/bjFzpq0DHepw4kT1Od+fL7cyuFaRgfaUWB2++TCFvz11J0leEtrGkpccfX9z2LY39sph4PBHCjNOOkd0ybUm+ZzS8GkFbqMpq8uiX2yHpa0jllTLfGTDBMYR6FT5FWLLDPMkYxt1Q0eyMvxJWztDjy0m6VvZPvamrFXjHmPpU6WxrZqH6WW//I37RwvqPQhPz8I3RPuXAk1C94ZprQWm9iGM/KgiGDO6SV9sjp+Jmk4TBajMNJ5zzWZ1k1jrteQQBp9C2dOvmbIeeEME8y573Q8TgGe+ZCzutM45gYLBzYm2LNvgq2kebAbMpHRDSyh6dQ27GbsAAdCqQVVXWC1C+zpwBM2Lr4eqtobmmu1vJEDlIQR1iN8CUWpztq50z7FFQBn3SKViX6wSqzVQCoYvAjByjeSa+h1PRnYWvBinTDB9cHt4eqDsPS4jcD3FwXJKT0RQsl8EvslI2SFaz2OtmYLFV8FwgvWroZ3fKmh7btewX9tfL2upXsrsqpLJzpzNGyNlnuZyetg7DIOxQTMBR7dqlrTlZ6FWi1g4j1NSjA2j1Yd7fzTH6k9LxCyUCneAKYCU581bnvKih6KJTeTeCX4Zhme/QIz7w2o+AdSgtLAkdrLS9nfweYEqrMLsrGGSWXtgWamAWp6+x6GM/Z8jNw3BqPNQ39hrzYLECn3tPvh/LqKbRSCiDGauDKBBj/kGbpnM1Bb/my8hv4NWStclkwjfl57y4oNDgw1JAG9VOti3QVVoSziMEsSdfEjaCPIDb7SgpLXykQsM+nbqbt97I0mIlzWv0uqFobLMAq8Rd9pszUBKxFhBPwOjf//gVOz2r7URJ2OnpviCXv9iz3a4X/YLBYbXoYwxBv/Kq0a5s4utQHzoTerJ7PmFW/no/ZAsid/hRIV82tD+Qabh5F1ssIM8Ri3chu0PuPD3sSJRMjDoxLAbwUbroiPAz/V52e8s3DIixxlO7OrvhMj3qfzA0kKxzwicr5wJmZwJxTXgrwYsqhRvpgC2Nfdyd+TYYxJSZgk+gk2g9KyHSlwQVAyPtWWgvVGyVBqsU2LpDlLNosSAtolC1uBKt5pQZLhAxTjeGCWIC/HVpagc5rRwkgpCHKEsjA8d+scp8aiMewwQBhp5dYTV5t/Nvl+HbDMu8F3S0psPyZb1bSnqlHPFUnMQeQqSqwDBT23fJO9gO3aVaa1icrXU0PKwlMM5K+iL3ATcVq2fFWKk0irCTF4LDVDG4gUpkyplq6efcZS+WDR1woApjD18x+2JQR9oOXzuA7uy4b+/91WsJd/tSd1QcAH8PVPXApieA37B7YXPhDPH1azP3PKR+HfHmOoDYLeuKsIi/ssSsdYs62qJo14Hw1P2N/6zpr8F3FTWmJ4ysAVcl84Iv/tl///Z8FaAWbBQbyMNDZjrZ2JwdRjtd1jOeNumSodFtr4/Zf45iRJf/8HSW+KIB/+GlKu8Rv1BPLr/4duoL+kFPRqrstEr41gfJupoJRf4hcYDWX93FOcfEBiIivxtjtV8g7mvOReiamYWKE7vfPbv3v2L9Kwq3cIDFGLyhyfOGuf/9vA5muH6Pjg7B4SUj2ydDXra9fSBI+DrsNHA6l51wfHssJb+11TfNk7B8OleUe3Y+ZmHboMFHdv7FFP2cfISFyeAQR0sk/Xv62HBTdW4HmnGSLFk/cqyWVVFJkdIIa+4hos3JRHcqLoRKM5h2Qtk1RZtzISMtlXTfTqIc77YsCCgQD0r61jtxskCctwJOtjE/pL8wC4LBD4AZFjh2wzzFCrT/PNqW0/DeBbkfMfzVm9yy06WiF+1mTdNNEAytVtohBKg3brWd2VQa+aF+cQ0mW5CvbwOlWCT07liX226PjiVLwFCRs/Ax2/u+ZNPjrNFIWIPf5GjHyUKp60OeXe9F01f7IaPf/SDTvyDAf7LSWWejtiZcsqtWZjrdn6A2MqBwnSeKhrZOlUMmgMionmiCIvXqKZfmhGZ1MwD3uMF4n9KJcfWLA3cL5pq48tm5NDYNh3SS/TKUtmFSlQR89MR4+kxcqJgpGbhm9gXneDELkyqAN5nitmIzTscKeJRXqd64RiaOALR2d295NWwbjHRNG2AU5oR9OS2oJg/5CY6BFPc1JvD2Mxdhp2/MZdI8dLePxiP4KRIp8VXmqfg+jqd/RNG7GNuq1U2SiI4735Bdc0MVFx6mH5UOWEa5HuhYykd6t4M1gYLVS8m1B+9bUqi5DziQq7qT8d94cxB6AB4WqMCOF/zPPtRSZUUaMSsvHOWxGASufywTX8ogy6HgUf9p+Z30wUEosl8qgmwm6o2AV6nO9HKQjRHpN6SUegI5pvR61RLnUJ1lqCtmfcsRQutEizVpAaPXN7xMp5UQ5OSZK6tniCK9CpyMd7LjR6+MxfoMEDPpWdf2p2m5N3KO4QMxf+V7vGdYjemQczQ+m2MGIkFNYDMf0Yop2eSx81sP36WHUczqEhKysp2iJSYAvfgJjinKwToPvRKb+HBi+7cJ96S5ngfLOXaHAFRLkulo4TnXTFO51gX0TCCo4ZUHdbpdgkMEwUZAPjh6M+hA8DzycbtxAgH3uD6i0nN1aTiIuQ4BYCE9dEHHwAmINU+4YEWx4EC3OZwFGfYZMPLScVlb+BAAJeARUh+gdWA3/gRqCrf1jecgqeFf1MdzrrP4SVlGm5mMihSP+zYYksAB7O+SBPwNQqSNMiLnkviY/klwgcRmvqtCqeWeA0gjuir4CMZqmw/ntP6M+l0pdN8/P9xI53aP7x/zavJbbKOz8VzO/nXxIr1tjparMnqd6iWdByHKw4lF4p/u57Yv07WeZPDnRl7wgmDVZZ44fQsjdYO/gmXQ+940PRGst8UMQApFC4OOV22e4N+lVOPyFLAOj4t8R3PFw/FjbSWy0ELuAFReNkee8ORcBOT2NPDcs7OfpUmzvn/F9Czk9o9naMyVYy/j8I5qVFmQDFcptBp65J/+sJA3w/j6y/eqUkKxTsf0CZjtNdRSBEmJ2tmfgmJbqpcsSagk+Ul9qdyV+NnqFBIJZFCB1XwPvWGDBOjVUmpWGHsWA5uDuMgLUNKZ4vlq5qfzY1LnRhCc/mh5/EX+hzuGdDy5aYYx4BAdwTTeZHcZpl3X0YyuxZFWNE6wFNppYs3LcFJePOyfKZ8KYb7dmRyvDOcORLPH0sytC6mH1US3JVj6paYM1GEr+CUmyHRnabHPqLlh6Kl0/BWd3ebziDfvpRQpPoR7N+LkUeYWtQ6Rn5v5+NtNeBPs2+DKDlzEVR5aYbTVPrZekJsZ9UC9qtVcP99thVIt1GREnN8zXP8mBfzS+wKYym8fcW6KqrE702Zco+hFQAEIR7qimo7dd7wO8B7R+QZPTuCWm1UAwblDTyURSbd85P4Pz+wBpQyGPeEpsEvxxIZkKsyfSOUcfE3UqzMFwZKYijb7sOkzpou+tC4bPXey5GI1GUAg9c3vLwIwAhcdPHRsYvpAfzkZHWY20vWxxJO0lvKfj6sG2g/pJ1vd/X2EBZkyEjLN4nUZOpOO7MewyHCrxQK8d5aF7rCeQlFX+XksK6l6z971BPuJqwdjj68ULOj9ZTDdOLopMdOLL0PFSS792SXE/EC9EDnIXZGYhr52aQb+9b2zEdBSnpkxAdBUkwJDqGCpZk/HkRidjdp0zKv/Cm52EenmfeKX6HkLUJgMbTTxxIZkIeL/6xuAaAAHbA7mONVduTHNX/UJj1nJEaI7f3HlUyiqKn7VfBE+bdb4HWln1HPJx001Ulq1tOxFf8WZEARvq5Da1+pE7fPVxLntGACz3nkoLsKcPdUqdCwwiyWkmXTd5+bv3j7HaReRt3ESn783Ew3SWsvkEjKtbocNksbrLmV+GVZn1+Uneo35MT1/4r8fngQX5/ptORfgmWfF6KSB/ssJmUSijXxQqUpzkANEkSkYgYj560OOjJr6uqckFuO15TRNgABEwNDjus1V3q2huLPYERMCLXUNmJJpbMrUQsSO7Qnxta55TvPWL6gWmMOvFknqETzqzFVO8SVkovEdYatypLGmDy9VWfgAc0KyIChiOhbd7UlbAeVLPZyEDp4POXKBwN/KP5pT6Cyqs6yaI00vXMn1ubk9OWT9Q/O2t/C25qlnO/zO0xcBzpMBCAB8vsdsh3U8fnPX1XlPEWfaYJxKVaTUgfCESWl4CCkIyjE6iQ5JFcwU6S4/IH0/Agacp8d5Gzq2+GzPnJ7+sqk40mfFQpKrDbAKwLlr3ONEati2k/ycLMSUu7V/7BBkDlNyXoN9tvqXCbbMc4SSQXgC/DBUY9QjtrCtQ+susEomCq8xcNJNNMWCH31GtlTw2BdCXkJBjT+/QNWlBWwQ5SWCh1LdQ99QVii/DyTxjSR6rmdap3l3L3aiplQpPYlrzNm9er88fXd2+ao+YdUNjtqmxiVxmyYPzJxl67OokDcTezEGqldkGgPbRdXA+fGcuZVkembZByo7J1dMnkGNjwwCny+FNcVcWvWYL9mg8oF7jACVWI3bA64EXpdM8bSIEVIAs5JJH+LHXgnCsgcMGPZyAAVBncvbLiexzg9YozcytjPXVlAbQAC7Tc4S0C8QN4LlAGjj4pQAVWrwkaDoUYGxxvkCWKRRHkdzJB5zpREleBDL1oDKEvAqmkDibVC4kTqF89YO6laUjgtJPebBfzr16tg4t10GmN1sJ5vezk2sUOq8blCn5mPZyT3ltaDcddKupQjqusNM9wtFVD0ABzv17fZDn7GPT1nkCtdcgYejcK1qOcTGtPxnCX1rErEjVWCnEJv5HaOAUjgpiKQjUKkQi64D5g2COgwas8FcgIl0Pw95H9dWxE3QG0VbMNffh6BPlAojLDf4es2/5Xfq7hw5NGcON2g8Qsy2UQm94KddKyy3kdJxWgpNaEc15xcylbLC3vnT26u8qS90qc2MU8LdOJc5VPF5KnSpXIhnj1eJJ/jszjZ01oR6JDFJRoeTPO/wh4IPFbdG9KljuSzeuI92p8JF/bpgDE8wG86/W2EBKgPrmzdLijxssQn8mM44ky/KLGOJcrSwXIpZa/Z3v7W6HCRk7ewds99LTsUW1LbeJytw8Q/BFZVZyfO9BUHOCe2suuEkO8DU4fLX0IQSQ2TdOkKXDtPf3sNV9tYhYFueuPRhfQlEEy+aYM/MCz7diDNmFSswYYlZZPmKr2Q5AxLsSVEqqBtn6hVl1BCFOFExnqnIsmyY/NA8jXnDaNzr7Zv3hu+I1Mf/PJjk0gALN2G8ABzdf9FNvWHvZHhv6xIoDCXf964MxG92vGZtx/LYU5PeZqgly8tT5tGeQGeJzMMsJc5p+a5Rn2PtEhiRzo/5Owjy1n0Lzx3ev8GHQmeWb8vagG6O5Qk5nrZuQTiKODI4UqL0LLAusS2Ve7j1Ivdxquu1BR9Rc4QkOiUPwQXJv6du2E8i5pDhVoQpUhyMWGUT2O2YODIhjAfI71gxep5r5zAY7GBUZpy51hAw0pcCCrhOmU8Wp6ujQTdZQsCjtq6SHX8QAMNiPCIIkoxhHEZPgsBcOlP4aErJZPhF7qvx6gHrn8hEwPwYbx8YmT/n7lbcmTip1v8kgsrIjFTAlvLY4Nuil0KDmgz3svYs0ZJ3O3Is/vSx4xpxF1e2VAtZE8dJxGYEIhCSuPvCjP54l/NSNDnwlKvAW8mG+AQkgp7a87Igh26uKMFGD0PoPHTSvoWxiHuk+su8XkQiHIjeYKl/RdcOHpxhQH3zHCNE3aARm83Bl6zGxU/vMltlVPQhubcqhW4RYkl6uXk5JdP/QpzaKFpw2M8zvysv2qj7xaQECuu2akM0Cssj/uB9+wDR7uA6XOnLNaoczalHoMj33eiiu+DRaFsUmlmUZuh9bjDY4INMNSSAivSh03uJvny4Gj+D+neudoa7iJi7c4VFlZ/J5gUR82308zSNAt/ZroBXDWw0fV3eVPAn3aX0mtJabF6RsUZmL+Ehn+wn51/4QipMjD+6y64t7bjL6bjENan2prQ4h7++hBJ9NXvX8CUocJqMC937IasLzm5K0qwXeFMAimMHkEIQIQI2LrQ9sLBfXuyp66zWvlsh74GPv7Xpabj993pRNNDuFud5oIcn/92isbADXdpRPbjmbCNOrwRbxGZx2XmYNGMiV5kjF4IKyxCBvKier9U4uVoheCdmk83rp5G0PihAm2fAtczI4b9BWqX+nrZTrJX5kSwQddi93NQrXG+Cl3eBGNkM77VBsMpEolhXex1MVvMkZN9fG59GGbciH11FEXaY1MxrArovaSjE/lUUqBg2cZBNmiWbvzCHCPJ4RVGFK2dTbObM1m+gJyEX53fa7u3+TZpm74mNEzWbkVL4vjNwfL9uzRCu1cgbrNx5Yv5dDruNrIOgwIk+UZWwJfdbu/WHul6PMmRflVCIzd7B37Pgm/Up/NuCiQW7RXyafevN3AL6ycciCc4ZPlTRzEu+aURGlUBOJbUEsheX7PPyrrhdUt5JAG12EEEZpY/N3Vhbl5uLAfT0CbC2XmpnryFkxZmBTs5prvEeuf0bn73i3O82WTiQtJWEPLsBXnQmdnKhB06NbbhLtlTZYJMxDMJpFeajSNRDB2v61BMUHqXggUwRJ19m6p5zl51v11q34T74lTXdJURuV6+bg2D6qpfGnLy7KGLuLZngobM4pIouz4+n0/UzFKxDgLM4h+fUwKZozQ9UGrHjcif51Ruonz7oIVZ56xWtZS8z7u5zay6J2LD4gCYh2RXoBRLDKsUlZ80R8kmoxlJiL8aZCy2wCAonnucFxCLT1HKoMhbPKt34D97EXPPh0joO93iJVF1Uruew61Qoy3ZUVNX9uIJDt9AQWKLLo+mSzmTibyLHq0D6hhzpvgUgI6ekyVEL3FD+Fi5R3A8MRHPXspN1VyKkfRlC+OGiNgPC4NREZpFETgVmdXrQ2TxChuS3aY+Ndc7CiYv5+CmzfiqeZrWIQJW/C4RvjbGUoJFf1K6ZdR2xL/bG4kVq1+I4jQWX+26YUijpp+lpN7o5c6ZodXJCF56UkFGsqz44sIg8jrdWvbjRCxi2Bk0iyM3a7ecAV93zB6h1Ei38c0s6+8nrbkopArccGP8vntQe1bFeEh2nJIFOHX/k3/UHb5PtKGpnzbkmnRETMX+9X/QduLZWw/feklW/kH/JnzToJe9Kgu9Hct1UGbH5BPCLo4OOtQnZonW0xnyCcdtKyPQ/sbLiSTYJdSx4sJqWLMnfn6fIqPB3WAgk00J+fCOkomPHqtS67pf0mFmKoItYZUlJu6BihSZ8qve8+/X+LX1MhQXF95AshfUleCtmdn6l6QFXzLg2sgLn1oyVFuZecv7fzsIHzoRlAGp0gwYDOn1S4qabWvB5xUaE+Svw4KmjWtxdnuQbI32dw87D4N95u8qQRJTSQg0wLxOLkxSrPMLEn1UIhNKjAa9VLs3WLaXGrtCIt8bKY2AQP/ZdyRU6zT/E8qP2ltyBE2CCZPgWgEYDoJJO4n92y61ylNaSFXKohJhLjkfvYWm592539sIpmBNLlDo1bExFBfmHJJ0lFEiC/fj8v42OoMC9Mo3whIoWvyHfq6Uacqq55mzFf/EGC+NP/gHjhd6urc6R0hES27VXux7UY8CGKPohplWIZtTrFSaPWslCWy78E22Pw8fvReSUZx/txqLtHrFqg1DY/Eus6Iq1heZdrdcqE0/c971Bz1HW/XNXHsXpUIbI4kHdOfCc6T5zHZzvzQJB0ggMFL6IGPAilU9bj/ASdPk6fNvNtZqPuwEDhMBtBnhCexo6D6VAGIOPvJPPV523Y8R8a9vCqZbswSZKzOT1291BsUbmUWehtbb1fdRX9hiJKXvwr1QX6GjnZMgyMvnwOo2Dr24amr7FqEAbVeJAjRNOceM2EQ1Mna9fInqPJ5mh5X8CzT1aDOv08An0blz0fF5Gq4mS2cwq5glwIOlY5nznE8X4j/UdZ3FJsVIXte1JH0A7iibuPfazStM5O/Vo3KXIpXBeGORV0M9XDXFvsYZUHGvFCUubWzTw248EHE0cpQM2zNg6rjavreq3NHCAWsoZ7wvVy7l5gvtKRmIj1MnvfWEm0yFnGcuOq192350a5WefpfKCcX3Sn+AgHU+qnpstNtddbdVebagJU390lq9ko4aI9rqdaWXYG8tv5O/ZQHSqDRYHC6zfH10l5z++opso7aOSaIczlQ13iAzXvLdEu0V7kwNUZ1c8Y8aq7SeIEe5p902FlNkW8DnwHyueHchbK8vVFJfmr9mz7P8nUSccl1ULaoWMRSI1ls32kvlK0h46h3J25Yd9AzfcJbp9qYF/SEt3H5j69mMdcsNxZcAzT/A89ov3tglTX54y/EwjMfuoDoxPwLJDm5I7q6F9Kp469yNy1zSxz0N4HbRRBj9xFFuogvBspv7DXUNIsGxTINEQfmctb42XImWAODgARNo7dfcTqFKq6aTfivmvunLmzP9f8yLsJvXD3JbcPcDGNriMAcjzeDTNr65t8YB5tsnFDFLa0Uwmd2OvUdkLMX9TsAUYUfooSv47sw5J88j7CpahRjjO3/UhOXjTS39W5YZAel2KTbQd1h7INOw9P23GW7GDAe4agIUFHP48MZr7ubq0efFmmtwYMyk7D0r1oeG/CGOODgb9Ur+JMHxkwzPbtCX2ZnENQuI0RN5SyTIZuoY4XS9Rd/tPe3vNAZGSHM/YYwqs9xkkENx0O+eC2YVW1cwOJ3ckE890nbQeHLKlW15L0P0W2VliyYrfNr0nrIYddoRyGaCtj4OYd2MT7ebApqZOAQIaSHJM4mphhfjNjtnjg6YRyx9qM2FT3xOiYIMqXPFWdzhSgFF8ItocqVV09CmIoO8k6U/oJB7++wSX/YksxfPXHyjSgAGZOj1aKEq9fSvXBqtp2wu8/FxEf5AxapAD06pPGuLVUYLdgEzHR8wqRGYEwiUO9MyYbgswstuLYhwYFpSVKOdzAihZ9LuHtD598EGhINU9xc9xhL+QgTLAstmPIvvm2xyRw/WTUPXkP3ZHu6GyPmj5xFH9/QGpkglKXRVUBgVmLOJx8uZO2AstxQYocZH2JhORlxawj66BAXUEs7K/gPxINIRAFyK3WLuyq9oBTF9wEbnmCot82WjIg7CPNwYK3KrZMrKAz5yFszg4wCVLJVnIL8+OYA0xRDH8cHQjQUiQ2i1mr/be32k/3Xej9sdf3iuGvZHyLFSJvPSqz/wltnxumTJYKZsrWXtx/Rmu39jjV9lFaJttfFn57/No2h/unsJmMHbrnZ8csxkp5HQ4xR1s0HH+t3Iz82a3iQWTUDGq/+l2W3TUYLE8zNdL8Y+5oXaIH/Y2UUcX67cXeN4WvENZjz4+8q7vjhowOI3rSjFhGZ6KzwmU7+5nFV+kGWAZ5z2UWvzq0TK0pk1hPwAN4jbw//1CApRvIaIjhSGhioY6TUmsToek9cF9XjJdHvLPcyyCV3lbR5Jiz/ts46ay2F820VjTXvllElwrGzKcNSyvQlWDXdwrUINXmHorAM3fE19ngLZmgeUaCJLsSITf2VcfAOuWwX7mTPdP8Zb/04KqRniufCpwnDUk7sP0RX6cud/sanFMagnzKInSRVey0YzlVSOtA/AjrofmSH6RYbJQ8b4NDeTkIGc6247+Mnbez/qhJ9GAv9fGNFercPnnrf285Qgs+UqThLRgflcAKFuqWhLzZaR4QqvSwa3xe0LPkqj9xJWub195r7NrrR0e78FR+0mRBNMPsraqZctAUVAJfYKehTDV1MGGQSeDsOK9J3sbUuKRIS/WilX/64CBms9jCZocBlsBSZaIAjWm/SUZ8daWL2a/cJFyUOFqE3Epc2RWbtjNyPwOGpWtzu32kUooUqsJud7IV4E8rstUBXM7tGEtBx99x60g1duhyvxeKJSl8s5E34HTMmADT0836aEdg5Dv9rVyCz8i2REOmiz6wtIVFN0HsjAoN37SrY0bV1Ms8CRUILhvZvvRaDzoVCaSI0u8EPuTe4b7OPowgRGODl22UBBmHSTUY8e4DyL+Bc7bngo+2T8HtNvzyATSL5iJZgFPKpmUyZv54vVL90+/RQGATUmNKnrIvcJMYON9fl83naW5sf6hRkbbTC9RUEE6XADwjgA46wWfUQ+QWZl0J4PVTWAln/YfAz/SV3q3J9+yCYDleruoN5uoc/wT2f4YONGTb6zTGq3V+3JqzmCOjwebKln+fExVLN7sqtqfMnsKVXWbb2Ai5m3D/fCTgX7oKYzTZvj+m28XnDqPbXuP4MyWdmPezcesdrh7rCzA7BWdObiuyDEKjjzBbQ0qnuwjliz+b+j7aPMKlkXyIznV3tGzAfYwIbzGGt098oh4eq3ruDjdgHtjxfFCjHrjjRbHajoz/YOY4raojPFQ910GIlBV7hq47UDgpyajBxQUmD8NctiLV1rTSLAEsQDLTeRKcmPBMVMFF0SPBBhZ5oXoxtD3lMhuAQXmA+57OcciczVW9e9zwSIAHS+FJmvfXMJGF1dMBsIUMaPjvgaVqUc3p32qVCMQYFEiRLzlVSOGMCmv/HJIxAHe3mL/XnoZ1IkWLeRZfgyByjnDbbeRK5KL7bYHSVJZ9UFq+yCiNKeRUaYjgbC3hVUvfJAhy/QNl/JqLKVvGMk9ZcfyGidNeo/VTxK9vUpodzfQI9Z2eAre4nmrkzgxKSnT5IJ1D69oHuUS5hp7pK9IAWuNrAOtOH0mAuwCrY8mXAtVXUeaNK3OXr6PRvmWg4VQqFSy+a1GZfFYgdsJELG8N0kvqmzvwZ02Plf5fH9QTy6br0oY/IDsEA+GBf9pEVWCIuBCjsup3LDSDqI+5+0IKSUFr7A96A2f0FbcU9fqljdqvsd8sG55KcKloHIFZem2Wb6pCLXybnVSB0sjCXzdS8IKvE");const vw=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Ew=4;function gx(r){return r.toString(16).toUpperCase().padStart(2,"0")}function _w(r){return`{${gx(r)}}`}function mx(r){let t=[];for(let e=0,n=r.length;e>24&255}function Aw(r){return r&16777215}const wx=new Map(ww(Id).flatMap((r,t)=>r.map(e=>[e,t+1<<24]))),yx=new Set(Ss(Id)),xw=new Map,Cd=new Map;for(let[r,t]of yw(Id)){if(!yx.has(r)&&t.length==2){let[e,n]=t,i=Cd.get(e);i||(i=new Map,Cd.set(e,i)),i.set(n,r)}xw.set(r,t.reverse())}const Bc=44032,Lu=4352,$u=4449,ku=4519,Iw=19,Cw=21,ma=28,Uu=Cw*ma,bx=Iw*Uu,vx=Bc+bx,Ex=Lu+Iw,_x=$u+Cw,Ax=ku+ma;function Sw(r){return r>=Bc&&r=Lu&&r=$u&&t<_x)return Bc+(r-Lu)*Uu+(t-$u)*ma;if(Sw(r)&&t>ku&&t0&&i(ku+f)}else{let a=xw.get(s);a?e.push(...a):i(s)}if(!e.length)break;s=e.pop()}if(n&&t.length>1){let s=Uc(t[0]);for(let a=1;a0&&i>=a)a==0?(t.push(n,...e),e.length=0,n=l):e.push(l),i=a;else{let u=xx(n,l);u>=0?n=u:i==0&&a==0?(t.push(n),n=l):(e.push(l),i=a)}}return n>=0&&t.push(n,...e),t}function Pw(r){return Ow(r).map(Aw)}function Cx(r){return Ix(Ow(r))}const Sd=65039,Dw=".",Tw=1,Nw=45;function wa(){return new Set(Ss(Nn))}const Sx=new Map(yw(Nn)),Ox=wa(),Bu=wa(),Rw=new Set(Ss(Nn).map(function(r){return this[r]},[...Bu])),Px=wa();wa();const Dx=ww(Nn);function Lw(){return new Set([Ss(Nn).map(r=>Dx[r]),Ss(Nn)].flat(2))}const Tx=Nn(),Fc=$c(r=>{let t=$c(Nn).map(e=>e+96);if(t.length){let e=r>=Tx;t[0]-=32,t=kc(t),e&&(t=`Restricted[${t}]`);let n=Lw(),i=Lw(),s=[...n,...i].sort((l,u)=>l-u),a=!Nn();return{N:t,P:n,M:a,R:e,V:new Set(s)}}}),$w=wa(),Mc=new Map;[...$w,...wa()].sort((r,t)=>r-t).map((r,t,e)=>{let n=Nn(),i=e[t]=n?e[t-n]:{V:[],M:new Map};i.V.push(r),$w.has(r)||Mc.set(r,i)});for(let{V:r,M:t}of new Set(Mc.values())){let e=[];for(let i of r){let s=Fc.filter(l=>l.V.has(i)),a=e.find(({G:l})=>s.some(u=>l.has(u)));a||(a={G:new Set,V:[]},e.push(a)),a.V.push(i),s.forEach(l=>a.G.add(l))}let n=e.flatMap(({G:i})=>[...i]);for(let{G:i,V:s}of e){let a=new Set(n.filter(l=>!i.has(l)));for(let l of s)t.set(l,a)}}let jc=new Set,kw=new Set;for(let r of Fc)for(let t of r.V)(jc.has(t)?kw:jc).add(t);for(let r of jc)!Mc.has(r)&&!kw.has(r)&&Mc.set(r,Tw);const Nx=new Set([...jc,...Pw(jc)]),Rx=Ss(Nn),Lx=Uw([]);function Uw(r){let t=$c(()=>{let l=Ss(Nn).map(u=>Rx[u]);if(l.length)return Uw(l)}).sort((l,u)=>u.Q.size-l.Q.size),e=Nn(),n=e%3;e=e/3|0;let i=e&1;e>>=1;let s=e&1,a=e&2;return{B:t,V:n,F:i,S:s,C:a,Q:new Set(r)}}class $x extends Array{get is_emoji(){return!0}}function Fu(r,t=_w){let e=[];Bx(r[0])&&e.push("◌");let n=0,i=r.length;for(let s=0;s=4&&r[2]==Nw&&r[3]==Nw)throw new Error("invalid label extension")}function Bw(r){for(let e=r.lastIndexOf(95);e>0;)if(r[--e]!==95)throw new Error("underscore allowed only at start")}function Ux(r){let t=r[0],e=vw.get(t);if(e)throw Hc(`leading ${e}`);let n=r.length,i=-1;for(let s=1;s{let i=mx(n),s={input:i,offset:e};e+=i.length+1;let a;try{let l=s.tokens=Gx(i,Cx),u=l.length,f;if(u){let d=l[0],w=u>1||d.is_emoji;if(!w&&d.every(m=>m<128))a=d,Bw(a),kx(a),f="ASCII";else if(w&&(s.emoji=!0,d=l.flatMap(m=>m.is_emoji?[]:m)),a=l.flatMap(m=>!t&&m.is_emoji?qx(m):m),Bw(a),!d.length)f="Emoji";else{if(Bu.has(a[0]))throw Hc("leading combining mark");for(let E=1;Ea.has(l)):[...a],!e.length)return}else n.push(i)}if(e){for(let i of e)if(n.every(s=>i.V.has(s)))throw new Error(`whole-script confusable: ${r.N}/${i.N}`)}}function Hx(r){let t=Fc;for(let e of r){let n=t.filter(i=>i.V.has(e));if(!n.length)throw t===Fc?Mw(e):jw(t[0],e);if(t=n,n.length==1)break}return t}function zx(r){return r.map(({input:t,error:e,output:n})=>{if(e){let i=e.message;throw new Error(r.length==1?i:`Invalid label ${Pd(Fu(t))}: ${i}`)}return kc(n)}).join(Dw)}function Mw(r){return new Error(`disallowed character: ${Od(r)}`)}function jw(r,t){let e=Od(t),n=Fc.find(i=>i.P.has(t));return n&&(e=`${n.N} ${e}`),new Error(`illegal mixture: ${r.N} + ${e}`)}function Hc(r){return new Error(`illegal placement: ${r}`)}function Vx(r,t){let{V:e,M:n}=r;for(let i of t)if(!e.has(i))throw jw(r,i);if(n){let i=Pw(t);for(let s=1,a=i.length;sEw)throw new Error(`non-spacing marks: too many ${Pd(Fu(i.slice(s-1,l)))} (${l-s}/${Ew})`);s=l}}}function Gx(r,t){let e=[],n=[];for(r=r.slice().reverse();r.length;){let i=Wx(r);if(i)n.length&&(e.push(t(n)),n=[]),e.push(i);else{let s=r.pop();if(Nx.has(s))n.push(s);else{let a=Sx.get(s);if(a)n.push(...a);else if(!Ox.has(s))throw Mw(s)}}}return n.length&&e.push(t(n)),e}function qx(r){return r.filter(t=>t!=Sd)}function Wx(r,t){let e=Lx,n,i,s=[],a=r.length;for(t&&(t.length=0);a;){let l=r[--a];if(e=e.B.find(u=>u.Q.has(l)),!e)break;if(e.S)i=l;else if(e.C&&l===i)break;s.push(l),e.F&&(s.push(Sd),a>0&&r[a-1]==Sd&&a--),e.V&&(n=Kx(s,e),t&&t.push(...r.slice(a).reverse()),r.length=a)}return n}function Kx(r,t){let e=$x.from(r);return t.V==2&&e.splice(1,1),e}const Hw=new Uint8Array(32);Hw.fill(0);function zw(r){return q(r.length!==0,"invalid ENS name; empty component","comp",r),r}function Vw(r){const t=Fi(Qx(r)),e=[];if(r.length===0)return e;let n=0;for(let i=0;i{if(t.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const e=new Uint8Array(t.length+1);return e.set(t,1),e[0]=e.length-1,e})))+"00"}function Td(r,t){return{address:xe(r),storageKeys:t.map((e,n)=>(q(Qe(e,32),"invalid slot",`storageKeys[${n}]`,e),e.toLowerCase()))}}function lo(r){if(Array.isArray(r))return r.map((e,n)=>Array.isArray(e)?(q(e.length===2,"invalid slot set",`value[${n}]`,e),Td(e[0],e[1])):(q(e!=null&&typeof e=="object","invalid address-slot set","value",r),Td(e.address,e.storageKeys)));q(r!=null&&typeof r=="object","invalid access list","value",r);const t=Object.keys(r).map(e=>{const n=r[e].reduce((i,s)=>(i[s]=!0,i),{});return Td(e,Object.keys(n).sort())});return t.sort((e,n)=>e.address.localeCompare(n.address)),t}function Yx(r){let t;return typeof r=="string"?t=Hi.computePublicKey(r,!1):t=r.publicKey,xe(Je("0x"+t.substring(4)).substring(26))}function Zx(r,t){return Yx(Hi.recoverPublicKey(r,t))}const pn=BigInt(0),Xx=BigInt(2),t8=BigInt(27),e8=BigInt(28),r8=BigInt(35),n8=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function Nd(r){return r==="0x"?null:xe(r)}function Gw(r,t){try{return lo(r)}catch(e){q(!1,e.message,t,r)}}function Mu(r,t){return r==="0x"?0:se(r,t)}function Zr(r,t){if(r==="0x")return pn;const e=It(r,t);return q(e<=n8,"value exceeds uint size",t,e),e}function Fr(r,t){const e=It(r,"value"),n=Pn(e);return q(n.length<=32,"value too large",`tx.${t}`,e),n}function qw(r){return lo(r).map(t=>[t.address,t.storageKeys])}function i8(r){const t=hd(r);q(Array.isArray(t)&&(t.length===9||t.length===6),"invalid field count for legacy transaction","data",r);const e={type:0,nonce:Mu(t[0],"nonce"),gasPrice:Zr(t[1],"gasPrice"),gasLimit:Zr(t[2],"gasLimit"),to:Nd(t[3]),value:Zr(t[4],"value"),data:At(t[5]),chainId:pn};if(t.length===6)return e;const n=Zr(t[6],"v"),i=Zr(t[7],"r"),s=Zr(t[8],"s");if(i===pn&&s===pn)e.chainId=n;else{let a=(n-r8)/Xx;a=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ct(!e||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ct(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):e?i.push(2):t?(i.push(1),n||i.push(0)):n?(i.push(1),i.push(2)):(i.push(0),i.push(1),i.push(2)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}clone(){return ra.from(this)}toJSON(){const t=e=>e==null?null:e.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(t==null)return new ra;if(typeof t=="string"){const n=ve(t);if(n[0]>=127)return ra.from(i8(n));switch(n[0]){case 1:return ra.from(o8(n));case 2:return ra.from(s8(n))}ct(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new ra;return t.type!=null&&(e.type=t.type),t.to!=null&&(e.to=t.to),t.nonce!=null&&(e.nonce=t.nonce),t.gasLimit!=null&&(e.gasLimit=t.gasLimit),t.gasPrice!=null&&(e.gasPrice=t.gasPrice),t.maxPriorityFeePerGas!=null&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),t.maxFeePerGas!=null&&(e.maxFeePerGas=t.maxFeePerGas),t.data!=null&&(e.data=t.data),t.value!=null&&(e.value=t.value),t.chainId!=null&&(e.chainId=t.chainId),t.signature!=null&&(e.signature=Tr.from(t.signature)),t.accessList!=null&&(e.accessList=t.accessList),t.hash!=null&&(q(e.isSigned(),"unsigned transaction cannot define hash","tx",t),q(e.hash===t.hash,"hash mismatch","tx",t)),t.from!=null&&(q(e.isSigned(),"unsigned transaction cannot define from","tx",t),q(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}};const Zw=new Uint8Array(32);Zw.fill(0);const a8=BigInt(-1),Xw=BigInt(0),ty=BigInt(1),c8=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function l8(r){const t=ve(r),e=t.length%32;return e?br([t,Zw.slice(e)]):At(t)}const u8=ms(ty,32),h8=ms(Xw,32),ey={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Rd=["name","version","chainId","verifyingContract","salt"];function ry(r){return function(t){return q(typeof t=="string",`invalid domain value for ${JSON.stringify(r)}`,`domain.${r}`,t),t}}const f8={name:ry("name"),version:ry("version"),chainId:function(r){const t=It(r,"domain.chainId");return q(t>=0,"invalid chain ID","domain.chainId",r),Number.isSafeInteger(t)?Number(t):ca(t)},verifyingContract:function(r){try{return xe(r).toLowerCase()}catch{}q(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",r)},salt:function(r){const t=ve(r,"domain.salt");return q(t.length===32,'invalid domain value "salt"',"domain.salt",r),At(t)}};function Ld(r){{const t=r.match(/^(u?)int(\d*)$/);if(t){const e=t[1]==="",n=parseInt(t[2]||"256");q(n%8===0&&n!==0&&n<=256&&(t[2]==null||t[2]===String(n)),"invalid numeric width","type",r);const i=Ec(c8,e?n-1:n),s=e?(i+ty)*a8:Xw;return function(a){const l=It(a,"value");return q(l>=s&&l<=i,`value out-of-bounds for ${r}`,"value",l),ms(e?cm(l,256):l,32)}}}{const t=r.match(/^bytes(\d+)$/);if(t){const e=parseInt(t[1]);return q(e!==0&&e<=32&&t[1]===String(e),"invalid bytes width","type",r),function(n){const i=ve(n);return q(i.length===e,`invalid length for ${r}`,"value",n),l8(n)}}}switch(r){case"address":return function(t){return oo(xe(t),32)};case"bool":return function(t){return t?u8:h8};case"bytes":return function(t){return Je(t)};case"string":return function(t){return co(t)}}return null}function ny(r,t){return`${r}(${t.map(({name:e,type:n})=>n+" "+e).join(",")})`}class Rn{primaryType;#t;get types(){return JSON.parse(this.#t)}#e;#r;constructor(t){this.#t=JSON.stringify(t),this.#e=new Map,this.#r=new Map;const e=new Map,n=new Map,i=new Map;Object.keys(t).forEach(l=>{e.set(l,new Set),n.set(l,[]),i.set(l,new Set)});for(const l in t){const u=new Set;for(const f of t[l]){q(!u.has(f.name),`duplicate variable name ${JSON.stringify(f.name)} in ${JSON.stringify(l)}`,"types",t),u.add(f.name);const d=f.type.match(/^([^\x5b]*)(\x5b|$)/)[1]||null;q(d!==l,`circular type reference to ${JSON.stringify(d)}`,"types",t),!Ld(d)&&(q(n.has(d),`unknown type ${JSON.stringify(d)}`,"types",t),n.get(d).push(l),e.get(l).add(d))}}const s=Array.from(n.keys()).filter(l=>n.get(l).length===0);q(s.length!==0,"missing primary type","types",t),q(s.length===1,`ambiguous primary types or unused types: ${s.map(l=>JSON.stringify(l)).join(", ")}`,"types",t),Nt(this,{primaryType:s[0]});function a(l,u){q(!u.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",t),u.add(l);for(const f of e.get(l))if(n.has(f)){a(f,u);for(const d of u)i.get(d).add(f)}u.delete(l)}a(this.primaryType,new Set);for(const[l,u]of i){const f=Array.from(u);f.sort(),this.#e.set(l,ny(l,t[l])+f.map(d=>ny(d,t[d])).join(""))}}getEncoder(t){let e=this.#r.get(t);return e||(e=this.#n(t),this.#r.set(t,e)),e}#n(t){{const i=Ld(t);if(i)return i}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const i=e[1],s=this.getEncoder(i);return a=>{q(!e[3]||parseInt(e[3])===a.length,`array length mismatch; expected length ${parseInt(e[3])}`,"value",a);let l=a.map(s);return this.#e.has(i)&&(l=l.map(Je)),Je(br(l))}}const n=this.types[t];if(n){const i=co(this.#e.get(t));return s=>{const a=n.map(({name:l,type:u})=>{const f=this.getEncoder(u)(s[l]);return this.#e.has(u)?Je(f):f});return a.unshift(i),br(a)}}q(!1,`unknown type: ${t}`,"type",t)}encodeType(t){const e=this.#e.get(t);return q(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Je(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,n){if(Ld(t))return n(t,e);const i=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i)return q(!i[3]||parseInt(i[3])===e.length,`array length mismatch; expected length ${parseInt(i[3])}`,"value",e),e.map(a=>this._visit(i[1],a,n));const s=this.types[t];if(s)return s.reduce((a,{name:l,type:u})=>(a[l]=this._visit(u,e[l],n),a),{});q(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Rn(t)}static getPrimaryType(t){return Rn.from(t).primaryType}static hashStruct(t,e,n){return Rn.from(e).hashStruct(t,n)}static hashDomain(t){const e=[];for(const n in t){if(t[n]==null)continue;const i=ey[n];q(i,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",t),e.push({name:n,type:i})}return e.sort((n,i)=>Rd.indexOf(n.name)-Rd.indexOf(i.name)),Rn.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,n){return br(["0x1901",Rn.hashDomain(t),Rn.from(e).hash(n)])}static hash(t,e,n){return Je(Rn.encode(t,e,n))}static async resolveNames(t,e,n,i){t=Object.assign({},t);for(const l in t)t[l]==null&&delete t[l];const s={};t.verifyingContract&&!Qe(t.verifyingContract,20)&&(s[t.verifyingContract]="0x");const a=Rn.from(e);a.visit(n,(l,u)=>(l==="address"&&!Qe(u,20)&&(s[u]="0x"),u));for(const l in s)s[l]=await i(l);return t.verifyingContract&&s[t.verifyingContract]&&(t.verifyingContract=s[t.verifyingContract]),n=a.visit(n,(l,u)=>l==="address"&&s[u]?s[u]:u),{domain:t,value:n}}static getPayload(t,e,n){Rn.hashDomain(t);const i={},s=[];Rd.forEach(u=>{const f=t[u];f!=null&&(i[u]=f8[u](f),s.push({name:u,type:ey[u]}))});const a=Rn.from(e),l=Object.assign({},e);return q(l.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",e),l.EIP712Domain=s,a.encode(n),{types:l,domain:i,primaryType:a.primaryType,message:a.visit(n,(u,f)=>{if(u.match(/^bytes(\d*)/))return At(ve(f));if(u.match(/^u?int/))return It(f).toString();switch(u){case"address":return f.toLowerCase();case"bool":return!!f;case"string":return q(typeof f=="string","invalid string","value",f),f}q(!1,"unsupported type","type",u)})}}}function Xr(r){const t=new Set;return r.forEach(e=>t.add(e)),Object.freeze(t)}const d8=Xr("external public payable".split(" ")),iy="constant external internal payable private public pure view",p8=Xr(iy.split(" ")),sy="constructor error event fallback function receive struct",oy=Xr(sy.split(" ")),ay="calldata memory storage payable indexed",g8=Xr(ay.split(" ")),m8=[sy,ay,"tuple returns",iy].join(" "),w8=Xr(m8.split(" ")),y8={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},b8=new RegExp("^(\\s*)"),v8=new RegExp("^([0-9]+)"),E8=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),cy=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),ly=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class Wn{#t;#e;get offset(){return this.#t}get length(){return this.#e.length-this.#t}constructor(t){this.#t=0,this.#e=t.slice()}clone(){return new Wn(this.#e)}reset(){this.#t=0}#r(t=0,e=0){return new Wn(this.#e.slice(t,e).map(n=>Object.freeze(Object.assign({},n,{match:n.match-t,linkBack:n.linkBack-t,linkNext:n.linkNext-t}))))}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t)throw new Error(`expected ${t}; got ${JSON.stringify(this.peek())}`);return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=this.#r(this.#t+1,t.match+1);return this.#t=t.match+1,e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;this.#t=this.#e.length)throw new Error("out-of-bounds");return this.#e[this.#t]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return this.#t++,t}toString(){const t=[];for(let e=this.#t;e`}}function Os(r){const t=[],e=a=>{const l=s0&&t[t.length-1].type==="NUMBER"){const w=t.pop().text;d=w+d,t[t.length-1].value=se(w)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=d}continue}if(l=a.match(E8),l){if(u.text=l[1],s+=u.text.length,w8.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(ly)){u.type="TYPE";continue}u.type="ID";continue}if(l=a.match(v8),l){u.text=l[1],u.type="NUMBER",s+=u.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${s}`)}return new Wn(t.map(a=>Object.freeze(a)))}function uy(r,t){let e=[];for(const n in t.keys())r.has(n)&&e.push(n);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function ju(r,t){if(t.peekKeyword(oy)){const e=t.pop().text;if(e!==r)throw new Error(`expected ${r}, got ${e}`)}return t.popType("ID")}function Vi(r,t){const e=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||t&&!t.has(n))break;if(r.pop(),e.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);e.add(n)}return Object.freeze(e)}function hy(r){let t=Vi(r,p8);return uy(t,Xr("constant payable nonpayable".split(" "))),uy(t,Xr("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 Gi(r,t){return r.popParams().map(e=>Be.from(e,t))}function fy(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return It(r.pop().text);throw new Error("invalid gas")}return null}function uo(r){if(r.length)throw new Error(`unexpected tokens: ${r.toString()}`)}const _8=new RegExp(/^(.*)\[([0-9]*)\]$/);function dy(r){const t=r.match(ly);if(q(t,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(t[2]){const e=parseInt(t[2]);q(e!==0&&e<=32,"invalid bytes length","type",r)}else if(t[3]){const e=parseInt(t[3]);q(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",r)}return r}const Ye={},gn=Symbol.for("_ethers_internal"),py="_ParamTypeInternal",gy="_ErrorInternal",my="_EventInternal",wy="_ConstructorInternal",yy="_FallbackInternal",by="_FunctionInternal",vy="_StructInternal";class Be{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(t,e,n,i,s,a,l,u){if(mu(t,Ye,"ParamType"),Object.defineProperty(this,gn,{value:py}),a&&(a=Object.freeze(a.slice())),i==="array"){if(l==null||u==null)throw new Error("")}else if(l!=null||u!=null)throw new Error("");if(i==="tuple"){if(a==null)throw new Error("")}else if(a!=null)throw new Error("");Nt(this,{name:e,type:n,baseType:i,indexed:s,components:a,arrayLength:l,arrayChildren:u})}format(t){if(t==null&&(t="sighash"),t==="json"){const n=this.name||"";if(this.isArray()){const s=JSON.parse(this.arrayChildren.format("json"));return s.name=n,s.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(s)}const i={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.isTuple()&&(i.components=this.components.map(s=>JSON.parse(s.format(t)))),JSON.stringify(i)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?(t!=="sighash"&&(e+=this.type),e+="("+this.components.map(n=>n.format(t)).join(t==="full"?", ":",")+")"):e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map(i=>n.arrayChildren.walk(i,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map((i,s)=>n.components[s].walk(i,e))}return e(this.type,t)}#t(t,e,n,i){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const a=this.arrayChildren,l=e.slice();l.forEach((u,f)=>{a.#t(t,u,n,d=>{l[f]=d})}),i(l);return}if(this.isTuple()){const a=this.components;let l;if(Array.isArray(e))l=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");l=a.map(u=>{if(!u.name)throw new Error("cannot use object value with unnamed components");if(!(u.name in e))throw new Error(`missing value for component ${u.name}`);return e[u.name]})}if(l.length!==this.components.length)throw new Error("array is wrong length");l.forEach((u,f)=>{a[f].#t(t,u,n,d=>{l[f]=d})}),i(l);return}const s=n(this.type,e);s.then?t.push(async function(){i(await s)}()):i(s)}async walkAsync(t,e){const n=[],i=[t];return this.#t(n,t,e,s=>{i[0]=s}),n.length&&await Promise.all(n),i[0]}static from(t,e){if(Be.isParamType(t))return t;if(typeof t=="string")try{return Be.from(Os(t),e)}catch{q(!1,"invalid param type","obj",t)}else if(t instanceof Wn){let l="",u="",f=null;Vi(t,Xr(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(u="tuple",f=t.popParams().map(C=>Be.from(C)),l=`tuple(${f.map(C=>C.format()).join(",")})`):(l=dy(t.popType("TYPE")),u=l);let d=null,w=null;for(;t.length&&t.peekType("BRACKET");){const C=t.pop();d=new Be(Ye,"",l,u,null,f,w,d),w=C.value,l+=C.text,u="array",f=null}let m=null;if(Vi(t,g8).has("indexed")){if(!e)throw new Error("");m=!0}const E=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new Be(Ye,E,l,u,m,f,w,d)}const n=t.name;q(!n||typeof n=="string"&&n.match(cy),"invalid name","obj.name",n);let i=t.indexed;i!=null&&(q(e,"parameter cannot be indexed","obj.indexed",t.indexed),i=!!i);let s=t.type,a=s.match(_8);if(a){const l=parseInt(a[2]||"-1"),u=Be.from({type:a[1],components:t.components});return new Be(Ye,n||"",s,"array",i,null,l,u)}if(s==="tuple"||s.startsWith("tuple(")||s.startsWith("(")){const l=t.components!=null?t.components.map(f=>Be.from(f)):null;return new Be(Ye,n||"",s,"tuple",i,l,null,null)}return s=dy(t.type),new Be(Ye,n||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[gn]===py}}class ho{type;inputs;constructor(t,e,n){mu(t,Ye,"Fragment"),n=Object.freeze(n.slice()),Nt(this,{type:e,inputs:n})}static from(t){if(typeof t=="string"){try{ho.from(JSON.parse(t))}catch{}return ho.from(Os(t))}if(t instanceof Wn)switch(t.peekKeyword(oy)){case"constructor":return qi.from(t);case"error":return mn.from(t);case"event":return Ei.from(t);case"fallback":case"receive":return Wi.from(t);case"function":return _i.from(t);case"struct":return fo.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return qi.from(t);case"error":return mn.from(t);case"event":return Ei.from(t);case"fallback":case"receive":return Wi.from(t);case"function":return _i.from(t);case"struct":return fo.from(t)}ct(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}q(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return qi.isFragment(t)}static isError(t){return mn.isFragment(t)}static isEvent(t){return Ei.isFragment(t)}static isFunction(t){return _i.isFragment(t)}static isStruct(t){return fo.isFragment(t)}}class Hu extends ho{name;constructor(t,e,n,i){super(t,e,i),q(typeof n=="string"&&n.match(cy),"invalid identifier","name",n),i=Object.freeze(i.slice()),Nt(this,{name:n})}}function zc(r,t){return"("+t.map(e=>e.format(r)).join(r==="full"?", ":",")+")"}class mn extends Hu{constructor(t,e,n){super(t,"error",e,n),Object.defineProperty(this,gn,{value:gy})}get selector(){return co(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+zc(t,this.inputs)),e.join(" ")}static from(t){if(mn.isFragment(t))return t;if(typeof t=="string")return mn.from(Os(t));if(t instanceof Wn){const e=ju("error",t),n=Gi(t);return uo(t),new mn(Ye,e,n)}return new mn(Ye,t.name,t.inputs?t.inputs.map(Be.from):[])}static isFragment(t){return t&&t[gn]===gy}}class Ei extends Hu{anonymous;constructor(t,e,n,i){super(t,"event",e,n),Object.defineProperty(this,gn,{value:my}),Nt(this,{anonymous:i})}get topicHash(){return co(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("event"),e.push(this.name+zc(t,this.inputs)),t!=="sighash"&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){return e=(e||[]).map(i=>Be.from(i)),new Ei(Ye,t,e,!1).topicHash}static from(t){if(Ei.isFragment(t))return t;if(typeof t=="string")try{return Ei.from(Os(t))}catch{q(!1,"invalid event fragment","obj",t)}else if(t instanceof Wn){const e=ju("event",t),n=Gi(t,!0),i=!!Vi(t,Xr(["anonymous"])).has("anonymous");return uo(t),new Ei(Ye,e,n,i)}return new Ei(Ye,t.name,t.inputs?t.inputs.map(e=>Be.from(e,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[gn]===my}}class qi extends ho{payable;gas;constructor(t,e,n,i,s){super(t,e,n),Object.defineProperty(this,gn,{value:wy}),Nt(this,{payable:i,gas:s})}format(t){if(ct(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[`constructor${zc(t,this.inputs)}`];return e.push(this.payable?"payable":"nonpayable"),this.gas!=null&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(qi.isFragment(t))return t;if(typeof t=="string")try{return qi.from(Os(t))}catch{q(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Wn){Vi(t,Xr(["constructor"]));const e=Gi(t),n=!!Vi(t,d8).has("payable"),i=fy(t);return uo(t),new qi(Ye,"constructor",e,n,i)}return new qi(Ye,"constructor",t.inputs?t.inputs.map(Be.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[gn]===wy}}class Wi extends ho{payable;constructor(t,e,n){super(t,"fallback",e),Object.defineProperty(this,gn,{value:yy}),Nt(this,{payable:n})}format(t){const e=this.inputs.length===0?"receive":"fallback";if(t==="json"){const n=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:n})}return`${e}()${this.payable?" payable":""}`}static from(t){if(Wi.isFragment(t))return t;if(typeof t=="string")try{return Wi.from(Os(t))}catch{q(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Wn){const e=t.toString(),n=t.peekKeyword(Xr(["fallback","receive"]));if(q(n,"type must be fallback or receive","obj",e),t.popKeyword(Xr(["fallback","receive"]))==="receive"){const l=Gi(t);return q(l.length===0,"receive cannot have arguments","obj.inputs",l),Vi(t,Xr(["payable"])),uo(t),new Wi(Ye,[],!0)}let s=Gi(t);s.length?q(s.length===1&&s[0].type==="bytes","invalid fallback inputs","obj.inputs",s.map(l=>l.format("minimal")).join(", ")):s=[Be.from("bytes")];const a=hy(t);if(q(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Vi(t,Xr(["returns"])).has("returns")){const l=Gi(t);q(l.length===1&&l[0].type==="bytes","invalid fallback outputs","obj.outputs",l.map(u=>u.format("minimal")).join(", "))}return uo(t),new Wi(Ye,s,a==="payable")}if(t.type==="receive")return new Wi(Ye,[],!0);if(t.type==="fallback"){const e=[Be.from("bytes")],n=t.stateMutability==="payable";return new Wi(Ye,e,n)}q(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[gn]===yy}}class _i extends Hu{constant;outputs;stateMutability;payable;gas;constructor(t,e,n,i,s,a){super(t,"function",e,i),Object.defineProperty(this,gn,{value:by}),s=Object.freeze(s.slice()),Nt(this,{constant:n==="view"||n==="pure",gas:a,outputs:s,payable:n==="payable",stateMutability:n})}get selector(){return co(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(t))),outputs:this.outputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("function"),e.push(this.name+zc(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(zc(t,this.outputs))),this.gas!=null&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){return e=(e||[]).map(i=>Be.from(i)),new _i(Ye,t,"view",e,[],null).selector}static from(t){if(_i.isFragment(t))return t;if(typeof t=="string")try{return _i.from(Os(t))}catch{q(!1,"invalid function fragment","obj",t)}else if(t instanceof Wn){const n=ju("function",t),i=Gi(t),s=hy(t);let a=[];Vi(t,Xr(["returns"])).has("returns")&&(a=Gi(t));const l=fy(t);return uo(t),new _i(Ye,n,s,i,a,l)}let e=t.stateMutability;return e==null&&(e="payable",typeof t.constant=="boolean"?(e="view",t.constant||(e="payable",typeof t.payable=="boolean"&&!t.payable&&(e="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(e="nonpayable")),new _i(Ye,t.name,e,t.inputs?t.inputs.map(Be.from):[],t.outputs?t.outputs.map(Be.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[gn]===by}}class fo extends Hu{constructor(t,e,n){super(t,"struct",e,n),Object.defineProperty(this,gn,{value:vy})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return fo.from(Os(t))}catch{q(!1,"invalid struct fragment","obj",t)}else if(t instanceof Wn){const e=ju("struct",t),n=Gi(t);return uo(t),new fo(Ye,e,n)}return new fo(Ye,t.name,t.inputs?t.inputs.map(Be.from):[])}static isFragment(t){return t&&t[gn]===vy}}const hi=new Map;hi.set(0,"GENERIC_PANIC"),hi.set(1,"ASSERT_FALSE"),hi.set(17,"OVERFLOW"),hi.set(18,"DIVIDE_BY_ZERO"),hi.set(33,"ENUM_RANGE_ERROR"),hi.set(34,"BAD_STORAGE_DATA"),hi.set(49,"STACK_UNDERFLOW"),hi.set(50,"ARRAY_RANGE_ERROR"),hi.set(65,"OUT_OF_MEMORY"),hi.set(81,"UNINITIALIZED_FUNCTION_CALL");const A8=new RegExp(/^bytes([0-9]*)$/),x8=new RegExp(/^(u?int)([0-9]*)$/);let $d=null;function I8(r,t,e,n){let i="missing revert data",s=null;const a=null;let l=null;if(e){i="execution reverted";const f=ve(e);if(e=At(e),f.length===0)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(f.length%32!==4)i+=" (could not decode reason; invalid data length)";else if(At(f.slice(0,4))==="0x08c379a0")try{s=n.decode(["string"],f.slice(4))[0],l={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch{i+=" (could not decode reason; invalid string data)"}else if(At(f.slice(0,4))==="0x4e487b71")try{const d=Number(n.decode(["uint256"],f.slice(4))[0]);l={signature:"Panic(uint256)",name:"Panic",args:[d]},s=`Panic due to ${hi.get(d)||"UNKNOWN"}(${d})`,i+=`: ${s}`}catch{i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const u={to:t.to?xe(t.to):null,data:t.data||"0x"};return t.from&&(u.from=xe(t.from)),Dr(i,"CALL_EXCEPTION",{action:r,data:e,reason:s,transaction:u,invocation:a,revert:l})}class ya{#t(t){if(t.isArray())return new Y6(this.#t(t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new Ru(t.components.map(n=>this.#t(n)),t.name);switch(t.baseType){case"address":return new Q6(t.name);case"bool":return new Z6(t.name);case"string":return new ax(t.name);case"bytes":return new X6(t.name);case"":return new rx(t.name)}let e=t.type.match(x8);if(e){let n=parseInt(e[2]||"256");return q(n!==0&&n<=256&&n%8===0,"invalid "+e[1]+" bit length","param",t),new ox(n/8,e[1]==="int",t.name)}if(e=t.type.match(A8),e){let n=parseInt(e[1]);return q(n!==0&&n<=32,"invalid bytes length","param",t),new tx(n,t.name)}q(!1,"invalid type","type",t.type)}getDefaultValue(t){const e=t.map(i=>this.#t(Be.from(i)));return new Ru(e,"_").defaultValue()}encode(t,e){im(e.length,t.length,"types/values length mismatch");const n=t.map(a=>this.#t(Be.from(a))),i=new Ru(n,"_"),s=new dd;return i.encode(s,e),s.data}decode(t,e,n){const i=t.map(a=>this.#t(Be.from(a)));return new Ru(i,"_").decode(new pd(e,n))}static defaultAbiCoder(){return $d==null&&($d=new ya),$d}static getBuiltinCallException(t,e,n){return I8(t,e,n,ya.defaultAbiCoder())}}class C8{fragment;name;signature;topic;args;constructor(t,e,n){const i=t.name,s=t.format();Nt(this,{fragment:t,name:i,signature:s,topic:e,args:n})}}class S8{fragment;name;args;signature;selector;value;constructor(t,e,n,i){const s=t.name,a=t.format();Nt(this,{fragment:t,name:s,args:n,signature:a,selector:e,value:i})}}class O8{fragment;name;args;signature;selector;constructor(t,e,n){const i=t.name,s=t.format();Nt(this,{fragment:t,name:i,args:n,signature:s,selector:e})}}class Ey{hash;_isIndexed;static isIndexed(t){return!!(t&&t._isIndexed)}constructor(t){Nt(this,{hash:t,_isIndexed:!0})}}const _y={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"},Ay={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let t="unknown panic code";return r>=0&&r<=255&&_y[r.toString()]&&(t=_y[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${t})`}}};class ba{fragments;deploy;fallback;receive;#t;#e;#r;#n;constructor(t){let e=[];typeof t=="string"?e=JSON.parse(t):e=t,this.#r=new Map,this.#t=new Map,this.#e=new Map;const n=[];for(const a of e)try{n.push(ho.from(a))}catch(l){console.log("EE",l)}Nt(this,{fragments:Object.freeze(n)});let i=null,s=!1;this.#n=this.getAbiCoder(),this.fragments.forEach((a,l)=>{let u;switch(a.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}Nt(this,{deploy:a});return;case"fallback":a.inputs.length===0?s=!0:(q(!i||a.payable!==i.payable,"conflicting fallback fragments",`fragments[${l}]`,a),i=a,s=i.payable);return;case"function":u=this.#r;break;case"event":u=this.#e;break;case"error":u=this.#t;break;default:return}const f=a.format();u.has(f)||u.set(f,a)}),this.deploy||Nt(this,{deploy:qi.from("constructor()")}),Nt(this,{fallback:i,receive:s})}format(t){const e=t?"minimal":"full";return this.fragments.map(i=>i.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return ya.defaultAbiCoder()}#i(t,e,n){if(Qe(t)){const s=t.toLowerCase();for(const a of this.#r.values())if(s===a.selector)return a;return null}if(t.indexOf("(")===-1){const s=[];for(const[a,l]of this.#r)a.split("(")[0]===t&&s.push(l);if(e){const a=e.length>0?e[e.length-1]:null;let l=e.length,u=!0;nr.isTyped(a)&&a.type==="overrides"&&(u=!1,l--);for(let f=s.length-1;f>=0;f--){const d=s[f].inputs.length;d!==l&&(!u||d!==l-1)&&s.splice(f,1)}for(let f=s.length-1;f>=0;f--){const d=s[f].inputs;for(let w=0;w=d.length){if(e[w].type==="overrides")continue;s.splice(f,1);break}if(e[w].type!==d[w].baseType){s.splice(f,1);break}}}}if(s.length===1&&e&&e.length!==s[0].inputs.length){const a=e[e.length-1];(a==null||Array.isArray(a)||typeof a!="object")&&s.splice(0,1)}if(s.length===0)return null;if(s.length>1&&n){const a=s.map(l=>JSON.stringify(l.format())).join(", ");q(!1,`ambiguous function description (i.e. matches ${a})`,"key",t)}return s[0]}const i=this.#r.get(_i.from(t).format());return i||null}getFunctionName(t){const e=this.#i(t,null,!1);return q(e,"no matching function","key",t),e.name}hasFunction(t){return!!this.#i(t,null,!1)}getFunction(t,e){return this.#i(t,e||null,!0)}forEachFunction(t){const e=Array.from(this.#r.keys());e.sort((n,i)=>n.localeCompare(i));for(let n=0;n=0;a--)s[a].inputs.length=0;a--){const l=s[a].inputs;for(let u=0;u1&&n){const a=s.map(l=>JSON.stringify(l.format())).join(", ");q(!1,`ambiguous event description (i.e. matches ${a})`,"key",t)}return s[0]}const i=this.#e.get(Ei.from(t).format());return i||null}getEventName(t){const e=this.#s(t,null,!1);return q(e,"no matching event","key",t),e.name}hasEvent(t){return!!this.#s(t,null,!1)}getEvent(t,e){return this.#s(t,e||null,!0)}forEachEvent(t){const e=Array.from(this.#e.keys());e.sort((n,i)=>n.localeCompare(i));for(let n=0;n1){const s=i.map(a=>JSON.stringify(a.format())).join(", ");q(!1,`ambiguous error description (i.e. ${s})`,"name",t)}return i[0]}if(t=mn.from(t).format(),t==="Error(string)")return mn.from("error Error(string)");if(t==="Panic(uint256)")return mn.from("error Panic(uint256)");const n=this.#t.get(t);return n||null}forEachError(t){const e=Array.from(this.#t.keys());e.sort((n,i)=>n.localeCompare(i));for(let n=0;ns.type==="string"?co(a):s.type==="bytes"?Je(At(a)):(s.type==="bool"&&typeof a=="boolean"?a=a?"0x01":"0x00":s.type.match(/^u?int/)?a=ms(a):s.type.match(/^bytes/)?a=d5(a,32):s.type==="address"&&this.#n.encode(["address"],[a]),oo(At(a),32));for(e.forEach((s,a)=>{const l=t.inputs[a];if(!l.indexed){q(s==null,"cannot filter non-indexed parameters; must be null","contract."+l.name,s);return}s==null?n.push(null):l.baseType==="array"||l.baseType==="tuple"?q(!1,"filtering with tuples or arrays not supported","contract."+l.name,s):Array.isArray(s)?n.push(s.map(u=>i(l,u))):n.push(i(l,s))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(t,e){if(typeof t=="string"){const a=this.getEvent(t);q(a,"unknown event","eventFragment",t),t=a}const n=[],i=[],s=[];return t.anonymous||n.push(t.topicHash),q(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((a,l)=>{const u=e[l];if(a.indexed)if(a.type==="string")n.push(co(u));else if(a.type==="bytes")n.push(Je(u));else{if(a.baseType==="tuple"||a.baseType==="array")throw new Error("not implemented");n.push(this.#n.encode([a.type],[u]))}else i.push(a),s.push(u)}),{data:this.#n.encode(i,s),topics:n}}decodeEventLog(t,e,n){if(typeof t=="string"){const b=this.getEvent(t);q(b,"unknown event","eventFragment",t),t=b}if(n!=null&&!t.anonymous){const b=t.topicHash;q(Qe(n[0],32)&&n[0].toLowerCase()===b,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const i=[],s=[],a=[];t.inputs.forEach((b,E)=>{b.indexed?b.type==="string"||b.type==="bytes"||b.baseType==="tuple"||b.baseType==="array"?(i.push(Be.from({type:"bytes32",name:b.name})),a.push(!0)):(i.push(b),a.push(!1)):(s.push(b),a.push(!1))});const l=n!=null?this.#n.decode(i,br(n)):null,u=this.#n.decode(s,e,!0),f=[],d=[];let w=0,m=0;return t.inputs.forEach((b,E)=>{let C=null;if(b.indexed)if(l==null)C=new Ey(null);else if(a[E])C=new Ey(l[m++]);else try{C=l[m++]}catch(R){C=R}else try{C=u[w++]}catch(R){C=R}f.push(C),d.push(b.name||null)}),la.fromItems(f,d)}parseTransaction(t){const e=ve(t.data,"tx.data"),n=It(t.value!=null?t.value:0,"tx.value"),i=this.getFunction(At(e.slice(0,4)));if(!i)return null;const s=this.#n.decode(i.inputs,e.slice(4));return new S8(i,i.selector,s,n)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new C8(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=At(t),n=this.getError(rr(e,0,4));if(!n)return null;const i=this.#n.decode(n.inputs,rr(e,4));return new O8(n,n.selector,i)}static from(t){return t instanceof ba?t:typeof t=="string"?new ba(JSON.parse(t)):typeof t.format=="function"?new ba(t.format("json")):new ba(t)}}const xy=BigInt(0);function Vc(r){return r??null}function Vr(r){return r==null?null:r.toString()}class Iy{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(t,e,n){Nt(this,{gasPrice:Vc(t),maxFeePerGas:Vc(e),maxPriorityFeePerGas:Vc(n)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:Vr(t),maxFeePerGas:Vr(e),maxPriorityFeePerGas:Vr(n)}}}function zu(r){const t={};r.to&&(t.to=r.to),r.from&&(t.from=r.from),r.data&&(t.data=At(r.data));const e="chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of e)!(i in r)||r[i]==null||(t[i]=It(r[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)!(i in r)||r[i]==null||(t[i]=se(r[i],`request.${i}`));return r.accessList&&(t.accessList=lo(r.accessList)),"blockTag"in r&&(t.blockTag=r.blockTag),"enableCcipRead"in r&&(t.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(t.customData=r.customData),t}class P8{provider;number;hash;timestamp;parentHash;nonce;difficulty;gasLimit;gasUsed;miner;extraData;baseFeePerGas;#t;constructor(t,e){this.#t=t.transactions.map(n=>typeof n!="string"?new qc(n,e):n),Nt(this,{provider:e,hash:Vc(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,miner:t.miner,extraData:t.extraData,baseFeePerGas:Vc(t.baseFeePerGas)})}get transactions(){return this.#t.map(t=>typeof t=="string"?t:t.hash)}get prefetchedTransactions(){const t=this.#t.slice();return t.length===0?[]:(ct(typeof t[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:n,gasLimit:i,gasUsed:s,hash:a,miner:l,nonce:u,number:f,parentHash:d,timestamp:w,transactions:m}=this;return{_type:"Block",baseFeePerGas:Vr(t),difficulty:Vr(e),extraData:n,gasLimit:Vr(i),gasUsed:Vr(s),hash:a,miner:l,nonce:u,number:f,parentHash:d,timestamp:w,transactions:m}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>tnew Gc(i,e)));let n=xy;t.effectiveGasPrice!=null?n=t.effectiveGasPrice:t.gasPrice!=null&&(n=t.gasPrice),Nt(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,gasPrice:n,type:t.type,status:t.status,root:t.root})}get logs(){return this.#t}toJSON(){const{to:t,from:e,contractAddress:n,hash:i,index:s,blockHash:a,blockNumber:l,logsBloom:u,logs:f,status:d,root:w}=this;return{_type:"TransactionReceipt",blockHash:a,blockNumber:l,contractAddress:n,cumulativeGasUsed:Vr(this.cumulativeGasUsed),from:e,gasPrice:Vr(this.gasPrice),gasUsed:Vr(this.gasUsed),hash:i,index:s,logs:f,logsBloom:u,root:w,status:d,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t{if(l)return null;const{blockNumber:m,nonce:b}=await Jr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(b{if(m==null||m.status!==0)return m;ct(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:m.to,from:m.from,data:""},receipt:m})},d=await this.provider.getTransactionReceipt(this.hash);if(n===0)return f(d);if(d){if(await d.confirmations()>=n)return f(d)}else if(await u(),n===0)return null;return await new Promise((m,b)=>{const E=[],C=()=>{E.forEach(k=>k())};if(E.push(()=>{l=!0}),i>0){const k=setTimeout(()=>{C(),b(Dr("wait for transaction timeout","TIMEOUT"))},i);E.push(()=>{clearTimeout(k)})}const R=async k=>{if(await k.confirmations()>=n){C();try{m(f(k))}catch(D){b(D)}}};if(E.push(()=>{this.provider.off(this.hash,R)}),this.provider.on(this.hash,R),s>=0){const k=async()=>{try{await u()}catch(D){if(Gn(D,"TRANSACTION_REPLACED")){C(),b(D);return}}l||this.provider.once("block",k)};E.push(()=>{this.provider.off("block",k)}),this.provider.once("block",k)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}removedEvent(){return ct(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Oy(this)}reorderedEvent(t){return ct(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ct(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Sy(this,t)}replaceableTransaction(t){q(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new qc(this,this.provider);return e.#t=t,e}}function D8(r){return{orphan:"drop-block",hash:r.hash,number:r.number}}function Sy(r,t){return{orphan:"reorder-transaction",tx:r,other:t}}function Oy(r){return{orphan:"drop-transaction",tx:r}}function T8(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class kd extends Gc{interface;fragment;args;constructor(t,e,n){super(t,t.provider);const i=e.decodeEventLog(n,t.data,t.topics);Nt(this,{args:i,fragment:n,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Py extends Gc{error;constructor(t,e){super(t,t.provider),Nt(this,{error:e})}}class N8 extends Cy{#t;constructor(t,e,n){super(n,e),this.#t=t}get logs(){return super.logs.map(t=>{const e=t.topics.length?this.#t.getEvent(t.topics[0]):null;if(e)try{return new kd(t,this.#t,e)}catch(n){return new Py(t,n)}return t})}}class Ud extends qc{#t;constructor(t,e,n){super(n,e),this.#t=t}async wait(t){const e=await super.wait(t);return e==null?null:new N8(this.#t,this.provider,e)}}class Dy extends hm{log;constructor(t,e,n,i){super(t,e,n),Nt(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class R8 extends Dy{constructor(t,e,n,i,s){super(t,e,n,new kd(s,t.interface,i));const a=t.interface.decodeEventLog(i,this.log.data,this.log.topics);Nt(this,{args:a,fragment:i})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Ty=BigInt(0);function Ny(r){return r&&typeof r.call=="function"}function Ry(r){return r&&typeof r.estimateGas=="function"}function Bd(r){return r&&typeof r.resolveName=="function"}function Ly(r){return r&&typeof r.sendTransaction=="function"}class L8{#t;fragment;constructor(t,e,n){if(Nt(this,{fragment:e}),e.inputs.lengthn[u]==null?null:l.walkAsync(n[u],(d,w)=>d==="address"?Array.isArray(w)?Promise.all(w.map(m=>dn(m,s))):dn(w,s):w)));return t.interface.encodeFilterTopics(e,a)}()}getTopicFilter(){return this.#t}}function po(r,t){return r==null?null:typeof r[t]=="function"?r:r.provider&&typeof r.provider[t]=="function"?r.provider:null}function go(r){return r==null?null:r.provider||null}async function $y(r,t){const e=nr.dereference(r,"overrides");q(typeof e=="object","invalid overrides parameter","overrides",r);const n=zu(e);return q(n.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),q(n.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=await dn(n.from)),n}async function $8(r,t,e){const n=po(r,"resolveName"),i=Bd(n)?n:null;return await Promise.all(t.map((s,a)=>s.walkAsync(e[a],(l,u)=>(u=nr.dereference(u,l),l==="address"?dn(u,i):u))))}function k8(r){const t=async function(a){const l=await $y(a,["data"]);l.to=await r.getAddress();const u=r.interface,f=It(l.value||Ty,"overrides.value")===Ty,d=(l.data||"0x")==="0x";u.fallback&&!u.fallback.payable&&u.receive&&!d&&!f&&q(!1,"cannot send data to receive or send value to non-payable fallback","overrides",a),q(u.fallback||d,"cannot send data to receive-only contract","overrides.data",l.data);const w=u.receive||u.fallback&&u.fallback.payable;return q(w||f,"cannot send value to non-payable fallback","overrides.value",l.value),q(u.fallback||d,"cannot send data to receive-only contract","overrides.data",l.data),l},e=async function(a){const l=po(r.runner,"call");ct(Ny(l),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await t(a);try{return await l.call(u)}catch(f){throw ad(f)&&f.data?r.interface.makeError(f.data,u):f}},n=async function(a){const l=r.runner;ct(Ly(l),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await l.sendTransaction(await t(a)),f=go(r.runner);return new Ud(r.interface,f,u)},i=async function(a){const l=po(r.runner,"estimateGas");return ct(Ry(l),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await l.estimateGas(await t(a))},s=async a=>await n(a);return Nt(s,{_contract:r,estimateGas:i,populateTransaction:t,send:n,staticCall:e}),s}function U8(r,t){const e=function(...f){const d=r.interface.getFunction(t,f);return ct(d,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:f}}),d},n=async function(...f){const d=e(...f);let w={};if(d.inputs.length+1===f.length&&(w=await $y(f.pop())),d.inputs.length!==f.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const m=await $8(r.runner,d.inputs,f);return Object.assign({},w,await Jr({to:r.getAddress(),data:r.interface.encodeFunctionData(d,m)}))},i=async function(...f){const d=await l(...f);return d.length===1?d[0]:d},s=async function(...f){const d=r.runner;ct(Ly(d),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const w=await d.sendTransaction(await n(...f)),m=go(r.runner);return new Ud(r.interface,m,w)},a=async function(...f){const d=po(r.runner,"estimateGas");return ct(Ry(d),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await d.estimateGas(await n(...f))},l=async function(...f){const d=po(r.runner,"call");ct(Ny(d),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const w=await n(...f);let m="0x";try{m=await d.call(w)}catch(E){throw ad(E)&&E.data?r.interface.makeError(E.data,w):E}const b=e(...f);return r.interface.decodeFunctionResult(b,m)},u=async(...f)=>e(...f).constant?await i(...f):await s(...f);return Nt(u,{name:r.interface.getFunctionName(t),_contract:r,_key:t,getFragment:e,estimateGas:a,populateTransaction:n,send:s,staticCall:i,staticCallResult:l}),Object.defineProperty(u,"fragment",{configurable:!1,enumerable:!0,get:()=>{const f=r.interface.getFunction(t);return ct(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),f}}),u}function B8(r,t){const e=function(...i){const s=r.interface.getEvent(t,i);return ct(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:i}}),s},n=function(...i){return new L8(r,e(...i),i)};return Nt(n,{name:r.interface.getEventName(t),_contract:r,_key:t,getFragment:e}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const i=r.interface.getEvent(t);return ct(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),i}}),n}const Vu=Symbol.for("_ethersInternal_contract"),ky=new WeakMap;function F8(r,t){ky.set(r[Vu],t)}function Ln(r){return ky.get(r[Vu])}function M8(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function Fd(r,t){let e,n=null;if(Array.isArray(t)){const s=function(a){if(Qe(a,32))return a;const l=r.interface.getEvent(a);return q(l,"unknown fragment","name",a),l.topicHash};e=t.map(a=>a==null?null:Array.isArray(a)?a.map(s):s(a))}else t==="*"?e=[null]:typeof t=="string"?Qe(t,32)?e=[t]:(n=r.interface.getEvent(t),q(n,"unknown fragment","event",t),e=[n.topicHash]):M8(t)?e=await t.getTopicFilter():"fragment"in t?(n=t.fragment,e=[n.topicHash]):q(!1,"unknown event name","event",t);e=e.map(s=>{if(s==null)return null;if(Array.isArray(s)){const a=Array.from(new Set(s.map(l=>l.toLowerCase())).values());return a.length===1?a[0]:(a.sort(),a)}return s.toLowerCase()});const i=e.map(s=>s==null?"null":Array.isArray(s)?s.join("|"):s).join("&");return{fragment:n,tag:i,topics:e}}async function Wc(r,t){const{subs:e}=Ln(r);return e.get((await Fd(r,t)).tag)||null}async function Uy(r,t,e){const n=go(r.runner);ct(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:i,tag:s,topics:a}=await Fd(r,e),{addr:l,subs:u}=Ln(r);let f=u.get(s);if(!f){const w={address:l||r,topics:a},m=R=>{let k=i;if(k==null)try{k=r.interface.getEvent(R.topics[0])}catch{}if(k){const D=k,P=i?r.interface.decodeEventLog(i,R.data,R.topics):[];jd(r,e,P,I=>new R8(r,I,e,D,R))}else jd(r,e,[],D=>new Dy(r,D,e,R))};let b=[];f={tag:s,listeners:[],start:()=>{b.length||b.push(n.on(w,m))},stop:async()=>{if(b.length==0)return;let R=b;b=[],await Promise.all(R),n.off(w,m)}},u.set(s,f)}return f}let Md=Promise.resolve();async function j8(r,t,e,n){await Md;const i=await Wc(r,t);if(!i)return!1;const s=i.listeners.length;return i.listeners=i.listeners.filter(({listener:a,once:l})=>{const u=Array.from(e);n&&u.push(n(l?null:a));try{a.call(r,...u)}catch{}return!l}),i.listeners.length===0&&(i.stop(),Ln(r).subs.delete(i.tag)),s>0}async function jd(r,t,e,n){try{await Md}catch{}const i=j8(r,t,e,n);return Md=i,await i}const Gu=["then"];class Kc{target;interface;runner;filters;[Vu];fallback;constructor(t,e,n,i){q(typeof t=="string"||hw(t),"invalid value for Contract target","target",t),n==null&&(n=null);const s=ba.from(e);Nt(this,{target:t,runner:n,interface:s}),Object.defineProperty(this,Vu,{value:{}});let a,l=null,u=null;if(i){const w=go(n);u=new Ud(this.interface,w,i)}let f=new Map;if(typeof t=="string")if(Qe(t))l=t,a=Promise.resolve(t);else{const w=po(n,"resolveName");if(!Bd(w))throw Dr("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});a=w.resolveName(t).then(m=>{if(m==null)throw Dr("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Ln(this).addr=m,m})}else a=t.getAddress().then(w=>{if(w==null)throw new Error("TODO");return Ln(this).addr=w,w});F8(this,{addrPromise:a,addr:l,deployTx:u,subs:f});const d=new Proxy({},{get:(w,m,b)=>{if(typeof m=="symbol"||Gu.indexOf(m)>=0)return Reflect.get(w,m,b);try{return this.getEvent(m)}catch(E){if(!Gn(E,"INVALID_ARGUMENT")||E.argument!=="key")throw E}},has:(w,m)=>Gu.indexOf(m)>=0?Reflect.has(w,m):Reflect.has(w,m)||this.interface.hasEvent(String(m))});return Nt(this,{filters:d}),Nt(this,{fallback:s.receive||s.fallback?k8(this):null}),new Proxy(this,{get:(w,m,b)=>{if(typeof m=="symbol"||m in w||Gu.indexOf(m)>=0)return Reflect.get(w,m,b);try{return w.getFunction(m)}catch(E){if(!Gn(E,"INVALID_ARGUMENT")||E.argument!=="key")throw E}},has:(w,m)=>typeof m=="symbol"||m in w||Gu.indexOf(m)>=0?Reflect.has(w,m):w.interface.hasFunction(m)})}connect(t){return new Kc(this.target,this.interface,t)}attach(t){return new Kc(t,this.interface,this.runner)}async getAddress(){return await Ln(this).addrPromise}async getDeployedCode(){const t=go(this.runner);ct(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=go(this.runner);return ct(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((i,s)=>{const a=async()=>{try{if(await this.getDeployedCode()!=null)return i(this);n.once("block",a)}catch(l){s(l)}};a()})}deploymentTransaction(){return Ln(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),U8(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),B8(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,n){e==null&&(e=0),n==null&&(n="latest");const{addr:i,addrPromise:s}=Ln(this),a=i||await s,{fragment:l,topics:u}=await Fd(this,t),f={address:a,topics:u,fromBlock:e,toBlock:n},d=go(this.runner);return ct(d,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await d.getLogs(f)).map(w=>{let m=l;if(m==null)try{m=this.interface.getEvent(w.topics[0])}catch{}if(m)try{return new kd(w,this.interface,m)}catch(b){return new Py(w,b)}return new Gc(w,d)})}async on(t,e){const n=await Uy(this,"on",t);return n.listeners.push({listener:e,once:!1}),n.start(),this}async once(t,e){const n=await Uy(this,"once",t);return n.listeners.push({listener:e,once:!0}),n.start(),this}async emit(t,...e){return await jd(this,t,e,null)}async listenerCount(t){if(t){const i=await Wc(this,t);return i?i.listeners.length:0}const{subs:e}=Ln(this);let n=0;for(const{listeners:i}of e.values())n+=i.length;return n}async listeners(t){if(t){const i=await Wc(this,t);return i?i.listeners.map(({listener:s})=>s):[]}const{subs:e}=Ln(this);let n=[];for(const{listeners:i}of e.values())n=n.concat(i.map(({listener:s})=>s));return n}async off(t,e){const n=await Wc(this,t);if(!n)return this;if(e){const i=n.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&n.listeners.splice(i,1)}return(e==null||n.listeners.length===0)&&(n.stop(),Ln(this).subs.delete(n.tag)),this}async removeAllListeners(t){if(t){const e=await Wc(this,t);if(!e)return this;e.stop(),Ln(this).subs.delete(e.tag)}else{const{subs:e}=Ln(this);for(const{tag:n,stop:i}of e.values())i(),e.delete(n)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends Kc{constructor(i,s=null){super(i,t,s)}}return e}static from(t,e,n){return n==null&&(n=null),new this(t,e,n)}}function H8(){return Kc}class Qc extends H8(){}function Hd(r){return r.match(/^ipfs:\/\/ipfs\//i)?r=r.substring(12):r.match(/^ipfs:\/\//i)?r=r.substring(7):q(!1,"unsupported IPFS format","link",r),`https://gateway.ipfs.io/ipfs/${r}`}class z8{name;constructor(t){Nt(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const By=new RegExp("^(ipfs)://(.*)$","i"),Fy=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),By,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];class va{provider;address;name;#t;#e;constructor(t,e,n){Nt(this,{provider:t,address:e,name:n}),this.#t=null,this.#e=new Qc(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t)}async supportsWildcard(){return this.#t==null&&(this.#t=(async()=>{try{return await this.#e.supportsInterface("0x9061b923")}catch(t){if(Gn(t,"CALL_EXCEPTION"))return!1;throw this.#t=null,t}})()),await this.#t}async#r(t,e){e=(e||[]).slice();const n=this.#e.interface;e.unshift(Dd(this.name));let i=null;await this.supportsWildcard()&&(i=n.getFunction(t),ct(i,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[Jx(this.name),n.encodeFunctionData(i,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const s=await this.#e[t](...e);return i?n.decodeFunctionResult(i,s)[0]:s}catch(s){if(!Gn(s,"CALL_EXCEPTION"))throw s}return null}async getAddress(t){if(t==null&&(t=60),t===60)try{const s=await this.#r("addr(bytes32)");return s==null||s===_d?null:s}catch(s){if(Gn(s,"CALL_EXCEPTION"))return null;throw s}if(t>=0&&t<2147483648){let s=t+2147483648;const a=await this.#r("addr(bytes32,uint)",[s]);if(Qe(a,20))return xe(a)}let e=null;for(const s of this.provider.plugins)if(s instanceof z8&&s.supportsCoinType(t)){e=s;break}if(e==null)return null;const n=await this.#r("addr(bytes32,uint)",[t]);if(n==null||n==="0x")return null;const i=await e.decodeAddress(t,n);if(i!=null)return i;ct(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:n}})}async getText(t){const e=await this.#r("text(bytes32,string)",[t]);return e==null||e==="0x"?null:e}async getContentHash(){const t=await this.#r("contenthash(bytes32)");if(t==null||t==="0x")return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const i=e[1]==="e3010170"?"ipfs":"ipns",s=parseInt(e[4],16);if(e[5].length===s*2)return`${i}://${w5("0x"+e[2])}`}const n=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;ct(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(e==null)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let n=0;n{if(!Array.isArray(t))throw new Error("not an array");return t.map(e=>r(e))}}function Jc(r,t){return e=>{const n={};for(const i in r){let s=i;if(t&&i in t&&!(s in e)){for(const a of t[i])if(a in e){s=a;break}}try{const a=r[i](e[s]);a!==void 0&&(n[i]=a)}catch(a){const l=a instanceof Error?a.message:"not-an-error";ct(!1,`invalid value for value.${i} (${l})`,"BAD_DATA",{value:e})}}return n}}function V8(r){switch(r){case!0:case"true":return!0;case!1:case"false":return!1}q(!1,`invalid boolean; ${JSON.stringify(r)}`,"value",r)}function Ea(r){return q(Qe(r,!0),"invalid data","value",r),r}function Kn(r){return q(Qe(r,32),"invalid hash","value",r),r}const G8=Jc({address:xe,blockHash:Kn,blockNumber:se,data:Ea,index:se,removed:Ze(V8,!1),topics:zd(Kn),transactionHash:Kn,transactionIndex:se},{index:["logIndex"]});function q8(r){return G8(r)}const W8=Jc({hash:Ze(Kn),parentHash:Kn,number:se,timestamp:se,nonce:Ze(Ea),difficulty:It,gasLimit:It,gasUsed:It,miner:Ze(xe),extraData:Ea,baseFeePerGas:Ze(It)});function K8(r){const t=W8(r);return t.transactions=r.transactions.map(e=>typeof e=="string"?e:jy(e)),t}const Q8=Jc({transactionIndex:se,blockNumber:se,transactionHash:Kn,address:xe,topics:zd(Kn),data:Ea,index:se,blockHash:Kn},{index:["logIndex"]});function J8(r){return Q8(r)}const Y8=Jc({to:Ze(xe,null),from:Ze(xe,null),contractAddress:Ze(xe,null),index:se,root:Ze(At),gasUsed:It,logsBloom:Ze(Ea),blockHash:Kn,hash:Kn,logs:zd(J8),blockNumber:se,cumulativeGasUsed:It,effectiveGasPrice:Ze(It),status:Ze(se),type:Ze(se,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function Z8(r){return Y8(r)}function jy(r){r.to&&It(r.to)===My&&(r.to="0x0000000000000000000000000000000000000000");const t=Jc({hash:Kn,type:e=>e==="0x"||e==null?0:se(e),accessList:Ze(lo,null),blockHash:Ze(Kn,null),blockNumber:Ze(se,null),transactionIndex:Ze(se,null),from:xe,gasPrice:Ze(It),maxPriorityFeePerGas:Ze(It),maxFeePerGas:Ze(It),gasLimit:It,to:Ze(xe,null),value:It,nonce:se,data:Ea,creates:Ze(xe,null),chainId:Ze(It,null)},{data:["input"],gasLimit:["gas"]})(r);if(t.to==null&&t.creates==null&&(t.creates=K6(t)),(r.type===1||r.type===2)&&r.accessList==null&&(t.accessList=[]),r.signature?t.signature=Tr.from(r.signature):t.signature=Tr.from(r),t.chainId==null){const e=t.signature.legacyChainId;e!=null&&(t.chainId=e)}return t.blockHash&&It(t.blockHash)===My&&(t.blockHash=null),t}const X8="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Yc{name;constructor(t){Nt(this,{name:t})}clone(){return new Yc(this.name)}}class qu extends Yc{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(t,e){t==null&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`);const n={effectiveBlock:t};function i(s,a){let l=(e||{})[s];l==null&&(l=a),q(typeof l=="number",`invalud value for ${s}`,"costs",e),n[s]=l}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),Nt(this,n)}clone(){return new qu(this.effectiveBlock,this)}}class Wu extends Yc{address;targetNetwork;constructor(t,e){super("org.ethers.plugins.network.Ens"),Nt(this,{address:t||X8,targetNetwork:e??1})}clone(){return new Wu(this.address,this.targetNetwork)}}class Hy extends Yc{#t;#e;get url(){return this.#t}get processFunc(){return this.#e}constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),this.#t=t,this.#e=e}clone(){return this}}const Vd=new Map;let mo=class gu{#t;#e;#r;constructor(t,e){this.#t=t,this.#e=It(e),this.#r=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#t}set name(t){this.#t=t}get chainId(){return this.#e}set chainId(t){this.#e=It(t,"chainId")}matches(t){if(t==null)return!1;if(typeof t=="string"){try{return this.chainId===It(t)}catch{}return this.name===t}if(typeof t=="number"||typeof t=="bigint"){try{return this.chainId===It(t)}catch{}return!1}if(typeof t=="object"){if(t.chainId!=null){try{return this.chainId===It(t.chainId)}catch{}return!1}return t.name!=null?this.name===t.name:!1}return!1}get plugins(){return Array.from(this.#r.values())}attachPlugin(t){if(this.#r.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#r.set(t.name,t.clone()),this}getPlugin(t){return this.#r.get(t)||null}getPlugins(t){return this.plugins.filter(e=>e.name.split("#")[0]===t)}clone(){const t=new gu(this.name,this.chainId);return this.plugins.forEach(e=>{t.attachPlugin(e.clone())}),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new qu;let n=e.txBase;if(t.to==null&&(n+=e.txCreate),t.data)for(let i=2;i9){let i=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||i++,n[1]=i.toString()}return BigInt(n[0]+n[1])}function Vy(r){return new Hy(r,async(t,e,n)=>{n.setHeader("User-Agent","ethers");let i;try{const[s,a]=await Promise.all([n.send(),t()]);i=s;const l=i.bodyJson.standard;return{gasPrice:a.gasPrice,maxFeePerGas:zy(l.maxFee,9),maxPriorityFeePerGas:zy(l.maxPriorityFee,9)}}catch(s){ct(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:i,error:s})}})}function t4(r){return new Hy("data:",async(t,e,n)=>{const i=await t();if(i.maxFeePerGas==null||i.maxPriorityFeePerGas==null)return i;const s=i.maxFeePerGas-i.maxPriorityFeePerGas;return{gasPrice:i.gasPrice,maxFeePerGas:s+r,maxPriorityFeePerGas:r}})}let Gy=!1;function e4(){if(Gy)return;Gy=!0;function r(t,e,n){const i=function(){const s=new mo(t,e);return n.ensNetwork!=null&&s.attachPlugin(new Wu(null,n.ensNetwork)),s.attachPlugin(new qu),(n.plugins||[]).forEach(a=>{s.attachPlugin(a)}),s};mo.register(t,i),mo.register(e,i),n.altNames&&n.altNames.forEach(s=>{mo.register(s,i)})}r("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),r("ropsten",3,{ensNetwork:3}),r("rinkeby",4,{ensNetwork:4}),r("goerli",5,{ensNetwork:5}),r("kovan",42,{ensNetwork:42}),r("sepolia",11155111,{}),r("classic",61,{}),r("classicKotti",6,{}),r("arbitrum",42161,{ensNetwork:1}),r("arbitrum-goerli",421613,{}),r("bnb",56,{ensNetwork:1}),r("bnbt",97,{}),r("linea",59144,{ensNetwork:1}),r("linea-goerli",59140,{}),r("matic",137,{ensNetwork:1,plugins:[Vy("https://gasstation.polygon.technology/v2")]}),r("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Vy("https://gasstation-testnet.polygon.technology/v2")]}),r("optimism",10,{ensNetwork:1,plugins:[t4(BigInt("1000000"))]}),r("optimism-goerli",420,{}),r("xdai",100,{ensNetwork:1})}function Gd(r){return JSON.parse(JSON.stringify(r))}class r4{#t;#e;#r;#n;constructor(t){this.#t=t,this.#e=null,this.#r=4e3,this.#n=-2}get pollingInterval(){return this.#r}set pollingInterval(t){this.#r=t}async#i(){try{const t=await this.#t.getBlockNumber();if(this.#n===-2){this.#n=t;return}if(t!==this.#n){for(let e=this.#n+1;e<=t;e++){if(this.#e==null)return;await this.#t.emit("block",e)}this.#n=t}}catch{}this.#e!=null&&(this.#e=this.#t._setTimeout(this.#i.bind(this),this.#r))}start(){this.#e||(this.#e=this.#t._setTimeout(this.#i.bind(this),this.#r),this.#i())}stop(){this.#e&&(this.#t._clearTimeout(this.#e),this.#e=null)}pause(t){this.stop(),t&&(this.#n=-2)}resume(){this.start()}}class qy{#t;#e;#r;constructor(t){this.#t=t,this.#r=!1,this.#e=e=>{this._poll(e,this.#t)}}async _poll(t,e){throw new Error("sub-classes must override this")}start(){this.#r||(this.#r=!0,this.#e(-2),this.#t.on("block",this.#e))}stop(){this.#r&&(this.#r=!1,this.#t.off("block",this.#e))}pause(t){this.stop()}resume(){this.start()}}class n4 extends qy{#t;constructor(t,e){super(t),this.#t=Gd(e)}async _poll(t,e){throw new Error("@TODO")}}class i4 extends qy{#t;constructor(t,e){super(t),this.#t=e}async _poll(t,e){const n=await e.getTransactionReceipt(this.#t);n&&e.emit(this.#t,n)}}class qd{#t;#e;#r;#n;#i;constructor(t,e){this.#t=t,this.#e=Gd(e),this.#r=this.#s.bind(this),this.#n=!1,this.#i=-2}async#s(t){if(this.#i===-2)return;const e=Gd(this.#e);e.fromBlock=this.#i+1,e.toBlock=t;const n=await this.#t.getLogs(e);if(n.length===0){this.#i{this.#i=t}),this.#t.on("block",this.#r))}stop(){this.#n&&(this.#n=!1,this.#t.off("block",this.#r))}pause(t){this.stop(),t&&(this.#i=-2)}resume(){this.start()}}const s4=BigInt(2),o4=10;function Ku(r){return r&&typeof r.then=="function"}function Qu(r,t){return r+":"+JSON.stringify(t,(e,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const i=Object.keys(n);return i.sort(),i.reduce((s,a)=>(s[a]=n[a],s),{})}return n})}class Wy{name;constructor(t){Nt(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function a4(r){return JSON.parse(JSON.stringify(r))}function Wd(r){return r=Array.from(new Set(r).values()),r.sort(),r}async function Kd(r,t){if(r==null)throw new Error("invalid event");if(Array.isArray(r)&&(r={topics:r}),typeof r=="string")switch(r){case"block":case"pending":case"debug":case"error":case"network":return{type:r,tag:r}}if(Qe(r,32)){const e=r.toLowerCase();return{type:"transaction",tag:Qu("tx",{hash:e}),hash:e}}if(r.orphan){const e=r;return{type:"orphan",tag:Qu("orphan",e),filter:a4(e)}}if(r.address||r.topics){const e=r,n={topics:(e.topics||[]).map(i=>i==null?null:Array.isArray(i)?Wd(i.map(s=>s.toLowerCase())):i.toLowerCase())};if(e.address){const i=[],s=[],a=l=>{Qe(l)?i.push(l):s.push((async()=>{i.push(await dn(l,t))})())};Array.isArray(e.address)?e.address.forEach(a):a(e.address),s.length&&await Promise.all(s),n.address=Wd(i.map(l=>l.toLowerCase()))}return{filter:n,tag:Qu("event",n),type:"event"}}q(!1,"unknown ProviderEvent","event",r)}function Qd(){return new Date().getTime()}const c4={cacheTimeout:250,pollingInterval:4e3};class l4{#t;#e;#r;#n;#i;#s;#o;#a;#u;#l;#h;#f;constructor(t,e){if(this.#f=Object.assign({},c4,e||{}),t==="any")this.#s=!0,this.#i=null;else if(t){const n=mo.from(t);this.#s=!1,this.#i=Promise.resolve(n),setTimeout(()=>{this.emit("network",n,null)},0)}else this.#s=!1,this.#i=null;this.#a=-1,this.#o=new Map,this.#t=new Map,this.#e=new Map,this.#r=null,this.#n=!1,this.#u=1,this.#l=new Map,this.#h=!1}get pollingInterval(){return this.#f.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#e.values())}attachPlugin(t){if(this.#e.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#e.set(t.name,t.connect(this)),this}getPlugin(t){return this.#e.get(t)||null}get disableCcipRead(){return this.#h}set disableCcipRead(t){this.#h=!!t}async#c(t){const e=this.#f.cacheTimeout;if(e<0)return await this._perform(t);const n=Qu(t.method,t);let i=this.#o.get(n);return i||(i=this._perform(t),this.#o.set(n,i),setTimeout(()=>{this.#o.get(n)===i&&this.#o.delete(n)},e)),await i}async ccipReadFetch(t,e,n){if(this.disableCcipRead||n.length===0||t.to==null)return null;const i=t.to.toLowerCase(),s=e.toLowerCase(),a=[];for(let l=0;l=500,`response not found during CCIP fetch: ${w}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:u,errorMessage:w}}),a.push(w)}ct(!1,`error encountered during CCIP fetch: ${a.map(l=>JSON.stringify(l)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:n,errorMessages:a}})}_wrapBlock(t,e){return new P8(K8(t),this)}_wrapLog(t,e){return new Gc(q8(t),this)}_wrapTransactionReceipt(t,e){return new Cy(Z8(t),this)}_wrapTransactionResponse(t,e){return new qc(jy(t),this)}_detectNetwork(){ct(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){ct(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=se(await this.#c({method:"getBlockNumber"}),"%response");return this.#a>=0&&(this.#a=t),t}_getAddress(t){return dn(t,this)}_getBlockTag(t){if(t==null)return"latest";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(Qe(t))return Qe(t,32)?t:ca(t);if(typeof t=="bigint"&&(t=se(t,"blockTag")),typeof t=="number")return t>=0?ca(t):this.#a>=0?ca(this.#a+t):this.getBlockNumber().then(e=>ca(e+t));q(!1,"invalid blockTag","blockTag",t)}_getFilter(t){const e=(t.topics||[]).map(u=>u==null?null:Array.isArray(u)?Wd(u.map(f=>f.toLowerCase())):u.toLowerCase()),n="blockHash"in t?t.blockHash:void 0,i=(u,f,d)=>{let w;switch(u.length){case 0:break;case 1:w=u[0];break;default:u.sort(),w=u}if(n&&(f!=null||d!=null))throw new Error("invalid filter");const m={};return w&&(m.address=w),e.length&&(m.topics=e),f&&(m.fromBlock=f),d&&(m.toBlock=d),n&&(m.blockHash=n),m};let s=[];if(t.address)if(Array.isArray(t.address))for(const u of t.address)s.push(this._getAddress(u));else s.push(this._getAddress(t.address));let a;"fromBlock"in t&&(a=this._getBlockTag(t.fromBlock));let l;return"toBlock"in t&&(l=this._getBlockTag(t.toBlock)),s.filter(u=>typeof u!="string").length||a!=null&&typeof a!="string"||l!=null&&typeof l!="string"?Promise.all([Promise.all(s),a,l]).then(u=>i(u[0],u[1],u[2])):i(s,a,l)}_getTransactionRequest(t){const e=zu(t),n=[];if(["to","from"].forEach(i=>{if(e[i]==null)return;const s=dn(e[i]);Ku(s)?n.push(async function(){e[i]=await s}()):e[i]=s}),e.blockTag!=null){const i=this._getBlockTag(e.blockTag);Ku(i)?n.push(async function(){e.blockTag=await i}()):e.blockTag=i}return n.length?async function(){return await Promise.all(n),e}():e}async getNetwork(){if(this.#i==null){const i=this._detectNetwork().then(s=>(this.emit("network",s,null),s),s=>{throw this.#i===i&&(this.#i=null),s});return this.#i=i,(await i).clone()}const t=this.#i,[e,n]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==n.chainId&&(this.#s?(this.emit("network",n,e),this.#i===t&&(this.#i=Promise.resolve(n))):ct(!1,`network changed: ${e.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:i,gasPrice:s}=await Jr({_block:this.#y("latest",!1),gasPrice:(async()=>{try{const f=await this.#c({method:"getGasPrice"});return It(f,"%response")}catch{}return null})()});let a=null,l=null;const u=this._wrapBlock(i,t);return u&&u.baseFeePerGas&&(l=BigInt("1000000000"),a=u.baseFeePerGas*s4+l),new Iy(s,a,l)},n=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const i=new Mi(n.url),s=await n.processFunc(e,this,i);return new Iy(s.gasPrice,s.maxFeePerGas,s.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return Ku(e)&&(e=await e),It(await this.#c({method:"estimateGas",transaction:e}),"%response")}async#d(t,e,n){ct(n=0&&e==="latest"&&i.to!=null&&rr(s.data,0,4)==="0x556f1830"){const a=s.data,l=await dn(i.to,this);let u;try{u=p4(rr(s.data,4))}catch(w){ct(!1,w.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:i,info:{data:a}})}ct(u.sender.toLowerCase()===l.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:a,reason:"OffchainLookup",transaction:i,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:u.errorArgs}});const f=await this.ccipReadFetch(i,u.calldata,u.urls);ct(f!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:i,info:{data:s.data,errorArgs:u.errorArgs}});const d={to:l,data:br([u.selector,d4([f,u.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:d});try{const w=await this.#d(d,e,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},d),result:w}),w}catch(w){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},d),error:w}),w}}throw s}}async#p(t){const{value:e}=await Jr({network:this.getNetwork(),value:t});return e}async call(t){const{tx:e,blockTag:n}=await Jr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await this.#p(this.#d(e,n,t.enableCcipRead?0:-1))}async#g(t,e,n){let i=this._getAddress(e),s=this._getBlockTag(n);return(typeof i!="string"||typeof s!="string")&&([i,s]=await Promise.all([i,s])),await this.#p(this.#c(Object.assign(t,{address:i,blockTag:s})))}async getBalance(t,e){return It(await this.#g({method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return se(await this.#g({method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return At(await this.#g({method:"getCode"},t,e))}async getStorage(t,e,n){const i=It(e,"position");return At(await this.#g({method:"getStorage",position:i},t,n))}async broadcastTransaction(t){const{blockNumber:e,hash:n,network:i}=await Jr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),s=Yw.from(t);if(s.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(s,i).replaceableTransaction(e)}async#y(t,e){if(Qe(t,32))return await this.#c({method:"getBlock",blockHash:t,includeTransactions:e});let n=this._getBlockTag(t);return typeof n!="string"&&(n=await n),await this.#c({method:"getBlock",blockTag:n,includeTransactions:e})}async getBlock(t,e){const{network:n,params:i}=await Jr({network:this.getNetwork(),params:this.#y(t,!!e)});return i==null?null:this._wrapBlock(i,n)}async getTransaction(t){const{network:e,params:n}=await Jr({network:this.getNetwork(),params:this.#c({method:"getTransaction",hash:t})});return n==null?null:this._wrapTransactionResponse(n,e)}async getTransactionReceipt(t){const{network:e,params:n}=await Jr({network:this.getNetwork(),params:this.#c({method:"getTransactionReceipt",hash:t})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const i=await this.#c({method:"getTransaction",hash:t});if(i==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=i.gasPrice}return this._wrapTransactionReceipt(n,e)}async getTransactionResult(t){const{result:e}=await Jr({network:this.getNetwork(),result:this.#c({method:"getTransactionResult",hash:t})});return e==null?null:At(e)}async getLogs(t){let e=this._getFilter(t);Ku(e)&&(e=await e);const{network:n,params:i}=await Jr({network:this.getNetwork(),params:this.#c({method:"getLogs",filter:e})});return i.map(s=>this._wrapLog(s,n))}_getProvider(t){ct(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await va.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){t=xe(t);const e=Dd(t.substring(2).toLowerCase()+".addr.reverse");try{const n=await va.getEnsAddress(this),s=await new Qc(n,["function resolver(bytes32) view returns (address)"],this).resolver(e);if(s==null||s===_d)return null;const l=await new Qc(s,["function name(bytes32) view returns (string)"],this).name(e);return await this.resolveName(l)!==t?null:l}catch(n){if(Gn(n,"BAD_DATA")&&n.value==="0x"||Gn(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(t,e,n){const i=e??1;return i===0?this.getTransactionReceipt(t):new Promise(async(s,a)=>{let l=null;const u=async f=>{try{const d=await this.getTransactionReceipt(t);if(d!=null&&f-d.blockNumber+1>=i){s(d),l&&(clearTimeout(l),l=null);return}}catch(d){console.log("EEE",d)}this.once("block",u)};n!=null&&(l=setTimeout(()=>{l!=null&&(l=null,this.off("block",u),a(Dr("timeout","TIMEOUT",{reason:"timeout"})))},n)),u(await this.getBlockNumber())})}async waitForBlock(t){ct(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=this.#l.get(t);e&&(e.timer&&clearTimeout(e.timer),this.#l.delete(t))}_setTimeout(t,e){e==null&&(e=0);const n=this.#u++,i=()=>{this.#l.delete(n),t()};if(this.paused)this.#l.set(n,{timer:null,func:i,time:e});else{const s=setTimeout(i,e);this.#l.set(n,{timer:s,func:i,time:Qd()})}return n}_forEachSubscriber(t){for(const e of this.#t.values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Wy(t.type);case"block":{const e=new r4(this);return e.pollingInterval=this.pollingInterval,e}case"event":return new qd(this,t.filter);case"transaction":return new i4(this,t.hash);case"orphan":return new n4(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const n of this.#t.values())if(n.subscriber===t){n.started&&n.subscriber.stop(),n.subscriber=e,n.started&&e.start(),this.#r!=null&&e.pause(this.#r);break}}async#m(t,e){let n=await Kd(t,this);return n.type==="event"&&e&&e.length>0&&e[0].removed===!0&&(n=await Kd({orphan:"drop-log",log:e[0]},this)),this.#t.get(n.tag)||null}async#w(t){const e=await Kd(t,this),n=e.tag;let i=this.#t.get(n);return i||(i={subscriber:this._getSubscriber(e),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#t.set(n,i)),i}async on(t,e){const n=await this.#w(t);return n.listeners.push({listener:e,once:!1}),n.started||(n.subscriber.start(),n.started=!0,this.#r!=null&&n.subscriber.pause(this.#r)),this}async once(t,e){const n=await this.#w(t);return n.listeners.push({listener:e,once:!0}),n.started||(n.subscriber.start(),n.started=!0,this.#r!=null&&n.subscriber.pause(this.#r)),this}async emit(t,...e){const n=await this.#m(t,e);if(!n||n.listeners.length===0)return!1;const i=n.listeners.length;return n.listeners=n.listeners.filter(({listener:s,once:a})=>{const l=new hm(this,a?null:s,t);try{s.call(this,...e,l)}catch{}return!a}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),this.#t.delete(n.tag)),i>0}async listenerCount(t){if(t){const n=await this.#m(t);return n?n.listeners.length:0}let e=0;for(const{listeners:n}of this.#t.values())e+=n.length;return e}async listeners(t){if(t){const n=await this.#m(t);return n?n.listeners.map(({listener:i})=>i):[]}let e=[];for(const{listeners:n}of this.#t.values())e=e.concat(n.map(({listener:i})=>i));return e}async off(t,e){const n=await this.#m(t);if(!n)return this;if(e){const i=n.listeners.map(({listener:s})=>s).indexOf(e);i>=0&&n.listeners.splice(i,1)}return(!e||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),this.#t.delete(n.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:n,subscriber:i}=await this.#w(t);n&&i.stop(),this.#t.delete(e)}else for(const[e,{started:n,subscriber:i}]of this.#t)n&&i.stop(),this.#t.delete(e);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return this.#n}destroy(){this.removeAllListeners();for(const t of this.#l.keys())this._clearTimeout(t);this.#n=!0}get paused(){return this.#r!=null}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(this.#a=-1,this.#r!=null){if(this.#r==!!t)return;ct(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(e=>e.pause(t)),this.#r=!!t;for(const e of this.#l.values())e.timer&&clearTimeout(e.timer),e.time=Qd()-e.time}resume(){if(this.#r!=null){this._forEachSubscriber(t=>t.resume()),this.#r=null;for(const t of this.#l.values()){let e=t.time;e<0&&(e=0),t.time=Qd(),setTimeout(t.func,e)}}}}function u4(r,t){try{const e=Jd(r,t);if(e)return ld(e)}catch{}return null}function Jd(r,t){if(r==="0x")return null;try{const e=se(rr(r,t,t+32)),n=se(rr(r,e,e+32));return rr(r,e+32,e+32+n)}catch{}return null}function Ky(r){const t=Pn(r);if(t.length>32)throw new Error("internal; should not happen");const e=new Uint8Array(32);return e.set(t,32-t.length),e}function h4(r){if(r.length%32===0)return r;const t=new Uint8Array(Math.ceil(r.length/32)*32);return t.set(r),t}const f4=new Uint8Array([]);function d4(r){const t=[];let e=0;for(let n=0;n=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const e=rr(r,0,32);ct(rr(e,0,12)===rr(Qy,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),t.sender=rr(e,12);try{const n=[],i=se(rr(r,32,64)),s=se(rr(r,i,i+32)),a=rr(r,i+32);for(let l=0;lt[n]),t}function _a(r,t){if(r.provider)return r.provider;ct(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:t})}async function Jy(r,t){let e=zu(t);if(e.to!=null&&(e.to=dn(e.to,r)),e.from!=null){const n=e.from;e.from=Promise.all([r.getAddress(),dn(n,r)]).then(([i,s])=>(q(i.toLowerCase()===s.toLowerCase(),"transaction from mismatch","tx.from",s),i))}else e.from=r.getAddress();return await Jr(e)}class g4{provider;constructor(t){Nt(this,{provider:t||null})}async getNonce(t){return _a(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await Jy(this,t)}async populateTransaction(t){const e=_a(this,"populateTransaction"),n=await Jy(this,t);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const i=await this.provider.getNetwork();if(n.chainId!=null){const a=It(n.chainId);q(a===i.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else n.chainId=i.chainId;const s=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||s)?q(!1,"eip-1559 transaction do not support gasPrice","tx",t):(n.type===0||n.type===1)&&s&&q(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const a=await e.getFeeData();ct(a.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=a.gasPrice)}else{const a=await e.getFeeData();if(n.type==null)if(a.maxFeePerGas!=null&&a.maxPriorityFeePerGas!=null)if(n.type=2,n.gasPrice!=null){const l=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=l,n.maxPriorityFeePerGas=l}else n.maxFeePerGas==null&&(n.maxFeePerGas=a.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=a.maxPriorityFeePerGas);else a.gasPrice!=null?(ct(!s,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=a.gasPrice),n.type=0):ct(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else n.type===2&&(n.maxFeePerGas==null&&(n.maxFeePerGas=a.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=a.maxPriorityFeePerGas))}return await Jr(n)}async estimateGas(t){return _a(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return _a(this,"call").call(await this.populateCall(t))}async resolveName(t){return await _a(this,"resolveName").resolveName(t)}async sendTransaction(t){const e=_a(this,"sendTransaction"),n=await this.populateTransaction(t);delete n.from;const i=Yw.from(n);return await e.broadcastTransaction(await this.signTransaction(i))}}function m4(r){return JSON.parse(JSON.stringify(r))}class Yy{#t;#e;#r;#n;#i;#s;constructor(t){this.#t=t,this.#e=null,this.#r=this.#o.bind(this),this.#n=!1,this.#i=null,this.#s=!1}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}async#o(t){try{this.#e==null&&(this.#e=this._subscribe(this.#t));let e=null;try{e=await this.#e}catch(s){if(!Gn(s,"UNSUPPORTED_OPERATION")||s.operation!=="eth_newFilter")throw s}if(e==null){this.#e=null,this.#t._recoverSubscriber(this,this._recover(this.#t));return}const n=await this.#t.getNetwork();if(this.#i||(this.#i=n),this.#i.chainId!==n.chainId)throw new Error("chaid changed");if(this.#s)return;const i=await this.#t.send("eth_getFilterChanges",[e]);await this._emitResults(this.#t,i)}catch(e){console.log("@TODO",e)}this.#t.once("block",this.#r)}#a(){const t=this.#e;t&&(this.#e=null,t.then(e=>{this.#t.send("eth_uninstallFilter",[e])}))}start(){this.#n||(this.#n=!0,this.#o(-2))}stop(){this.#n&&(this.#n=!1,this.#s=!0,this.#a(),this.#t.off("block",this.#r))}pause(t){t&&this.#a(),this.#t.off("block",this.#r)}resume(){this.start()}}class w4 extends Yy{#t;constructor(t,e){super(t),this.#t=m4(e)}_recover(t){return new qd(t,this.#t)}async _subscribe(t){return await t.send("eth_newFilter",[this.#t])}async _emitResults(t,e){for(const n of e)t.emit(this.#t,t._wrapLog(n,t._network))}}class y4 extends Yy{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const n of e)t.emit("pending",n)}}const b4="bigint,boolean,function,number,string,symbol".split(/,/g);function Ju(r){if(r==null||b4.indexOf(typeof r)>=0||typeof r.getAddress=="function")return r;if(Array.isArray(r))return r.map(Ju);if(typeof r=="object")return Object.keys(r).reduce((t,e)=>(t[e]=r[e],t),{});throw new Error(`should not happen: ${r} (${typeof r})`)}function v4(r){return new Promise(t=>{setTimeout(t,r)})}function Aa(r){return r&&r.toLowerCase()}function Zy(r){return r&&typeof r.pollingInterval=="number"}const E4={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Yd extends g4{address;constructor(t,e){super(t),e=xe(e),Nt(this,{address:e})}connect(t){ct(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const e=Ju(t),n=[];if(e.from){const s=e.from;n.push((async()=>{const a=await dn(s,this.provider);q(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=a})())}else e.from=this.address;if(e.gasLimit==null&&n.push((async()=>{e.gasLimit=await this.provider.estimateGas({...e,from:this.address})})()),e.to!=null){const s=e.to;n.push((async()=>{e.to=await dn(s,this.provider)})())}n.length&&await Promise.all(n);const i=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const e=await this.provider.getBlockNumber(),n=await this.sendUncheckedTransaction(t);return await new Promise((i,s)=>{const a=[1e3,100],l=async()=>{const u=await this.provider.getTransaction(n);if(u!=null){i(u.replaceableTransaction(e));return}this.provider._setTimeout(()=>{l()},a.pop()||4e3)};l()})}async signTransaction(t){const e=Ju(t);if(e.from){const i=await dn(e.from,this.provider);q(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=i}else e.from=this.address;const n=this.provider.getRpcTransaction(e);return await this.provider.send("eth_signTransaction",[n])}async signMessage(t){const e=typeof t=="string"?Fi(t):t;return await this.provider.send("personal_sign",[At(e),this.address.toLowerCase()])}async signTypedData(t,e,n){const i=Ju(n),s=await Rn.resolveNames(t,e,i,async a=>{const l=await dn(a);return q(l!=null,"TypedData does not support null address","value",a),l});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Rn.getPayload(s.domain,e,s.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const e=typeof t=="string"?Fi(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),At(e)])}}class _4 extends l4{#t;#e;#r;#n;#i;#s;#o(){if(this.#n)return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");this.#n=setTimeout(()=>{this.#n=null;const e=this.#r;for(this.#r=[];e.length;){const n=[e.shift()];for(;e.length&&n.length!==this.#t.batchMaxCount;)if(n.push(e.shift()),JSON.stringify(n.map(s=>s.payload)).length>this.#t.batchMaxSize){e.unshift(n.pop());break}(async()=>{const i=n.length===1?n[0].payload:n.map(s=>s.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const s=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:s});for(const{resolve:a,reject:l,payload:u}of n){if(this.destroyed){l(Dr("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:u.method}));continue}const f=s.filter(d=>d.id===u.id)[0];if(f==null){const d=Dr("missing response for request","BAD_DATA",{value:s,info:{payload:u}});this.emit("error",d),l(d);continue}if("error"in f){l(this.getRpcError(u,f));continue}a(f.result)}}catch(s){this.emit("debug",{action:"receiveRpcError",error:s});for(const{reject:a}of n)a(s)}})()}},t)}constructor(t,e){super(t,e),this.#e=1,this.#t=Object.assign({},E4,e||{}),this.#r=[],this.#n=null,this.#s=null;{let i=null;const s=new Promise(a=>{i=a});this.#i={promise:s,resolve:i}}const n=this._getOption("staticNetwork");n&&(q(t==null||n.matches(t),"staticNetwork MUST match network object","options",e),this.#s=n)}_getOption(t){return this.#t[t]}get _network(){return ct(this.#s,"network is not available yet","NETWORK_ERROR"),this.#s}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let n=t.transaction;if(n&&n.type!=null&&It(n.type)&&n.maxFeePerGas==null&&n.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},n,{type:void 0})}))}}const e=this.getRpcRequest(t);return e!=null?await this.send(e.method,e.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)return t;if(this.ready)return mo.from(It(await this.send("eth_chainId",[])));const e={id:this.#e++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:e});let n;try{n=(await this._send(e))[0]}catch(i){throw this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:n}),"result"in n)return mo.from(It(n.result));throw this.getRpcError(e,n)}_start(){this.#i==null||this.#i.resolve==null||(this.#i.resolve(),this.#i=null,(async()=>{for(;this.#s==null&&!this.destroyed;)try{this.#s=await this._detectNetwork()}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Dr("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await v4(1e3)}this.#o()})())}async _waitUntilReady(){if(this.#i!=null)return await this.#i.promise}_getSubscriber(t){return t.type==="pending"?new y4(this):t.type==="event"?this._getOption("polling")?new qd(this,t.filter):new w4(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Wy("orphan"):super._getSubscriber(t)}get ready(){return this.#i==null}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(n=>{if(t[n]==null)return;let i=n;n==="gasLimit"&&(i="gas"),e[i]=ca(It(t[n],`tx.${n}`))}),["from","to","data"].forEach(n=>{t[n]!=null&&(e[n]=At(t[n]))}),t.accessList&&(e.accessList=lo(t.accessList)),e}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Aa(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Aa(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Aa(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Aa(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Aa):t.filter.address=Aa(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:n}=t,{error:i}=e;if(n==="eth_estimateGas"&&i.message){const l=i.message;if(!l.match(/revert/i)&&l.match(/insufficient funds/i))return Dr("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(n==="eth_call"||n==="eth_estimateGas"){const l=Zd(i),u=ya.getBuiltinCallException(n==="eth_call"?"call":"estimateGas",t.params[0],l?l.data:null);return u.info={error:i,payload:t},u}const s=JSON.stringify(x4(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return Dr("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[n]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(n==="eth_sendRawTransaction"||n==="eth_sendTransaction"){const l=t.params[0];if(s.match(/insufficient funds|base fee exceeds gas limit/i))return Dr("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:l,info:{error:i}});if(s.match(/nonce/i)&&s.match(/too low/i))return Dr("nonce has already been used","NONCE_EXPIRED",{transaction:l,info:{error:i}});if(s.match(/replacement transaction/i)&&s.match(/underpriced/i))return Dr("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:l,info:{error:i}});if(s.match(/only replay-protected/i))return Dr("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:n,info:{transaction:l,info:{error:i}}})}let a=!!s.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?Dr("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):Dr("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Dr("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const n=this.#e++,i=new Promise((s,a)=>{this.#r.push({resolve:s,reject:a,payload:{method:t,params:e,id:n,jsonrpc:"2.0"}})});return this.#o(),i}async getSigner(t){t==null&&(t=0);const e=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await e;if(t>=i.length)throw new Error("no such account");return new Yd(this,i[t])}const{accounts:n}=await Jr({network:this.getNetwork(),accounts:e});t=xe(t);for(const i of n)if(xe(i)===t)return new Yd(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(e=>new Yd(this,e))}destroy(){this.#n&&(clearTimeout(this.#n),this.#n=null);for(const{payload:t,reject:e}of this.#r)e(Dr("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));this.#r=[],super.destroy()}}class A4 extends _4{#t;constructor(t,e){super(t,e),this.#t=4e3}_getSubscriber(t){const e=super._getSubscriber(t);return Zy(e)&&(e.pollingInterval=this.#t),e}get pollingInterval(){return this.#t}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");this.#t=t,this._forEachSubscriber(e=>{Zy(e)&&(e.pollingInterval=this.#t)})}}function Zd(r){if(r==null)return null;if(typeof r.message=="string"&&r.message.match(/revert/i)&&Qe(r.data))return{message:r.message,data:r.data};if(typeof r=="object"){for(const t in r){const e=Zd(r[t]);if(e)return e}return null}if(typeof r=="string")try{return Zd(JSON.parse(r))}catch{}return null}function Xd(r,t){if(r!=null){if(typeof r.message=="string"&&t.push(r.message),typeof r=="object")for(const e in r)Xd(r[e],t);if(typeof r=="string")try{return Xd(JSON.parse(r),t)}catch{}}}function x4(r){const t=[];return Xd(r,t),t}class Yu extends A4{#t;constructor(t,e){super(e,{batchMaxCount:1}),this.#t=async(n,i)=>{const s={method:n,params:i};this.emit("debug",{action:"sendEip1193Request",payload:s});try{const a=await t.request(s);return this.emit("debug",{action:"receiveEip1193Result",result:a}),a}catch(a){const l=new Error(a.message);throw l.code=a.code,l.data=a.data,l.payload=s,this.emit("debug",{action:"receiveEip1193Error",error:l}),l}}}async send(t,e){return await this._start(),await super.send(t,e)}async _send(t){q(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const e=await this.#t(t.method,t.params||[]);return[{id:t.id,result:e}]}catch(e){return[{id:t.id,error:{code:e.code,data:e.data,message:e.message}}]}}getRpcError(t,e){switch(e=JSON.parse(JSON.stringify(e)),e.error.code||-1){case 4001:e.error.message=`ethers-user-denied: ${e.error.message}`;break;case 4200:e.error.message=`ethers-unsupported: ${e.error.message}`;break}return super.getRpcError(t,e)}async hasSigner(t){t==null&&(t=0);const e=await this.send("eth_accounts",[]);return typeof t=="number"?e.length>t:(t=t.toLowerCase(),e.filter(n=>n.toLowerCase()===t).length!==0)}async getSigner(t){if(t==null&&(t=0),!await this.hasSigner(t))try{await this.#t("eth_requestAccounts",[])}catch(e){const n=e.payload;throw this.getRpcError(n,{id:n.id,error:e})}return await super.getSigner(t)}}const I4=Symbol(),Xy=Object.getPrototypeOf,tp=new WeakMap,C4=r=>r&&(tp.has(r)?tp.get(r):Xy(r)===Object.prototype||Xy(r)===Array.prototype),S4=r=>C4(r)&&r[I4]||null,tb=(r,t=!0)=>{tp.set(r,t)},ep=r=>typeof r=="object"&&r!==null,Ps=new WeakMap,Zu=new WeakSet,O4=(r=Object.is,t=(f,d)=>new Proxy(f,d),e=f=>ep(f)&&!Zu.has(f)&&(Array.isArray(f)||!(Symbol.iterator in f))&&!(f instanceof WeakMap)&&!(f instanceof WeakSet)&&!(f instanceof Error)&&!(f instanceof Number)&&!(f instanceof Date)&&!(f instanceof String)&&!(f instanceof RegExp)&&!(f instanceof ArrayBuffer),n=f=>{switch(f.status){case"fulfilled":return f.value;case"rejected":throw f.reason;default:throw f}},i=new WeakMap,s=(f,d,w=n)=>{const m=i.get(f);if(m?.[0]===d)return m[1];const b=Array.isArray(f)?[]:Object.create(Object.getPrototypeOf(f));return tb(b,!0),i.set(f,[d,b]),Reflect.ownKeys(f).forEach(E=>{if(Object.getOwnPropertyDescriptor(b,E))return;const C=Reflect.get(f,E),R={value:C,enumerable:!0,configurable:!0};if(Zu.has(C))tb(C,!1);else if(C instanceof Promise)delete R.value,R.get=()=>w(C);else if(Ps.has(C)){const[k,D]=Ps.get(C);R.value=s(k,D(),w)}Object.defineProperty(b,E,R)}),Object.preventExtensions(b)},a=new WeakMap,l=[1,1],u=f=>{if(!ep(f))throw new Error("object required");const d=a.get(f);if(d)return d;let w=l[0];const m=new Set,b=(M,F=++l[0])=>{w!==F&&(w=F,m.forEach(K=>K(M,F)))};let E=l[1];const C=(M=++l[1])=>(E!==M&&!m.size&&(E=M,k.forEach(([F])=>{const K=F[1](M);K>w&&(w=K)})),w),R=M=>(F,K)=>{const st=[...F];st[1]=[M,...st[1]],b(st,K)},k=new Map,D=(M,F)=>{if(m.size){const K=F[3](R(M));k.set(M,[F,K])}else k.set(M,[F])},P=M=>{var F;const K=k.get(M);K&&(k.delete(M),(F=K[1])==null||F.call(K))},I=M=>(m.add(M),m.size===1&&k.forEach(([K,st],lt)=>{const S=K[3](R(lt));k.set(lt,[K,S])}),()=>{m.delete(M),m.size===0&&k.forEach(([K,st],lt)=>{st&&(st(),k.set(lt,[K]))})}),T=Array.isArray(f)?[]:Object.create(Object.getPrototypeOf(f)),p=t(T,{deleteProperty(M,F){const K=Reflect.get(M,F);P(F);const st=Reflect.deleteProperty(M,F);return st&&b(["delete",[F],K]),st},set(M,F,K,st){const lt=Reflect.has(M,F),S=Reflect.get(M,F,st);if(lt&&(r(S,K)||a.has(K)&&r(S,a.get(K))))return!0;P(F),ep(K)&&(K=S4(K)||K);let $=K;if(K instanceof Promise)K.then(tt=>{K.status="fulfilled",K.value=tt,b(["resolve",[F],tt])}).catch(tt=>{K.status="rejected",K.reason=tt,b(["reject",[F],tt])});else{!Ps.has(K)&&e(K)&&($=u(K));const tt=!Zu.has($)&&Ps.get($);tt&&D(F,tt)}return Reflect.set(M,F,$,st),b(["set",[F],K,S]),!0}});a.set(f,p);const _=[T,C,s,I];return Ps.set(p,_),Reflect.ownKeys(f).forEach(M=>{const F=Object.getOwnPropertyDescriptor(f,M);"value"in F&&(p[M]=f[M],delete F.value,delete F.writable),Object.defineProperty(T,M,F)}),p})=>[u,Ps,Zu,r,t,e,n,i,s,a,l],[P4]=O4();function Ds(r={}){return P4(r)}function wo(r,t,e){const n=Ps.get(r);let i;const s=[],a=n[3];let l=!1;const f=a(d=>{if(s.push(d),e){t(s.splice(0));return}i||(i=Promise.resolve().then(()=>{i=void 0,l&&t(s.splice(0))}))});return l=!0,()=>{l=!1,f()}}function D4(r,t){const e=Ps.get(r),[n,i,s]=e;return s(n,i(),t)}const $r=Ds({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),Xe={state:$r,subscribe(r){return wo($r,()=>r($r))},push(r,t){r!==$r.view&&($r.view=r,t&&($r.data=t),$r.history.push(r))},reset(r){$r.view=r,$r.history=[r]},replace(r){$r.history.length>1&&($r.history[$r.history.length-1]=r,$r.view=r)},goBack(){if($r.history.length>1){$r.history.pop();const[r]=$r.history.slice(-1);$r.view=r}},setData(r){$r.data=r}},xt={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return xt.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const r=navigator.userAgent.toLowerCase();return xt.isMobile()&&(r.includes("iphone")||r.includes("ipad"))},isHttpUrl(r){return r.startsWith("http://")||r.startsWith("https://")},isArray(r){return Array.isArray(r)&&r.length>0},formatNativeUrl(r,t,e){if(xt.isHttpUrl(r))return this.formatUniversalUrl(r,t,e);let n=r;n.includes("://")||(n=r.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,e);const i=encodeURIComponent(t);return`${n}wc?uri=${i}`},formatUniversalUrl(r,t,e){if(!xt.isHttpUrl(r))return this.formatNativeUrl(r,t,e);let n=r;n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,e);const i=encodeURIComponent(t);return`${n}wc?uri=${i}`},async wait(r){return new Promise(t=>{setTimeout(t,r)})},openHref(r,t){window.open(r,t,"noreferrer noopener")},setWalletConnectDeepLink(r,t){try{localStorage.setItem(xt.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:r,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(r){try{const[t]=r.split("?");localStorage.setItem(xt.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(xt.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(xt.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var r;const t=(r=Xe.state.data)==null?void 0:r.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},T4=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),Gr=Ds({enabled:T4,userSessionId:"",events:[],connectedWalletId:void 0}),eb={state:Gr,subscribe(r){return wo(Gr.events,()=>r(D4(Gr.events[Gr.events.length-1])))},initialize(){Gr.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(Gr.userSessionId=crypto.randomUUID())},setConnectedWalletId(r){Gr.connectedWalletId=r},click(r){if(Gr.enabled){const t={type:"CLICK",name:r.name,userSessionId:Gr.userSessionId,timestamp:Date.now(),data:r};Gr.events.push(t)}},track(r){if(Gr.enabled){const t={type:"TRACK",name:r.name,userSessionId:Gr.userSessionId,timestamp:Date.now(),data:r};Gr.events.push(t)}},view(r){if(Gr.enabled){const t={type:"VIEW",name:r.name,userSessionId:Gr.userSessionId,timestamp:Date.now(),data:r};Gr.events.push(t)}}},Ai=Ds({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),dr={state:Ai,subscribe(r){return wo(Ai,()=>r(Ai))},setChains(r){Ai.chains=r},setWalletConnectUri(r){Ai.walletConnectUri=r},setIsCustomDesktop(r){Ai.isCustomDesktop=r},setIsCustomMobile(r){Ai.isCustomMobile=r},setIsDataLoaded(r){Ai.isDataLoaded=r},setIsUiLoaded(r){Ai.isUiLoaded=r},setIsAuth(r){Ai.isAuth=r}},Xu=Ds({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),$n={state:Xu,subscribe(r){return wo(Xu,()=>r(Xu))},setConfig(r){var t,e;eb.initialize(),dr.setChains(r.chains),dr.setIsAuth(!!r.enableAuthMode),dr.setIsCustomMobile(!!((t=r.mobileWallets)!=null&&t.length)),dr.setIsCustomDesktop(!!((e=r.desktopWallets)!=null&&e.length)),xt.setModalVersionInStorage(),Object.assign(Xu,r)}};var N4=Object.defineProperty,rb=Object.getOwnPropertySymbols,R4=Object.prototype.hasOwnProperty,L4=Object.prototype.propertyIsEnumerable,nb=(r,t,e)=>t in r?N4(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$4=(r,t)=>{for(var e in t||(t={}))R4.call(t,e)&&nb(r,e,t[e]);if(rb)for(var e of rb(t))L4.call(t,e)&&nb(r,e,t[e]);return r};const rp="https://explorer-api.walletconnect.com",np="wcm",ip="js-2.6.2";async function th(r,t){const e=$4({sdkType:np,sdkVersion:ip},t),n=new URL(r,rp);return n.searchParams.append("projectId",$n.state.projectId),Object.entries(e).forEach(([i,s])=>{s&&n.searchParams.append(i,String(s))}),(await fetch(n)).json()}const yo={async getDesktopListings(r){return th("/w3m/v1/getDesktopListings",r)},async getMobileListings(r){return th("/w3m/v1/getMobileListings",r)},async getInjectedListings(r){return th("/w3m/v1/getInjectedListings",r)},async getAllListings(r){return th("/w3m/v1/getAllListings",r)},getWalletImageUrl(r){return`${rp}/w3m/v1/getWalletImage/${r}?projectId=${$n.state.projectId}&sdkType=${np}&sdkVersion=${ip}`},getAssetImageUrl(r){return`${rp}/w3m/v1/getAssetImage/${r}?projectId=${$n.state.projectId}&sdkType=${np}&sdkVersion=${ip}`}};var k4=Object.defineProperty,ib=Object.getOwnPropertySymbols,U4=Object.prototype.hasOwnProperty,B4=Object.prototype.propertyIsEnumerable,sb=(r,t,e)=>t in r?k4(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,F4=(r,t)=>{for(var e in t||(t={}))U4.call(t,e)&&sb(r,e,t[e]);if(ib)for(var e of ib(t))B4.call(t,e)&&sb(r,e,t[e]);return r};const ob=xt.isMobile(),xi=Ds({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),wn={state:xi,async getRecomendedWallets(){const{explorerRecommendedWalletIds:r,explorerExcludedWalletIds:t}=$n.state;if(r==="NONE"||t==="ALL"&&!r)return xi.recomendedWallets;if(xt.isArray(r)){const e={recommendedIds:r.join(",")},{listings:n}=await yo.getAllListings(e),i=Object.values(n);i.sort((s,a)=>{const l=r.indexOf(s.id),u=r.indexOf(a.id);return l-u}),xi.recomendedWallets=i}else{const{chains:e,isAuth:n}=dr.state,i=e?.join(","),s=xt.isArray(t),a={page:1,sdks:n?"auth_v1":void 0,entries:xt.RECOMMENDED_WALLET_AMOUNT,chains:i,version:2,excludedIds:s?t.join(","):void 0},{listings:l}=ob?await yo.getMobileListings(a):await yo.getDesktopListings(a);xi.recomendedWallets=Object.values(l)}return xi.recomendedWallets},async getWallets(r){const t=F4({},r),{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:n}=$n.state,{recomendedWallets:i}=xi;if(n==="ALL")return xi.wallets;i.length?t.excludedIds=i.map(w=>w.id).join(","):xt.isArray(e)&&(t.excludedIds=e.join(",")),xt.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),dr.state.isAuth&&(t.sdks="auth_v1");const{page:s,search:a}=r,{listings:l,total:u}=ob?await yo.getMobileListings(t):await yo.getDesktopListings(t),f=Object.values(l),d=a?"search":"wallets";return xi[d]={listings:[...xi[d].listings,...f],total:u,page:s??1},{listings:f,total:u}},getWalletImageUrl(r){return yo.getWalletImageUrl(r)},getAssetImageUrl(r){return yo.getAssetImageUrl(r)},resetSearch(){xi.search={listings:[],total:0,page:1}}},xa=Ds({open:!1}),bo={state:xa,subscribe(r){return wo(xa,()=>r(xa))},async open(r){return new Promise(t=>{const{isUiLoaded:e,isDataLoaded:n}=dr.state;if(xt.removeWalletConnectDeepLink(),dr.setWalletConnectUri(r?.uri),dr.setChains(r?.chains),Xe.reset("ConnectWallet"),e&&n)xa.open=!0,t();else{const i=setInterval(()=>{const s=dr.state;s.isUiLoaded&&s.isDataLoaded&&(clearInterval(i),xa.open=!0,t())},200)}})},close(){xa.open=!1}};var M4=Object.defineProperty,ab=Object.getOwnPropertySymbols,j4=Object.prototype.hasOwnProperty,H4=Object.prototype.propertyIsEnumerable,cb=(r,t,e)=>t in r?M4(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,z4=(r,t)=>{for(var e in t||(t={}))j4.call(t,e)&&cb(r,e,t[e]);if(ab)for(var e of ab(t))H4.call(t,e)&&cb(r,e,t[e]);return r};function V4(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const Zc=Ds({themeMode:V4()?"dark":"light"}),Ts={state:Zc,subscribe(r){return wo(Zc,()=>r(Zc))},setThemeConfig(r){const{themeMode:t,themeVariables:e}=r;t&&(Zc.themeMode=t),e&&(Zc.themeVariables=z4({},e))}},vo=Ds({open:!1,message:"",variant:"success"}),Ns={state:vo,subscribe(r){return wo(vo,()=>r(vo))},openToast(r,t){vo.open=!0,vo.message=r,vo.variant=t},closeToast(){vo.open=!1}};let G4=class{constructor(t){this.openModal=bo.open,this.closeModal=bo.close,this.subscribeModal=bo.subscribe,this.setTheme=Ts.setThemeConfig,Ts.setThemeConfig(t),$n.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await Promise.resolve().then(()=>PU);const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),dr.setIsUiLoaded(!0)}}};function lb(){throw new Error("setTimeout has not been defined")}function ub(){throw new Error("clearTimeout has not been defined")}var Rs=lb,Ls=ub;typeof Te.setTimeout=="function"&&(Rs=setTimeout),typeof Te.clearTimeout=="function"&&(Ls=clearTimeout);function hb(r){if(Rs===setTimeout)return setTimeout(r,0);if((Rs===lb||!Rs)&&setTimeout)return Rs=setTimeout,setTimeout(r,0);try{return Rs(r,0)}catch{try{return Rs.call(null,r,0)}catch{return Rs.call(this,r,0)}}}function q4(r){if(Ls===clearTimeout)return clearTimeout(r);if((Ls===ub||!Ls)&&clearTimeout)return Ls=clearTimeout,clearTimeout(r);try{return Ls(r)}catch{try{return Ls.call(null,r)}catch{return Ls.call(this,r)}}}var Ki=[],Ia=!1,Eo,eh=-1;function W4(){!Ia||!Eo||(Ia=!1,Eo.length?Ki=Eo.concat(Ki):eh=-1,Ki.length&&fb())}function fb(){if(!Ia){var r=hb(W4);Ia=!0;for(var t=Ki.length;t;){for(Eo=Ki,Ki=[];++eh1)for(var e=1;e0&&(a=e[0]),a instanceof Error)throw a;var l=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw l.context=a,l}var u=s[t];if(u===void 0)return!1;if(typeof u=="function")pb(u,this,e);else for(var f=u.length,d=_b(u,f),n=0;n0&&a.length>i&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=r,l.type=t,l.count=a.length,bI(l)}return r}Ne.prototype.addListener=function(t,e){return yb(this,t,e,!1)},Ne.prototype.on=Ne.prototype.addListener,Ne.prototype.prependListener=function(t,e){return yb(this,t,e,!0)};function vI(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function bb(r,t,e){var n={fired:!1,wrapFn:void 0,target:r,type:t,listener:e},i=vI.bind(n);return i.listener=e,n.wrapFn=i,i}Ne.prototype.once=function(t,e){return nh(e),this.on(t,bb(this,t,e)),this},Ne.prototype.prependOnceListener=function(t,e){return nh(e),this.prependListener(t,bb(this,t,e)),this},Ne.prototype.removeListener=function(t,e){var n,i,s,a,l;if(nh(e),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(s=-1,a=n.length-1;a>=0;a--)if(n[a]===e||n[a].listener===e){l=n[a].listener,s=a;break}if(s<0)return this;s===0?n.shift():EI(n,s),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,l||e)}return this},Ne.prototype.off=Ne.prototype.removeListener,Ne.prototype.removeAllListeners=function(t){var e,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var s=Object.keys(n),a;for(i=0;i=0;i--)this.removeListener(t,e[i]);return this};function vb(r,t,e){var n=r._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?e?[i.listener||i]:[i]:e?_I(i):_b(i,i.length)}Ne.prototype.listeners=function(t){return vb(this,t,!0)},Ne.prototype.rawListeners=function(t){return vb(this,t,!1)},Ne.listenerCount=function(r,t){return typeof r.listenerCount=="function"?r.listenerCount(t):Eb.call(r,t)},Ne.prototype.listenerCount=Eb;function Eb(r){var t=this._events;if(t!==void 0){var e=t[r];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}Ne.prototype.eventNames=function(){return this._eventsCount>0?rh(this._events):[]};function _b(r,t){for(var e=new Array(t),n=0;n=0;l--)(a=r[l])&&(s=(i<3?a(s):i>3?a(t,e,s):a(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s}function OI(r,t){return function(e,n){t(e,n,r)}}function PI(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function DI(r,t,e,n){function i(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function l(d){try{f(n.next(d))}catch(w){a(w)}}function u(d){try{f(n.throw(d))}catch(w){a(w)}}function f(d){d.done?s(d.value):i(d.value).then(l,u)}f((n=n.apply(r,t||[])).next())})}function TI(r,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(f){return function(d){return u([f,d])}}function u(f){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return e.label++,{value:f[1],done:!1};case 5:e.label++,i=f[1],f=[0];continue;case 7:f=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){e=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function xb(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,s=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return s}function LI(){for(var r=[],t=0;t1||l(m,b)})})}function l(m,b){try{u(n[m](b))}catch(E){w(s[0][3],E)}}function u(m){m.value instanceof Xc?Promise.resolve(m.value.v).then(f,d):w(s[0][2],m)}function f(m){l("next",m)}function d(m){l("throw",m)}function w(m,b){m(b),s.shift(),s.length&&l(s[0][0],s[0][1])}}function UI(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(a){return(e=!e)?{value:Xc(r[i](a)),done:i==="return"}:s?s(a):a}:s}}function BI(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof up=="function"?up(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(a){return new Promise(function(l,u){a=r[s](a),i(l,u,a.done,a.value)})}}function i(s,a,l,u){Promise.resolve(u).then(function(f){s({value:f,done:l})},a)}}function FI(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}function MI(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t}function jI(r){return r&&r.__esModule?r:{default:r}}function HI(r,t){if(!t.has(r))throw new TypeError("attempted to get private field on non-instance");return t.get(r)}function zI(r,t,e){if(!t.has(r))throw new TypeError("attempted to set private field on non-instance");return t.set(r,e),e}const Ib=Ao(Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return lp},__asyncDelegator:UI,__asyncGenerator:kI,__asyncValues:BI,__await:Xc,__awaiter:DI,__classPrivateFieldGet:HI,__classPrivateFieldSet:zI,__createBinding:NI,__decorate:SI,__exportStar:RI,__extends:II,__generator:TI,__importDefault:jI,__importStar:MI,__makeTemplateObject:FI,__metadata:PI,__param:OI,__read:xb,__rest:CI,__spread:LI,__spreadArrays:$I,__values:up},Symbol.toStringTag,{value:"Module"})));var tl={};Object.defineProperty(tl,"__esModule",{value:!0});function VI(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return JSON.parse(r)}catch{return r}}tl.safeJsonParse=VI;function GI(r){return typeof r=="string"?r:JSON.stringify(r,(t,e)=>typeof e>"u"?null:e)}tl.safeJsonStringify=GI;var el={exports:{}},Cb;function qI(){return Cb||(Cb=1,function(){let r;function t(){}r=t,r.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},r.prototype.setItem=function(e,n){this[e]=String(n)},r.prototype.removeItem=function(e){delete this[e]},r.prototype.clear=function(){const e=this;Object.keys(e).forEach(function(n){e[n]=void 0,delete e[n]})},r.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof yn<"u"&&yn.localStorage?el.exports=yn.localStorage:typeof window<"u"&&window.localStorage?el.exports=window.localStorage:el.exports=new t}()),el.exports}var hp={},rl={},Sb;function WI(){if(Sb)return rl;Sb=1,Object.defineProperty(rl,"__esModule",{value:!0}),rl.IKeyValueStorage=void 0;class r{}return rl.IKeyValueStorage=r,rl}var nl={},Ob;function KI(){if(Ob)return nl;Ob=1,Object.defineProperty(nl,"__esModule",{value:!0}),nl.parseEntry=void 0;const r=tl;function t(e){var n;return[e[0],r.safeJsonParse((n=e[1])!==null&&n!==void 0?n:"")]}return nl.parseEntry=t,nl}var Pb;function QI(){return Pb||(Pb=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=Ib;t.__exportStar(WI(),r),t.__exportStar(KI(),r)}(hp)),hp}Object.defineProperty(ih,"__esModule",{value:!0}),ih.KeyValueStorage=void 0;const Oa=Ib,Db=tl,JI=Oa.__importDefault(qI()),YI=QI();class Tb{constructor(){this.localStorage=JI.default}getKeys(){return Oa.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return Oa.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(YI.parseEntry)})}getItem(t){return Oa.__awaiter(this,void 0,void 0,function*(){const e=this.localStorage.getItem(t);if(e!==null)return Db.safeJsonParse(e)})}setItem(t,e){return Oa.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(t,Db.safeJsonStringify(e))})}removeItem(t){return Oa.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(t)})}}ih.KeyValueStorage=Tb;var ZI=ih.default=Tb,Pa={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var fp=function(r,t){return fp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},fp(r,t)};function XI(r,t){fp(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var dp=function(){return dp=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;l--)(a=r[l])&&(s=(i<3?a(s):i>3?a(t,e,s):a(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s}function rC(r,t){return function(e,n){t(e,n,r)}}function nC(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function iC(r,t,e,n){function i(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function l(d){try{f(n.next(d))}catch(w){a(w)}}function u(d){try{f(n.throw(d))}catch(w){a(w)}}function f(d){d.done?s(d.value):i(d.value).then(l,u)}f((n=n.apply(r,t||[])).next())})}function sC(r,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(f){return function(d){return u([f,d])}}function u(f){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return e.label++,{value:f[1],done:!1};case 5:e.label++,i=f[1],f=[0];continue;case 7:f=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){e=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Nb(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,s=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return s}function cC(){for(var r=[],t=0;t1||l(m,b)})})}function l(m,b){try{u(n[m](b))}catch(E){w(s[0][3],E)}}function u(m){m.value instanceof il?Promise.resolve(m.value.v).then(f,d):w(s[0][2],m)}function f(m){l("next",m)}function d(m){l("throw",m)}function w(m,b){m(b),s.shift(),s.length&&l(s[0][0],s[0][1])}}function hC(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(a){return(e=!e)?{value:il(r[i](a)),done:i==="return"}:s?s(a):a}:s}}function fC(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof pp=="function"?pp(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(a){return new Promise(function(l,u){a=r[s](a),i(l,u,a.done,a.value)})}}function i(s,a,l,u){Promise.resolve(u).then(function(f){s({value:f,done:l})},a)}}function dC(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}function pC(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t}function gC(r){return r&&r.__esModule?r:{default:r}}function mC(r,t){if(!t.has(r))throw new TypeError("attempted to get private field on non-instance");return t.get(r)}function wC(r,t,e){if(!t.has(r))throw new TypeError("attempted to set private field on non-instance");return t.set(r,e),e}const sh=Ao(Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return dp},__asyncDelegator:hC,__asyncGenerator:uC,__asyncValues:fC,__await:il,__awaiter:iC,__classPrivateFieldGet:mC,__classPrivateFieldSet:wC,__createBinding:oC,__decorate:eC,__exportStar:aC,__extends:XI,__generator:sC,__importDefault:gC,__importStar:pC,__makeTemplateObject:dC,__metadata:nC,__param:rC,__read:Nb,__rest:tC,__spread:cC,__spreadArrays:lC,__values:pp},Symbol.toStringTag,{value:"Module"})));var sl={},_t={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var gp=function(r,t){return gp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},gp(r,t)};function yC(r,t){gp(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var mp=function(){return mp=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;l--)(a=r[l])&&(s=(i<3?a(s):i>3?a(t,e,s):a(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s}function EC(r,t){return function(e,n){t(e,n,r)}}function _C(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function AC(r,t,e,n){function i(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function l(d){try{f(n.next(d))}catch(w){a(w)}}function u(d){try{f(n.throw(d))}catch(w){a(w)}}function f(d){d.done?s(d.value):i(d.value).then(l,u)}f((n=n.apply(r,t||[])).next())})}function xC(r,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(f){return function(d){return u([f,d])}}function u(f){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return e.label++,{value:f[1],done:!1};case 5:e.label++,i=f[1],f=[0];continue;case 7:f=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){e=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Rb(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,s=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return s}function SC(){for(var r=[],t=0;t1||l(m,b)})})}function l(m,b){try{u(n[m](b))}catch(E){w(s[0][3],E)}}function u(m){m.value instanceof ol?Promise.resolve(m.value.v).then(f,d):w(s[0][2],m)}function f(m){l("next",m)}function d(m){l("throw",m)}function w(m,b){m(b),s.shift(),s.length&&l(s[0][0],s[0][1])}}function DC(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(a){return(e=!e)?{value:ol(r[i](a)),done:i==="return"}:s?s(a):a}:s}}function TC(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof wp=="function"?wp(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(a){return new Promise(function(l,u){a=r[s](a),i(l,u,a.done,a.value)})}}function i(s,a,l,u){Promise.resolve(u).then(function(f){s({value:f,done:l})},a)}}function NC(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}function RC(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t}function LC(r){return r&&r.__esModule?r:{default:r}}function $C(r,t){if(!t.has(r))throw new TypeError("attempted to get private field on non-instance");return t.get(r)}function kC(r,t,e){if(!t.has(r))throw new TypeError("attempted to set private field on non-instance");return t.set(r,e),e}const oh=Ao(Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return mp},__asyncDelegator:DC,__asyncGenerator:PC,__asyncValues:TC,__await:ol,__awaiter:AC,__classPrivateFieldGet:$C,__classPrivateFieldSet:kC,__createBinding:IC,__decorate:vC,__exportStar:CC,__extends:yC,__generator:xC,__importDefault:LC,__importStar:RC,__makeTemplateObject:NC,__metadata:_C,__param:EC,__read:Rb,__rest:bC,__spread:SC,__spreadArrays:OC,__values:wp},Symbol.toStringTag,{value:"Module"})));var yp={},al={},Lb;function UC(){if(Lb)return al;Lb=1,Object.defineProperty(al,"__esModule",{value:!0}),al.delay=void 0;function r(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}return al.delay=r,al}var xo={},bp={},Io={},$b;function BC(){return $b||($b=1,Object.defineProperty(Io,"__esModule",{value:!0}),Io.ONE_THOUSAND=Io.ONE_HUNDRED=void 0,Io.ONE_HUNDRED=100,Io.ONE_THOUSAND=1e3),Io}var vp={},kb;function FC(){return kb||(kb=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(vp)),vp}var Ub;function Bb(){return Ub||(Ub=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=oh;t.__exportStar(BC(),r),t.__exportStar(FC(),r)}(bp)),bp}var Fb;function MC(){if(Fb)return xo;Fb=1,Object.defineProperty(xo,"__esModule",{value:!0}),xo.fromMiliseconds=xo.toMiliseconds=void 0;const r=Bb();function t(n){return n*r.ONE_THOUSAND}xo.toMiliseconds=t;function e(n){return Math.floor(n/r.ONE_THOUSAND)}return xo.fromMiliseconds=e,xo}var Mb;function jC(){return Mb||(Mb=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=oh;t.__exportStar(UC(),r),t.__exportStar(MC(),r)}(yp)),yp}var Da={},jb;function HC(){if(jb)return Da;jb=1,Object.defineProperty(Da,"__esModule",{value:!0}),Da.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const n=this.get(e);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);const i=Date.now()-n.started;this.timestamps.set(e,{started:n.started,elapsed:i})}get(e){const n=this.timestamps.get(e);if(typeof n>"u")throw new Error(`No timestamp found for label: ${e}`);return n}elapsed(e){const n=this.get(e);return n.elapsed||Date.now()-n.started}}return Da.Watch=r,Da.default=r,Da}var Ep={},cl={},Hb;function zC(){if(Hb)return cl;Hb=1,Object.defineProperty(cl,"__esModule",{value:!0}),cl.IWatch=void 0;class r{}return cl.IWatch=r,cl}var zb;function VC(){return zb||(zb=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),oh.__exportStar(zC(),r)}(Ep)),Ep}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=oh;t.__exportStar(jC(),r),t.__exportStar(HC(),r),t.__exportStar(VC(),r),t.__exportStar(Bb(),r)})(_t);var _p={},ll={};let Co=class{};const GC=Ao(Object.freeze(Object.defineProperty({__proto__:null,IEvents:Co},Symbol.toStringTag,{value:"Module"})));var Vb;function qC(){if(Vb)return ll;Vb=1,Object.defineProperty(ll,"__esModule",{value:!0}),ll.IHeartBeat=void 0;const r=GC;class t extends r.IEvents{constructor(n){super()}}return ll.IHeartBeat=t,ll}var Gb;function qb(){return Gb||(Gb=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),sh.__exportStar(qC(),r)}(_p)),_p}var Ap={},So={},Wb;function WC(){if(Wb)return So;Wb=1,Object.defineProperty(So,"__esModule",{value:!0}),So.HEARTBEAT_EVENTS=So.HEARTBEAT_INTERVAL=void 0;const r=_t;return So.HEARTBEAT_INTERVAL=r.FIVE_SECONDS,So.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},So}var Kb;function Qb(){return Kb||(Kb=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),sh.__exportStar(WC(),r)}(Ap)),Ap}var Jb;function KC(){if(Jb)return sl;Jb=1,Object.defineProperty(sl,"__esModule",{value:!0}),sl.HeartBeat=void 0;const r=sh,t=Jn,e=_t,n=qb(),i=Qb();class s extends n.IHeartBeat{constructor(l){super(l),this.events=new t.EventEmitter,this.interval=i.HEARTBEAT_INTERVAL,this.interval=l?.interval||i.HEARTBEAT_INTERVAL}static init(l){return r.__awaiter(this,void 0,void 0,function*(){const u=new s(l);return yield u.init(),u})}init(){return r.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(l,u){this.events.on(l,u)}once(l,u){this.events.once(l,u)}off(l,u){this.events.off(l,u)}removeListener(l,u){this.events.removeListener(l,u)}initialize(){return r.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),e.toMiliseconds(this.interval))})}pulse(){this.events.emit(i.HEARTBEAT_EVENTS.pulse)}}return sl.HeartBeat=s,sl}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=sh;t.__exportStar(KC(),r),t.__exportStar(qb(),r),t.__exportStar(Qb(),r)})(Pa);var he={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var xp=function(r,t){return xp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},xp(r,t)};function QC(r,t){xp(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Ip=function(){return Ip=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;l--)(a=r[l])&&(s=(i<3?a(s):i>3?a(t,e,s):a(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s}function ZC(r,t){return function(e,n){t(e,n,r)}}function XC(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function tS(r,t,e,n){function i(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function l(d){try{f(n.next(d))}catch(w){a(w)}}function u(d){try{f(n.throw(d))}catch(w){a(w)}}function f(d){d.done?s(d.value):i(d.value).then(l,u)}f((n=n.apply(r,t||[])).next())})}function eS(r,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(f){return function(d){return u([f,d])}}function u(f){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return e.label++,{value:f[1],done:!1};case 5:e.label++,i=f[1],f=[0];continue;case 7:f=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){e=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Yb(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,s=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return s}function iS(){for(var r=[],t=0;t1||l(m,b)})})}function l(m,b){try{u(n[m](b))}catch(E){w(s[0][3],E)}}function u(m){m.value instanceof ul?Promise.resolve(m.value.v).then(f,d):w(s[0][2],m)}function f(m){l("next",m)}function d(m){l("throw",m)}function w(m,b){m(b),s.shift(),s.length&&l(s[0][0],s[0][1])}}function aS(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(a){return(e=!e)?{value:ul(r[i](a)),done:i==="return"}:s?s(a):a}:s}}function cS(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Cp=="function"?Cp(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(a){return new Promise(function(l,u){a=r[s](a),i(l,u,a.done,a.value)})}}function i(s,a,l,u){Promise.resolve(u).then(function(f){s({value:f,done:l})},a)}}function lS(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}function uS(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t}function hS(r){return r&&r.__esModule?r:{default:r}}function fS(r,t){if(!t.has(r))throw new TypeError("attempted to get private field on non-instance");return t.get(r)}function dS(r,t,e){if(!t.has(r))throw new TypeError("attempted to set private field on non-instance");return t.set(r,e),e}const pS=Ao(Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Ip},__asyncDelegator:aS,__asyncGenerator:oS,__asyncValues:cS,__await:ul,__awaiter:tS,__classPrivateFieldGet:fS,__classPrivateFieldSet:dS,__createBinding:rS,__decorate:YC,__exportStar:nS,__extends:QC,__generator:eS,__importDefault:hS,__importStar:uS,__makeTemplateObject:lS,__metadata:XC,__param:ZC,__read:Yb,__rest:JC,__spread:iS,__spreadArrays:sS,__values:Cp},Symbol.toStringTag,{value:"Module"})));var Sp,Zb;function gS(){if(Zb)return Sp;Zb=1;function r(e){try{return JSON.stringify(e)}catch{return'"[Circular]"'}}Sp=t;function t(e,n,i){var s=i&&i.stringify||r,a=1;if(typeof e=="object"&&e!==null){var l=n.length+a;if(l===1)return e;var u=new Array(l);u[0]=s(e);for(var f=1;f-1?b:0,e.charCodeAt(C+1)){case 100:case 102:if(m>=d||n[m]==null)break;b=d||n[m]==null)break;b=d||n[m]===void 0)break;b",b=C+2,C++;break}w+=s(n[m]),b=C+2,C++;break;case 115:if(m>=d)break;b-1&&(K=!1);const st=["error","fatal","warn","info","debug","trace"];typeof _=="function"&&(_.error=_.fatal=_.warn=_.info=_.debug=_.trace=_),A.enabled===!1&&(A.level="silent");const lt=A.level||"info",S=Object.create(_);S.log||(S.log=R),Object.defineProperty(S,"levelVal",{get:tt}),Object.defineProperty(S,"level",{get:et,set:J});const $={transmit:p,serialize:F,asObject:A.browser.asObject,levels:st,timestamp:b(A)};S.levels=i.levels,S.level=lt,S.setMaxListeners=S.getMaxListeners=S.emit=S.addListener=S.on=S.prependListener=S.once=S.prependOnceListener=S.removeListener=S.removeAllListeners=S.listeners=S.listenerCount=S.eventNames=S.write=S.flush=R,S.serializers=M,S._serialize=F,S._stdErrSerialize=K,S.child=Y,p&&(S._logEvent=w());function tt(){return this.level==="silent"?1/0:this.levels.values[this.level]}function et(){return this._level}function J(X){if(X!=="silent"&&!this.levels.values[X])throw Error("unknown level "+X);this._level=X,s($,S,"error","log"),s($,S,"fatal","error"),s($,S,"warn","error"),s($,S,"info","log"),s($,S,"debug","log"),s($,S,"trace","log")}function Y(X,ot){if(!X)throw new Error("missing bindings for child Pino");ot=ot||{},F&&X.serializers&&(ot.serializers=X.serializers);const Ot=ot.serializers;if(F&&Ot){var ut=Object.assign({},M,Ot),Pt=A.browser.serialize===!0?Object.keys(ut):F;delete X.serializers,u([X],Pt,ut,this._stdErrSerialize)}function gt(Ct){this._childLevel=(Ct._childLevel|0)+1,this.error=f(Ct,X,"error"),this.fatal=f(Ct,X,"fatal"),this.warn=f(Ct,X,"warn"),this.info=f(Ct,X,"info"),this.debug=f(Ct,X,"debug"),this.trace=f(Ct,X,"trace"),ut&&(this.serializers=ut,this._serialize=Pt),p&&(this._logEvent=w([].concat(Ct._logEvent.bindings,X)))}return gt.prototype=this,new gt(this)}return S}i.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},i.stdSerializers=e,i.stdTimeFunctions=Object.assign({},{nullTime:k,epochTime:D,unixTime:P,isoTime:I});function s(A,p,_,M){const F=Object.getPrototypeOf(p);p[_]=p.levelVal>p.levels.values[_]?R:F[_]?F[_]:t[_]||t[M]||R,a(A,p,_)}function a(A,p,_){!A.transmit&&p[_]===R||(p[_]=function(M){return function(){const K=A.timestamp(),st=new Array(arguments.length),lt=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var S=0;S-1&&K in _&&(A[F][K]=_[K](A[F][K]))}function f(A,p,_){return function(){const M=new Array(1+arguments.length);M[0]=p;for(var F=1;F"u"?f=e(l,u):f=l.bindings().context||"",f}tn.getLoggerContext=i;function s(l,u,f=r.PINO_CUSTOM_CONTEXT_KEY){const d=i(l,f);return d.trim()?`${d}/${u}`:u}tn.formatChildLoggerContext=s;function a(l,u,f=r.PINO_CUSTOM_CONTEXT_KEY){const d=s(l,u,f),w=l.child({context:d});return n(w,d,f)}return tn.generateChildLogger=a,tn}(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.pino=void 0;const t=pS,e=t.__importDefault(mS());Object.defineProperty(r,"pino",{enumerable:!0,get:function(){return e.default}}),t.__exportStar(ev(),r),t.__exportStar(wS(),r)})(he);let yS=class extends Co{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}},bS=class extends Co{constructor(t,e){super(),this.core=t,this.logger=e,this.records=new Map}},vS=class{constructor(t,e){this.logger=t,this.core=e}},ES=class extends Co{constructor(t,e){super(),this.relayer=t,this.logger=e}},_S=class extends Co{constructor(t){super()}},AS=class{constructor(t,e,n,i){this.core=t,this.logger=e,this.name=n}},xS=class extends Co{constructor(t,e){super(),this.relayer=t,this.logger=e}},IS=class extends Co{constructor(t,e){super(),this.core=t,this.logger=e}},CS=class{constructor(t,e){this.projectId=t,this.logger=e}},SS=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},OS=class{constructor(t){this.client=t}};const PS=r=>JSON.stringify(r,(t,e)=>typeof e=="bigint"?e.toString()+"n":e),DS=r=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,e=r.replace(t,'$1"$2n"$3');return JSON.parse(e,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function Pp(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return DS(r)}catch{return r}}function hl(r){return typeof r=="string"?r:PS(r)||""}var Dp={},Ta={},ah={},ch={};Object.defineProperty(ch,"__esModule",{value:!0}),ch.BrowserRandomSource=void 0;const nv=65536;class TS{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t=typeof self<"u"?self.crypto||self.msCrypto:null;t&&t.getRandomValues!==void 0&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const e=new Uint8Array(t);for(let n=0;n>>16&65535,d=l&65535,w=u>>>16&65535,m=u&65535;return d*m+(f*m+d*w<<16>>>0)|0}r.mul=Math.imul||t;function e(l,u){return l+u|0}r.add=e;function n(l,u){return l-u|0}r.sub=n;function i(l,u){return l<>>32-u}r.rotl=i;function s(l,u){return l<<32-u|l>>>u}r.rotr=s;function a(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l}r.isInteger=Number.isInteger||a,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(l){return r.isInteger(l)&&l>=-r.MAX_SAFE_INTEGER&&l<=r.MAX_SAFE_INTEGER}})(iv),Object.defineProperty(Gt,"__esModule",{value:!0});var sv=iv;function MS(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])<<16>>16}Gt.readInt16BE=MS;function jS(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])>>>0}Gt.readUint16BE=jS;function HS(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])<<16>>16}Gt.readInt16LE=HS;function zS(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])>>>0}Gt.readUint16LE=zS;function ov(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>8,t[e+1]=r>>>0,t}Gt.writeUint16BE=ov,Gt.writeInt16BE=ov;function av(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t}Gt.writeUint16LE=av,Gt.writeInt16LE=av;function Tp(r,t){return t===void 0&&(t=0),r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]}Gt.readInt32BE=Tp;function Np(r,t){return t===void 0&&(t=0),(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}Gt.readUint32BE=Np;function Rp(r,t){return t===void 0&&(t=0),r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t]}Gt.readInt32LE=Rp;function Lp(r,t){return t===void 0&&(t=0),(r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t])>>>0}Gt.readUint32LE=Lp;function uh(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r>>>0,t}Gt.writeUint32BE=uh,Gt.writeInt32BE=uh;function hh(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t[e+2]=r>>>16,t[e+3]=r>>>24,t}Gt.writeUint32LE=hh,Gt.writeInt32LE=hh;function VS(r,t){t===void 0&&(t=0);var e=Tp(r,t),n=Tp(r,t+4);return e*4294967296+n-(n>>31)*4294967296}Gt.readInt64BE=VS;function GS(r,t){t===void 0&&(t=0);var e=Np(r,t),n=Np(r,t+4);return e*4294967296+n}Gt.readUint64BE=GS;function qS(r,t){t===void 0&&(t=0);var e=Rp(r,t),n=Rp(r,t+4);return n*4294967296+e-(e>>31)*4294967296}Gt.readInt64LE=qS;function WS(r,t){t===void 0&&(t=0);var e=Lp(r,t),n=Lp(r,t+4);return n*4294967296+e}Gt.readUint64LE=WS;function cv(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),uh(r/4294967296>>>0,t,e),uh(r>>>0,t,e+4),t}Gt.writeUint64BE=cv,Gt.writeInt64BE=cv;function lv(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),hh(r>>>0,t,e),hh(r/4294967296>>>0,t,e+4),t}Gt.writeUint64LE=lv,Gt.writeInt64LE=lv;function KS(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=r/8+e-1;s>=e;s--)n+=t[s]*i,i*=256;return n}Gt.readUintBE=KS;function QS(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=e;s=n;s--)e[s]=t/i&255,i*=256;return e}Gt.writeUintBE=JS;function YS(r,t,e,n){if(e===void 0&&(e=new Uint8Array(r/8)),n===void 0&&(n=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!sv.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s256)throw new Error("randomString charset is too long");let m="";const b=d.length,E=256-256%b;for(;f>0;){const C=i(Math.ceil(f*256/E),w);for(let R=0;R0;R++){const k=C[R];k0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=u[d++],f--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(d=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,u,d,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=u[d++],f--;return this},l.prototype.finish=function(u){if(!this._finished){var f=this._bytesHashed,d=this._bufferLength,w=f/536870912|0,m=f<<3,b=f%128<112?128:256;this._buffer[d]=128;for(var E=d+1;E0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},l.prototype.restoreState=function(u){return this._stateHi.set(u.stateHi),this._stateLo.set(u.stateLo),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(u){e.wipe(u.stateHi),e.wipe(u.stateLo),u.buffer&&e.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},l}();r.SHA512=n;var i=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function s(l,u,f,d,w,m,b){for(var E=f[0],C=f[1],R=f[2],k=f[3],D=f[4],P=f[5],I=f[6],T=f[7],A=d[0],p=d[1],_=d[2],M=d[3],F=d[4],K=d[5],st=d[6],lt=d[7],S,$,tt,et,J,Y,X,ot;b>=128;){for(var Ot=0;Ot<16;Ot++){var ut=8*Ot+m;l[Ot]=t.readUint32BE(w,ut),u[Ot]=t.readUint32BE(w,ut+4)}for(var Ot=0;Ot<80;Ot++){var Pt=E,gt=C,Ct=R,W=k,G=D,j=P,y=I,U=T,ht=A,mt=p,Lt=_,ee=M,oe=F,Jt=K,Ve=st,Ge=lt;if(S=T,$=lt,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=(D>>>14|F<<32-14)^(D>>>18|F<<32-18)^(F>>>41-32|D<<32-(41-32)),$=(F>>>14|D<<32-14)^(F>>>18|D<<32-18)^(D>>>41-32|F<<32-(41-32)),J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,S=D&P^~D&I,$=F&K^~F&st,J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,S=i[Ot*2],$=i[Ot*2+1],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,S=l[Ot%16],$=u[Ot%16],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,tt=X&65535|ot<<16,et=J&65535|Y<<16,S=tt,$=et,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=(E>>>28|A<<32-28)^(A>>>34-32|E<<32-(34-32))^(A>>>39-32|E<<32-(39-32)),$=(A>>>28|E<<32-28)^(E>>>34-32|A<<32-(34-32))^(E>>>39-32|A<<32-(39-32)),J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,S=E&C^E&R^C&R,$=A&p^A&_^p&_,J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,U=X&65535|ot<<16,Ge=J&65535|Y<<16,S=W,$=ee,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=tt,$=et,J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,W=X&65535|ot<<16,ee=J&65535|Y<<16,C=Pt,R=gt,k=Ct,D=W,P=G,I=j,T=y,E=U,p=ht,_=mt,M=Lt,F=ee,K=oe,st=Jt,lt=Ve,A=Ge,Ot%16===15)for(var ut=0;ut<16;ut++)S=l[ut],$=u[ut],J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=l[(ut+9)%16],$=u[(ut+9)%16],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,tt=l[(ut+1)%16],et=u[(ut+1)%16],S=(tt>>>1|et<<32-1)^(tt>>>8|et<<32-8)^tt>>>7,$=(et>>>1|tt<<32-1)^(et>>>8|tt<<32-8)^(et>>>7|tt<<32-7),J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,tt=l[(ut+14)%16],et=u[(ut+14)%16],S=(tt>>>19|et<<32-19)^(et>>>61-32|tt<<32-(61-32))^tt>>>6,$=(et>>>19|tt<<32-19)^(tt>>>61-32|et<<32-(61-32))^(et>>>6|tt<<32-6),J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,l[ut]=X&65535|ot<<16,u[ut]=J&65535|Y<<16}S=E,$=A,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[0],$=d[0],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[0]=E=X&65535|ot<<16,d[0]=A=J&65535|Y<<16,S=C,$=p,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[1],$=d[1],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[1]=C=X&65535|ot<<16,d[1]=p=J&65535|Y<<16,S=R,$=_,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[2],$=d[2],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[2]=R=X&65535|ot<<16,d[2]=_=J&65535|Y<<16,S=k,$=M,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[3],$=d[3],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[3]=k=X&65535|ot<<16,d[3]=M=J&65535|Y<<16,S=D,$=F,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[4],$=d[4],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[4]=D=X&65535|ot<<16,d[4]=F=J&65535|Y<<16,S=P,$=K,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[5],$=d[5],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[5]=P=X&65535|ot<<16,d[5]=K=J&65535|Y<<16,S=I,$=st,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[6],$=d[6],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[6]=I=X&65535|ot<<16,d[6]=st=J&65535|Y<<16,S=T,$=lt,J=$&65535,Y=$>>>16,X=S&65535,ot=S>>>16,S=f[7],$=d[7],J+=$&65535,Y+=$>>>16,X+=S&65535,ot+=S>>>16,Y+=J>>>16,X+=Y>>>16,ot+=X>>>16,f[7]=T=X&65535|ot<<16,d[7]=lt=J&65535|Y<<16,m+=128,b-=128}return m}function a(l){var u=new n;u.update(l);var f=u.digest();return u.clean(),f}r.hash=a})(uv),function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const t=Ta,e=uv,n=kn;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function i(W){const G=new Float64Array(16);if(W)for(let j=0;j>16&1),j[mt-1]&=65535;j[15]=y[15]-32767-(j[14]>>16&1);const ht=j[15]>>16&1;j[14]&=65535,C(y,j,1-ht)}for(let U=0;U<16;U++)W[2*U]=y[U]&255,W[2*U+1]=y[U]>>8}function k(W,G){let j=0;for(let y=0;y<32;y++)j|=W[y]^G[y];return(1&j-1>>>8)-1}function D(W,G){const j=new Uint8Array(32),y=new Uint8Array(32);return R(j,W),R(y,G),k(j,y)}function P(W){const G=new Uint8Array(32);return R(G,W),G[0]&1}function I(W,G){for(let j=0;j<16;j++)W[j]=G[2*j]+(G[2*j+1]<<8);W[15]&=32767}function T(W,G,j){for(let y=0;y<16;y++)W[y]=G[y]+j[y]}function A(W,G,j){for(let y=0;y<16;y++)W[y]=G[y]-j[y]}function p(W,G,j){let y,U,ht=0,mt=0,Lt=0,ee=0,oe=0,Jt=0,Ve=0,Ge=0,Zt=0,$t=0,qt=0,Wt=0,Xt=0,Bt=0,Kt=0,Rt=0,Mt=0,re=0,kt=0,ae=0,le=0,ye=0,be=0,de=0,on=0,An=0,Di=0,an=0,is=0,Ks=0,Ho=0,sr=j[0],qe=j[1],or=j[2],ar=j[3],tr=j[4],We=j[5],_r=j[6],Ar=j[7],cr=j[8],xr=j[9],lr=j[10],gr=j[11],ur=j[12],Me=j[13],Ir=j[14],Cr=j[15];y=G[0],ht+=y*sr,mt+=y*qe,Lt+=y*or,ee+=y*ar,oe+=y*tr,Jt+=y*We,Ve+=y*_r,Ge+=y*Ar,Zt+=y*cr,$t+=y*xr,qt+=y*lr,Wt+=y*gr,Xt+=y*ur,Bt+=y*Me,Kt+=y*Ir,Rt+=y*Cr,y=G[1],mt+=y*sr,Lt+=y*qe,ee+=y*or,oe+=y*ar,Jt+=y*tr,Ve+=y*We,Ge+=y*_r,Zt+=y*Ar,$t+=y*cr,qt+=y*xr,Wt+=y*lr,Xt+=y*gr,Bt+=y*ur,Kt+=y*Me,Rt+=y*Ir,Mt+=y*Cr,y=G[2],Lt+=y*sr,ee+=y*qe,oe+=y*or,Jt+=y*ar,Ve+=y*tr,Ge+=y*We,Zt+=y*_r,$t+=y*Ar,qt+=y*cr,Wt+=y*xr,Xt+=y*lr,Bt+=y*gr,Kt+=y*ur,Rt+=y*Me,Mt+=y*Ir,re+=y*Cr,y=G[3],ee+=y*sr,oe+=y*qe,Jt+=y*or,Ve+=y*ar,Ge+=y*tr,Zt+=y*We,$t+=y*_r,qt+=y*Ar,Wt+=y*cr,Xt+=y*xr,Bt+=y*lr,Kt+=y*gr,Rt+=y*ur,Mt+=y*Me,re+=y*Ir,kt+=y*Cr,y=G[4],oe+=y*sr,Jt+=y*qe,Ve+=y*or,Ge+=y*ar,Zt+=y*tr,$t+=y*We,qt+=y*_r,Wt+=y*Ar,Xt+=y*cr,Bt+=y*xr,Kt+=y*lr,Rt+=y*gr,Mt+=y*ur,re+=y*Me,kt+=y*Ir,ae+=y*Cr,y=G[5],Jt+=y*sr,Ve+=y*qe,Ge+=y*or,Zt+=y*ar,$t+=y*tr,qt+=y*We,Wt+=y*_r,Xt+=y*Ar,Bt+=y*cr,Kt+=y*xr,Rt+=y*lr,Mt+=y*gr,re+=y*ur,kt+=y*Me,ae+=y*Ir,le+=y*Cr,y=G[6],Ve+=y*sr,Ge+=y*qe,Zt+=y*or,$t+=y*ar,qt+=y*tr,Wt+=y*We,Xt+=y*_r,Bt+=y*Ar,Kt+=y*cr,Rt+=y*xr,Mt+=y*lr,re+=y*gr,kt+=y*ur,ae+=y*Me,le+=y*Ir,ye+=y*Cr,y=G[7],Ge+=y*sr,Zt+=y*qe,$t+=y*or,qt+=y*ar,Wt+=y*tr,Xt+=y*We,Bt+=y*_r,Kt+=y*Ar,Rt+=y*cr,Mt+=y*xr,re+=y*lr,kt+=y*gr,ae+=y*ur,le+=y*Me,ye+=y*Ir,be+=y*Cr,y=G[8],Zt+=y*sr,$t+=y*qe,qt+=y*or,Wt+=y*ar,Xt+=y*tr,Bt+=y*We,Kt+=y*_r,Rt+=y*Ar,Mt+=y*cr,re+=y*xr,kt+=y*lr,ae+=y*gr,le+=y*ur,ye+=y*Me,be+=y*Ir,de+=y*Cr,y=G[9],$t+=y*sr,qt+=y*qe,Wt+=y*or,Xt+=y*ar,Bt+=y*tr,Kt+=y*We,Rt+=y*_r,Mt+=y*Ar,re+=y*cr,kt+=y*xr,ae+=y*lr,le+=y*gr,ye+=y*ur,be+=y*Me,de+=y*Ir,on+=y*Cr,y=G[10],qt+=y*sr,Wt+=y*qe,Xt+=y*or,Bt+=y*ar,Kt+=y*tr,Rt+=y*We,Mt+=y*_r,re+=y*Ar,kt+=y*cr,ae+=y*xr,le+=y*lr,ye+=y*gr,be+=y*ur,de+=y*Me,on+=y*Ir,An+=y*Cr,y=G[11],Wt+=y*sr,Xt+=y*qe,Bt+=y*or,Kt+=y*ar,Rt+=y*tr,Mt+=y*We,re+=y*_r,kt+=y*Ar,ae+=y*cr,le+=y*xr,ye+=y*lr,be+=y*gr,de+=y*ur,on+=y*Me,An+=y*Ir,Di+=y*Cr,y=G[12],Xt+=y*sr,Bt+=y*qe,Kt+=y*or,Rt+=y*ar,Mt+=y*tr,re+=y*We,kt+=y*_r,ae+=y*Ar,le+=y*cr,ye+=y*xr,be+=y*lr,de+=y*gr,on+=y*ur,An+=y*Me,Di+=y*Ir,an+=y*Cr,y=G[13],Bt+=y*sr,Kt+=y*qe,Rt+=y*or,Mt+=y*ar,re+=y*tr,kt+=y*We,ae+=y*_r,le+=y*Ar,ye+=y*cr,be+=y*xr,de+=y*lr,on+=y*gr,An+=y*ur,Di+=y*Me,an+=y*Ir,is+=y*Cr,y=G[14],Kt+=y*sr,Rt+=y*qe,Mt+=y*or,re+=y*ar,kt+=y*tr,ae+=y*We,le+=y*_r,ye+=y*Ar,be+=y*cr,de+=y*xr,on+=y*lr,An+=y*gr,Di+=y*ur,an+=y*Me,is+=y*Ir,Ks+=y*Cr,y=G[15],Rt+=y*sr,Mt+=y*qe,re+=y*or,kt+=y*ar,ae+=y*tr,le+=y*We,ye+=y*_r,be+=y*Ar,de+=y*cr,on+=y*xr,An+=y*lr,Di+=y*gr,an+=y*ur,is+=y*Me,Ks+=y*Ir,Ho+=y*Cr,ht+=38*Mt,mt+=38*re,Lt+=38*kt,ee+=38*ae,oe+=38*le,Jt+=38*ye,Ve+=38*be,Ge+=38*de,Zt+=38*on,$t+=38*An,qt+=38*Di,Wt+=38*an,Xt+=38*is,Bt+=38*Ks,Kt+=38*Ho,U=1,y=ht+U+65535,U=Math.floor(y/65536),ht=y-U*65536,y=mt+U+65535,U=Math.floor(y/65536),mt=y-U*65536,y=Lt+U+65535,U=Math.floor(y/65536),Lt=y-U*65536,y=ee+U+65535,U=Math.floor(y/65536),ee=y-U*65536,y=oe+U+65535,U=Math.floor(y/65536),oe=y-U*65536,y=Jt+U+65535,U=Math.floor(y/65536),Jt=y-U*65536,y=Ve+U+65535,U=Math.floor(y/65536),Ve=y-U*65536,y=Ge+U+65535,U=Math.floor(y/65536),Ge=y-U*65536,y=Zt+U+65535,U=Math.floor(y/65536),Zt=y-U*65536,y=$t+U+65535,U=Math.floor(y/65536),$t=y-U*65536,y=qt+U+65535,U=Math.floor(y/65536),qt=y-U*65536,y=Wt+U+65535,U=Math.floor(y/65536),Wt=y-U*65536,y=Xt+U+65535,U=Math.floor(y/65536),Xt=y-U*65536,y=Bt+U+65535,U=Math.floor(y/65536),Bt=y-U*65536,y=Kt+U+65535,U=Math.floor(y/65536),Kt=y-U*65536,y=Rt+U+65535,U=Math.floor(y/65536),Rt=y-U*65536,ht+=U-1+37*(U-1),U=1,y=ht+U+65535,U=Math.floor(y/65536),ht=y-U*65536,y=mt+U+65535,U=Math.floor(y/65536),mt=y-U*65536,y=Lt+U+65535,U=Math.floor(y/65536),Lt=y-U*65536,y=ee+U+65535,U=Math.floor(y/65536),ee=y-U*65536,y=oe+U+65535,U=Math.floor(y/65536),oe=y-U*65536,y=Jt+U+65535,U=Math.floor(y/65536),Jt=y-U*65536,y=Ve+U+65535,U=Math.floor(y/65536),Ve=y-U*65536,y=Ge+U+65535,U=Math.floor(y/65536),Ge=y-U*65536,y=Zt+U+65535,U=Math.floor(y/65536),Zt=y-U*65536,y=$t+U+65535,U=Math.floor(y/65536),$t=y-U*65536,y=qt+U+65535,U=Math.floor(y/65536),qt=y-U*65536,y=Wt+U+65535,U=Math.floor(y/65536),Wt=y-U*65536,y=Xt+U+65535,U=Math.floor(y/65536),Xt=y-U*65536,y=Bt+U+65535,U=Math.floor(y/65536),Bt=y-U*65536,y=Kt+U+65535,U=Math.floor(y/65536),Kt=y-U*65536,y=Rt+U+65535,U=Math.floor(y/65536),Rt=y-U*65536,ht+=U-1+37*(U-1),W[0]=ht,W[1]=mt,W[2]=Lt,W[3]=ee,W[4]=oe,W[5]=Jt,W[6]=Ve,W[7]=Ge,W[8]=Zt,W[9]=$t,W[10]=qt,W[11]=Wt,W[12]=Xt,W[13]=Bt,W[14]=Kt,W[15]=Rt}function _(W,G){p(W,G,G)}function M(W,G){const j=i();let y;for(y=0;y<16;y++)j[y]=G[y];for(y=253;y>=0;y--)_(j,j),y!==2&&y!==4&&p(j,j,G);for(y=0;y<16;y++)W[y]=j[y]}function F(W,G){const j=i();let y;for(y=0;y<16;y++)j[y]=G[y];for(y=250;y>=0;y--)_(j,j),y!==1&&p(j,j,G);for(y=0;y<16;y++)W[y]=j[y]}function K(W,G){const j=i(),y=i(),U=i(),ht=i(),mt=i(),Lt=i(),ee=i(),oe=i(),Jt=i();A(j,W[1],W[0]),A(Jt,G[1],G[0]),p(j,j,Jt),T(y,W[0],W[1]),T(Jt,G[0],G[1]),p(y,y,Jt),p(U,W[3],G[3]),p(U,U,f),p(ht,W[2],G[2]),T(ht,ht,ht),A(mt,y,j),A(Lt,ht,U),T(ee,ht,U),T(oe,y,j),p(W[0],mt,Lt),p(W[1],oe,ee),p(W[2],ee,Lt),p(W[3],mt,oe)}function st(W,G,j){for(let y=0;y<4;y++)C(W[y],G[y],j)}function lt(W,G){const j=i(),y=i(),U=i();M(U,G[2]),p(j,G[0],U),p(y,G[1],U),R(W,y),W[31]^=P(j)<<7}function S(W,G,j){b(W[0],a),b(W[1],l),b(W[2],l),b(W[3],a);for(let y=255;y>=0;--y){const U=j[y/8|0]>>(y&7)&1;st(W,G,U),K(G,W),K(W,W),st(W,G,U)}}function $(W,G){const j=[i(),i(),i(),i()];b(j[0],d),b(j[1],w),b(j[2],l),p(j[3],d,w),S(W,j,G)}function tt(W){if(W.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const G=(0,e.hash)(W);G[0]&=248,G[31]&=127,G[31]|=64;const j=new Uint8Array(32),y=[i(),i(),i(),i()];$(y,G),lt(j,y);const U=new Uint8Array(64);return U.set(W),U.set(j,32),{publicKey:j,secretKey:U}}r.generateKeyPairFromSeed=tt;function et(W){const G=(0,t.randomBytes)(32,W),j=tt(G);return(0,n.wipe)(G),j}r.generateKeyPair=et;function J(W){if(W.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(W.subarray(32))}r.extractPublicKeyFromSecretKey=J;const Y=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function X(W,G){let j,y,U,ht;for(y=63;y>=32;--y){for(j=0,U=y-32,ht=y-12;U>4)*Y[U],j=G[U]>>8,G[U]&=255;for(U=0;U<32;U++)G[U]-=j*Y[U];for(y=0;y<32;y++)G[y+1]+=G[y]>>8,W[y]=G[y]&255}function ot(W){const G=new Float64Array(64);for(let j=0;j<64;j++)G[j]=W[j];for(let j=0;j<64;j++)W[j]=0;X(W,G)}function Ot(W,G){const j=new Float64Array(64),y=[i(),i(),i(),i()],U=(0,e.hash)(W.subarray(0,32));U[0]&=248,U[31]&=127,U[31]|=64;const ht=new Uint8Array(64);ht.set(U.subarray(32),32);const mt=new e.SHA512;mt.update(ht.subarray(32)),mt.update(G);const Lt=mt.digest();mt.clean(),ot(Lt),$(y,Lt),lt(ht,y),mt.reset(),mt.update(ht.subarray(0,32)),mt.update(W.subarray(32)),mt.update(G);const ee=mt.digest();ot(ee);for(let oe=0;oe<32;oe++)j[oe]=Lt[oe];for(let oe=0;oe<32;oe++)for(let Jt=0;Jt<32;Jt++)j[oe+Jt]+=ee[oe]*U[Jt];return X(ht.subarray(32),j),ht}r.sign=Ot;function ut(W,G){const j=i(),y=i(),U=i(),ht=i(),mt=i(),Lt=i(),ee=i();return b(W[2],l),I(W[1],G),_(U,W[1]),p(ht,U,u),A(U,U,W[2]),T(ht,W[2],ht),_(mt,ht),_(Lt,mt),p(ee,Lt,mt),p(j,ee,U),p(j,j,ht),F(j,j),p(j,j,U),p(j,j,ht),p(j,j,ht),p(W[0],j,ht),_(y,W[0]),p(y,y,ht),D(y,U)&&p(W[0],W[0],m),_(y,W[0]),p(y,y,ht),D(y,U)?-1:(P(W[0])===G[31]>>7&&A(W[0],a,W[0]),p(W[3],W[0],W[1]),0)}function Pt(W,G,j){const y=new Uint8Array(32),U=[i(),i(),i(),i()],ht=[i(),i(),i(),i()];if(j.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(ut(ht,W))return!1;const mt=new e.SHA512;mt.update(j.subarray(0,32)),mt.update(W),mt.update(G);const Lt=mt.digest();return ot(Lt),S(U,ht,Lt),$(ht,j.subarray(32)),K(U,ht),lt(y,U),!k(j,y)}r.verify=Pt;function gt(W){let G=[i(),i(),i(),i()];if(ut(G,W))throw new Error("Ed25519: invalid public key");let j=i(),y=i(),U=G[1];T(j,l,U),A(y,l,U),M(y,y),p(j,j,y);let ht=new Uint8Array(32);return R(ht,j),ht}r.convertPublicKeyToX25519=gt;function Ct(W){const G=(0,e.hash)(W.subarray(0,32));G[0]&=248,G[31]&=127,G[31]|=64;const j=new Uint8Array(G.subarray(0,32));return(0,n.wipe)(G),j}r.convertSecretKeyToX25519=Ct}(Dp);const oO="EdDSA",aO="JWT",hv=".",fv="base64url",cO="utf8",lO="utf8",uO=":",hO="did",fO="key",dv="base58btc",dO="z",pO="K36",gO=32;function $p(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function pv(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?$p(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function kp(r,t){t||(t=r.reduce((i,s)=>i+s.length,0));const e=pv(t);let n=0;for(const i of r)e.set(i,n),n+=i.length;return $p(e)}function mO(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n>>0,I=new Uint8Array(P);k!==D;){for(var T=E[k],A=0,p=P-1;(T!==0||A>>0,I[p]=T%l>>>0,T=T/l>>>0;if(T!==0)throw new Error("Non-zero carry");R=A,k++}for(var _=P-R;_!==P&&I[_]===0;)_++;for(var M=u.repeat(C);_>>0,P=new Uint8Array(D);E[C];){var I=e[E.charCodeAt(C)];if(I===255)return;for(var T=0,A=D-1;(I!==0||T>>0,P[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");k=T,C++}if(E[C]!==" "){for(var p=D-k;p!==D&&P[p]===0;)p++;for(var _=new Uint8Array(R+(D-p)),M=R;p!==D;)_[M++]=P[p++];return _}}}function b(E){var C=m(E);if(C)return C;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:m,decode:b}}var wO=mO,yO=wO;const bO=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},vO=r=>new TextEncoder().encode(r),EO=r=>new TextDecoder().decode(r);class _O{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class AO{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return gv(this,t)}}class xO{constructor(t){this.decoders=t}or(t){return gv(this,t)}decode(t){const e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const gv=(r,t)=>new xO({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});class IO{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new _O(t,e,n),this.decoder=new AO(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const fh=({name:r,prefix:t,encode:e,decode:n})=>new IO(r,t,e,n),fl=({prefix:r,name:t,alphabet:e})=>{const{encode:n,decode:i}=yO(e,t);return fh({prefix:r,name:t,encode:n,decode:s=>bO(i(s))})},CO=(r,t,e,n)=>{const i={};for(let d=0;d=8&&(l-=8,a[f++]=255&u>>l)}if(l>=e||255&u<<8-l)throw new SyntaxError("Unexpected end of data");return a},SO=(r,t,e)=>{const n=t[t.length-1]==="=",i=(1<e;)a-=e,s+=t[i&l>>a];if(a&&(s+=t[i&l<fh({prefix:t,name:r,encode(i){return SO(i,n,e)},decode(i){return CO(i,n,e,r)}}),OO=fh({prefix:"\0",name:"identity",encode:r=>EO(r),decode:r=>vO(r)}),PO=Object.freeze(Object.defineProperty({__proto__:null,identity:OO},Symbol.toStringTag,{value:"Module"})),DO=Mr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),TO=Object.freeze(Object.defineProperty({__proto__:null,base2:DO},Symbol.toStringTag,{value:"Module"})),NO=Mr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),RO=Object.freeze(Object.defineProperty({__proto__:null,base8:NO},Symbol.toStringTag,{value:"Module"})),LO=fl({prefix:"9",name:"base10",alphabet:"0123456789"}),$O=Object.freeze(Object.defineProperty({__proto__:null,base10:LO},Symbol.toStringTag,{value:"Module"})),kO=Mr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),UO=Mr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),BO=Object.freeze(Object.defineProperty({__proto__:null,base16:kO,base16upper:UO},Symbol.toStringTag,{value:"Module"})),FO=Mr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),MO=Mr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),jO=Mr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),HO=Mr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zO=Mr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),VO=Mr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),GO=Mr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),qO=Mr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),WO=Mr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),KO=Object.freeze(Object.defineProperty({__proto__:null,base32:FO,base32hex:zO,base32hexpad:GO,base32hexpadupper:qO,base32hexupper:VO,base32pad:jO,base32padupper:HO,base32upper:MO,base32z:WO},Symbol.toStringTag,{value:"Module"})),QO=fl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),JO=fl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),YO=Object.freeze(Object.defineProperty({__proto__:null,base36:QO,base36upper:JO},Symbol.toStringTag,{value:"Module"})),ZO=fl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),XO=fl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),tP=Object.freeze(Object.defineProperty({__proto__:null,base58btc:ZO,base58flickr:XO},Symbol.toStringTag,{value:"Module"})),eP=Mr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),rP=Mr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),nP=Mr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),iP=Mr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),sP=Object.freeze(Object.defineProperty({__proto__:null,base64:eP,base64pad:rP,base64url:nP,base64urlpad:iP},Symbol.toStringTag,{value:"Module"})),mv=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),oP=mv.reduce((r,t,e)=>(r[e]=t,r),[]),aP=mv.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function cP(r){return r.reduce((t,e)=>(t+=oP[e],t),"")}function lP(r){const t=[];for(const e of r){const n=aP[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}const uP=fh({prefix:"🚀",name:"base256emoji",encode:cP,decode:lP}),hP=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:uP},Symbol.toStringTag,{value:"Module"}));new TextEncoder,new TextDecoder;const wv={...PO,...TO,...RO,...$O,...BO,...KO,...YO,...tP,...sP,...hP};function yv(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}const bv=yv("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Up=yv("ascii","a",r=>{let t="a";for(let e=0;e{r=r.substring(1);const t=pv(r.length);for(let e=0;e>>32-16|$<<16,K=K+$|0,p^=K,p=p>>>32-12|p<<12,I=I+_|0,tt^=I,tt=tt>>>32-16|tt<<16,st=st+tt|0,_^=st,_=_>>>32-12|_<<12,T=T+M|0,et^=T,et=et>>>32-16|et<<16,lt=lt+et|0,M^=lt,M=M>>>32-12|M<<12,A=A+F|0,J^=A,J=J>>>32-16|J<<16,S=S+J|0,F^=S,F=F>>>32-12|F<<12,T=T+M|0,et^=T,et=et>>>32-8|et<<8,lt=lt+et|0,M^=lt,M=M>>>32-7|M<<7,A=A+F|0,J^=A,J=J>>>32-8|J<<8,S=S+J|0,F^=S,F=F>>>32-7|F<<7,I=I+_|0,tt^=I,tt=tt>>>32-8|tt<<8,st=st+tt|0,_^=st,_=_>>>32-7|_<<7,P=P+p|0,$^=P,$=$>>>32-8|$<<8,K=K+$|0,p^=K,p=p>>>32-7|p<<7,P=P+_|0,J^=P,J=J>>>32-16|J<<16,lt=lt+J|0,_^=lt,_=_>>>32-12|_<<12,I=I+M|0,$^=I,$=$>>>32-16|$<<16,S=S+$|0,M^=S,M=M>>>32-12|M<<12,T=T+F|0,tt^=T,tt=tt>>>32-16|tt<<16,K=K+tt|0,F^=K,F=F>>>32-12|F<<12,A=A+p|0,et^=A,et=et>>>32-16|et<<16,st=st+et|0,p^=st,p=p>>>32-12|p<<12,T=T+F|0,tt^=T,tt=tt>>>32-8|tt<<8,K=K+tt|0,F^=K,F=F>>>32-7|F<<7,A=A+p|0,et^=A,et=et>>>32-8|et<<8,st=st+et|0,p^=st,p=p>>>32-7|p<<7,I=I+M|0,$^=I,$=$>>>32-8|$<<8,S=S+$|0,M^=S,M=M>>>32-7|M<<7,P=P+_|0,J^=P,J=J>>>32-8|J<<8,lt=lt+J|0,_^=lt,_=_>>>32-7|_<<7;qr.writeUint32LE(P+n|0,r,0),qr.writeUint32LE(I+i|0,r,4),qr.writeUint32LE(T+s|0,r,8),qr.writeUint32LE(A+a|0,r,12),qr.writeUint32LE(p+l|0,r,16),qr.writeUint32LE(_+u|0,r,20),qr.writeUint32LE(M+f|0,r,24),qr.writeUint32LE(F+d|0,r,28),qr.writeUint32LE(K+w|0,r,32),qr.writeUint32LE(st+m|0,r,36),qr.writeUint32LE(lt+b|0,r,40),qr.writeUint32LE(S+E|0,r,44),qr.writeUint32LE($+C|0,r,48),qr.writeUint32LE(tt+R|0,r,52),qr.writeUint32LE(et+k|0,r,56),qr.writeUint32LE(J+D|0,r,60)}function Av(r,t,e,n,i){if(i===void 0&&(i=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length>>=8,t++;if(n>0)throw new Error("ChaCha: counter overflow")}var xv={},$s={};Object.defineProperty($s,"__esModule",{value:!0});function vP(r,t,e){return~(r-1)&t|r-1&e}$s.select=vP;function EP(r,t){return(r|0)-(t|0)-1>>>31&1}$s.lessOrEqual=EP;function Iv(r,t){if(r.length!==t.length)return 0;for(var e=0,n=0;n>>8}$s.compare=Iv;function _P(r,t){return r.length===0||t.length===0?!1:Iv(r,t)!==0}$s.equal=_P,function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=$s,e=kn;r.DIGEST_LENGTH=16;var n=function(){function a(l){this.digestLength=r.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var u=l[0]|l[1]<<8;this._r[0]=u&8191;var f=l[2]|l[3]<<8;this._r[1]=(u>>>13|f<<3)&8191;var d=l[4]|l[5]<<8;this._r[2]=(f>>>10|d<<6)&7939;var w=l[6]|l[7]<<8;this._r[3]=(d>>>7|w<<9)&8191;var m=l[8]|l[9]<<8;this._r[4]=(w>>>4|m<<12)&255,this._r[5]=m>>>1&8190;var b=l[10]|l[11]<<8;this._r[6]=(m>>>14|b<<2)&8191;var E=l[12]|l[13]<<8;this._r[7]=(b>>>11|E<<5)&8065;var C=l[14]|l[15]<<8;this._r[8]=(E>>>8|C<<8)&8191,this._r[9]=C>>>5&127,this._pad[0]=l[16]|l[17]<<8,this._pad[1]=l[18]|l[19]<<8,this._pad[2]=l[20]|l[21]<<8,this._pad[3]=l[22]|l[23]<<8,this._pad[4]=l[24]|l[25]<<8,this._pad[5]=l[26]|l[27]<<8,this._pad[6]=l[28]|l[29]<<8,this._pad[7]=l[30]|l[31]<<8}return a.prototype._blocks=function(l,u,f){for(var d=this._fin?0:2048,w=this._h[0],m=this._h[1],b=this._h[2],E=this._h[3],C=this._h[4],R=this._h[5],k=this._h[6],D=this._h[7],P=this._h[8],I=this._h[9],T=this._r[0],A=this._r[1],p=this._r[2],_=this._r[3],M=this._r[4],F=this._r[5],K=this._r[6],st=this._r[7],lt=this._r[8],S=this._r[9];f>=16;){var $=l[u+0]|l[u+1]<<8;w+=$&8191;var tt=l[u+2]|l[u+3]<<8;m+=($>>>13|tt<<3)&8191;var et=l[u+4]|l[u+5]<<8;b+=(tt>>>10|et<<6)&8191;var J=l[u+6]|l[u+7]<<8;E+=(et>>>7|J<<9)&8191;var Y=l[u+8]|l[u+9]<<8;C+=(J>>>4|Y<<12)&8191,R+=Y>>>1&8191;var X=l[u+10]|l[u+11]<<8;k+=(Y>>>14|X<<2)&8191;var ot=l[u+12]|l[u+13]<<8;D+=(X>>>11|ot<<5)&8191;var Ot=l[u+14]|l[u+15]<<8;P+=(ot>>>8|Ot<<8)&8191,I+=Ot>>>5|d;var ut=0,Pt=ut;Pt+=w*T,Pt+=m*(5*S),Pt+=b*(5*lt),Pt+=E*(5*st),Pt+=C*(5*K),ut=Pt>>>13,Pt&=8191,Pt+=R*(5*F),Pt+=k*(5*M),Pt+=D*(5*_),Pt+=P*(5*p),Pt+=I*(5*A),ut+=Pt>>>13,Pt&=8191;var gt=ut;gt+=w*A,gt+=m*T,gt+=b*(5*S),gt+=E*(5*lt),gt+=C*(5*st),ut=gt>>>13,gt&=8191,gt+=R*(5*K),gt+=k*(5*F),gt+=D*(5*M),gt+=P*(5*_),gt+=I*(5*p),ut+=gt>>>13,gt&=8191;var Ct=ut;Ct+=w*p,Ct+=m*A,Ct+=b*T,Ct+=E*(5*S),Ct+=C*(5*lt),ut=Ct>>>13,Ct&=8191,Ct+=R*(5*st),Ct+=k*(5*K),Ct+=D*(5*F),Ct+=P*(5*M),Ct+=I*(5*_),ut+=Ct>>>13,Ct&=8191;var W=ut;W+=w*_,W+=m*p,W+=b*A,W+=E*T,W+=C*(5*S),ut=W>>>13,W&=8191,W+=R*(5*lt),W+=k*(5*st),W+=D*(5*K),W+=P*(5*F),W+=I*(5*M),ut+=W>>>13,W&=8191;var G=ut;G+=w*M,G+=m*_,G+=b*p,G+=E*A,G+=C*T,ut=G>>>13,G&=8191,G+=R*(5*S),G+=k*(5*lt),G+=D*(5*st),G+=P*(5*K),G+=I*(5*F),ut+=G>>>13,G&=8191;var j=ut;j+=w*F,j+=m*M,j+=b*_,j+=E*p,j+=C*A,ut=j>>>13,j&=8191,j+=R*T,j+=k*(5*S),j+=D*(5*lt),j+=P*(5*st),j+=I*(5*K),ut+=j>>>13,j&=8191;var y=ut;y+=w*K,y+=m*F,y+=b*M,y+=E*_,y+=C*p,ut=y>>>13,y&=8191,y+=R*A,y+=k*T,y+=D*(5*S),y+=P*(5*lt),y+=I*(5*st),ut+=y>>>13,y&=8191;var U=ut;U+=w*st,U+=m*K,U+=b*F,U+=E*M,U+=C*_,ut=U>>>13,U&=8191,U+=R*p,U+=k*A,U+=D*T,U+=P*(5*S),U+=I*(5*lt),ut+=U>>>13,U&=8191;var ht=ut;ht+=w*lt,ht+=m*st,ht+=b*K,ht+=E*F,ht+=C*M,ut=ht>>>13,ht&=8191,ht+=R*_,ht+=k*p,ht+=D*A,ht+=P*T,ht+=I*(5*S),ut+=ht>>>13,ht&=8191;var mt=ut;mt+=w*S,mt+=m*lt,mt+=b*st,mt+=E*K,mt+=C*F,ut=mt>>>13,mt&=8191,mt+=R*M,mt+=k*_,mt+=D*p,mt+=P*A,mt+=I*T,ut+=mt>>>13,mt&=8191,ut=(ut<<2)+ut|0,ut=ut+Pt|0,Pt=ut&8191,ut=ut>>>13,gt+=ut,w=Pt,m=gt,b=Ct,E=W,C=G,R=j,k=y,D=U,P=ht,I=mt,u+=16,f-=16}this._h[0]=w,this._h[1]=m,this._h[2]=b,this._h[3]=E,this._h[4]=C,this._h[5]=R,this._h[6]=k,this._h[7]=D,this._h[8]=P,this._h[9]=I},a.prototype.finish=function(l,u){u===void 0&&(u=0);var f=new Uint16Array(10),d,w,m,b;if(this._leftover){for(b=this._leftover,this._buffer[b++]=1;b<16;b++)this._buffer[b]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(d=this._h[1]>>>13,this._h[1]&=8191,b=2;b<10;b++)this._h[b]+=d,d=this._h[b]>>>13,this._h[b]&=8191;for(this._h[0]+=d*5,d=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=d,d=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=d,f[0]=this._h[0]+5,d=f[0]>>>13,f[0]&=8191,b=1;b<10;b++)f[b]=this._h[b]+d,d=f[b]>>>13,f[b]&=8191;for(f[9]-=8192,w=(d^1)-1,b=0;b<10;b++)f[b]&=w;for(w=~w,b=0;b<10;b++)this._h[b]=this._h[b]&w|f[b];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,m=this._h[0]+this._pad[0],this._h[0]=m&65535,b=1;b<8;b++)m=(this._h[b]+this._pad[b]|0)+(m>>>16)|0,this._h[b]=m&65535;return l[u+0]=this._h[0]>>>0,l[u+1]=this._h[0]>>>8,l[u+2]=this._h[1]>>>0,l[u+3]=this._h[1]>>>8,l[u+4]=this._h[2]>>>0,l[u+5]=this._h[2]>>>8,l[u+6]=this._h[3]>>>0,l[u+7]=this._h[3]>>>8,l[u+8]=this._h[4]>>>0,l[u+9]=this._h[4]>>>8,l[u+10]=this._h[5]>>>0,l[u+11]=this._h[5]>>>8,l[u+12]=this._h[6]>>>0,l[u+13]=this._h[6]>>>8,l[u+14]=this._h[7]>>>0,l[u+15]=this._h[7]>>>8,this._finished=!0,this},a.prototype.update=function(l){var u=0,f=l.length,d;if(this._leftover){d=16-this._leftover,d>f&&(d=f);for(var w=0;w=16&&(d=f-f%16,this._blocks(l,u,d),u+=d,f-=d),f){for(var w=0;w16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var b=new Uint8Array(16);b.set(f,b.length-f.length);var E=new Uint8Array(32);t.stream(this._key,b,E,4);var C=d.length+this.tagLength,R;if(m){if(m.length!==C)throw new Error("ChaCha20Poly1305: incorrect destination length");R=m}else R=new Uint8Array(C);return t.streamXOR(this._key,b,d,R,4),this._authenticate(R.subarray(R.length-this.tagLength,R.length),E,R.subarray(0,R.length-this.tagLength),w),n.wipe(b),R},u.prototype.open=function(f,d,w,m){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(d.length0&&b.update(a.subarray(m.length%16))),b.update(w),w.length%16>0&&b.update(a.subarray(w.length%16));var E=new Uint8Array(8);m&&i.writeUint64LE(m.length,E),b.update(E),i.writeUint64LE(w.length,E),b.update(E);for(var C=b.digest(),R=0;Rthis.blockSize?this._inner.update(e).finish(n).clean():n.set(e);for(var i=0;i1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(t){for(var e=new Uint8Array(t),n=0;n0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=u[d++],f--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(d=s(this._temp,this._state,u,d,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=u[d++],f--;return this},l.prototype.finish=function(u){if(!this._finished){var f=this._bytesHashed,d=this._bufferLength,w=f/536870912|0,m=f<<3,b=f%64<56?64:128;this._buffer[d]=128;for(var E=d+1;E0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},l.prototype.restoreState=function(u){return this._state.set(u.state),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(u){e.wipe(u.state),u.buffer&&e.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},l}();r.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(l,u,f,d,w){for(;w>=64;){for(var m=u[0],b=u[1],E=u[2],C=u[3],R=u[4],k=u[5],D=u[6],P=u[7],I=0;I<16;I++){var T=d+I*4;l[I]=t.readUint32BE(f,T)}for(var I=16;I<64;I++){var A=l[I-2],p=(A>>>17|A<<32-17)^(A>>>19|A<<32-19)^A>>>10;A=l[I-15];var _=(A>>>7|A<<32-7)^(A>>>18|A<<32-18)^A>>>3;l[I]=(p+l[I-7]|0)+(_+l[I-16]|0)}for(var I=0;I<64;I++){var p=(((R>>>6|R<<26)^(R>>>11|R<<21)^(R>>>25|R<<7))+(R&k^~R&D)|0)+(P+(i[I]+l[I]|0)|0)|0,_=((m>>>2|m<<32-2)^(m>>>13|m<<32-13)^(m>>>22|m<<32-22))+(m&b^m&E^b&E)|0;P=D,D=k,k=R,R=C+p|0,C=E,E=b,b=m,m=p+_|0}u[0]+=m,u[1]+=b,u[2]+=E,u[3]+=C,u[4]+=R,u[5]+=k,u[6]+=D,u[7]+=P,d+=64,w-=64}return d}function a(l){var u=new n;u.update(l);var f=u.digest();return u.clean(),f}r.hash=a})(gh);var jp={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const t=Ta,e=kn;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function n(I){const T=new Float64Array(16);if(I)for(let A=0;A>16&1),A[F-1]&=65535;A[15]=p[15]-32767-(A[14]>>16&1);const M=A[15]>>16&1;A[14]&=65535,l(p,A,1-M)}for(let _=0;_<16;_++)I[2*_]=p[_]&255,I[2*_+1]=p[_]>>8}function f(I,T){for(let A=0;A<16;A++)I[A]=T[2*A]+(T[2*A+1]<<8);I[15]&=32767}function d(I,T,A){for(let p=0;p<16;p++)I[p]=T[p]+A[p]}function w(I,T,A){for(let p=0;p<16;p++)I[p]=T[p]-A[p]}function m(I,T,A){let p,_,M=0,F=0,K=0,st=0,lt=0,S=0,$=0,tt=0,et=0,J=0,Y=0,X=0,ot=0,Ot=0,ut=0,Pt=0,gt=0,Ct=0,W=0,G=0,j=0,y=0,U=0,ht=0,mt=0,Lt=0,ee=0,oe=0,Jt=0,Ve=0,Ge=0,Zt=A[0],$t=A[1],qt=A[2],Wt=A[3],Xt=A[4],Bt=A[5],Kt=A[6],Rt=A[7],Mt=A[8],re=A[9],kt=A[10],ae=A[11],le=A[12],ye=A[13],be=A[14],de=A[15];p=T[0],M+=p*Zt,F+=p*$t,K+=p*qt,st+=p*Wt,lt+=p*Xt,S+=p*Bt,$+=p*Kt,tt+=p*Rt,et+=p*Mt,J+=p*re,Y+=p*kt,X+=p*ae,ot+=p*le,Ot+=p*ye,ut+=p*be,Pt+=p*de,p=T[1],F+=p*Zt,K+=p*$t,st+=p*qt,lt+=p*Wt,S+=p*Xt,$+=p*Bt,tt+=p*Kt,et+=p*Rt,J+=p*Mt,Y+=p*re,X+=p*kt,ot+=p*ae,Ot+=p*le,ut+=p*ye,Pt+=p*be,gt+=p*de,p=T[2],K+=p*Zt,st+=p*$t,lt+=p*qt,S+=p*Wt,$+=p*Xt,tt+=p*Bt,et+=p*Kt,J+=p*Rt,Y+=p*Mt,X+=p*re,ot+=p*kt,Ot+=p*ae,ut+=p*le,Pt+=p*ye,gt+=p*be,Ct+=p*de,p=T[3],st+=p*Zt,lt+=p*$t,S+=p*qt,$+=p*Wt,tt+=p*Xt,et+=p*Bt,J+=p*Kt,Y+=p*Rt,X+=p*Mt,ot+=p*re,Ot+=p*kt,ut+=p*ae,Pt+=p*le,gt+=p*ye,Ct+=p*be,W+=p*de,p=T[4],lt+=p*Zt,S+=p*$t,$+=p*qt,tt+=p*Wt,et+=p*Xt,J+=p*Bt,Y+=p*Kt,X+=p*Rt,ot+=p*Mt,Ot+=p*re,ut+=p*kt,Pt+=p*ae,gt+=p*le,Ct+=p*ye,W+=p*be,G+=p*de,p=T[5],S+=p*Zt,$+=p*$t,tt+=p*qt,et+=p*Wt,J+=p*Xt,Y+=p*Bt,X+=p*Kt,ot+=p*Rt,Ot+=p*Mt,ut+=p*re,Pt+=p*kt,gt+=p*ae,Ct+=p*le,W+=p*ye,G+=p*be,j+=p*de,p=T[6],$+=p*Zt,tt+=p*$t,et+=p*qt,J+=p*Wt,Y+=p*Xt,X+=p*Bt,ot+=p*Kt,Ot+=p*Rt,ut+=p*Mt,Pt+=p*re,gt+=p*kt,Ct+=p*ae,W+=p*le,G+=p*ye,j+=p*be,y+=p*de,p=T[7],tt+=p*Zt,et+=p*$t,J+=p*qt,Y+=p*Wt,X+=p*Xt,ot+=p*Bt,Ot+=p*Kt,ut+=p*Rt,Pt+=p*Mt,gt+=p*re,Ct+=p*kt,W+=p*ae,G+=p*le,j+=p*ye,y+=p*be,U+=p*de,p=T[8],et+=p*Zt,J+=p*$t,Y+=p*qt,X+=p*Wt,ot+=p*Xt,Ot+=p*Bt,ut+=p*Kt,Pt+=p*Rt,gt+=p*Mt,Ct+=p*re,W+=p*kt,G+=p*ae,j+=p*le,y+=p*ye,U+=p*be,ht+=p*de,p=T[9],J+=p*Zt,Y+=p*$t,X+=p*qt,ot+=p*Wt,Ot+=p*Xt,ut+=p*Bt,Pt+=p*Kt,gt+=p*Rt,Ct+=p*Mt,W+=p*re,G+=p*kt,j+=p*ae,y+=p*le,U+=p*ye,ht+=p*be,mt+=p*de,p=T[10],Y+=p*Zt,X+=p*$t,ot+=p*qt,Ot+=p*Wt,ut+=p*Xt,Pt+=p*Bt,gt+=p*Kt,Ct+=p*Rt,W+=p*Mt,G+=p*re,j+=p*kt,y+=p*ae,U+=p*le,ht+=p*ye,mt+=p*be,Lt+=p*de,p=T[11],X+=p*Zt,ot+=p*$t,Ot+=p*qt,ut+=p*Wt,Pt+=p*Xt,gt+=p*Bt,Ct+=p*Kt,W+=p*Rt,G+=p*Mt,j+=p*re,y+=p*kt,U+=p*ae,ht+=p*le,mt+=p*ye,Lt+=p*be,ee+=p*de,p=T[12],ot+=p*Zt,Ot+=p*$t,ut+=p*qt,Pt+=p*Wt,gt+=p*Xt,Ct+=p*Bt,W+=p*Kt,G+=p*Rt,j+=p*Mt,y+=p*re,U+=p*kt,ht+=p*ae,mt+=p*le,Lt+=p*ye,ee+=p*be,oe+=p*de,p=T[13],Ot+=p*Zt,ut+=p*$t,Pt+=p*qt,gt+=p*Wt,Ct+=p*Xt,W+=p*Bt,G+=p*Kt,j+=p*Rt,y+=p*Mt,U+=p*re,ht+=p*kt,mt+=p*ae,Lt+=p*le,ee+=p*ye,oe+=p*be,Jt+=p*de,p=T[14],ut+=p*Zt,Pt+=p*$t,gt+=p*qt,Ct+=p*Wt,W+=p*Xt,G+=p*Bt,j+=p*Kt,y+=p*Rt,U+=p*Mt,ht+=p*re,mt+=p*kt,Lt+=p*ae,ee+=p*le,oe+=p*ye,Jt+=p*be,Ve+=p*de,p=T[15],Pt+=p*Zt,gt+=p*$t,Ct+=p*qt,W+=p*Wt,G+=p*Xt,j+=p*Bt,y+=p*Kt,U+=p*Rt,ht+=p*Mt,mt+=p*re,Lt+=p*kt,ee+=p*ae,oe+=p*le,Jt+=p*ye,Ve+=p*be,Ge+=p*de,M+=38*gt,F+=38*Ct,K+=38*W,st+=38*G,lt+=38*j,S+=38*y,$+=38*U,tt+=38*ht,et+=38*mt,J+=38*Lt,Y+=38*ee,X+=38*oe,ot+=38*Jt,Ot+=38*Ve,ut+=38*Ge,_=1,p=M+_+65535,_=Math.floor(p/65536),M=p-_*65536,p=F+_+65535,_=Math.floor(p/65536),F=p-_*65536,p=K+_+65535,_=Math.floor(p/65536),K=p-_*65536,p=st+_+65535,_=Math.floor(p/65536),st=p-_*65536,p=lt+_+65535,_=Math.floor(p/65536),lt=p-_*65536,p=S+_+65535,_=Math.floor(p/65536),S=p-_*65536,p=$+_+65535,_=Math.floor(p/65536),$=p-_*65536,p=tt+_+65535,_=Math.floor(p/65536),tt=p-_*65536,p=et+_+65535,_=Math.floor(p/65536),et=p-_*65536,p=J+_+65535,_=Math.floor(p/65536),J=p-_*65536,p=Y+_+65535,_=Math.floor(p/65536),Y=p-_*65536,p=X+_+65535,_=Math.floor(p/65536),X=p-_*65536,p=ot+_+65535,_=Math.floor(p/65536),ot=p-_*65536,p=Ot+_+65535,_=Math.floor(p/65536),Ot=p-_*65536,p=ut+_+65535,_=Math.floor(p/65536),ut=p-_*65536,p=Pt+_+65535,_=Math.floor(p/65536),Pt=p-_*65536,M+=_-1+37*(_-1),_=1,p=M+_+65535,_=Math.floor(p/65536),M=p-_*65536,p=F+_+65535,_=Math.floor(p/65536),F=p-_*65536,p=K+_+65535,_=Math.floor(p/65536),K=p-_*65536,p=st+_+65535,_=Math.floor(p/65536),st=p-_*65536,p=lt+_+65535,_=Math.floor(p/65536),lt=p-_*65536,p=S+_+65535,_=Math.floor(p/65536),S=p-_*65536,p=$+_+65535,_=Math.floor(p/65536),$=p-_*65536,p=tt+_+65535,_=Math.floor(p/65536),tt=p-_*65536,p=et+_+65535,_=Math.floor(p/65536),et=p-_*65536,p=J+_+65535,_=Math.floor(p/65536),J=p-_*65536,p=Y+_+65535,_=Math.floor(p/65536),Y=p-_*65536,p=X+_+65535,_=Math.floor(p/65536),X=p-_*65536,p=ot+_+65535,_=Math.floor(p/65536),ot=p-_*65536,p=Ot+_+65535,_=Math.floor(p/65536),Ot=p-_*65536,p=ut+_+65535,_=Math.floor(p/65536),ut=p-_*65536,p=Pt+_+65535,_=Math.floor(p/65536),Pt=p-_*65536,M+=_-1+37*(_-1),I[0]=M,I[1]=F,I[2]=K,I[3]=st,I[4]=lt,I[5]=S,I[6]=$,I[7]=tt,I[8]=et,I[9]=J,I[10]=Y,I[11]=X,I[12]=ot,I[13]=Ot,I[14]=ut,I[15]=Pt}function b(I,T){m(I,T,T)}function E(I,T){const A=n();for(let p=0;p<16;p++)A[p]=T[p];for(let p=253;p>=0;p--)b(A,A),p!==2&&p!==4&&m(A,A,T);for(let p=0;p<16;p++)I[p]=A[p]}function C(I,T){const A=new Uint8Array(32),p=new Float64Array(80),_=n(),M=n(),F=n(),K=n(),st=n(),lt=n();for(let et=0;et<31;et++)A[et]=I[et];A[31]=I[31]&127|64,A[0]&=248,f(p,T);for(let et=0;et<16;et++)M[et]=p[et];_[0]=K[0]=1;for(let et=254;et>=0;--et){const J=A[et>>>3]>>>(et&7)&1;l(_,M,J),l(F,K,J),d(st,_,F),w(_,_,F),d(F,M,K),w(M,M,K),b(K,st),b(lt,_),m(_,F,_),m(F,M,st),d(st,_,F),w(_,_,F),b(M,_),w(F,K,lt),m(_,F,s),d(_,_,K),m(F,F,_),m(_,K,lt),m(K,M,p),b(M,st),l(_,M,J),l(F,K,J)}for(let et=0;et<16;et++)p[et+16]=_[et],p[et+32]=F[et],p[et+48]=M[et],p[et+64]=K[et];const S=p.subarray(32),$=p.subarray(16);E(S,S),m($,$,S);const tt=new Uint8Array(32);return u(tt,$),tt}r.scalarMult=C;function R(I){return C(I,i)}r.scalarMultBase=R;function k(I){if(I.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const T=new Uint8Array(I);return{publicKey:R(T),secretKey:T}}r.generateKeyPairFromSeed=k;function D(I){const T=(0,t.randomBytes)(32,I),A=k(T);return(0,e.wipe)(T),A}r.generateKeyPair=D;function P(I,T,A=!1){if(I.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(T.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const p=C(I,T);if(A){let _=0;for(let M=0;M"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new RP:typeof navigator<"u"?Rv(navigator.userAgent):MP()}function BP(r){return r!==""&&kP.reduce(function(t,e){var n=e[0],i=e[1];if(t)return t;var s=i.exec(r);return!!s&&[n,s]},!1)}function Rv(r){var t=BP(r);if(!t)return null;var e=t[0],n=t[1];if(e==="searchbot")return new NP;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length-1){const R=E.getAttribute("href");if(R)if(R.toLowerCase().indexOf("https:")===-1&&R.toLowerCase().indexOf("http:")===-1&&R.indexOf("//")!==0){let k=t.protocol+"//"+t.host;if(R.indexOf("/")===0)k+=R;else{const D=t.pathname.split("/");D.pop();const P=D.join("/");k+=P+"/"+R}m.push(k)}else if(R.indexOf("//")===0){const k=t.protocol+R;m.push(k)}else m.push(R)}}return m}function n(...w){const m=r.getElementsByTagName("meta");for(let b=0;bE.getAttribute(R)).filter(R=>R?w.includes(R):!1);if(C.length&&C){const R=E.getAttribute("content");if(R)return R}}return""}function i(){let w=n("name","og:site_name","og:title","twitter:title");return w||(w=r.title),w}function s(){return n("description","og:description","twitter:description","keywords")}const a=i(),l=s(),u=t.origin,f=e();return{description:l,url:u,icons:f,name:a}}kv=zp.getWindowMetadata=ZP;var pl={},XP=r=>encodeURIComponent(r).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),Bv="%[a-f0-9]{2}",Fv=new RegExp("("+Bv+")|([^%]+?)","gi"),Mv=new RegExp("("+Bv+")+","gi");function Vp(r,t){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;t=t||1;var e=r.slice(0,t),n=r.slice(t);return Array.prototype.concat.call([],Vp(e),Vp(n))}function tD(r){try{return decodeURIComponent(r)}catch{for(var t=r.match(Fv)||[],e=1;e{if(!(typeof r=="string"&&typeof t=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(t==="")return[r];const e=r.indexOf(t);return e===-1?[r]:[r.slice(0,e),r.slice(e+t.length)]},iD=function(r,t){for(var e={},n=Object.keys(r),i=Array.isArray(t),s=0;sD==null,a=Symbol("encodeFragmentIdentifier");function l(D){switch(D.arrayFormat){case"index":return P=>(I,T)=>{const A=I.length;return T===void 0||D.skipNull&&T===null||D.skipEmptyString&&T===""?I:T===null?[...I,[d(P,D),"[",A,"]"].join("")]:[...I,[d(P,D),"[",d(A,D),"]=",d(T,D)].join("")]};case"bracket":return P=>(I,T)=>T===void 0||D.skipNull&&T===null||D.skipEmptyString&&T===""?I:T===null?[...I,[d(P,D),"[]"].join("")]:[...I,[d(P,D),"[]=",d(T,D)].join("")];case"colon-list-separator":return P=>(I,T)=>T===void 0||D.skipNull&&T===null||D.skipEmptyString&&T===""?I:T===null?[...I,[d(P,D),":list="].join("")]:[...I,[d(P,D),":list=",d(T,D)].join("")];case"comma":case"separator":case"bracket-separator":{const P=D.arrayFormat==="bracket-separator"?"[]=":"=";return I=>(T,A)=>A===void 0||D.skipNull&&A===null||D.skipEmptyString&&A===""?T:(A=A===null?"":A,T.length===0?[[d(I,D),P,d(A,D)].join("")]:[[T,d(A,D)].join(D.arrayFormatSeparator)])}default:return P=>(I,T)=>T===void 0||D.skipNull&&T===null||D.skipEmptyString&&T===""?I:T===null?[...I,d(P,D)]:[...I,[d(P,D),"=",d(T,D)].join("")]}}function u(D){let P;switch(D.arrayFormat){case"index":return(I,T,A)=>{if(P=/\[(\d*)\]$/.exec(I),I=I.replace(/\[\d*\]$/,""),!P){A[I]=T;return}A[I]===void 0&&(A[I]={}),A[I][P[1]]=T};case"bracket":return(I,T,A)=>{if(P=/(\[\])$/.exec(I),I=I.replace(/\[\]$/,""),!P){A[I]=T;return}if(A[I]===void 0){A[I]=[T];return}A[I]=[].concat(A[I],T)};case"colon-list-separator":return(I,T,A)=>{if(P=/(:list)$/.exec(I),I=I.replace(/:list$/,""),!P){A[I]=T;return}if(A[I]===void 0){A[I]=[T];return}A[I]=[].concat(A[I],T)};case"comma":case"separator":return(I,T,A)=>{const p=typeof T=="string"&&T.includes(D.arrayFormatSeparator),_=typeof T=="string"&&!p&&w(T,D).includes(D.arrayFormatSeparator);T=_?w(T,D):T;const M=p||_?T.split(D.arrayFormatSeparator).map(F=>w(F,D)):T===null?T:w(T,D);A[I]=M};case"bracket-separator":return(I,T,A)=>{const p=/(\[\])$/.test(I);if(I=I.replace(/\[\]$/,""),!p){A[I]=T&&w(T,D);return}const _=T===null?[]:T.split(D.arrayFormatSeparator).map(M=>w(M,D));if(A[I]===void 0){A[I]=_;return}A[I]=[].concat(A[I],_)};default:return(I,T,A)=>{if(A[I]===void 0){A[I]=T;return}A[I]=[].concat(A[I],T)}}}function f(D){if(typeof D!="string"||D.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function d(D,P){return P.encode?P.strict?t(D):encodeURIComponent(D):D}function w(D,P){return P.decode?e(D):D}function m(D){return Array.isArray(D)?D.sort():typeof D=="object"?m(Object.keys(D)).sort((P,I)=>Number(P)-Number(I)).map(P=>D[P]):D}function b(D){const P=D.indexOf("#");return P!==-1&&(D=D.slice(0,P)),D}function E(D){let P="";const I=D.indexOf("#");return I!==-1&&(P=D.slice(I)),P}function C(D){D=b(D);const P=D.indexOf("?");return P===-1?"":D.slice(P+1)}function R(D,P){return P.parseNumbers&&!Number.isNaN(Number(D))&&typeof D=="string"&&D.trim()!==""?D=Number(D):P.parseBooleans&&D!==null&&(D.toLowerCase()==="true"||D.toLowerCase()==="false")&&(D=D.toLowerCase()==="true"),D}function k(D,P){P=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},P),f(P.arrayFormatSeparator);const I=u(P),T=Object.create(null);if(typeof D!="string"||(D=D.trim().replace(/^[?#&]/,""),!D))return T;for(const A of D.split("&")){if(A==="")continue;let[p,_]=n(P.decode?A.replace(/\+/g," "):A,"=");_=_===void 0?null:["comma","separator","bracket-separator"].includes(P.arrayFormat)?_:w(_,P),I(w(p,P),_,T)}for(const A of Object.keys(T)){const p=T[A];if(typeof p=="object"&&p!==null)for(const _ of Object.keys(p))p[_]=R(p[_],P);else T[A]=R(p,P)}return P.sort===!1?T:(P.sort===!0?Object.keys(T).sort():Object.keys(T).sort(P.sort)).reduce((A,p)=>{const _=T[p];return _&&typeof _=="object"&&!Array.isArray(_)?A[p]=m(_):A[p]=_,A},Object.create(null))}r.extract=C,r.parse=k,r.stringify=(D,P)=>{if(!D)return"";P=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},P),f(P.arrayFormatSeparator);const I=_=>P.skipNull&&s(D[_])||P.skipEmptyString&&D[_]==="",T=l(P),A={};for(const _ of Object.keys(D))I(_)||(A[_]=D[_]);const p=Object.keys(A);return P.sort!==!1&&p.sort(P.sort),p.map(_=>{const M=D[_];return M===void 0?"":M===null?d(_,P):Array.isArray(M)?M.length===0&&P.arrayFormat==="bracket-separator"?d(_,P)+"[]":M.reduce(T(_),[]).join("&"):d(_,P)+"="+d(M,P)}).filter(_=>_.length>0).join("&")},r.parseUrl=(D,P)=>{P=Object.assign({decode:!0},P);const[I,T]=n(D,"#");return Object.assign({url:I.split("?")[0]||"",query:k(C(D),P)},P&&P.parseFragmentIdentifier&&T?{fragmentIdentifier:w(T,P)}:{})},r.stringifyUrl=(D,P)=>{P=Object.assign({encode:!0,strict:!0,[a]:!0},P);const I=b(D.url).split("?")[0]||"",T=r.extract(D.url),A=r.parse(T,{sort:!1}),p=Object.assign(A,D.query);let _=r.stringify(p,P);_&&(_=`?${_}`);let M=E(D.url);return D.fragmentIdentifier&&(M=`#${P[a]?d(D.fragmentIdentifier,P):D.fragmentIdentifier}`),`${I}${_}${M}`},r.pick=(D,P,I)=>{I=Object.assign({parseFragmentIdentifier:!0,[a]:!1},I);const{url:T,query:A,fragmentIdentifier:p}=r.parseUrl(D,I);return r.stringifyUrl({url:T,query:i(A,P),fragmentIdentifier:p},I)},r.exclude=(D,P,I)=>{const T=Array.isArray(P)?A=>!P.includes(A):(A,p)=>!P(A,p);return r.pick(D,T,I)}})(pl);const sD={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe"}};function jv(r,t){return r.includes(":")?[r]:t.chains||[]}const Hv="base10",rn="base16",Gp="base64pad",qp="utf8",zv=0,Do=1,oD=0,Vv=1,Wp=12,Kp=32;function aD(){const r=jp.generateKeyPair();return{privateKey:en(r.secretKey,rn),publicKey:en(r.publicKey,rn)}}function Qp(){const r=Ta.randomBytes(Kp);return en(r,rn)}function cD(r,t){const e=jp.sharedKey(bn(r,rn),bn(t,rn)),n=new OP(gh.SHA256,e).expand(Kp);return en(n,rn)}function lD(r){const t=gh.hash(bn(r,rn));return en(t,rn)}function Ra(r){const t=gh.hash(bn(r,qp));return en(t,rn)}function uD(r){return bn(`${r}`,Hv)}function gl(r){return Number(en(r,Hv))}function hD(r){const t=uD(typeof r.type<"u"?r.type:zv);if(gl(t)===Do&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const e=typeof r.senderPublicKey<"u"?bn(r.senderPublicKey,rn):void 0,n=typeof r.iv<"u"?bn(r.iv,rn):Ta.randomBytes(Wp),i=new Bp.ChaCha20Poly1305(bn(r.symKey,rn)).seal(n,bn(r.message,qp));return dD({type:t,sealed:i,iv:n,senderPublicKey:e})}function fD(r){const t=new Bp.ChaCha20Poly1305(bn(r.symKey,rn)),{sealed:e,iv:n}=mh(r.encoded),i=t.open(n,e);if(i===null)throw new Error("Failed to decrypt");return en(i,qp)}function dD(r){if(gl(r.type)===Do){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return en(kp([r.type,r.senderPublicKey,r.iv,r.sealed]),Gp)}return en(kp([r.type,r.iv,r.sealed]),Gp)}function mh(r){const t=bn(r,Gp),e=t.slice(oD,Vv),n=Vv;if(gl(e)===Do){const l=n+Kp,u=l+Wp,f=t.slice(n,l),d=t.slice(l,u),w=t.slice(u);return{type:e,sealed:w,iv:d,senderPublicKey:f}}const i=n+Wp,s=t.slice(n,i),a=t.slice(i);return{type:e,sealed:a,iv:s}}function pD(r,t){const e=mh(r);return Gv({type:gl(e.type),senderPublicKey:typeof e.senderPublicKey<"u"?en(e.senderPublicKey,rn):void 0,receiverPublicKey:t?.receiverPublicKey})}function Gv(r){const t=r?.type||zv;if(t===Do){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function qv(r){return r.type===Do&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}var gD=Object.defineProperty,Wv=Object.getOwnPropertySymbols,mD=Object.prototype.hasOwnProperty,wD=Object.prototype.propertyIsEnumerable,Kv=(r,t,e)=>t in r?gD(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qv=(r,t)=>{for(var e in t||(t={}))mD.call(t,e)&&Kv(r,e,t[e]);if(Wv)for(var e of Wv(t))wD.call(t,e)&&Kv(r,e,t[e]);return r};const yD="ReactNative",Un={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},bD="js";function Jp(){return typeof Qn<"u"&&typeof Qn.versions<"u"&&typeof Qn.versions.node<"u"}function wh(){return!Lv()&&!!Hp()&&navigator.product===yD}function ml(){return!Jp()&&!!Hp()}function wl(){return wh()?Un.reactNative:Jp()?Un.node:ml()?Un.browser:Un.unknown}function vD(r,t){let e=pl.parse(r);return e=Qv(Qv({},e),t),r=pl.stringify(e),r}function ED(){return kv()||{name:"",description:"",url:"",icons:[""]}}function _D(){if(wl()===Un.reactNative&&typeof Te<"u"&&typeof Te?.Platform<"u"){const{OS:e,Version:n}=Te.Platform;return[e,n].join("-")}const r=UP();if(r===null)return"unknown";const t=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[t,r.name,r.version].join("-"):[t,r.version].join("-")}function AD(){var r;const t=wl();return t===Un.browser?[t,((r=$v())==null?void 0:r.host)||"unknown"].join(":"):t}function xD(r,t,e){const n=_D(),i=AD();return[[r,t].join("-"),[bD,e].join("-"),n,i].join("/")}function ID({protocol:r,version:t,relayUrl:e,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:a}){const l=e.split("?"),u=xD(r,t,n),f={auth:i,ua:u,projectId:s,useOnCloseEvent:a||void 0},d=vD(l[1]||"",f);return l[0]+"?"+d}function To(r,t){return r.filter(e=>t.includes(e)).length===r.length}function Jv(r){return Object.fromEntries(r.entries())}function Yv(r){return new Map(Object.entries(r))}function La(r=_t.FIVE_MINUTES,t){const e=_t.toMiliseconds(r||_t.FIVE_MINUTES);let n,i,s;return{resolve:a=>{s&&n&&(clearTimeout(s),n(a))},reject:a=>{s&&i&&(clearTimeout(s),i(a))},done:()=>new Promise((a,l)=>{s=setTimeout(()=>{l(new Error(t))},e),n=a,i=l})}}function yl(r,t,e){return new Promise(async(n,i)=>{const s=setTimeout(()=>i(new Error(e)),t);try{const a=await r;n(a)}catch(a){i(a)}clearTimeout(s)})}function Zv(r,t){if(typeof t=="string"&&t.startsWith(`${r}:`))return t;if(r.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(r.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${r}`)}function CD(r){return Zv("topic",r)}function SD(r){return Zv("id",r)}function Xv(r){const[t,e]=r.split(":"),n={id:void 0,topic:void 0};if(t==="topic"&&typeof e=="string")n.topic=e;else if(t==="id"&&Number.isInteger(Number(e)))n.id=Number(e);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${e}`);return n}function fi(r,t){return _t.fromMiliseconds((t||Date.now())+_t.toMiliseconds(r))}function ks(r){return Date.now()>=_t.toMiliseconds(r)}function vr(r,t){return`${r}${t?`:${t}`:""}`}function Yp(r=[],t=[]){return[...new Set([...r,...t])]}async function OD({id:r,topic:t,wcDeepLink:e}){try{if(!e)return;let i=(typeof e=="string"?JSON.parse(e):e)?.href;if(typeof i!="string")return;i.endsWith("/")&&(i=i.slice(0,-1));const s=`${i}/wc?requestId=${r}&sessionTopic=${t}`,a=wl();a===Un.browser?s.startsWith("https://")?window.open(s,"_blank","noreferrer noopener"):window.open(s,"_self","noreferrer noopener"):a===Un.reactNative&&typeof Te?.Linking<"u"&&await Te.Linking.openURL(s)}catch(n){console.error(n)}}const PD="irn";function Zp(r){return r?.relay||{protocol:PD}}function yh(r){const t=sD[r];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${r}`);return t}var DD=Object.defineProperty,t2=Object.getOwnPropertySymbols,TD=Object.prototype.hasOwnProperty,ND=Object.prototype.propertyIsEnumerable,e2=(r,t,e)=>t in r?DD(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,RD=(r,t)=>{for(var e in t||(t={}))TD.call(t,e)&&e2(r,e,t[e]);if(t2)for(var e of t2(t))ND.call(t,e)&&e2(r,e,t[e]);return r};function LD(r,t="-"){const e={},n="relay"+t;return Object.keys(r).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),a=r[i];e[s]=a}}),e}function $D(r){const t=r.indexOf(":"),e=r.indexOf("?")!==-1?r.indexOf("?"):void 0,n=r.substring(0,t),i=r.substring(t+1,e).split("@"),s=typeof e<"u"?r.substring(e):"",a=pl.parse(s);return{protocol:n,topic:kD(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:LD(a)}}function kD(r){return r.startsWith("//")?r.substring(2):r}function UD(r,t="-"){const e="relay",n={};return Object.keys(r).forEach(i=>{const s=e+t+i;r[i]&&(n[s]=r[i])}),n}function BD(r){return`${r.protocol}:${r.topic}@${r.version}?`+pl.stringify(RD({symKey:r.symKey},UD(r.relay)))}function $a(r){const t=[];return r.forEach(e=>{const[n,i]=e.split(":");t.push(`${n}:${i}`)}),t}function FD(r){const t=[];return Object.values(r).forEach(e=>{t.push(...$a(e.accounts))}),t}function MD(r,t){const e=[];return Object.values(r).forEach(n=>{$a(n.accounts).includes(t)&&e.push(...n.methods)}),e}function jD(r,t){const e=[];return Object.values(r).forEach(n=>{$a(n.accounts).includes(t)&&e.push(...n.events)}),e}function HD(r,t){const e=vh(r,t);if(e)throw new Error(e.message);const n={};for(const[i,s]of Object.entries(r))n[i]={methods:s.methods,events:s.events,chains:s.accounts.map(a=>`${a.split(":")[0]}:${a.split(":")[1]}`)};return n}function Xp(r){return r.includes(":")}function bl(r){return Xp(r)?r.split(":")[0]:r}const zD={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},VD={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function pt(r,t){const{message:e,code:n}=VD[r];return{message:t?`${e} ${t}`:e,code:n}}function Er(r,t){const{message:e,code:n}=zD[r];return{message:t?`${e} ${t}`:e,code:n}}function No(r,t){return Array.isArray(r)?typeof t<"u"&&r.length?r.every(t):!0:!1}function ka(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function nn(r){return typeof r>"u"}function kr(r,t){return t&&nn(r)?!0:typeof r=="string"&&!!r.trim().length}function t0(r,t){return t&&nn(r)?!0:typeof r=="number"&&!isNaN(r)}function GD(r,t){const{requiredNamespaces:e}=t,n=Object.keys(r.namespaces),i=Object.keys(e);let s=!0;return To(i,n)?(n.forEach(a=>{const{accounts:l,methods:u,events:f}=r.namespaces[a],d=$a(l),w=e[a];(!To(jv(a,w),d)||!To(w.methods,u)||!To(w.events,f))&&(s=!1)}),s):!1}function bh(r){return kr(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function qD(r){if(kr(r,!1)&&r.includes(":")){const t=r.split(":");if(t.length===3){const e=t[0]+":"+t[1];return!!t[2]&&bh(e)}}return!1}function WD(r){if(kr(r,!1))try{return typeof new URL(r)<"u"}catch{return!1}return!1}function KD(r){var t;return(t=r?.proposer)==null?void 0:t.publicKey}function QD(r){return r?.topic}function JD(r,t){let e=null;return kr(r?.publicKey,!1)||(e=pt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),e}function r2(r){let t=!0;return No(r)?r.length&&(t=r.every(e=>kr(e,!1))):t=!1,t}function YD(r,t,e){let n=null;return No(t)&&t.length?t.forEach(i=>{n||bh(i)||(n=Er("UNSUPPORTED_CHAINS",`${e}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):bh(r)||(n=Er("UNSUPPORTED_CHAINS",`${e}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),n}function ZD(r,t,e){let n=null;return Object.entries(r).forEach(([i,s])=>{if(n)return;const a=YD(i,jv(i,s),`${t} ${e}`);a&&(n=a)}),n}function XD(r,t){let e=null;return No(r)?r.forEach(n=>{e||qD(n)||(e=Er("UNSUPPORTED_ACCOUNTS",`${t}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):e=Er("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),e}function tT(r,t){let e=null;return Object.values(r).forEach(n=>{if(e)return;const i=XD(n?.accounts,`${t} namespace`);i&&(e=i)}),e}function eT(r,t){let e=null;return r2(r?.methods)?r2(r?.events)||(e=Er("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):e=Er("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),e}function n2(r,t){let e=null;return Object.values(r).forEach(n=>{if(e)return;const i=eT(n,`${t}, namespace`);i&&(e=i)}),e}function rT(r,t,e){let n=null;if(r&&ka(r)){const i=n2(r,t);i&&(n=i);const s=ZD(r,t,e);s&&(n=s)}else n=pt("MISSING_OR_INVALID",`${t}, ${e} should be an object with data`);return n}function vh(r,t){let e=null;if(r&&ka(r)){const n=n2(r,t);n&&(e=n);const i=tT(r,t);i&&(e=i)}else e=pt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return e}function i2(r){return kr(r.protocol,!0)}function nT(r,t){let e=!1;return t&&!r?e=!0:r&&No(r)&&r.length&&r.forEach(n=>{e=i2(n)}),e}function iT(r){return typeof r=="number"}function vn(r){return typeof r<"u"&&typeof r!==null}function sT(r){return!(!r||typeof r!="object"||!r.code||!t0(r.code,!1)||!r.message||!kr(r.message,!1))}function oT(r){return!(nn(r)||!kr(r.method,!1))}function aT(r){return!(nn(r)||nn(r.result)&&nn(r.error)||!t0(r.id,!1)||!kr(r.jsonrpc,!1))}function cT(r){return!(nn(r)||!kr(r.name,!1))}function s2(r,t){return!(!bh(t)||!FD(r).includes(t))}function lT(r,t,e){return kr(e,!1)?MD(r,t).includes(e):!1}function uT(r,t,e){return kr(e,!1)?jD(r,t).includes(e):!1}function o2(r,t,e){let n=null;const i=hT(r),s=fT(t),a=Object.keys(i),l=Object.keys(s),u=a2(Object.keys(r)),f=a2(Object.keys(t)),d=u.filter(w=>!f.includes(w));return d.length&&(n=pt("NON_CONFORMING_NAMESPACES",`${e} namespaces keys don't satisfy requiredNamespaces. Required: ${d.toString()} Received: ${Object.keys(t).toString()}`)),To(a,l)||(n=pt("NON_CONFORMING_NAMESPACES",`${e} namespaces chains don't satisfy required namespaces. Required: ${a.toString()} Approved: ${l.toString()}`)),Object.keys(t).forEach(w=>{if(!w.includes(":")||n)return;const m=$a(t[w].accounts);m.includes(w)||(n=pt("NON_CONFORMING_NAMESPACES",`${e} namespaces accounts don't satisfy namespace accounts for ${w} Required: ${w} Approved: ${m.toString()}`))}),a.forEach(w=>{n||(To(i[w].methods,s[w].methods)?To(i[w].events,s[w].events)||(n=pt("NON_CONFORMING_NAMESPACES",`${e} namespaces events don't satisfy namespace events for ${w}`)):n=pt("NON_CONFORMING_NAMESPACES",`${e} namespaces methods don't satisfy namespace methods for ${w}`))}),n}function hT(r){const t={};return Object.keys(r).forEach(e=>{var n;e.includes(":")?t[e]=r[e]:(n=r[e].chains)==null||n.forEach(i=>{t[i]={methods:r[e].methods,events:r[e].events}})}),t}function a2(r){return[...new Set(r.map(t=>t.includes(":")?t.split(":")[0]:t))]}function fT(r){const t={};return Object.keys(r).forEach(e=>{e.includes(":")?t[e]=r[e]:$a(r[e].accounts)?.forEach(i=>{t[i]={accounts:r[e].accounts.filter(s=>s.includes(`${i}:`)),methods:r[e].methods,events:r[e].events}})}),t}function dT(r,t){return t0(r,!1)&&r<=t.max&&r>=t.min}function c2(){const r=wl();return new Promise(t=>{switch(r){case Un.browser:t(pT());break;case Un.reactNative:t(gT());break;case Un.node:t(mT());break;default:t(!0)}})}function pT(){return ml()&&navigator?.onLine}async function gT(){return wh()&&typeof Te<"u"&&Te!=null&&Te.NetInfo?(await Te?.NetInfo.fetch())?.isConnected:!0}function mT(){return!0}function wT(r){switch(wl()){case Un.browser:yT(r);break;case Un.reactNative:bT(r);break}}function yT(r){ml()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function bT(r){wh()&&typeof Te<"u"&&Te!=null&&Te.NetInfo&&Te?.NetInfo.addEventListener(t=>r(t?.isConnected))}const e0={};let Eh=class{static get(t){return e0[t]}static set(t,e){e0[t]=e}static delete(t){delete e0[t]}};const vT="PARSE_ERROR",ET="INVALID_REQUEST",_T="METHOD_NOT_FOUND",AT="INVALID_PARAMS",l2="INTERNAL_ERROR",r0="SERVER_ERROR",xT=[-32700,-32600,-32601,-32602,-32603],vl={[vT]:{code:-32700,message:"Parse error"},[ET]:{code:-32600,message:"Invalid Request"},[_T]:{code:-32601,message:"Method not found"},[AT]:{code:-32602,message:"Invalid params"},[l2]:{code:-32603,message:"Internal error"},[r0]:{code:-32e3,message:"Server error"}},u2=r0;function IT(r){return xT.includes(r)}function h2(r){return Object.keys(vl).includes(r)?vl[r]:vl[u2]}function CT(r){const t=Object.values(vl).find(e=>e.code===r);return t||vl[u2]}function f2(r,t,e){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${e} RPC url at ${t}`):r}var d2={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var n0=function(r,t){return n0=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])},n0(r,t)};function ST(r,t){n0(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var i0=function(){return i0=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;l--)(a=r[l])&&(s=(i<3?a(s):i>3?a(t,e,s):a(t,e))||s);return i>3&&s&&Object.defineProperty(t,e,s),s}function DT(r,t){return function(e,n){t(e,n,r)}}function TT(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function NT(r,t,e,n){function i(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function l(d){try{f(n.next(d))}catch(w){a(w)}}function u(d){try{f(n.throw(d))}catch(w){a(w)}}function f(d){d.done?s(d.value):i(d.value).then(l,u)}f((n=n.apply(r,t||[])).next())})}function RT(r,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(f){return function(d){return u([f,d])}}function u(f){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return e.label++,{value:f[1],done:!1};case 5:e.label++,i=f[1],f=[0];continue;case 7:f=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){e=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function p2(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var n=e.call(r),i,s=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(l){a={error:l}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return s}function kT(){for(var r=[],t=0;t1||l(m,b)})})}function l(m,b){try{u(n[m](b))}catch(E){w(s[0][3],E)}}function u(m){m.value instanceof El?Promise.resolve(m.value.v).then(f,d):w(s[0][2],m)}function f(m){l("next",m)}function d(m){l("throw",m)}function w(m,b){m(b),s.shift(),s.length&&l(s[0][0],s[0][1])}}function FT(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(a){return(e=!e)?{value:El(r[i](a)),done:i==="return"}:s?s(a):a}:s}}function MT(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof s0=="function"?s0(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(a){return new Promise(function(l,u){a=r[s](a),i(l,u,a.done,a.value)})}}function i(s,a,l,u){Promise.resolve(u).then(function(f){s({value:f,done:l})},a)}}function jT(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}function HT(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t}function zT(r){return r&&r.__esModule?r:{default:r}}function VT(r,t){if(!t.has(r))throw new TypeError("attempted to get private field on non-instance");return t.get(r)}function GT(r,t,e){if(!t.has(r))throw new TypeError("attempted to set private field on non-instance");return t.set(r,e),e}const qT=Ao(Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return i0},__asyncDelegator:FT,__asyncGenerator:BT,__asyncValues:MT,__await:El,__awaiter:NT,__classPrivateFieldGet:VT,__classPrivateFieldSet:GT,__createBinding:LT,__decorate:PT,__exportStar:$T,__extends:ST,__generator:RT,__importDefault:zT,__importStar:HT,__makeTemplateObject:jT,__metadata:TT,__param:DT,__read:p2,__rest:OT,__spread:kT,__spreadArrays:UT,__values:s0},Symbol.toStringTag,{value:"Module"})));var Qi={},g2;function WT(){if(g2)return Qi;g2=1,Object.defineProperty(Qi,"__esModule",{value:!0}),Qi.isBrowserCryptoAvailable=Qi.getSubtleCrypto=Qi.getBrowerCrypto=void 0;function r(){return yn?.crypto||yn?.msCrypto||{}}Qi.getBrowerCrypto=r;function t(){const n=r();return n.subtle||n.webkitSubtle}Qi.getSubtleCrypto=t;function e(){return!!r()&&!!t()}return Qi.isBrowserCryptoAvailable=e,Qi}var Ji={},m2;function KT(){if(m2)return Ji;m2=1,Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.isBrowser=Ji.isNode=Ji.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Ji.isReactNative=r;function t(){return typeof Qn<"u"&&typeof Qn.versions<"u"&&typeof Qn.versions.node<"u"}Ji.isNode=t;function e(){return!r()&&!t()}return Ji.isBrowser=e,Ji}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=qT;t.__exportStar(WT(),r),t.__exportStar(KT(),r)})(d2);function o0(r=3){const t=Date.now()*Math.pow(10,r),e=Math.floor(Math.random()*Math.pow(10,r));return t+e}function w2(r=6){return BigInt(o0(r))}function _l(r,t,e){return{id:e||o0(),jsonrpc:"2.0",method:r,params:t}}function a0(r,t){return{id:r,jsonrpc:"2.0",result:t}}function _h(r,t,e){return{id:r,jsonrpc:"2.0",error:QT(t,e)}}function QT(r,t){return typeof r>"u"?h2(l2):(typeof r=="string"&&(r=Object.assign(Object.assign({},h2(r0)),{message:r})),typeof t<"u"&&(r.data=t),IT(r.code)&&(r=CT(r.code)),r)}class JT{}class YT extends JT{constructor(){super()}}class ZT extends YT{constructor(t){super()}}const XT="^https?:",tN="^wss?:";function eN(r){const t=r.match(new RegExp(/^\w+:/,"gi"));if(!(!t||!t.length))return t[0]}function y2(r,t){const e=eN(r);return typeof e>"u"?!1:new RegExp(t).test(e)}function b2(r){return y2(r,XT)}function v2(r){return y2(r,tN)}function rN(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function E2(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function c0(r){return E2(r)&&"method"in r}function Ah(r){return E2(r)&&(Yi(r)||di(r))}function Yi(r){return"result"in r}function di(r){return"error"in r}class Us extends ZT{constructor(t){super(t),this.events=new Jn.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async request(t,e){return this.requestStrict(_l(t.method,t.params||[],t.id||w2().toString()),e)}async requestStrict(t,e){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${t.id}`,s=>{di(s)?i(s.error):n(s.result)});try{await this.connection.send(t,e)}catch(s){i(s)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),Ah(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const nN=()=>typeof WebSocket<"u"?WebSocket:typeof Te<"u"&&typeof Te.WebSocket<"u"?Te.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),iN=()=>typeof WebSocket<"u"||typeof Te<"u"&&typeof Te.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",_2=r=>r.split("?")[0],A2=10,sN=nN();class oN{constructor(t){if(this.url=t,this.events=new Jn.EventEmitter,this.registering=!1,!v2(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,e)=>{if(typeof this.socket>"u"){e(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),t()},this.socket.close()})}async send(t,e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(hl(t))}catch(n){this.onError(t.id,n)}}register(t=this.url){if(!v2(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=t,this.registering=!0,new Promise((e,n)=>{const i=d2.isReactNative()?void 0:{rejectUnauthorized:!rN(t)},s=new sN(t,[],i);iN()?s.onerror=a=>{const l=a;n(this.emitError(l.error))}:s.on("error",a=>{n(this.emitError(a))}),s.onopen=()=>{this.onOpen(s),e(s)}})}onOpen(t){t.onmessage=e=>this.onPayload(e),t.onclose=e=>this.onClose(e),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?Pp(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const n=this.parseError(e),i=n.message||n.toString(),s=_h(t,i);this.events.emit("payload",s)}parseError(t,e=this.url){return f2(t,_2(e),"WS")}resetMaxListeners(){this.events.getMaxListeners()>A2&&this.events.setMaxListeners(A2)}emitError(t){const e=this.parseError(new Error(t?.message||`WebSocket connection failed for host: ${_2(this.url)}`));return this.events.emit("register_error",e),e}}var xh={exports:{}};xh.exports,function(r,t){var e=200,n="__lodash_hash_undefined__",i=1,s=2,a=9007199254740991,l="[object Arguments]",u="[object Array]",f="[object AsyncFunction]",d="[object Boolean]",w="[object Date]",m="[object Error]",b="[object Function]",E="[object GeneratorFunction]",C="[object Map]",R="[object Number]",k="[object Null]",D="[object Object]",P="[object Promise]",I="[object Proxy]",T="[object RegExp]",A="[object Set]",p="[object String]",_="[object Symbol]",M="[object Undefined]",F="[object WeakMap]",K="[object ArrayBuffer]",st="[object DataView]",lt="[object Float32Array]",S="[object Float64Array]",$="[object Int8Array]",tt="[object Int16Array]",et="[object Int32Array]",J="[object Uint8Array]",Y="[object Uint8ClampedArray]",X="[object Uint16Array]",ot="[object Uint32Array]",Ot=/[\\^$.*+?()[\]{}|]/g,ut=/^\[object .+?Constructor\]$/,Pt=/^(?:0|[1-9]\d*)$/,gt={};gt[lt]=gt[S]=gt[$]=gt[tt]=gt[et]=gt[J]=gt[Y]=gt[X]=gt[ot]=!0,gt[l]=gt[u]=gt[K]=gt[d]=gt[st]=gt[w]=gt[m]=gt[b]=gt[C]=gt[R]=gt[D]=gt[T]=gt[A]=gt[p]=gt[F]=!1;var Ct=typeof yn=="object"&&yn&&yn.Object===Object&&yn,W=typeof self=="object"&&self&&self.Object===Object&&self,G=Ct||W||Function("return this")(),j=t&&!t.nodeType&&t,y=j&&!0&&r&&!r.nodeType&&r,U=y&&y.exports===j,ht=U&&Ct.process,mt=function(){try{return ht&&ht.binding&&ht.binding("util")}catch{}}(),Lt=mt&&mt.isTypedArray;function ee(N,H){for(var it=-1,wt=N==null?0:N.length,$e=0,zt=[];++it-1}function kg(N,H){var it=this.__data__,wt=zo(it,N);return wt<0?(++this.size,it.push([N,H])):it[wt][1]=H,this}ti.prototype.clear=Ng,ti.prototype.delete=Rg,ti.prototype.get=Lg,ti.prototype.has=$g,ti.prototype.set=kg;function ss(N){var H=-1,it=N==null?0:N.length;for(this.clear();++HSr))return!1;var ke=zt.get(N);if(ke&&zt.get(H))return ke==H;var mr=-1,xn=!0,Or=it&s?new nc:void 0;for(zt.set(N,H),zt.set(H,N);++mr-1&&N%1==0&&N-1&&N%1==0&&N<=a}function bf(N){var H=typeof N;return N!=null&&(H=="object"||H=="function")}function qo(N){return N!=null&&typeof N=="object"}var vf=Lt?Ge(Lt):af;function Qg(N){return Wg(N)?sf(N):cf(N)}function Le(){return[]}function Re(){return!1}r.exports=Kg}(xh,xh.exports);var aN=xh.exports;const cN=sp(aN);function lN(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n>>0,I=new Uint8Array(P);k!==D;){for(var T=E[k],A=0,p=P-1;(T!==0||A>>0,I[p]=T%l>>>0,T=T/l>>>0;if(T!==0)throw new Error("Non-zero carry");R=A,k++}for(var _=P-R;_!==P&&I[_]===0;)_++;for(var M=u.repeat(C);_>>0,P=new Uint8Array(D);E[C];){var I=e[E.charCodeAt(C)];if(I===255)return;for(var T=0,A=D-1;(I!==0||T>>0,P[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");k=T,C++}if(E[C]!==" "){for(var p=D-k;p!==D&&P[p]===0;)p++;for(var _=new Uint8Array(R+(D-p)),M=R;p!==D;)_[M++]=P[p++];return _}}}function b(E){var C=m(E);if(C)return C;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:m,decode:b}}var uN=lN,hN=uN;const x2=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},fN=r=>new TextEncoder().encode(r),dN=r=>new TextDecoder().decode(r);class pN{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class gN{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return I2(this,t)}}class mN{constructor(t){this.decoders=t}or(t){return I2(this,t)}decode(t){const e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const I2=(r,t)=>new mN({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});class wN{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new pN(t,e,n),this.decoder=new gN(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const Ih=({name:r,prefix:t,encode:e,decode:n})=>new wN(r,t,e,n),Al=({prefix:r,name:t,alphabet:e})=>{const{encode:n,decode:i}=hN(e,t);return Ih({prefix:r,name:t,encode:n,decode:s=>x2(i(s))})},yN=(r,t,e,n)=>{const i={};for(let d=0;d=8&&(l-=8,a[f++]=255&u>>l)}if(l>=e||255&u<<8-l)throw new SyntaxError("Unexpected end of data");return a},bN=(r,t,e)=>{const n=t[t.length-1]==="=",i=(1<e;)a-=e,s+=t[i&l>>a];if(a&&(s+=t[i&l<Ih({prefix:t,name:r,encode(i){return bN(i,n,e)},decode(i){return yN(i,n,e,r)}}),vN=Ih({prefix:"\0",name:"identity",encode:r=>dN(r),decode:r=>fN(r)});var EN=Object.freeze({__proto__:null,identity:vN});const _N=jr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var AN=Object.freeze({__proto__:null,base2:_N});const xN=jr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var IN=Object.freeze({__proto__:null,base8:xN});const CN=Al({prefix:"9",name:"base10",alphabet:"0123456789"});var SN=Object.freeze({__proto__:null,base10:CN});const ON=jr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),PN=jr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var DN=Object.freeze({__proto__:null,base16:ON,base16upper:PN});const TN=jr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),NN=jr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),RN=jr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),LN=jr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$N=jr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kN=jr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),UN=jr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),BN=jr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),FN=jr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var MN=Object.freeze({__proto__:null,base32:TN,base32upper:NN,base32pad:RN,base32padupper:LN,base32hex:$N,base32hexupper:kN,base32hexpad:UN,base32hexpadupper:BN,base32z:FN});const jN=Al({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),HN=Al({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var zN=Object.freeze({__proto__:null,base36:jN,base36upper:HN});const VN=Al({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),GN=Al({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qN=Object.freeze({__proto__:null,base58btc:VN,base58flickr:GN});const WN=jr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),KN=jr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),QN=jr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),JN=jr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var YN=Object.freeze({__proto__:null,base64:WN,base64pad:KN,base64url:QN,base64urlpad:JN});const C2=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ZN=C2.reduce((r,t,e)=>(r[e]=t,r),[]),XN=C2.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function t7(r){return r.reduce((t,e)=>(t+=ZN[e],t),"")}function e7(r){const t=[];for(const e of r){const n=XN[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}const r7=Ih({prefix:"🚀",name:"base256emoji",encode:t7,decode:e7});var n7=Object.freeze({__proto__:null,base256emoji:r7}),i7=O2,S2=128,s7=127,o7=~s7,a7=Math.pow(2,31);function O2(r,t,e){t=t||[],e=e||0;for(var n=e;r>=a7;)t[e++]=r&255|S2,r/=128;for(;r&o7;)t[e++]=r&255|S2,r>>>=7;return t[e]=r|0,O2.bytes=e-n+1,t}var c7=l0,l7=128,P2=127;function l0(r,n){var e=0,n=n||0,i=0,s=n,a,l=r.length;do{if(s>=l)throw l0.bytes=0,new RangeError("Could not decode varint");a=r[s++],e+=i<28?(a&P2)<=l7);return l0.bytes=s-n,e}var u7=Math.pow(2,7),h7=Math.pow(2,14),f7=Math.pow(2,21),d7=Math.pow(2,28),p7=Math.pow(2,35),g7=Math.pow(2,42),m7=Math.pow(2,49),w7=Math.pow(2,56),y7=Math.pow(2,63),b7=function(r){return r(D2.encode(r,t,e),t),N2=r=>D2.encodingLength(r),u0=(r,t)=>{const e=t.byteLength,n=N2(r),i=n+N2(e),s=new Uint8Array(i+e);return T2(r,s,0),T2(e,s,n),s.set(t,i),new E7(r,e,t,s)};class E7{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}}const R2=({name:r,code:t,encode:e})=>new _7(r,t,e);class _7{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?u0(this.code,e):e.then(n=>u0(this.code,n))}else throw Error("Unknown type, must be binary type")}}const L2=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),A7=R2({name:"sha2-256",code:18,encode:L2("SHA-256")}),x7=R2({name:"sha2-512",code:19,encode:L2("SHA-512")});var I7=Object.freeze({__proto__:null,sha256:A7,sha512:x7});const $2=0,C7="identity",k2=x2;var S7=Object.freeze({__proto__:null,identity:{code:$2,name:C7,encode:k2,digest:r=>u0($2,k2(r))}});new TextEncoder,new TextDecoder;const U2={...EN,...AN,...IN,...SN,...DN,...MN,...zN,...qN,...YN,...n7};({...I7,...S7});function B2(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function O7(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?B2(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function F2(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}const M2=F2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),h0=F2("ascii","a",r=>{let t="a";for(let e=0;e{r=r.substring(1);const t=O7(r.length);for(let e=0;e{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=pt("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=t,this.logger=he.generateChildLogger(e,this.name)}get context(){return he.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,Jv(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Yv(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}},oR=class{constructor(t,e,n){this.core=t,this.logger=e,this.name=L7,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=_v(i);return Ev(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=aD();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),a=_v(s),l=Qp();return await gP(l,i,$7,a)},this.generateSharedKey=(i,s,a)=>{this.isInitialized();const l=this.getPrivateKey(i),u=cD(l,s);return this.setSymKey(u,a)},this.setSymKey=async(i,s)=>{this.isInitialized();const a=s||lD(i);return await this.keychain.set(a,i),a},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,a)=>{this.isInitialized();const l=Gv(a),u=hl(s);if(qv(l)){const m=l.senderPublicKey,b=l.receiverPublicKey;i=await this.generateSharedKey(m,b)}const f=this.getSymKey(i),{type:d,senderPublicKey:w}=l;return hD({type:d,symKey:f,message:u,senderPublicKey:w})},this.decode=async(i,s,a)=>{this.isInitialized();const l=pD(s,a);if(qv(l)){const u=l.receiverPublicKey,f=l.senderPublicKey;i=await this.generateSharedKey(u,f)}try{const u=this.getSymKey(i),f=fD({symKey:u,encoded:s});return Pp(f)}catch(u){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}},this.getPayloadType=i=>{const s=mh(i);return gl(s.type)},this.getPayloadSenderPublicKey=i=>{const s=mh(i);return s.senderPublicKey?en(s.senderPublicKey,rn):void 0},this.core=t,this.logger=he.generateChildLogger(e,this.name),this.keychain=n||new sR(this.core,this.logger)}get context(){return he.getLoggerContext(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(H2)}catch{t=Qp(),await this.keychain.set(H2,t)}return D7(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}},aR=class extends vS{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name=B7,this.version=F7,this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=Ra(i);let a=this.messages.get(n);return typeof a>"u"&&(a={}),typeof a[s]<"u"||(a[s]=i,this.messages.set(n,a),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),a=Ra(i);return typeof s[a]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=he.generateChildLogger(t,this.name),this.core=e}get context(){return he.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,Jv(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Yv(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}};class cR extends ES{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new Jn.EventEmitter,this.name=j7,this.queue=new Map,this.publishTimeout=_t.toMiliseconds(_t.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(n,i,s)=>{var a;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const l=s?.ttl||M7,u=Zp(s),f=s?.prompt||!1,d=s?.tag||0,w=s?.id||w2().toString(),m={topic:n,message:i,opts:{ttl:l,relay:u,prompt:f,tag:d,id:w}},b=setTimeout(()=>this.queue.set(w,m),this.publishTimeout);try{await await yl(this.rpcPublish(n,i,l,u,f,d,w),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(w),this.relayer.events.emit(Wr.publish,m)}catch(E){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(a=s?.internal)!=null&&a.throwOnFailedPublish)throw this.removeRequestFromQueue(w),E;return}finally{clearTimeout(b)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(l){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(l),l}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=t,this.logger=he.generateChildLogger(e,this.name),this.registerEventListeners()}get context(){return he.getLoggerContext(this.logger)}rpcPublish(t,e,n,i,s,a,l){var u,f,d,w;const m={method:yh(i.protocol).publish,params:{topic:t,message:e,ttl:n,prompt:s,tag:a},id:l};return nn((u=m.params)==null?void 0:u.prompt)&&((f=m.params)==null||delete f.prompt),nn((d=m.params)==null?void 0:d.tag)&&((w=m.params)==null||delete w.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:m}),this.relayer.request(m)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:e,message:n,opts:i}=t;await this.publish(e,n,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(Pa.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Wr.connection_stalled);return}this.checkQueue()}),this.relayer.on(Wr.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class lR{constructor(){this.map=new Map,this.set=(t,e)=>{const n=this.get(t);this.exists(t,e)||this.map.set(t,[...n,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const n=this.get(t);if(!this.exists(t,e))return;const i=n.filter(s=>s!==e);if(!i.length){this.map.delete(t);return}this.map.set(t,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var uR=Object.defineProperty,hR=Object.defineProperties,fR=Object.getOwnPropertyDescriptors,W2=Object.getOwnPropertySymbols,dR=Object.prototype.hasOwnProperty,pR=Object.prototype.propertyIsEnumerable,K2=(r,t,e)=>t in r?uR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Il=(r,t)=>{for(var e in t||(t={}))dR.call(t,e)&&K2(r,e,t[e]);if(W2)for(var e of W2(t))pR.call(t,e)&&K2(r,e,t[e]);return r},p0=(r,t)=>hR(r,fR(t));let gR=class extends xS{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new lR,this.events=new Jn.EventEmitter,this.name=J7,this.version=Y7,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Bs,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(n,i)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=Zp(i),a={topic:n,relay:s};this.pending.set(n,a);const l=await this.rpcSubscribe(n,s);return this.onSubscribe(l,a),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),l}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{await this.restartToComplete(),this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const a=new _t.Watch;a.start(this.pendingSubscriptionWatchLabel);const l=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(l),a.stop(this.pendingSubscriptionWatchLabel),i(!0)),a.elapsed(this.pendingSubscriptionWatchLabel)>=Z7&&(clearInterval(l),a.stop(this.pendingSubscriptionWatchLabel),s(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=he.generateChildLogger(e,this.name),this.clientId=""}get context(){return he.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,e){let n=!1;try{n=this.getSubscription(t).topic===e}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){const n=this.topicMap.get(t);await Promise.all(n.map(async i=>await this.unsubscribeById(t,i,e)))}async unsubscribeById(t,e,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:n}});try{const i=Zp(n);await this.rpcUnsubscribe(t,e,i);const s=Er("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,e,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(t,e){const n={method:yh(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await yl(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Wr.connection_stalled)}return Ra(t+this.clientId)}async rpcBatchSubscribe(t){if(!t.length)return;const e=t[0].relay,n={method:yh(e.protocol).batchSubscribe,params:{topics:t.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await yl(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Wr.connection_stalled)}}rpcUnsubscribe(t,e,n){const i={method:yh(n.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(t,e){this.setSubscription(t,p0(Il({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach(e=>{this.setSubscription(e.id,Il({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(t,e,n){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,n),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,e){this.subscriptions.has(t)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e))}addSubscription(t,e){this.subscriptions.set(t,Il({},e)),this.topicMap.set(e.topic,t),this.events.emit(Ci.created,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const e=this.subscriptions.get(t);if(!e){const{message:n}=pt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});const n=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(n.topic,t),this.events.emit(Ci.deleted,p0(Il({},n),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ci.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e"u"||!t.length)return;if(this.subscriptions.size){const{message:e}=pt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const e=await this.rpcBatchSubscribe(t);No(e)&&this.onBatchSubscribe(e.map((n,i)=>p0(Il({},t[i]),{id:n})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const t=[];this.pending.forEach(e=>{t.push(e)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(Pa.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(Wr.connect,async()=>{await this.onConnect()}),this.relayer.on(Wr.disconnect,()=>{this.onDisconnect()}),this.events.on(Ci.created,async t=>{const e=Ci.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}),this.events.on(Ci.deleted,async t=>{const e=Ci.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const e=setInterval(()=>{this.restartInProgress||(clearInterval(e),t())},this.pollingInterval)})}};var mR=Object.defineProperty,Q2=Object.getOwnPropertySymbols,wR=Object.prototype.hasOwnProperty,yR=Object.prototype.propertyIsEnumerable,J2=(r,t,e)=>t in r?mR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bR=(r,t)=>{for(var e in t||(t={}))wR.call(t,e)&&J2(r,e,t[e]);if(Q2)for(var e of Q2(t))yR.call(t,e)&&J2(r,e,t[e]);return r};let vR=class extends _S{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new Jn.EventEmitter,this.name=z7,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(n){throw this.logger.debug("Failed to Publish Request"),this.logger.error(n),n}},this.onPayloadHandler=e=>{this.onProviderPayload(e)},this.onConnectHandler=()=>{this.events.emit(Wr.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=e=>{this.logger.error(e),this.events.emit(Wr.error,e)},this.registerProviderListeners=()=>{this.provider.on(Zi.payload,this.onPayloadHandler),this.provider.on(Zi.connect,this.onConnectHandler),this.provider.on(Zi.disconnect,this.onDisconnectHandler),this.provider.on(Zi.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?he.generateChildLogger(t.logger,this.name):he.pino(he.getDefaultLoggerOptions({level:t.logger||H7})),this.messages=new aR(this.logger,t.core),this.subscriber=new gR(this,this.logger),this.publisher=new cR(this,this.logger),this.relayUrl=t?.relayUrl||V2,this.projectId=t.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${G2}...`),await this.restartTransport(G2)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},W7)}get context(){return he.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(t,e,n){this.isInitialized(),await this.publisher.publish(t,e,n),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now()})}async subscribe(t,e){var n;this.isInitialized();let i=((n=this.subscriber.topicMap.get(t))==null?void 0:n[0])||"";return i||(await Promise.all([new Promise(s=>{this.subscriber.once(Ci.created,a=>{a.topic===t&&s()})}),new Promise(async s=>{i=await this.subscriber.subscribe(t,e),s()})]),i)}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await yl(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect()}async transportOpen(t){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(e=>{if(!this.initialized)return e();this.subscriber.once(Ci.resubscribed,()=>{e()})}),new Promise(async(e,n)=>{try{await yl(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(i){n(i);return}e()})])}catch(e){this.logger.error(e);const n=e;if(!this.isConnectionStalled(n.message))throw e;this.provider.events.emit(Zi.disconnect)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(t){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=t||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await c2())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(t){return this.staleConnectionErrors.some(e=>t.includes(e))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Us(new oN(ID({sdkVersion:q7,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:e,message:n}=t;await this.messages.set(e,n)}async shouldIgnoreMessageEvent(t){const{topic:e,message:n}=t;if(!n||n.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug(`Ignoring message for non-subscribed topic ${e}`),!0;const i=this.messages.has(e,n);return i&&this.logger.debug(`Ignoring duplicate message: ${n}`),i}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),c0(t)){if(!t.method.endsWith(V7))return;const e=t.params,{topic:n,message:i,publishedAt:s}=e.data,a={topic:n,message:i,publishedAt:s};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(bR({type:"event",event:e.id},a)),this.events.emit(e.id,a),await this.acknowledgePayload(t),await this.onMessageEvent(a)}else Ah(t)&&this.events.emit(Wr.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(Wr.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const e=a0(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(Zi.payload,this.onPayloadHandler),this.provider.off(Zi.connect,this.onConnectHandler),this.provider.off(Zi.disconnect,this.onDisconnectHandler),this.provider.off(Zi.error,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(Wr.connection_stalled,()=>{this.restartTransport().catch(e=>this.logger.error(e))});let t=await c2();wT(async e=>{this.initialized&&t!==e&&(t=e,e?await this.restartTransport().catch(n=>this.logger.error(n)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(n=>this.logger.error(n))))})}onProviderDisconnect(){this.events.emit(Wr.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(t=>this.logger.error(t))},_t.toMiliseconds(G7)))}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(t=>{const e=setInterval(()=>{this.connected&&(clearInterval(e),t())},this.connectionStatusPollingInterval)});await this.restartTransport()}}};var ER=Object.defineProperty,Y2=Object.getOwnPropertySymbols,_R=Object.prototype.hasOwnProperty,AR=Object.prototype.propertyIsEnumerable,Z2=(r,t,e)=>t in r?ER(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,X2=(r,t)=>{for(var e in t||(t={}))_R.call(t,e)&&Z2(r,e,t[e]);if(Y2)for(var e of Y2(t))AR.call(t,e)&&Z2(r,e,t[e]);return r};let Sh=class extends AS{constructor(t,e,n,i=Bs,s=void 0){super(t,e,n,i),this.core=t,this.logger=e,this.name=n,this.map=new Map,this.version=K7,this.cached=[],this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(a=>{this.getKey&&a!==null&&!nn(a)?this.map.set(this.getKey(a),a):KD(a)?this.map.set(a.id,a):QD(a)&&this.map.set(a.topic,a)}),this.cached=[],this.initialized=!0)},this.set=async(a,l)=>{this.isInitialized(),this.map.has(a)?await this.update(a,l):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:a,value:l}),this.map.set(a,l),await this.persist())},this.get=a=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:a}),this.getData(a)),this.getAll=a=>(this.isInitialized(),a?this.values.filter(l=>Object.keys(a).every(u=>cN(l[u],a[u]))):this.values),this.update=async(a,l)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:a,update:l});const u=X2(X2({},this.getData(a)),l);this.map.set(a,u),await this.persist()},this.delete=async(a,l)=>{this.isInitialized(),this.map.has(a)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:a,reason:l}),this.map.delete(a),await this.persist())},this.logger=he.generateChildLogger(e,this.name),this.storagePrefix=i,this.getKey=s}get context(){return he.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const e=this.map.get(t);if(!e){const{message:n}=pt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(n),new Error(n)}return e}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:e}=pt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}},xR=class{constructor(t,e){this.core=t,this.logger=e,this.name=X7,this.version=tR,this.events=new ap,this.initialized=!1,this.storagePrefix=Bs,this.ignoredPayloadTypes=[Do],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=Qp(),i=await this.core.crypto.setSymKey(n),s=fi(_t.FIVE_MINUTES),a={protocol:z2},l={topic:i,expiry:s,relay:a,active:!1},u=BD({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:n,relay:a});return await this.pairings.set(i,l),await this.core.relayer.subscribe(i),this.core.expirer.set(i,s),{topic:i,uri:u}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:i,symKey:s,relay:a}=$D(n.uri);if(this.pairings.keys.includes(i))throw new Error(`Pairing already exists: ${i}`);if(this.core.crypto.hasKeys(i))throw new Error(`Keychain already exists: ${i}`);const l=fi(_t.FIVE_MINUTES),u={topic:i,relay:a,expiry:l,active:!1};return await this.pairings.set(i,u),await this.core.crypto.setSymKey(s,i),await this.core.relayer.subscribe(i,{relay:a}),this.core.expirer.set(i,l),n.activatePairing&&await this.activate({topic:i}),u},this.activate=async({topic:n})=>{this.isInitialized();const i=fi(_t.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:i}),this.core.expirer.set(n,i)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:a,resolve:l,reject:u}=La();this.events.once(vr("pairing_ping",s),({error:f})=>{f?u(f):l()}),await a()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:i}=n;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",Er("USER_DISCONNECTED")),await this.deletePairing(i))},this.sendRequest=async(n,i,s)=>{const a=_l(i,s),l=await this.core.crypto.encode(n,a),u=xl[i].req;return this.core.history.set(n,a),this.core.relayer.publish(n,l,u),a.id},this.sendResult=async(n,i,s)=>{const a=a0(n,s),l=await this.core.crypto.encode(i,a),u=await this.core.history.get(i,n),f=xl[u.request.method].res;await this.core.relayer.publish(i,l,f),await this.core.history.resolve(a)},this.sendError=async(n,i,s)=>{const a=_h(n,s),l=await this.core.crypto.encode(i,a),u=await this.core.history.get(i,n),f=xl[u.request.method]?xl[u.request.method].res:xl.unregistered_method.res;await this.core.relayer.publish(i,l,f),await this.core.history.resolve(a)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Er("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>ks(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:s}=n,a=(await this.core.history.get(i,s.id)).request.method;switch(a){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(a)}},this.onPairingPingRequest=async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit("pairing_ping",{id:s,topic:n})}catch(a){await this.sendError(s,n,a),this.logger.error(a)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{Yi(i)?this.events.emit(vr("pairing_ping",s),{}):di(i)&&this.events.emit(vr("pairing_ping",s),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit("pairing_delete",{id:s,topic:n})}catch(a){await this.sendError(s,n,a),this.logger.error(a)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:a}=i;try{if(this.registeredMethods.includes(a))return;const l=Er("WC_METHOD_UNSUPPORTED",a);await this.sendError(s,n,l),this.logger.error(l)}catch(l){await this.sendError(s,n,l),this.logger.error(l)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Er("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{if(!vn(n)){const{message:i}=pt("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(i)}if(!WD(n.uri)){const{message:i}=pt("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(i)}},this.isValidPing=async n=>{if(!vn(n)){const{message:s}=pt("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!vn(n)){const{message:s}=pt("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!kr(n,!1)){const{message:i}=pt("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=pt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(ks(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=pt("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=t,this.logger=he.generateChildLogger(e,this.name),this.pairings=new Sh(this.core,this.logger,this.name,this.storagePrefix)}get context(){return he.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(Wr.message,async t=>{const{topic:e,message:n}=t;if(!this.pairings.keys.includes(e)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const i=await this.core.crypto.decode(e,n);try{c0(i)?(this.core.history.set(e,i),this.onRelayEventRequest({topic:e,payload:i})):Ah(i)&&(await this.core.history.resolve(i),await this.onRelayEventResponse({topic:e,payload:i}),this.core.history.delete(e,i.id))}catch(s){this.logger.error(s)}})}registerExpirerEvents(){this.core.expirer.on(Yn.expired,async t=>{const{topic:e}=Xv(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit("pairing_expire",{topic:e}))})}},IR=class extends bS{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new Jn.EventEmitter,this.name=eR,this.version=rR,this.cached=[],this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const a={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s,expiry:fi(_t.THIRTY_DAYS)};this.records.set(a.id,a),this.events.emit(Si.created,a)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=di(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(Si.updated,i))},this.get=async(n,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),await this.getRecord(i)),this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(Si.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=he.generateChildLogger(e,this.name)}get context(){return he.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const t=[];return this.values.forEach(e=>{if(typeof e.response<"u")return;const n={topic:e.topic,request:_l(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(n)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const e=this.records.get(t);if(!e){const{message:n}=pt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Si.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:e}=pt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(Si.created,t=>{const e=Si.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t}),this.persist()}),this.events.on(Si.updated,t=>{const e=Si.updated;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t}),this.persist()}),this.events.on(Si.deleted,t=>{const e=Si.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t}),this.persist()}),this.core.heartbeat.on(Pa.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(t=>{_t.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.delete(t.topic,t.id))})}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}},CR=class extends IS{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new Jn.EventEmitter,this.name=nR,this.version=iR,this.cached=[],this.initialized=!1,this.storagePrefix=Bs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),a={target:s,expiry:i};this.expirations.set(s,a),this.checkExpiry(s,a),this.events.emit(Yn.created,{target:s,expiration:a})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{if(this.isInitialized(),this.has(n)){const i=this.formatTarget(n),s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Yn.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=he.generateChildLogger(e,this.name)}get context(){return he.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if(typeof t=="string")return CD(t);if(typeof t=="number")return SD(t);const{message:e}=pt("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(e)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Yn.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:e}=pt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const e=this.expirations.get(t);if(!e){const{message:n}=pt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(n),new Error(n)}return e}checkExpiry(t,e){const{expiry:n}=e;_t.toMiliseconds(n)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(Yn.expired,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,e)=>this.checkExpiry(e,t))}registerEventListeners(){this.core.heartbeat.on(Pa.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Yn.created,t=>{const e=Yn.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Yn.expired,t=>{const e=Yn.expired;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Yn.deleted,t=>{const e=Yn.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}}},SR=class extends CS{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.name=d0,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async n=>{if(this.verifyDisabled||wh()||!ml())return;const i=n?.verifyUrl||Ch;this.verifyUrl!==i&&this.removeIframe(),this.verifyUrl=i;try{await this.createIframe()}catch(s){this.logger.warn(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.warn(s)}if(!this.initialized){this.removeIframe(),this.verifyUrl=q2;try{await this.createIframe()}catch(s){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(s),this.verifyDisabled=!0}}},this.register=async n=>{this.initialized?this.sendPost(n.attestationId):(this.addToQueue(n.attestationId),await this.init())},this.resolve=async n=>{if(this.isDevEnv)return"";const i=n?.verifyUrl||Ch;let s="";try{s=await this.fetchAttestation(n.attestationId,i)}catch(a){this.logger.warn(`failed to resolve attestation: ${n.attestationId} from url: ${i}`),this.logger.warn(a),s=await this.fetchAttestation(n.attestationId,q2)}return s},this.fetchAttestation=async(n,i)=>{var s;this.logger.info(`resolving attestation: ${n} from url: ${i}`);const a=this.startAbortTimer(_t.ONE_SECOND*2),l=await fetch(`${i}/attestation/${n}`,{signal:this.abortController.signal});return clearTimeout(a),l.status===200?(s=await l.json())==null?void 0:s.origin:""},this.addToQueue=n=>{this.queue.push(n)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(n=>this.sendPost(n)),this.queue=[])},this.sendPost=n=>{var i;try{if(!this.iframe)return;(i=this.iframe.contentWindow)==null||i.postMessage(n,"*"),this.logger.info(`postMessage sent: ${n} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let n;const i=s=>{s.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",i),n())};await Promise.race([new Promise(s=>{if(document.getElementById(d0))return s();window.addEventListener("message",i);const a=document.createElement("iframe");a.id=d0,a.src=`${this.verifyUrl}/${this.projectId}`,a.style.display="none",document.body.append(a),this.iframe=a,n=s}),new Promise((s,a)=>setTimeout(()=>{window.removeEventListener("message",i),a("verify iframe load timeout")},_t.toMiliseconds(_t.FIVE_SECONDS)))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.logger=he.generateChildLogger(e,this.name),this.verifyUrl=Ch,this.abortController=new AbortController,this.isDevEnv=Jp()&&Qn.env.IS_VITEST}get context(){return he.getLoggerContext(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),_t.toMiliseconds(t))}};var OR=Object.defineProperty,tE=Object.getOwnPropertySymbols,PR=Object.prototype.hasOwnProperty,DR=Object.prototype.propertyIsEnumerable,eE=(r,t,e)=>t in r?OR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rE=(r,t)=>{for(var e in t||(t={}))PR.call(t,e)&&eE(r,e,t[e]);if(tE)for(var e of tE(t))DR.call(t,e)&&eE(r,e,t[e]);return r};const TR=class $A extends yS{constructor(t){super(t),this.protocol=j2,this.version=T7,this.name=f0,this.events=new Jn.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=t?.projectId,this.relayUrl=t?.relayUrl||V2;const e=typeof t?.logger<"u"&&typeof t?.logger!="string"?t.logger:he.pino(he.getDefaultLoggerOptions({level:t?.logger||N7.logger}));this.logger=he.generateChildLogger(e,this.name),this.heartbeat=new Pa.HeartBeat,this.crypto=new oR(this,this.logger,t?.keychain),this.history=new IR(this,this.logger),this.expirer=new CR(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new ZI(rE(rE({},R7),t?.storageOptions)),this.relayer=new vR({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new xR(this,this.logger),this.verify=new SR(this.projectId||"",this.logger)}static async init(t){const e=new $A(t);await e.initialize();const n=await e.crypto.getClientId();return await e.storage.setItem(Q7,n),e}get context(){return he.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}},nE="wc",iE=2,sE="client",g0=`${nE}@${iE}:${sE}:`,m0={name:sE,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},oE="WALLETCONNECT_DEEPLINK_CHOICE",NR="proposal",aE="Proposal expired",RR="session",Oh=_t.SEVEN_DAYS,LR="engine",Cl={wc_sessionPropose:{req:{ttl:_t.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:_t.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:_t.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:_t.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:_t.ONE_DAY,prompt:!1,tag:1104},res:{ttl:_t.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:_t.ONE_DAY,prompt:!1,tag:1106},res:{ttl:_t.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:_t.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:_t.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:_t.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:_t.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:_t.ONE_DAY,prompt:!1,tag:1112},res:{ttl:_t.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:_t.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:_t.THIRTY_SECONDS,prompt:!1,tag:1115}}},w0={min:_t.FIVE_MINUTES,max:_t.SEVEN_DAYS},Xi={idle:"IDLE",active:"ACTIVE"},$R="request",kR=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var UR=Object.defineProperty,BR=Object.defineProperties,FR=Object.getOwnPropertyDescriptors,cE=Object.getOwnPropertySymbols,MR=Object.prototype.hasOwnProperty,jR=Object.prototype.propertyIsEnumerable,lE=(r,t,e)=>t in r?UR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,En=(r,t)=>{for(var e in t||(t={}))MR.call(t,e)&&lE(r,e,t[e]);if(cE)for(var e of cE(t))jR.call(t,e)&&lE(r,e,t[e]);return r},Sl=(r,t)=>BR(r,FR(t));class HR extends OS{constructor(t){super(t),this.name=LR,this.events=new ap,this.initialized=!1,this.ignoredPayloadTypes=[Do],this.requestQueue={state:Xi.idle,queue:[]},this.sessionRequestQueue={state:Xi.idle,queue:[]},this.requestQueueDelay=_t.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Cl)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},_t.toMiliseconds(this.requestQueueDelay)))},this.connect=async e=>{await this.isInitialized();const n=Sl(En({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:a,sessionProperties:l,relays:u}=n;let f=i,d,w=!1;if(f&&(w=this.client.core.pairing.pairings.get(f).active),!f||!w){const{topic:P,uri:I}=await this.client.core.pairing.create();f=P,d=I}const m=await this.client.core.crypto.generateKeyPair(),b=En({requiredNamespaces:s,optionalNamespaces:a,relays:u??[{protocol:z2}],proposer:{publicKey:m,metadata:this.client.metadata}},l&&{sessionProperties:l}),{reject:E,resolve:C,done:R}=La(_t.FIVE_MINUTES,aE);if(this.events.once(vr("session_connect"),async({error:P,session:I})=>{if(P)E(P);else if(I){I.self.publicKey=m;const T=Sl(En({},I),{requiredNamespaces:I.requiredNamespaces,optionalNamespaces:I.optionalNamespaces});await this.client.session.set(I.topic,T),await this.setExpiry(I.topic,I.expiry),f&&await this.client.core.pairing.updateMetadata({topic:f,metadata:I.peer.metadata}),C(T)}}),!f){const{message:P}=pt("NO_MATCHING_KEY",`connect() pairing topic: ${f}`);throw new Error(P)}const k=await this.sendRequest({topic:f,method:"wc_sessionPropose",params:b}),D=fi(_t.FIVE_MINUTES);return await this.setProposal(k,En({id:k,expiry:D},b)),{uri:d,approval:R}},this.pair=async e=>(await this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{await this.isInitialized(),await this.isValidApprove(e);const{id:n,relayProtocol:i,namespaces:s,sessionProperties:a}=e,l=this.client.proposal.get(n);let{pairingTopic:u,proposer:f,requiredNamespaces:d,optionalNamespaces:w}=l;u=u||"",ka(d)||(d=HD(s,"approve()"));const m=await this.client.core.crypto.generateKeyPair(),b=f.publicKey,E=await this.client.core.crypto.generateSharedKey(m,b);u&&n&&(await this.client.core.pairing.updateMetadata({topic:u,metadata:f.metadata}),await this.sendResult({id:n,topic:u,result:{relay:{protocol:i??"irn"},responderPublicKey:m}}),await this.client.proposal.delete(n,Er("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:u}));const C=En({relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:d,optionalNamespaces:w,pairingTopic:u,controller:{publicKey:m,metadata:this.client.metadata},expiry:fi(Oh)},a&&{sessionProperties:a});await this.client.core.relayer.subscribe(E),await this.sendRequest({topic:E,method:"wc_sessionSettle",params:C,throwOnFailedPublish:!0});const R=Sl(En({},C),{topic:E,pairingTopic:u,acknowledged:!1,self:C.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:m});return await this.client.session.set(E,R),await this.setExpiry(E,fi(Oh)),{topic:E,acknowledged:()=>new Promise(k=>setTimeout(()=>k(this.client.session.get(E)),500))}},this.reject=async e=>{await this.isInitialized(),await this.isValidReject(e);const{id:n,reason:i}=e,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,Er("USER_DISCONNECTED")))},this.update=async e=>{await this.isInitialized(),await this.isValidUpdate(e);const{topic:n,namespaces:i}=e,s=await this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:i}}),{done:a,resolve:l,reject:u}=La();return this.events.once(vr("session_update",s),({error:f})=>{f?u(f):l()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:a}},this.extend=async e=>{await this.isInitialized(),await this.isValidExtend(e);const{topic:n}=e,i=await this.sendRequest({topic:n,method:"wc_sessionExtend",params:{}}),{done:s,resolve:a,reject:l}=La();return this.events.once(vr("session_extend",i),({error:u})=>{u?l(u):a()}),await this.setExpiry(n,fi(Oh)),{acknowledged:s}},this.request=async e=>{await this.isInitialized(),await this.isValidRequest(e);const{chainId:n,request:i,topic:s,expiry:a}=e,l=o0(),{done:u,resolve:f,reject:d}=La(a);return this.events.once(vr("session_request",l),({error:w,result:m})=>{w?d(w):f(m)}),await Promise.all([new Promise(async w=>{await this.sendRequest({clientRpcId:l,topic:s,method:"wc_sessionRequest",params:{request:i,chainId:n},expiry:a,throwOnFailedPublish:!0}).catch(m=>d(m)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:n,id:l}),w()}),new Promise(async w=>{const m=await this.client.core.storage.getItem(oE);OD({id:l,topic:s,wcDeepLink:m}),w()}),u()]).then(w=>w[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:n,response:i}=e,{id:s}=i;Yi(i)?await this.sendResult({id:s,topic:n,result:i.result,throwOnFailedPublish:!0}):di(i)&&await this.sendError(s,n,i.error),this.cleanupAfterResponse(e)},this.ping=async e=>{await this.isInitialized(),await this.isValidPing(e);const{topic:n}=e;if(this.client.session.keys.includes(n)){const i=await this.sendRequest({topic:n,method:"wc_sessionPing",params:{}}),{done:s,resolve:a,reject:l}=La();this.events.once(vr("session_ping",i),({error:u})=>{u?l(u):a()}),await s()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:n,event:i,chainId:s}=e;await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:i,chainId:s}})},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:n}=e;this.client.session.keys.includes(n)?(await this.sendRequest({topic:n,method:"wc_sessionDelete",params:Er("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(n)):await this.client.core.pairing.disconnect({topic:n})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(n=>GD(n,e))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const n=this.client.core.pairing.pairings.get(e.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(s=>{var a,l;return((a=s.peerMetadata)==null?void 0:a.url)&&((l=s.peerMetadata)==null?void 0:l.url)===e.peer.metadata.url&&s.topic&&s.topic!==n.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async(e,n)=>{const{self:i}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,Er("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(i.publicKey)&&await this.client.core.crypto.deleteKeyPair(i.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),n||this.client.core.expirer.del(e),this.client.core.storage.removeItem(oE).catch(s=>this.client.logger.warn(s))},this.deleteProposal=async(e,n)=>{await Promise.all([this.client.proposal.delete(e,Er("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,n,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,n),i?Promise.resolve():this.client.core.expirer.del(e)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==e),i&&(this.sessionRequestQueue.state=Xi.idle)},this.setExpiry=async(e,n)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:n}),this.client.core.expirer.set(e,n)},this.setProposal=async(e,n)=>{await this.client.proposal.set(e,n),this.client.core.expirer.set(e,n.expiry)},this.setPendingSessionRequest=async e=>{const n=Cl.wc_sessionRequest.req.ttl,{id:i,topic:s,params:a}=e;await this.client.pendingRequest.set(i,{id:i,topic:s,params:a}),n&&this.client.core.expirer.set(i,fi(n))},this.sendRequest=async e=>{const{topic:n,method:i,params:s,expiry:a,relayRpcId:l,clientRpcId:u,throwOnFailedPublish:f}=e,d=_l(i,s,u);if(ml()&&kR.includes(i)){const b=Ra(JSON.stringify(d));this.client.core.verify.register({attestationId:b})}const w=await this.client.core.crypto.encode(n,d),m=Cl[i].req;return a&&(m.ttl=a),l&&(m.id=l),this.client.core.history.set(n,d),f?(m.internal=Sl(En({},m.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,w,m)):this.client.core.relayer.publish(n,w,m).catch(b=>this.client.logger.error(b)),d.id},this.sendResult=async e=>{const{id:n,topic:i,result:s,throwOnFailedPublish:a}=e,l=a0(n,s),u=await this.client.core.crypto.encode(i,l),f=await this.client.core.history.get(i,n),d=Cl[f.request.method].res;a?(d.internal=Sl(En({},d.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,u,d)):this.client.core.relayer.publish(i,u,d).catch(w=>this.client.logger.error(w)),await this.client.core.history.resolve(l)},this.sendError=async(e,n,i)=>{const s=_h(e,i),a=await this.client.core.crypto.encode(n,s),l=await this.client.core.history.get(n,e),u=Cl[l.request.method].res;this.client.core.relayer.publish(n,a,u),await this.client.core.history.resolve(s)},this.cleanup=async()=>{const e=[],n=[];this.client.session.getAll().forEach(i=>{ks(i.expiry)&&e.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{ks(i.expiry)&&n.push(i.id)}),await Promise.all([...e.map(i=>this.deleteSession(i)),...n.map(i=>this.deleteProposal(i))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Xi.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Xi.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(n=>setTimeout(n,300))}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=Xi.idle},this.processRequest=e=>{const{topic:n,payload:i}=e,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async e=>{const{topic:n,payload:i}=e,s=(await this.client.core.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:n}=e,{message:i}=pt("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)},this.onSessionProposeRequest=async(e,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(En({},n.params));const a=fi(_t.FIVE_MINUTES),l=En({id:s,pairingTopic:e,expiry:a},i);await this.setProposal(s,l);const u=Ra(JSON.stringify(n)),f=await this.getVerifyContext(u,l.proposer.metadata);this.client.events.emit("session_proposal",{id:s,params:l,verifyContext:f})}catch(a){await this.sendError(s,e,a),this.client.logger.error(a)}},this.onSessionProposeResponse=async(e,n)=>{const{id:i}=n;if(Yi(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const a=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const l=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const u=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const f=await this.client.core.crypto.generateSharedKey(l,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:f});const d=await this.client.core.relayer.subscribe(f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:d}),await this.client.core.pairing.activate({topic:e})}else di(n)&&(await this.client.proposal.delete(i,Er("USER_DISCONNECTED")),this.events.emit(vr("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(e,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:a,controller:l,expiry:u,namespaces:f,requiredNamespaces:d,optionalNamespaces:w,sessionProperties:m,pairingTopic:b}=n.params,E=En({topic:e,relay:a,expiry:u,namespaces:f,acknowledged:!0,pairingTopic:b,requiredNamespaces:d,optionalNamespaces:w,controller:l.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:l.publicKey,metadata:l.metadata}},m&&{sessionProperties:m});await this.sendResult({id:n.id,topic:e,result:!0}),this.events.emit(vr("session_connect"),{session:E}),this.cleanupDuplicatePairings(E)}catch(a){await this.sendError(i,e,a),this.client.logger.error(a)}},this.onSessionSettleResponse=async(e,n)=>{const{id:i}=n;Yi(n)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(vr("session_approve",i),{})):di(n)&&(await this.client.session.delete(e,Er("USER_DISCONNECTED")),this.events.emit(vr("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(e,n)=>{const{params:i,id:s}=n;try{const a=`${e}_session_update`,l=Eh.get(a);if(l&&this.isRequestOutOfSync(l,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidUpdate(En({topic:e},i)),await this.client.session.update(e,{namespaces:i.namespaces}),await this.sendResult({id:s,topic:e,result:!0}),this.client.events.emit("session_update",{id:s,topic:e,params:i}),Eh.set(a,s)}catch(a){await this.sendError(s,e,a),this.client.logger.error(a)}},this.isRequestOutOfSync=(e,n)=>parseInt(n.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,n)=>{const{id:i}=n;Yi(n)?this.events.emit(vr("session_update",i),{}):di(n)&&this.events.emit(vr("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(e,n)=>{const{id:i}=n;try{this.isValidExtend({topic:e}),await this.setExpiry(e,fi(Oh)),await this.sendResult({id:i,topic:e,result:!0}),this.client.events.emit("session_extend",{id:i,topic:e})}catch(s){await this.sendError(i,e,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(e,n)=>{const{id:i}=n;Yi(n)?this.events.emit(vr("session_extend",i),{}):di(n)&&this.events.emit(vr("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(e,n)=>{const{id:i}=n;try{this.isValidPing({topic:e}),await this.sendResult({id:i,topic:e,result:!0}),this.client.events.emit("session_ping",{id:i,topic:e})}catch(s){await this.sendError(i,e,s),this.client.logger.error(s)}},this.onSessionPingResponse=(e,n)=>{const{id:i}=n;setTimeout(()=>{Yi(n)?this.events.emit(vr("session_ping",i),{}):di(n)&&this.events.emit(vr("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(e,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:e,reason:n.params}),await Promise.all([new Promise(s=>{this.client.core.relayer.once(Wr.publish,async()=>{s(await this.deleteSession(e))})}),this.sendResult({id:i,topic:e,result:!0})]),this.client.events.emit("session_delete",{id:i,topic:e})}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async(e,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(En({topic:e},s)),await this.setPendingSessionRequest({id:i,topic:e,params:s}),this.addSessionRequestToSessionRequestQueue({id:i,topic:e,params:s}),await this.processSessionRequestQueue()}catch(a){await this.sendError(i,e,a),this.client.logger.error(a)}},this.onSessionRequestResponse=(e,n)=>{const{id:i}=n;Yi(n)?this.events.emit(vr("session_request",i),{result:n.result}):di(n)&&this.events.emit(vr("session_request",i),{error:n.error})},this.onSessionEventRequest=async(e,n)=>{const{id:i,params:s}=n;try{const a=`${e}_session_event_${s.event.name}`,l=Eh.get(a);if(l&&this.isRequestOutOfSync(l,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(En({topic:e},s)),this.client.events.emit("session_event",{id:i,topic:e,params:s}),Eh.set(a,i)}catch(a){await this.sendError(i,e,a),this.client.logger.error(a)}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Xi.idle,this.processSessionRequestQueue()},_t.toMiliseconds(this.requestQueueDelay))},this.processSessionRequestQueue=async()=>{if(this.sessionRequestQueue.state===Xi.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{const{id:n,topic:i,params:s}=e,a=Ra(JSON.stringify(_l("wc_sessionRequest",s,n))),l=this.client.session.get(i),u=await this.getVerifyContext(a,l.peer.metadata);this.sessionRequestQueue.state=Xi.active,this.client.events.emit("session_request",{id:n,topic:i,params:s,verifyContext:u})}catch(n){this.client.logger.error(n)}},this.isValidConnect=async e=>{if(!vn(e)){const{message:u}=pt("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(u)}const{pairingTopic:n,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:a,relays:l}=e;if(nn(n)||await this.isValidPairingTopic(n),!nT(l,!0)){const{message:u}=pt("MISSING_OR_INVALID",`connect() relays: ${l}`);throw new Error(u)}!nn(i)&&ka(i)!==0&&this.validateNamespaces(i,"requiredNamespaces"),!nn(s)&&ka(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),nn(a)||this.validateSessionProps(a,"sessionProperties")},this.validateNamespaces=(e,n)=>{const i=rT(e,"connect()",n);if(i)throw new Error(i.message)},this.isValidApprove=async e=>{if(!vn(e))throw new Error(pt("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:n,namespaces:i,relayProtocol:s,sessionProperties:a}=e;await this.isValidProposalId(n);const l=this.client.proposal.get(n),u=vh(i,"approve()");if(u)throw new Error(u.message);const f=o2(l.requiredNamespaces,i,"approve()");if(f)throw new Error(f.message);if(!kr(s,!0)){const{message:d}=pt("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(d)}nn(a)||this.validateSessionProps(a,"sessionProperties")},this.isValidReject=async e=>{if(!vn(e)){const{message:s}=pt("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(s)}const{id:n,reason:i}=e;if(await this.isValidProposalId(n),!sT(i)){const{message:s}=pt("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=e=>{if(!vn(e)){const{message:f}=pt("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(f)}const{relay:n,controller:i,namespaces:s,expiry:a}=e;if(!i2(n)){const{message:f}=pt("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const l=JD(i,"onSessionSettleRequest()");if(l)throw new Error(l.message);const u=vh(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(ks(a)){const{message:f}=pt("EXPIRED","onSessionSettleRequest()");throw new Error(f)}},this.isValidUpdate=async e=>{if(!vn(e)){const{message:u}=pt("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(u)}const{topic:n,namespaces:i}=e;await this.isValidSessionTopic(n);const s=this.client.session.get(n),a=vh(i,"update()");if(a)throw new Error(a.message);const l=o2(s.requiredNamespaces,i,"update()");if(l)throw new Error(l.message)},this.isValidExtend=async e=>{if(!vn(e)){const{message:i}=pt("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(i)}const{topic:n}=e;await this.isValidSessionTopic(n)},this.isValidRequest=async e=>{if(!vn(e)){const{message:u}=pt("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(u)}const{topic:n,request:i,chainId:s,expiry:a}=e;await this.isValidSessionTopic(n);const{namespaces:l}=this.client.session.get(n);if(!s2(l,s)){const{message:u}=pt("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!oT(i)){const{message:u}=pt("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(u)}if(!lT(l,s,i.method)){const{message:u}=pt("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(u)}if(a&&!dT(a,w0)){const{message:u}=pt("MISSING_OR_INVALID",`request() expiry: ${a}. Expiry must be a number (in seconds) between ${w0.min} and ${w0.max}`);throw new Error(u)}},this.isValidRespond=async e=>{if(!vn(e)){const{message:s}=pt("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(s)}const{topic:n,response:i}=e;if(await this.isValidSessionTopic(n),!aT(i)){const{message:s}=pt("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async e=>{if(!vn(e)){const{message:i}=pt("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(i)}const{topic:n}=e;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async e=>{if(!vn(e)){const{message:l}=pt("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(l)}const{topic:n,event:i,chainId:s}=e;await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!s2(a,s)){const{message:l}=pt("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(l)}if(!cT(i)){const{message:l}=pt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(l)}if(!uT(a,s,i.name)){const{message:l}=pt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(l)}},this.isValidDisconnect=async e=>{if(!vn(e)){const{message:i}=pt("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(i)}const{topic:n}=e;await this.isValidSessionOrPairingTopic(n)},this.getVerifyContext=async(e,n)=>{const i={verified:{verifyUrl:n.verifyUrl||Ch,validation:"UNKNOWN",origin:n.url||""}};try{const s=await this.client.core.verify.resolve({attestationId:e,verifyUrl:n.verifyUrl});s&&(i.verified.origin=s,i.verified.validation=s===new URL(n.url).origin?"VALID":"INVALID")}catch(s){this.client.logger.error(s)}return this.client.logger.info(`Verify context: ${JSON.stringify(i)}`),i},this.validateSessionProps=(e,n)=>{Object.values(e).forEach(i=>{if(!kr(i,!1)){const{message:s}=pt("MISSING_OR_INVALID",`${n} must be in Record format. Received: ${JSON.stringify(i)}`);throw new Error(s)}})}}async isInitialized(){if(!this.initialized){const{message:t}=pt("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Wr.message,async t=>{const{topic:e,message:n}=t;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const i=await this.client.core.crypto.decode(e,n);try{c0(i)?(this.client.core.history.set(e,i),this.onRelayEventRequest({topic:e,payload:i})):Ah(i)?(await this.client.core.history.resolve(i),await this.onRelayEventResponse({topic:e,payload:i}),this.client.core.history.delete(e,i.id)):this.onRelayEventUnknownPayload({topic:e,payload:i})}catch(s){this.client.logger.error(s)}})}registerExpirerEvents(){this.client.core.expirer.on(Yn.expired,async t=>{const{topic:e,id:n}=Xv(t.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,pt("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession(e,!0),this.client.events.emit("session_expire",{topic:e})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}isValidPairingTopic(t){if(!kr(t,!1)){const{message:e}=pt("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=pt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(ks(this.client.core.pairing.pairings.get(t).expiry)){const{message:e}=pt("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}}async isValidSessionTopic(t){if(!kr(t,!1)){const{message:e}=pt("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(e)}if(!this.client.session.keys.includes(t)){const{message:e}=pt("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(e)}if(ks(this.client.session.get(t).expiry)){await this.deleteSession(t);const{message:e}=pt("EXPIRED",`session topic: ${t}`);throw new Error(e)}}async isValidSessionOrPairingTopic(t){if(this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(kr(t,!1)){const{message:e}=pt("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(e)}else{const{message:e}=pt("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(e)}}async isValidProposalId(t){if(!iT(t)){const{message:e}=pt("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(e)}if(!this.client.proposal.keys.includes(t)){const{message:e}=pt("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(e)}if(ks(this.client.proposal.get(t).expiry)){await this.deleteProposal(t);const{message:e}=pt("EXPIRED",`proposal id: ${t}`);throw new Error(e)}}}class zR extends Sh{constructor(t,e){super(t,e,NR,g0),this.core=t,this.logger=e}}class VR extends Sh{constructor(t,e){super(t,e,RR,g0),this.core=t,this.logger=e}}class GR extends Sh{constructor(t,e){super(t,e,$R,g0,n=>n.id),this.core=t,this.logger=e}}let qR=class kA extends SS{constructor(t){super(t),this.protocol=nE,this.version=iE,this.name=m0.name,this.events=new Jn.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=t?.name||m0.name,this.metadata=t?.metadata||ED();const e=typeof t?.logger<"u"&&typeof t?.logger!="string"?t.logger:he.pino(he.getDefaultLoggerOptions({level:t?.logger||m0.logger}));this.core=t?.core||new TR(t),this.logger=he.generateChildLogger(e,this.name),this.session=new VR(this.core,this.logger),this.proposal=new zR(this.core,this.logger),this.pendingRequest=new GR(this.core,this.logger),this.engine=new HR(this)}static async init(t){const e=new kA(t);return await e.initialize(),e}get context(){return he.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}};var y0={exports:{}};(function(r,t){var e=typeof self<"u"?self:yn,n=function(){function s(){this.fetch=!1,this.DOMException=e.DOMException}return s.prototype=e,new s}();(function(s){(function(a){var l={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function u(S){return S&&DataView.prototype.isPrototypeOf(S)}if(l.arrayBuffer)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(S){return S&&f.indexOf(Object.prototype.toString.call(S))>-1};function w(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(S))throw new TypeError("Invalid character in header field name");return S.toLowerCase()}function m(S){return typeof S!="string"&&(S=String(S)),S}function b(S){var $={next:function(){var tt=S.shift();return{done:tt===void 0,value:tt}}};return l.iterable&&($[Symbol.iterator]=function(){return $}),$}function E(S){this.map={},S instanceof E?S.forEach(function($,tt){this.append(tt,$)},this):Array.isArray(S)?S.forEach(function($){this.append($[0],$[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function($){this.append($,S[$])},this)}E.prototype.append=function(S,$){S=w(S),$=m($);var tt=this.map[S];this.map[S]=tt?tt+", "+$:$},E.prototype.delete=function(S){delete this.map[w(S)]},E.prototype.get=function(S){return S=w(S),this.has(S)?this.map[S]:null},E.prototype.has=function(S){return this.map.hasOwnProperty(w(S))},E.prototype.set=function(S,$){this.map[w(S)]=m($)},E.prototype.forEach=function(S,$){for(var tt in this.map)this.map.hasOwnProperty(tt)&&S.call($,this.map[tt],tt,this)},E.prototype.keys=function(){var S=[];return this.forEach(function($,tt){S.push(tt)}),b(S)},E.prototype.values=function(){var S=[];return this.forEach(function($){S.push($)}),b(S)},E.prototype.entries=function(){var S=[];return this.forEach(function($,tt){S.push([tt,$])}),b(S)},l.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function C(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function R(S){return new Promise(function($,tt){S.onload=function(){$(S.result)},S.onerror=function(){tt(S.error)}})}function k(S){var $=new FileReader,tt=R($);return $.readAsArrayBuffer(S),tt}function D(S){var $=new FileReader,tt=R($);return $.readAsText(S),tt}function P(S){for(var $=new Uint8Array(S),tt=new Array($.length),et=0;et<$.length;et++)tt[et]=String.fromCharCode($[et]);return tt.join("")}function I(S){if(S.slice)return S.slice(0);var $=new Uint8Array(S.byteLength);return $.set(new Uint8Array(S)),$.buffer}function T(){return this.bodyUsed=!1,this._initBody=function(S){this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:l.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:l.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:l.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():l.arrayBuffer&&l.blob&&u(S)?(this._bodyArrayBuffer=I(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):l.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||d(S))?this._bodyArrayBuffer=I(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):l.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},l.blob&&(this.blob=function(){var S=C(this);if(S)return S;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?C(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(k)}),this.text=function(){var S=C(this);if(S)return S;if(this._bodyBlob)return D(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(P(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},l.formData&&(this.formData=function(){return this.text().then(M)}),this.json=function(){return this.text().then(JSON.parse)},this}var A=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function p(S){var $=S.toUpperCase();return A.indexOf($)>-1?$:S}function _(S,$){$=$||{};var tt=$.body;if(S instanceof _){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,$.headers||(this.headers=new E(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!tt&&S._bodyInit!=null&&(tt=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=$.credentials||this.credentials||"same-origin",($.headers||!this.headers)&&(this.headers=new E($.headers)),this.method=p($.method||this.method||"GET"),this.mode=$.mode||this.mode||null,this.signal=$.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&tt)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(tt)}_.prototype.clone=function(){return new _(this,{body:this._bodyInit})};function M(S){var $=new FormData;return S.trim().split("&").forEach(function(tt){if(tt){var et=tt.split("="),J=et.shift().replace(/\+/g," "),Y=et.join("=").replace(/\+/g," ");$.append(decodeURIComponent(J),decodeURIComponent(Y))}}),$}function F(S){var $=new E,tt=S.replace(/\r?\n[\t ]+/g," ");return tt.split(/\r?\n/).forEach(function(et){var J=et.split(":"),Y=J.shift().trim();if(Y){var X=J.join(":").trim();$.append(Y,X)}}),$}T.call(_.prototype);function K(S,$){$||($={}),this.type="default",this.status=$.status===void 0?200:$.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in $?$.statusText:"OK",this.headers=new E($.headers),this.url=$.url||"",this._initBody(S)}T.call(K.prototype),K.prototype.clone=function(){return new K(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},K.error=function(){var S=new K(null,{status:0,statusText:""});return S.type="error",S};var st=[301,302,303,307,308];K.redirect=function(S,$){if(st.indexOf($)===-1)throw new RangeError("Invalid status code");return new K(null,{status:$,headers:{location:S}})},a.DOMException=s.DOMException;try{new a.DOMException}catch{a.DOMException=function($,tt){this.message=$,this.name=tt;var et=Error($);this.stack=et.stack},a.DOMException.prototype=Object.create(Error.prototype),a.DOMException.prototype.constructor=a.DOMException}function lt(S,$){return new Promise(function(tt,et){var J=new _(S,$);if(J.signal&&J.signal.aborted)return et(new a.DOMException("Aborted","AbortError"));var Y=new XMLHttpRequest;function X(){Y.abort()}Y.onload=function(){var ot={status:Y.status,statusText:Y.statusText,headers:F(Y.getAllResponseHeaders()||"")};ot.url="responseURL"in Y?Y.responseURL:ot.headers.get("X-Request-URL");var Ot="response"in Y?Y.response:Y.responseText;tt(new K(Ot,ot))},Y.onerror=function(){et(new TypeError("Network request failed"))},Y.ontimeout=function(){et(new TypeError("Network request failed"))},Y.onabort=function(){et(new a.DOMException("Aborted","AbortError"))},Y.open(J.method,J.url,!0),J.credentials==="include"?Y.withCredentials=!0:J.credentials==="omit"&&(Y.withCredentials=!1),"responseType"in Y&&l.blob&&(Y.responseType="blob"),J.headers.forEach(function(ot,Ot){Y.setRequestHeader(Ot,ot)}),J.signal&&(J.signal.addEventListener("abort",X),Y.onreadystatechange=function(){Y.readyState===4&&J.signal.removeEventListener("abort",X)}),Y.send(typeof J._bodyInit>"u"?null:J._bodyInit)})}return lt.polyfill=!0,s.fetch||(s.fetch=lt,s.Headers=E,s.Request=_,s.Response=K),a.Headers=E,a.Request=_,a.Response=K,a.fetch=lt,Object.defineProperty(a,"__esModule",{value:!0}),a})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;t=i.fetch,t.default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,r.exports=t})(y0,y0.exports);var WR=y0.exports;const uE=sp(WR),hE={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},fE=10;class Ro{constructor(t,e=!1){if(this.url=t,this.disableProviderPing=e,this.events=new Jn.EventEmitter,this.isAvailable=!1,this.registering=!1,!b2(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t,e){this.isAvailable||await this.register();try{const n=hl(t),s=await(await uE(this.url,Object.assign(Object.assign({},hE),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(t.id,n)}}async register(t=this.url){if(!b2(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const e=hl({id:1,jsonrpc:"2.0",method:"test",params:[]});await uE(t,Object.assign(Object.assign({},hE),{body:e}))}this.onOpen()}catch(e){const n=this.parseError(e);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?Pp(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const n=this.parseError(e),i=n.message||n.toString(),s=_h(t,i);this.events.emit("payload",s)}parseError(t,e=this.url){return f2(t,e,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>fE&&this.events.setMaxListeners(fE)}}const dE="error",KR="wss://relay.walletconnect.com",QR="wc",JR="universal_provider",pE=`${QR}@2:${JR}:`,YR="https://rpc.walletconnect.com/v1",Fs={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Ol=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Te<"u"?Te:typeof self<"u"?self:{},b0={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */(function(r,t){(function(){var e,n="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",l="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",f=500,d="__lodash_placeholder__",w=1,m=2,b=4,E=1,C=2,R=1,k=2,D=4,P=8,I=16,T=32,A=64,p=128,_=256,M=512,F=30,K="...",st=800,lt=16,S=1,$=2,tt=3,et=1/0,J=9007199254740991,Y=17976931348623157e292,X=0/0,ot=4294967295,Ot=ot-1,ut=ot>>>1,Pt=[["ary",p],["bind",R],["bindKey",k],["curry",P],["curryRight",I],["flip",M],["partial",T],["partialRight",A],["rearg",_]],gt="[object Arguments]",Ct="[object Array]",W="[object AsyncFunction]",G="[object Boolean]",j="[object Date]",y="[object DOMException]",U="[object Error]",ht="[object Function]",mt="[object GeneratorFunction]",Lt="[object Map]",ee="[object Number]",oe="[object Null]",Jt="[object Object]",Ve="[object Promise]",Ge="[object Proxy]",Zt="[object RegExp]",$t="[object Set]",qt="[object String]",Wt="[object Symbol]",Xt="[object Undefined]",Bt="[object WeakMap]",Kt="[object WeakSet]",Rt="[object ArrayBuffer]",Mt="[object DataView]",re="[object Float32Array]",kt="[object Float64Array]",ae="[object Int8Array]",le="[object Int16Array]",ye="[object Int32Array]",be="[object Uint8Array]",de="[object Uint8ClampedArray]",on="[object Uint16Array]",An="[object Uint32Array]",Di=/\b__p \+= '';/g,an=/\b(__p \+=) '' \+/g,is=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ks=/&(?:amp|lt|gt|quot|#39);/g,Ho=/[&<>"']/g,sr=RegExp(Ks.source),qe=RegExp(Ho.source),or=/<%-([\s\S]+?)%>/g,ar=/<%([\s\S]+?)%>/g,tr=/<%=([\s\S]+?)%>/g,We=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_r=/^\w*$/,Ar=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cr=/[\\^$.*+?()[\]{}|]/g,xr=RegExp(cr.source),lr=/^\s+/,gr=/\s/,ur=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Me=/\{\n\/\* \[wrapped with (.+)\] \*/,Ir=/,? & /,Cr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Pg=/[()=,{}\[\]\/\s]/,Dg=/\\(\\)?/g,Tg=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ti=/\w*$/,Ng=/^[-+]0x[0-9a-f]+$/i,Rg=/^0b[01]+$/i,Lg=/^\[object .+?Constructor\]$/,$g=/^0o[0-7]+$/i,kg=/^(?:0|[1-9]\d*)$/,ss=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ec=/($^)/,Ug=/['\n\r\u2028\u2029\\]/g,rc="\\ud800-\\udfff",Bg="\\u0300-\\u036f",Fg="\\ufe20-\\ufe2f",nc="\\u20d0-\\u20ff",ef=Bg+Fg+nc,rf="\\u2700-\\u27bf",pi="a-z\\xdf-\\xf6\\xf8-\\xff",Mg="\\xac\\xb1\\xd7\\xf7",jg="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Hg="\\u2000-\\u206f",zg=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",nf="A-Z\\xc0-\\xd6\\xd8-\\xde",sf="\\ufe0e\\ufe0f",zo=Mg+jg+Hg+zg,Jl="['’]",Vo="["+rc+"]",Yl="["+zo+"]",Go="["+ef+"]",of="\\d+",Vg="["+rf+"]",af="["+pi+"]",cf="[^"+rc+zo+of+rf+pi+nf+"]",ic="\\ud83c[\\udffb-\\udfff]",Gg="(?:"+Go+"|"+ic+")",lf="[^"+rc+"]",sc="(?:\\ud83c[\\udde6-\\uddff]){2}",Qs="[\\ud800-\\udbff][\\udc00-\\udfff]",Fn="["+nf+"]",uf="\\u200d",hf="(?:"+af+"|"+cf+")",Ti="(?:"+Fn+"|"+cf+")",ff="(?:"+Jl+"(?:d|ll|m|re|s|t|ve))?",df="(?:"+Jl+"(?:D|LL|M|RE|S|T|VE))?",pf=Gg+"?",gf="["+sf+"]?",qg="(?:"+uf+"(?:"+[lf,sc,Qs].join("|")+")"+gf+pf+")*",os="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",mf="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",wf=gf+pf+qg,oc="(?:"+[Vg,sc,Qs].join("|")+")"+wf,Wg="(?:"+[lf+Go+"?",Go,sc,Qs,Vo].join("|")+")",Zl=RegExp(Jl,"g"),Kg=RegExp(Go,"g"),ac=RegExp(ic+"(?="+ic+")|"+Wg+wf,"g"),yf=RegExp([Fn+"?"+af+"+"+ff+"(?="+[Yl,Fn,"$"].join("|")+")",Ti+"+"+df+"(?="+[Yl,Fn+hf,"$"].join("|")+")",Fn+"?"+hf+"+"+ff,Fn+"+"+df,mf,os,of,oc].join("|"),"g"),bf=RegExp("["+uf+rc+ef+sf+"]"),qo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,vf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Qg=-1,Le={};Le[re]=Le[kt]=Le[ae]=Le[le]=Le[ye]=Le[be]=Le[de]=Le[on]=Le[An]=!0,Le[gt]=Le[Ct]=Le[Rt]=Le[G]=Le[Mt]=Le[j]=Le[U]=Le[ht]=Le[Lt]=Le[ee]=Le[Jt]=Le[Zt]=Le[$t]=Le[qt]=Le[Bt]=!1;var Re={};Re[gt]=Re[Ct]=Re[Rt]=Re[Mt]=Re[G]=Re[j]=Re[re]=Re[kt]=Re[ae]=Re[le]=Re[ye]=Re[Lt]=Re[ee]=Re[Jt]=Re[Zt]=Re[$t]=Re[qt]=Re[Wt]=Re[be]=Re[de]=Re[on]=Re[An]=!0,Re[U]=Re[ht]=Re[Bt]=!1;var N={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},H={"&":"&","<":"<",">":">",'"':""","'":"'"},it={"&":"&","<":"<",">":">",""":'"',"'":"'"},wt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$e=parseFloat,zt=parseInt,je=typeof Ol=="object"&&Ol&&Ol.Object===Object&&Ol,Sr=typeof self=="object"&&self&&self.Object===Object&&self,pe=je||Sr||Function("return this")(),ke=t&&!t.nodeType&&t,mr=ke&&!0&&r&&!r.nodeType&&r,xn=mr&&mr.exports===ke,Or=xn&&je.process,He=function(){try{var z=mr&&mr.require&&mr.require("util").types;return z||Or&&Or.binding&&Or.binding("util")}catch{}}(),cn=He&&He.isArrayBuffer,gi=He&&He.isDate,ei=He&&He.isMap,Ni=He&&He.isRegExp,Xl=He&&He.isSet,Wo=He&&He.isTypedArray;function Ur(z,Z,Q){switch(Q.length){case 0:return z.call(Z);case 1:return z.call(Z,Q[0]);case 2:return z.call(Z,Q[0],Q[1]);case 3:return z.call(Z,Q[0],Q[1],Q[2])}return z.apply(Z,Q)}function DU(z,Z,Q,yt){for(var jt=-1,Ce=z==null?0:z.length;++jt-1}function Jg(z,Z,Q){for(var yt=-1,jt=z==null?0:z.length;++yt-1;);return Q}function z3(z,Z){for(var Q=z.length;Q--&&cc(Z,z[Q],0)>-1;);return Q}function FU(z,Z){for(var Q=z.length,yt=0;Q--;)z[Q]===Z&&++yt;return yt}var MU=t1(N),jU=t1(H);function HU(z){return"\\"+wt[z]}function zU(z,Z){return z==null?e:z[Z]}function lc(z){return bf.test(z)}function VU(z){return qo.test(z)}function GU(z){for(var Z,Q=[];!(Z=z.next()).done;)Q.push(Z.value);return Q}function i1(z){var Z=-1,Q=Array(z.size);return z.forEach(function(yt,jt){Q[++Z]=[jt,yt]}),Q}function V3(z,Z){return function(Q){return z(Z(Q))}}function Zs(z,Z){for(var Q=-1,yt=z.length,jt=0,Ce=[];++Q-1}function NB(o,c){var h=this.__data__,g=Bf(h,o);return g<0?(++this.size,h.push([o,c])):h[g][1]=c,this}as.prototype.clear=OB,as.prototype.delete=PB,as.prototype.get=DB,as.prototype.has=TB,as.prototype.set=NB;function cs(o){var c=-1,h=o==null?0:o.length;for(this.clear();++c=c?o:c)),o}function si(o,c,h,g,v,O){var L,B=c&w,V=c&m,rt=c&b;if(h&&(L=v?h(o,g,v,O):h(o)),L!==e)return L;if(!er(o))return o;var nt=Vt(o);if(nt){if(L=kF(o),!B)return In(o,L)}else{var at=Qr(o),dt=at==ht||at==mt;if(io(o))return C_(o,B);if(at==Jt||at==gt||dt&&!v){if(L=V||dt?{}:G_(o),!B)return V?IF(o,KB(L,o)):xF(o,r_(L,o))}else{if(!Re[at])return v?o:{};L=UF(o,at,B)}}O||(O=new wi);var Et=O.get(o);if(Et)return Et;O.set(o,L),vA(o)?o.forEach(function(Tt){L.add(si(Tt,c,h,Tt,o,O))}):yA(o)&&o.forEach(function(Tt,ce){L.set(ce,si(Tt,c,h,ce,o,O))});var Dt=rt?V?D1:P1:V?Sn:Br,te=nt?e:Dt(o);return ri(te||o,function(Tt,ce){te&&(ce=Tt,Tt=o[ce]),ou(L,ce,si(Tt,c,h,ce,o,O))}),L}function QB(o){var c=Br(o);return function(h){return n_(h,o,c)}}function n_(o,c,h){var g=h.length;if(o==null)return!g;for(o=Ue(o);g--;){var v=h[g],O=c[v],L=o[v];if(L===e&&!(v in o)||!O(L))return!1}return!0}function i_(o,c,h){if(typeof o!="function")throw new ni(a);return du(function(){o.apply(e,h)},c)}function au(o,c,h,g){var v=-1,O=Ef,L=!0,B=o.length,V=[],rt=c.length;if(!B)return V;h&&(c=Ke(c,Mn(h))),g?(O=Jg,L=!1):c.length>=i&&(O=tu,L=!1,c=new Jo(c));t:for(;++vv?0:v+h),g=g===e||g>v?v:Yt(g),g<0&&(g+=v),g=h>g?0:_A(g);h0&&h(B)?c>1?Hr(B,c-1,h,g,v):Ys(v,B):g||(v[v.length]=B)}return v}var h1=N_(),a_=N_(!0);function Ri(o,c){return o&&h1(o,c,Br)}function f1(o,c){return o&&a_(o,c,Br)}function Mf(o,c){return Js(c,function(h){return ds(o[h])})}function Zo(o,c){c=ro(c,o);for(var h=0,g=c.length;o!=null&&hc}function ZB(o,c){return o!=null&&De.call(o,c)}function XB(o,c){return o!=null&&c in Ue(o)}function tF(o,c,h){return o>=Kr(c,h)&&o=120&&nt.length>=120)?new Jo(L&&nt):e}nt=o[0];var at=-1,dt=B[0];t:for(;++at-1;)B!==o&&Tf.call(B,V,1),Tf.call(o,V,1);return o}function y_(o,c){for(var h=o?c.length:0,g=h-1;h--;){var v=c[h];if(h==g||v!==O){var O=v;fs(v)?Tf.call(o,v,1):_1(o,v)}}return o}function b1(o,c){return o+Lf(Z3()*(c-o+1))}function dF(o,c,h,g){for(var v=-1,O=Lr(Rf((c-o)/(h||1)),0),L=Q(O);O--;)L[g?O:++v]=o,o+=h;return L}function v1(o,c){var h="";if(!o||c<1||c>J)return h;do c%2&&(h+=o),c=Lf(c/2),c&&(o+=o);while(c);return h}function ne(o,c){return U1(K_(o,c,On),o+"")}function pF(o){return e_(vc(o))}function gF(o,c){var h=vc(o);return Yf(h,Yo(c,0,h.length))}function uu(o,c,h,g){if(!er(o))return o;c=ro(c,o);for(var v=-1,O=c.length,L=O-1,B=o;B!=null&&++vv?0:v+c),h=h>v?v:h,h<0&&(h+=v),v=c>h?0:h-c>>>0,c>>>=0;for(var O=Q(v);++g>>1,L=o[O];L!==null&&!Hn(L)&&(h?L<=c:L=i){var rt=c?null:PF(o);if(rt)return Af(rt);L=!1,v=tu,V=new Jo}else V=c?[]:B;t:for(;++g=g?o:oi(o,c,h)}var I_=oB||function(o){return pe.clearTimeout(o)};function C_(o,c){if(c)return o.slice();var h=o.length,g=W3?W3(h):new o.constructor(h);return o.copy(g),g}function C1(o){var c=new o.constructor(o.byteLength);return new Pf(c).set(new Pf(o)),c}function vF(o,c){var h=c?C1(o.buffer):o.buffer;return new o.constructor(h,o.byteOffset,o.byteLength)}function EF(o){var c=new o.constructor(o.source,ti.exec(o));return c.lastIndex=o.lastIndex,c}function _F(o){return su?Ue(su.call(o)):{}}function S_(o,c){var h=c?C1(o.buffer):o.buffer;return new o.constructor(h,o.byteOffset,o.length)}function O_(o,c){if(o!==c){var h=o!==e,g=o===null,v=o===o,O=Hn(o),L=c!==e,B=c===null,V=c===c,rt=Hn(c);if(!B&&!rt&&!O&&o>c||O&&L&&V&&!B&&!rt||g&&L&&V||!h&&V||!v)return 1;if(!g&&!O&&!rt&&o=B)return V;var rt=h[g];return V*(rt=="desc"?-1:1)}}return o.index-c.index}function P_(o,c,h,g){for(var v=-1,O=o.length,L=h.length,B=-1,V=c.length,rt=Lr(O-L,0),nt=Q(V+rt),at=!g;++B1?h[v-1]:e,L=v>2?h[2]:e;for(O=o.length>3&&typeof O=="function"?(v--,O):e,L&&un(h[0],h[1],L)&&(O=v<3?e:O,v=1),c=Ue(c);++g-1?v[O?c[L]:L]:e}}function $_(o){return hs(function(c){var h=c.length,g=h,v=ii.prototype.thru;for(o&&c.reverse();g--;){var O=c[g];if(typeof O!="function")throw new ni(a);if(v&&!L&&Qf(O)=="wrapper")var L=new ii([],!0)}for(g=L?g:h;++g1&&ge.reverse(),nt&&VB))return!1;var rt=O.get(o),nt=O.get(c);if(rt&&nt)return rt==c&&nt==o;var at=-1,dt=!0,Et=h&C?new Jo:e;for(O.set(o,c),O.set(c,o);++at1?"& ":"")+c[g],c=c.join(h>2?", ":" "),o.replace(ur,`{ /* [wrapped with `+c+`] */ `)}function FF(o){return Vt(o)||ea(o)||!!(J3&&o&&o[J3])}function fs(o,c){var h=typeof o;return c=c??J,!!c&&(h=="number"||h!="symbol"&&kg.test(o))&&o>-1&&o%1==0&&o0){if(++c>=st)return arguments[0]}else c=0;return o.apply(e,arguments)}}function Yf(o,c){var h=-1,g=o.length,v=g-1;for(c=c===e?g:c;++h1?o[c-1]:e;return h=typeof h=="function"?(o.pop(),h):e,oA(o,h)});function aA(o){var c=x(o);return c.__chain__=!0,c}function JM(o,c){return c(o),o}function Zf(o,c){return c(o)}var YM=hs(function(o){var c=o.length,h=c?o[0]:0,g=this.__wrapped__,v=function(O){return u1(O,o)};return c>1||this.__actions__.length||!(g instanceof ue)||!fs(h)?this.thru(v):(g=g.slice(h,+h+(c?1:0)),g.__actions__.push({func:Zf,args:[v],thisArg:e}),new ii(g,this.__chain__).thru(function(O){return c&&!O.length&&O.push(e),O}))});function ZM(){return aA(this)}function XM(){return new ii(this.value(),this.__chain__)}function tj(){this.__values__===e&&(this.__values__=EA(this.value()));var o=this.__index__>=this.__values__.length,c=o?e:this.__values__[this.__index__++];return{done:o,value:c}}function ej(){return this}function rj(o){for(var c,h=this;h instanceof Uf;){var g=tA(h);g.__index__=0,g.__values__=e,c?v.__wrapped__=g:c=g;var v=g;h=h.__wrapped__}return v.__wrapped__=o,c}function nj(){var o=this.__wrapped__;if(o instanceof ue){var c=o;return this.__actions__.length&&(c=new ue(this)),c=c.reverse(),c.__actions__.push({func:Zf,args:[B1],thisArg:e}),new ii(c,this.__chain__)}return this.thru(B1)}function ij(){return A_(this.__wrapped__,this.__actions__)}var sj=Vf(function(o,c,h){De.call(o,h)?++o[h]:ls(o,h,1)});function oj(o,c,h){var g=Vt(o)?k3:JB;return h&&un(o,c,h)&&(c=e),g(o,St(c,3))}function aj(o,c){var h=Vt(o)?Js:o_;return h(o,St(c,3))}var cj=L_(eA),lj=L_(rA);function uj(o,c){return Hr(Xf(o,c),1)}function hj(o,c){return Hr(Xf(o,c),et)}function fj(o,c,h){return h=h===e?1:Yt(h),Hr(Xf(o,c),h)}function cA(o,c){var h=Vt(o)?ri:to;return h(o,St(c,3))}function lA(o,c){var h=Vt(o)?TU:s_;return h(o,St(c,3))}var dj=Vf(function(o,c,h){De.call(o,h)?o[h].push(c):ls(o,h,[c])});function pj(o,c,h,g){o=Cn(o)?o:vc(o),h=h&&!g?Yt(h):0;var v=o.length;return h<0&&(h=Lr(v+h,0)),id(o)?h<=v&&o.indexOf(c,h)>-1:!!v&&cc(o,c,h)>-1}var gj=ne(function(o,c,h){var g=-1,v=typeof c=="function",O=Cn(o)?Q(o.length):[];return to(o,function(L){O[++g]=v?Ur(c,L,h):cu(L,c,h)}),O}),mj=Vf(function(o,c,h){ls(o,h,c)});function Xf(o,c){var h=Vt(o)?Ke:f_;return h(o,St(c,3))}function wj(o,c,h,g){return o==null?[]:(Vt(c)||(c=c==null?[]:[c]),h=g?e:h,Vt(h)||(h=h==null?[]:[h]),m_(o,c,h))}var yj=Vf(function(o,c,h){o[h?0:1].push(c)},function(){return[[],[]]});function bj(o,c,h){var g=Vt(o)?Yg:M3,v=arguments.length<3;return g(o,St(c,4),h,v,to)}function vj(o,c,h){var g=Vt(o)?NU:M3,v=arguments.length<3;return g(o,St(c,4),h,v,s_)}function Ej(o,c){var h=Vt(o)?Js:o_;return h(o,rd(St(c,3)))}function _j(o){var c=Vt(o)?e_:pF;return c(o)}function Aj(o,c,h){(h?un(o,c,h):c===e)?c=1:c=Yt(c);var g=Vt(o)?GB:gF;return g(o,c)}function xj(o){var c=Vt(o)?qB:wF;return c(o)}function Ij(o){if(o==null)return 0;if(Cn(o))return id(o)?uc(o):o.length;var c=Qr(o);return c==Lt||c==$t?o.size:m1(o).length}function Cj(o,c,h){var g=Vt(o)?Zg:yF;return h&&un(o,c,h)&&(c=e),g(o,St(c,3))}var Sj=ne(function(o,c){if(o==null)return[];var h=c.length;return h>1&&un(o,c[0],c[1])?c=[]:h>2&&un(c[0],c[1],c[2])&&(c=[c[0]]),m_(o,Hr(c,1),[])}),td=aB||function(){return pe.Date.now()};function Oj(o,c){if(typeof c!="function")throw new ni(a);return o=Yt(o),function(){if(--o<1)return c.apply(this,arguments)}}function uA(o,c,h){return c=h?e:c,c=o&&c==null?o.length:c,us(o,p,e,e,e,e,c)}function hA(o,c){var h;if(typeof c!="function")throw new ni(a);return o=Yt(o),function(){return--o>0&&(h=c.apply(this,arguments)),o<=1&&(c=e),h}}var M1=ne(function(o,c,h){var g=R;if(h.length){var v=Zs(h,yc(M1));g|=T}return us(o,g,c,h,v)}),fA=ne(function(o,c,h){var g=R|k;if(h.length){var v=Zs(h,yc(fA));g|=T}return us(c,g,o,h,v)});function dA(o,c,h){c=h?e:c;var g=us(o,P,e,e,e,e,e,c);return g.placeholder=dA.placeholder,g}function pA(o,c,h){c=h?e:c;var g=us(o,I,e,e,e,e,e,c);return g.placeholder=pA.placeholder,g}function gA(o,c,h){var g,v,O,L,B,V,rt=0,nt=!1,at=!1,dt=!0;if(typeof o!="function")throw new ni(a);c=ci(c)||0,er(h)&&(nt=!!h.leading,at="maxWait"in h,O=at?Lr(ci(h.maxWait)||0,c):O,dt="trailing"in h?!!h.trailing:dt);function Et(yr){var bi=g,gs=v;return g=v=e,rt=yr,L=o.apply(gs,bi),L}function Dt(yr){return rt=yr,B=du(ce,c),nt?Et(yr):L}function te(yr){var bi=yr-V,gs=yr-rt,LA=c-bi;return at?Kr(LA,O-gs):LA}function Tt(yr){var bi=yr-V,gs=yr-rt;return V===e||bi>=c||bi<0||at&&gs>=O}function ce(){var yr=td();if(Tt(yr))return ge(yr);B=du(ce,te(yr))}function ge(yr){return B=e,dt&&g?Et(yr):(g=v=e,L)}function zn(){B!==e&&I_(B),rt=0,g=V=v=B=e}function hn(){return B===e?L:ge(td())}function Vn(){var yr=td(),bi=Tt(yr);if(g=arguments,v=this,V=yr,bi){if(B===e)return Dt(V);if(at)return I_(B),B=du(ce,c),Et(V)}return B===e&&(B=du(ce,c)),L}return Vn.cancel=zn,Vn.flush=hn,Vn}var Pj=ne(function(o,c){return i_(o,1,c)}),Dj=ne(function(o,c,h){return i_(o,ci(c)||0,h)});function Tj(o){return us(o,M)}function ed(o,c){if(typeof o!="function"||c!=null&&typeof c!="function")throw new ni(a);var h=function(){var g=arguments,v=c?c.apply(this,g):g[0],O=h.cache;if(O.has(v))return O.get(v);var L=o.apply(this,g);return h.cache=O.set(v,L)||O,L};return h.cache=new(ed.Cache||cs),h}ed.Cache=cs;function rd(o){if(typeof o!="function")throw new ni(a);return function(){var c=arguments;switch(c.length){case 0:return!o.call(this);case 1:return!o.call(this,c[0]);case 2:return!o.call(this,c[0],c[1]);case 3:return!o.call(this,c[0],c[1],c[2])}return!o.apply(this,c)}}function Nj(o){return hA(2,o)}var Rj=bF(function(o,c){c=c.length==1&&Vt(c[0])?Ke(c[0],Mn(St())):Ke(Hr(c,1),Mn(St()));var h=c.length;return ne(function(g){for(var v=-1,O=Kr(g.length,h);++v=c}),ea=l_(function(){return arguments}())?l_:function(o){return hr(o)&&De.call(o,"callee")&&!Q3.call(o,"callee")},Vt=Q.isArray,Kj=cn?Mn(cn):rF;function Cn(o){return o!=null&&nd(o.length)&&!ds(o)}function wr(o){return hr(o)&&Cn(o)}function Qj(o){return o===!0||o===!1||hr(o)&&ln(o)==G}var io=lB||Z1,Jj=gi?Mn(gi):nF;function Yj(o){return hr(o)&&o.nodeType===1&&!pu(o)}function Zj(o){if(o==null)return!0;if(Cn(o)&&(Vt(o)||typeof o=="string"||typeof o.splice=="function"||io(o)||bc(o)||ea(o)))return!o.length;var c=Qr(o);if(c==Lt||c==$t)return!o.size;if(fu(o))return!m1(o).length;for(var h in o)if(De.call(o,h))return!1;return!0}function Xj(o,c){return lu(o,c)}function tH(o,c,h){h=typeof h=="function"?h:e;var g=h?h(o,c):e;return g===e?lu(o,c,e,h):!!g}function H1(o){if(!hr(o))return!1;var c=ln(o);return c==U||c==y||typeof o.message=="string"&&typeof o.name=="string"&&!pu(o)}function eH(o){return typeof o=="number"&&Y3(o)}function ds(o){if(!er(o))return!1;var c=ln(o);return c==ht||c==mt||c==W||c==Ge}function wA(o){return typeof o=="number"&&o==Yt(o)}function nd(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=J}function er(o){var c=typeof o;return o!=null&&(c=="object"||c=="function")}function hr(o){return o!=null&&typeof o=="object"}var yA=ei?Mn(ei):sF;function rH(o,c){return o===c||g1(o,c,N1(c))}function nH(o,c,h){return h=typeof h=="function"?h:e,g1(o,c,N1(c),h)}function iH(o){return bA(o)&&o!=+o}function sH(o){if(HF(o))throw new jt(s);return u_(o)}function oH(o){return o===null}function aH(o){return o==null}function bA(o){return typeof o=="number"||hr(o)&&ln(o)==ee}function pu(o){if(!hr(o)||ln(o)!=Jt)return!1;var c=Df(o);if(c===null)return!0;var h=De.call(c,"constructor")&&c.constructor;return typeof h=="function"&&h instanceof h&&Cf.call(h)==nB}var z1=Ni?Mn(Ni):oF;function cH(o){return wA(o)&&o>=-J&&o<=J}var vA=Xl?Mn(Xl):aF;function id(o){return typeof o=="string"||!Vt(o)&&hr(o)&&ln(o)==qt}function Hn(o){return typeof o=="symbol"||hr(o)&&ln(o)==Wt}var bc=Wo?Mn(Wo):cF;function lH(o){return o===e}function uH(o){return hr(o)&&Qr(o)==Bt}function hH(o){return hr(o)&&ln(o)==Kt}var fH=Kf(w1),dH=Kf(function(o,c){return o<=c});function EA(o){if(!o)return[];if(Cn(o))return id(o)?mi(o):In(o);if(eu&&o[eu])return GU(o[eu]());var c=Qr(o),h=c==Lt?i1:c==$t?Af:vc;return h(o)}function ps(o){if(!o)return o===0?o:0;if(o=ci(o),o===et||o===-et){var c=o<0?-1:1;return c*Y}return o===o?o:0}function Yt(o){var c=ps(o),h=c%1;return c===c?h?c-h:c:0}function _A(o){return o?Yo(Yt(o),0,ot):0}function ci(o){if(typeof o=="number")return o;if(Hn(o))return X;if(er(o)){var c=typeof o.valueOf=="function"?o.valueOf():o;o=er(c)?c+"":c}if(typeof o!="string")return o===0?o:+o;o=j3(o);var h=Rg.test(o);return h||$g.test(o)?zt(o.slice(2),h?2:8):Ng.test(o)?X:+o}function AA(o){return Li(o,Sn(o))}function pH(o){return o?Yo(Yt(o),-J,J):o===0?o:0}function Pe(o){return o==null?"":jn(o)}var gH=mc(function(o,c){if(fu(c)||Cn(c)){Li(c,Br(c),o);return}for(var h in c)De.call(c,h)&&ou(o,h,c[h])}),xA=mc(function(o,c){Li(c,Sn(c),o)}),sd=mc(function(o,c,h,g){Li(c,Sn(c),o,g)}),mH=mc(function(o,c,h,g){Li(c,Br(c),o,g)}),wH=hs(u1);function yH(o,c){var h=gc(o);return c==null?h:r_(h,c)}var bH=ne(function(o,c){o=Ue(o);var h=-1,g=c.length,v=g>2?c[2]:e;for(v&&un(c[0],c[1],v)&&(g=1);++h1),O}),Li(o,D1(o),h),g&&(h=si(h,w|m|b,DF));for(var v=c.length;v--;)_1(h,c[v]);return h});function UH(o,c){return CA(o,rd(St(c)))}var BH=hs(function(o,c){return o==null?{}:hF(o,c)});function CA(o,c){if(o==null)return{};var h=Ke(D1(o),function(g){return[g]});return c=St(c),w_(o,h,function(g,v){return c(g,v[0])})}function FH(o,c,h){c=ro(c,o);var g=-1,v=c.length;for(v||(v=1,o=e);++gc){var g=o;o=c,c=g}if(h||o%1||c%1){var v=Z3();return Kr(o+v*(c-o+$e("1e-"+((v+"").length-1))),c)}return b1(o,c)}var JH=wc(function(o,c,h){return c=c.toLowerCase(),o+(h?PA(c):c)});function PA(o){return q1(Pe(o).toLowerCase())}function DA(o){return o=Pe(o),o&&o.replace(ss,MU).replace(Kg,"")}function YH(o,c,h){o=Pe(o),c=jn(c);var g=o.length;h=h===e?g:Yo(Yt(h),0,g);var v=h;return h-=c.length,h>=0&&o.slice(h,v)==c}function ZH(o){return o=Pe(o),o&&qe.test(o)?o.replace(Ho,jU):o}function XH(o){return o=Pe(o),o&&xr.test(o)?o.replace(cr,"\\$&"):o}var tz=wc(function(o,c,h){return o+(h?"-":"")+c.toLowerCase()}),ez=wc(function(o,c,h){return o+(h?" ":"")+c.toLowerCase()}),rz=R_("toLowerCase");function nz(o,c,h){o=Pe(o),c=Yt(c);var g=c?uc(o):0;if(!c||g>=c)return o;var v=(c-g)/2;return Wf(Lf(v),h)+o+Wf(Rf(v),h)}function iz(o,c,h){o=Pe(o),c=Yt(c);var g=c?uc(o):0;return c&&g>>0,h?(o=Pe(o),o&&(typeof c=="string"||c!=null&&!z1(c))&&(c=jn(c),!c&&lc(o))?no(mi(o),0,h):o.split(c,h)):[]}var hz=wc(function(o,c,h){return o+(h?" ":"")+q1(c)});function fz(o,c,h){return o=Pe(o),h=h==null?0:Yo(Yt(h),0,o.length),c=jn(c),o.slice(h,h+c.length)==c}function dz(o,c,h){var g=x.templateSettings;h&&un(o,c,h)&&(c=e),o=Pe(o),c=sd({},c,g,M_);var v=sd({},c.imports,g.imports,M_),O=Br(v),L=n1(v,O),B,V,rt=0,nt=c.interpolate||ec,at="__p += '",dt=s1((c.escape||ec).source+"|"+nt.source+"|"+(nt===tr?Tg:ec).source+"|"+(c.evaluate||ec).source+"|$","g"),Et="//# sourceURL="+(De.call(c,"sourceURL")?(c.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Qg+"]")+` `;o.replace(dt,function(Tt,ce,ge,zn,hn,Vn){return ge||(ge=zn),at+=o.slice(rt,Vn).replace(Ug,HU),ce&&(B=!0,at+=`' + __e(`+ce+`) + '`),hn&&(V=!0,at+=`'; `+hn+`; __p += '`),ge&&(at+=`' + ((__t = (`+ge+`)) == null ? '' : __t) + '`),rt=Vn+Tt.length,Tt}),at+=`'; `;var Dt=De.call(c,"variable")&&c.variable;if(!Dt)at=`with (obj) { `+at+` } `;else if(Pg.test(Dt))throw new jt(l);at=(V?at.replace(Di,""):at).replace(an,"$1").replace(is,"$1;"),at="function("+(Dt||"obj")+`) { `+(Dt?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(B?", __e = _.escape":"")+(V?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+at+`return __p }`;var te=NA(function(){return Ce(O,Et+"return "+at).apply(e,L)});if(te.source=at,H1(te))throw te;return te}function pz(o){return Pe(o).toLowerCase()}function gz(o){return Pe(o).toUpperCase()}function mz(o,c,h){if(o=Pe(o),o&&(h||c===e))return j3(o);if(!o||!(c=jn(c)))return o;var g=mi(o),v=mi(c),O=H3(g,v),L=z3(g,v)+1;return no(g,O,L).join("")}function wz(o,c,h){if(o=Pe(o),o&&(h||c===e))return o.slice(0,G3(o)+1);if(!o||!(c=jn(c)))return o;var g=mi(o),v=z3(g,mi(c))+1;return no(g,0,v).join("")}function yz(o,c,h){if(o=Pe(o),o&&(h||c===e))return o.replace(lr,"");if(!o||!(c=jn(c)))return o;var g=mi(o),v=H3(g,mi(c));return no(g,v).join("")}function bz(o,c){var h=F,g=K;if(er(c)){var v="separator"in c?c.separator:v;h="length"in c?Yt(c.length):h,g="omission"in c?jn(c.omission):g}o=Pe(o);var O=o.length;if(lc(o)){var L=mi(o);O=L.length}if(h>=O)return o;var B=h-uc(g);if(B<1)return g;var V=L?no(L,0,B).join(""):o.slice(0,B);if(v===e)return V+g;if(L&&(B+=V.length-B),z1(v)){if(o.slice(B).search(v)){var rt,nt=V;for(v.global||(v=s1(v.source,Pe(ti.exec(v))+"g")),v.lastIndex=0;rt=v.exec(nt);)var at=rt.index;V=V.slice(0,at===e?B:at)}}else if(o.indexOf(jn(v),B)!=B){var dt=V.lastIndexOf(v);dt>-1&&(V=V.slice(0,dt))}return V+g}function vz(o){return o=Pe(o),o&&sr.test(o)?o.replace(Ks,QU):o}var Ez=wc(function(o,c,h){return o+(h?" ":"")+c.toUpperCase()}),q1=R_("toUpperCase");function TA(o,c,h){return o=Pe(o),c=h?e:c,c===e?VU(o)?ZU(o):$U(o):o.match(c)||[]}var NA=ne(function(o,c){try{return Ur(o,e,c)}catch(h){return H1(h)?h:new jt(h)}}),_z=hs(function(o,c){return ri(c,function(h){h=$i(h),ls(o,h,M1(o[h],o))}),o});function Az(o){var c=o==null?0:o.length,h=St();return o=c?Ke(o,function(g){if(typeof g[1]!="function")throw new ni(a);return[h(g[0]),g[1]]}):[],ne(function(g){for(var v=-1;++vJ)return[];var h=ot,g=Kr(o,ot);c=St(c),o-=ot;for(var v=r1(g,c);++h0||c<0)?new ue(h):(o<0?h=h.takeRight(-o):o&&(h=h.drop(o)),c!==e&&(c=Yt(c),h=c<0?h.dropRight(-c):h.take(c-o)),h)},ue.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},ue.prototype.toArray=function(){return this.take(ot)},Ri(ue.prototype,function(o,c){var h=/^(?:filter|find|map|reject)|While$/.test(c),g=/^(?:head|last)$/.test(c),v=x[g?"take"+(c=="last"?"Right":""):c],O=g||/^find/.test(c);v&&(x.prototype[c]=function(){var L=this.__wrapped__,B=g?[1]:arguments,V=L instanceof ue,rt=B[0],nt=V||Vt(L),at=function(ce){var ge=v.apply(x,Ys([ce],B));return g&&dt?ge[0]:ge};nt&&h&&typeof rt=="function"&&rt.length!=1&&(V=nt=!1);var dt=this.__chain__,Et=!!this.__actions__.length,Dt=O&&!dt,te=V&&!Et;if(!O&&nt){L=te?L:new ue(this);var Tt=o.apply(L,B);return Tt.__actions__.push({func:Zf,args:[at],thisArg:e}),new ii(Tt,dt)}return Dt&&te?o.apply(this,B):(Tt=this.thru(at),Dt?g?Tt.value()[0]:Tt.value():Tt)})}),ri(["pop","push","shift","sort","splice","unshift"],function(o){var c=xf[o],h=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",g=/^(?:pop|shift)$/.test(o);x.prototype[o]=function(){var v=arguments;if(g&&!this.__chain__){var O=this.value();return c.apply(Vt(O)?O:[],v)}return this[h](function(L){return c.apply(Vt(L)?L:[],v)})}}),Ri(ue.prototype,function(o,c){var h=x[c];if(h){var g=h.name+"";De.call(pc,g)||(pc[g]=[]),pc[g].push({name:c,func:h})}}),pc[Gf(e,k).name]=[{name:"wrapper",func:e}],ue.prototype.clone=vB,ue.prototype.reverse=EB,ue.prototype.value=_B,x.prototype.at=YM,x.prototype.chain=ZM,x.prototype.commit=XM,x.prototype.next=tj,x.prototype.plant=rj,x.prototype.reverse=nj,x.prototype.toJSON=x.prototype.valueOf=x.prototype.value=ij,x.prototype.first=x.prototype.head,eu&&(x.prototype[eu]=ej),x},hc=XU();mr?((mr.exports=hc)._=hc,ke._=hc):pe._=hc}).call(Ol)})(b0,b0.exports);var ZR=Object.defineProperty,XR=Object.defineProperties,t9=Object.getOwnPropertyDescriptors,gE=Object.getOwnPropertySymbols,e9=Object.prototype.hasOwnProperty,r9=Object.prototype.propertyIsEnumerable,mE=(r,t,e)=>t in r?ZR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ph=(r,t)=>{for(var e in t||(t={}))e9.call(t,e)&&mE(r,e,t[e]);if(gE)for(var e of gE(t))r9.call(t,e)&&mE(r,e,t[e]);return r},n9=(r,t)=>XR(r,t9(t));function Zn(r,t,e){let n;const i=v0(r);return t.rpcMap&&(n=t.rpcMap[i]),n||(n=`${YR}?chainId=eip155:${i}&projectId=${e}`),n}function v0(r){return r.includes("eip155")?Number(r.split(":")[1]):Number(r)}function wE(r){return r.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function i9(r,t){const e=Object.keys(t.namespaces).filter(i=>i.includes(r));if(!e.length)return[];const n=[];return e.forEach(i=>{const s=t.namespaces[i].accounts;n.push(...s)}),n}function s9(r={},t={}){const e=yE(r),n=yE(t);return b0.exports.merge(e,n)}function yE(r){var t,e,n,i;const s={};if(!ka(r))return s;for(const[a,l]of Object.entries(r)){const u=Xp(a)?[a]:l.chains,f=l.methods||[],d=l.events||[],w=l.rpcMap||{},m=bl(a);s[m]=n9(Ph(Ph({},s[m]),l),{chains:Yp(u,(t=s[m])==null?void 0:t.chains),methods:Yp(f,(e=s[m])==null?void 0:e.methods),events:Yp(d,(n=s[m])==null?void 0:n.events),rpcMap:Ph(Ph({},w),(i=s[m])==null?void 0:i.rpcMap)})}return s}function o9(r){return r.includes(":")?r.split(":")[2]:r}function a9(r){const t={};for(const[e,n]of Object.entries(r)){const i=n.methods||[],s=n.events||[],a=n.accounts||[],l=Xp(e)?[e]:n.chains?n.chains:wE(n.accounts);t[e]={chains:l,methods:i,events:s,accounts:a}}return t}function E0(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):r.includes(":")?Number(r.split(":")[1]):Number(r)}const bE={},pr=r=>bE[r],_0=(r,t)=>{bE[r]=t};class c9{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=pr("events"),this.client=pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const n=e||Zn(`${this.name}:${t}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.events.emit(Fs.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;t[e]=this.createHttpProvider(e,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Zn(t,this.namespace);return typeof n>"u"?void 0:new Us(new Ro(n,pr("disableProviderPing")))}}class l9{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=pr("events"),this.client=pr("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){const n=v0(t);if(!this.httpProviders[n]){const i=e||Zn(`${this.name}:${n}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${n}`);this.setHttpProvider(n,i)}this.chainId=n,this.events.emit(Fs.DEFAULT_CHAIN_CHANGED,`${this.name}:${n}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const n=e||Zn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Us(new Ro(n,pr("disableProviderPing")))}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;const i=v0(e);t[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,n;let i=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class u9{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=pr("events"),this.client=pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const n=e||Zn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.chainId=t,this.events.emit(Fs.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;t[e]=this.createHttpProvider(e,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Zn(t,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Us(new Ro(n,pr("disableProviderPing")))}}class h9{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=pr("events"),this.client=pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const n=e||Zn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.events.emit(Fs.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;t[e]=this.createHttpProvider(e,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Zn(t,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Us(new Ro(n,pr("disableProviderPing")))}}class f9{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=pr("events"),this.client=pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const n=e||this.getCardanoRPCUrl(t);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.events.emit(Fs.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const n=this.getCardanoRPCUrl(e);t[e]=this.createHttpProvider(e,n)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||this.getCardanoRPCUrl(t);return typeof n>"u"?void 0:new Us(new Ro(n,pr("disableProviderPing")))}}class d9{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=pr("events"),this.client=pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const n=e||Zn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.chainId=t,this.events.emit(Fs.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;t[e]=this.createHttpProvider(e,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Zn(t,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Us(new Ro(n,pr("disableProviderPing")))}}class p9{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=pr("events"),this.client=pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const n=e||Zn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.chainId=t,this.events.emit(Fs.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;t[e]=this.createHttpProvider(e,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Zn(t,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Us(new Ro(n,pr("disableProviderPing")))}}var g9=Object.defineProperty,m9=Object.defineProperties,w9=Object.getOwnPropertyDescriptors,vE=Object.getOwnPropertySymbols,y9=Object.prototype.hasOwnProperty,b9=Object.prototype.propertyIsEnumerable,EE=(r,t,e)=>t in r?g9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Dh=(r,t)=>{for(var e in t||(t={}))y9.call(t,e)&&EE(r,e,t[e]);if(vE)for(var e of vE(t))b9.call(t,e)&&EE(r,e,t[e]);return r},A0=(r,t)=>m9(r,w9(t));let v9=class UA{constructor(t){this.events=new ap,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof t?.logger<"u"&&typeof t?.logger!="string"?t.logger:he.pino(he.getDefaultLoggerOptions({level:t?.logger||dE})),this.disableProviderPing=t?.disableProviderPing||!1}static async init(t){const e=new UA(t);return await e.initialize(),e}async request(t,e){const[n,i]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:Dh({},t),chainId:`${n}:${i}`,topic:this.session.topic})}sendAsync(t,e,n){this.request(t,n).then(i=>e(null,i)).catch(i=>e(i,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Er("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:i}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await i().then(s=>{this.session=s,this.namespaces||(this.namespaces=a9(s.namespaces),this.persist("namespaces",this.namespaces))}).catch(s=>{if(s.message!==aE)throw s;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[n,i]=this.validateChain(t);this.getProvider(n).setDefaultChain(i,e)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(No(e)){for(const n of e)t.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await qR.init({logger:this.providerOpts.logger||dE,relayUrl:this.providerOpts.relayUrl||KR,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>bl(e)))];_0("client",this.client),_0("events",this.events),_0("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const n=i9(e,this.session),i=wE(n),s=s9(this.namespaces,this.optionalNamespaces),a=A0(Dh({},s[e]),{accounts:n,chains:i});switch(e){case"eip155":this.rpcProviders[e]=new l9({namespace:a});break;case"solana":this.rpcProviders[e]=new u9({namespace:a});break;case"cosmos":this.rpcProviders[e]=new h9({namespace:a});break;case"polkadot":this.rpcProviders[e]=new c9({namespace:a});break;case"cip34":this.rpcProviders[e]=new f9({namespace:a});break;case"elrond":this.rpcProviders[e]=new d9({namespace:a});break;case"multiversx":this.rpcProviders[e]=new p9({namespace:a});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:e}=t,{event:n}=e;if(n.name==="accountsChanged"){const i=n.data;i&&No(i)&&this.events.emit("accountsChanged",i.map(o9))}else if(n.name==="chainChanged"){const i=e.chainId,s=e.event.data,a=bl(i),l=E0(i)!==E0(s)?`${a}:${E0(s)}`:i;this.onChainChanged(l)}else this.events.emit(n.name,n.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var n;const{namespaces:i}=e,s=(n=this.client)==null?void 0:n.session.get(t);this.session=A0(Dh({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",A0(Dh({},Er("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Fs.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:n,sessionProperties:i}=t;e&&Object.keys(e).length&&(this.namespaces=e),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.persist("namespaces",e),this.persist("optionalNamespaces",n)}validateChain(t){const[e,n]=t?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,n];if(e&&!Object.keys(this.namespaces||{}).map(a=>bl(a)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&n)return[e,n];const i=bl(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){var n;if(!this.namespaces)return;const[i,s]=this.validateChain(t);e||this.getProvider(i).setDefaultChain(s),((n=this.namespaces[i])!=null?n:this.namespaces[`${i}:${s}`]).defaultChain=s,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",s)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,e){this.client.core.storage.setItem(`${pE}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${pE}/${t}`)}};class _E{target;constructor(){this.target=new EventTarget}on(t,e){return this.target.addEventListener(t,e)}once(t,e){return this.target.addEventListener(t,e,{once:!0})}off(t,e){return this.target.removeEventListener(t,e)}emit(t,e){return this.target.dispatchEvent(new CustomEvent(t,{detail:e,cancelable:!0}))}}class ts{data;constructor(t){this.data=t}get provider(){return this.data.provider}get chainId(){return this.data.chainId}get name(){return this.data.name}get shortName(){return this.data.short_name}get image(){return this.data.image}get blockExplorer(){return this.data.blockExplorer}get nativeCoin(){return this.data.nativeCoin}get cryptos(){return this.data.cryptos}get gasFee(){return String(this.data.gasLimit*this.data.gasPrice*this.data.coinPrice)}static async estimateGasFee(t,e,n=!0){const i=await ts.getNetwork(t),s=i.cryptos.find(l=>l.symbol===e||l.address.toLowerCase()===e.toLowerCase());if(!s)throw new Error("Crypto not supported");if(s.decimals>17){let l=Math.floor(Number(i.gasFee)/1e18);return n&&(l=l/1e18),String(l)}let a=Math.floor(Number(i.gasFee)/1e18/10**(18-s.decimals));return n&&(a=a/10**s.decimals),String(a)}static async getNetwork(t){const{error:e,network:n}=await e5(t);if(e)throw new Error(e);return new ts(n)}static async getNetworks(){return(await r5()).map(e=>new ts(e))}}function E9(r){let t=!0,e=!1,n=!1;const i=r.then(s=>(n=!0,t=!1,s)).catch(s=>{throw e=!0,t=!1,s});return{get isPending(){return t},get isRejected(){return e},get isFulfilled(){return n},promise:i}}const Ua=new _E;class Ht{wallet;session;static events=Ua;static projectId;static web3modal;static provider;static connected=!1;static wallet;static connectCB;constructor(t,e){this.wallet=t,this.session=e}setChainId(t){return Ht.provider.setDefaultChain(`eip155:${t}`)}async setNetwork(t){let e=t.chainId;try{e=await this.wallet.getChainId()}catch(n){if(n.message.indexOf("network changed")===-1)throw n;e=0}return e!==t.chainId&&(this.session=await Th(t.chainId)),this}async addChain(t,e,n,i,s){return window.ethereum.request({method:"wallet_addEthereumChain",params:[{chainId:`0x${t.toString(16)}`,chainName:e,rpcUrls:n,nativeCurrency:i,blockExplorerUrls:s}]})}static set_project_id(t){Ht.projectId=t}static setProjectId(t){Ht.set_project_id(t)}static async init(t){if(Ht.projectId===void 0)throw new Error("Project ID not set");const e=Ht.projectId,n=await v9.init({projectId:e,logger:"error",metadata:t});Ht.web3modal=new G4({projectId:e}),Ht.web3modal.subscribeModal(i=>{Ua.emit("modal",i.open)}),n.on("display_uri",i=>{Ht.openModal(i)}),Ua.on("modal",i=>{i.detail||Ua.emit("modelClosed")}),n.on("session_event",({params:{event:i,chainId:s}})=>{console.log("session_event",i.name),i.name==="accountsChanged"&&Ht.events.emit("accountsChanged",[i.data[0].split(":")[2]]),i.name==="chainChanged"&&(Ht.provider.setDefaultChain(`eip155:${i.data}`),Ht.events.emit("chainChanged",parseInt(i.data))),Ht.events.emit("session_event",{event:i,chainId:s})}),n.on("session_delete",()=>{Ht.connected=!1,Ht.events.emit("disconnect")}),Ht.provider=n}static async disconnect(t){if(!Ht.provider)throw new Error("WalletConnect not initialized");await Ht.provider.disconnect(),Ht.connected=!1,t&&t()}static openModal(t){if(!Ht.web3modal)throw new Error("WalletConnect not initialized");return Ht.web3modal.openModal({uri:t})}static async connect(t,e){if(Ht.provider||await Ht.init(),typeof t=="string"&&(t=(await ts.getNetwork(t)).chainId),!t)throw new Error("Invalid chain");if(Ht.provider.session){Ht.connected=!0;const a=await Ht.provider.enable();if(!a)throw new Error("Could not connect to WalletConnect");const l=new Pl(a[0],t),u=new Ht(l,Ht.provider.session);return await l.setWalletConnect(u),u}const n=await Th(t);if(!n)throw new Error("Could not connect to WalletConnect");Ht.connected=!0;const i=await Ht.provider.enable(),s=new Ht(new Pl(i[0],t),n);return await s.wallet.setWalletConnect(s),e&&e(s),s}async getBalance(){return await Ht.provider.request({method:"eth_getBalance",params:[this.wallet.address]},`eip155:${this.wallet.network.chainId}`)}}async function Th(r){try{const t=E9(Ht.provider.connect({namespaces:{eip155:{methods:["eth_sendTransaction","eth_signTransaction","eth_sign","personal_sign","eth_signTypedData"],chains:[`eip155:${r}`],events:["chainChanged","accountsChanged"]}}}));return await new Promise(async(e,n)=>{function i(){t.isPending&&n("user closed modal")}Ua.once("modelClosed",i),await t.promise,Ua.off("modelClosed",i),Ht.web3modal.closeModal(),e()}),t.promise}catch(t){throw Ht.web3modal.closeModal(),t}}class x0{data;wallet;tx;constructor(t,e){this.wallet=t,this.data=e}get from(){return this.data.from}get to(){return this.data.to}get hash(){return this.tx?.hash}static send(t,e){return new x0(t,e).send()}async send(){if(!this.wallet.signer)throw new Error("Not connected to Wallet");try{return this.tx=await this.wallet.signer?.sendTransaction(this.data),this}catch(t){if(t.code==="ACTION_REJECTED")throw new Error("User rejected transaction");if(this.wallet.walletConnect&&t.message.indexOf("Missing or invalid. request() chainId")!==-1)try{return await Th(this.data.chainId),this.tx=await this.wallet.signer?.sendTransaction(this.data),this}catch(e){throw e.code===5001?new Error("User rejected connection request"):new Error(e.error?.message||e.message||"Unknown error sending transaction")}else throw t.message.indexOf("User canceled")!==-1?new Error("User rejected transaction"):new Error(t.error?.message||t.message||"Unknown error sending transaction")}}async wait(){if(!this.tx)throw new Error("No transaction sent");return this.tx.wait()}}class Pl{address;balance="0";chainId=1;network;metaMask;walletConnect;provider;signer;events;static WalleTypes={MetaMask:"metamask",WalletConnect:"walletconnect"};constructor(t,e){this.address=t,this.chainId=e||1}async setMetaMask(t){this.metaMask=t,this.provider=new Yu(window.ethereum),this.signer=await this.provider.getSigner(),this.events=t.events,await this.getChainId(),await this.getBalance(),this.metaMask.events.on("chainChanged",async e=>{this.setNetwork(e.detail)}),this.metaMask.events.on("accountsChanged",async e=>{this.address=e[0],this.getBalance()})}async setWalletConnect(t){this.walletConnect=t,this.provider=new Yu(Ht.provider);try{this.signer=await this.provider.getSigner(this.address)}catch(e){if(e.message.indexOf("no such account")!==-1)try{await Th(this.chainId),this.signer=await this.provider.getSigner(this.address)}catch(n){console.log("setWalletConnect, try, try",n)}}this.events=Ht.events,Ht.events.on("chainChanged",async e=>{this.setNetwork(e.detail)}),Ht.events.on("accountsChanged",async e=>{this.address=e.detail[0]})}async setNetwork(t){const e=await ts.getNetwork(t);if(this.network=e,this.metaMask)try{await this.metaMask.switchChain(e.chainId),this.provider=new Yu(window.ethereum),this.signer=await this.provider.getSigner(this.address)}catch(n){if(n.message.indexOf("Unrecognized chain ID")!==-1)await this.metaMask.addChain(e.chainId,e.name,[e.provider],e.nativeCoin,[e.blockExplorer]);else throw n}this.walletConnect&&(this.walletConnect=await this.walletConnect.setNetwork(e),this.provider=new Yu(Ht.provider),this.signer=await this.provider.getSigner(this.address))}async sendTransaction(t){if(this.signer===void 0||this.provider===void 0)throw new Error("Not connected to Wallet");return t.from=this.address,t.chainId!==this.chainId&&await this.setNetwork(t.chainId),t.gasLimit=t.gasLimit||Number(await this.signer.provider?.estimateGas(t)),x0.send(this,t)}async withdraw(t,e,n){const{error:i,to:s,data:a,chainId:l}=await XA({network:t,token:e,address:n,amount:"0"});if(i)throw new Error(i);const u={to:s,data:a,chainId:l},f=await this.sendTransaction(u);if(!f)throw new Error("Transaction failed");return f}async allowance(t,e,n=!0){const{error:i,wei:s,eth:a}=await nm({network:t,crypto:e,address:this.address});if(i)throw new Error(i);return n?a:s}async approve(t,e,n){const{error:i,to:s,data:a,chainId:l}=await na({network:t,crypto:e,amount:n});if(i)throw new Error(i);const u={to:s,data:a,chainId:l},f=this.sendTransaction(u);if(!f)throw new Error("Transaction failed");return f}async disconnect(t){if(this.walletConnect&&await Ht.disconnect(t),this.metaMask)throw new Error("MetaMask does not support disconnecting")}async getBalance(t=!0){return this.balance=String(await this.provider?.getBalance(this.address)),this.events.emit("balance",this.balance),t?String(Number(this.balance)/10**this.network.nativeCoin.decimals):this.balance}async balanceOf(t,e=!0){const n=this.network.cryptos.find(l=>l.symbol===t||l.address.toLowerCase()===t.toLowerCase());if(!n)throw new Error("Crypto not supported");const i=n.address,s=await this.provider?.send("eth_call",[{to:i,data:"0x70a08231000000000000000000000000"+this.address.slice(2)},"latest"]);if(!s)throw new Error("Request failed");let a=BigInt(Number(s));return e&&(a=a/BigInt(10**n.decimals)),String(a)}async getChainId(){const t=await this.provider?.getNetwork().then(e=>e.chainId);return this.chainId=Number(t),this.events.emit("chainId",this.chainId),(!this.network||this.chainId!==this.network.chainId)&&(this.network=await ts.getNetwork(this.chainId)),this.chainId}}let I0=null;class Dl{wallet;events=new _E;constructor(t){this.wallet=t,window.ethereum.on("accountsChanged",e=>{this.events.emit("accountsChanged",e)}),window.ethereum.on("chainChanged",e=>{this.events.emit("chainChanged",e)}),window.ethereum.on("connect",async e=>{const[n]=await window.ethereum.request({method:"eth_accounts"});this.events.emit("connect",{chain:e.chainId,address:n})}),window.ethereum.on("disconnect",e=>{this.events.emit("disconnect",e)})}async switchChain(t){return window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]})}async addChain(t,e,n,i,s){return window.ethereum.request({method:"wallet_addEthereumChain",params:[{chainId:`0x${t.toString(16)}`,chainName:e,rpcUrls:n,nativeCurrency:i,blockExplorerUrls:s}]})}async getChainId(){const t=await window.ethereum.request({method:"eth_chainId"});return parseInt(t,16)}static async connect(t){if(!Dl.isInstalled())throw new Error("MetaMask not installed");I0=I0||_9();const e=await I0,n=new Pl(e),i=new Dl(n);return n.setMetaMask(i),t&&t(i),i}async getBalance(){return await window.ethereum.request({method:"eth_getBalance",params:[this.wallet.address,"latest"]}).then(t=>t)}static isInstalled(){return!!window.ethereum}static isConnected(){return!!(window.ethereum&&window.ethereum.selectedAddress)}}async function _9(){return(await window.ethereum.request({method:"eth_requestAccounts"}))[0]}class AE{static async getFee(t,e){const{error:n,fee:i}=await YA({network:t,address:e});if(n)throw new Error(n);return i}static async setFee(t,e,n){const{error:i,to:s,data:a,chainId:l}=await ZA({network:e,fee:n});if(i)throw new Error(i);return t.sendTransaction({to:s,data:a,chainId:l})}}class Tl{data;constructor(t){this.data=t}get url(){return this.data.url}get address(){return this.data.address}get network(){return this.data.network}get id(){return this.data.id}get json(){return JSON.stringify(this.data)}async delete(){const{error:t,ok:e}=await o5(this.id);if(t)throw new Error(t);return e}async save(){const{error:t}=await s5(this.id,{url:this.url,network:this.network,address:this.address});if(t)throw new Error(t)}static async create(t,e,n){const{error:i,webhook:s}=await n5({url:e,network:t,address:n});if(i)throw new Error(i);return new Tl(s)}static async search(t,e){const{error:n,webhooks:i}=await i5({network:t,address:e});if(n)throw new Error(n);return i.map(s=>new Tl(s))}}const A9={Invoice:Ui,Subscription:Bi,Wallet:Pl,MetaMask:Dl,WalletConnect:Ht,Erc20:ia,setAuthToken:X1,Merchant:AE,Webhook:Tl,Network:ts};/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const Nh=window,C0=Nh.ShadowRoot&&(Nh.ShadyCSS===void 0||Nh.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,S0=Symbol(),xE=new WeakMap;let IE=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==S0)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(C0&&t===void 0){const n=e!==void 0&&e.length===1;n&&(t=xE.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&xE.set(e,t))}return t}toString(){return this.cssText}};const x9=r=>new IE(typeof r=="string"?r:r+"",void 0,S0),Ie=(r,...t)=>{const e=r.length===1?r[0]:t.reduce((n,i,s)=>n+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+r[s+1],r[0]);return new IE(e,r,S0)},I9=(r,t)=>{C0?r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const n=document.createElement("style"),i=Nh.litNonce;i!==void 0&&n.setAttribute("nonce",i),n.textContent=e.cssText,r.appendChild(n)})},CE=C0?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return x9(e)})(r):r;/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */var O0;const Rh=window,SE=Rh.trustedTypes,C9=SE?SE.emptyScript:"",OE=Rh.reactiveElementPolyfillSupport,P0={toAttribute(r,t){switch(t){case Boolean:r=r?C9:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},PE=(r,t)=>t!==r&&(t==t||r==r),D0={attribute:!0,type:String,converter:P0,reflect:!1,hasChanged:PE},T0="finalized";let Ba=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),((e=this.h)!==null&&e!==void 0?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((e,n)=>{const i=this._$Ep(n,e);i!==void 0&&(this._$Ev.set(i,n),t.push(i))}),t}static createProperty(t,e=D0){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const n=typeof t=="symbol"?Symbol():"__"+t,i=this.getPropertyDescriptor(t,n,e);i!==void 0&&Object.defineProperty(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){return{get(){return this[e]},set(i){const s=this[t];this[e]=i,this.requestUpdate(t,s,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||D0}static finalize(){if(this.hasOwnProperty(T0))return!1;this[T0]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,n=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of n)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const i of n)e.unshift(CE(i))}else t!==void 0&&e.push(CE(t));return e}static _$Ep(t,e){const n=e.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(e=>e(this))}addController(t){var e,n;((e=this._$ES)!==null&&e!==void 0?e:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((n=t.hostConnected)===null||n===void 0||n.call(t))}removeController(t){var e;(e=this._$ES)===null||e===void 0||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])})}createRenderRoot(){var t;const e=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return I9(e,this.constructor.elementStyles),e}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(e=>{var n;return(n=e.hostConnected)===null||n===void 0?void 0:n.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(e=>{var n;return(n=e.hostDisconnected)===null||n===void 0?void 0:n.call(e)})}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$EO(t,e,n=D0){var i;const s=this.constructor._$Ep(t,n);if(s!==void 0&&n.reflect===!0){const a=(((i=n.converter)===null||i===void 0?void 0:i.toAttribute)!==void 0?n.converter:P0).toAttribute(e,n.type);this._$El=t,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$El=null}}_$AK(t,e){var n;const i=this.constructor,s=i._$Ev.get(t);if(s!==void 0&&this._$El!==s){const a=i.getPropertyOptions(s),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)===null||n===void 0?void 0:n.fromAttribute)!==void 0?a.converter:P0;this._$El=s,this[s]=l.fromAttribute(e,a.type),this._$El=null}}requestUpdate(t,e,n){let i=!0;t!==void 0&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||PE)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),n.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,n))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((i,s)=>this[s]=i),this._$Ei=void 0);let e=!1;const n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var s;return(s=i.hostUpdate)===null||s===void 0?void 0:s.call(i)}),this.update(n)):this._$Ek()}catch(i){throw e=!1,this._$Ek(),i}e&&this._$AE(n)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)===null||e===void 0||e.forEach(n=>{var i;return(i=n.hostUpdated)===null||i===void 0?void 0:i.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((e,n)=>this._$EO(n,this[n],e)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Ba[T0]=!0,Ba.elementProperties=new Map,Ba.elementStyles=[],Ba.shadowRootOptions={mode:"open"},OE?.({ReactiveElement:Ba}),((O0=Rh.reactiveElementVersions)!==null&&O0!==void 0?O0:Rh.reactiveElementVersions=[]).push("1.6.3");/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */var N0;const Lh=window,Fa=Lh.trustedTypes,DE=Fa?Fa.createPolicy("lit-html",{createHTML:r=>r}):void 0,R0="$lit$",Ms=`lit$${(Math.random()+"").slice(9)}$`,TE="?"+Ms,S9=`<${TE}>`,Lo=document,Nl=()=>Lo.createComment(""),Rl=r=>r===null||typeof r!="object"&&typeof r!="function",NE=Array.isArray,O9=r=>NE(r)||typeof r?.[Symbol.iterator]=="function",L0=`[ \f\r]`,Ll=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,RE=/-->/g,LE=/>/g,$o=RegExp(`>|${L0}(?:([^\\s"'>=/]+)(${L0}*=${L0}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),$E=/'/g,kE=/"/g,UE=/^(?:script|style|textarea|title)$/i,BE=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),ft=BE(1),ir=BE(2),ko=Symbol.for("lit-noChange"),Nr=Symbol.for("lit-nothing"),FE=new WeakMap,Uo=Lo.createTreeWalker(Lo,129,null,!1);function ME(r,t){if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return DE!==void 0?DE.createHTML(t):t}const P9=(r,t)=>{const e=r.length-1,n=[];let i,s=t===2?"":"",a=Ll;for(let l=0;l"?(a=i??Ll,w=-1):d[1]===void 0?w=-2:(w=a.lastIndex-d[2].length,f=d[1],a=d[3]===void 0?$o:d[3]==='"'?kE:$E):a===kE||a===$E?a=$o:a===RE||a===LE?a=Ll:(a=$o,i=void 0);const b=a===$o&&r[l+1].startsWith("/>")?" ":"";s+=a===Ll?u+S9:w>=0?(n.push(f),u.slice(0,w)+R0+u.slice(w)+Ms+b):u+Ms+(w===-2?(n.push(void 0),l):b)}return[ME(r,s+(r[e]||"")+(t===2?"":"")),n]};class $l{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let s=0,a=0;const l=t.length-1,u=this.parts,[f,d]=P9(t,e);if(this.el=$l.createElement(f,n),Uo.currentNode=this.el.content,e===2){const w=this.el.content,m=w.firstChild;m.remove(),w.append(...m.childNodes)}for(;(i=Uo.nextNode())!==null&&u.length0){i.textContent=Fa?Fa.emptyScript:"";for(let b=0;b2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Nr}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,n,i){const s=this.strings;let a=!1;if(s===void 0)t=Ma(this,t,e,0),a=!Rl(t)||t!==this._$AH&&t!==ko,a&&(this._$AH=t);else{const l=t;let u,f;for(t=s[0],u=0;u{var n,i;const s=(n=e?.renderBefore)!==null&&n!==void 0?n:t;let a=s._$litPart$;if(a===void 0){const l=(i=e?.renderBefore)!==null&&i!==void 0?i:null;s._$litPart$=a=new kl(t.insertBefore(Nl(),l),l,void 0,e??{})}return a._$AI(r),a};/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */var $0,k0;class ie extends Ba{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const n=super.createRenderRoot();return(t=(e=this.renderOptions).renderBefore)!==null&&t!==void 0||(e.renderBefore=n.firstChild),n}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=k9(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return ko}}ie.finalized=!0,ie._$litElement$=!0,($0=globalThis.litElementHydrateSupport)===null||$0===void 0||$0.call(globalThis,{LitElement:ie});const HE=globalThis.litElementPolyfillSupport;HE?.({LitElement:ie}),((k0=globalThis.litElementVersions)!==null&&k0!==void 0?k0:globalThis.litElementVersions=[]).push("3.3.3");/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const we=r=>t=>typeof t=="function"?((e,n)=>(customElements.define(e,n),n))(r,t):((e,n)=>{const{kind:i,elements:s}=n;return{kind:i,elements:s,finisher(a){customElements.define(e,a)}}})(r,t);/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const U9=(r,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(e){e.createProperty(t.key,r)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,r)}},B9=(r,t,e)=>{t.constructor.createProperty(e,r)};function Qt(r){return(t,e)=>e!==void 0?B9(r,t,e):U9(r,t)}/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */function _n(r){return Qt({...r,state:!0})}/** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */var U0;((U0=window.HTMLSlotElement)===null||U0===void 0?void 0:U0.prototype.assignedElements)!=null;/** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const F9={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},M9=r=>(...t)=>({_$litDirective$:r,values:t});class j9{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,n){this._$Ct=t,this._$AM=e,this._$Ci=n}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}/** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const es=M9(class extends j9{constructor(r){var t;if(super(r),r.type!==F9.ATTRIBUTE||r.name!=="class"||((t=r.strings)===null||t===void 0?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return" "+Object.keys(r).filter(t=>r[t]).join(" ")+" "}update(r,[t]){var e,n;if(this.it===void 0){this.it=new Set,r.strings!==void 0&&(this.nt=new Set(r.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(const s in t)t[s]&&!(!((e=this.nt)===null||e===void 0)&&e.has(s))&&this.it.add(s);return this.render(t)}const i=r.element.classList;this.it.forEach(s=>{s in t||(i.remove(s),this.it.delete(s))});for(const s in t){const a=!!t[s];a===this.it.has(s)||!((n=this.nt)===null||n===void 0)&&n.has(s)||(a?(i.add(s),this.it.add(s)):(i.remove(s),this.it.delete(s)))}return ko}});function H9(r,t){r.indexOf(t)===-1&&r.push(t)}const zE=(r,t,e)=>Math.min(Math.max(e,r),t),Xn={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},kh=r=>typeof r=="number",ja=r=>Array.isArray(r)&&!kh(r[0]),z9=(r,t,e)=>{const n=t-r;return((e-r)%n+n)%n+r};function V9(r,t){return ja(r)?r[z9(0,r.length,t)]:r}const VE=(r,t,e)=>-e*r+e*t+r,GE=()=>{},js=r=>r,B0=(r,t,e)=>t-r===0?1:(e-r)/(t-r);function qE(r,t){const e=r[r.length-1];for(let n=1;n<=t;n++){const i=B0(0,t,n);r.push(VE(e,1,i))}}function G9(r){const t=[0];return qE(t,r-1),t}function q9(r,t=G9(r.length),e=js){const n=r.length,i=n-t.length;return i>0&&qE(t,i),s=>{let a=0;for(;aArray.isArray(r)&&kh(r[0]),F0=r=>typeof r=="object"&&!!r.createAnimation,Ha=r=>typeof r=="function",W9=r=>typeof r=="string",Ul={ms:r=>r*1e3,s:r=>r/1e3},KE=(r,t,e)=>(((1-3*e+3*t)*r+(3*e-6*t))*r+3*t)*r,K9=1e-7,Q9=12;function J9(r,t,e,n,i){let s,a,l=0;do a=t+(e-t)/2,s=KE(a,n,i)-r,s>0?e=a:t=a;while(Math.abs(s)>K9&&++lJ9(s,0,1,r,e);return s=>s===0||s===1?s:KE(i(s),t,n)}const Y9=(r,t="end")=>e=>{e=t==="end"?Math.min(e,.999):Math.max(e,.001);const n=e*r,i=t==="end"?Math.floor(n):Math.ceil(n);return zE(0,1,i/r)},QE={ease:Bl(.25,.1,.25,1),"ease-in":Bl(.42,0,1,1),"ease-in-out":Bl(.42,0,.58,1),"ease-out":Bl(0,0,.58,1)},Z9=/\((.*?)\)/;function JE(r){if(Ha(r))return r;if(WE(r))return Bl(...r);if(QE[r])return QE[r];if(r.startsWith("steps")){const t=Z9.exec(r);if(t){const e=t[1].split(",");return Y9(parseFloat(e[0]),e[1].trim())}}return js}class YE{constructor(t,e=[0,1],{easing:n,duration:i=Xn.duration,delay:s=Xn.delay,endDelay:a=Xn.endDelay,repeat:l=Xn.repeat,offset:u,direction:f="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=js,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((w,m)=>{this.resolve=w,this.reject=m}),n=n||Xn.easing,F0(n)){const w=n.createAnimation(e);n=w.easing,e=w.keyframes||e,i=w.duration||i}this.repeat=l,this.easing=ja(n)?js:JE(n),this.updateDuration(i);const d=q9(e,u,ja(n)?n.map(JE):js);this.tick=w=>{var m;s=s;let b=0;this.pauseTime!==void 0?b=this.pauseTime:b=(w-this.startTime)*this.rate,this.t=b,b/=1e3,b=Math.max(b-s,0),this.playState==="finished"&&this.pauseTime===void 0&&(b=this.totalDuration);const E=b/this.duration;let C=Math.floor(E),R=E%1;!R&&E>=1&&(R=1),R===1&&C--;const k=C%2;(f==="reverse"||f==="alternate"&&k||f==="alternate-reverse"&&!k)&&(R=1-R);const D=b>=this.totalDuration?1:Math.min(R,1),P=d(this.easing(D));t(P),this.pauseTime===void 0&&(this.playState==="finished"||b>=this.totalDuration+a)?(this.playState="finished",(m=this.resolve)===null||m===void 0||m.call(this,P)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(t=this.reject)===null||t===void 0||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){this.pauseTime!==void 0||this.rate===0?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}var M0=function(){};Qn.env.NODE_ENV!=="production"&&(M0=function(r,t){if(!r)throw new Error(t)});class X9{setAnimation(t){this.animation=t,t?.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}const j0=new WeakMap;function ZE(r){return j0.has(r)||j0.set(r,{transforms:[],values:new Map}),j0.get(r)}function tL(r,t){return r.has(t)||r.set(t,new X9),r.get(t)}const eL=["","X","Y","Z"],rL=["translate","scale","rotate","skew"],Uh={x:"translateX",y:"translateY",z:"translateZ"},XE={syntax:"",initialValue:"0deg",toDefaultUnit:r=>r+"deg"},nL={translate:{syntax:"",initialValue:"0px",toDefaultUnit:r=>r+"px"},rotate:XE,scale:{syntax:"",initialValue:1,toDefaultUnit:js},skew:XE},Fl=new Map,H0=r=>`--motion-${r}`,Bh=["x","y","z"];rL.forEach(r=>{eL.forEach(t=>{Bh.push(r+t),Fl.set(H0(r+t),nL[r])})});const iL=(r,t)=>Bh.indexOf(r)-Bh.indexOf(t),sL=new Set(Bh),t3=r=>sL.has(r),oL=(r,t)=>{Uh[t]&&(t=Uh[t]);const{transforms:e}=ZE(r);H9(e,t),r.style.transform=aL(e)},aL=r=>r.sort(iL).reduce(cL,"").trim(),cL=(r,t)=>`${r} ${t}(var(${H0(t)}))`,z0=r=>r.startsWith("--"),e3=new Set;function lL(r){if(!e3.has(r)){e3.add(r);try{const{syntax:t,initialValue:e}=Fl.has(r)?Fl.get(r):{};CSS.registerProperty({name:r,inherits:!1,syntax:t,initialValue:e})}catch{}}}const V0=(r,t)=>document.createElement("div").animate(r,t),r3={cssRegisterProperty:()=>typeof CSS<"u"&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{V0({opacity:[1]})}catch{return!1}return!0},finished:()=>!!V0({opacity:[0,1]},{duration:.001}).finished,linearEasing:()=>{try{V0({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0}},G0={},za={};for(const r in r3)za[r]=()=>(G0[r]===void 0&&(G0[r]=r3[r]()),G0[r]);const uL=.015,hL=(r,t)=>{let e="";const n=Math.round(t/uL);for(let i=0;iHa(r)?za.linearEasing()?`linear(${hL(r,t)})`:Xn.easing:WE(r)?fL(r):r,fL=([r,t,e,n])=>`cubic-bezier(${r}, ${t}, ${e}, ${n})`;function dL(r,t){for(let e=0;eArray.isArray(r)?r:[r];function q0(r){return Uh[r]&&(r=Uh[r]),t3(r)?H0(r):r}const Fh={get:(r,t)=>{t=q0(t);let e=z0(t)?r.style.getPropertyValue(t):getComputedStyle(r)[t];if(!e&&e!==0){const n=Fl.get(t);n&&(e=n.initialValue)}return e},set:(r,t,e)=>{t=q0(t),z0(t)?r.style.setProperty(t,e):r.style[t]=e}};function i3(r,t=!0){if(!(!r||r.playState==="finished"))try{r.stop?r.stop():(t&&r.commitStyles(),r.cancel())}catch{}}function gL(r,t){var e;let n=t?.toDefaultUnit||js;const i=r[r.length-1];if(W9(i)){const s=((e=i.match(/(-?[\d.]+)([a-z%]*)/))===null||e===void 0?void 0:e[2])||"";s&&(n=a=>a+s)}return n}function mL(){return window.__MOTION_DEV_TOOLS_RECORD}function wL(r,t,e,n={},i){const s=mL(),a=n.record!==!1&&s;let l,{duration:u=Xn.duration,delay:f=Xn.delay,endDelay:d=Xn.endDelay,repeat:w=Xn.repeat,easing:m=Xn.easing,persist:b=!1,direction:E,offset:C,allowWebkitAcceleration:R=!1}=n;const k=ZE(r),D=t3(t);let P=za.waapi();D&&oL(r,t);const I=q0(t),T=tL(k.values,I),A=Fl.get(I);return i3(T.animation,!(F0(m)&&T.generator)&&n.record!==!1),()=>{const p=()=>{var F,K;return(K=(F=Fh.get(r,I))!==null&&F!==void 0?F:A?.initialValue)!==null&&K!==void 0?K:0};let _=dL(pL(e),p);const M=gL(_,A);if(F0(m)){const F=m.createAnimation(_,t!=="opacity",p,I,T);m=F.easing,_=F.keyframes||_,u=F.duration||u}if(z0(I)&&(za.cssRegisterProperty()?lL(I):P=!1),D&&!za.linearEasing()&&(Ha(m)||ja(m)&&m.some(Ha))&&(P=!1),P){A&&(_=_.map(st=>kh(st)?A.toDefaultUnit(st):st)),_.length===1&&(!za.partialKeyframes()||a)&&_.unshift(p());const F={delay:Ul.ms(f),duration:Ul.ms(u),endDelay:Ul.ms(d),easing:ja(m)?void 0:n3(m,u),direction:E,iterations:w+1,fill:"both"};l=r.animate({[I]:_,offset:C,easing:ja(m)?m.map(st=>n3(st,u)):void 0},F),l.finished||(l.finished=new Promise((st,lt)=>{l.onfinish=st,l.oncancel=lt}));const K=_[_.length-1];l.finished.then(()=>{b||(Fh.set(r,I,K),l.cancel())}).catch(GE),R||(l.playbackRate=1.000001)}else if(i&&D)_=_.map(F=>typeof F=="string"?parseFloat(F):F),_.length===1&&_.unshift(parseFloat(p())),l=new i(F=>{Fh.set(r,I,M?M(F):F)},_,Object.assign(Object.assign({},n),{duration:u,easing:m}));else{const F=_[_.length-1];Fh.set(r,I,A&&kh(F)?A.toDefaultUnit(F):F)}return a&&s(r,t,_,{duration:u,delay:f,easing:m,repeat:w,offset:C},"motion-one"),T.setAnimation(l),l}}const yL=(r,t)=>r[t]?Object.assign(Object.assign({},r),r[t]):Object.assign({},r);function bL(r,t){var e;return typeof r=="string"?t?((e=t[r])!==null&&e!==void 0||(t[r]=document.querySelectorAll(r)),r=t[r]):r=document.querySelectorAll(r):r instanceof Element&&(r=[r]),Array.from(r||[])}const vL=r=>r(),s3=(r,t,e=Xn.duration)=>new Proxy({animations:r.map(vL).filter(Boolean),duration:e,options:t},_L),EL=r=>r.animations[0],_L={get:(r,t)=>{const e=EL(r);switch(t){case"duration":return r.duration;case"currentTime":return Ul.s(e?.[t]||0);case"playbackRate":case"playState":return e?.[t];case"finished":return r.finished||(r.finished=Promise.all(r.animations.map(AL)).catch(GE)),r.finished;case"stop":return()=>{r.animations.forEach(n=>i3(n))};case"forEachNative":return n=>{r.animations.forEach(i=>n(i,r))};default:return typeof e?.[t]>"u"?void 0:()=>r.animations.forEach(n=>n[t]())}},set:(r,t,e)=>{switch(t){case"currentTime":e=Ul.ms(e);case"currentTime":case"playbackRate":for(let n=0;nr.finished;function xL(r,t,e){return Ha(r)?r(t,e):r}function IL(r){return function(e,n,i={}){e=bL(e);const s=e.length;M0(!!s,"No valid element provided."),M0(!!n,"No keyframes defined.");const a=[];for(let l=0;l{const e=new YE(r,[0,1],t);return e.finished.catch(()=>{}),e}],t,t.duration)}function Bo(r,t,e){return(Ha(r)?SL:CL)(r,t,e)}/** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const sn=r=>r??Nr;var Ml={},OL=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},o3={},Bn={};let W0;const PL=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Bn.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},Bn.getSymbolTotalCodewords=function(t){return PL[t]},Bn.getBCHDigit=function(r){let t=0;for(;r!==0;)t++,r>>>=1;return t},Bn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');W0=t},Bn.isKanjiModeEnabled=function(){return typeof W0<"u"},Bn.toSJIS=function(t){return W0(t)};var Mh={};(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function t(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+e)}}r.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},r.from=function(n,i){if(r.isValid(n))return n;try{return t(n)}catch{return i}}})(Mh);function a3(){this.buffer=[],this.length=0}a3.prototype={get:function(r){const t=Math.floor(r/8);return(this.buffer[t]>>>7-r%8&1)===1},put:function(r,t){for(let e=0;e>>t-e-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),r&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var DL=a3;function jl(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}jl.prototype.set=function(r,t,e,n){const i=r*this.size+t;this.data[i]=e,n&&(this.reservedBit[i]=!0)},jl.prototype.get=function(r,t){return this.data[r*this.size+t]},jl.prototype.xor=function(r,t,e){this.data[r*this.size+t]^=e},jl.prototype.isReserved=function(r,t){return this.reservedBit[r*this.size+t]};var TL=jl,c3={};(function(r){const t=Bn.getSymbolSize;r.getRowColCoords=function(n){if(n===1)return[];const i=Math.floor(n/7)+2,s=t(n),a=s===145?26:Math.ceil((s-13)/(2*i-2))*2,l=[s-7];for(let u=1;u=0&&i<=7},r.from=function(i){return r.isValid(i)?parseInt(i,10):void 0},r.getPenaltyN1=function(i){const s=i.size;let a=0,l=0,u=0,f=null,d=null;for(let w=0;w=5&&(a+=t.N1+(l-5)),f=b,l=1),b=i.get(m,w),b===d?u++:(u>=5&&(a+=t.N1+(u-5)),d=b,u=1)}l>=5&&(a+=t.N1+(l-5)),u>=5&&(a+=t.N1+(u-5))}return a},r.getPenaltyN2=function(i){const s=i.size;let a=0;for(let l=0;l=10&&(l===1488||l===93)&&a++,u=u<<1&2047|i.get(d,f),d>=10&&(u===1488||u===93)&&a++}return a*t.N3},r.getPenaltyN4=function(i){let s=0;const a=i.data.length;for(let u=0;u=0;){const a=s[0];for(let u=0;u0){const s=new Uint8Array(this.degree);return s.set(n,i),s}return n};var RL=K0,p3={},zs={},Q0={};Q0.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var Oi={};const g3="[0-9]+",LL="[A-Z $%*+\\-./:]+";let zl="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";zl=zl.replace(/u/g,"\\u");const $L="(?:(?![A-Z0-9 $%*+\\-./:]|"+zl+`)(?:.|[\r ]))+`;Oi.KANJI=new RegExp(zl,"g"),Oi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Oi.BYTE=new RegExp($L,"g"),Oi.NUMERIC=new RegExp(g3,"g"),Oi.ALPHANUMERIC=new RegExp(LL,"g");const kL=new RegExp("^"+zl+"$"),UL=new RegExp("^"+g3+"$"),BL=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Oi.testKanji=function(t){return kL.test(t)},Oi.testNumeric=function(t){return UL.test(t)},Oi.testAlphanumeric=function(t){return BL.test(t)},function(r){const t=Q0,e=Oi;r.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},r.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},r.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},r.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},r.MIXED={bit:-1},r.getCharCountIndicator=function(s,a){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?s.ccBits[0]:a<27?s.ccBits[1]:s.ccBits[2]},r.getBestModeForData=function(s){return e.testNumeric(s)?r.NUMERIC:e.testAlphanumeric(s)?r.ALPHANUMERIC:e.testKanji(s)?r.KANJI:r.BYTE},r.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},r.isValid=function(s){return s&&s.bit&&s.ccBits};function n(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return r.NUMERIC;case"alphanumeric":return r.ALPHANUMERIC;case"kanji":return r.KANJI;case"byte":return r.BYTE;default:throw new Error("Unknown mode: "+i)}}r.from=function(s,a){if(r.isValid(s))return s;try{return n(s)}catch{return a}}}(zs),function(r){const t=Bn,e=jh,n=Mh,i=zs,s=Q0,a=7973,l=t.getBCHDigit(a);function u(m,b,E){for(let C=1;C<=40;C++)if(b<=r.getCapacity(C,E,m))return C}function f(m,b){return i.getCharCountIndicator(m,b)+4}function d(m,b){let E=0;return m.forEach(function(C){const R=f(C.mode,b);E+=R+C.getBitsLength()}),E}function w(m,b){for(let E=1;E<=40;E++)if(d(m,E)<=r.getCapacity(E,b,i.MIXED))return E}r.from=function(b,E){return s.isValid(b)?parseInt(b,10):E},r.getCapacity=function(b,E,C){if(!s.isValid(b))throw new Error("Invalid QR Code version");typeof C>"u"&&(C=i.BYTE);const R=t.getSymbolTotalCodewords(b),k=e.getTotalCodewordsCount(b,E),D=(R-k)*8;if(C===i.MIXED)return D;const P=D-f(C,b);switch(C){case i.NUMERIC:return Math.floor(P/10*3);case i.ALPHANUMERIC:return Math.floor(P/11*2);case i.KANJI:return Math.floor(P/13);case i.BYTE:default:return Math.floor(P/8)}},r.getBestVersionForData=function(b,E){let C;const R=n.from(E,n.M);if(Array.isArray(b)){if(b.length>1)return w(b,R);if(b.length===0)return 1;C=b[0]}else C=b;return u(C.mode,C.getLength(),R)},r.getEncodedBits=function(b){if(!s.isValid(b)||b<7)throw new Error("Invalid QR Code version");let E=b<<12;for(;t.getBCHDigit(E)-l>=0;)E^=a<=0;)i^=w3<0&&(n=this.data.substr(e),i=parseInt(n,10),t.put(i,s*3+1))};var jL=Va;const HL=zs,Y0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ga(r){this.mode=HL.ALPHANUMERIC,this.data=r}Ga.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)},Ga.prototype.getLength=function(){return this.data.length},Ga.prototype.getBitsLength=function(){return Ga.getBitsLength(this.data.length)},Ga.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=Y0.indexOf(this.data[e])*45;n+=Y0.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(Y0.indexOf(this.data[e]),6)};var zL=Ga,VL=function(t){for(var e=[],n=t.length,i=0;i=55296&&s<=56319&&n>i+1){var a=t.charCodeAt(i+1);a>=56320&&a<=57343&&(s=(s-55296)*1024+a-56320+65536,i+=1)}if(s<128){e.push(s);continue}if(s<2048){e.push(s>>6|192),e.push(s&63|128);continue}if(s<55296||s>=57344&&s<65536){e.push(s>>12|224),e.push(s>>6&63|128),e.push(s&63|128);continue}if(s>=65536&&s<=1114111){e.push(s>>18|240),e.push(s>>12&63|128),e.push(s>>6&63|128),e.push(s&63|128);continue}e.push(239,191,189)}return new Uint8Array(e).buffer};const GL=VL,qL=zs;function qa(r){this.mode=qL.BYTE,typeof r=="string"&&(r=GL(r)),this.data=new Uint8Array(r)}qa.getBitsLength=function(t){return t*8},qa.prototype.getLength=function(){return this.data.length},qa.prototype.getBitsLength=function(){return qa.getBitsLength(this.data.length)},qa.prototype.write=function(r){for(let t=0,e=this.data.length;t=33088&&e<=40956)e-=33088;else if(e>=57408&&e<=60351)e-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` Make sure your charset is UTF-8`);e=(e>>>8&255)*192+(e&255),r.put(e,13)}};var JL=Wa,v3={exports:{}};(function(r){var t={single_source_shortest_paths:function(e,n,i){var s={},a={};a[n]=0;var l=t.PriorityQueue.make();l.push(n,0);for(var u,f,d,w,m,b,E,C,R;!l.empty();){u=l.pop(),f=u.value,w=u.cost,m=e[f]||{};for(d in m)m.hasOwnProperty(d)&&(b=m[d],E=w+b,C=a[d],R=typeof a[d]>"u",(R||C>E)&&(a[d]=E,l.push(d,E),s[d]=f))}if(typeof i<"u"&&typeof a[i]>"u"){var k=["Could not find a path from ",n," to ",i,"."].join("");throw new Error(k)}return s},extract_shortest_path_from_predecessor_list:function(e,n){for(var i=[],s=n;s;)i.push(s),e[s],s=e[s];return i.reverse(),i},find_path:function(e,n,i){var s=t.single_source_shortest_paths(e,n,i);return t.extract_shortest_path_from_predecessor_list(s,i)},PriorityQueue:{make:function(e){var n=t.PriorityQueue,i={},s;e=e||{};for(s in n)n.hasOwnProperty(s)&&(i[s]=n[s]);return i.queue=[],i.sorter=e.sorter||n.default_sorter,i},default_sorter:function(e,n){return e.cost-n.cost},push:function(e,n){var i={value:e,cost:n};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};r.exports=t})(v3);var YL=v3.exports;(function(r){const t=zs,e=jL,n=zL,i=WL,s=JL,a=Oi,l=Bn,u=YL;function f(k){return unescape(encodeURIComponent(k)).length}function d(k,D,P){const I=[];let T;for(;(T=k.exec(P))!==null;)I.push({data:T[0],index:T.index,mode:D,length:T[0].length});return I}function w(k){const D=d(a.NUMERIC,t.NUMERIC,k),P=d(a.ALPHANUMERIC,t.ALPHANUMERIC,k);let I,T;return l.isKanjiModeEnabled()?(I=d(a.BYTE,t.BYTE,k),T=d(a.KANJI,t.KANJI,k)):(I=d(a.BYTE_KANJI,t.BYTE,k),T=[]),D.concat(P,I,T).sort(function(p,_){return p.index-_.index}).map(function(p){return{data:p.data,mode:p.mode,length:p.length}})}function m(k,D){switch(D){case t.NUMERIC:return e.getBitsLength(k);case t.ALPHANUMERIC:return n.getBitsLength(k);case t.KANJI:return s.getBitsLength(k);case t.BYTE:return i.getBitsLength(k)}}function b(k){return k.reduce(function(D,P){const I=D.length-1>=0?D[D.length-1]:null;return I&&I.mode===P.mode?(D[D.length-1].data+=P.data,D):(D.push(P),D)},[])}function E(k){const D=[];for(let P=0;P=0&&l<=6&&(u===0||u===6)||u>=0&&u<=6&&(l===0||l===6)||l>=2&&l<=4&&u>=2&&u<=4?r.set(s+l,a+u,!0,!0):r.set(s+l,a+u,!1,!0))}}function o$(r){const t=r.size;for(let e=8;e>l&1)===1,r.set(i,s,a,!0),r.set(s,i,a,!0)}function rg(r,t,e){const n=r.size,i=n$.getEncodedBits(t,e);let s,a;for(s=0;s<15;s++)a=(i>>s&1)===1,s<6?r.set(s,8,a,!0):s<8?r.set(s+1,8,a,!0):r.set(n-15+s,8,a,!0),s<8?r.set(8,n-s-1,a,!0):s<9?r.set(8,15-s-1+1,a,!0):r.set(8,15-s-1,a,!0);r.set(n-8,8,1,!0)}function l$(r,t){const e=r.size;let n=-1,i=e-1,s=7,a=0;for(let l=e-1;l>0;l-=2)for(l===6&&l--;;){for(let u=0;u<2;u++)if(!r.isReserved(i,l-u)){let f=!1;a>>s&1)===1),r.set(i,l-u,f),s--,s===-1&&(a++,s=7)}if(i+=n,i<0||e<=i){i-=n,n=-n;break}}}function u$(r,t,e){const n=new ZL;e.forEach(function(u){n.put(u.mode.bit,4),n.put(u.getLength(),i$.getCharCountIndicator(u.mode,r)),u.write(n)});const i=qh.getSymbolTotalCodewords(r),s=tg.getTotalCodewordsCount(r,t),a=(i-s)*8;for(n.getLengthInBits()+4<=a&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(0);const l=(a-n.getLengthInBits())/8;for(let u=0;u=7&&c$(u,t),l$(u,a),isNaN(n)&&(n=X0.getBestMask(u,rg.bind(null,u,e))),X0.applyMask(n,u),rg(u,e,n),{modules:u,version:t,errorCorrectionLevel:e,maskPattern:n,segments:i}}o3.create=function(t,e){if(typeof t>"u"||t==="")throw new Error("No input text");let n=Z0.M,i,s;return typeof e<"u"&&(n=Z0.from(e.errorCorrectionLevel,Z0.M),i=Wh.from(e.version),s=X0.from(e.maskPattern),e.toSJISFunc&&qh.setToSJISFunction(e.toSJISFunc)),f$(t,i,n,s)};var E3={},ng={};(function(r){function t(e){if(typeof e=="number"&&(e=e.toString()),typeof e!="string")throw new Error("Color should be defined as hex string");let n=e.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+e);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(s){return[s,s]}))),n.length===6&&n.push("F","F");const i=parseInt(n.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+n.slice(0,6).join("")}}r.getOptions=function(n){n||(n={}),n.color||(n.color={});const i=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,s=n.width&&n.width>=21?n.width:void 0,a=n.scale||4;return{width:s,scale:s?4:a,margin:i,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},r.getScale=function(n,i){return i.width&&i.width>=n+i.margin*2?i.width/(n+i.margin*2):i.scale},r.getImageWidth=function(n,i){const s=r.getScale(n,i);return Math.floor((n+i.margin*2)*s)},r.qrToImageData=function(n,i,s){const a=i.modules.size,l=i.modules.data,u=r.getScale(a,s),f=Math.floor((a+s.margin*2)*u),d=s.margin*u,w=[s.color.light,s.color.dark];for(let m=0;m=d&&b>=d&&m"u"&&(!a||!a.getContext)&&(u=a,a=void 0),a||(f=n()),u=t.getOptions(u);const d=t.getImageWidth(s.modules.size,u),w=f.getContext("2d"),m=w.createImageData(d,d);return t.qrToImageData(m.data,s,u),e(w,f,d),w.putImageData(m,0,0),f},r.renderToDataURL=function(s,a,l){let u=l;typeof u>"u"&&(!a||!a.getContext)&&(u=a,a=void 0),u||(u={});const f=r.render(s,a,u),d=u.type||"image/png",w=u.rendererOpts||{};return f.toDataURL(d,w.quality)}}(E3);var _3={};const d$=ng;function A3(r,t){const e=r.a/255,n=t+'="'+r.hex+'"';return e<1?n+" "+t+'-opacity="'+e.toFixed(2).slice(1)+'"':n}function ig(r,t,e){let n=r+t;return typeof e<"u"&&(n+=" "+e),n}function p$(r,t,e){let n="",i=0,s=!1,a=0;for(let l=0;l0&&u>0&&r[l-1]||(n+=s?ig("M",u+e,.5+f+e):ig("m",i,0),i=0,s=!1),u+1':"",f="',d='viewBox="0 0 '+l+" "+l+'"',m=''+u+f+` `;return typeof n=="function"&&n(null,m),m};const g$=OL,sg=o3,x3=E3,m$=_3;function og(r,t,e,n,i){const s=[].slice.call(arguments,1),a=s.length,l=typeof s[a-1]=="function";if(!l&&!g$())throw new Error("Callback required as last argument");if(l){if(a<2)throw new Error("Too few arguments provided");a===2?(i=e,e=t,t=n=void 0):a===3&&(t.getContext&&typeof i>"u"?(i=n,n=void 0):(i=n,n=e,e=t,t=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(e=t,t=n=void 0):a===2&&!t.getContext&&(n=e,e=t,t=void 0),new Promise(function(u,f){try{const d=sg.create(e,n);u(r(d,t,n))}catch(d){f(d)}})}try{const u=sg.create(e,n);i(null,r(u,t,n))}catch(u){i(u)}}Ml.create=sg.create,Ml.toCanvas=og.bind(null,x3.render),Ml.toDataURL=og.bind(null,x3.renderToDataURL),Ml.toString=og.bind(null,function(r,t,e){return m$.render(r,e)});var w$=Object.defineProperty,I3=Object.getOwnPropertySymbols,y$=Object.prototype.hasOwnProperty,b$=Object.prototype.propertyIsEnumerable,C3=(r,t,e)=>t in r?w$(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ag=(r,t)=>{for(var e in t||(t={}))y$.call(t,e)&&C3(r,e,t[e]);if(I3)for(var e of I3(t))b$.call(t,e)&&C3(r,e,t[e]);return r};function v$(){var r;const t=(r=Ts.state.themeMode)!=null?r:"dark",e={light:{foreground:{1:"rgb(20,20,20)",2:"rgb(121,134,134)",3:"rgb(158,169,169)"},background:{1:"rgb(255,255,255)",2:"rgb(241,243,243)",3:"rgb(228,231,231)"},overlay:"rgba(0,0,0,0.1)"},dark:{foreground:{1:"rgb(228,231,231)",2:"rgb(148,158,158)",3:"rgb(110,119,119)"},background:{1:"rgb(20,20,20)",2:"rgb(39,42,42)",3:"rgb(59,64,64)"},overlay:"rgba(255,255,255,0.1)"}}[t];return{"--wcm-color-fg-1":e.foreground[1],"--wcm-color-fg-2":e.foreground[2],"--wcm-color-fg-3":e.foreground[3],"--wcm-color-bg-1":e.background[1],"--wcm-color-bg-2":e.background[2],"--wcm-color-bg-3":e.background[3],"--wcm-color-overlay":e.overlay}}function S3(){return{"--wcm-accent-color":"#3396FF","--wcm-accent-fill-color":"#FFFFFF","--wcm-z-index":"89","--wcm-background-color":"#3396FF","--wcm-background-border-radius":"8px","--wcm-container-border-radius":"30px","--wcm-wallet-icon-border-radius":"15px","--wcm-wallet-icon-large-border-radius":"30px","--wcm-wallet-icon-small-border-radius":"7px","--wcm-input-border-radius":"28px","--wcm-button-border-radius":"10px","--wcm-notification-border-radius":"36px","--wcm-secondary-button-border-radius":"28px","--wcm-icon-button-border-radius":"50%","--wcm-button-hover-highlight-border-radius":"10px","--wcm-text-big-bold-size":"20px","--wcm-text-big-bold-weight":"600","--wcm-text-big-bold-line-height":"24px","--wcm-text-big-bold-letter-spacing":"-0.03em","--wcm-text-big-bold-text-transform":"none","--wcm-text-xsmall-bold-size":"10px","--wcm-text-xsmall-bold-weight":"700","--wcm-text-xsmall-bold-line-height":"12px","--wcm-text-xsmall-bold-letter-spacing":"0.02em","--wcm-text-xsmall-bold-text-transform":"uppercase","--wcm-text-xsmall-regular-size":"12px","--wcm-text-xsmall-regular-weight":"600","--wcm-text-xsmall-regular-line-height":"14px","--wcm-text-xsmall-regular-letter-spacing":"-0.03em","--wcm-text-xsmall-regular-text-transform":"none","--wcm-text-small-thin-size":"14px","--wcm-text-small-thin-weight":"500","--wcm-text-small-thin-line-height":"16px","--wcm-text-small-thin-letter-spacing":"-0.03em","--wcm-text-small-thin-text-transform":"none","--wcm-text-small-regular-size":"14px","--wcm-text-small-regular-weight":"600","--wcm-text-small-regular-line-height":"16px","--wcm-text-small-regular-letter-spacing":"-0.03em","--wcm-text-small-regular-text-transform":"none","--wcm-text-medium-regular-size":"16px","--wcm-text-medium-regular-weight":"600","--wcm-text-medium-regular-line-height":"20px","--wcm-text-medium-regular-letter-spacing":"-0.03em","--wcm-text-medium-regular-text-transform":"none","--wcm-font-family":"-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif","--wcm-font-feature-settings":"'tnum' on, 'lnum' on, 'case' on","--wcm-success-color":"rgb(38,181,98)","--wcm-error-color":"rgb(242, 90, 103)","--wcm-overlay-background-color":"rgba(0, 0, 0, 0.3)","--wcm-overlay-backdrop-filter":"none"}}const fe={getPreset(r){return S3()[r]},setTheme(){const r=document.querySelector(":root"),{themeVariables:t}=Ts.state;if(r){const e=ag(ag(ag({},v$()),S3()),t);Object.entries(e).forEach(([n,i])=>r.style.setProperty(n,i))}},globalCss:Ie`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`},E$=Ie`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`;var _$=Object.defineProperty,A$=Object.getOwnPropertyDescriptor,Ka=(r,t,e,n)=>{for(var i=n>1?void 0:n?A$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&_$(t,e,i),i};let Vs=class extends ie{constructor(){super(...arguments),this.disabled=!1,this.iconLeft=void 0,this.iconRight=void 0,this.onClick=()=>null,this.variant="default"}render(){const r={"wcm-icon-left":this.iconLeft!==void 0,"wcm-icon-right":this.iconRight!==void 0,"wcm-ghost":this.variant==="ghost","wcm-outline":this.variant==="outline"};let t="inverse";return this.variant==="ghost"&&(t="secondary"),this.variant==="outline"&&(t="accent"),ft``}};Vs.styles=[fe.globalCss,E$],Ka([Qt({type:Boolean})],Vs.prototype,"disabled",2),Ka([Qt()],Vs.prototype,"iconLeft",2),Ka([Qt()],Vs.prototype,"iconRight",2),Ka([Qt()],Vs.prototype,"onClick",2),Ka([Qt()],Vs.prototype,"variant",2),Vs=Ka([we("wcm-button")],Vs);const x$=Ie`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`;var I$=Object.defineProperty,C$=Object.getOwnPropertyDescriptor,cg=(r,t,e,n)=>{for(var i=n>1?void 0:n?C$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&I$(t,e,i),i};let Vl=class extends ie{constructor(){super(...arguments),this.disabled=!1,this.variant="primary"}render(){const r={"wcm-secondary":this.variant==="secondary"};return ft``}};Vl.styles=[fe.globalCss,x$],cg([Qt({type:Boolean})],Vl.prototype,"disabled",2),cg([Qt()],Vl.prototype,"variant",2),Vl=cg([we("wcm-button-big")],Vl);const S$=Ie`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`;var O$=Object.defineProperty,P$=Object.getOwnPropertyDescriptor,D$=(r,t,e,n)=>{for(var i=n>1?void 0:n?P$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&O$(t,e,i),i};let lg=class extends ie{render(){return ft`
`}};lg.styles=[fe.globalCss,S$],lg=D$([we("wcm-info-footer")],lg);const Oe={CROSS_ICON:ir``,WALLET_CONNECT_LOGO:ir``,WALLET_CONNECT_ICON:ir``,WALLET_CONNECT_ICON_COLORED:ir``,BACK_ICON:ir``,COPY_ICON:ir``,RETRY_ICON:ir``,DESKTOP_ICON:ir``,MOBILE_ICON:ir``,ARROW_DOWN_ICON:ir``,ARROW_UP_RIGHT_ICON:ir``,ARROW_RIGHT_ICON:ir``,QRCODE_ICON:ir``,SCAN_ICON:ir``,CHECKMARK_ICON:ir``,SEARCH_ICON:ir``,WALLET_PLACEHOLDER:ir``,GLOBE_ICON:ir``},T$=Ie`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`;var N$=Object.defineProperty,R$=Object.getOwnPropertyDescriptor,L$=(r,t,e,n)=>{for(var i=n>1?void 0:n?R$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&N$(t,e,i),i};let ug=class extends ie{render(){return ft`
${Oe.WALLET_CONNECT_LOGO}
`}};ug.styles=[fe.globalCss,T$],ug=L$([we("wcm-modal-backcard")],ug);const $$=Ie`main{padding:20px;padding-top:0;width:100%}`;var k$=Object.defineProperty,U$=Object.getOwnPropertyDescriptor,B$=(r,t,e,n)=>{for(var i=n>1?void 0:n?U$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&k$(t,e,i),i};let hg=class extends ie{render(){return ft`
`}};hg.styles=[fe.globalCss,$$],hg=B$([we("wcm-modal-content")],hg);const F$=Ie`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`;var M$=Object.defineProperty,j$=Object.getOwnPropertyDescriptor,H$=(r,t,e,n)=>{for(var i=n>1?void 0:n?j$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&M$(t,e,i),i};let fg=class extends ie{render(){return ft`
`}};fg.styles=[fe.globalCss,F$],fg=H$([we("wcm-modal-footer")],fg);const z$=Ie`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`;var V$=Object.defineProperty,G$=Object.getOwnPropertyDescriptor,Gl=(r,t,e,n)=>{for(var i=n>1?void 0:n?G$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&V$(t,e,i),i};let Fo=class extends ie{constructor(){super(...arguments),this.title="",this.onAction=void 0,this.actionIcon=void 0,this.border=!1}backBtnTemplate(){return ft``}actionBtnTemplate(){return ft``}render(){const r={"wcm-border":this.border},t=Xe.state.history.length>1,e=this.title?ft`${this.title}`:ft``;return ft`
${t?this.backBtnTemplate():null} ${e} ${this.onAction?this.actionBtnTemplate():null}
`}};Fo.styles=[fe.globalCss,z$],Gl([Qt()],Fo.prototype,"title",2),Gl([Qt()],Fo.prototype,"onAction",2),Gl([Qt()],Fo.prototype,"actionIcon",2),Gl([Qt({type:Boolean})],Fo.prototype,"border",2),Fo=Gl([we("wcm-modal-header")],Fo);const Ft={MOBILE_BREAKPOINT:600,WCM_RECENT_WALLET_DATA:"WCM_RECENT_WALLET_DATA",EXPLORER_WALLET_URL:"https://explorer.walletconnect.com/?type=wallet",getShadowRootElement(r,t){const e=r.renderRoot.querySelector(t);if(!e)throw new Error(`${t} not found`);return e},getWalletIcon({id:r,image_id:t}){const{walletImages:e}=$n.state;return e!=null&&e[r]?e[r]:t?wn.getWalletImageUrl(t):""},getWalletName(r,t=!1){return t&&r.length>8?`${r.substring(0,8)}..`:r},isMobileAnimation(){return window.innerWidth<=Ft.MOBILE_BREAKPOINT},async preloadImage(r){const t=new Promise((e,n)=>{const i=new Image;i.onload=e,i.onerror=n,i.crossOrigin="anonymous",i.src=r});return Promise.race([t,xt.wait(3e3)])},getErrorMessage(r){return r instanceof Error?r.message:"Unknown Error"},debounce(r,t=500){let e;return(...n)=>{function i(){r(...n)}e&&clearTimeout(e),e=setTimeout(i,t)}},handleMobileLinking(r){const{walletConnectUri:t}=dr.state,{mobile:e,name:n}=r,i=e?.native,s=e?.universal;Ft.setRecentWallet(r);function a(l){let u="";i?u=xt.formatUniversalUrl(i,l,n):s&&(u=xt.formatNativeUrl(s,l,n)),xt.openHref(u,"_self")}t&&a(t)},handleAndroidLinking(){const{walletConnectUri:r}=dr.state;r&&(xt.setWalletConnectAndroidDeepLink(r),xt.openHref(r,"_self"))},async handleUriCopy(){const{walletConnectUri:r}=dr.state;if(r)try{await navigator.clipboard.writeText(r),Ns.openToast("Link copied","success")}catch{Ns.openToast("Failed to copy","error")}},getCustomImageUrls(){const{walletImages:r}=$n.state,t=Object.values(r??{});return Object.values(t)},truncate(r,t=8){return r.length<=t?r:`${r.substring(0,4)}...${r.substring(r.length-4)}`},setRecentWallet(r){try{localStorage.setItem(Ft.WCM_RECENT_WALLET_DATA,JSON.stringify(r))}catch{console.info("Unable to set recent wallet")}},getRecentWallet(){try{const r=localStorage.getItem(Ft.WCM_RECENT_WALLET_DATA);return r?JSON.parse(r):void 0}catch{console.info("Unable to get recent wallet")}},caseSafeIncludes(r,t){return r.toUpperCase().includes(t.toUpperCase())},openWalletExplorerUrl(){xt.openHref(Ft.EXPLORER_WALLET_URL,"_blank")},getCachedRouterWalletPlatforms(){const{desktop:r,mobile:t}=xt.getWalletRouterData(),e=!!r?.native,n=!!r?.universal,i=!!t?.native||!!t?.universal;return{isDesktop:e,isMobile:i,isWeb:n}},goToConnectingView(r){Xe.setData({Wallet:r});const t=xt.isMobile(),{isDesktop:e,isWeb:n,isMobile:i}=Ft.getCachedRouterWalletPlatforms();t?i?Xe.push("MobileConnecting"):n?Xe.push("WebConnecting"):Xe.push("InstallWallet"):e?Xe.push("DesktopConnecting"):n?Xe.push("WebConnecting"):i?Xe.push("MobileQrcodeConnecting"):Xe.push("InstallWallet")}},q$=Ie`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`;var W$=Object.defineProperty,K$=Object.getOwnPropertyDescriptor,dg=(r,t,e,n)=>{for(var i=n>1?void 0:n?K$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&W$(t,e,i),i};let ql=class extends ie{constructor(){super(),this.view=Xe.state.view,this.prevView=Xe.state.view,this.unsubscribe=void 0,this.oldHeight="0px",this.resizeObserver=void 0,this.unsubscribe=Xe.subscribe(r=>{this.view!==r.view&&this.onChangeRoute()})}firstUpdated(){this.resizeObserver=new ResizeObserver(([r])=>{const t=`${r.contentRect.height}px`;this.oldHeight!=="0px"&&Bo(this.routerEl,{height:[this.oldHeight,t]},{duration:.2}),this.oldHeight=t}),this.resizeObserver.observe(this.contentEl)}disconnectedCallback(){var r,t;(r=this.unsubscribe)==null||r.call(this),(t=this.resizeObserver)==null||t.disconnect()}get routerEl(){return Ft.getShadowRootElement(this,".wcm-router")}get contentEl(){return Ft.getShadowRootElement(this,".wcm-content")}viewTemplate(){switch(this.view){case"ConnectWallet":return ft``;case"DesktopConnecting":return ft``;case"MobileConnecting":return ft``;case"WebConnecting":return ft``;case"MobileQrcodeConnecting":return ft``;case"WalletExplorer":return ft``;case"Qrcode":return ft``;case"InstallWallet":return ft``;default:return ft`
Not Found
`}}async onChangeRoute(){await Bo(this.routerEl,{opacity:[1,0],scale:[1,1.02]},{duration:.15,delay:.1}).finished,this.view=Xe.state.view,Bo(this.routerEl,{opacity:[0,1],scale:[.99,1]},{duration:.37,delay:.05})}render(){return ft`
${this.viewTemplate()}
`}};ql.styles=[fe.globalCss,q$],dg([_n()],ql.prototype,"view",2),dg([_n()],ql.prototype,"prevView",2),ql=dg([we("wcm-modal-router")],ql);const Q$=Ie`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`;var J$=Object.defineProperty,Y$=Object.getOwnPropertyDescriptor,O3=(r,t,e,n)=>{for(var i=n>1?void 0:n?Y$(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&J$(t,e,i),i};let Kh=class extends ie{constructor(){super(),this.open=!1,this.unsubscribe=void 0,this.timeout=void 0,this.unsubscribe=Ns.subscribe(r=>{r.open?(this.open=!0,this.timeout=setTimeout(()=>Ns.closeToast(),2200)):(this.open=!1,clearTimeout(this.timeout))})}disconnectedCallback(){var r;(r=this.unsubscribe)==null||r.call(this),clearTimeout(this.timeout),Ns.closeToast()}render(){const{message:r,variant:t}=Ns.state,e={"wcm-success":t==="success","wcm-error":t==="error"};return this.open?ft`
${t==="success"?Oe.CHECKMARK_ICON:null} ${t==="error"?Oe.CROSS_ICON:null}${r}
`:null}};Kh.styles=[fe.globalCss,Q$],O3([_n()],Kh.prototype,"open",2),Kh=O3([we("wcm-modal-toast")],Kh);const Z$=.1,P3=2.5,rs=7;function pg(r,t,e){return r===t?!1:(r-t<0?t-r:r-t)<=e+Z$}function X$(r,t){const e=Array.prototype.slice.call(Ml.create(r,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(e.length);return e.reduce((i,s,a)=>(a%n===0?i.push([s]):i[i.length-1].push(s))&&i,[])}const tk={generate(r,t,e){const n="#141414",i="#ffffff",s=[],a=X$(r,"Q"),l=t/a.length,u=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];u.forEach(({x:E,y:C})=>{const R=(a.length-rs)*l*E,k=(a.length-rs)*l*C,D=.45;for(let P=0;P`)}});const f=Math.floor((e+25)/l),d=a.length/2-f/2,w=a.length/2+f/2-1,m=[];a.forEach((E,C)=>{E.forEach((R,k)=>{if(a[C][k]&&!(Ca.length-(rs+1)&&ka.length-(rs+1))&&!(C>d&&Cd&&k{b[E]?b[E].push(C):b[E]=[C]}),Object.entries(b).map(([E,C])=>{const R=C.filter(k=>C.every(D=>!pg(k,D,l)));return[Number(E),R]}).forEach(([E,C])=>{C.forEach(R=>{s.push(ir``)})}),Object.entries(b).filter(([E,C])=>C.length>1).map(([E,C])=>{const R=C.filter(k=>C.some(D=>pg(k,D,l)));return[Number(E),R]}).map(([E,C])=>{C.sort((k,D)=>kP.some(I=>pg(k,I,l)));D?D.push(k):R.push([k])}return[E,R.map(k=>[k[0],k[k.length-1]])]}).forEach(([E,C])=>{C.forEach(([R,k])=>{s.push(ir``)})}),s}},ek=Ie`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;var rk=Object.defineProperty,nk=Object.getOwnPropertyDescriptor,Qa=(r,t,e,n)=>{for(var i=n>1?void 0:n?nk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&rk(t,e,i),i};let ns=class extends ie{constructor(){super(...arguments),this.uri="",this.size=0,this.imageId=void 0,this.walletId=void 0,this.imageUrl=void 0}svgTemplate(){const r=Ts.state.themeMode==="light"?this.size:this.size-36;return ir`${tk.generate(this.uri,r,r/4)}`}render(){const r={"wcm-dark":Ts.state.themeMode==="dark"};return ft`
${this.walletId||this.imageUrl?ft``:Oe.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}
`}};ns.styles=[fe.globalCss,ek],Qa([Qt()],ns.prototype,"uri",2),Qa([Qt({type:Number})],ns.prototype,"size",2),Qa([Qt()],ns.prototype,"imageId",2),Qa([Qt()],ns.prototype,"walletId",2),Qa([Qt()],ns.prototype,"imageUrl",2),ns=Qa([we("wcm-qrcode")],ns);const ik=Ie`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`;var sk=Object.defineProperty,ok=Object.getOwnPropertyDescriptor,D3=(r,t,e,n)=>{for(var i=n>1?void 0:n?ok(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&sk(t,e,i),i};let Qh=class extends ie{constructor(){super(...arguments),this.onChange=()=>null}render(){return ft` ${Oe.SEARCH_ICON}`}};Qh.styles=[fe.globalCss,ik],D3([Qt()],Qh.prototype,"onChange",2),Qh=D3([we("wcm-search-input")],Qh);const ak=Ie`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`;var ck=Object.defineProperty,lk=Object.getOwnPropertyDescriptor,uk=(r,t,e,n)=>{for(var i=n>1?void 0:n?lk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&ck(t,e,i),i};let gg=class extends ie{render(){return ft``}};gg.styles=[fe.globalCss,ak],gg=uk([we("wcm-spinner")],gg);const hk=Ie`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`;var fk=Object.defineProperty,dk=Object.getOwnPropertyDescriptor,mg=(r,t,e,n)=>{for(var i=n>1?void 0:n?dk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&fk(t,e,i),i};let Wl=class extends ie{constructor(){super(...arguments),this.variant="medium-regular",this.color="primary"}render(){const r={"wcm-big-bold":this.variant==="big-bold","wcm-medium-regular":this.variant==="medium-regular","wcm-small-regular":this.variant==="small-regular","wcm-small-thin":this.variant==="small-thin","wcm-xsmall-regular":this.variant==="xsmall-regular","wcm-xsmall-bold":this.variant==="xsmall-bold","wcm-color-primary":this.color==="primary","wcm-color-secondary":this.color==="secondary","wcm-color-tertiary":this.color==="tertiary","wcm-color-inverse":this.color==="inverse","wcm-color-accnt":this.color==="accent","wcm-color-error":this.color==="error"};return ft``}};Wl.styles=[fe.globalCss,hk],mg([Qt()],Wl.prototype,"variant",2),mg([Qt()],Wl.prototype,"color",2),Wl=mg([we("wcm-text")],Wl);const pk=Ie`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`;var gk=Object.defineProperty,mk=Object.getOwnPropertyDescriptor,Gs=(r,t,e,n)=>{for(var i=n>1?void 0:n?mk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&gk(t,e,i),i};let Pi=class extends ie{constructor(){super(...arguments),this.onClick=()=>null,this.name="",this.walletId="",this.label=void 0,this.imageId=void 0,this.installed=!1,this.recent=!1}sublabelTemplate(){return this.recent?ft`RECENT`:this.installed?ft`INSTALLED`:null}handleClick(){eb.click({name:"WALLET_BUTTON",walletId:this.walletId}),this.onClick()}render(){var r;return ft``}};Pi.styles=[fe.globalCss,pk],Gs([Qt()],Pi.prototype,"onClick",2),Gs([Qt()],Pi.prototype,"name",2),Gs([Qt()],Pi.prototype,"walletId",2),Gs([Qt()],Pi.prototype,"label",2),Gs([Qt()],Pi.prototype,"imageId",2),Gs([Qt({type:Boolean})],Pi.prototype,"installed",2),Gs([Qt({type:Boolean})],Pi.prototype,"recent",2),Pi=Gs([we("wcm-wallet-button")],Pi);const wk=Ie`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var yk=Object.defineProperty,bk=Object.getOwnPropertyDescriptor,Jh=(r,t,e,n)=>{for(var i=n>1?void 0:n?bk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&yk(t,e,i),i};let Ja=class extends ie{constructor(){super(...arguments),this.walletId="",this.imageId=void 0,this.imageUrl=void 0}render(){var r;const t=(r=this.imageUrl)!=null&&r.length?this.imageUrl:Ft.getWalletIcon({id:this.walletId,image_id:this.imageId});return ft`${t.length?ft`
${this.id}
`:Oe.WALLET_PLACEHOLDER}`}};Ja.styles=[fe.globalCss,wk],Jh([Qt()],Ja.prototype,"walletId",2),Jh([Qt()],Ja.prototype,"imageId",2),Jh([Qt()],Ja.prototype,"imageUrl",2),Ja=Jh([we("wcm-wallet-image")],Ja);var vk=Object.defineProperty,Ek=Object.getOwnPropertyDescriptor,T3=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ek(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&vk(t,e,i),i};let wg=class extends ie{constructor(){super(),this.preload=!0,this.preloadData()}async loadImages(r){try{r!=null&&r.length&&await Promise.all(r.map(async t=>Ft.preloadImage(t)))}catch{console.info("Unsuccessful attempt at preloading some images",r)}}async preloadListings(){if($n.state.enableExplorer){await wn.getRecomendedWallets(),dr.setIsDataLoaded(!0);const{recomendedWallets:r}=wn.state,t=r.map(e=>Ft.getWalletIcon(e));await this.loadImages(t)}else dr.setIsDataLoaded(!0)}async preloadCustomImages(){const r=Ft.getCustomImageUrls();await this.loadImages(r)}async preloadData(){try{this.preload&&(this.preload=!1,await Promise.all([this.preloadListings(),this.preloadCustomImages()]))}catch(r){console.error(r),Ns.openToast("Failed preloading","error")}}};T3([_n()],wg.prototype,"preload",2),wg=T3([we("wcm-explorer-context")],wg);var _k=Object.defineProperty,Ak=Object.getOwnPropertyDescriptor,xk=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ak(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&_k(t,e,i),i};let N3=class extends ie{constructor(){super(),this.unsubscribeTheme=void 0,fe.setTheme(),this.unsubscribeTheme=Ts.subscribe(fe.setTheme)}disconnectedCallback(){var r;(r=this.unsubscribeTheme)==null||r.call(this)}};N3=xk([we("wcm-theme-context")],N3);const Ik=Ie`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var Ck=Object.defineProperty,Sk=Object.getOwnPropertyDescriptor,Ok=(r,t,e,n)=>{for(var i=n>1?void 0:n?Sk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Ck(t,e,i),i};let yg=class extends ie{onGoToQrcode(){Xe.push("Qrcode")}render(){const{recomendedWallets:r}=wn.state,t=[...r,...r],e=xt.RECOMMENDED_WALLET_AMOUNT*2;return ft`
${Oe.MOBILE_ICON}WalletConnect
${[...Array(e)].map((n,i)=>{const s=t[i%t.length];return s?ft``:Oe.WALLET_PLACEHOLDER})}
Select Wallet
Choose WalletConnect to see supported apps on your device`}};yg.styles=[fe.globalCss,Ik],yg=Ok([we("wcm-android-wallet-selection")],yg);const Pk=Ie`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;var Dk=Object.defineProperty,Tk=Object.getOwnPropertyDescriptor,Ya=(r,t,e,n)=>{for(var i=n>1?void 0:n?Tk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Dk(t,e,i),i};let qs=class extends ie{constructor(){super(...arguments),this.walletId=void 0,this.imageId=void 0,this.isError=!1,this.isStale=!1,this.label=""}svgLoaderTemplate(){var r,t;const e=(t=(r=Ts.state.themeVariables)==null?void 0:r["--wcm-wallet-icon-large-border-radius"])!=null?t:fe.getPreset("--wcm-wallet-icon-large-border-radius");let n=0;e.includes("%")?n=88/100*parseInt(e,10):n=parseInt(e,10),n*=1.17;const i=317-n*1.57,s=425-n*1.8;return ft``}render(){const r={"wcm-error":this.isError,"wcm-stale":this.isStale};return ft`
${this.svgLoaderTemplate()}
${this.isError?"Connection declined":this.label}`}};qs.styles=[fe.globalCss,Pk],Ya([Qt()],qs.prototype,"walletId",2),Ya([Qt()],qs.prototype,"imageId",2),Ya([Qt({type:Boolean})],qs.prototype,"isError",2),Ya([Qt({type:Boolean})],qs.prototype,"isStale",2),Ya([Qt()],qs.prototype,"label",2),qs=Ya([we("wcm-connector-waiting")],qs);const Za={manualWallets(){var r,t;const{mobileWallets:e,desktopWallets:n}=$n.state,i=(r=Za.recentWallet())==null?void 0:r.id,s=xt.isMobile()?e:n,a=s?.filter(l=>i!==l.id);return(t=xt.isMobile()?a?.map(({id:l,name:u,links:f})=>({id:l,name:u,mobile:f,links:f})):a?.map(({id:l,name:u,links:f})=>({id:l,name:u,desktop:f,links:f})))!=null?t:[]},recentWallet(){return Ft.getRecentWallet()},recomendedWallets(r=!1){var t;const e=r||(t=Za.recentWallet())==null?void 0:t.id,{recomendedWallets:n}=wn.state;return n.filter(i=>e!==i.id)}},Ws={onConnecting(r){Ft.goToConnectingView(r)},manualWalletsTemplate(){return Za.manualWallets().map(r=>ft``)},recomendedWalletsTemplate(r=!1){return Za.recomendedWallets(r).map(t=>ft``)},recentWalletTemplate(){const r=Za.recentWallet();if(r)return ft``}},Nk=Ie`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;var Rk=Object.defineProperty,Lk=Object.getOwnPropertyDescriptor,$k=(r,t,e,n)=>{for(var i=n>1?void 0:n?Lk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Rk(t,e,i),i};let bg=class extends ie{render(){const{explorerExcludedWalletIds:r,enableExplorer:t}=$n.state,e=r!=="ALL"&&t,n=Ws.manualWalletsTemplate(),i=Ws.recomendedWalletsTemplate();let s=[Ws.recentWalletTemplate(),...n,...i];s=s.filter(Boolean);const a=s.length>4||e;let l=[];a?l=s.slice(0,3):l=s;const u=!!l.length;return ft`
${Oe.MOBILE_ICON}Mobile
${Oe.SCAN_ICON}Scan with your wallet
${u?ft`
${Oe.DESKTOP_ICON}Desktop
${l} ${a?ft``:null}
`:null}`}};bg.styles=[fe.globalCss,Nk],bg=$k([we("wcm-desktop-wallet-selection")],bg);const kk=Ie`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;var Uk=Object.defineProperty,Bk=Object.getOwnPropertyDescriptor,Fk=(r,t,e,n)=>{for(var i=n>1?void 0:n?Bk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Uk(t,e,i),i};let vg=class extends ie{render(){const{termsOfServiceUrl:r,privacyPolicyUrl:t}=$n.state;return r??t?ft`
By connecting your wallet to this app, you agree to the app's ${r?ft`Terms of Service`:null} ${r&&t?"and":null} ${t?ft`Privacy Policy`:null}
`:null}};vg.styles=[fe.globalCss,kk],vg=Fk([we("wcm-legal-notice")],vg);const Mk=Ie`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`;var jk=Object.defineProperty,Hk=Object.getOwnPropertyDescriptor,zk=(r,t,e,n)=>{for(var i=n>1?void 0:n?Hk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&jk(t,e,i),i};let Eg=class extends ie{onQrcode(){Xe.push("Qrcode")}render(){const{explorerExcludedWalletIds:r,enableExplorer:t}=$n.state,e=r!=="ALL"&&t,n=Ws.manualWalletsTemplate(),i=Ws.recomendedWalletsTemplate();let s=[Ws.recentWalletTemplate(),...n,...i];s=s.filter(Boolean);const a=s.length>8||e;let l=[];a?l=s.slice(0,7):l=s;const u=!!l.length;return ft`${u?ft`
${l} ${a?ft``:null}
`:null}`}};Eg.styles=[fe.globalCss,Mk],Eg=zk([we("wcm-mobile-wallet-selection")],Eg);const Vk=Ie`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`;var Gk=Object.defineProperty,qk=Object.getOwnPropertyDescriptor,_g=(r,t,e,n)=>{for(var i=n>1?void 0:n?qk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Gk(t,e,i),i};let Xa=class extends ie{constructor(){super(),this.open=!1,this.active=!1,this.unsubscribeModal=void 0,this.abortController=void 0,this.unsubscribeModal=bo.subscribe(r=>{r.open?this.onOpenModalEvent():this.onCloseModalEvent()})}disconnectedCallback(){var r;(r=this.unsubscribeModal)==null||r.call(this)}get overlayEl(){return Ft.getShadowRootElement(this,".wcm-overlay")}get containerEl(){return Ft.getShadowRootElement(this,".wcm-container")}toggleBodyScroll(r){document.querySelector("body")&&(r?document.getElementById("wcm-styles")?.remove():document.head.insertAdjacentHTML("beforeend",''))}onCloseModal(r){r.target===r.currentTarget&&bo.close()}onOpenModalEvent(){this.toggleBodyScroll(!1),this.addKeyboardEvents(),this.open=!0,setTimeout(async()=>{const r=Ft.isMobileAnimation()?{y:["50vh","0vh"]}:{scale:[.98,1]},t=.1,e=.2;await Promise.all([Bo(this.overlayEl,{opacity:[0,1]},{delay:t,duration:e}).finished,Bo(this.containerEl,r,{delay:t,duration:e}).finished]),this.active=!0},0)}async onCloseModalEvent(){this.toggleBodyScroll(!0),this.removeKeyboardEvents();const r=Ft.isMobileAnimation()?{y:["0vh","50vh"]}:{scale:[1,.98]},t=.2;await Promise.all([Bo(this.overlayEl,{opacity:[1,0]},{duration:t}).finished,Bo(this.containerEl,r,{duration:t}).finished]),this.containerEl.removeAttribute("style"),this.active=!1,this.open=!1}addKeyboardEvents(){this.abortController=new AbortController,window.addEventListener("keydown",r=>{var t;r.key==="Escape"?bo.close():r.key==="Tab"&&((t=r.target)!=null&&t.tagName.includes("wcm-")||this.containerEl.focus())},this.abortController),this.containerEl.focus()}removeKeyboardEvents(){var r;(r=this.abortController)==null||r.abort(),this.abortController=void 0}render(){const r={"wcm-overlay":!0,"wcm-active":this.active};return ft`
${this.open?ft`
`:null}
`}};Xa.styles=[fe.globalCss,Vk],_g([_n()],Xa.prototype,"open",2),_g([_n()],Xa.prototype,"active",2),Xa=_g([we("wcm-modal")],Xa);const Wk=Ie`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`;var Kk=Object.defineProperty,Qk=Object.getOwnPropertyDescriptor,Kl=(r,t,e,n)=>{for(var i=n>1?void 0:n?Qk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Kk(t,e,i),i};let Mo=class extends ie{constructor(){super(...arguments),this.isMobile=!1,this.isDesktop=!1,this.isWeb=!1,this.isRetry=!1}onMobile(){xt.isMobile()?Xe.replace("MobileConnecting"):Xe.replace("MobileQrcodeConnecting")}onDesktop(){Xe.replace("DesktopConnecting")}onWeb(){Xe.replace("WebConnecting")}render(){return ft`
${this.isRetry?ft``:null} ${this.isMobile?ft`Mobile`:null} ${this.isDesktop?ft`Desktop`:null} ${this.isWeb?ft`Web`:null}
`}};Mo.styles=[fe.globalCss,Wk],Kl([Qt({type:Boolean})],Mo.prototype,"isMobile",2),Kl([Qt({type:Boolean})],Mo.prototype,"isDesktop",2),Kl([Qt({type:Boolean})],Mo.prototype,"isWeb",2),Kl([Qt({type:Boolean})],Mo.prototype,"isRetry",2),Mo=Kl([we("wcm-platform-selection")],Mo);const Jk=Ie`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var Yk=Object.defineProperty,Zk=Object.getOwnPropertyDescriptor,Xk=(r,t,e,n)=>{for(var i=n>1?void 0:n?Zk(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&Yk(t,e,i),i};let Ag=class extends ie{onClick(){Xe.push("WalletExplorer")}render(){const{recomendedWallets:r}=wn.state,t=Za.manualWallets(),e=[...r,...t].reverse().slice(0,4);return ft``}};Ag.styles=[fe.globalCss,Jk],Ag=Xk([we("wcm-view-all-wallets-button")],Ag);const tU=Ie`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`;var eU=Object.defineProperty,rU=Object.getOwnPropertyDescriptor,Yh=(r,t,e,n)=>{for(var i=n>1?void 0:n?rU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&eU(t,e,i),i};let tc=class extends ie{constructor(){super(),this.walletId="",this.imageId="",this.uri="",setTimeout(()=>{const{walletConnectUri:r}=dr.state;this.uri=r},0)}get overlayEl(){return Ft.getShadowRootElement(this,".wcm-qr-container")}render(){return ft`
${this.uri?ft``:ft``}
`}};tc.styles=[fe.globalCss,tU],Yh([Qt()],tc.prototype,"walletId",2),Yh([Qt()],tc.prototype,"imageId",2),Yh([_n()],tc.prototype,"uri",2),tc=Yh([we("wcm-walletconnect-qr")],tc);var nU=Object.defineProperty,iU=Object.getOwnPropertyDescriptor,sU=(r,t,e,n)=>{for(var i=n>1?void 0:n?iU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&nU(t,e,i),i};let xg=class extends ie{viewTemplate(){return xt.isAndroid()?ft``:xt.isMobile()?ft``:ft``}render(){return ft`${this.viewTemplate()}`}};xg.styles=[fe.globalCss],xg=sU([we("wcm-connect-wallet-view")],xg);const oU=Ie`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var aU=Object.defineProperty,cU=Object.getOwnPropertyDescriptor,R3=(r,t,e,n)=>{for(var i=n>1?void 0:n?cU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&aU(t,e,i),i};let Zh=class extends ie{constructor(){super(),this.isError=!1,this.openDesktopApp()}onFormatAndRedirect(r){const{desktop:t,name:e}=xt.getWalletRouterData(),n=t?.native;if(n){const i=xt.formatNativeUrl(n,r,e);xt.openHref(i,"_self")}}openDesktopApp(){const{walletConnectUri:r}=dr.state,t=xt.getWalletRouterData();Ft.setRecentWallet(t),r&&this.onFormatAndRedirect(r)}render(){const{name:r,id:t,image_id:e}=xt.getWalletRouterData(),{isMobile:n,isWeb:i}=Ft.getCachedRouterWalletPlatforms();return ft`${`Connection can continue loading if ${r} is not installed on your device`}Retry`}};Zh.styles=[fe.globalCss,oU],R3([_n()],Zh.prototype,"isError",2),Zh=R3([we("wcm-desktop-connecting-view")],Zh);const lU=Ie`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`;var uU=Object.defineProperty,hU=Object.getOwnPropertyDescriptor,fU=(r,t,e,n)=>{for(var i=n>1?void 0:n?hU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&uU(t,e,i),i};let Ig=class extends ie{onInstall(r){r&&xt.openHref(r,"_blank")}render(){const{name:r,id:t,image_id:e,homepage:n}=xt.getWalletRouterData();return ft`${`Download ${r} to continue. If multiple browser extensions are installed, disable non ${r} ones and try again`}Download`}};Ig.styles=[fe.globalCss,lU],Ig=fU([we("wcm-install-wallet-view")],Ig);const dU=Ie`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`;var pU=Object.defineProperty,gU=Object.getOwnPropertyDescriptor,L3=(r,t,e,n)=>{for(var i=n>1?void 0:n?gU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&pU(t,e,i),i};let Xh=class extends ie{constructor(){super(),this.isError=!1,this.openMobileApp()}onFormatAndRedirect(r,t=!1){const{mobile:e,name:n}=xt.getWalletRouterData(),i=e?.native,s=e?.universal;if(i&&!t){const a=xt.formatNativeUrl(i,r,n);xt.openHref(a,"_self")}else if(s){const a=xt.formatUniversalUrl(s,r,n);xt.openHref(a,"_self")}}openMobileApp(r=!1){const{walletConnectUri:t}=dr.state,e=xt.getWalletRouterData();Ft.setRecentWallet(e),t&&this.onFormatAndRedirect(t,r)}onGoToAppStore(r){r&&xt.openHref(r,"_blank")}render(){const{name:r,id:t,image_id:e,app:n,mobile:i}=xt.getWalletRouterData(),{isWeb:s}=Ft.getCachedRouterWalletPlatforms(),a=n?.ios,l=i?.universal;return ft`Retry${l?ft`Still doesn't work? Try this alternate link`:null}
${`Get ${r}`}
App Store
`}};Xh.styles=[fe.globalCss,dU],L3([_n()],Xh.prototype,"isError",2),Xh=L3([we("wcm-mobile-connecting-view")],Xh);const mU=Ie`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var wU=Object.defineProperty,yU=Object.getOwnPropertyDescriptor,bU=(r,t,e,n)=>{for(var i=n>1?void 0:n?yU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&wU(t,e,i),i};let Cg=class extends ie{render(){const{name:r,id:t,image_id:e}=xt.getWalletRouterData(),{isDesktop:n,isWeb:i}=Ft.getCachedRouterWalletPlatforms();return ft`${`Scan this QR Code with your phone's camera or inside ${r} app`}`}};Cg.styles=[fe.globalCss,mU],Cg=bU([we("wcm-mobile-qr-connecting-view")],Cg);var vU=Object.defineProperty,EU=Object.getOwnPropertyDescriptor,_U=(r,t,e,n)=>{for(var i=n>1?void 0:n?EU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&vU(t,e,i),i};let Sg=class extends ie{render(){return ft``}};Sg.styles=[fe.globalCss],Sg=_U([we("wcm-qrcode-view")],Sg);const AU=Ie`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`;var xU=Object.defineProperty,IU=Object.getOwnPropertyDescriptor,Ql=(r,t,e,n)=>{for(var i=n>1?void 0:n?IU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&xU(t,e,i),i};const Og=40;let jo=class extends ie{constructor(){super(...arguments),this.loading=!wn.state.wallets.listings.length,this.firstFetch=!wn.state.wallets.listings.length,this.search="",this.endReached=!1,this.intersectionObserver=void 0,this.searchDebounce=Ft.debounce(r=>{r.length>=1?(this.firstFetch=!0,this.endReached=!1,this.search=r,wn.resetSearch(),this.fetchWallets()):this.search&&(this.search="",this.endReached=this.isLastPage(),wn.resetSearch())})}firstUpdated(){this.createPaginationObserver()}disconnectedCallback(){var r;(r=this.intersectionObserver)==null||r.disconnect()}get placeholderEl(){return Ft.getShadowRootElement(this,".wcm-placeholder-block")}createPaginationObserver(){this.intersectionObserver=new IntersectionObserver(([r])=>{r.isIntersecting&&!(this.search&&this.firstFetch)&&this.fetchWallets()}),this.intersectionObserver.observe(this.placeholderEl)}isLastPage(){const{wallets:r,search:t}=wn.state,{listings:e,total:n}=this.search?t:r;return n<=Og||e.length>=n}async fetchWallets(){var r;const{wallets:t,search:e}=wn.state,{listings:n,total:i,page:s}=this.search?e:t;if(!this.endReached&&(this.firstFetch||i>Og&&n.lengthFt.getWalletIcon(f));await Promise.all([...u.map(async f=>Ft.preloadImage(f)),xt.wait(300)]),this.endReached=this.isLastPage()}catch(a){console.error(a),Ns.openToast(Ft.getErrorMessage(a),"error")}finally{this.loading=!1,this.firstFetch=!1}}onConnect(r){xt.isAndroid()?Ft.handleMobileLinking(r):Ft.goToConnectingView(r)}onSearchChange(r){const{value:t}=r.target;this.searchDebounce(t)}render(){const{wallets:r,search:t}=wn.state,{listings:e}=this.search?t:r,n=this.loading&&!e.length,i=this.search.length>=3;let s=Ws.manualWalletsTemplate(),a=Ws.recomendedWalletsTemplate(!0);i&&(s=s.filter(({values:f})=>Ft.caseSafeIncludes(f[0],this.search)),a=a.filter(({values:f})=>Ft.caseSafeIncludes(f[0],this.search)));const l=!this.loading&&!e.length&&!a.length,u={"wcm-loading":n,"wcm-end-reached":this.endReached||!this.loading,"wcm-empty":l};return ft`
${n?null:s} ${n?null:a} ${n?null:e.map(f=>ft`${f?ft``:null}`)}
${l?ft`No results found`:null} ${!l&&this.loading?ft``:null}
`}};jo.styles=[fe.globalCss,AU],Ql([_n()],jo.prototype,"loading",2),Ql([_n()],jo.prototype,"firstFetch",2),Ql([_n()],jo.prototype,"search",2),Ql([_n()],jo.prototype,"endReached",2),jo=Ql([we("wcm-wallet-explorer-view")],jo);const CU=Ie`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var SU=Object.defineProperty,OU=Object.getOwnPropertyDescriptor,$3=(r,t,e,n)=>{for(var i=n>1?void 0:n?OU(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=(n?a(t,e,i):a(i))||i);return n&&i&&SU(t,e,i),i};let tf=class extends ie{constructor(){super(),this.isError=!1,this.openWebWallet()}onFormatAndRedirect(r){const{desktop:t,name:e}=xt.getWalletRouterData(),n=t?.universal;if(n){const i=xt.formatUniversalUrl(n,r,e);xt.openHref(i,"_blank")}}openWebWallet(){const{walletConnectUri:r}=dr.state,t=xt.getWalletRouterData();Ft.setRecentWallet(t),r&&this.onFormatAndRedirect(r)}render(){const{name:r,id:t,image_id:e}=xt.getWalletRouterData(),{isMobile:n,isDesktop:i}=Ft.getCachedRouterWalletPlatforms(),s=xt.isMobile();return ft`${`${r} web app has opened in a new tab. Go there, accept the connection, and come back`}Retry`}};tf.styles=[fe.globalCss,CU],$3([_n()],tf.prototype,"isError",2),tf=$3([we("wcm-web-connecting-view")],tf);const PU=Object.freeze(Object.defineProperty({__proto__:null,get WcmModal(){return Xa},get WcmQrCode(){return ns}},Symbol.toStringTag,{value:"Module"}));zr.Erc20=ia,zr.Invoice=Ui,zr.Merchant=AE,zr.MetaMask=Dl,zr.Network=ts,zr.Subscription=Bi,zr.Wallet=Pl,zr.WalletConnect=Ht,zr.Webhook=Tl,zr.default=A9,zr.setAuthToken=X1,Object.defineProperties(zr,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});