/*! For license information please see bundle.1889280af20762a28df6.js.LICENSE.txt */ (self.webpackChunkfrog=self.webpackChunkfrog||[]).push([[3896],{75206:(e,t,s)=>{"use strict";s.d(t,{$Q:()=>f,GF:()=>m,S9:()=>w,Vx:()=>d,ZP:()=>o,dQ:()=>c,lZ:()=>a,m5:()=>p,mF:()=>u,pi:()=>l,qE:()=>h,yJ:()=>y,zl:()=>g});var i=s(4556),n=s(37007),r=s.n(n);class o extends i.H{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class a extends i.H{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class c{constructor(e,t){this.logger=e,this.core=t}}class h extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class p extends i.H{constructor(e){super()}}class l{constructor(e,t,s,i){this.core=e,this.logger=t,this.name=s}}class u extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class d extends i.H{constructor(e,t){super(),this.core=e,this.logger=t}}class g{constructor(e,t,s){this.core=e,this.logger=t,this.store=s}}class m{constructor(e,t){this.projectId=e,this.logger=t}}class f{constructor(e,t,s){this.core=e,this.logger=t,this.telemetryEnabled=s}}r();class w{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}n.EventEmitter;class y{constructor(e){this.client=e}}},14761:(e,t,s)=>{"use strict";s.d(t,{A:()=>ze});var i=s(23664),n=s(29838),r=s(75206),o=s(88900),a=s(6754),c=s(37007),h=s.n(c),p=s(39031);const l="client",u=`wc@2:${l}:`,d=l,g="error",m="WALLETCONNECT_DEEPLINK_CHOICE",f="Proposal expired",w=o.SEVEN_DAYS,y={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},v={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},E="IDLE",P="ACTIVE",I=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],b="wc@1.5:auth:",_=`${b}:PUB_KEY`;var S=Object.defineProperty,R=Object.defineProperties,q=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,C=(e,t,s)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,T=(e,t)=>{for(var s in t||(t={}))N.call(t,s)&&C(e,s,t[s]);if(O)for(var s of O(t))$.call(t,s)&&C(e,s,t[s]);return e},A=(e,t)=>R(e,q(t));class D extends r.yJ{constructor(e){super(e),this.name="engine",this.events=new(h()),this.initialized=!1,this.requestQueue={state:E,queue:[]},this.sessionRequestQueue={state:E,queue:[]},this.requestQueueDelay=o.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(y)}),this.initialized=!0,setTimeout((()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),(0,o.toMiliseconds)(this.requestQueueDelay)))},this.connect=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=A(T({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:s,requiredNamespaces:n,optionalNamespaces:r,sessionProperties:c,relays:h}=t;let p,l=s,u=!1;try{if(l){const e=this.client.core.pairing.pairings.get(l);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),u=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),e}if(!l||!u){const{topic:e,uri:t}=await this.client.core.pairing.create();l=e,p=t}if(!l){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(e)}const d=await this.client.core.crypto.generateKeyPair(),g=y.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,m=(0,a.Xw0)(g),w=T({requiredNamespaces:n,optionalNamespaces:r,relays:h??[{protocol:i.sD}],proposer:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:m,pairingTopic:l},c&&{sessionProperties:c}),{reject:v,resolve:E,done:P}=(0,a.Wx8)(g,f);this.events.once((0,a.hEn)("session_connect"),(async({error:e,session:t})=>{if(e)v(e);else if(t){t.self.publicKey=d;const e=A(T({},t),{pairingTopic:w.pairingTopic,requiredNamespaces:w.requiredNamespaces,optionalNamespaces:w.optionalNamespaces,transportType:i.cV.relay});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),l&&await this.client.core.pairing.updateMetadata({topic:l,metadata:t.peer.metadata}),this.cleanupDuplicatePairings(e),E(e)}}));const I=await this.sendRequest({topic:l,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0});return await this.setProposal(I,T({id:I},w)),{uri:p,approval:P}},this.pair=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}},this.approve=async e=>{var t,s,n;const r=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[i.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw r.setError(i.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),r.setError(i.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),r.setError(i.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:h,sessionProperties:p,sessionConfig:l}=e,u=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:r.eventId});const{pairingTopic:d,proposer:g,requiredNamespaces:m,optionalNamespaces:f}=u;let y=null==(s=this.client.core.eventClient)?void 0:s.getEvent({topic:d});y||(y=null==(n=this.client.core.eventClient)?void 0:n.createEvent({type:i.$I.session_approve_started,properties:{topic:d,trace:[i.$I.session_approve_started,i.$I.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),E=g.publicKey,P=await this.client.core.crypto.generateSharedKey(v,E),I=T(T({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:v,metadata:this.client.metadata},expiry:(0,a.Xw0)(w)},p&&{sessionProperties:p}),l&&{sessionConfig:l}),b=i.cV.relay;y.addTrace(i.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(P,{transportType:b})}catch(e){throw y.setError(i.U.subscribe_session_topic_failure),e}y.addTrace(i.$I.subscribe_session_topic_success);const _=A(T({},I),{topic:P,requiredNamespaces:m,optionalNamespaces:f,pairingTopic:d,acknowledged:!1,self:I.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:v,transportType:i.cV.relay});await this.client.session.set(P,_),y.addTrace(i.$I.store_session);try{y.addTrace(i.$I.publishing_session_settle),await this.sendRequest({topic:P,method:"wc_sessionSettle",params:I,throwOnFailedPublish:!0}).catch((e=>{throw y?.setError(i.U.session_settle_publish_failure),e})),y.addTrace(i.$I.session_settle_publish_success),y.addTrace(i.$I.publishing_session_approve),await this.sendResult({id:o,topic:d,result:{relay:{protocol:c??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch((e=>{throw y?.setError(i.U.session_approve_publish_failure),e})),y.addTrace(i.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(P,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(P),e}return this.client.core.eventClient.deleteEvent({eventId:y.eventId}),await this.client.core.pairing.updateMetadata({topic:d,metadata:g.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:d}),await this.setExpiry(P,(0,a.Xw0)(w)),{topic:P,acknowledged:()=>Promise.resolve(this.client.session.get(P))}},this.reject=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:s}=e;let i;try{i=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}i&&(await this.sendError({id:t,topic:i,error:s,rpcOpts:y.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:s}=e,{done:i,resolve:n,reject:r}=(0,a.Wx8)(),o=(0,p.payloadId)(),c=(0,p.getBigIntRpcId)().toString(),h=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),(({error:e})=>{e?r(e):n()})),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch((e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:h}),r(e)})),{acknowledged:i}},this.extend=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,s=(0,p.payloadId)(),{done:i,resolve:n,reject:r}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",s),(({error:e})=>{e?r(e):n()})),await this.setExpiry(t,(0,a.Xw0)(w)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch((e=>{r(e)})),{acknowledged:i}},this.request=async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:s,topic:n,expiry:r=y.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(n);o?.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,p.payloadId)(),h=(0,p.getBigIntRpcId)().toString(),{done:l,resolve:u,reject:d}=(0,a.Wx8)(r,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),(({error:e,result:t})=>{e?d(e):u(t)}));const g=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);return g?(await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:A(T({},s),{expiryTimestamp:(0,a.Xw0)(r)}),chainId:t},expiry:r,throwOnFailedPublish:!0,appLink:g}).catch((e=>d(e))),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:t,id:c}),await l()):await Promise.all([new Promise((async e=>{await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:A(T({},s),{expiryTimestamp:(0,a.Xw0)(r)}),chainId:t},expiry:r,throwOnFailedPublish:!0}).catch((e=>d(e))),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:t,id:c}),e()})),new Promise((async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,m);await(0,a.n3s)({id:c,topic:n,wcDeepLink:e})}e()})),l()]).then((e=>e[2]))},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:s}=e,{id:n}=s,r=this.client.session.get(t);r.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(r.peer.metadata,r.transportType);(0,p.isJsonRpcResult)(s)?await this.sendResult({id:n,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:o}):(0,p.isJsonRpcError)(s)&&await this.sendError({id:n,topic:t,error:s.error,appLink:o}),this.cleanupAfterResponse(e)},this.ping=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,p.payloadId)(),s=(0,p.getBigIntRpcId)().toString(),{done:i,resolve:n,reject:r}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),(({error:e})=>{e?r(e):n()})),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:s}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))},this.emit=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:s,chainId:i}=e,n=(0,p.getBigIntRpcId)().toString(),r=(0,p.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:!0,relayRpcId:n,clientRpcId:r})},this.disconnect=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>(0,a.HNf)(t,e)))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(e,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(e);const n=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(s=this.client.metadata.redirect)?void 0:s.linkMode),r=n?i.cV.link_mode:i.cV.relay;r===i.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:h,domain:l,nonce:u,type:d,exp:g,nbf:m,methods:f=[],expiry:v}=e,E=[...e.resources||[]],{topic:P,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:r});this.client.logger.info({message:"Generated new pairing",pairing:{topic:P,uri:I}});const b=await this.client.core.crypto.generateKeyPair(),S=(0,a.EN$)(b);if(await Promise.all([this.client.auth.authKeys.set(_,{responseTopic:S,publicKey:b}),this.client.auth.pairingTopics.set(S,{topic:S,pairingTopic:P})]),await this.client.core.relayer.subscribe(S,{transportType:r}),this.client.logger.info(`sending request to new pairing topic: ${P}`),f.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",f);(0,a.VBM)(E)&&(t=(0,a.hVC)(t,E.pop())),E.push(t)}const R=v&&v>y.wc_sessionAuthenticate.req.ttl?v:y.wc_sessionAuthenticate.req.ttl,q={authPayload:{type:d??"caip122",chains:o,statement:c,aud:h,domain:l,version:"1",nonce:u,iat:(new Date).toISOString(),exp:g,nbf:m,resources:E},requester:{publicKey:b,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(R)},O={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...f])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:P,proposer:{publicKey:b,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(y.wc_sessionPropose.req.ttl)},{done:N,resolve:$,reject:C}=(0,a.Wx8)(R,"Request expired"),D=async({error:e,session:t})=>{if(this.events.off((0,a.hEn)("session_request",j),x),e)C(e);else if(t){t.self.publicKey=b,await this.client.session.set(t.topic,t),await this.setExpiry(t.topic,t.expiry),P&&await this.client.core.pairing.updateMetadata({topic:P,metadata:t.peer.metadata});const e=this.client.session.get(t.topic);await this.deleteProposal(k),$({session:e})}},x=async e=>{var s,n,o;if(await this.deletePendingAuthRequest(j,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off((0,a.hEn)("session_connect"),D),C(e.error.message))}await this.deleteProposal(k),this.events.off((0,a.hEn)("session_connect"),D);const{cacaos:c,responder:h}=e.result,p=[],l=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),C((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,s=(0,a.VBM)(t.resources),i=[(0,a.xkc)(t.iss)],n=(0,a.q_h)(t.iss);if(s){const e=(0,a.sc_)(s),t=(0,a.WWN)(s);p.push(...e),i.push(...t)}for(const e of i)l.push(`${e}:${n}`)}const u=await this.client.core.crypto.generateSharedKey(b,h.publicKey);let d;p.length>0&&(d={topic:u,acknowledged:!0,self:{publicKey:b,metadata:this.client.metadata},peer:h,controller:h.publicKey,expiry:(0,a.Xw0)(w),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:P,namespaces:(0,a.Van)([...new Set(p)],[...new Set(l)]),transportType:r},await this.client.core.relayer.subscribe(u,{transportType:r}),await this.client.session.set(u,d),P&&await this.client.core.pairing.updateMetadata({topic:P,metadata:h.metadata}),d=this.client.session.get(u)),null!=(s=this.client.metadata.redirect)&&s.linkMode&&null!=(n=h.metadata.redirect)&&n.linkMode&&null!=(o=h.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.session.update(u,{transportType:i.cV.link_mode})),$({auths:c,session:d})},j=(0,p.payloadId)(),k=(0,p.payloadId)();let M;this.events.once((0,a.hEn)("session_connect"),D),this.events.once((0,a.hEn)("session_request",j),x);try{if(n){const e=(0,p.formatJsonRpcRequest)("wc_sessionAuthenticate",q,j);this.client.core.history.set(P,e);const s=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});M=(0,a.$Bq)(t,P,s)}else await Promise.all([this.sendRequest({topic:P,method:"wc_sessionAuthenticate",params:q,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:j}),this.sendRequest({topic:P,method:"wc_sessionPropose",params:O,expiry:y.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:k})])}catch(e){throw this.events.off((0,a.hEn)("session_connect"),D),this.events.off((0,a.hEn)("session_request",j),x),e}return await this.setProposal(k,T({id:k},O)),await this.setAuthRequest(j,{request:A(T({},q),{verifyContext:{}}),pairingTopic:P,transportType:r}),{uri:M??I,response:N}},this.approveSessionAuthenticate=async e=>{const{id:t,auths:s}=e,n=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[i.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw n.setError(i.Tn.no_internet_connection),e}const r=this.getPendingAuthRequest(t);if(!r)throw n.setError(i.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=r.transportType||i.cV.relay;o===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=r.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),p=(0,a.EN$)(c),l={type:a.Lp_,receiverPublicKey:c,senderPublicKey:h},u=[],d=[];for(const e of s){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){n.setError(i.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:p,error:e,encodeOpts:l}),new Error(e.message)}n.addTrace(i.U$.cacaos_verified);const{p:s}=e,r=(0,a.VBM)(s.resources),o=[(0,a.xkc)(s.iss)],c=(0,a.q_h)(s.iss);if(r){const e=(0,a.sc_)(r),t=(0,a.WWN)(r);u.push(...e),o.push(...t)}for(const e of o)d.push(`${e}:${c}`)}const g=await this.client.core.crypto.generateSharedKey(h,c);let m;if(n.addTrace(i.U$.create_authenticated_session_topic),u?.length>0){m={topic:g,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:r.requester.metadata},controller:c,expiry:(0,a.Xw0)(w),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:r.pairingTopic,namespaces:(0,a.Van)([...new Set(u)],[...new Set(d)]),transportType:o},n.addTrace(i.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:o})}catch(e){throw n.setError(i.Tn.subscribe_authenticated_session_topic_failure),e}n.addTrace(i.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(g,m),n.addTrace(i.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:r.pairingTopic,metadata:r.requester.metadata})}n.addTrace(i.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:p,id:t,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(r.requester.metadata,o)})}catch(e){throw n.setError(i.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:r.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:m}},this.rejectSessionAuthenticate=async e=>{this.isInitialized();const{id:t,reason:s}=e,n=this.getPendingAuthRequest(t);if(!n)throw new Error(`Could not find pending auth request with id ${t}`);n.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const r=n.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(r),h={type:a.Lp_,receiverPublicKey:r,senderPublicKey:o};await this.sendError({id:t,topic:c,error:s,encodeOpts:h,rpcOpts:y.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED"))},this.formatAuthMessage=e=>{this.isInitialized();const{request:t,iss:s}=e;return(0,a.hwK)(t,s)},this.processRelayMessageCache=()=>{setTimeout((async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}}),50)},this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter((s=>{var i,n;return(null==(i=s.peerMetadata)?void 0:i.url)&&(null==(n=s.peerMetadata)?void 0:n.url)===e.peer.metadata.url&&s.topic&&s.topic!==t.topic}));if(0===s.length)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async e=>{var t;const{topic:s,expirerHasDeleted:i=!1,emitEvent:n=!0,id:r=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(m).catch((e=>this.client.logger.warn(e))),this.getPendingSessionRequests().forEach((e=>{e.topic===s&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))})),s===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=E),n&&this.client.events.emit("session_delete",{id:r,topic:s})},this.deleteProposal=async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),s=this.client.core.eventClient.getEvent({topic:t.pairingTopic});s?.setError(i.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")},this.deletePendingSessionRequest=async(e,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter((t=>t.id!==e)),s&&(this.sessionRequestQueue.state=E,this.client.events.emit("session_request_expire",{id:e}))},this.deletePendingAuthRequest=async(e,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)])},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))},this.setProposal=async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(y.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)},this.setAuthRequest=async(e,t)=>{const{request:s,pairingTopic:n,transportType:r=i.cV.relay}=t;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:n,verifyContext:s.verifyContext,transportType:r})},this.setPendingSessionRequest=async e=>{const{id:t,topic:s,params:i,verifyContext:n}=e,r=i.request.expiryTimestamp||(0,a.Xw0)(y.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,r),await this.client.pendingRequest.set(t,{id:t,topic:s,params:i,verifyContext:n})},this.sendRequest=async e=>{const{topic:t,method:i,params:n,expiry:r,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:h,appLink:l}=e,u=(0,p.formatJsonRpcRequest)(i,n,c);let d;const g=!!l;try{const e=g?a.Pa8:a.EWt;d=await this.client.core.crypto.encode(t,u,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let m;if(I.includes(i)){const e=(0,a.ALl)(JSON.stringify(u)),t=(0,a.ALl)(d);m=await this.client.core.verify.register({id:t,decryptedId:e})}const f=y[i].req;if(f.attestation=m,r&&(f.ttl=r),o&&(f.id=o),this.client.core.history.set(t,u),g){const e=(0,a.$Bq)(l,t,d);await s.g.Linking.openURL(e,this.client.name)}else{const e=y[i].req;r&&(e.ttl=r),o&&(e.id=o),h?(e.internal=A(T({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,d,e)):this.client.core.relayer.publish(t,d,e).catch((e=>this.client.logger.error(e)))}return u.id},this.sendResult=async e=>{const{id:t,topic:i,result:n,throwOnFailedPublish:r,encodeOpts:o,appLink:c}=e,h=(0,p.formatJsonRpcResult)(t,n);let l;const u=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=u?a.Pa8:a.EWt;l=await this.client.core.crypto.encode(i,h,A(T({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),e}let d;try{d=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${t}) failed`),e}if(u){const e=(0,a.$Bq)(c,i,l);await s.g.Linking.openURL(e,this.client.name)}else{const e=y[d.request.method].res;r?(e.internal=A(T({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,l,e)):this.client.core.relayer.publish(i,l,e).catch((e=>this.client.logger.error(e)))}await this.client.core.history.resolve(h)},this.sendError=async e=>{const{id:t,topic:i,error:n,encodeOpts:r,rpcOpts:o,appLink:c}=e,h=(0,p.formatJsonRpcError)(t,n);let l;const u=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=u?a.Pa8:a.EWt;l=await this.client.core.crypto.encode(i,h,A(T({},r||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),e}let d;try{d=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${i}, ${t}) failed`),e}if(u){const e=(0,a.$Bq)(c,i,l);await s.g.Linking.openURL(e,this.client.name)}else{const e=o||y[d.request.method].res;this.client.core.relayer.publish(i,l,e)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{let s=!1;(0,a._dF)(t.expiry)&&(s=!0),this.client.core.crypto.keychain.has(t.topic)||(s=!0),s&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession({topic:e}))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state!==P){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=P;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=E}else this.client.logger.info("Request queue already active, skipping...")},this.processRequest=async e=>{const{topic:t,payload:s,attestation:i,transportType:n,encryptedId:r}=e,o=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:i,encryptedId:r});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:i,encryptedId:r,transportType:n});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:i,encryptedId:r,transportType:n});default:return this.client.logger.info(`Unsupported request method ${o}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:s,transportType:i}=e,n=(await this.client.core.history.get(t,s.id)).request.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${n}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)},this.shouldIgnorePairingRequest=e=>{const{topic:t,requestMethod:s}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(s))&&!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async e=>{const{topic:t,payload:s,attestation:n,encryptedId:r}=e,{params:o,id:c}=s;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&e?.setError(i.S$.proposal_listener_not_found),this.isValidConnect(T({},s.params));const h=o.expiryTimestamp||(0,a.Xw0)(y.wc_sessionPropose.req.ttl),p=T({id:c,pairingTopic:t,expiryTimestamp:h},o);await this.setProposal(c,p);const l=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(s)),encryptedId:r,metadata:p.proposer.metadata});e?.addTrace(i.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:p,verifyContext:l})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:y.wc_sessionPropose.autoReject}),this.client.logger.error(e)}},this.onSessionProposeResponse=async(e,t,s)=>{const{id:i}=t;if((0,p.isJsonRpcResult)(t)){const{result:n}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:n});const r=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:r});const o=r.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=n.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const h=await this.client.core.relayer.subscribe(c,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else if((0,p.isJsonRpcError)(t)){await this.client.proposal.delete(i,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect");if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit((0,a.hEn)("session_connect"),{error:t.error})}},this.onSessionSettleRequest=async(e,t)=>{const{id:s,params:n}=t;try{this.isValidSessionSettleRequest(n);const{relay:s,controller:r,expiry:o,namespaces:c,sessionProperties:h,sessionConfig:p}=t.params,l=A(T(T({topic:e,relay:s,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:r.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:r.publicKey,metadata:r.metadata}},h&&{sessionProperties:h}),p&&{sessionConfig:p}),{transportType:i.cV.relay}),u=(0,a.hEn)("session_connect");if(0===this.events.listenerCount(u))throw new Error(`emitting ${u} without any listeners 997`);this.events.emit((0,a.hEn)("session_connect"),{session:l}),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:s}=t;(0,p.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",s),{})):(0,p.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",s),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:s,id:i}=t;try{const t=`${e}_session_update`,n=a.nyL.get(t);if(n&&this.isRequestOutOfSync(n,i))return this.client.logger.warn(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(T({topic:e},s));try{a.nyL.set(t,i),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:s})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}},this.isRequestOutOfSync=(e,t)=>t.toString().slice(0,-3){const{id:s}=t,i=(0,a.hEn)("session_update",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,p.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",s),{}):(0,p.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",s),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:s}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(w)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_extend",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,p.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",s),{}):(0,p.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",s),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_ping",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);setTimeout((()=>{(0,p.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",s),{}):(0,p.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",s),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise((t=>{this.client.core.relayer.once(i.Jf.publish,(async()=>{t(await this.deleteSession({topic:e,id:s}))}))})),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch((e=>this.client.logger.error(e)))}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async e=>{var t,s,n;const{topic:r,payload:o,attestation:c,encryptedId:h,transportType:l}=e,{id:u,params:d}=o;try{await this.isValidRequest(T({topic:r},d));const e=this.client.session.get(r),o={id:u,topic:r,params:d,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,p.formatJsonRpcRequest)("wc_sessionRequest",d,u))),encryptedId:h,metadata:e.peer.metadata,transportType:l})};await this.setPendingSessionRequest(o),l===i.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(s=e.peer.metadata.redirect)?void 0:s.universal),null!=(n=this.client.signConfig)&&n.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:u,topic:r,error:e}),this.client.logger.error(e)}},this.onSessionRequestResponse=(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,p.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,p.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:s,params:i}=t;try{const t=`${e}_session_event_${i.event.name}`,n=a.nyL.get(t);if(n&&this.isRequestOutOfSync(n,s))return void this.client.logger.info(`Discarding out of sync request - ${s}`);this.isValidEmit(T({topic:e},i)),this.client.events.emit("session_event",{id:s,topic:e,params:i}),a.nyL.set(t,s)}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionAuthenticateResponse=(e,t)=>{const{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,p.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,p.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})},this.onSessionAuthenticateRequest=async e=>{var t;const{topic:s,payload:n,attestation:r,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:h,expiryTimestamp:p}=n.params,l=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(n)),encryptedId:o,metadata:e.metadata,transportType:c}),u={requester:e,pairingTopic:s,id:n.id,authPayload:h,verifyContext:l,expiryTimestamp:p};await this.setAuthRequest(n.id,{request:u,pairingTopic:s,transportType:c}),c===i.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:n.params,id:n.id,verifyContext:l})}catch(e){this.client.logger.error(e);const t=n.params.requester.publicKey,i=await this.client.core.crypto.generateKeyPair(),r=this.getAppLinkIfEnabled(n.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:i};await this.sendError({id:n.id,topic:s,error:e,encodeOpts:o,rpcOpts:y.wc_sessionAuthenticate.autoReject,appLink:r})}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=E,this.processSessionRequestQueue()}),(0,o.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:e,error:t})=>{const s=this.client.core.history.pending;s.length>0&&s.filter((t=>t.topic===e&&"wc_sessionRequest"===t.request.method)).forEach((e=>{const s=e.request.id,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})}))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===P)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=P,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")},this.emitSessionRequest=e=>{this.client.events.emit("session_request",e)},this.onPairingCreated=e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find((t=>t.pairingTopic===e.topic));t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,p.formatJsonRpcRequest)("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})},this.isValidConnect=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:n,relays:r}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(r,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${r}`);throw new Error(e)}!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"requiredNamespaces"),!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"optionalNamespaces"),(0,a.b07)(n)||this.validateSessionProps(n,"sessionProperties")},this.validateNamespaces=(e,t)=>{const s=(0,a.esh)(e,"connect()",t);if(s)throw new Error(s.message)},this.isValidApprove=async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:s,relayProtocol:i,sessionProperties:n}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const r=this.client.proposal.get(t),o=(0,a.FiO)(s,"approve()");if(o)throw new Error(o.message);const c=(0,a.XqR)(r.requiredNamespaces,s,"approve()");if(c)throw new Error(c.message);if(!(0,a.Qhg)(i,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(e)}(0,a.b07)(n)||this.validateSessionProps(n,"sessionProperties")},this.isValidReject=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:s}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:s,namespaces:i,expiry:n}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const r=(0,a.tk0)(s,"onSessionSettleRequest()");if(r)throw new Error(r.message);const o=(0,a.FiO)(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(n)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const i=this.client.session.get(t),n=(0,a.FiO)(s,"update()");if(n)throw new Error(n.message);const r=(0,a.XqR)(i.requiredNamespaces,s,"update()");if(r)throw new Error(r.message)},this.isValidExtend=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:s,chainId:i,expiry:n}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(e)}if(!(0,a.iV1)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.oKp)(r,i,s.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(e)}if(n&&!(0,a.Hbs)(n,v)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${v.min} and ${v.max}`);throw new Error(e)}},this.isValidRespond=async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:s,response:i}=e;try{await this.isValidSessionTopic(s)}catch(s){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),s}if(!(0,a.M8n)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:s,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(e)}if(!(0,a.FR8)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.z2N)(n,i,s.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidAuthenticate=e=>{const{chains:t,uri:s,domain:i,nonce:n}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(s,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(i,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(n,!1))throw new Error("nonce is required parameter");if([...new Set(t.map((e=>(0,a._Yb)(e).namespace)))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:r}=(0,a._Yb)(t[0]);if("eip155"!==r)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async e=>{const{attestationId:t,hash:s,encryptedId:n,metadata:r,transportType:o}=e,a={verified:{verifyUrl:r.verifyUrl||i.WB,validation:"UNKNOWN",origin:r.url||""}};try{if(o===i.cV.link_mode){const e=this.getAppLinkIfEnabled(r,o);return a.verified.validation=e&&new URL(e).origin===new URL(r.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:n,verifyUrl:r.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(r.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!(0,a.Qhg)(e,!1)){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must be in Record format. Received: ${JSON.stringify(e)}`);throw new Error(s)}}))},this.getPendingAuthRequest=e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0},this.addToRecentlyDeleted=(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const s of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(s)}}},this.checkRecentlyDeleted=e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(s)}},this.isLinkModeEnabled=(e,t)=>{var n,r,o,a,c,h,p,l,u;return!(!e||t!==i.cV.link_mode)&&(!0===(null==(r=null==(n=this.client.metadata)?void 0:n.redirect)?void 0:r.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(h=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:h.universal)&&void 0!==(null==(p=e?.redirect)?void 0:p.universal)&&""!==(null==(l=e?.redirect)?void 0:l.universal)&&!0===(null==(u=e?.redirect)?void 0:u.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==s.g?void 0:s.g.Linking)<"u")},this.getAppLinkIfEnabled=(e,t)=>{var s;return this.isLinkModeEnabled(e,t)?null==(s=e?.redirect)?void 0:s.universal:void 0},this.handleLinkModeMessage=({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",s=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),n=this.client.session.keys.includes(t);n&&this.client.session.update(t,{transportType:i.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:n})},this.registerLinkModeListeners=async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==s.g?void 0:s.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout((()=>{this.handleLinkModeMessage({url:t})}),50)}}}}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(i.Jf.message,(e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)}))}async onRelayMessage(e){const{topic:t,message:s,attestation:n,transportType:r}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(_)?this.client.auth.authKeys.get(_):{responseTopic:void 0,publicKey:void 0},c=await this.client.core.crypto.decode(t,s,{receiverPublicKey:o,encoding:r===i.cV.link_mode?a.Pa8:a.EWt});try{(0,p.isJsonRpcRequest)(c)?(this.client.core.history.set(t,c),this.onRelayEventRequest({topic:t,payload:c,attestation:n,transportType:r,encryptedId:(0,a.ALl)(s)})):(0,p.isJsonRpcResponse)(c)?(await this.client.core.history.resolve(c),await this.onRelayEventResponse({topic:t,payload:c,transportType:r}),this.client.core.history.delete(t,c.id)):this.onRelayEventUnknownPayload({topic:t,payload:c,transportType:r})}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(i.wn.expired,(async e=>{const{topic:t,id:s}=(0,a.c82)(e.target);return s&&this.client.pendingRequest.keys.includes(s)?await this.deletePendingSessionRequest(s,(0,a.GuA)("EXPIRED"),!0):s&&this.client.auth.requests.keys.includes(s)?await this.deletePendingAuthRequest(s,(0,a.GuA)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s})))}))}registerPairingEvents(){this.client.core.pairing.events.on(i.zN.create,(e=>this.onPairingCreated(e))),this.client.core.pairing.events.on(i.zN.delete,(e=>{this.addToRecentlyDeleted(e.topic,"pairing")}))}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class x extends i.il{constructor(e,t){super(e,t,"proposal",u),this.core=e,this.logger=t}}class j extends i.il{constructor(e,t){super(e,t,"session",u),this.core=e,this.logger=t}}class k extends i.il{constructor(e,t){super(e,t,"request",u,(e=>e.id)),this.core=e,this.logger=t}}class M extends i.il{constructor(e,t){super(e,t,"authKeys",b,(()=>_)),this.core=e,this.logger=t}}class U extends i.il{constructor(e,t){super(e,t,"pairingTopics",b),this.core=e,this.logger=t}}class V extends i.il{constructor(e,t){super(e,t,"requests",b,(e=>e.id)),this.core=e,this.logger=t}}class H{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new M(this.core,this.logger),this.pairingTopics=new U(this.core,this.logger),this.requests=new V(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class L extends r.S9{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=d,this.events=new c.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.authenticate=async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}},this.approveSessionAuthenticate=async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}},this.rejectSessionAuthenticate=async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}},this.name=e?.name||d,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||g}));this.core=e?.core||new i.iJ(e),this.logger=(0,n.U5)(t,this.name),this.session=new j(this.core,this.logger),this.proposal=new x(this.core,this.logger),this.pendingRequest=new k(this.core,this.logger),this.engine=new D(this),this.auth=new H(this.core,this.logger)}static async init(e){const t=new L(e);return await t.initialize(),t}get context(){return(0,n.oI)(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.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout((()=>{this.engine.processRelayMessageCache()}),(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var K=s(2543),F=s(36647),G=s(27907);const J="error",z="wc@2:universal_provider:",Q="https://rpc.walletconnect.org/v1/",W="generic",Y=`${Q}bundler`,B="default_chain_changed";var X=Object.defineProperty,Z=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,re=(e,t)=>{for(var s in t||(t={}))se.call(t,s)&&ne(e,s,t[s]);if(te)for(var s of te(t))ie.call(t,s)&&ne(e,s,t[s]);return e},oe=(e,t)=>Z(e,ee(t));function ae(e,t,s){var i;const n=(0,a._Yb)(e);return(null==(i=t.rpcMap)?void 0:i[n.reference])||`${Q}?chainId=${n.namespace}:${n.reference}&projectId=${s}`}function ce(e){return e.includes(":")?e.split(":")[1]:e}function he(e){return e.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))}function pe(e={},t={}){const s=le(e),i=le(t);return(0,K.merge)(s,i)}function le(e){var t,s,i,n;const r={};if(!(0,a.aF0)(e))return r;for(const[o,c]of Object.entries(e)){const e=(0,a.nWe)(o)?[o]:c.chains,h=c.methods||[],p=c.events||[],l=c.rpcMap||{},u=(0,a.kob)(o);r[u]=oe(re(re({},r[u]),c),{chains:(0,a.TRk)(e,null==(t=r[u])?void 0:t.chains),methods:(0,a.TRk)(h,null==(s=r[u])?void 0:s.methods),events:(0,a.TRk)(p,null==(i=r[u])?void 0:i.events),rpcMap:re(re({},l),null==(n=r[u])?void 0:n.rpcMap)})}return r}function ue(e){return e.includes(":")?e.split(":")[2]:e}function de(e){const t={};for(const[s,i]of Object.entries(e)){const e=i.methods||[],n=i.events||[],r=i.accounts||[],o=(0,a.nWe)(s)?[s]:i.chains?i.chains:he(i.accounts);t[s]={chains:o,methods:e,events:n,accounts:r}}return t}function ge(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const me={},fe=e=>me[e],we=(e,t)=>{me[e]=t};class ye{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(B,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;const i=ce(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.A(s,fe("disableProviderPing")))}}var ve=Object.defineProperty,Ee=Object.defineProperties,Pe=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable,Se=(e,t,s)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Re=(e,t)=>{for(var s in t||(t={}))be.call(t,s)&&Se(e,s,t[s]);if(Ie)for(var s of Ie(t))_e.call(t,s)&&Se(e,s,t[s]);return e},qe=(e,t)=>Ee(e,Pe(t));class Oe{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(B,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const s=t||ae(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.V(s,fe("disableProviderPing")))}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;const i=parseInt(ce(t));e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,s;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const n=parseInt(i,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:null==(s=this.namespace.chains)?void 0:s[0]}),this.setDefaultChain(`${n}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,s,i;const n=null==(s=null==(t=e.request)?void 0:t.params)?void 0:s[0];if(!n)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const r=this.client.session.get(e.topic),o=(null==(i=r?.sessionProperties)?void 0:i.capabilities)||{};if(null!=o&&o[n])return o?.[n];const a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:qe(Re({},r.sessionProperties||{}),{capabilities:qe(Re({},o||{}),{[n]:a})})})}catch(e){}return a}async getCallStatus(e){var t,s;const i=this.client.session.get(e.topic),n=null==(t=i.sessionProperties)?void 0:t.bundler_name;if(n){const t=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(t,e)}catch(e){}}const r=null==(s=i.sessionProperties)?void 0:s.bundler_url;if(r)try{return await this.getUserOperationReceipt(r,e)}catch(e){}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var s;const i=new URL(e),n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,p.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(s=t.request.params)?void 0:s[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,t){return`${Y}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class Ne{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(B,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;const i=ce(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.A(s,fe("disableProviderPing")))}}class $e{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(B,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;const i=ce(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.A(s,fe("disableProviderPing")))}}class Ce{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const s=t||ae(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.chainId=e,this.events.emit(B,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new G.F(new F.A(s,fe("disableProviderPing")))}}class Te{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(B,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{const s=this.getCardanoRPCUrl(t),i=ce(t);e[i]=this.createHttpProvider(i,s)})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||this.getCardanoRPCUrl(e);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.A(s,fe("disableProviderPing")))}}class Ae{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(B,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;const i=ce(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.A(s,fe("disableProviderPing")))}}class De{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(B,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;const i=ce(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.A(s,fe("disableProviderPing")))}}class xe{constructor(e){this.name="near",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||ae(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(B,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace);return typeof s>"u"?void 0:new G.F(new F.A(s,fe("disableProviderPing")))}}class je{constructor(e){this.name="tezos",this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||ae(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(B,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{e[t]=this.createHttpProvider(t)})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace);return typeof s>"u"?void 0:new G.F(new F.A(s))}}class ke{constructor(e){this.name=W,this.namespace=e.namespace,this.events=fe("events"),this.client=fe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(B,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){var e,t;const s={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach((e=>{const t=(0,a._Yb)(e);s[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)})),s}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||ae(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new G.F(new F.A(s,fe("disableProviderPing")))}}var Me=Object.defineProperty,Ue=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,He=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,Fe=(e,t,s)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ge=(e,t)=>{for(var s in t||(t={}))Le.call(t,s)&&Fe(e,s,t[s]);if(He)for(var s of He(t))Ke.call(t,s)&&Fe(e,s,t[s]);return e},Je=(e,t)=>Ue(e,Ve(t));class ze{constructor(e){this.events=new(h()),this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||J})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new ze(e);return await t.initialize(),t}async request(e,t,s){const[i,n]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Ge({},e),chainId:`${i}:${n}`,topic:this.session.topic,expiry:s})}sendAsync(e,t,s,i){const n=(new Date).getTime();this.request(e,s,i).then((e=>t(null,(0,p.formatJsonRpcResult)(n,e)))).catch((e=>t(e,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 e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:(0,a.Hjj)("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:s,response:i}=await this.client.authenticate(e,t);s&&(this.uri=s,this.events.emit("display_uri",s));const n=await i();if(this.session=n.session,this.session){const e=de(this.session.namespaces);this.namespaces=pe(this.namespaces,e),this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await i().then((e=>{this.session=e;const t=de(e.namespaces);this.namespaces=pe(this.namespaces,t),this.persist("namespaces",this.namespaces)})).catch((e=>{if(e.message!==f)throw e;t++}))}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[s,i]=this.validateChain(e),n=this.getProvider(s);n.name===W?n.setDefaultChain(`${s}:${i}`,t):n.setDefaultChain(i,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if((0,a.OP1)(t)){for(const s of t)e.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${t.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 e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await L.init({core:this.providerOpts.core,logger:this.providerOpts.logger||J,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),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 e=[...new Set(Object.keys(this.session.namespaces).map((e=>(0,a.kob)(e))))];we("client",this.client),we("events",this.events),we("disableProviderPing",this.disableProviderPing),e.forEach((e=>{if(!this.session)return;const t=function(e,t){const s=Object.keys(t.namespaces).filter((t=>t.includes(e)));if(!s.length)return[];const i=[];return s.forEach((e=>{const s=t.namespaces[e].accounts;i.push(...s)})),i}(e,this.session),s=he(t),i=pe(this.namespaces,this.optionalNamespaces),n=Je(Ge({},i[e]),{accounts:t,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new Oe({namespace:n});break;case"algorand":this.rpcProviders[e]=new Ce({namespace:n});break;case"solana":this.rpcProviders[e]=new Ne({namespace:n});break;case"cosmos":this.rpcProviders[e]=new $e({namespace:n});break;case"polkadot":this.rpcProviders[e]=new ye({namespace:n});break;case"cip34":this.rpcProviders[e]=new Te({namespace:n});break;case"elrond":this.rpcProviders[e]=new Ae({namespace:n});break;case"multiversx":this.rpcProviders[e]=new De({namespace:n});break;case"near":this.rpcProviders[e]=new xe({namespace:n});break;case"tezos":this.rpcProviders[e]=new je({namespace:n});break;default:this.rpcProviders[W]?this.rpcProviders[W].updateNamespace(n):this.rpcProviders[W]=new ke({namespace:n})}}))}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",(e=>{this.events.emit("session_ping",e)})),this.client.on("session_event",(e=>{const{params:t}=e,{event:s}=t;if("accountsChanged"===s.name){const e=s.data;e&&(0,a.OP1)(e)&&this.events.emit("accountsChanged",e.map(ue))}else if("chainChanged"===s.name){const e=t.chainId,s=t.event.data,i=(0,a.kob)(e),n=ge(e)!==ge(s)?`${i}:${ge(s)}`:e;this.onChainChanged(n)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)})),this.client.on("session_update",(({topic:e,params:t})=>{var s;const{namespaces:i}=t,n=null==(s=this.client)?void 0:s.session.get(e);this.session=Je(Ge({},n),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})})),this.client.on("session_delete",(async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Je(Ge({},(0,a.Hjj)("USER_DISCONNECTED")),{data:e.topic}))})),this.on(B,(e=>{this.onChainChanged(e,!0)}))}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[W]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach((e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])}))}setNamespaces(e){const{namespaces:t,optionalNamespaces:s,sessionProperties:i}=e;t&&Object.keys(t).length&&(this.namespaces=t),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=i,this.persist("namespaces",t),this.persist("optionalNamespaces",s)}validateChain(e){const[t,s]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,s];if(t&&!Object.keys(this.namespaces||{}).map((e=>(0,a.kob)(e))).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&s)return[t,s];const i=(0,a.kob)(Object.keys(this.namespaces)[0]);return[i,this.rpcProviders[i].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[s,i]=this.validateChain(e);i&&(t||this.getProvider(s).setDefaultChain(i),this.namespaces[s]?this.namespaces[s].defaultChain=i:this.namespaces[`${s}:${i}`]?this.namespaces[`${s}:${i}`].defaultChain=i:this.namespaces[`${s}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}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(e,t){this.client.core.storage.setItem(`${z}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${z}/${e}`)}}},6754:(e,t,s)=>{"use strict";s.d(t,{$Bq:()=>lt,$hI:()=>W,ADD:()=>V,ALl:()=>Fe,AYU:()=>qt,Alu:()=>Ut,AwN:()=>et,BdH:()=>O,C5G:()=>Ze,CTo:()=>Ot,EHS:()=>xe,EN$:()=>Ke,EWt:()=>$e,F$L:()=>Ye,FR8:()=>Ft,FiO:()=>jt,GuA:()=>yt,HNf:()=>St,Hbs:()=>Yt,Hjj:()=>vt,IjX:()=>me,K3g:()=>M,Lln:()=>_,Lp_:()=>De,M8n:()=>Kt,OP1:()=>Et,PUk:()=>j,Pa8:()=>Ce,QJh:()=>pt,Qhg:()=>bt,R7U:()=>$,TRk:()=>J,TZl:()=>Ve,TeY:()=>Vt,Tw2:()=>Qe,U0i:()=>it,V7m:()=>tt,V9G:()=>Mt,VBM:()=>qe,Van:()=>mt,WWN:()=>Re,Wx8:()=>k,X3c:()=>Ht,XqR:()=>Qt,Xw0:()=>K,YcA:()=>We,_Yb:()=>v,_dF:()=>F,aF0:()=>Pt,aRZ:()=>q,aa1:()=>ot,b07:()=>It,bEt:()=>Ne,c82:()=>L,e8_:()=>Pe,esh:()=>xt,gOF:()=>H,gZm:()=>Y,h0Y:()=>x,hEn:()=>G,hVC:()=>be,hwK:()=>fe,iV1:()=>Lt,iui:()=>Xe,jTh:()=>Q,jUZ:()=>A,kob:()=>gt,kuU:()=>kt,lFF:()=>C,lVv:()=>S,m01:()=>R,mr0:()=>Nt,n3s:()=>z,n6V:()=>rt,nWe:()=>dt,nyL:()=>es,oKp:()=>Jt,ojD:()=>T,ovp:()=>Le,ps1:()=>st,q_h:()=>ge,sc7:()=>Bt,sc_:()=>Se,tLy:()=>Gt,tk0:()=>$t,two:()=>He,uym:()=>Xt,w8K:()=>B,wYp:()=>ct,wa2:()=>ze,x0t:()=>Je,xkc:()=>de,yy4:()=>Z,z2N:()=>zt});var i=s(48468),n=s(88900),r=s(38196),o=s(42063),a=s(47234),c=s(82833),h=s(51612),p=s(16804),l=s(37052),u=s(50204),d=s(774),g=s(53155),m=s(31140),f=s(10106),w=s(43228);const y=":";function v(e){const[t,s]=e.split(y);return{namespace:t,reference:s}}function E(e,t){return e.includes(":")?[e]:t.chains||[]}const P="ReactNative",I={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},b="js";function _(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function S(){return!(0,r.getDocument)()&&!!(0,r.getNavigator)()&&navigator.product===P}function R(){return S()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"android"===(null==s.g?void 0:s.g.Platform.OS)}function q(){return S()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"ios"===(null==s.g?void 0:s.g.Platform.OS)}function O(){return!_()&&!!(0,r.getNavigator)()&&!!(0,r.getDocument)()}function N(){return S()?I.reactNative:_()?I.node:O()?I.browser:I.unknown}function $(){var e;try{return S()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Application)<"u"?null==(e=s.g.Application)?void 0:e.applicationId:void 0}catch{return}}function C(){return(0,o.g)()||{name:"",description:"",url:"",icons:[""]}}function T(e,t,n){const o=function(){if(N()===I.reactNative&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"){const{OS:e,Version:t}=s.g.Platform;return[e,t].join("-")}const e=(0,i.o0)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;const t=N();return t===I.browser?[t,(null==(e=(0,r.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[b,n].join("-"),o,a].join("/")}function A({protocol:e,version:t,relayUrl:s,sdkVersion:i,auth:n,projectId:r,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=s.split("?"),p={auth:n,ua:T(e,t,i),projectId:r,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},l=function(e,t){const s=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const i=t[e];void 0!==i&&s.set(e,i)}return s.toString()}(h[1]||"",p);return h[0]+"?"+l}function D(e,t){return e.filter((e=>t.includes(e))).length===e.length}function x(e){return Object.fromEntries(e.entries())}function j(e){return new Map(Object.entries(e))}function k(e=n.FIVE_MINUTES,t){const s=(0,n.toMiliseconds)(e||n.FIVE_MINUTES);let i,r,o,a;return{resolve:e=>{o&&i&&(clearTimeout(o),i(e),a=Promise.resolve(e))},reject:e=>{o&&r&&(clearTimeout(o),r(e))},done:()=>new Promise(((e,n)=>{if(a)return e(a);o=setTimeout((()=>{const e=new Error(t);a=Promise.reject(e),n(e)}),s),i=e,r=n}))}}function M(e,t,s){return new Promise((async(i,n)=>{const r=setTimeout((()=>n(new Error(s))),t);try{i(await e)}catch(e){n(e)}clearTimeout(r)}))}function U(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function V(e){return U("topic",e)}function H(e){return U("id",e)}function L(e){const[t,s]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof s)i.topic=s;else{if("id"!==t||!Number.isInteger(Number(s)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${s}`);i.id=Number(s)}return i}function K(e,t){return(0,n.fromMiliseconds)((t||Date.now())+(0,n.toMiliseconds)(e))}function F(e){return Date.now()>=(0,n.toMiliseconds)(e)}function G(e,t){return`${e}${t?`:${t}`:""}`}function J(e=[],t=[]){return[...new Set([...e,...t])]}async function z({id:e,topic:t,wcDeepLink:i}){var n;try{if(!i)return;const o="string"==typeof i?JSON.parse(i):i,a=o?.href;if("string"!=typeof a)return;const c=function(e,t,s){const i=`requestId=${t}&sessionTopic=${s}`;e.endsWith("/")&&(e=e.slice(0,-1));let n=`${e}`;if(e.startsWith("https://t.me")){n=`${n}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const s=Buffer.from(e).toString("base64");return t?s.replace(/[=]/g,""):s}(i,!0)}`}else n=`${n}/wc?${i}`;return n}(a,e,t),h=N();if(h===I.browser){if(null==(n=(0,r.getDocument)())||!n.hasFocus())return;!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(c)}else h===I.reactNative&&typeof(null==s.g?void 0:s.g.Linking)<"u"&&await s.g.Linking.openURL(c)}catch(e){}}async function Q(e,t){let s="";try{if(O()&&(s=localStorage.getItem(t),s))return s;s=await e.getItem(t)}catch(e){}return s}function W(e,t){if(!e.includes(t))return null;const s=e.split(/([&,?,=])/),i=s.indexOf(t);return s[i+2]}function Y(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function B(){return typeof process<"u"&&"true"===process.env.IS_VITEST}function X(e){return Buffer.from(e,"base64").toString("utf-8")}function Z(e){return new Promise((t=>setTimeout(t,e)))}const ee="https://rpc.walletconnect.org/v1";async function te(e,t,s,i,n,r){switch(s.t){case"eip191":return function(e,t,s){return(0,c.x_)((0,a.A)(t),s).toLowerCase()===e.toLowerCase()}(e,t,s.s);case"eip1271":return await async function(e,t,s,i,n,r){const o=v(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const o="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",p=s.substring(2),l=o+(0,a.A)(t).substring(2)+c+h+p,u=await fetch(`${r||ee}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:se(),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:l},"latest"]})}),{result:d}=await u.json();return!!d&&d.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return!1}}(e,t,s.s,i,n,r);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}function se(){return Date.now()+Math.floor(1e3*Math.random())}var ie=Object.defineProperty,ne=Object.defineProperties,re=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,he=(e,t,s)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,pe=(e,t)=>{for(var s in t||(t={}))ae.call(t,s)&&he(e,s,t[s]);if(oe)for(var s of oe(t))ce.call(t,s)&&he(e,s,t[s]);return e},le=(e,t)=>ne(e,re(t));const ue=e=>e?.split(":"),de=e=>{const t=e&&ue(e);if(t)return t[2]+":"+t[3]},ge=e=>{const t=e&&ue(e);if(t)return t.pop()};async function me(e){const{cacao:t,projectId:s}=e,{s:i,p:n}=t,r=fe(n,n.iss),o=ge(n.iss);return await te(o,r,i,de(n.iss),s)}const fe=(e,t)=>{const s=`${e.domain} wants you to sign in with your Ethereum account:`,i=ge(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=e.statement||void 0;const r=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&ue(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,h=`Issued At: ${e.iat}`,p=e.exp?`Expiration Time: ${e.exp}`:void 0,l=e.nbf?`Not Before: ${e.nbf}`:void 0,u=e.requestId?`Request ID: ${e.requestId}`:void 0,d=e.resources?`Resources:${e.resources.map((e=>`\n- ${e}`)).join("")}`:void 0,g=qe(e.resources);if(g){n=_e(n,Ee(g))}return[s,i,"",n,"",r,o,a,c,h,p,l,u,d].filter((e=>null!=e)).join("\n")};function we(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach((t=>{const s=e.att[t];if(Array.isArray(s))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof s)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(s).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(s).forEach((e=>{const t=s[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach((t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)}))}))}))}function ye(e,t,s={}){t=t?.sort(((e,t)=>e.localeCompare(t)));const i=t.map((t=>({[`${e}/${t}`]:[s]})));return Object.assign({},...i)}function ve(e){return we(e),`urn:recap:${function(e){return Buffer.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function Ee(e){const t=function(e){return JSON.parse(Buffer.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return we(t),t}function Pe(e,t,s){const i=function(e,t,s,i={}){return s?.sort(((e,t)=>e.localeCompare(t))),{att:{[e]:ye(t,s,i)}}}(e,t,s);return ve(i)}function Ie(e){return e&&e.includes("urn:recap:")}function be(e,t){const s=function(e,t){we(e),we(t);const s=Object.keys(e.att).concat(Object.keys(t.att)).sort(((e,t)=>e.localeCompare(t))),i={att:{}};return s.forEach((s=>{var n,r;Object.keys((null==(n=e.att)?void 0:n[s])||{}).concat(Object.keys((null==(r=t.att)?void 0:r[s])||{})).sort(((e,t)=>e.localeCompare(t))).forEach((n=>{var r,o;i.att[s]=le(pe({},i.att[s]),{[n]:(null==(r=e.att[s])?void 0:r[n])||(null==(o=t.att[s])?void 0:o[n])})}))})),i}(Ee(e),Ee(t));return ve(s)}function _e(e="",t){we(t);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(s))return e;const i=[];let n=0;Object.keys(t.att).forEach((e=>{const s=Object.keys(t.att[e]).map((e=>({ability:e.split("/")[0],action:e.split("/")[1]})));s.sort(((e,t)=>e.action.localeCompare(t.action)));const r={};s.forEach((e=>{r[e.ability]||(r[e.ability]=[]),r[e.ability].push(e.action)}));const o=Object.keys(r).map((t=>(n++,`(${n}) '${t}': '${r[t].join("', '")}' for '${e}'.`)));i.push(o.join(", ").replace(".,","."))}));return`${e?e+" ":""}${`${s}${i.join(" ")}`}`}function Se(e){var t;const s=Ee(e);we(s);const i=null==(t=s.att)?void 0:t.eip155;return i?Object.keys(i).map((e=>e.split("/")[1])):[]}function Re(e){const t=Ee(e);we(t);const s=[];return Object.values(t.att).forEach((e=>{Object.values(e).forEach((e=>{var t;null!=(t=e?.[0])&&t.chains&&s.push(e[0].chains)}))})),[...new Set(s.flat())]}function qe(e){if(!e)return;const t=e?.[e.length-1];return Ie(t)?t:void 0}const Oe="base10",Ne="base16",$e="base64pad",Ce="base64url",Te="utf8",Ae=0,De=1,xe=2,je=0,ke=1,Me=12,Ue=32;function Ve(){const e=d.TZ();return{privateKey:(0,g.dI)(e.secretKey,Ne),publicKey:(0,g.dI)(e.publicKey,Ne)}}function He(){const e=(0,l.randomBytes)(Ue);return(0,g.dI)(e,Ne)}function Le(e,t){const s=d.Tc((0,g.sH)(e,Ne),(0,g.sH)(t,Ne),!0),i=new p.i(u.aD,s).expand(Ue);return(0,g.dI)(i,Ne)}function Ke(e){const t=(0,u.tW)((0,g.sH)(e,Ne));return(0,g.dI)(t,Ne)}function Fe(e){const t=(0,u.tW)((0,g.sH)(e,Te));return(0,g.dI)(t,Ne)}function Ge(e){return(0,g.sH)(`${e}`,Oe)}function Je(e){return Number((0,g.dI)(e,Oe))}function ze(e){const t=Ge(typeof e.type<"u"?e.type:Ae);if(Je(t)===De&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof e.senderPublicKey<"u"?(0,g.sH)(e.senderPublicKey,Ne):void 0,i=typeof e.iv<"u"?(0,g.sH)(e.iv,Ne):(0,l.randomBytes)(Me);return Be({type:t,sealed:new h.g6((0,g.sH)(e.symKey,Ne)).seal(i,(0,g.sH)(e.message,Te)),iv:i,senderPublicKey:s,encoding:e.encoding})}function Qe(e,t){const s=Ge(xe),i=(0,l.randomBytes)(Me);return Be({type:s,sealed:(0,g.sH)(e,Te),iv:i,encoding:t})}function We(e){const t=new h.g6((0,g.sH)(e.symKey,Ne)),{sealed:s,iv:i}=Xe({encoded:e.encoded,encoding:e?.encoding}),n=t.open(i,s);if(null===n)throw new Error("Failed to decrypt");return(0,g.dI)(n,Te)}function Ye(e,t){const{sealed:s}=Xe({encoded:e,encoding:t});return(0,g.dI)(s,Te)}function Be(e){const{encoding:t=$e}=e;if(Je(e.type)===xe)return(0,g.dI)((0,g.xW)([e.type,e.sealed]),t);if(Je(e.type)===De){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,g.dI)((0,g.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,g.dI)((0,g.xW)([e.type,e.iv,e.sealed]),t)}function Xe(e){const{encoded:t,encoding:s=$e}=e,i=(0,g.sH)(t,s),n=i.slice(je,ke),r=ke;if(Je(n)===De){const e=r+Ue,t=e+Me,s=i.slice(r,e),o=i.slice(e,t);return{type:n,sealed:i.slice(t),iv:o,senderPublicKey:s}}if(Je(n)===xe){return{type:n,sealed:i.slice(r),iv:(0,l.randomBytes)(Me)}}const o=r+Me,a=i.slice(r,o);return{type:n,sealed:i.slice(o),iv:a}}function Ze(e,t){const s=Xe({encoded:e,encoding:t?.encoding});return et({type:Je(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?(0,g.dI)(s.senderPublicKey,Ne):void 0,receiverPublicKey:t?.receiverPublicKey})}function et(e){const t=e?.type||Ae;if(t===De){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function tt(e){return e.type===De&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function st(e){return e.type===xe}function it(e,t){const[s,i,n]=e.split("."),r=function(e){return Buffer.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const s=t.length%4;return s>0&&(t+="=".repeat(4-s)),t}(e),"base64")}(n);if(64!==r.length)throw new Error("Invalid signature length");const o=r.slice(0,32).toString("hex"),a=r.slice(32,64).toString("hex"),c=`${s}.${i}`,h=(new u.aD).update(Buffer.from(c)).digest(),p=function(e){return new m.ec("p256").keyFromPublic({x:Buffer.from(e.x,"base64").toString("hex"),y:Buffer.from(e.y,"base64").toString("hex")},"hex")}(t),l=Buffer.from(h).toString("hex");if(!p.verify(l,{r:o,s:a}))throw new Error("Invalid signature");return(0,f.decodeJWT)(e).payload}const nt="irn";function rt(e){return e?.relay||{protocol:nt}}function ot(e){const t=w.CG[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function at(e,t="-"){const s={},i="relay"+t;return Object.keys(e).forEach((t=>{if(t.startsWith(i)){const n=t.replace(i,""),r=e[t];s[n]=r}})),s}function ct(e){if(!e.includes("wc:")){const t=X(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),s=-1!==e.indexOf("?")?e.indexOf("?"):void 0,i=e.substring(0,t),n=e.substring(t+1,s).split("@"),r=typeof s<"u"?e.substring(s):"",o=new URLSearchParams(r),a={};o.forEach(((e,t)=>{a[t]=e}));const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:i,topic:ht(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:at(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function ht(e){return e.startsWith("//")?e.substring(2):e}function pt(e){const t=new URLSearchParams,s=function(e,t="-"){const s={};return Object.keys(e).forEach((i=>{const n="relay"+t+i;e[i]&&(s[n]=e[i])})),s}(e.relay);Object.keys(s).sort().forEach((e=>{t.set(e,s[e])})),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`}function lt(e,t,s){return`${e}?wc_ev=${s}&topic=${t}`}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;function ut(e){const t=[];return e.forEach((e=>{const[s,i]=e.split(":");t.push(`${s}:${i}`)})),t}function dt(e){return e.includes(":")}function gt(e){return dt(e)?e.split(":")[0]:e}function mt(e,t){const s=function(e){const t={};return e?.forEach((e=>{const[s,i]=e.split(":");t[s]||(t[s]={accounts:[],chains:[],events:[]}),t[s].accounts.push(e),t[s].chains.push(`${s}:${i}`)})),t}(t=t.map((e=>e.replace("did:pkh:",""))));for(const[t,i]of Object.entries(s))i.methods?i.methods=J(i.methods,e):i.methods=e,i.events=["chainChanged","accountsChanged"];return s}const ft={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}},wt={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 yt(e,t){const{message:s,code:i}=wt[e];return{message:t?`${s} ${t}`:s,code:i}}function vt(e,t){const{message:s,code:i}=ft[e];return{message:t?`${s} ${t}`:s,code:i}}function Et(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Pt(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function It(e){return typeof e>"u"}function bt(e,t){return!(!t||!It(e))||"string"==typeof e&&!!e.trim().length}function _t(e,t){return!(!t||!It(e))||"number"==typeof e&&!isNaN(e)}function St(e,t){const{requiredNamespaces:s}=t,i=Object.keys(e.namespaces),n=Object.keys(s);let r=!0;return!!D(n,i)&&(i.forEach((t=>{const{accounts:i,methods:n,events:o}=e.namespaces[t],a=ut(i),c=s[t];D(E(t,c),a)&&D(c.methods,n)&&D(c.events,o)||(r=!1)})),r)}function Rt(e){return!(!bt(e,!1)||!e.includes(":"))&&2===e.split(":").length}function qt(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(bt(e,!1)){if(t(e))return!0;return t(X(e))}}catch{}return!1}function Ot(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}function Nt(e){return e?.topic}function $t(e,t){let s=null;return bt(e?.publicKey,!1)||(s=yt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),s}function Ct(e){let t=!0;return Et(e)?e.length&&(t=e.every((e=>bt(e,!1)))):t=!1,t}function Tt(e,t,s){let i=null;return Object.entries(e).forEach((([e,n])=>{if(i)return;const r=function(e,t,s){let i=null;return Et(t)&&t.length?t.forEach((e=>{i||Rt(e)||(i=vt("UNSUPPORTED_CHAINS",`${s}, chain ${e} should be a string and conform to "namespace:chainId" format`))})):Rt(e)||(i=vt("UNSUPPORTED_CHAINS",`${s}, 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"] }`)),i}(e,E(e,n),`${t} ${s}`);r&&(i=r)})),i}function At(e,t){let s=null;return Et(e)?e.forEach((e=>{s||function(e){if(bt(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Rt(e)}}return!1}(e)||(s=vt("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):s=vt("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}function Dt(e,t){let s=null;return Object.values(e).forEach((e=>{if(s)return;const i=function(e,t){let s=null;return Ct(e?.methods)?Ct(e?.events)||(s=vt("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):s=vt("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),s}(e,`${t}, namespace`);i&&(s=i)})),s}function xt(e,t,s){let i=null;if(e&&Pt(e)){const n=Dt(e,t);n&&(i=n);const r=Tt(e,t,s);r&&(i=r)}else i=yt("MISSING_OR_INVALID",`${t}, ${s} should be an object with data`);return i}function jt(e,t){let s=null;if(e&&Pt(e)){const i=Dt(e,t);i&&(s=i);const n=function(e,t){let s=null;return Object.values(e).forEach((e=>{if(s)return;const i=At(e?.accounts,`${t} namespace`);i&&(s=i)})),s}(e,t);n&&(s=n)}else s=yt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return s}function kt(e){return bt(e.protocol,!0)}function Mt(e,t){let s=!1;return t&&!e?s=!0:e&&Et(e)&&e.length&&e.forEach((e=>{s=kt(e)})),s}function Ut(e){return"number"==typeof e}function Vt(e){return typeof e<"u"&&null!==typeof e}function Ht(e){return!!(e&&"object"==typeof e&&e.code&&_t(e.code,!1)&&e.message&&bt(e.message,!1))}function Lt(e){return!(It(e)||!bt(e.method,!1))}function Kt(e){return!(It(e)||It(e.result)&&It(e.error)||!_t(e.id,!1)||!bt(e.jsonrpc,!1))}function Ft(e){return!(It(e)||!bt(e.name,!1))}function Gt(e,t){return!(!Rt(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...ut(e.accounts))})),t}(e).includes(t))}function Jt(e,t,s){return!!bt(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach((e=>{ut(e.accounts).includes(t)&&s.push(...e.methods)})),s}(e,t).includes(s)}function zt(e,t,s){return!!bt(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach((e=>{ut(e.accounts).includes(t)&&s.push(...e.events)})),s}(e,t).includes(s)}function Qt(e,t,s){let i=null;const n=function(e){const t={};return Object.keys(e).forEach((s=>{var i;s.includes(":")?t[s]=e[s]:null==(i=e[s].chains)||i.forEach((i=>{t[i]={methods:e[s].methods,events:e[s].events}}))})),t}(e),r=function(e){const t={};return Object.keys(e).forEach((s=>{if(s.includes(":"))t[s]=e[s];else{const i=ut(e[s].accounts);i?.forEach((i=>{t[i]={accounts:e[s].accounts.filter((e=>e.includes(`${i}:`))),methods:e[s].methods,events:e[s].events}}))}})),t}(t),o=Object.keys(n),a=Object.keys(r),c=Wt(Object.keys(e)),h=Wt(Object.keys(t)),p=c.filter((e=>!h.includes(e)));return p.length&&(i=yt("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.\n Required: ${p.toString()}\n Received: ${Object.keys(t).toString()}`)),D(o,a)||(i=yt("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach((e=>{if(!e.includes(":")||i)return;const n=ut(t[e].accounts);n.includes(e)||(i=yt("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${n.toString()}`))})),o.forEach((e=>{i||(D(n[e].methods,r[e].methods)?D(n[e].events,r[e].events)||(i=yt("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${e}`)):i=yt("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${e}`))})),i}function Wt(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}function Yt(e,t){return _t(e,!1)&&e<=t.max&&e>=t.min}function Bt(){const e=N();return new Promise((t=>{switch(e){case I.browser:t(O()&&navigator?.onLine);break;case I.reactNative:t(async function(){if(S()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo){const e=await(null==s.g?void 0:s.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case I.node:default:t(!0)}}))}function Xt(e){switch(N()){case I.browser:!function(e){!S()&&O()&&(window.addEventListener("online",(()=>e(!0))),window.addEventListener("offline",(()=>e(!1))))}(e);break;case I.reactNative:!function(e){S()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo&&s.g?.NetInfo.addEventListener((t=>e(t?.isConnected)))}(e);case I.node:}}const Zt={};class es{static get(e){return Zt[e]}static set(e,t){Zt[e]=t}static delete(e){delete Zt[e]}}},4477:(e,t)=>{"use strict";function s(e,t){var s=e.length;e.push(t);e:for(;0>>1,n=e[i];if(!(0>>1;ir(c,s))hr(p,c)?(e[i]=p,e[h]=s,i=h):(e[i]=c,e[a]=s,i=a);else{if(!(hr(p,s)))break e;e[i]=p,e[h]=s,i=h}}}return t}function r(e,t){var s=e.sortIndex-t.sortIndex;return 0!==s?s:e.id-t.id}if(t.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var o=performance;t.unstable_now=function(){return o.now()}}else{var a=Date,c=a.now();t.unstable_now=function(){return a.now()-c}}var h=[],p=[],l=1,u=null,d=3,g=!1,m=!1,f=!1,w="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,v="undefined"!=typeof setImmediate?setImmediate:null;function E(e){for(var t=i(p);null!==t;){if(null===t.callback)n(p);else{if(!(t.startTime<=e))break;n(p),t.sortIndex=t.expirationTime,s(h,t)}t=i(p)}}function P(e){if(f=!1,E(e),!m)if(null!==i(h))m=!0,C();else{var t=i(p);null!==t&&T(P,t.startTime-e)}}var I,b=!1,_=-1,S=5,R=-1;function q(){return!(t.unstable_now()-Re&&q());){var o=u.callback;if("function"==typeof o){u.callback=null,d=u.priorityLevel;var a=o(u.expirationTime<=e);if(e=t.unstable_now(),"function"==typeof a){u.callback=a,E(e),s=!0;break t}u===i(h)&&n(h),E(e)}else n(h);u=i(h)}if(null!==u)s=!0;else{var c=i(p);null!==c&&T(P,c.startTime-e),s=!1}}break e}finally{u=null,d=r,g=!1}s=void 0}}finally{s?I():b=!1}}}if("function"==typeof v)I=function(){v(O)};else if("undefined"!=typeof MessageChannel){var N=new MessageChannel,$=N.port2;N.port1.onmessage=O,I=function(){$.postMessage(null)}}else I=function(){w(O,0)};function C(){b||(b=!0,I())}function T(e,s){_=w((function(){e(t.unstable_now())}),s)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){m||g||(m=!0,C())},t.unstable_forceFrameRate=function(e){0>e||125o?(e.sortIndex=r,s(p,e),null===i(h)&&e===i(p)&&(f?(y(_),_=-1):f=!0,T(P,r-o))):(e.sortIndex=a,s(h,e),m||g||(m=!0,C())),e},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(e){var t=d;return function(){var s=d;d=t;try{return e.apply(this,arguments)}finally{d=s}}}},69982:(e,t,s)=>{"use strict";e.exports=s(4477)},2833:e=>{e.exports=function(e,t,s,i){var n=s?s.call(i,e,t):void 0;if(void 0!==n)return!!n;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(t),c=0;c