diff --git a/assets/index-BTMLuAci.js b/assets/index-B10cr2A7.js similarity index 96% rename from assets/index-BTMLuAci.js rename to assets/index-B10cr2A7.js index 4d4b219..e789746 100644 --- a/assets/index-BTMLuAci.js +++ b/assets/index-B10cr2A7.js @@ -945,12 +945,12 @@ __p += '`),Mr&&(Ve+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+Ve+`return __p -}`;var ur=BO(function(){return Nr(se,Rt+"return "+Ve).apply(r,he)});if(ur.source=Ve,FC(ur))throw ur;return ur}function cae(d){return Yr(d).toLowerCase()}function lae(d){return Yr(d).toUpperCase()}function fae(d,h,A){if(d=Yr(d),d&&(A||h===r))return Yx(d);if(!d||!(h=Wo(h)))return d;var U=ho(d),J=ho(h),se=Vu(U,J),he=Qx(U,J)+1;return Qu(U,se,he).join("")}function uae(d,h,A){if(d=Yr(d),d&&(A||h===r))return d.slice(0,em(d)+1);if(!d||!(h=Wo(h)))return d;var U=ho(d),J=Qx(U,ho(h))+1;return Qu(U,0,J).join("")}function dae(d,h,A){if(d=Yr(d),d&&(A||h===r))return d.replace(Bt,"");if(!d||!(h=Wo(h)))return d;var U=ho(d),J=Vu(U,ho(h));return Qu(U,J).join("")}function hae(d,h){var A=ce,U=K;if(kn(h)){var J="separator"in h?h.separator:J;A="length"in h?fr(h.length):A,U="omission"in h?Wo(h.omission):U}d=Yr(d);var se=d.length;if(zu(d)){var he=ho(d);se=he.length}if(A>=se)return d;var ye=A-df(U);if(ye<1)return U;var Ce=he?Qu(he,0,ye).join(""):d.slice(0,ye);if(J===r)return Ce+U;if(he&&(ye+=Ce.length-ye),jC(J)){if(d.slice(ye).search(J)){var Fe,je=Ce;for(J.global||(J=tm(J.source,Yr(er.exec(J))+"g")),J.lastIndex=0;Fe=J.exec(je);)var Ve=Fe.index;Ce=Ce.slice(0,Ve===r?ye:Ve)}}else if(d.indexOf(Wo(J),ye)!=ye){var ft=Ce.lastIndexOf(J);ft>-1&&(Ce=Ce.slice(0,ft))}return Ce+U}function pae(d){return d=Yr(d),d&&Dt.test(d)?d.replace(rr,Zx):d}var vae=C1(function(d,h,A){return d+(A?" ":"")+h.toUpperCase()}),qC=LR("toUpperCase");function NO(d,h,A){return d=Yr(d),h=A?r:h,h===r?JE(d)?t2(d):qE(d):d.match(h)||[]}var BO=pr(function(d,h){try{return Qn(d,r,h)}catch(A){return FC(A)?A:new Jt(A)}}),gae=mf(function(d,h){return fo(h,function(A){A=ul(A),gf(d,A,BC(d[A],d))}),d});function yae(d){var h=d==null?0:d.length,A=Gt();return d=h?dn(d,function(U){if(typeof U[1]!="function")throw new po(o);return[A(U[0]),U[1]]}):[],pr(function(U){for(var J=-1;++JE)return[];var A=T,U=pt(d,T);h=Gt(h),d-=T;for(var J=Jy(U,h);++A0||h<0)?new _r(A):(d<0?A=A.takeRight(-d):d&&(A=A.drop(d)),h!==r&&(h=fr(h),A=h<0?A.dropRight(-h):A.take(h-d)),A)},_r.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},_r.prototype.toArray=function(){return this.take(T)},ll(_r.prototype,function(d,h){var A=/^(?:filter|find|map|reject)|While$/.test(h),U=/^(?:head|last)$/.test(h),J=ne[U?"take"+(h=="last"?"Right":""):h],se=U||/^find/.test(h);J&&(ne.prototype[h]=function(){var he=this.__wrapped__,ye=U?[1]:arguments,Ce=he instanceof _r,Fe=ye[0],je=Ce||nr(he),Ve=function(xr){var Mr=J.apply(ne,ol([xr],ye));return U&&ft?Mr[0]:Mr};je&&A&&typeof Fe=="function"&&Fe.length!=1&&(Ce=je=!1);var ft=this.__chain__,Rt=!!this.__actions__.length,Wt=se&&!ft,ur=Ce&&!Rt;if(!se&&je){he=ur?he:new _r(this);var Kt=d.apply(he,ye);return Kt.__actions__.push({func:I2,args:[Ve],thisArg:r}),new _a(Kt,ft)}return Wt&&ur?d.apply(this,ye):(Kt=this.thru(Ve),Wt?U?Kt.value()[0]:Kt.value():Kt)})}),fo(["pop","push","shift","sort","splice","unshift"],function(d){var h=f1[d],A=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",U=/^(?:pop|shift)$/.test(d);ne.prototype[d]=function(){var J=arguments;if(U&&!this.__chain__){var se=this.value();return h.apply(nr(se)?se:[],J)}return this[A](function(he){return h.apply(nr(he)?he:[],J)})}}),ll(_r.prototype,function(d,h){var A=ne[h];if(A){var U=A.name+"";Hr.call(hf,U)||(hf[U]=[]),hf[U].push({name:h,func:A})}}),hf[w2(r,C).name]=[{name:"wrapper",func:r}],_r.prototype.clone=pre,_r.prototype.reverse=vre,_r.prototype.value=gre,ne.prototype.at=Hie,ne.prototype.chain=Gie,ne.prototype.commit=Wie,ne.prototype.next=Kie,ne.prototype.plant=Qie,ne.prototype.reverse=Jie,ne.prototype.toJSON=ne.prototype.valueOf=ne.prototype.value=Zie,ne.prototype.first=ne.prototype.head,Wh&&(ne.prototype[Wh]=Yie),ne},Hu=r2();Pn?((Pn.exports=Hu)._=Hu,en._=Hu):wr._=Hu}).call(Si)})(h4,h4.exports);var IBe=h4.exports,xI={exports:{}};(function(t,e){var r=typeof self<"u"?self:Si,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function c(v){return v&&DataView.prototype.isPrototypeOf(v)}if(a.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(v){return v&&l.indexOf(Object.prototype.toString.call(v))>-1};function u(v){if(typeof v!="string"&&(v=String(v)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(v))throw new TypeError("Invalid character in header field name");return v.toLowerCase()}function p(v){return typeof v!="string"&&(v=String(v)),v}function g(v){var m={next:function(){var R=v.shift();return{done:R===void 0,value:R}}};return a.iterable&&(m[Symbol.iterator]=function(){return m}),m}function y(v){this.map={},v instanceof y?v.forEach(function(m,R){this.append(R,m)},this):Array.isArray(v)?v.forEach(function(m){this.append(m[0],m[1])},this):v&&Object.getOwnPropertyNames(v).forEach(function(m){this.append(m,v[m])},this)}y.prototype.append=function(v,m){v=u(v),m=p(m);var R=this.map[v];this.map[v]=R?R+", "+m:m},y.prototype.delete=function(v){delete this.map[u(v)]},y.prototype.get=function(v){return v=u(v),this.has(v)?this.map[v]:null},y.prototype.has=function(v){return this.map.hasOwnProperty(u(v))},y.prototype.set=function(v,m){this.map[u(v)]=p(m)},y.prototype.forEach=function(v,m){for(var R in this.map)this.map.hasOwnProperty(R)&&v.call(m,this.map[R],R,this)},y.prototype.keys=function(){var v=[];return this.forEach(function(m,R){v.push(R)}),g(v)},y.prototype.values=function(){var v=[];return this.forEach(function(m){v.push(m)}),g(v)},y.prototype.entries=function(){var v=[];return this.forEach(function(m,R){v.push([R,m])}),g(v)},a.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function b(v){if(v.bodyUsed)return Promise.reject(new TypeError("Already read"));v.bodyUsed=!0}function I(v){return new Promise(function(m,R){v.onload=function(){m(v.result)},v.onerror=function(){R(v.error)}})}function C(v){var m=new FileReader,R=I(m);return m.readAsArrayBuffer(v),R}function S(v){var m=new FileReader,R=I(m);return m.readAsText(v),R}function O(v){for(var m=new Uint8Array(v),R=new Array(m.length),B=0;B-1?m:v}function $(v,m){m=m||{};var R=m.body;if(v instanceof $){if(v.bodyUsed)throw new TypeError("Already read");this.url=v.url,this.credentials=v.credentials,m.headers||(this.headers=new y(v.headers)),this.method=v.method,this.mode=v.mode,this.signal=v.signal,!R&&v._bodyInit!=null&&(R=v._bodyInit,v.bodyUsed=!0)}else this.url=String(v);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new y(m.headers)),this.method=_(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&R)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(R)}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function ie(v){var m=new FormData;return v.trim().split("&").forEach(function(R){if(R){var B=R.split("="),E=B.shift().replace(/\+/g," "),x=B.join("=").replace(/\+/g," ");m.append(decodeURIComponent(E),decodeURIComponent(x))}}),m}function ce(v){var m=new y,R=v.replace(/\r?\n[\t ]+/g," ");return R.split(/\r?\n/).forEach(function(B){var E=B.split(":"),x=E.shift().trim();if(x){var w=E.join(":").trim();m.append(x,w)}}),m}F.call($.prototype);function K(v,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new y(m.headers),this.url=m.url||"",this._initBody(v)}F.call(K.prototype),K.prototype.clone=function(){return new K(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},K.error=function(){var v=new K(null,{status:0,statusText:""});return v.type="error",v};var P=[301,302,303,307,308];K.redirect=function(v,m){if(P.indexOf(m)===-1)throw new RangeError("Invalid status code");return new K(null,{status:m,headers:{location:v}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,R){this.message=m,this.name=R;var B=Error(m);this.stack=B.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function M(v,m){return new Promise(function(R,B){var E=new $(v,m);if(E.signal&&E.signal.aborted)return B(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function w(){x.abort()}x.onload=function(){var T={status:x.status,statusText:x.statusText,headers:ce(x.getAllResponseHeaders()||"")};T.url="responseURL"in x?x.responseURL:T.headers.get("X-Request-URL");var k="response"in x?x.response:x.responseText;R(new K(k,T))},x.onerror=function(){B(new TypeError("Network request failed"))},x.ontimeout=function(){B(new TypeError("Network request failed"))},x.onabort=function(){B(new o.DOMException("Aborted","AbortError"))},x.open(E.method,E.url,!0),E.credentials==="include"?x.withCredentials=!0:E.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&a.blob&&(x.responseType="blob"),E.headers.forEach(function(T,k){x.setRequestHeader(k,T)}),E.signal&&(E.signal.addEventListener("abort",w),x.onreadystatechange=function(){x.readyState===4&&E.signal.removeEventListener("abort",w)}),x.send(typeof E._bodyInit>"u"?null:E._bodyInit)})}return M.polyfill=!0,s.fetch||(s.fetch=M,s.Headers=y,s.Request=$,s.Response=K),o.Headers=y,o.Request=$,o.Response=K,o.fetch=M,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(xI,xI.exports);var TBe=xI.exports;const o$=_u(TBe);var PBe=Object.defineProperty,kBe=Object.defineProperties,MBe=Object.getOwnPropertyDescriptors,a$=Object.getOwnPropertySymbols,RBe=Object.prototype.hasOwnProperty,OBe=Object.prototype.propertyIsEnumerable,c$=(t,e,r)=>e in t?PBe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,l$=(t,e)=>{for(var r in e||(e={}))RBe.call(e,r)&&c$(t,r,e[r]);if(a$)for(var r of a$(e))OBe.call(e,r)&&c$(t,r,e[r]);return t},f$=(t,e)=>kBe(t,MBe(e));const DBe={Accept:"application/json","Content-Type":"application/json"},NBe="POST",u$={headers:DBe,method:NBe},d$=10;let rl=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new ba.EventEmitter,this.isAvailable=!1,this.registering=!1,!RU(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=Su(e),n=await(await o$(this.url,f$(l$({},u$),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!RU(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Su({id:1,jsonrpc:"2.0",method:"test",params:[]});await o$(e,f$(l$({},u$),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?Lp(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=PE(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return rte(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>d$&&this.events.setMaxListeners(d$)}};const h$="error",BBe="wss://relay.walletconnect.org",LBe="wc",FBe="universal_provider",p$=`${LBe}@2:${FBe}:`,_te="https://rpc.walletconnect.org/v1/",W1="generic",jBe=`${_te}bundler`,hc={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var UBe=Object.defineProperty,$Be=Object.defineProperties,qBe=Object.getOwnPropertyDescriptors,v$=Object.getOwnPropertySymbols,VBe=Object.prototype.hasOwnProperty,zBe=Object.prototype.propertyIsEnumerable,g$=(t,e,r)=>e in t?UBe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,D6=(t,e)=>{for(var r in e||(e={}))VBe.call(e,r)&&g$(t,r,e[r]);if(v$)for(var r of v$(e))zBe.call(e,r)&&g$(t,r,e[r]);return t},HBe=(t,e)=>$Be(t,qBe(e));function va(t,e,r){var n;const i=Vv(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${_te}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function t1(t){return t.includes(":")?t.split(":")[1]:t}function Ite(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function GBe(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function nS(t={},e={}){const r=y$(t),n=y$(e);return IBe.merge(r,n)}function y$(t){var e,r,n,i;const s={};if(!Rw(t))return s;for(const[o,a]of Object.entries(t)){const c=$M(o)?[o]:a.chains,l=a.methods||[],f=a.events||[],u=a.rpcMap||{},p=lb(o);s[p]=HBe(D6(D6({},s[p]),a),{chains:R3(c,(e=s[p])==null?void 0:e.chains),methods:R3(l,(r=s[p])==null?void 0:r.methods),events:R3(f,(n=s[p])==null?void 0:n.events),rpcMap:D6(D6({},u),(i=s[p])==null?void 0:i.rpcMap)})}return s}function WBe(t){return t.includes(":")?t.split(":")[2]:t}function m$(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=$M(r)?[r]:n.chains?n.chains:Ite(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function iS(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const Tte={},Vr=t=>Tte[t],sS=(t,e)=>{Tte[t]=e};class KBe{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}var YBe=Object.defineProperty,QBe=Object.defineProperties,JBe=Object.getOwnPropertyDescriptors,b$=Object.getOwnPropertySymbols,ZBe=Object.prototype.hasOwnProperty,XBe=Object.prototype.propertyIsEnumerable,w$=(t,e,r)=>e in t?YBe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x$=(t,e)=>{for(var r in e||(e={}))ZBe.call(e,r)&&w$(t,r,e[r]);if(b$)for(var r of b$(e))XBe.call(e,r)&&w$(t,r,e[r]);return t},E$=(t,e)=>QBe(t,JBe(e));class eLe{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();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,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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,r){const n=r||va(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(t1(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o==null?void 0:o.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a==null?void 0:a[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:E$(x$({},o.sessionProperties||{}),{capabilities:E$(x$({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}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,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ud("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${jBe}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}class tLe{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class rLe{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}let nLe=class{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){if(!this.httpProviders[e]){const n=r||va(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new dc(new rl(n,Vr("disableProviderPing")))}};class iLe{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=t1(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class sLe{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class oLe{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class aLe{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||va(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace);return typeof n>"u"?void 0:new dc(new rl(n,Vr("disableProviderPing")))}}class cLe{constructor(e){this.name="tezos",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||va(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace);return typeof n>"u"?void 0:new dc(new rl(n))}}class lLe{constructor(e){this.name=W1,this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=Vv(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}var fLe=Object.defineProperty,uLe=Object.defineProperties,dLe=Object.getOwnPropertyDescriptors,C$=Object.getOwnPropertySymbols,hLe=Object.prototype.hasOwnProperty,pLe=Object.prototype.propertyIsEnumerable,A$=(t,e,r)=>e in t?fLe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,N6=(t,e)=>{for(var r in e||(e={}))hLe.call(e,r)&&A$(t,r,e[r]);if(C$)for(var r of C$(e))pLe.call(e,r)&&A$(t,r,e[r]);return t},oS=(t,e)=>uLe(t,dLe(e));let vLe=class Pte{constructor(e){this.events=new yM,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:qx(IE({level:(e==null?void 0:e.logger)||h$})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new Pte(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:N6({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,TE(s,o))).catch(o=>r(o,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:(e=this.session)==null?void 0:e.topic,reason:rn("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,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=m$(this.session.namespaces);this.namespaces=nS(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await i().then(s=>{this.session=s;const o=m$(s.namespaces);this.namespaces=nS(this.namespaces,o),this.persist("namespaces",this.namespaces)}).catch(s=>{if(s.message!==Ste)throw s;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===W1?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(rf(r)){for(const n of r)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${r.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 OE.init({core:this.providerOpts.core,logger:this.providerOpts.logger||h$,relayUrl:this.providerOpts.relayUrl||BBe,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(r=>lb(r)))];sS("client",this.client),sS("events",this.events),sS("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=GBe(r,this.session),i=Ite(n),s=nS(this.namespaces,this.optionalNamespaces),o=oS(N6({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new eLe({namespace:o});break;case"algorand":this.rpcProviders[r]=new nLe({namespace:o});break;case"solana":this.rpcProviders[r]=new tLe({namespace:o});break;case"cosmos":this.rpcProviders[r]=new rLe({namespace:o});break;case"polkadot":this.rpcProviders[r]=new KBe({namespace:o});break;case"cip34":this.rpcProviders[r]=new iLe({namespace:o});break;case"elrond":this.rpcProviders[r]=new sLe({namespace:o});break;case"multiversx":this.rpcProviders[r]=new oLe({namespace:o});break;case"near":this.rpcProviders[r]=new aLe({namespace:o});break;case"tezos":this.rpcProviders[r]=new cLe({namespace:o});break;default:this.rpcProviders[W1]?this.rpcProviders[W1].updateNamespace(o):this.rpcProviders[W1]=new lLe({namespace:o})}})}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:r}=e,{event:n}=r;if(n.name==="accountsChanged"){const i=n.data;i&&rf(i)&&this.events.emit("accountsChanged",i.map(WBe))}else if(n.name==="chainChanged"){const i=r.chainId,s=r.event.data,o=lb(i),a=iS(i)!==iS(s)?`${o}:${iS(s)}`:i;this.onChainChanged(a)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n;const{namespaces:i}=r,s=(n=this.client)==null?void 0:n.session.get(e);this.session=oS(N6({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",oS(N6({},rn("USER_DISCONNECTED")),{data:e.topic}))}),this.on(hc.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[W1]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.persist("namespaces",r),this.persist("optionalNamespaces",n)}validateChain(e){const[r,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>lb(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=lb(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);i&&(r||this.getProvider(n).setDefaultChain(i),this.namespaces[n]?this.namespaces[n].defaultChain=i:this.namespaces[`${n}:${i}`]?this.namespaces[`${n}:${i}`].defaultChain=i:this.namespaces[`${n}:${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,r){this.client.core.storage.setItem(`${p$}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${p$}/${e}`)}};const gLe=vLe,yLe="wc",mLe="ethereum_provider",bLe=`${yLe}@2:${mLe}:`,wLe="https://rpc.walletconnect.org/v1/",EI=["eth_sendTransaction","personal_sign"],xLe=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],CI=["chainChanged","accountsChanged"],ELe=["chainChanged","accountsChanged","message","disconnect","connect"];var CLe=Object.defineProperty,ALe=Object.defineProperties,SLe=Object.getOwnPropertyDescriptors,S$=Object.getOwnPropertySymbols,_Le=Object.prototype.hasOwnProperty,ILe=Object.prototype.propertyIsEnumerable,_$=(t,e,r)=>e in t?CLe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K1=(t,e)=>{for(var r in e||(e={}))_Le.call(e,r)&&_$(t,r,e[r]);if(S$)for(var r of S$(e))ILe.call(e,r)&&_$(t,r,e[r]);return t},aS=(t,e)=>ALe(t,SLe(e));function p4(t){return Number(t[0].split(":")[1])}function B6(t){return`0x${t.toString(16)}`}function TLe(t){const{chains:e,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=t;if(!rf(e))throw new Error("Invalid chains");const c={chains:e,methods:n||EI,events:s||CI,rpcMap:K1({},e.length?{[p4(e)]:a[p4(e)]}:{})},l=s==null?void 0:s.filter(g=>!CI.includes(g)),f=n==null?void 0:n.filter(g=>!EI.includes(g));if(!r&&!o&&!i&&!(l!=null&&l.length)&&!(f!=null&&f.length))return{required:e.length?c:void 0};const u=(l==null?void 0:l.length)&&(f==null?void 0:f.length)||!r,p={chains:[...new Set(u?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(i!=null&&i.length?i:xLe))],events:[...new Set(c.events.concat(o!=null&&o.length?o:ELe))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?p:void 0}}let PLe=class kte{constructor(){this.events=new ba.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=bLe,this.on=(e,r)=>(this.events.on(e,r),this),this.once=(e,r)=>(this.events.once(e,r),this),this.removeListener=(e,r)=>(this.events.removeListener(e,r),this),this.off=(e,r)=>(this.events.off(e,r),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const r=new kte;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,n){this.signer.sendAsync(e,r,this.formatChainId(this.chainId),n)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:n}=TLe(this.rpc);try{const i=await new Promise(async(o,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(aS(K1({namespaces:K1({},r&&{[this.namespace]:r})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(l=>{o(l)}).catch(l=>{a(new Error(l.message))})});if(!i)return;const s=Yj(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:B6(this.chainId)})}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const n=await new Promise(async(s,o)=>{var a;this.rpc.showQrModal&&((a=this.modal)==null||a.subscribeModal(c=>{!c.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),o(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(aS(K1({},e),{chains:this.rpc.chains}),r).then(c=>{s(c)}).catch(c=>{o(new Error(c.message))})}),i=n.session;if(i){const s=Yj(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:B6(this.chainId)})}return n}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:n}=r;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",B6(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",aS(K1({},rn("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,n;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(n=this.modal)==null||n.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",B6(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,n;const i=(r=e==null?void 0:e.chains)!=null?r:[],s=(n=e==null?void 0:e.optionalChains)!=null?n:[],o=i.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=i.length?(e==null?void 0:e.methods)||EI:[],c=i.length?(e==null?void 0:e.events)||CI:[],l=(e==null?void 0:e.optionalMethods)||[],f=(e==null?void 0:e.optionalEvents)||[],u=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),p=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:i==null?void 0:i.map(g=>this.formatChainId(g)),optionalChains:s.map(g=>this.formatChainId(g)),methods:a,events:c,optionalMethods:l,optionalEvents:f,rpcMap:u,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:p,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const n={};return e.forEach(i=>{n[i]=this.getRpcUrl(i,r)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?p4(this.rpc.chains):p4(this.rpc.optionalChains),this.signer=await gLe.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:n}=await R9e(()=>import("./index-Mx8kZtbv.js").then(i=>i.i),[]);r=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(K1({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:n,rpcMap:i}=e;r&&rf(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)})),n&&rf(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(s=>this.formatChainId(s)),n.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)}))}getRpcUrl(e,r){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${wLe}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}};var Mte={exports:{}};/*! +}`;var ur=BO(function(){return Nr(se,Rt+"return "+Ve).apply(r,he)});if(ur.source=Ve,FC(ur))throw ur;return ur}function cae(d){return Yr(d).toLowerCase()}function lae(d){return Yr(d).toUpperCase()}function fae(d,h,A){if(d=Yr(d),d&&(A||h===r))return Yx(d);if(!d||!(h=Wo(h)))return d;var U=ho(d),J=ho(h),se=Vu(U,J),he=Qx(U,J)+1;return Qu(U,se,he).join("")}function uae(d,h,A){if(d=Yr(d),d&&(A||h===r))return d.slice(0,em(d)+1);if(!d||!(h=Wo(h)))return d;var U=ho(d),J=Qx(U,ho(h))+1;return Qu(U,0,J).join("")}function dae(d,h,A){if(d=Yr(d),d&&(A||h===r))return d.replace(Bt,"");if(!d||!(h=Wo(h)))return d;var U=ho(d),J=Vu(U,ho(h));return Qu(U,J).join("")}function hae(d,h){var A=ce,U=K;if(kn(h)){var J="separator"in h?h.separator:J;A="length"in h?fr(h.length):A,U="omission"in h?Wo(h.omission):U}d=Yr(d);var se=d.length;if(zu(d)){var he=ho(d);se=he.length}if(A>=se)return d;var ye=A-df(U);if(ye<1)return U;var Ce=he?Qu(he,0,ye).join(""):d.slice(0,ye);if(J===r)return Ce+U;if(he&&(ye+=Ce.length-ye),jC(J)){if(d.slice(ye).search(J)){var Fe,je=Ce;for(J.global||(J=tm(J.source,Yr(er.exec(J))+"g")),J.lastIndex=0;Fe=J.exec(je);)var Ve=Fe.index;Ce=Ce.slice(0,Ve===r?ye:Ve)}}else if(d.indexOf(Wo(J),ye)!=ye){var ft=Ce.lastIndexOf(J);ft>-1&&(Ce=Ce.slice(0,ft))}return Ce+U}function pae(d){return d=Yr(d),d&&Dt.test(d)?d.replace(rr,Zx):d}var vae=C1(function(d,h,A){return d+(A?" ":"")+h.toUpperCase()}),qC=LR("toUpperCase");function NO(d,h,A){return d=Yr(d),h=A?r:h,h===r?JE(d)?t2(d):qE(d):d.match(h)||[]}var BO=pr(function(d,h){try{return Qn(d,r,h)}catch(A){return FC(A)?A:new Jt(A)}}),gae=mf(function(d,h){return fo(h,function(A){A=ul(A),gf(d,A,BC(d[A],d))}),d});function yae(d){var h=d==null?0:d.length,A=Gt();return d=h?dn(d,function(U){if(typeof U[1]!="function")throw new po(o);return[A(U[0]),U[1]]}):[],pr(function(U){for(var J=-1;++JE)return[];var A=T,U=pt(d,T);h=Gt(h),d-=T;for(var J=Jy(U,h);++A0||h<0)?new _r(A):(d<0?A=A.takeRight(-d):d&&(A=A.drop(d)),h!==r&&(h=fr(h),A=h<0?A.dropRight(-h):A.take(h-d)),A)},_r.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},_r.prototype.toArray=function(){return this.take(T)},ll(_r.prototype,function(d,h){var A=/^(?:filter|find|map|reject)|While$/.test(h),U=/^(?:head|last)$/.test(h),J=ne[U?"take"+(h=="last"?"Right":""):h],se=U||/^find/.test(h);J&&(ne.prototype[h]=function(){var he=this.__wrapped__,ye=U?[1]:arguments,Ce=he instanceof _r,Fe=ye[0],je=Ce||nr(he),Ve=function(xr){var Mr=J.apply(ne,ol([xr],ye));return U&&ft?Mr[0]:Mr};je&&A&&typeof Fe=="function"&&Fe.length!=1&&(Ce=je=!1);var ft=this.__chain__,Rt=!!this.__actions__.length,Wt=se&&!ft,ur=Ce&&!Rt;if(!se&&je){he=ur?he:new _r(this);var Kt=d.apply(he,ye);return Kt.__actions__.push({func:I2,args:[Ve],thisArg:r}),new _a(Kt,ft)}return Wt&&ur?d.apply(this,ye):(Kt=this.thru(Ve),Wt?U?Kt.value()[0]:Kt.value():Kt)})}),fo(["pop","push","shift","sort","splice","unshift"],function(d){var h=f1[d],A=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",U=/^(?:pop|shift)$/.test(d);ne.prototype[d]=function(){var J=arguments;if(U&&!this.__chain__){var se=this.value();return h.apply(nr(se)?se:[],J)}return this[A](function(he){return h.apply(nr(he)?he:[],J)})}}),ll(_r.prototype,function(d,h){var A=ne[h];if(A){var U=A.name+"";Hr.call(hf,U)||(hf[U]=[]),hf[U].push({name:h,func:A})}}),hf[w2(r,C).name]=[{name:"wrapper",func:r}],_r.prototype.clone=pre,_r.prototype.reverse=vre,_r.prototype.value=gre,ne.prototype.at=Hie,ne.prototype.chain=Gie,ne.prototype.commit=Wie,ne.prototype.next=Kie,ne.prototype.plant=Qie,ne.prototype.reverse=Jie,ne.prototype.toJSON=ne.prototype.valueOf=ne.prototype.value=Zie,ne.prototype.first=ne.prototype.head,Wh&&(ne.prototype[Wh]=Yie),ne},Hu=r2();Pn?((Pn.exports=Hu)._=Hu,en._=Hu):wr._=Hu}).call(Si)})(h4,h4.exports);var IBe=h4.exports,xI={exports:{}};(function(t,e){var r=typeof self<"u"?self:Si,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function c(v){return v&&DataView.prototype.isPrototypeOf(v)}if(a.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(v){return v&&l.indexOf(Object.prototype.toString.call(v))>-1};function u(v){if(typeof v!="string"&&(v=String(v)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(v))throw new TypeError("Invalid character in header field name");return v.toLowerCase()}function p(v){return typeof v!="string"&&(v=String(v)),v}function g(v){var m={next:function(){var R=v.shift();return{done:R===void 0,value:R}}};return a.iterable&&(m[Symbol.iterator]=function(){return m}),m}function y(v){this.map={},v instanceof y?v.forEach(function(m,R){this.append(R,m)},this):Array.isArray(v)?v.forEach(function(m){this.append(m[0],m[1])},this):v&&Object.getOwnPropertyNames(v).forEach(function(m){this.append(m,v[m])},this)}y.prototype.append=function(v,m){v=u(v),m=p(m);var R=this.map[v];this.map[v]=R?R+", "+m:m},y.prototype.delete=function(v){delete this.map[u(v)]},y.prototype.get=function(v){return v=u(v),this.has(v)?this.map[v]:null},y.prototype.has=function(v){return this.map.hasOwnProperty(u(v))},y.prototype.set=function(v,m){this.map[u(v)]=p(m)},y.prototype.forEach=function(v,m){for(var R in this.map)this.map.hasOwnProperty(R)&&v.call(m,this.map[R],R,this)},y.prototype.keys=function(){var v=[];return this.forEach(function(m,R){v.push(R)}),g(v)},y.prototype.values=function(){var v=[];return this.forEach(function(m){v.push(m)}),g(v)},y.prototype.entries=function(){var v=[];return this.forEach(function(m,R){v.push([R,m])}),g(v)},a.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function b(v){if(v.bodyUsed)return Promise.reject(new TypeError("Already read"));v.bodyUsed=!0}function I(v){return new Promise(function(m,R){v.onload=function(){m(v.result)},v.onerror=function(){R(v.error)}})}function C(v){var m=new FileReader,R=I(m);return m.readAsArrayBuffer(v),R}function S(v){var m=new FileReader,R=I(m);return m.readAsText(v),R}function O(v){for(var m=new Uint8Array(v),R=new Array(m.length),B=0;B-1?m:v}function $(v,m){m=m||{};var R=m.body;if(v instanceof $){if(v.bodyUsed)throw new TypeError("Already read");this.url=v.url,this.credentials=v.credentials,m.headers||(this.headers=new y(v.headers)),this.method=v.method,this.mode=v.mode,this.signal=v.signal,!R&&v._bodyInit!=null&&(R=v._bodyInit,v.bodyUsed=!0)}else this.url=String(v);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new y(m.headers)),this.method=_(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&R)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(R)}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function ie(v){var m=new FormData;return v.trim().split("&").forEach(function(R){if(R){var B=R.split("="),E=B.shift().replace(/\+/g," "),x=B.join("=").replace(/\+/g," ");m.append(decodeURIComponent(E),decodeURIComponent(x))}}),m}function ce(v){var m=new y,R=v.replace(/\r?\n[\t ]+/g," ");return R.split(/\r?\n/).forEach(function(B){var E=B.split(":"),x=E.shift().trim();if(x){var w=E.join(":").trim();m.append(x,w)}}),m}F.call($.prototype);function K(v,m){m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in m?m.statusText:"OK",this.headers=new y(m.headers),this.url=m.url||"",this._initBody(v)}F.call(K.prototype),K.prototype.clone=function(){return new K(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},K.error=function(){var v=new K(null,{status:0,statusText:""});return v.type="error",v};var P=[301,302,303,307,308];K.redirect=function(v,m){if(P.indexOf(m)===-1)throw new RangeError("Invalid status code");return new K(null,{status:m,headers:{location:v}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,R){this.message=m,this.name=R;var B=Error(m);this.stack=B.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function M(v,m){return new Promise(function(R,B){var E=new $(v,m);if(E.signal&&E.signal.aborted)return B(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function w(){x.abort()}x.onload=function(){var T={status:x.status,statusText:x.statusText,headers:ce(x.getAllResponseHeaders()||"")};T.url="responseURL"in x?x.responseURL:T.headers.get("X-Request-URL");var k="response"in x?x.response:x.responseText;R(new K(k,T))},x.onerror=function(){B(new TypeError("Network request failed"))},x.ontimeout=function(){B(new TypeError("Network request failed"))},x.onabort=function(){B(new o.DOMException("Aborted","AbortError"))},x.open(E.method,E.url,!0),E.credentials==="include"?x.withCredentials=!0:E.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&a.blob&&(x.responseType="blob"),E.headers.forEach(function(T,k){x.setRequestHeader(k,T)}),E.signal&&(E.signal.addEventListener("abort",w),x.onreadystatechange=function(){x.readyState===4&&E.signal.removeEventListener("abort",w)}),x.send(typeof E._bodyInit>"u"?null:E._bodyInit)})}return M.polyfill=!0,s.fetch||(s.fetch=M,s.Headers=y,s.Request=$,s.Response=K),o.Headers=y,o.Request=$,o.Response=K,o.fetch=M,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(xI,xI.exports);var TBe=xI.exports;const o$=_u(TBe);var PBe=Object.defineProperty,kBe=Object.defineProperties,MBe=Object.getOwnPropertyDescriptors,a$=Object.getOwnPropertySymbols,RBe=Object.prototype.hasOwnProperty,OBe=Object.prototype.propertyIsEnumerable,c$=(t,e,r)=>e in t?PBe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,l$=(t,e)=>{for(var r in e||(e={}))RBe.call(e,r)&&c$(t,r,e[r]);if(a$)for(var r of a$(e))OBe.call(e,r)&&c$(t,r,e[r]);return t},f$=(t,e)=>kBe(t,MBe(e));const DBe={Accept:"application/json","Content-Type":"application/json"},NBe="POST",u$={headers:DBe,method:NBe},d$=10;let rl=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new ba.EventEmitter,this.isAvailable=!1,this.registering=!1,!RU(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=Su(e),n=await(await o$(this.url,f$(l$({},u$),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!RU(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Su({id:1,jsonrpc:"2.0",method:"test",params:[]});await o$(e,f$(l$({},u$),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?Lp(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=PE(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return rte(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>d$&&this.events.setMaxListeners(d$)}};const h$="error",BBe="wss://relay.walletconnect.org",LBe="wc",FBe="universal_provider",p$=`${LBe}@2:${FBe}:`,_te="https://rpc.walletconnect.org/v1/",W1="generic",jBe=`${_te}bundler`,hc={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var UBe=Object.defineProperty,$Be=Object.defineProperties,qBe=Object.getOwnPropertyDescriptors,v$=Object.getOwnPropertySymbols,VBe=Object.prototype.hasOwnProperty,zBe=Object.prototype.propertyIsEnumerable,g$=(t,e,r)=>e in t?UBe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,D6=(t,e)=>{for(var r in e||(e={}))VBe.call(e,r)&&g$(t,r,e[r]);if(v$)for(var r of v$(e))zBe.call(e,r)&&g$(t,r,e[r]);return t},HBe=(t,e)=>$Be(t,qBe(e));function va(t,e,r){var n;const i=Vv(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${_te}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function t1(t){return t.includes(":")?t.split(":")[1]:t}function Ite(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function GBe(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function nS(t={},e={}){const r=y$(t),n=y$(e);return IBe.merge(r,n)}function y$(t){var e,r,n,i;const s={};if(!Rw(t))return s;for(const[o,a]of Object.entries(t)){const c=$M(o)?[o]:a.chains,l=a.methods||[],f=a.events||[],u=a.rpcMap||{},p=lb(o);s[p]=HBe(D6(D6({},s[p]),a),{chains:R3(c,(e=s[p])==null?void 0:e.chains),methods:R3(l,(r=s[p])==null?void 0:r.methods),events:R3(f,(n=s[p])==null?void 0:n.events),rpcMap:D6(D6({},u),(i=s[p])==null?void 0:i.rpcMap)})}return s}function WBe(t){return t.includes(":")?t.split(":")[2]:t}function m$(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=$M(r)?[r]:n.chains?n.chains:Ite(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function iS(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const Tte={},Vr=t=>Tte[t],sS=(t,e)=>{Tte[t]=e};class KBe{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}var YBe=Object.defineProperty,QBe=Object.defineProperties,JBe=Object.getOwnPropertyDescriptors,b$=Object.getOwnPropertySymbols,ZBe=Object.prototype.hasOwnProperty,XBe=Object.prototype.propertyIsEnumerable,w$=(t,e,r)=>e in t?YBe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x$=(t,e)=>{for(var r in e||(e={}))ZBe.call(e,r)&&w$(t,r,e[r]);if(b$)for(var r of b$(e))XBe.call(e,r)&&w$(t,r,e[r]);return t},E$=(t,e)=>QBe(t,JBe(e));class eLe{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();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,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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,r){const n=r||va(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(t1(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o==null?void 0:o.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a==null?void 0:a[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:E$(x$({},o.sessionProperties||{}),{capabilities:E$(x$({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}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,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ud("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${jBe}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}class tLe{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class rLe{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}let nLe=class{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){if(!this.httpProviders[e]){const n=r||va(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new dc(new rl(n,Vr("disableProviderPing")))}};class iLe{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=t1(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class sLe{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class oLe{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=t1(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}class aLe{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||va(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace);return typeof n>"u"?void 0:new dc(new rl(n,Vr("disableProviderPing")))}}class cLe{constructor(e){this.name="tezos",this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||va(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace);return typeof n>"u"?void 0:new dc(new rl(n))}}class lLe{constructor(e){this.name=W1,this.namespace=e.namespace,this.events=Vr("events"),this.client=Vr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(hc.DEFAULT_CHAIN_CHANGED,`${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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=Vv(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||va(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new dc(new rl(n,Vr("disableProviderPing")))}}var fLe=Object.defineProperty,uLe=Object.defineProperties,dLe=Object.getOwnPropertyDescriptors,C$=Object.getOwnPropertySymbols,hLe=Object.prototype.hasOwnProperty,pLe=Object.prototype.propertyIsEnumerable,A$=(t,e,r)=>e in t?fLe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,N6=(t,e)=>{for(var r in e||(e={}))hLe.call(e,r)&&A$(t,r,e[r]);if(C$)for(var r of C$(e))pLe.call(e,r)&&A$(t,r,e[r]);return t},oS=(t,e)=>uLe(t,dLe(e));let vLe=class Pte{constructor(e){this.events=new yM,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:qx(IE({level:(e==null?void 0:e.logger)||h$})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new Pte(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:N6({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,TE(s,o))).catch(o=>r(o,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:(e=this.session)==null?void 0:e.topic,reason:rn("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,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=m$(this.session.namespaces);this.namespaces=nS(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await i().then(s=>{this.session=s;const o=m$(s.namespaces);this.namespaces=nS(this.namespaces,o),this.persist("namespaces",this.namespaces)}).catch(s=>{if(s.message!==Ste)throw s;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===W1?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(rf(r)){for(const n of r)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${r.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 OE.init({core:this.providerOpts.core,logger:this.providerOpts.logger||h$,relayUrl:this.providerOpts.relayUrl||BBe,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(r=>lb(r)))];sS("client",this.client),sS("events",this.events),sS("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=GBe(r,this.session),i=Ite(n),s=nS(this.namespaces,this.optionalNamespaces),o=oS(N6({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new eLe({namespace:o});break;case"algorand":this.rpcProviders[r]=new nLe({namespace:o});break;case"solana":this.rpcProviders[r]=new tLe({namespace:o});break;case"cosmos":this.rpcProviders[r]=new rLe({namespace:o});break;case"polkadot":this.rpcProviders[r]=new KBe({namespace:o});break;case"cip34":this.rpcProviders[r]=new iLe({namespace:o});break;case"elrond":this.rpcProviders[r]=new sLe({namespace:o});break;case"multiversx":this.rpcProviders[r]=new oLe({namespace:o});break;case"near":this.rpcProviders[r]=new aLe({namespace:o});break;case"tezos":this.rpcProviders[r]=new cLe({namespace:o});break;default:this.rpcProviders[W1]?this.rpcProviders[W1].updateNamespace(o):this.rpcProviders[W1]=new lLe({namespace:o})}})}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:r}=e,{event:n}=r;if(n.name==="accountsChanged"){const i=n.data;i&&rf(i)&&this.events.emit("accountsChanged",i.map(WBe))}else if(n.name==="chainChanged"){const i=r.chainId,s=r.event.data,o=lb(i),a=iS(i)!==iS(s)?`${o}:${iS(s)}`:i;this.onChainChanged(a)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n;const{namespaces:i}=r,s=(n=this.client)==null?void 0:n.session.get(e);this.session=oS(N6({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",oS(N6({},rn("USER_DISCONNECTED")),{data:e.topic}))}),this.on(hc.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[W1]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.persist("namespaces",r),this.persist("optionalNamespaces",n)}validateChain(e){const[r,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>lb(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=lb(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);i&&(r||this.getProvider(n).setDefaultChain(i),this.namespaces[n]?this.namespaces[n].defaultChain=i:this.namespaces[`${n}:${i}`]?this.namespaces[`${n}:${i}`].defaultChain=i:this.namespaces[`${n}:${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,r){this.client.core.storage.setItem(`${p$}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${p$}/${e}`)}};const gLe=vLe,yLe="wc",mLe="ethereum_provider",bLe=`${yLe}@2:${mLe}:`,wLe="https://rpc.walletconnect.org/v1/",EI=["eth_sendTransaction","personal_sign"],xLe=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],CI=["chainChanged","accountsChanged"],ELe=["chainChanged","accountsChanged","message","disconnect","connect"];var CLe=Object.defineProperty,ALe=Object.defineProperties,SLe=Object.getOwnPropertyDescriptors,S$=Object.getOwnPropertySymbols,_Le=Object.prototype.hasOwnProperty,ILe=Object.prototype.propertyIsEnumerable,_$=(t,e,r)=>e in t?CLe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K1=(t,e)=>{for(var r in e||(e={}))_Le.call(e,r)&&_$(t,r,e[r]);if(S$)for(var r of S$(e))ILe.call(e,r)&&_$(t,r,e[r]);return t},aS=(t,e)=>ALe(t,SLe(e));function p4(t){return Number(t[0].split(":")[1])}function B6(t){return`0x${t.toString(16)}`}function TLe(t){const{chains:e,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=t;if(!rf(e))throw new Error("Invalid chains");const c={chains:e,methods:n||EI,events:s||CI,rpcMap:K1({},e.length?{[p4(e)]:a[p4(e)]}:{})},l=s==null?void 0:s.filter(g=>!CI.includes(g)),f=n==null?void 0:n.filter(g=>!EI.includes(g));if(!r&&!o&&!i&&!(l!=null&&l.length)&&!(f!=null&&f.length))return{required:e.length?c:void 0};const u=(l==null?void 0:l.length)&&(f==null?void 0:f.length)||!r,p={chains:[...new Set(u?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(i!=null&&i.length?i:xLe))],events:[...new Set(c.events.concat(o!=null&&o.length?o:ELe))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?p:void 0}}let PLe=class kte{constructor(){this.events=new ba.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=bLe,this.on=(e,r)=>(this.events.on(e,r),this),this.once=(e,r)=>(this.events.once(e,r),this),this.removeListener=(e,r)=>(this.events.removeListener(e,r),this),this.off=(e,r)=>(this.events.off(e,r),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const r=new kte;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,n){this.signer.sendAsync(e,r,this.formatChainId(this.chainId),n)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:n}=TLe(this.rpc);try{const i=await new Promise(async(o,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(aS(K1({namespaces:K1({},r&&{[this.namespace]:r})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(l=>{o(l)}).catch(l=>{a(new Error(l.message))})});if(!i)return;const s=Yj(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:B6(this.chainId)})}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const n=await new Promise(async(s,o)=>{var a;this.rpc.showQrModal&&((a=this.modal)==null||a.subscribeModal(c=>{!c.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),o(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(aS(K1({},e),{chains:this.rpc.chains}),r).then(c=>{s(c)}).catch(c=>{o(new Error(c.message))})}),i=n.session;if(i){const s=Yj(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:B6(this.chainId)})}return n}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:n}=r;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",B6(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",aS(K1({},rn("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,n;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(n=this.modal)==null||n.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",B6(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,n;const i=(r=e==null?void 0:e.chains)!=null?r:[],s=(n=e==null?void 0:e.optionalChains)!=null?n:[],o=i.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=i.length?(e==null?void 0:e.methods)||EI:[],c=i.length?(e==null?void 0:e.events)||CI:[],l=(e==null?void 0:e.optionalMethods)||[],f=(e==null?void 0:e.optionalEvents)||[],u=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),p=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:i==null?void 0:i.map(g=>this.formatChainId(g)),optionalChains:s.map(g=>this.formatChainId(g)),methods:a,events:c,optionalMethods:l,optionalEvents:f,rpcMap:u,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:p,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const n={};return e.forEach(i=>{n[i]=this.getRpcUrl(i,r)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?p4(this.rpc.chains):p4(this.rpc.optionalChains),this.signer=await gLe.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:n}=await R9e(()=>import("./index-BSEof6bf.js").then(i=>i.i),[]);r=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(K1({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:n,rpcMap:i}=e;r&&rf(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)})),n&&rf(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(s=>this.formatChainId(s)),n.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)}))}getRpcUrl(e,r){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${wLe}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}};var Mte={exports:{}};/*! * EventEmitter2 * https://github.com/hij1nx/EventEmitter2 * * Copyright (c) 2013 hij1nx * Licensed under the MIT license. */(function(t,e){(function(r){var n=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(x){return Object.prototype.toString.call(x)==="[object Array]"},s=10,o=typeof process=="object"&&typeof process.nextTick=="function",a=typeof Symbol=="function",c=typeof Reflect=="object",l=typeof setImmediate=="function",f=l?setImmediate:setTimeout,u=a?c&&typeof Reflect.ownKeys=="function"?Reflect.ownKeys:function(E){var x=Object.getOwnPropertyNames(E);return x.push.apply(x,Object.getOwnPropertySymbols(E)),x}:Object.keys;function p(){this._events={},this._conf&&g.call(this,this._conf)}function g(E){E&&(this._conf=E,E.delimiter&&(this.delimiter=E.delimiter),E.maxListeners!==r&&(this._maxListeners=E.maxListeners),E.wildcard&&(this.wildcard=E.wildcard),E.newListener&&(this._newListener=E.newListener),E.removeListener&&(this._removeListener=E.removeListener),E.verboseMemoryLeak&&(this.verboseMemoryLeak=E.verboseMemoryLeak),E.ignoreErrors&&(this.ignoreErrors=E.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function y(E,x){var w="(node) warning: possible EventEmitter memory leak detected. "+E+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(w+=" Event name: "+x+"."),typeof process<"u"&&process.emitWarning){var T=new Error(w);T.name="MaxListenersExceededWarning",T.emitter=this,T.count=E,process.emitWarning(T)}else console.error(w),console.trace&&console.trace()}var b=function(E,x,w){var T=arguments.length;switch(T){case 0:return[];case 1:return[E];case 2:return[E,x];case 3:return[E,x,w];default:for(var k=new Array(T);T--;)k[T]=arguments[T];return k}};function I(E,x){for(var w={},T,k=E.length,H=0,oe=0;oe0;)E=H[X],oe.call(j,E,w[E]);this._listeners={},this._listenersCount=0,G()}}});function S(E,x,w,T){var k=Object.assign({},x);if(!E)return k;if(typeof E!="object")throw TypeError("options must be an object");var H=Object.keys(E),oe=H.length,j,X,G;function Z(N){throw Error('Invalid "'+j+'" option value'+(N?". Reason: "+N:""))}for(var ee=0;ee0;)if(j===E[X])return H;oe(x)}}var F=L(["function"]),z=L(["object","function"]);function _(E,x,w){var T,k,H=0,oe,j=new E(function(X,G,Z){w=S(w,{timeout:0,overload:!1},{timeout:function(fe,Ee){return fe*=1,(typeof fe!="number"||fe<0||!Number.isFinite(fe))&&Ee("timeout must be a positive number"),fe}}),T=!w.overload&&typeof E.prototype.cancel=="function"&&typeof Z=="function";function ee(){k&&(k=null),H&&(clearTimeout(H),H=0)}var N=function(fe){ee(),X(fe)},te=function(fe){ee(),G(fe)};T?x(N,te,Z):(k=[function(fe){te(fe||Error("canceled"))}],x(N,te,function(fe){if(oe)throw Error("Unable to subscribe on cancel event asynchronously");if(typeof fe!="function")throw TypeError("onCancel callback must be a function");k.push(fe)}),oe=!0),w.timeout>0&&(H=setTimeout(function(){var fe=Error("timeout");fe.code="ETIMEDOUT",H=0,j.cancel(fe),G(fe)},w.timeout))});return T||(j.cancel=function(X){if(k){for(var G=k.length,Z=1;Z0;)te=ze[j],te!=="_listeners"&&(et=ie(E,x,w[te],T+1,k),et&&(N?N.push.apply(N,et):N=et));return N}else if(Te==="**"){for(Re=T+1===k||T+2===k&&De==="*",Re&&w._listeners&&(N=ie(E,x,w,k,k)),ze=u(w),j=ze.length;j-- >0;)te=ze[j],te!=="_listeners"&&(te==="*"||te==="**"?(w[te]._listeners&&!Re&&(et=ie(E,x,w[te],k,k),et&&(N?N.push.apply(N,et):N=et)),et=ie(E,x,w[te],T,k)):te===De?et=ie(E,x,w[te],T+2,k):et=ie(E,x,w[te],T,k),et&&(N?N.push.apply(N,et):N=et));return N}else w[Te]&&(N=ie(E,x,w[Te],T+1,k));if(fe=w["*"],fe&&ie(E,x,fe,T+1,k),Ee=w["**"],Ee)if(T0;)te=ze[j],te!=="_listeners"&&(te===De?ie(E,x,Ee[te],T+2,k):te===Te?ie(E,x,Ee[te],T+1,k):(_e={},_e[te]=Ee[te],ie(E,x,{"**":_e},T+1,k)));else Ee._listeners?ie(E,x,Ee,k,k):Ee["*"]&&Ee["*"]._listeners&&ie(E,x,Ee["*"],k,k);return N}function ce(E,x,w){var T=0,k=0,H,oe=this.delimiter,j=oe.length,X;if(typeof E=="string")if((H=E.indexOf(oe))!==-1){X=new Array(5);do X[T++]=E.slice(k,H),k=H+j;while((H=E.indexOf(oe,k))!==-1);X[T++]=E.slice(k)}else X=[E],T=1;else X=E,T=E.length;if(T>1){for(H=0;H+10&&G._listeners.length>this._maxListeners&&(G._listeners.warned=!0,y.call(this,G._listeners.length,Z))):G._listeners=x,!0;return!0}function K(E,x,w,T){for(var k=u(E),H=k.length,oe,j,X,G=E._listeners,Z;H-- >0;)j=k[H],oe=E[j],j==="_listeners"?X=w:X=w?w.concat(j):[j],Z=T||typeof j=="symbol",G&&x.push(Z?X:X.join(this.delimiter)),typeof oe=="object"&&K.call(this,oe,x,X,Z);return x}function P(E){for(var x=u(E),w=x.length,T,k,H;w-- >0;)k=x[w],T=E[k],T&&(H=!0,k!=="_listeners"&&!P(T)&&delete E[k]);return H}function M(E,x,w){this.emitter=E,this.event=x,this.listener=w}M.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function v(E,x,w){if(w===!0)k=!0;else if(w===!1)T=!0;else{if(!w||typeof w!="object")throw TypeError("options should be an object or true");var T=w.async,k=w.promisify,H=w.nextTick,oe=w.objectify}if(T||H||k){var j=x,X=x._origin||x;if(H&&!o)throw Error("process.nextTick is not supported");k===r&&(k=x.constructor.name==="AsyncFunction"),x=function(){var G=arguments,Z=this,ee=this.event;return k?H?Promise.resolve():new Promise(function(N){f(N)}).then(function(){return Z.event=ee,j.apply(Z,G)}):(H?process.nextTick:f)(function(){Z.event=ee,j.apply(Z,G)})},x._async=!0,x._origin=X}return[x,oe?new M(this,E,x):this]}function m(E){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,g.call(this,E)}m.EventEmitter2=m,m.prototype.listenTo=function(E,x,w){if(typeof E!="object")throw TypeError("target musts be an object");var T=this;w=S(w,{on:r,off:r,reducers:r},{on:F,off:F,reducers:z});function k(H){if(typeof H!="object")throw TypeError("events must be an object");var oe=w.reducers,j=$.call(T,E),X;j===-1?X=new C(T,E,w):X=T._observers[j];for(var G=u(H),Z=G.length,ee,N=typeof oe=="function",te=0;te0;)k=w[T],(!E||k._target===E)&&(k.unsubscribe(x),H=!0);return H},m.prototype.delimiter=".",m.prototype.setMaxListeners=function(E){E!==r&&(this._maxListeners=E,this._conf||(this._conf={}),this._conf.maxListeners=E)},m.prototype.getMaxListeners=function(){return this._maxListeners},m.prototype.event="",m.prototype.once=function(E,x,w){return this._once(E,x,!1,w)},m.prototype.prependOnceListener=function(E,x,w){return this._once(E,x,!0,w)},m.prototype._once=function(E,x,w,T){return this._many(E,1,x,w,T)},m.prototype.many=function(E,x,w,T){return this._many(E,x,w,!1,T)},m.prototype.prependMany=function(E,x,w,T){return this._many(E,x,w,!0,T)},m.prototype._many=function(E,x,w,T,k){var H=this;if(typeof w!="function")throw new Error("many only accepts instances of Function");function oe(){return--x===0&&H.off(E,oe),w.apply(this,arguments)}return oe._origin=w,this._on(E,oe,T,k)},m.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||p.call(this);var E=arguments[0],x,w=this.wildcard,T,k,H,oe,j;if(E==="newListener"&&!this._newListener&&!this._events.newListener)return!1;if(w&&(x=E,E!=="newListener"&&E!=="removeListener"&&typeof E=="object")){if(k=E.length,a){for(H=0;H3)for(T=new Array(X-1),oe=1;oe3)for(k=new Array(G-1),j=1;j0&&this._events[E].length>this._maxListeners&&(this._events[E].warned=!0,y.call(this,this._events[E].length,E))):this._events[E]=x,k)},m.prototype.off=function(E,x){if(typeof x!="function")throw new Error("removeListener only takes instances of Function");var w,T=[];if(this.wildcard){var k=typeof E=="string"?E.split(this.delimiter):E.slice();if(T=ie.call(this,null,k,this.listenerTree,0),!T)return this}else{if(!this._events[E])return this;w=this._events[E],T.push({_listeners:w})}for(var H=0;H0){for(T=this._all,x=0,w=T.length;x0;)T=x[w[H]],typeof T=="function"?k.push(T):k.push.apply(k,T);return k}else{if(this.wildcard){if(oe=this.listenerTree,!oe)return[];var j=[],X=typeof E=="string"?E.split(this.delimiter):E.slice();return ie.call(this,j,X,oe,0),j}return x?(T=x[E],T?typeof T=="function"?[T]:T:[]):[]}},m.prototype.eventNames=function(E){var x=this._events;return this.wildcard?K.call(this,this.listenerTree,[],null,E):x?u(x):[]},m.prototype.listenerCount=function(E){return this.listeners(E).length},m.prototype.hasListeners=function(E){if(this.wildcard){var x=[],w=typeof E=="string"?E.split(this.delimiter):E.slice();return ie.call(this,x,w,this.listenerTree,0),x.length>0}var T=this._events,k=this._all;return!!(k&&k.length||T&&(E===r?u(T).length:T[E]))},m.prototype.listenersAny=function(){return this._all?this._all:[]},m.prototype.waitFor=function(E,x){var w=this,T=typeof x;return T==="number"?x={timeout:x}:T==="function"&&(x={filter:x}),x=S(x,{timeout:0,filter:r,handleError:!1,Promise,overload:!1},{filter:F,Promise:O}),_(x.Promise,function(k,H,oe){function j(){var X=x.filter;if(!(X&&!X.apply(w,arguments)))if(w.off(E,j),x.handleError){var G=arguments[0];G?H(G):k(b.apply(null,arguments).slice(1))}else k(b.apply(null,arguments))}oe(function(){w.off(E,j)}),w._on(E,j,!1)},{timeout:x.timeout,overload:x.overload})};function R(E,x,w){w=S(w,{Promise,timeout:0,overload:!1},{Promise:O});var T=w.Promise;return _(T,function(k,H,oe){var j;if(typeof E.addEventListener=="function"){j=function(){k(b.apply(null,arguments))},oe(function(){E.removeEventListener(x,j)}),E.addEventListener(x,j,{once:!0});return}var X=function(){G&&E.removeListener("error",G),k(b.apply(null,arguments))},G;x!=="error"&&(G=function(Z){E.removeListener(x,X),H(Z)},E.once("error",G)),oe(function(){G&&E.removeListener("error",G),E.removeListener(x,X)}),E.once(x,X)},{timeout:w.timeout,overload:w.overload})}var B=m.prototype;Object.defineProperties(m,{defaultMaxListeners:{get:function(){return B._maxListeners},set:function(E){if(typeof E!="number"||E<0||Number.isNaN(E))throw TypeError("n must be a non-negative number");B._maxListeners=E},enumerable:!0},once:{value:R,writable:!0,configurable:!0}}),Object.defineProperties(B,{_maxListeners:{value:s,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),t.exports=m})()})(Mte);var kLe=Mte.exports,AI=function(){return AI=Object.assign||function(e){for(var r,n=1,i=arguments.length;n0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]0&&(i.types.Claims.push({name:"app",type:"string"}),i.message.app=this.claims.app),this.claims.iat&&this.claims.iat>0&&(i.types.Claims.push({name:"iat",type:"int64"}),i.message.iat=this.claims.iat),this.claims.exp&&this.claims.exp>0&&(i.types.Claims.push({name:"exp",type:"int64"}),i.message.exp=this.claims.exp),this.claims.n&&this.claims.n>0&&(i.types.Claims.push({name:"n",type:"uint64"}),i.message.n=this.claims.n),this.claims.typ&&this.claims.typ.length>0&&(i.types.Claims.push({name:"typ",type:"string"}),i.message.typ=this.claims.typ),this.claims.ogn&&this.claims.ogn.length>0&&(i.types.Claims.push({name:"ogn",type:"string"}),i.message.ogn=this.claims.ogn),this.claims.v&&this.claims.v.length>0&&(i.types.Claims.push({name:"v",type:"string"}),i.message.v=this.claims.v),i},t}(),OLe=function(t){if(t.app==="")return{ok:!1,err:new Error("claims: app is empty")};var e=Math.round(new Date().getTime()/1e3),r=5*60,n=60*60*24*365+r;return t.v===""?{ok:!1,err:new Error("claims: ethauth version is empty")}:t.iat&&t.iat!==0&&(t.iat>e+r||t.iate+n?{ok:!1,err:new Error("claims: token has expired")}:{ok:!0}},DLe=function(t,e,r){return E0(void 0,void 0,void 0,function(){var n,i;return C0(this,function(s){return n=r.messageDigest(),i=A4e(n,r.signature),i.slice(0,2)==="0x"&&i.length===42&&i.toLowerCase()===r.address.toLowerCase()?[2,{isValid:!0,address:r.address}]:[2,{isValid:!1}]})})},NLe=function(t,e,r){return E0(void 0,void 0,void 0,function(){var n,i,s,o,a;return C0(this,function(c){switch(c.label){case 0:return!t||t===void 0?[2,{isValid:!1}]:(n=r.messageDigest(),[4,t.getCode(r.address)]);case 1:if(i=c.sent(),i==="0x"||i.length<=2)throw new Error("ValidateContractAccountProof failed. unable to fetch wallet contract code");return s=["function isValidSignature(bytes32, bytes) public view returns (bytes4)"],o=new Dn(r.address,s,t),[4,o.isValidSignature(n,Ue(r.signature))];case 2:return a=c.sent(),a===BLe?[2,{isValid:!0,address:r.address}]:[2,{isValid:!1}]}})})},BLe="0x1626ba7e",LLe=function(){function t(){for(var e=[],r=0;r0&&(c+="."+i.extra),[2,c]}})})},this.decodeProof=function(i,s){return s===void 0&&(s=!1),E0(n,void 0,void 0,function(){var o,a,c,l,f,u,p,g,y,b;return C0(this,function(I){switch(I.label){case 0:if(o=i.split("."),o.length<4||o.length>5)throw new Error("ethauth: invalid proof string");if(a=o[0],c=o[1],l=o[2],f=o[3],u=o[4],a!==SI)throw new Error("ethauth: not an ethauth proof");return p=MF.decode(l),g=JSON.parse(p),y=new Ote({address:c,claims:g,signature:f,extra:u}),[4,this.validateProof(y,s)];case 1:if(b=I.sent(),!b)throw new Error("ethauth: proof is invalid");return[2,y]}})})},this.validateProof=function(i,s){return s===void 0&&(s=!1),E0(n,void 0,void 0,function(){var o,a;return C0(this,function(c){switch(c.label){case 0:if(o=this.validateProofClaims(i),o.err)throw new Error("ethauth: proof claims are invalid ".concat(o.err));return s===!0?[3,2]:[4,this.validateProofSignature(i)];case 1:if(a=c.sent(),a!==!0)throw new Error("ethauth: proof signature is invalid");c.label=2;case 2:return[2,!0]}})})},this.validateProofSignature=function(i){return E0(n,void 0,void 0,function(){var s,c,o,a,c;return C0(this,function(l){switch(l.label){case 0:s=[],c=0,l.label=1;case 1:if(!(c{const n=Qt(await t.getAddress());if(!n||n===""||n==="0x")throw ULe;const i=new Ote;if(i.address=n,!r||!r.app||r.app==="")throw new Dte("authorization options requires app to be set");i.claims.app=r.app,i.claims.ogn=r.origin,i.claims.n=r.nonce,i.setExpiryIn(r.expiry?Math.max(r.expiry,200):FLe);const s=i.messageTypedData(),o=c9e(e);i.signature=await(t instanceof Ix?t.signTypedData(s.domain,s.types,s.message,o,"eip6492"):t.signTypedData(s.domain,s.types,s.message,o));const c=await new LLe().encodeProof(i,!0);return{typedData:s,proofString:c}};class Dte extends Error{constructor(e){super(e),this.name="AuthError"}}const ULe=new Dte("auth error: account address is empty");mt.context.defaultContexts,new aX.remote.RemoteConfigTracker("https://sessions.sequence.app");const $Le=new Map(["addHook(bytes4,address)","clearExtraImageHashes(bytes32[])","removeHook(bytes4)","setExtraImageHash(bytes32,uint256)","updateIPFSRoot(bytes32)","updateImageHash(bytes32)","updateImageHashAndIPFS(bytes32,bytes32)","updateImplementation(address)"].map(t=>[Oo(t).slice(0,10),t]));function _I(t,e){const r=mt.transaction.fromTransactionish(t,e);mt.transaction.unwind(t,r).forEach(i=>qLe(t,i))}function qLe(t,e){if(e.to.toLowerCase()===t.toLowerCase()&&e.data){const r=Ue(e.data);if(r.length>=4&&!VLe(r))throw new Error("self calls are forbidden")}if(e.delegateCall)throw new Error("delegate calls are forbidden");if(e.data){const n=Me(e.data).slice(0,10),i=$Le.get(n);if(i){const s=i.slice(0,i.indexOf("("));throw new Error(`${s} calls are forbidden`)}}}function VLe(t){const e=new $i(Ps.mainModule.abi);try{return e.decodeFunctionData("createContract",t),!0}catch{return!1}}function $c(){return $c=Object.assign?Object.assign.bind():function(t){for(var e=1;ee.predicate(t))}const WLe=[{name:"Decentraland Exception",predicate:YLe},{name:"0x v3 Exception",predicate:QLe}],KLe=/^Decentraland Login\nEphemeral address: 0x[a-fA-F0-9]{40}\nExpiration: (\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)((-(\d{2}):(\d{2})|Z)?)$/;function YLe(t){try{const e=Ip(t);return KLe.test(e)}catch{return!1}}function QLe(t){const e=new $i(JLe);try{return e.decodeFunctionData("OrderWithHash",t),!0}catch{return!1}}const JLe=[{inputs:[{components:[{internalType:"address",name:"makerAddress",type:"address"},{internalType:"address",name:"takerAddress",type:"address"},{internalType:"address",name:"feeRecipientAddress",type:"address"},{internalType:"address",name:"senderAddress",type:"address"},{internalType:"uint256",name:"makerAssetAmount",type:"uint256"},{internalType:"uint256",name:"takerAssetAmount",type:"uint256"},{internalType:"uint256",name:"makerFee",type:"uint256"},{internalType:"uint256",name:"takerFee",type:"uint256"},{internalType:"uint256",name:"expirationTimeSeconds",type:"uint256"},{internalType:"uint256",name:"salt",type:"uint256"},{internalType:"bytes",name:"makerAssetData",type:"bytes"},{internalType:"bytes",name:"takerAssetData",type:"bytes"},{internalType:"bytes",name:"makerFeeAssetData",type:"bytes"},{internalType:"bytes",name:"takerFeeAssetData",type:"bytes"}],internalType:"struct IEIP1271Data.Order",name:"order",type:"tuple"},{internalType:"bytes32",name:"orderHash",type:"bytes32"}],name:"OrderWithHash",outputs:[],stateMutability:"pure",type:"function"}],F3=Ii(`Ethereum Signed Message: -`),ZLe=t=>mu(t)?Ue(t):Ii(t),Nte=t=>{const e=ZLe(t);return GLe(e)?e:Ue(qr([F3,Ii(String(e.length)),e]))},XLe=t=>{if(JSON.stringify(t.slice(0,F3.length))!==JSON.stringify(F3))return t;const e=t.slice(F3.length),r=String(e.length).length;let n,i;try{i=Number(Ip(e.slice(0,r)))}catch{i=Number(Me(e.slice(0,r)))}return i>e.length||!Number.isInteger(i)?n=r-1:n=r,e.slice(n)},I$=async(t,e,r,n)=>new mt.reader.OnChainReader(n).isValidSignature(t,e,r);async function eFe(t){return Array.isArray(t)?Promise.all(t.map(e=>vi(e))):vi(t)}function tFe(t){return[t,...t.auxiliary||[]]}const rFe=1e4;class nFe{constructor(e,r,n){var i=this;this.account=void 0,this.signerReadyCallbacks=[],this.prompter=void 0,this.networks=void 0,this._openIntent=void 0,this._connectOptions=void 0,this.events=new kLe.EventEmitter2,this.onConnectOptionsChange=void 0,this.promptConnect=async function(s){if(!s&&!i._connectOptions)throw new Error("prompter connect options are empty");if(!i.prompter)return i.connect(s);const o=await i.prompter.promptConnect(s||i._connectOptions).catch(c=>({connected:!1})),a=o;return a.connected&&!a.session&&(a.session=await i.walletSession(s==null?void 0:s.networkId)),o},this.isSignedIn=async function(){return await i.signerReady(),!!i.account},this.getAccount=async function(){if(await i.signerReady(),i.account===void 0)throw new Error("signerReady failed resolve");return i.account},this.account=e,this.prompter=r,this.networks=n}defaultChainId(){var e,r;return(e=(r=this.prompter)==null?void 0:r.getDefaultChainId())!=null?e:this.networks[0].chainId}async signIn(e,r={}){this.setAccount(e);const{connect:n,defaultNetworkId:i}=r;if(n){const a=this._connectOptions;let c;if(this.prompter!==null){var s;c=await((s=this.prompter)==null?void 0:s.promptSignInConnect(a))}else c=await this.connect(a);this.notifyConnect(c),(!a||a.keepWalletOpened!==!0)&&this.notifyClose()}if(i&&this.defaultChainId()!==i){var o;await((o=this.prompter)==null?void 0:o.promptChangeNetwork(i))}}signOut(){this.account&&this.notifyDisconnect(),this.setAccount(null)}signerReset(){this.account=void 0}signerReady(e=rFe){return new Promise((r,n)=>{this.account!==void 0?r():(setTimeout(()=>{this.account===void 0&&(this.signerReadyCallbacks=[],n("signerReady timed out"))},e),this.signerReadyCallbacks.push(r))})}async connect(e){var r,n;if(!this.account)return{connected:!1,chainId:"0x0",error:"unable to connect without signed in account"};const i=(r=(n=e==null?void 0:e.networkId)!=null?n:this.defaultChainId())!=null?r:ge.MAINNET,s=a9e(i).chainId,o={connected:!0,chainId:zc(s)};if(e&&e.authorize){const a={app:e.app,origin:e.origin,expiry:e.expiry,nonce:e.authorizeNonce};try{o.proof=await jLe(this.account,s,a)}catch(c){return Ci.warn(`connect, signAuthorization failed for options: ${JSON.stringify(e)}, due to: ${c.message}`),{connected:!1,chainId:"0x0",error:`signAuthorization failed: ${c.message}`}}}return o.session=this.walletSession(s),o}async sendMessageRequest(e){var r;const i=Number(((r=e.clientVersion)==null?void 0:r.split(".")[0])||"0")<2,s={id:e.data.id,jsonrpc:"2.0",result:null,error:void 0};try{const o=await this.request({method:e.data.method,params:e.data.params,chainId:e.chainId});return $c({},e,{data:i?$c({},s,{result:o}):o})}catch(o){return $c({},e,{data:i?$c({},s,{error:o}):{error:o}})}}async request(e){await this.getAccount();try{var r,n;if((!this.account||this.account===null)&&!iFe.includes(e.method))throw HLe;const l=this.account;if(!l)throw new Error("WalletRequestHandler: wallet account is not configured");const f=(r=this.account)==null?void 0:r.providerFor((n=e.chainId)!=null?n:this.defaultChainId());if(!f)throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${e.chainId}`);const u=sFe(f)?f:void 0;switch(e.method){case"net_version":{if(!u)throw new Error("Account provider doesn't support send method");return await u.send("net_version",[])}case"eth_chainId":{if(!u)throw new Error("Account provider doesn't support send method");return await u.send("eth_chainId",[])}case"eth_accounts":return[l.address];case"eth_getBalance":{const[p,g]=e.params,y=await f.getBalance(p,g);return Nv(y)}case"sequence_sign":case"personal_sign":case"eth_sign":{let p;switch(e.method){case"sequence_sign":case"personal_sign":{const[I,C]=e.params;p=I;break}case"eth_sign":{const[I,C]=e.params;p=C;break}}let g="";const y=Nte(p),b=e.method==="sequence_sign";if(this.prompter===null){var i;g=await l.signMessage(y,(i=e.chainId)!=null?i:this.defaultChainId(),b?"eip6492":"ignore")}else g=await this.prompter.promptSignMessage({chainId:e.chainId,message:Ue(y),eip6492:b},this.connectOptions);if(g&&g.length>0)return g;throw new Error("declined by user")}case"sequence_signTypedData_v4":case"eth_signTypedData":case"eth_signTypedData_v4":{const[p,g]=e.params;let y;if(typeof g=="string")try{y=JSON.parse(g)}catch(C){console.warn("walletRequestHandler: error parsing typedData",C)}else y=g;if(!y||!y.domain||!y.types||!y.message)throw new Error("invalid typedData object");let b="";const I=e.method==="sequence_signTypedData_v4";if(this.prompter===null){var s;b=await l.signTypedData(y.domain,y.types,y.message,(s=e.chainId)!=null?s:this.defaultChainId(),I?"eip6492":"ignore")}else b=await this.prompter.promptSignMessage({chainId:e.chainId,typedData:y,eip6492:I},this.connectOptions);if(b&&b.length>0)return b;throw new Error("declined by user")}case"eth_sendTransaction":{const p=tFe(e.params[0]).map(y=>("gas"in y&&y.gasLimit===void 0&&(y.gasLimit=y.gas,delete y.gas),y));_I(l.address,p);let g="";if(this.prompter===null){var o,a;const y=await l.sendTransaction(p,(o=e.chainId)!=null?o:this.defaultChainId());g=(a=y==null?void 0:y.hash)!=null?a:""}else g=await this.prompter.promptSendTransaction(p,e.chainId,this.connectOptions);if(g)return g;throw new Error("declined by user")}case"eth_signTransaction":{const[p]=e.params;if(Qt(p.from)!==l.address)throw new Error("sender address does not match wallet");if(_I(l.address,p),this.prompter===null){var c;return await l.signTransactions(p,(c=e.chainId)!=null?c:this.defaultChainId())}else return await this.prompter.promptSignTransaction(p,e.chainId,this.connectOptions)}case"eth_sendRawTransaction":if(mt.transaction.isSignedTransactionBundle(e.params[0])){const p=Number(e.params[0].chainId);return(await l.relayer(p).relay(e.params[0])).hash}else return(await f.broadcastTransaction(e.params[0])).hash;case"eth_getTransactionCount":{const p=Qt(e.params[0]),g=e.params[1],y=await f.getTransactionCount(p,g);return Nv(BigInt(y))}case"eth_blockNumber":return await f.getBlockNumber();case"eth_getBlockByNumber":return await f.getBlock(e.params[0]);case"eth_getBlockByHash":return await f.getBlock(e.params[0]);case"eth_getTransactionByHash":return await f.getTransaction(e.params[0]);case"eth_call":{const[p,g]=e.params;return await f.call($c({},p,{blockTag:g}))}case"eth_getCode":{const[p,g]=e.params;return await f.getCode(p,g)}case"eth_estimateGas":{const[p]=e.params;return await f.estimateGas(p)}case"eth_gasPrice":{const p=await f.getFeeData();return p.gasPrice===null?null:Nv(p.gasPrice)}case"wallet_switchEthereumChain":{const[p]=e.params;if(!p.chainId||p.chainId.length===0)throw new Error("invalid chainId");const g=BigInt(p.chainId);return this.setDefaultChainId(Number(g)),null}case"sequence_getWalletContext":return l.contexts;case"sequence_getWalletConfig":{const[p]=e.params;return p?[(await l.status(p)).onChain.config]:await Promise.all(l.networks.map(async function(g){return(await l.status(g.chainId)).onChain.config}))}case"sequence_getWalletState":{const[p]=e.params;return p?[T$(p,await l.status(p))]:await Promise.all(l.networks.map(async function(g){const y=await l.status(g.chainId);return T$(g.chainId,y)}))}case"sequence_getNetworks":return await this.getNetworks(!0);case"sequence_isSequence":return!0;case"sequence_updateConfig":throw new Error("sequence_updateConfig method is not allowed from a dapp");case"sequence_publishConfig":throw new Error("sequence_publishConfig method is not allowed from a dapp");case"sequence_gasRefundOptions":break;case"sequence_getNonce":break;case"sequence_relay":break;case"sequence_setDefaultNetwork":{const[p]=e.params;if(!p)throw new Error("invalid request, method argument defaultChainId cannot be empty");return this.setDefaultChainId(p),await this.getNetworks(!0)}default:{if(!u)throw new Error("Account provider doesn't support send method");return await u.send(e.method,e.params)}}}catch(l){throw Ci.error(l),{message:typeof l=="string"?l:(l==null?void 0:l.message)||"unkown error",code:4001}}}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}async getAddress(){var e,r;return(e=(r=this.account)==null?void 0:r.address)!=null?e:""}get openIntent(){return this._openIntent}setOpenIntent(e){this._openIntent=e}get connectOptions(){return this._connectOptions}setConnectOptions(e){var r;this._connectOptions=e,(r=this.onConnectOptionsChange)==null||r.call(this,e)}async setDefaultChainId(e){var r;return await((r=this.prompter)==null?void 0:r.promptChangeNetwork(e)),this.defaultChainId()}async getNetworks(e){return this.account?e?this.account.networks.map(r=>{const n=$c({},r);return n.provider=void 0,n.relayer=void 0,n}):this.account.networks:(Ci.warn("signer not set: getNetworks is returning an empty list"),[])}walletSession(e){if(!this.account)return;const r={walletContext:this.account.contexts,accountAddress:this.account.address,networks:this.account.networks.map(i=>$c({},i,{provider:void 0,relayer:void 0}))};if(e){const i=Iw(r.networks,e);if(i){var n;(n=r.networks)==null||n.forEach(s=>delete s.isDefaultChain),i.isDefaultChain=!0}}return r}notifyConnect(e,r){var n;if(console.log("emit connect",e),this.events.emit("connect",e),(n=e.session)!=null&&n.accountAddress){var i;this.events.emit("accountsChanged",[(i=e.session)==null?void 0:i.accountAddress],r)}}notifyDisconnect(e){this.events.emit("accountsChanged",[],e),this.events.emit("disconnect",void 0,e)}notifyChainChanged(e,r){this.events.emit("chainChanged",zc(e),r)}async notifyNetworks(e){const r=e||await this.getNetworks(!0);if(this.events.emit("networks",r),r.length>0){const n=r.find(i=>i.chainId===this.defaultChainId());n&&this.events.emit("chainChanged",zc(n.chainId))}else this.events.emit("chainChanged","0x0")}async notifyWalletContext(){if(!this.account){Ci.warn("signer not set: skipping to notify wallet context");return}const e=this.account.contexts;this.events.emit("walletContext",e)}notifyClose(e){this.events.emit("close",e)}setAccount(e){if(this.account=e,e!==void 0){for(let r=0;rc.canOnchainValidate||c.original.version===2&&n,o=await r.status(i);if(s(o))return!0;if(await e.promptConfirmWalletDeploy(i,this.connectOptions)){const c=await r.status(i);return s(c)?!0:(Ci.error("WalletRequestHandler: result for promptConfirmWalletDeploy is not correct"),!1)}return!1}}function T$(t,e){return{context:e.original.context,config:e.onChain.config,address:mt.context.addressOf(e.original.context,e.original.imageHash),chainId:t,deployed:e.onChain.deployed,imageHash:e.imageHash,lastImageHash:e.onChain.imageHash,published:!0,status:e}}const iFe=["net_version","eth_chainId","eth_getBalance","eth_getTransactionCount","eth_blockNumber","eth_getBlockByNumber","eth_getBlockByHash","eth_getTransactionByHash","eth_getCode","eth_estimateGas","eth_gasPrice","sequence_getWalletContext","sequence_getNetworks","sequence_setDefaultNetwork"];function sFe(t){return t&&typeof t=="object"&&typeof t.send=="function"&&typeof t.getNetwork=="function"}function oFe(t,e){if(t==null)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}class DE{get utils(){return this.provider.utils}constructor(e,r){this.client=e,this.provider=r,this.singleNetworkSigners={},this._isSequenceSigner=!0}async getAddress(){return this.client.getAddress()}connect(e){if(!KM.is(e))throw new Error("SequenceSigner can only be connected to a SequenceProvider");return new DE(this.client,e)}getSigner(e){if(!e)return this;const r=this.provider.toChainId(e);return this.singleNetworkSigners[r]||(this.singleNetworkSigners[r]=new Bte(this.client,this.provider,r)),this.singleNetworkSigners[r]}useChainId(e){return this.provider.toChainId(e)||this.client.getChainId()}async signMessage(e,r){const{eip6492:n=!0}=r||{},i=this.useChainId(r==null?void 0:r.chainId);return this.client.signMessage(e,{eip6492:n,chainId:i})}async signTypedData(e,r,n,i){const{eip6492:s=!0}=i||{},o=this.useChainId(i==null?void 0:i.chainId);return this.client.signTypedData({domain:e,types:r,message:n},{eip6492:s,chainId:o})}getProvider(e){return this.provider.getProvider(e)}async sendTransaction(e,r){const n=this.useChainId(r==null?void 0:r.chainId),i=await eFe(e),s=await this.client.sendTransaction(i,{chainId:n}),o=this.getProvider(n);try{return await new Promise(c=>{(async function f(){const u=await o.getTransaction(s);if(u!==null)return c(u);await o.once("block",f)})()})}catch(a){throw a.transactionHash=s,a}}async getWalletConfig(e){const r=this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}getNetworks(){return this.client.getNetworks()}async getBalance(e,r){return this.getProvider(r==null?void 0:r.chainId).getBalance(this.getAddress(),e)}async estimateGas(e,r){return this.getProvider(r==null?void 0:r.chainId).estimateGas(e)}async call(e,r){return this.getProvider(r==null?void 0:r.chainId).call(e)}getChainId(){return Promise.resolve(this.client.getChainId())}async getFeeData(e){return this.getProvider(e==null?void 0:e.chainId).getFeeData()}async resolveName(e){const r=await this.provider.resolveName(e);if(r===null)throw new Error(`ENS name not found: ${e}`);return r}_checkProvider(e){}getNonce(e){throw new Error("SequenceSigner does not support getNonce")}populateCall(e){throw new Error("SequenceSigner does not support populateCall")}populateTransaction(e){throw new Error("SequenceSigner does not support populateTransaction")}checkTransaction(e){throw new Error("SequenceSigner does not support checkTransaction")}getTransactionCount(e){throw new Error("SequenceSigner does not support getTransactionCount")}signTransaction(e){throw new Error("SequenceWallet does not support signTransaction, use sendTransaction instead.")}static is(e){return e&&typeof e=="object"&&e._isSequenceSigner===!0}}class Bte extends DE{constructor(e,r,n){super(e,r.getProvider(n)),this.chainId=n,this._isSingleNetworkSequenceSigner=!0}_useChainId(e){const r=this.provider.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This signer only supports the network ${this.chainId}, but ${r} was requested.`);return r||this.provider.toChainId(this.chainId)}useChainId(e){return this._useChainId(e)}getChainId(){return Promise.resolve(this.provider.toChainId(this.chainId))}getProvider(e){return super.getProvider(this._useChainId(e))}getSigner(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceSigner===!0}}class aFe{constructor(e){if(this.signer=e,Bte.is(e))throw new Error("WalletUtils does not support SingleNetworkSequenceSigner")}signMessage(e,r,n){return this.signer.signMessage(e,{chainId:r,eip6492:n})}signTypedData(e,r,n,i,s){return this.signer.signTypedData(e,r,n,{chainId:i,eip6492:s})}async isValidSignature(e,r,n,i){return I$(e,r,n,this.signer.getProvider(i))}async isValidMessageSignature(e,r,n,i){const s=this.signer.getProvider(i),o=Nte(r),a=OEe(o);return I$(e,a,n,s)}isValidTypedDataSignature(e,r,n,i){return this.isValidSignature(e,Dk(r),n,i)}}const cFe=["method"],P$=["connect","disconnect","chainChanged","accountsChanged"];class KM extends gJ{constructor(e,r,n=dM,i){super(e.getChainId(),i),this.client=e,this.providerFor=r,this.networks=n,this.options=i,this.singleNetworkProviders={},this._isSequenceProvider=!0,this.utils=void 0,this.signer=void 0,this.eip1193EventListeners=new Map,e.onConnect(s=>{var o;(o=this.eip1193EventListeners.get("connect"))==null||o.forEach(a=>a(s))}),e.onDisconnect(s=>{var o;(o=this.eip1193EventListeners.get("disconnect"))==null||o.forEach(a=>a(s))}),e.onDefaultChainIdChanged(s=>{var o;(o=this.eip1193EventListeners.get("chainChanged"))==null||o.forEach(a=>a(s))}),e.onAccountsChanged(s=>{var o;(o=this.eip1193EventListeners.get("accountsChanged"))==null||o.forEach(a=>a(s))}),this.signer=new DE(this.client,this),this.utils=new aFe(this.signer)}async on(e,r){if(P$.includes(e)){const n=this.eip1193EventListeners.get(e)||new Set;return n.add(r),this.eip1193EventListeners.set(e,n),this}return super.on(e,r)}async off(e,r){if(P$.includes(e)){const n=this.eip1193EventListeners.get(e);return n&&(r?n.delete(r):n.clear()),this}return super.off(e,r)}getSigner(e){return this.signer.getSigner(e)}connect(e){return this.client.connect(e)}disconnect(){return this.client.disconnect()}isConnected(){return this.client.isConnected()}getSession(){return this.client.getSession()}listAccounts(){return[this.client.getAddress()]}getAddress(){return this.client.getAddress()}getNetworks(){return this.client.getNetworks()}getChainId(){return this.client.getChainId()}setDefaultChainId(e){return this.client.setDefaultChainId(this.toChainId(e))}isOpened(){return this.client.isOpened()}closeWallet(){return this.client.closeWallet()}getWalletContext(){return this.client.getWalletContext()}async getWalletConfig(e){const r=await this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}authorize(e){return this.client.connect($c({},e,{authorize:!0}))}async openWallet(e,r){return await this.client.openWallet(e,r),!0}toChainId(e){if(e===void 0)return;const r=Iw(this.networks,e);if(!r)throw new Error(`Unsupported network ${e}`);return r.chainId}async useChainId(e){return this.toChainId(e)||this.client.getChainId()}getProvider(e){if(!e)return this;const r=this.toChainId(e);return this.singleNetworkProviders[r]||(this.singleNetworkProviders[r]=new lFe(this.client,this.providerFor,r,this.options)),this.singleNetworkProviders[r]}async _getSubprovider(e){const r=await this.useChainId(e),n=this.providerFor(r);if(!n)throw new Error(`Unsupported network ${r}`);return n}async _perform(e){var r;const{method:n}=e,i=oFe(e,cFe),s=await this._getSubprovider(),o=(r=s.getRpcRequest(e))!=null?r:{method:n,args:Object.values(i)};if(!o)throw new Error(`Unsupported method ${e.method}`);return s.send(o.method,o.args)}async perform(e,r){if(e==="eth_chainId")return zc(await this.useChainId());if(e==="eth_accounts")return[this.client.getAddress()];if(e==="wallet_switchEthereumChain"){const n=r[0],i=Lte(n);return this.setDefaultChainId(i)}return e==="eth_sendTransaction"||e==="eth_sign"||e==="eth_signTypedData"||e==="eth_signTypedData_v4"||e==="personal_sign"||e==="sequence_sign"||e==="sequence_signTypedData_v4"?this.client.request({method:e,params:r,chainId:this.getChainId()}):this._perform($c({method:e},r))}send(e,r){return this.perform(e,r)}request(e){return this.perform(e.method,e.params)}async _detectNetwork(){const e=this.client.getChainId(),r=Iw(this.networks,e);if(!r)throw new Error(`Unknown network ${e}`);return new ca(r.name,r.chainId)}async detectNetwork(){return this._detectNetwork()}async waitForTransaction(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).waitForTransaction(e,r,n)}async getBlockNumber(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getBlockNumber()}async getFeeData(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getFeeData()}async getBalance(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getBalance(e,r)}async getTransactionCount(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getTransactionCount(e,r)}async getCode(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getCode(e,r)}async getStorage(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).getStorage(e,r,n)}async call(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).call(e)}async estimateGas(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).estimateGas(e)}async getBlock(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getBlock(e,r)}async getTransaction(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getTransaction(e)}async getLogs(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getLogs(e)}async supportsENS(){return(await this.getNetworks()).some(r=>r.chainId===1)}async getResolver(e){return await this.supportsENS()?(await this._getSubprovider(1)).getResolver(e):null}async resolveName(e){return vw(e)?e:await this.supportsENS()?(await this._getSubprovider(1)).resolveName(e):null}async lookupAddress(e){return await this.supportsENS()?(await this._getSubprovider(1)).lookupAddress(e):null}async getAvatar(e){return await this.supportsENS()?(await this._getSubprovider(1)).getAvatar(e):null}}KM.is=t=>t&&typeof t=="object"&&t._isSequenceProvider===!0;function Lte(t){return typeof t=="object"?Lte(t.chainId):Number(t)}class lFe extends KM{constructor(e,r,n,i){super(e,r,void 0,i),this.chainId=n,this._isSingleNetworkSequenceProvider=!0}_useChainId(e){const r=this.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This provider only supports the network ${this.chainId}, but ${r} was requested.`);return r||super.toChainId(this.chainId)}useChainId(e){return Promise.resolve(this._useChainId(e))}getChainId(){return super.toChainId(this.chainId)}async getNetwork(){const e=await this.client.getNetworks(),r=Iw(e,this.chainId);if(!r)throw new Error(`Unsupported network ${this.chainId}`);return new ca(r.name,r.chainId)}getProvider(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}getSigner(e){return super.getSigner(this._useChainId(e))}setDefaultChainId(e){throw new Error(`This provider only supports the network ${this.chainId}; use the parent provider to switch networks.`)}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceProvider===!0}}class Zr{constructor(e){de(this,"networkStore",Ir(Nn));de(this,"authStore",Ir(li));de(this,"accountAddress",this.authStore.accountAddress.get());de(this,"availableExternalProviders",Or([]));de(this,"selectedExternalProvider",Or(void 0));de(this,"selectedExternalWalletAddress",Or(void 0));de(this,"isSendingTokenTransaction",Or(void 0));de(this,"isSendingCollectibleTransaction",Or(void 0));de(this,"isSendingSignedTokenTransaction",Or(void 0));de(this,"connectDetails",Or(void 0));de(this,"connectOptions",Or(void 0));de(this,"isSigningTxn",Or(!1));de(this,"isSigningMsg",Or(!1));de(this,"toSignPermission",Or(void 0));de(this,"toSignResult",Or(void 0));de(this,"toSignTxnDetails",Or(void 0));de(this,"toSignMsgDetails",Or(void 0));de(this,"isCheckingWalletDeployment",Or(!1));de(this,"signClientWarningType",Or(!1));de(this,"walletRequestHandler");de(this,"local",{lastConnectedExternalProviderInfo:new Np(dh.LAST_CONNECTED_EXTERNAL_PROVIDER_INFO)});de(this,"defaultNetwork",new Np(dh.DEFAULT_NETWORK));de(this,"getLastConnectedExternalProviderInfo",()=>this.local.lastConnectedExternalProviderInfo.get());de(this,"sendToken",async(e,r,n)=>{var i,s;try{const o=this.store.get(li).account,a=e.chainId;if(!o)throw new Error("No account found");const c=this.store.get(Nn).providerForChainId(a);this.isSendingTokenTransaction.set({tokenBalance:e,to:r,amount:n});const l=(i=this.selectedExternalProvider.get())==null?void 0:i.provider;if(!l)throw new Error("No external provider selected");const u=(await this.getExternalProviderAccounts(l))[0];await this.switchToChain(l,a);let p;if(!n)return{hash:""};if(e.contractType===hh.NATIVE?(console.info("Sending native token with address, on chainId: ",e.contractAddress,a),p={to:r,value:E6e(n)}):e.contractType===hh.ERC20&&(console.info("Sending ERC20 token with address, on chainId: ",e.contractAddress,a),p=await new Dn(e.contractAddress,jv,c).transfer.populateTransaction(r,W7(n,((s=e.contractInfo)==null?void 0:s.decimals)??18))),!p)throw this.isSendingTokenTransaction.set(void 0),new Error("Could not create transaction");let g;try{g=(await this.sendTransaction(o,l,u,p,a)).hash}catch(y){throw this.isSendingTokenTransaction.set(void 0),y}return{hash:g}}catch{throw this.isSendingTokenTransaction.set(void 0),new Error("Could not create transaction")}});de(this,"sendCollectible",async(e,r,n)=>{var i,s;try{const o=this.store.get(li).account,a=e.collectibleInfoParams.chainId;if(!o)throw new Error("No account found");const c=this.store.get(Nn).providerForChainId(a);this.isSendingCollectibleTransaction.set({collectibleInfo:e,to:r,amount:n});const l=(i=this.selectedExternalProvider.get())==null?void 0:i.provider;if(!l)throw new Error("No external provider selected");const u=(await this.getExternalProviderAccounts(l))[0];await this.switchToChain(l,a);let p;if(e.collectibleInfoParams.contractType==="ERC721")console.info("Sending ERC721 non-fungible token with address, on chainId: ",e.collectibleInfoParams.address,a),p=await new Dn(e.collectibleInfoParams.address,hM,c).safeTransferFrom.populateTransaction(o,r,e.collectibleInfoParams.tokenId);else if(e.collectibleInfoParams.contractType==="ERC1155"){console.info("Sending ERC1155 token with address, on chainId: ",e.collectibleInfoParams.address,a);const y=new Dn(e.collectibleInfoParams.address,pM,c);if(!n)return{hash:""};p=await y.safeTransferFrom.populateTransaction(o,r,e.collectibleInfoParams.tokenId,W7(n,((s=e==null?void 0:e.collectibleInfoResponse)==null?void 0:s.decimals)??18),"0x")}if(!p)throw this.isSendingCollectibleTransaction.set(void 0),new Error("Could not create transaction");let g;try{g=(await this.sendTransaction(o,l,u,p,a)).hash}catch(y){throw this.isSendingCollectibleTransaction.set(void 0),y}return{hash:g}}catch{throw this.isSendingCollectibleTransaction.set(void 0),new Error("Could not create transaction")}});de(this,"setExternalProvider",async e=>{if(!e){this.selectedExternalProvider.set(void 0),this.selectedExternalWalletAddress.set(void 0),this.local.lastConnectedExternalProviderInfo.set(void 0);return}const n=(await this.getExternalProviderAccounts(e.provider))[0];this.local.lastConnectedExternalProviderInfo.set(e.info),this.selectedExternalProvider.set(e),this.selectedExternalWalletAddress.set(n),e.provider.on("accountsChanged",async i=>{if(i.length===0){this.selectedExternalProvider.set(void 0),this.selectedExternalWalletAddress.set(void 0);return}if(i[0]!==n){const o=(await this.getExternalProviderAccounts(e.provider))[0];this.selectedExternalWalletAddress.set(o)}})});de(this,"resetSignObservables",()=>{this.isSigningTxn.set(!1),this.toSignTxnDetails.set(void 0),this.toSignMsgDetails.set(void 0),this.toSignPermission.set(void 0),this.toSignResult.set(void 0)});de(this,"checkWalletDeployment",async e=>{const r=this.store.get(li).account;if(!r)throw new Error("No account found");return(await r.status(e)).onChain.deployed});this.store=e,this.walletRequestHandler=new nFe(void 0,new fFe(e),this.networkStore.networks.get()),this.walletRequestHandler.onConnectOptionsChange=n=>{this.connectOptions.set(n)},this.availableExternalProviders.subscribe(n=>{const i=this.local.lastConnectedExternalProviderInfo.get(),s=n.find(o=>(i==null?void 0:i.name)===o.info.name);s&&this.setExternalProvider(s)});const r=this.store.get(li).account;this.walletRequestHandler.signIn(r??null)}async sendTransaction(e,r,n,i,s){const o=await e.status(s),a=await e.predecorateTransactions(i,o,s),c=await e.signTransactions(a,s,void 0,{serial:!0}),l=await e.decorateTransactions(c,o);await this.switchToChain(r,s);const f=await r.request({method:"eth_estimateGas",params:[{from:n,to:l.entrypoint,data:mt.transaction.encodeBundleExecData(l)}]});return{hash:await r.request({method:"eth_sendTransaction",params:[{from:n,to:l.entrypoint,data:mt.transaction.encodeBundleExecData(l),gas:f}]})}}async getExternalProviderAccounts(e){return new Promise((r,n)=>{var i;(i=e.sendAsync)==null||i.call(e,{method:"eth_requestAccounts",params:[]},(s,o)=>{s&&n(s),o.result.length===0&&n(new Error("No accounts found")),r(o.result)})})}async getExternalProviderAddress(e){return(await this.getExternalProviderAccounts(e))[0]}async switchToChain(e,r){return new Promise((n,i)=>{var s;(s=e.sendAsync)==null||s.call(e,{method:"wallet_switchEthereumChain",params:[{chainId:zc(r)}]},(o,a)=>{o&&i(o),n(a)})})}}class fFe{constructor(e){this.store=e}getDefaultChainId(){return this.store.get(Zr).defaultNetwork.get()??1}async promptChangeNetwork(e){return this.store.get(Nn).networks.get().some(n=>n.chainId===e)?(this.store.get(Zr).defaultNetwork.set(e),!0):!1}async promptConfirmWalletDeploy(e,r){if(console.log("prompt confirm wallet deploy:",e,r),!e)return Promise.resolve(!1);const n=await this.store.get(Zr).checkWalletDeployment(e);return new Promise((i,s)=>{i(!!n)})}async promptConnect(e){console.log("promptconnect",e);const r=this.store.get(li).account;return await this.store.get(Zr).walletRequestHandler.signIn(r??null),e&&this.store.get(Zr).walletRequestHandler.setConnectOptions(e),new Promise((n,i)=>{const s=this.store.get(Zr).connectDetails.subscribe(o=>{s(),!o||!o.connected?i("connect cancelled by user"):n(o)})})}async promptSignInConnect(e){return console.log("prompt sign in connect:",e),{connected:!1}}async promptSignMessage(e,r){return console.log("prompt sign message:",e,r),e.chainId?e.eip6492!==!0&&!(await this.store.get(li).account.status(e.chainId)).canOnchainValidate&&!await this.promptConfirmWalletDeploy(e.chainId,r)?(this.store.get(Zr).signClientWarningType.set("notDeployed"),Promise.reject("User rejected wallet deploy request")):(this.store.get(Zr).isSigningMsg.set(!0),this.store.get(Zr).toSignMsgDetails.set({message:e,chainId:e.chainId,options:r}),new Promise((n,i)=>{const s=this.store.get(Zr).toSignPermission.subscribe(()=>{s();const o=this.store.get(Zr).toSignPermission.get();if(this.store.get(Zr).toSignPermission.set(void 0),!o||o==="cancelled")i("request failed");else{const a=this.store.get(Zr).toSignResult.get();a&&n(a.hash)}})})):Promise.reject("No chainId found in message")}promptSignTransaction(e,r,n){console.log("prompt sign transaction:",e,r,n);let i;Array.isArray(e)?i=e:i=[e];const s=this.store.get(li).accountAddress.get();if(!s)throw new Error("Unknown account address");const o=mt.transaction.fromTransactionish(s,i);return console.log("prompt sign txn:",o,r,n),_I(s,i),new Promise((a,c)=>{this.store.get(Zr).toSignTxnDetails.set({txn:i,chainId:r,options:n}),this.store.get(Zr).isSigningTxn.set(!0);const l=this.store.get(Zr).toSignPermission.subscribe(()=>{l();const f=this.store.get(Zr).toSignPermission.get();if(this.store.get(Zr).toSignPermission.set(void 0),!f||f==="cancelled")c("request failed");else{const u=this.store.get(Zr).toSignResult.get();u&&a(u.hash)}})})}promptSendTransaction(e,r,n){return this.promptSignTransaction(e,r,n)}}async function Fte(t){return await PLe.init({projectId:lX,showQrModal:t,optionalChains:[1],metadata:{name:"Sequence Recovery Wallet External Wallet",description:"",url:"TODO_CHANGE_LATER",icons:[]}})}function uFe(){const[t,e]=D.useState(null),n=Ir(Zr).getLastConnectedExternalProviderInfo();return D.useEffect(()=>{async function i(){const s=await Fte(!1);await s.enable(),e(s)}return(n==null?void 0:n.name)==="WalletConnect"&&i(),()=>{t&&t.disconnect()}},[]),t}const k$=async(t,e,r=15)=>{let n,i=0;do{if(i>5&&await new Promise(s=>setTimeout(s,100*i)),n=await t.getTransactionReceipt(e),i===r){console.warn(`Could not get receipt for transaction ${e} after ${i} tries`);return}if(n)return n;i++}while(!n&&i<=r)};let L6=[];const cS={value:()=>L6,subscribe:t=>{function e(r){L6.some(n=>n.info.uuid===r.detail.info.uuid)||(L6=[...L6,r.detail],t())}return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)}},jte=()=>D.useSyncExternalStore(cS.subscribe,cS.value,cS.value);class NE{constructor(e){de(this,"authStore",Ir(li));de(this,"accountAddress",this.authStore.accountAddress.get());de(this,"isReady",Or(!1));de(this,"signClient");de(this,"currentRequestInfo");de(this,"allSessions",Or([]));de(this,"sessions",this.allSessions.readOnly());de(this,"createSignClient",async()=>{this.signClient=await OE.init({projectId:lX,metadata:{name:"Sequence Recovery Wallet",description:"Sequence Recovery Wallet - Recover Your Wallet",url:"http://localhost:5173",icons:["https://sequence.app/apple-touch-icon.png"]}}),this.signClient.on("session_proposal",this.onSessionProposal),this.signClient.on("session_request",this.onSessionRequest),this.signClient.on("session_ping",this.onSessionPing),this.signClient.on("session_event",this.onSessionEvent),this.signClient.on("session_update",this.onSessionUpdate),this.signClient.on("session_delete",this.onSessionDelete);const e=this.getSignClientSessions();e?this.allSessions.set(e):this.allSessions.set([]),this.isReady.set(!0)});de(this,"getSignClientSessions",()=>this.signClient.session.getAll().filter(r=>r.self.metadata.name!=="Sequence Recovery Wallet External Wallet"));de(this,"pair",async e=>{if(!this.signClient)throw new Error("WalletConnect signClient not initialized.");await this.signClient.core.pairing.pair({uri:e}),this.allSessions.set(this.getSignClientSessions())});de(this,"rejectRequest",()=>{var e;this.currentRequestInfo&&((e=this.signClient)==null||e.respond({topic:this.currentRequestInfo.topic,response:{id:this.currentRequestInfo.id,jsonrpc:"2.0",error:{message:"User rejected.",code:4001}}}))});de(this,"disconnectSession",async e=>{var n,i;const r=(n=this.signClient)==null?void 0:n.session.get(e);r&&(await((i=this.signClient)==null?void 0:i.engine.client.disconnect({topic:r.topic,reason:{message:"User disconnected.",code:6e3}})),this.allSessions.set(this.getSignClientSessions()??[]))});de(this,"disconnectAllSessions",async()=>{var r;(((r=this.signClient)==null?void 0:r.session.getAll())??[]).forEach(async n=>{var i;await((i=this.signClient)==null?void 0:i.engine.client.disconnect({topic:n.topic,reason:{message:"User disconnected.",code:6e3}}))}),this.allSessions.set([])});de(this,"onSessionProposal",async e=>{var l,f,u,p,g;console.log("onSessionProposal",e);const r=e.params.requiredNamespaces,n=e.params.optionalNamespaces,i=Object.keys(r).length===0?[]:r.eip155.chains??[],s=Object.keys(n).length===0?[]:n.eip155.chains??[],o=((l=i[0])==null?void 0:l.split(":").pop())??((f=s[0])==null?void 0:f.split(":").pop());if(!o)throw new Error("No chainId found in WalletConnect session proposal namespaces.");const a={app:e.params.proposer.metadata.name,origin:e.params.proposer.metadata.url,networkId:o,keepWalletOpened:!0},c=await this.store.get(Zr).walletRequestHandler.promptConnect(a);if(c&&c.connected){const b=this.store.get(Nn).networks.get(),I=i.map(_=>Number(_.split(":").pop())),C=s.map(_=>Number(_.split(":").pop())),L={eip155:{accounts:b.map(_=>_.chainId).filter(_=>[...I,...C].includes(_)).map(_=>"eip155:"+_+":"+this.accountAddress),methods:["eth_sendTransaction","eth_sign","personal_sign","eth_signTypedData","eth_signTypedData_v4","wallet_switchEthereumChain"],events:["chainChanged","accountsChanged","connect","disconnect"]}},F=await((u=this.signClient)==null?void 0:u.approve({id:e.id,namespaces:L})),z=await(F==null?void 0:F.acknowledged());console.log("session",z),this.allSessions.set(this.getSignClientSessions()??[]),(p=this.signClient)==null||p.core.pairing.getPairings().filter(_=>e.params.pairingTopic!==_.topic).forEach(async _=>{var $,ie;e.params.proposer.metadata.url===(($=_.peerMetadata)==null?void 0:$.url)&&await((ie=this.signClient)==null?void 0:ie.core.pairing.disconnect({topic:_.topic}))})}else(g=this.signClient)==null||g.reject({id:e.id,reason:{message:"User rejected.",code:5e3}})});de(this,"onSessionRequest",async e=>{var o,a,c;console.log("onSessionRequest",e);const r=e.params.chainId.split(":").pop(),n={jsonrpc:"2.0",id:e.id,method:e.params.request.method,params:e.params.request.params,chainId:Number(r)};n.method==="eth_sendTransaction"&&Array.isArray(n.params)&&n.params.forEach(l=>{delete l.nonce});const i=(o=this.signClient)==null?void 0:o.session.get(e.topic),s={app:(i==null?void 0:i.peer.metadata.name)??"",origin:i==null?void 0:i.peer.metadata.url,networkId:r};this.store.get(Zr).walletRequestHandler.setConnectOptions(s),this.currentRequestInfo={topic:e.topic,id:e.id};try{const l=await this.store.get(Zr).walletRequestHandler.request(n);(a=this.signClient)==null||a.respond({topic:e.topic,response:{id:e.id,jsonrpc:"2.0",result:l}})}catch(l){(c=this.signClient)==null||c.respond({topic:e.topic,response:{id:e.id,jsonrpc:"2.0",error:{message:l.message,code:l.code??4001}}})}this.currentRequestInfo=void 0});de(this,"onSessionPing",async e=>{console.log("onSessionPing",e)});de(this,"onSessionEvent",async e=>{console.log("onSessionEvent",e)});de(this,"onSessionUpdate",async e=>{console.log("onSessionUpdate",e)});de(this,"onSessionDelete",async e=>{console.log("onSessionDelete",e),this.allSessions.set(this.getSignClientSessions()??[])});this.store=e,this.createSignClient()}}const M$=["https://dweb.link/ipfs/","https://gateway.pinata.cloud/ipfs/","https://nftstorage.link/ipfs/","https://flk-ipfs.io/ipfs/","https://storry.tv/ipfs/","https://ipfs.io/ipfs/","https://hardbin.com/ipfs/","https://ipfs.runfission.com/ipfs/","https://ipfs.eth.aragon.network/ipfs/","https://4everland.io/ipfs/","https://w3s.link/ipfs/","https://trustless-gateway.link/ipfs/"],dFe="QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/1";class hFe{constructor(){de(this,"gatewayURL");de(this,"localStore");this.localStore=new Np(dh.GATEWAY_ADDRESS),this.gatewayURL=this.localStore.get(),this.findAccessibleGateway()}async findAccessibleGateway(){const e=this.localStore.get();if(e&&await this.isGatewayAccessible(e)){this.gatewayURL=e;return}for(const r of M$)if(await this.isGatewayAccessible(r)){this.gatewayURL=r,this.localStore.set(r);return}this.gatewayURL=M$[0],console.warn("No accessible IPFS gateways found, falling back to default")}async isGatewayAccessible(e){try{return await fetch(`${e}${dFe}`,{signal:AbortSignal.timeout(3e3)}),!0}catch{return!1}}async fetch(e){this.gatewayURL||await this.findAccessibleGateway();const r=await this.getGatewayURL(e);return fetch(r,{signal:AbortSignal.timeout(3e3)})}async getGatewayURL(e){if(this.gatewayURL||await this.findAccessibleGateway(),!e.startsWith("ipfs://"))throw new Error("Invalid IPFS URI");return e.replace("ipfs://",this.gatewayURL)}}class YM{constructor(e){de(this,"isFetchingBalances",Or(!1));de(this,"isFetchingCollectibleInfo",Or(!1));de(this,"ipfsGatewayHelper",new hFe);de(this,"userCollectibles",Or([]));de(this,"local",{userCollectibles:new Np(dh.COLLECTIBLES)});this.store=e;const r=this.store.get(Nn);pX(r.networks,n=>{const i=this.store.get(li).accountAddress.get();i&&n.length>0&&this.loadBalances(i)})}async loadBalances(e){const r=this.local.userCollectibles.get()??[];if(r.length===0)return;this.isFetchingBalances.set(!0);const n=[],i=r.map(async s=>{const o=await this.getCollectibleInfo(s);if(!o.isOwner){this.removeCollectible({collectibleInfoParams:s,collectibleInfoResponse:o});return}n.push({collectibleInfoParams:s,collectibleInfoResponse:o})});await Promise.allSettled(i),this.userCollectibles.set(n),this.isFetchingBalances.set(!1)}async getCollectibleInfo(e){const r=this.store.get(li).accountAddress.get();if(!r)throw new Error("No account found");const n=this.store.get(Nn).providerForChainId(e.chainId);this.isFetchingCollectibleInfo.set(!0);let i,s,o,a,c;if(e.contractType===hh.ERC721){const f=new Dn(e.address,hM,n),p=(await f.ownerOf(e.tokenId)).toLowerCase()===r.toLowerCase();if(!p)return this.isFetchingCollectibleInfo.set(!1),{isOwner:p,uri:""};i=await f.tokenURI(e.tokenId)}else if(e.contractType===hh.ERC1155){const f=new Dn(e.address,pM,n);if(a=await f.balanceOf(r,e.tokenId),!a)return this.isFetchingCollectibleInfo.set(!1),{isOwner:!1,uri:""};i=await f.uri(e.tokenId)}if(!i)throw new Error("Could not get collectible URI");i.includes("{id}")&&(i=i.replace("{id}",e.tokenId.toString()));let l;return i.startsWith("ipfs://")?l=await this.ipfsGatewayHelper.fetch(i).then(f=>f.json()):l=await fetch(i).then(f=>f.json()),l&&(c=l.decimals,s=l.image,o=l.name),s!=null&&s.startsWith("ipfs://")&&(s=await this.ipfsGatewayHelper.getGatewayURL(s)),a=a??BigInt(1),c=c??0,this.isFetchingCollectibleInfo.set(!1),{isOwner:!0,uri:i,image:s,name:o,balance:a,decimals:c}}async addCollectible(e){if(e.collectibleInfoResponse.isOwner){const r=this.local.userCollectibles.get()??[];if(r.some(n=>n.address===e.collectibleInfoParams.address&&n.tokenId===e.collectibleInfoParams.tokenId))throw new Error("Collectible already added");this.local.userCollectibles.set([...r,e.collectibleInfoParams]),this.isFetchingCollectibleInfo.set(!0),this.loadBalances(),this.isFetchingCollectibleInfo.set(!1)}}async removeCollectible(e){const n=(this.local.userCollectibles.get()??[]).filter(i=>i.address!==e.collectibleInfoParams.address||i.tokenId!==e.collectibleInfoParams.tokenId);this.local.userCollectibles.set(n),this.isFetchingCollectibleInfo.set(!0),this.loadBalances(),this.isFetchingCollectibleInfo.set(!1)}}function BE({chainId:t,paddingTop:e="1",paddingBottom:r="2"}){return W.jsx(xe,{background:"backgroundMuted",width:"fit",height:"fit",borderRadius:"sm",paddingTop:e,paddingBottom:r,paddingX:"2",children:W.jsx(Ge,{variant:"xsmall",color:"text100",children:ky(t)})})}function pFe({collectibleInfo:t,onSendClick:e,onRemoveClick:r}){return W.jsxs($r,{width:"full",flexDirection:"column",gap:"2",padding:"4",children:[W.jsx(xe,{flexDirection:"row",alignItems:"center",gap:"2",children:W.jsx(Ge,{variant:"medium",color:"text80",children:t.collectibleInfoResponse.name??"Collectible"})}),W.jsx(xe,{style:{height:"200px"},children:W.jsx(a8,{style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"},src:t.collectibleInfoResponse.image??"",width:"full"})}),W.jsx(xe,{justifyContent:"flex-end",children:W.jsx(Ge,{variant:"medium",color:"text100",children:t.collectibleInfoParams.contractType==="ERC1155"?Number(fh(t.collectibleInfoResponse.balance,t.collectibleInfoResponse.decimals??0)):1})}),W.jsxs(xe,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(BE,{chainId:t.collectibleInfoParams.chainId}),W.jsxs(xe,{children:[W.jsx(Zt,{size:"xs",label:"Send",variant:"primary",shape:"square",onClick:e}),r&&W.jsx(Zt,{marginLeft:"2",size:"xs",label:"Remove",shape:"square",onClick:r})]})]})]})}function vFe({onClose:t}){const r=Ir(Nn).networks.get(),n=r.filter(z=>z.type===Ft.MAINNET),i=Ir(YM),s=yn(i.isFetchingCollectibleInfo),o=h8(),[a,c]=D.useState(),[l,f]=D.useState(),[u,p]=D.useState(),[g,y]=D.useState(),[b,I]=D.useState(),[C,S]=D.useState(!1);D.useEffect(()=>{a&&l&&u&&g?i.getCollectibleInfo({chainId:a.chainId,address:l,tokenId:u,contractType:g}).then(z=>{I(z)}):I(void 0)},[a,l,u,g]);const O=n.map(z=>({label:z.title,value:z.chainId.toString()})),L=async()=>{a&&l&&b&&u&&g&&(await i.addCollectible({collectibleInfoParams:{chainId:a.chainId,address:l,tokenId:u,contractType:g},collectibleInfoResponse:b}),S(!1),o({variant:"success",title:"Collectible added"}),F(),t())},F=()=>{f(void 0),c(void 0),p(void 0),y(void 0)};return W.jsxs($r,{flexDirection:"column",paddingY:"4",paddingX:"8",marginBottom:"8",borderRadius:"md",width:"full",height:"full",alignItems:"center",disabled:C,children:[W.jsx(xe,{children:W.jsx(Ge,{variant:"medium",color:"text80",children:"Import ERC721 or ERC1155 Collectible"})}),W.jsxs(xe,{flexDirection:"column",width:"full",marginTop:"4",gap:"4",children:[W.jsx(M7,{label:"Collectible Network",labelLocation:"left",name:"collectibleNetwork",options:O,onValueChange:z=>c(r.find(_=>_.chainId===Number(z)))}),W.jsx(Wn,{width:"full",label:"Collectible Address",labelLocation:"left",name:"collectibleAddress",value:l??"",onChange:z=>{f(z.target.value)}}),W.jsx(M7,{label:"Collectible Type",labelLocation:"left",name:"collectibleType",options:[{value:"ERC721",label:"ERC721"},{value:"ERC1155",label:"ERC1155"}],onValueChange:z=>y(z)}),W.jsx(Wn,{width:"full",label:"Collectible Token ID",labelLocation:"left",name:"collectibleId",value:u??"",onKeyPress:z=>{/[0-9]/.test(z.key)||z.preventDefault()},onChange:z=>{if(z.target.value===""){p(void 0);return}p(z.target.value)}}),s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})}),b&&!b.isOwner&&!s&&W.jsx(xe,{alignItems:"center",justifyContent:"center",children:W.jsx(Ge,{variant:"medium",color:"warning",children:"You do not own this collectible"})}),b&&b.isOwner&&!s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx($r,{flexDirection:"column",gap:"2",children:W.jsxs(xe,{flexDirection:"row",gap:"6",children:[W.jsx("img",{src:b.image??"",alt:b.name??"",style:{width:"120px",height:"auto"}}),W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Ge,{variant:"medium",color:"text100",children:b.name??""}),W.jsx(W.Fragment,{children:b.balance&&W.jsxs(W.Fragment,{children:[W.jsx(Ge,{variant:"small",color:"text80",children:"Your Balance:"}),W.jsx(Ge,{variant:"medium",color:"text100",children:Number(fh(b.balance,b.decimals??0))})]})})]})]})})}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",disabled:C,onClick:()=>{F(),t()}}),W.jsx(Zt,{label:"Add",disabled:b===void 0||!b.isOwner||C,variant:"primary",size:"md",shape:"square",onClick:L})]})]})]})}function gFe({onSendClick:t}){const e=Ir(YM),r=yn(e.isFetchingBalances),n=yn(e.userCollectibles),i=D.useMemo(()=>n,[n]),[s,o]=D.useState(!1);return W.jsxs(W.Fragment,{children:[W.jsxs(xe,{width:"full",flexDirection:"row",flexWrap:"wrap",gap:"4",marginBottom:"8",children:[i.map(a=>W.jsx(xe,{width:"1/3",children:W.jsx(pFe,{collectibleInfo:a,onSendClick:()=>{t(a)},onRemoveClick:()=>{e.removeCollectible(a)}})},a.collectibleInfoParams.chainId+a.collectibleInfoParams.address+a.collectibleInfoParams.tokenId)),r&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})})]}),W.jsxs(xe,{width:"full",flexDirection:"column",alignItems:"center",justifyContent:"center",marginBottom:"4",children:[s&&W.jsx(vFe,{onClose:()=>o(!1)}),W.jsx(Zt,{label:"Import collectible",leftIcon:UH,variant:"primary",size:"md",shape:"square",onClick:()=>{o(!0)}})]})]})}function yFe({onClose:t}){const e=Ir(Nn),r=h8(),[n,i]=D.useState(),[s,o]=D.useState(),[a,c]=D.useState(),[l,f]=D.useState(),[u,p]=D.useState(),[g,y]=D.useState(),b=async()=>{n&&s&&a&&l&&await e.addNetwork({chainId:Number(n),name:s,title:s,type:Ft.MAINNET,rpcUrl:a,blockExplorer:{rootUrl:l},nativeToken:{name:u||"Ether",symbol:g||"ETH",decimals:18}})},I=()=>{i(void 0),o(void 0),c(void 0),f(void 0),p(void 0),y(void 0)};return W.jsxs(xe,{flexDirection:"column",width:"full",marginTop:"4",gap:"4",children:[W.jsx(Wn,{width:"full",label:"Chain ID",labelLocation:"left",name:"chainId",value:n??"",onChange:C=>{i(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Network Name",labelLocation:"left",name:"networkName",value:s??"",onChange:C=>{o(C.target.value)}}),W.jsx(Wn,{width:"full",label:"RPC URL",labelLocation:"left",name:"rpcUrl",value:a??"",onChange:C=>{c(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Block explorer URL",labelLocation:"left",name:"rpcUrl",value:l??"",onChange:C=>{f(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Native Token Name",labelLocation:"left",name:"tokenName",value:u??"",onChange:C=>{p(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Native Token Symbol",labelLocation:"left",name:"tokenSymbol",value:g??"",onChange:C=>{y(C.target.value)}}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",onClick:()=>{I(),t()}}),W.jsx(Zt,{label:"Add",variant:"primary",size:"md",shape:"square",onClick:async()=>{try{await b(),r({variant:"success",title:"Network added",description:`You can now use ${s} network`}),I(),t()}catch(C){r({variant:"error",title:"Could not add network",description:C.message}),console.error(C)}}})]})]})}function R$({network:t}){var f,u;const e=Ir(Nn),n=yn(e.userAdditionNetworkChainIds).includes(t.chainId);D.useEffect(()=>{var p,g;(s!==t.rpcUrl||a!==((p=t.blockExplorer)==null?void 0:p.rootUrl))&&(o(t.rpcUrl),c(((g=t.blockExplorer)==null?void 0:g.rootUrl)??""))},[t]);const i=e.editedNetworkChainIds.get().includes(t.chainId),[s,o]=D.useState(t.rpcUrl),[a,c]=D.useState(((f=t.blockExplorer)==null?void 0:f.rootUrl)??""),l=s!==t.rpcUrl||a!==((u=t.blockExplorer)==null?void 0:u.rootUrl);return W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Ge,{fontWeight:"bold",color:"text100",children:t.title}),W.jsx(Wn,{label:"RPC URL",labelLocation:"left",name:"rpcUrl",spellCheck:!1,disabled:n,value:s??"",onChange:p=>{o(p.target.value)}}),W.jsx(Wn,{label:"Block Explorer URL",labelLocation:"left",name:"blockExplorerUrl",spellCheck:!1,disabled:n,value:a??"",onChange:p=>{c(p.target.value)}}),n&&W.jsxs(xe,{marginTop:"4",alignItems:"center",justifyContent:"flex-end",gap:"5",children:[W.jsx(Ge,{variant:"small",color:"text50",children:"Added by you"}),W.jsx(Zt,{label:"Remove",variant:"danger",size:"md",shape:"square",onClick:()=>e.removeNetwork(t.chainId)})]}),(l||i)&&!n&&W.jsxs(xe,{marginTop:"4",justifyContent:"flex-end",gap:"3",children:[W.jsx(W.Fragment,{children:i&&W.jsx(Zt,{label:"Reset to default",variant:"danger",size:"md",shape:"square",onClick:()=>e.resetNetworkEdit(t.chainId)})}),W.jsx(W.Fragment,{children:l&&W.jsx(Zt,{label:"Save",variant:"primary",size:"md",shape:"square",onClick:()=>{const p=t;p.rpcUrl=s,p.blockExplorer={rootUrl:a},p.relayer=_3(s),e.editNetwork(p)}})})]}),W.jsx(Sh,{})]})}function mFe(){const t=Ir(Nn),e=yn(t.networks),r=e.filter(f=>f.type===Ft.MAINNET),n=yn(t.userAdditionNetworkChainIds),i=r.sort((f,u)=>n.includes(f.chainId)?-1:1),s=e.filter(f=>f.type===Ft.TESTNET),[o,a]=D.useState(Ft.MAINNET),[c,l]=D.useState(!1);return W.jsxs(xe,{flexDirection:"column",paddingY:"4",paddingX:"8",background:"backgroundPrimary",width:"full",height:"full",alignItems:"center",children:[W.jsx(xe,{children:W.jsx(Ge,{variant:"large",color:"text80",children:"Networks"})}),W.jsx(xe,{width:"full",marginTop:"4",paddingBottom:"4",children:W.jsxs(vwe,{value:o,onValueChange:f=>a(f),children:[W.jsx(xe,{marginBottom:"10",children:W.jsx(pwe,{value:o,tabs:[{label:"Networks",value:Ft.MAINNET},{label:"Test Networks",value:Ft.TESTNET}]})}),W.jsx(HB,{value:Ft.MAINNET,children:W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsxs(xe,{width:"full",flexDirection:"column",alignItems:"flex-end",marginY:"4",children:[W.jsx(Zt,{label:"Add network",variant:"primary",size:"md",shape:"square",onClick:()=>{l(!0)}}),c&&W.jsx(yFe,{onClose:()=>l(!1)})]}),W.jsx(W.Fragment,{children:i.map((f,u)=>W.jsx(R$,{network:f},u))})]})}),W.jsx(HB,{value:Ft.TESTNET,children:W.jsx(xe,{flexDirection:"column",gap:"2",children:s.map((f,u)=>W.jsx(R$,{network:f},u))})})]})})]})}function lS({symbol:t,chainId:e,to:r,amount:n}){return W.jsxs(xe,{flexDirection:"column",width:"full",gap:"4",children:[W.jsx(Ge,{variant:"large",color:"text80",children:"Pending transaction"}),W.jsxs(xe,{background:"backgroundMuted",flexDirection:"row",width:"full",height:"fit",borderRadius:"sm",paddingX:"4",paddingY:"2",alignItems:"center",gap:"5",children:[W.jsx(lh,{size:"md"}),W.jsxs(xe,{flexDirection:"column",gap:"1",children:[W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"1",children:[W.jsxs(Ge,{variant:"small",color:"text100",children:["Sending ",n," ",t," on"]}),W.jsx(BE,{chainId:e,paddingTop:"0",paddingBottom:"1"}),W.jsxs(Ge,{variant:"small",color:"text80",children:["to ",r]})]}),W.jsx(Ge,{variant:"small",color:"text50",children:"Your external wallet will prompt you to confirm the transaction"})]})]})]})}function bFe({onSelectProvider:t}){const e=Ir(NE),r=jte(),[n,i]=D.useState(!1),s=()=>window.confirm("All WalletConnect Dapp sessions will be disconnected. If you would like to continue, click OK and connect to WalletConnect again."),o=async()=>{try{if(!n){if(e.allSessions.get().length!==0){if(!s())throw new Error("User rejected wallet connect modal");await e.disconnectAllSessions(),t();return}i(!0);const a=await Fte(!0);await a.connect();let c=hre(a);t(c)}}catch(a){console.error(a)}};return W.jsx(W.Fragment,{children:!n&&W.jsxs(xe,{flexDirection:"column",paddingY:"5",alignItems:"center",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:"Select an external wallet to send transactions"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs(xe,{flexDirection:"column",gap:"4",padding:"8",children:[W.jsx($r,{flexDirection:"row",alignItems:"center",gap:"2",cursor:"pointer",background:{base:"buttonGlass",hover:"backgroundSecondary"},onClick:()=>{o()},children:W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"2",children:[W.jsx("img",{src:"https://avatars.githubusercontent.com/u/37784886",alt:"Wallet Connect",style:{width:"20px",height:"20px"}}),W.jsx(Ge,{variant:"normal",color:"text100",children:"Wallet Connect"})]})}),r.map(a=>W.jsx($r,{flexDirection:"row",alignItems:"center",gap:"2",cursor:"pointer",background:{base:"buttonGlass",hover:"backgroundSecondary"},onClick:()=>t(a),children:W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"2",children:[W.jsx("img",{src:a.info.icon,alt:a.info.name,style:{width:"20px",height:"20px"}}),W.jsx(Ge,{variant:"normal",color:"text100",children:a.info.name})]})},a.info.uuid))]})]})})}function wFe({collectibleInfo:t,onClose:e}){var y,b,I;const r=KP("isMobile"),n=Ir(Zr),[i,s]=D.useState(void 0),[o,a]=D.useState(void 0),[c,l]=D.useState(!1),[f,u]=D.useState(!1);if(D.useEffect(()=>{const C=n.selectedExternalWalletAddress.get();c&&C&&a(n.selectedExternalWalletAddress.get())},[c]),D.useEffect(()=>{u(n.selectedExternalWalletAddress.get()!==void 0)},[n.selectedExternalWalletAddress]),!t)return null;const p=t.collectibleInfoParams.contractType==="ERC721",g=ky(t.collectibleInfoParams.chainId);return W.jsxs(xe,{flexDirection:"column",paddingY:"5",alignItems:"center",children:[W.jsxs(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:["Sending ",(y=t==null?void 0:t.collectibleInfoResponse)==null?void 0:y.name," on ",g]}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs(xe,{style:{minWidth:r?"100vw":"520px"},paddingX:"6",flexDirection:"column",gap:"4",width:"full",marginTop:"6",children:[W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Wn,{label:"Amount",labelLocation:"top",name:"amount",placeholder:"Enter amount",value:p?"1":i??"",onChange:C=>{s(C.target.value)},disabled:p,controls:W.jsx(W.Fragment,{children:t.collectibleInfoParams.contractType==="ERC1155"&&W.jsx(Zt,{label:"Max",variant:"text",size:"md",shape:"square",paddingRight:"2",onClick:()=>{var C,S;s(fh((C=t==null?void 0:t.collectibleInfoResponse)==null?void 0:C.balance,((S=t==null?void 0:t.collectibleInfoResponse)==null?void 0:S.decimals)??18))}})})}),W.jsxs(Ge,{variant:"small",color:"text50",children:["Current balance:"," ",fh((b=t==null?void 0:t.collectibleInfoResponse)==null?void 0:b.balance,((I=t==null?void 0:t.collectibleInfoResponse)==null?void 0:I.decimals)??18)]})]}),W.jsxs(xe,{flexDirection:"column",gap:"3",children:[W.jsx(Wn,{label:"To",labelLocation:"top",name:"to",placeholder:"0x...",value:o??"",onChange:C=>{a(C.target.value)},disabled:c}),W.jsx(eP,{label:f?"Send to connected external wallet address":"Connect external wallet to autofill address",checked:c,onCheckedChange:C=>l(C===!0),labelLocation:"right",disabled:!f})]}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",onClick:()=>{e()}}),W.jsx(Zt,{label:"Send",variant:"primary",size:"md",shape:"square",disabled:!(p&&o||!p&&o&&i),onClick:()=>{e(o,i)}})]})]})]})}function xFe({tokenBalance:t,onClose:e}){var g,y;const r=KP("isMobile"),n=Ir(Zr),[i,s]=D.useState(void 0),[o,a]=D.useState(void 0),[c,l]=D.useState(!1),[f,u]=D.useState(!1);if(D.useEffect(()=>{const b=n.selectedExternalWalletAddress.get();c&&b&&a(n.selectedExternalWalletAddress.get())},[c]),D.useEffect(()=>{u(n.selectedExternalWalletAddress.get()!==void 0)},[n.selectedExternalWalletAddress]),!t)return null;const p=ky(t.chainId);return W.jsxs(xe,{flexDirection:"column",paddingY:"5",alignItems:"center",children:[W.jsxs(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:["Sending ",(g=t==null?void 0:t.contractInfo)==null?void 0:g.symbol," on ",p]}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs(xe,{style:{minWidth:r?"100vw":"520px"},paddingX:"6",flexDirection:"column",gap:"4",width:"full",marginTop:"6",children:[W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Wn,{label:"Amount",labelLocation:"top",name:"amount",placeholder:"Enter amount",value:i??"",onChange:b=>{s(b.target.value)},controls:W.jsx(Zt,{label:"Max",variant:"text",size:"md",shape:"square",paddingRight:"2",onClick:()=>{var b;s(fh(t==null?void 0:t.balance,((b=t==null?void 0:t.contractInfo)==null?void 0:b.decimals)??18))}})}),W.jsxs(Ge,{variant:"small",color:"text50",children:["Current balance:"," ",fh(t==null?void 0:t.balance,((y=t==null?void 0:t.contractInfo)==null?void 0:y.decimals)??18)]})]}),W.jsxs(xe,{flexDirection:"column",gap:"3",children:[W.jsx(Wn,{label:"To",labelLocation:"top",name:"to",placeholder:"0x...",value:o??"",onChange:b=>{a(b.target.value)},disabled:c}),W.jsx(eP,{label:f?"Send to connected external wallet address":"Connect external wallet to autofill address",checked:c,onCheckedChange:b=>l(b===!0),labelLocation:"right",disabled:!f})]}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",onClick:()=>{e()}}),W.jsx(Zt,{label:"Send",variant:"primary",size:"md",shape:"square",disabled:!o||!i,onClick:()=>{o&&i&&e(o,i)}})]})]})]})}function EFe({onTokenListClick:t}){const e=Ir(li),r=rk();return W.jsxs(Kye,{children:[W.jsx(Zt,{as:Yye,label:"Settings",variant:"text"}),W.jsx(Qye,{side:"bottom",align:"end",sideOffset:20,children:W.jsxs(xe,{marginTop:"2",children:[W.jsx(HA,{onClick:t,children:W.jsx(xe,{padding:"1",children:W.jsx(Ge,{variant:"normal",fontWeight:"bold",children:"Token List"})})}),W.jsx(HA,{disabled:!0,children:W.jsx(xe,{width:"16",children:W.jsx(Sh,{color:"white"})})}),W.jsx(HA,{onClick:()=>{e.logout(),r("/")},children:W.jsx(xe,{padding:"1",children:W.jsx(Ge,{variant:"normal",fontWeight:"bold",children:"Log out"})})})]})})]})}function CFe(){const t=Ir(Tx),e=yn(t.userAddedTokens);return W.jsxs(xe,{flexDirection:"column",paddingY:"4",paddingX:"8",background:"backgroundPrimary",width:"full",height:"full",alignItems:"center",children:[W.jsxs(xe,{flexDirection:"column",alignItems:"center",gap:"4",marginBottom:"4",children:[W.jsx(Ge,{variant:"large",color:"text80",children:"Token List"}),W.jsx(Ge,{variant:"normal",color:"text50",children:"Tokens added by you can be removed here"})]}),W.jsxs(xe,{width:"full",height:"full",flexDirection:"column",marginTop:"4",paddingBottom:"12",gap:"4",children:[e.length===0&&W.jsx(xe,{height:"full",alignItems:"center",justifyContent:"center",children:W.jsx(Ge,{variant:"medium",color:"text50",marginBottom:"16",children:"You haven't added any tokens yet"})}),e.map((r,n)=>W.jsxs($r,{width:"full",flexDirection:"row",gap:"2",alignItems:"center",children:[W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Ge,{variant:"medium",color:"text80",children:r.symbol}),W.jsx(Ge,{variant:"normal",color:"text50",children:r.address}),W.jsx(BE,{chainId:r.chainId})]}),W.jsx(xe,{marginLeft:"auto",children:W.jsx(Zt,{label:"Remove",variant:"danger",size:"md",shape:"square",onClick:()=>{t.removeToken(r)}})})]},n))]})]})}function AFe({onClose:t}){const r=Ir(Nn).networks.get(),n=r.filter(S=>S.type===Ft.MAINNET),i=Ir(Tx),s=yn(i.isFetchingTokenInfo),o=h8(),[a,c]=D.useState(),[l,f]=D.useState(),[u,p]=D.useState(),[g,y]=D.useState(!1);D.useEffect(()=>{a&&l?i.getTokenInfo(a.chainId,l).then(S=>{p(S)}):p(void 0)},[a,l]);const b=n.map(S=>({label:S.title,value:S.chainId.toString()})),I=async()=>{a&&l&&u&&(y(!0),await i.addToken({chainId:a.chainId,address:l,contractType:hh.ERC20,symbol:u.symbol,decimals:u.decimals}),y(!1),o({variant:"success",title:"Token added"}),C(),t())},C=()=>{f(void 0),c(void 0)};return W.jsxs($r,{flexDirection:"column",paddingY:"4",paddingX:"8",borderRadius:"md",width:"full",height:"full",alignItems:"center",disabled:g,children:[W.jsx(xe,{children:W.jsx(Ge,{variant:"medium",color:"text80",children:"Import ERC20 Token"})}),W.jsxs(xe,{flexDirection:"column",width:"full",marginTop:"4",gap:"4",children:[W.jsx(M7,{label:"Token Network",labelLocation:"left",name:"tokenNetwork",options:b,onValueChange:S=>c(r.find(O=>O.chainId===Number(S)))}),W.jsx(Wn,{width:"full",label:"Token Address",labelLocation:"left",name:"tokenAddress",value:l??"",onChange:S=>{f(S.target.value)}}),s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})}),u&&W.jsxs(W.Fragment,{children:[W.jsx(Wn,{width:"full",label:"Token Symbol",labelLocation:"left",name:"tokenSymbol",value:(u==null?void 0:u.symbol)??"",disabled:!0}),W.jsx(Wn,{width:"full",label:"Token Decimals",labelLocation:"left",name:"tokenDecimals",value:(u==null?void 0:u.decimals)??"",disabled:!0})]}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",disabled:g,onClick:()=>{C(),t()}}),W.jsx(Zt,{label:"Add",disabled:u===void 0||g,variant:"primary",size:"md",shape:"square",onClick:I})]})]})]})}const SFe=(t,e)=>Math.floor(t*10**e)/10**e;function _Fe({disabled:t,tokenBalance:e,onSendClick:r,onRemoveClick:n}){var o,a;const i=fh(e.balance,((o=e.contractInfo)==null?void 0:o.decimals)??18),s=SFe(Number(i),5);return W.jsxs($r,{width:"full",flexDirection:"column",gap:"2",children:[W.jsxs(xe,{flexDirection:"row",alignItems:"center",children:[W.jsx(Ge,{variant:"medium",color:"text80",children:((a=e.contractInfo)==null?void 0:a.symbol)??"Native Token"}),W.jsx(xe,{marginLeft:"auto",children:W.jsx(Ge,{color:"text80",children:s})})]}),W.jsxs(xe,{flexDirection:"row",children:[W.jsx(BE,{chainId:e.chainId}),W.jsxs(xe,{marginLeft:"auto",gap:"2",children:[W.jsx(Zt,{size:"xs",label:"Send",variant:"primary",shape:"square",disabled:t,onClick:r}),n&&W.jsx(Zt,{size:"xs",label:"Remove",shape:"square",onClick:n})]})]})]})}function IFe({filterZeroBalances:t,onSendClick:e}){const r=Ir(Zr),n=Ir(Tx),i=yn(n.balances),s=yn(n.isFetchingBalances),o=yn(r.selectedExternalProvider)!==void 0,a=D.useMemo(()=>t?i.filter(u=>u.balance!=="0"):i,[i,t,s]),[c,l]=D.useState(!1),f=u=>u.contractType===hh.NATIVE?void 0:()=>{var p,g;n.removeToken({chainId:u.chainId,address:u.contractAddress,contractType:u.contractType,decimals:(p=u.contractInfo)==null?void 0:p.decimals,symbol:(g=u.contractInfo)==null?void 0:g.symbol})};return W.jsxs(W.Fragment,{children:[W.jsxs(xe,{width:"full",flexDirection:"column",gap:"4",marginBottom:"8",children:[a.map(u=>W.jsx(_Fe,{tokenBalance:u,disabled:!o,onSendClick:()=>e(u),onRemoveClick:f(u)},u.contractAddress+u.chainId)),s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})})]}),c&&W.jsx(AFe,{onClose:()=>l(!1)}),!c&&W.jsx(xe,{width:"full",alignItems:"center",justifyContent:"center",marginBottom:"4",children:W.jsx(Zt,{label:"Import token",leftIcon:UH,variant:"primary",size:"md",shape:"square",onClick:()=>{l(!0)}})})]})}function TFe({onClose:t}){var a;const e=Ir(Zr),r=yn(e.connectOptions),[n,i]=D.useState(!1),s=async()=>{if(n)return;i(!0);const c=await e.walletRequestHandler.connect(r);e.connectDetails.set(c),i(!1),t()},o=()=>{e.connectDetails.set({connected:!1}),t()};return W.jsx(xe,{children:r&&W.jsxs(xe,{flexDirection:"column",padding:"10",alignItems:"center",gap:"4",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:"Would you like to allow this dapp to connect to your wallet?"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[W.jsx(Ge,{variant:"md",color:"text100",children:r.app}),W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"3",children:[W.jsx(Ge,{variant:"md",color:"text100",children:(a=r.origin)==null?void 0:a.split("//")[1]}),W.jsx(yu,{size:"xs",icon:J4,onClick:()=>window.open(r.origin,"_blank")})]})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Network"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${ky(Number(r.networkId))}`})]}),W.jsxs(xe,{flexDirection:{sm:"column",md:"row"},gap:"2",width:"full",marginTop:"6",children:[W.jsx(Zt,{width:"full",label:"Cancel",onClick:o,"data-id":"signingCancel"}),W.jsx(Zt,{width:"full",variant:"primary",label:n?"Authorizing…":"Connect",disabled:n,onClick:s,"data-id":"signingContinue"})]})]})})}function PFe({sessionList:t}){const e=Ir(NE);return W.jsxs(xe,{flexDirection:"column",gap:"2",children:[t.length!==0&&W.jsx(Ge,{variant:"large",color:"text80",marginTop:"6",marginBottom:"2",children:"Connected Dapps via WalletConnect"}),t.map((r,n)=>W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"2",padding:"2",children:[W.jsx(a8,{width:"8",height:"8",src:r.peer.metadata.icons[0]}),W.jsx(Ge,{variant:"normal",fontWeight:"bold",color:"text100",children:r.peer.metadata.name}),W.jsxs(xe,{gap:"2",children:[r.peer.metadata.url&&W.jsx(yu,{size:"xs",icon:J4,onClick:()=>window.open(r.peer.metadata.url,"_blank")}),W.jsx(yu,{size:"xs",icon:Vg,onClick:()=>{e.disconnectSession(r.topic)}})]})]},n))]})}function kFe({onClose:t}){var l,f;const e=Ir(Zr),r=Ir(li),n=e.toSignMsgDetails.get(),i=r.accountAddress.get(),[s,o]=D.useState(""),[a,c]=D.useState("");return D.useEffect(()=>{if(console.log("details",n),c(new Date().toLocaleString()),n!=null&&n.message.message){const u=XLe(n.message.message);try{o(Ip(u))}catch{o(Me(u))}}else n!=null&&n.message.typedData&&o(JSON.stringify(n.message.typedData,void 0,4))},[n]),W.jsx(xe,{children:n&&W.jsxs(xe,{flexDirection:"column",padding:"10",alignItems:"center",gap:"4",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",children:"Would you like to sign this message?"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Requested at"}),W.jsx(Ge,{variant:"md",color:"text100",children:a})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Origin"}),W.jsxs(xe,{alignItems:"center",gap:"3",children:[W.jsx(Ge,{variant:"md",color:"text100",children:(f=(l=n==null?void 0:n.options)==null?void 0:l.origin)==null?void 0:f.split("//")[1]}),W.jsx(yu,{size:"xs",icon:J4,onClick:()=>{var u;return window.open((u=n.options)==null?void 0:u.origin,"_blank")}})]})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Network"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${ky(n.chainId)}`})]}),W.jsxs($r,{flexDirection:"column",gap:"4",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Signee"}),W.jsx($r,{children:W.jsx(Ge,{variant:"md",color:"text100",children:`${i}`})})]}),W.jsx(GH,{label:"Message Content",children:W.jsx($r,{children:W.jsx(Ge,{variant:"code",color:"text80",style:{overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:s})})}),W.jsxs(xe,{flexDirection:{sm:"column",md:"row"},gap:"2",width:"full",marginTop:"10",children:[W.jsx(Zt,{width:"full",label:"Cancel",onClick:()=>{t()},"data-id":"signingCancel"}),W.jsx(Zt,{width:"full",variant:"primary",label:"Send",onClick:()=>{t(n)},"data-id":"signingContinue"})]})]})})}function MFe({onClose:t}){var I,C;const e=Ir(Zr),r=Ir(Nn),n=Ir(YM),[i,s]=D.useState("Unknown"),[o,a]=D.useState(null),[c,l]=D.useState({name:null}),[f,u]=D.useState(null),[p,g]=D.useState(""),y=e.toSignTxnDetails.get();D.useEffect(()=>{if(!y)return;g(new Date().toLocaleString());const S=r.providerForChainId(y.chainId??0),O=y.txn[0].data,L=y.txn[0].to;b(O,L,S)},[y]),D.useEffect(()=>{if(!y||!(y!=null&&y.txn[0].to)||!o)return;const S=y.txn[0].to,O={chainId:y.chainId,address:S,tokenId:o,contractType:i};n.getCollectibleInfo(O)},[i,o]);async function b(S,O,L){try{const F=new Dn(O,jv,L);try{const ie=await F.symbol();s("ERC20"),l({name:ie});const K=new $i(jv).parseTransaction({data:S}),P=await F.decimals();u(Number(fh(K==null?void 0:K.args[1],P??18)));return}catch{}const z=new Dn(O,C9e,L);if(await z.supportsInterface("0x80ac58cd")){s("ERC721");const ie=new Dn(O,hM,L),K=ie.interface.decodeFunctionData("safeTransferFrom",S).tokenId.toString();a(K);const P=await ie.name();l({name:P});return}if(await z.supportsInterface("0xd9b67a26")){s("ERC1155");const ie=new Dn(O,pM,L),K=ie.interface.decodeFunctionData("safeTransferFrom",S).id.toString();a(K);const P=await ie.uri(K);l({name:P});return}}catch(F){console.error("Error parsing contract type. The transaction is either using a smart contract that doesnt support ERC165 or the token is native:",F)}if(y!=null&&y.txn[0].value){s("Native Token"),l({name:`${ky((y==null?void 0:y.chainId)??1)} Native Token`});return}console.info("Token info could not be decoded for this transaction")}return W.jsx(xe,{children:y&&W.jsx(xe,{children:W.jsxs(xe,{flexDirection:"column",padding:"10",gap:"4",children:[W.jsx(Ge,{alignSelf:"center",variant:"md",fontWeight:"bold",color:"text100",children:"Would you like to approve this transaction?"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Requested at"}),W.jsx(Ge,{variant:"md",color:"text100",children:p})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Origin"}),W.jsxs(xe,{alignItems:"center",gap:"3",children:[W.jsx(Ge,{variant:"md",color:"text100",children:(C=(I=y==null?void 0:y.options)==null?void 0:I.origin)==null?void 0:C.split("//")[1]}),W.jsx(yu,{size:"xs",icon:J4,onClick:()=>{var S;return window.open((S=y.options)==null?void 0:S.origin,"_blank")}})]})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Token Standard"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${i}`})]}),i==="ERC721"||i==="ERC1155"&&W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Token ID"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${o}`})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Amount"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${f??0} ${c.name}`})]}),W.jsx(GH,{label:"Transaction Data",children:W.jsx(xe,{flexDirection:"column",gap:"2",children:y.txn.map((S,O)=>W.jsx($r,{children:W.jsx(Ge,{variant:"code",color:"text80",style:{whiteSpace:"pre-wrap"},children:JSON.stringify(S,null,4)||"Native token transfer"})},O))})}),W.jsxs(xe,{flexDirection:{sm:"column",md:"row"},gap:"2",width:"full",marginTop:"10",children:[W.jsx(Zt,{width:"full",label:"Cancel",onClick:()=>{t()},"data-id":"signingCancel"}),W.jsx(Zt,{width:"full",variant:"primary",label:"Send",onClick:()=>{t(y)},"data-id":"signingContinue"})]})]})})})}function RFe({warningType:t}){return W.jsx(xe,{children:W.jsxs(xe,{flexDirection:"column",padding:"10",alignItems:"center",gap:"6",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",children:"Warning:"}),W.jsx(xe,{flexDirection:"column",children:W.jsx($r,{children:W.jsxs(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"2",children:[t==="noProvider"&&'Please ensure that an external wallet is connected via the "Connect" button',t==="isWalletConnect"&&"Please switch your external wallet to an option other than WalletConnect",t==="notDeployed"&&"Please deploy our wallet on the required network before trying to sign messages"]})})})]})})}var Ute={},Fo={};Object.defineProperty(Fo,"__esModule",{value:!0});Fo.compactObject=Vte;Fo.deprecated=$Fe;var OFe=Fo.detectBrowser=qFe;Fo.disableLog=FFe;Fo.disableWarnings=jFe;Fo.extractVersion=j3;Fo.filterStats=VFe;Fo.log=UFe;Fo.walkStats=v4;Fo.wrapPeerConnectionEvent=LFe;function DFe(t,e,r){return e=NFe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function NFe(t){var e=BFe(t,"string");return gh(e)=="symbol"?e:e+""}function BFe(t,e){if(gh(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(gh(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gh(t){"@babel/helpers - typeof";return gh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gh(t)}var $te=!0,qte=!0;function j3(t,e,r){var n=t.match(e);return n&&n.length>=r&&parseInt(n[r],10)}function LFe(t,e,r){if(t.RTCPeerConnection){var n=t.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(o,a){if(o!==e)return i.apply(this,arguments);var c=function(f){var u=r(f);u&&(a.handleEvent?a.handleEvent(u):a(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(a,c),i.apply(this,[o,c])};var s=n.removeEventListener;n.removeEventListener=function(o,a){if(o!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(a))return s.apply(this,arguments);var c=this._eventMap[e].get(a);return this._eventMap[e].delete(a),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[o,c])},Object.defineProperty(n,"on"+e,{get:function(){return this["_on"+e]},set:function(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}}function FFe(t){return typeof t!="boolean"?new Error("Argument type: "+gh(t)+". Please use a boolean."):($te=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function jFe(t){return typeof t!="boolean"?new Error("Argument type: "+gh(t)+". Please use a boolean."):(qte=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function UFe(){if((typeof window>"u"?"undefined":gh(window))==="object"){if($te)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function $Fe(t,e){qte&&console.warn(t+" is deprecated, please use "+e+" instead.")}function qFe(t){var e={browser:null,version:null};if(typeof t>"u"||!t.navigator||!t.navigator.userAgent)return e.browser="Not a browser.",e;var r=t.navigator;if(r.userAgentData&&r.userAgentData.brands){var n=r.userAgentData.brands.find(function(i){return i.brand==="Chromium"});if(n)return{browser:"chrome",version:parseInt(n.version,10)}}if(r.mozGetUserMedia)e.browser="firefox",e.version=j3(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||t.isSecureContext===!1&&t.webkitRTCPeerConnection)e.browser="chrome",e.version=j3(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.RTCPeerConnection&&r.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=j3(r.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=t.RTCRtpTransceiver&&"currentDirection"in t.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function O$(t){return Object.prototype.toString.call(t)==="[object Object]"}function Vte(t){return O$(t)?Object.keys(t).reduce(function(e,r){var n=O$(t[r]),i=n?Vte(t[r]):t[r],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,DFe({},r,i))},{}):t}function v4(t,e,r){!e||r.has(e.id)||(r.set(e.id,e),Object.keys(e).forEach(function(n){n.endsWith("Id")?v4(t,t.get(e[n]),r):n.endsWith("Ids")&&e[n].forEach(function(i){v4(t,t.get(i),r)})}))}function VFe(t,e,r){var n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;var s=[];return t.forEach(function(o){o.type==="track"&&o.trackIdentifier===e.id&&s.push(o)}),s.forEach(function(o){t.forEach(function(a){a.type===n&&a.trackId===o.id&&v4(t,a,i)})}),i}Object.defineProperty(Ute,"__esModule",{value:!0});var zFe=Ute.shimGetUserMedia=WFe,HFe=GFe(Fo);function zte(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(zte=function(i){return i?r:e})(t)}function GFe(t,e){if(t&&t.__esModule)return t;if(t===null||gd(t)!="object"&&typeof t!="function")return{default:t};var r=zte(e);if(r&&r.has(t))return r.get(t);var n={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&{}.hasOwnProperty.call(t,s)){var o=i?Object.getOwnPropertyDescriptor(t,s):null;o&&(o.get||o.set)?Object.defineProperty(n,s,o):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}function gd(t){"@babel/helpers - typeof";return gd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gd(t)}var D$=HFe.log;function WFe(t,e){var r=t&&t.navigator;if(r.mediaDevices){var n=function(l){if(gd(l)!=="object"||l.mandatory||l.optional)return l;var f={};return Object.keys(l).forEach(function(u){if(!(u==="require"||u==="advanced"||u==="mediaSource")){var p=gd(l[u])==="object"?l[u]:{ideal:l[u]};p.exact!==void 0&&typeof p.exact=="number"&&(p.min=p.max=p.exact);var g=function(I,C){return I?I+C.charAt(0).toUpperCase()+C.slice(1):C==="deviceId"?"sourceId":C};if(p.ideal!==void 0){f.optional=f.optional||[];var y={};typeof p.ideal=="number"?(y[g("min",u)]=p.ideal,f.optional.push(y),y={},y[g("max",u)]=p.ideal,f.optional.push(y)):(y[g("",u)]=p.ideal,f.optional.push(y))}p.exact!==void 0&&typeof p.exact!="number"?(f.mandatory=f.mandatory||{},f.mandatory[g("",u)]=p.exact):["min","max"].forEach(function(b){p[b]!==void 0&&(f.mandatory=f.mandatory||{},f.mandatory[g(b,u)]=p[b])})}}),l.advanced&&(f.optional=(f.optional||[]).concat(l.advanced)),f},i=function(l,f){if(e.version>=61)return f(l);if(l=JSON.parse(JSON.stringify(l)),l&&gd(l.audio)==="object"){var u=function(I,C,S){C in I&&!(S in I)&&(I[S]=I[C],delete I[C])};l=JSON.parse(JSON.stringify(l)),u(l.audio,"autoGainControl","googAutoGainControl"),u(l.audio,"noiseSuppression","googNoiseSuppression"),l.audio=n(l.audio)}if(l&&gd(l.video)==="object"){var p=l.video.facingMode;p=p&&(gd(p)==="object"?p:{ideal:p});var g=e.version<66;if(p&&(p.exact==="user"||p.exact==="environment"||p.ideal==="user"||p.ideal==="environment")&&!(r.mediaDevices.getSupportedConstraints&&r.mediaDevices.getSupportedConstraints().facingMode&&!g)){delete l.video.facingMode;var y;if(p.exact==="environment"||p.ideal==="environment"?y=["back","rear"]:(p.exact==="user"||p.ideal==="user")&&(y=["front"]),y)return r.mediaDevices.enumerateDevices().then(function(b){b=b.filter(function(C){return C.kind==="videoinput"});var I=b.find(function(C){return y.some(function(S){return C.label.toLowerCase().includes(S)})});return!I&&b.length&&y.includes("back")&&(I=b[b.length-1]),I&&(l.video.deviceId=p.exact?{exact:I.deviceId}:{ideal:I.deviceId}),l.video=n(l.video),D$("chrome: "+JSON.stringify(l)),f(l)})}l.video=n(l.video)}return D$("chrome: "+JSON.stringify(l)),f(l)},s=function(l){return e.version>=64?l:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[l.name]||l.name,message:l.message,constraint:l.constraint||l.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},o=function(l,f,u){i(l,function(p){r.webkitGetUserMedia(p,f,function(g){u&&u(s(g))})})};if(r.getUserMedia=o.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(c){return i(c,function(l){return a(l).then(function(f){if(l.audio&&!f.getAudioTracks().length||l.video&&!f.getVideoTracks().length)throw f.getTracks().forEach(function(u){u.stop()}),new DOMException("","NotFoundError");return f},function(f){return Promise.reject(s(f))})})}}}}var Hte={};Object.defineProperty(Hte,"__esModule",{value:!0});var KFe=Hte.shimGetUserMedia=JFe,YFe=QFe(Fo);function Gte(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Gte=function(i){return i?r:e})(t)}function QFe(t,e){if(t&&t.__esModule)return t;if(t===null||Hv(t)!="object"&&typeof t!="function")return{default:t};var r=Gte(e);if(r&&r.has(t))return r.get(t);var n={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&{}.hasOwnProperty.call(t,s)){var o=i?Object.getOwnPropertyDescriptor(t,s):null;o&&(o.get||o.set)?Object.defineProperty(n,s,o):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}function Hv(t){"@babel/helpers - typeof";return Hv=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hv(t)}function JFe(t,e){var r=t&&t.navigator,n=t&&t.MediaStreamTrack;if(r.getUserMedia=function(c,l,f){YFe.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(c).then(l,f)},!(e.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(l,f,u){f in l&&!(u in l)&&(l[u]=l[f],delete l[f])},s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(c){return Hv(c)==="object"&&Hv(c.audio)==="object"&&(c=JSON.parse(JSON.stringify(c)),i(c.audio,"autoGainControl","mozAutoGainControl"),i(c.audio,"noiseSuppression","mozNoiseSuppression")),s(c)},n&&n.prototype.getSettings){var o=n.prototype.getSettings;n.prototype.getSettings=function(){var c=o.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(n&&n.prototype.applyConstraints){var a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(c){return this.kind==="audio"&&Hv(c)==="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[c])}}}}var af={};Object.defineProperty(af,"__esModule",{value:!0});af.shimAudioContext=aje;af.shimCallbacksAPI=rje;af.shimConstraints=Yte;af.shimCreateOfferLegacy=oje;var ZFe=af.shimGetUserMedia=nje;af.shimLocalStreamsAPI=eje;af.shimRTCIceServerUrls=ije;af.shimRemoteStreamsAPI=tje;af.shimTrackEventTransceiver=sje;var Wte=XFe(Fo);function Kte(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Kte=function(i){return i?r:e})(t)}function XFe(t,e){if(t&&t.__esModule)return t;if(t===null||yh(t)!="object"&&typeof t!="function")return{default:t};var r=Kte(e);if(r&&r.has(t))return r.get(t);var n={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&{}.hasOwnProperty.call(t,s)){var o=i?Object.getOwnPropertyDescriptor(t,s):null;o&&(o.get||o.set)?Object.defineProperty(n,s,o):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}function yh(t){"@babel/helpers - typeof";return yh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yh(t)}function eje(t){if(!(yh(t)!=="object"||!t.RTCPeerConnection)){if("getLocalStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in t.RTCPeerConnection.prototype)){var e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addStream=function(n){var i=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(function(s){return e.call(i,s,n)}),n.getVideoTracks().forEach(function(s){return e.call(i,s,n)})},t.RTCPeerConnection.prototype.addTrack=function(n){for(var i=this,s=arguments.length,o=new Array(s>1?s-1:0),a=1;a=0)){n._remoteStreams.push(s);var o=new Event("addstream");o.stream=s,n.dispatchEvent(o)}})}),e.apply(n,arguments)}}}function rje(t){if(!(yh(t)!=="object"||!t.RTCPeerConnection)){var e=t.RTCPeerConnection.prototype,r=e.createOffer,n=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,o=e.addIceCandidate;e.createOffer=function(l,f){var u=arguments.length>=2?arguments[2]:arguments[0],p=r.apply(this,[u]);return f?(p.then(l,f),Promise.resolve()):p},e.createAnswer=function(l,f){var u=arguments.length>=2?arguments[2]:arguments[0],p=n.apply(this,[u]);return f?(p.then(l,f),Promise.resolve()):p};var a=function(l,f,u){var p=i.apply(this,[l]);return u?(p.then(f,u),Promise.resolve()):p};e.setLocalDescription=a,a=function(l,f,u){var p=s.apply(this,[l]);return u?(p.then(f,u),Promise.resolve()):p},e.setRemoteDescription=a,a=function(l,f,u){var p=o.apply(this,[l]);return u?(p.then(f,u),Promise.resolve()):p},e.addIceCandidate=a}}function nje(t){var e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){var r=e.mediaDevices,n=r.getUserMedia.bind(r);e.mediaDevices.getUserMedia=function(i){return n(Yte(i))}}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(s,o,a){e.mediaDevices.getUserMedia(s).then(o,a)}).bind(e))}function Yte(t){return t&&t.video!==void 0?Object.assign({},t,{video:Wte.compactObject(t.video)}):t}function ije(t){if(t.RTCPeerConnection){var e=t.RTCPeerConnection;t.RTCPeerConnection=function(n,i){if(n&&n.iceServers){for(var s=[],o=0;o{throw TypeError(t)},Jte=(t,e,r)=>e.has(t)||Qte("Cannot "+r),cje=(t,e,r)=>(Jte(t,e,"read from private field"),r?r.call(t):e.get(t)),lje=(t,e,r)=>e.has(t)?Qte("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),fje=(t,e,r,n)=>(Jte(t,e,"write to private field"),e.set(t,r),r);const N$=["Aztec","Codabar","Code128","Code39","Code93","DataBar","DataBarExpanded","DataMatrix","DXFilmEdge","EAN-13","EAN-8","ITF","Linear-Codes","Matrix-Codes","MaxiCode","MicroQRCode","None","PDF417","QRCode","rMQRCode","UPC-A","UPC-E"];function uje(t){return t.join("|")}function dje(t){const e=B$(t);let r=0,n=N$.length-1;for(;r<=n;){const i=Math.floor((r+n)/2),s=N$[i],o=B$(s);if(o===e)return s;o{const r=t.match(/_(.+?)\.wasm$/);return r?`https://fastly.jsdelivr.net/npm/zxing-wasm@1.2.15/dist/${r[1]}/${t}`:e+t}};let L$=new WeakMap;function QM(t,e){var r;const n=L$.get(t);if(n!=null&&n.modulePromise&&e===void 0)return n.modulePromise;const i=(r=n==null?void 0:n.moduleOverrides)!=null?r:bje,s=t({...i});return L$.set(t,{moduleOverrides:i,modulePromise:s}),s}async function wje(t,e,r=ly){const n={...ly,...r},i=await QM(t),{size:s}=e,o=new Uint8Array(await e.arrayBuffer()),a=i._malloc(s);i.HEAPU8.set(o,a);const c=i.readBarcodesFromImage(a,s,Zte(i,n));i._free(a);const l=[];for(let f=0;f{var t,e=typeof document<"u"&&((t=document.currentScript)==null?void 0:t.tagName.toUpperCase())==="SCRIPT"?document.currentScript.src:void 0;return function(r={}){var n,i=r,s,o,a=new Promise((q,V)=>{s=q,o=V}),c=typeof window=="object",l=typeof Bun<"u",f=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var u=Object.assign({},i),p="./this.program",g="";function y(q){return i.locateFile?i.locateFile(q,g):g+q}var b,I;if(c||f||l){var C;f?g=self.location.href:typeof document<"u"&&((C=document.currentScript)===null||C===void 0?void 0:C.tagName.toUpperCase())==="SCRIPT"&&(g=document.currentScript.src),e&&(g=e),g.startsWith("blob:")?g="":g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1),f&&(I=q=>{var V=new XMLHttpRequest;return V.open("GET",q,!1),V.responseType="arraybuffer",V.send(null),new Uint8Array(V.response)}),b=q=>fetch(q,{credentials:"same-origin"}).then(V=>V.ok?V.arrayBuffer():Promise.reject(new Error(V.status+" : "+V.url)))}var S=i.print||console.log.bind(console),O=i.printErr||console.error.bind(console);Object.assign(i,u),u=null,i.arguments&&i.arguments,i.thisProgram&&(p=i.thisProgram);var L=i.wasmBinary,F,z=!1,_,$,ie,ce,K,P,M,v;function m(){var q=F.buffer;i.HEAP8=_=new Int8Array(q),i.HEAP16=ie=new Int16Array(q),i.HEAPU8=$=new Uint8Array(q),i.HEAPU16=ce=new Uint16Array(q),i.HEAP32=K=new Int32Array(q),i.HEAPU32=P=new Uint32Array(q),i.HEAPF32=M=new Float32Array(q),i.HEAPF64=v=new Float64Array(q)}var R=[],B=[],E=[];function x(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)k(i.preRun.shift());Je(R)}function w(){Je(B)}function T(){if(i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)oe(i.postRun.shift());Je(E)}function k(q){R.unshift(q)}function H(q){B.unshift(q)}function oe(q){E.unshift(q)}var j=0,X=null;function G(q){var V;j++,(V=i.monitorRunDependencies)===null||V===void 0||V.call(i,j)}function Z(q){var V;if(j--,(V=i.monitorRunDependencies)===null||V===void 0||V.call(i,j),j==0&&X){var re=X;X=null,re()}}function ee(q){var V;(V=i.onAbort)===null||V===void 0||V.call(i,q),q="Aborted("+q+")",O(q),z=!0,q+=". Build with -sASSERTIONS for more info.";var re=new WebAssembly.RuntimeError(q);throw o(re),re}var N="data:application/octet-stream;base64,",te=q=>q.startsWith(N);function fe(){var q="zxing_reader.wasm";return te(q)?q:y(q)}var Ee;function _e(q){if(q==Ee&&L)return new Uint8Array(L);if(I)return I(q);throw"both async and sync fetching of the wasm failed"}function Re(q){return L?Promise.resolve().then(()=>_e(q)):b(q).then(V=>new Uint8Array(V),()=>_e(q))}function Te(q,V,re){return Re(q).then(ae=>WebAssembly.instantiate(ae,V)).then(re,ae=>{O(`failed to asynchronously prepare wasm: ${ae}`),ee(ae)})}function De(q,V,re,ae){return!q&&typeof WebAssembly.instantiateStreaming=="function"&&!te(V)&&typeof fetch=="function"?fetch(V,{credentials:"same-origin"}).then(pe=>{var me=WebAssembly.instantiateStreaming(pe,re);return me.then(ae,function(Se){return O(`wasm streaming compile failed: ${Se}`),O("falling back to ArrayBuffer instantiation"),Te(V,re,ae)})}):Te(V,re,ae)}function ze(){return{a:Zy}}function et(){var q,V=ze();function re(pe,me){return hn=pe.exports,F=hn.za,m(),ds=hn.Da,H(hn.Aa),Z(),hn}G();function ae(pe){re(pe.instance)}if(i.instantiateWasm)try{return i.instantiateWasm(V,re)}catch(pe){O(`Module.instantiateWasm callback failed with error: ${pe}`),o(pe)}return(q=Ee)!==null&&q!==void 0||(Ee=fe()),De(L,Ee,V,ae).catch(o),{}}var Je=q=>{for(;q.length>0;)q.shift()(i)};i.noExitRuntime;var ke=q=>ho(q),Ne=()=>em(),tt=[],Ze=0,st=q=>{var V=new lt(q);return V.get_caught()||(V.set_caught(!0),Ze--),V.set_rethrown(!1),tt.push(V),Xx(q),Jx(q)},nt=0,We=()=>{yr(0,0);var q=tt.pop();Zx(q.excPtr),nt=0};class lt{constructor(V){this.excPtr=V,this.ptr=V-24}set_type(V){P[this.ptr+4>>2]=V}get_type(){return P[this.ptr+4>>2]}set_destructor(V){P[this.ptr+8>>2]=V}get_destructor(){return P[this.ptr+8>>2]}set_caught(V){V=V?1:0,_[this.ptr+12]=V}get_caught(){return _[this.ptr+12]!=0}set_rethrown(V){V=V?1:0,_[this.ptr+13]=V}get_rethrown(){return _[this.ptr+13]!=0}init(V,re){this.set_adjusted_ptr(0),this.set_type(V),this.set_destructor(re)}set_adjusted_ptr(V){P[this.ptr+16>>2]=V}get_adjusted_ptr(){return P[this.ptr+16>>2]}}var vt=q=>{throw nt||(nt=q),nt},Ke=q=>df(q),gt=q=>{var V=nt;if(!V)return Ke(0),0;var re=new lt(V);re.set_adjusted_ptr(V);var ae=re.get_type();if(!ae)return Ke(0),V;for(var pe of q){if(pe===0||pe===ae)break;var me=re.ptr+16;if(e2(pe,ae,me))return Ke(pe),V}return Ke(ae),V},wt=()=>gt([]),rt=q=>gt([q]),It=(q,V)=>gt([q,V]),At=()=>{var q=tt.pop();q||ee("no exception to throw");var V=q.excPtr;throw q.get_rethrown()||(tt.push(q),q.set_rethrown(!0),q.set_caught(!1),Ze++),nt=V,nt},Tt=(q,V,re)=>{var ae=new lt(q);throw ae.init(V,re),nt=q,Ze++,nt},Xt=()=>Ze,lr=()=>{ee("")},xt={},ar=q=>{for(;q.length;){var V=q.pop(),re=q.pop();re(V)}};function rr(q){return this.fromWireType(P[q>>2])}var kt={},Dt={},Nt={},dt,Lt=q=>{throw new dt(q)},Mt=(q,V,re)=>{q.forEach(Ae=>Nt[Ae]=V);function ae(Ae){var Be=re(Ae);Be.length!==q.length&&Lt("Mismatched type converter count");for(var Ye=0;Ye{Dt.hasOwnProperty(Ae)?pe[Be]=Dt[Ae]:(me.push(Ae),kt.hasOwnProperty(Ae)||(kt[Ae]=[]),kt[Ae].push(()=>{pe[Be]=Dt[Ae],++Se,Se===me.length&&ae(pe)}))}),me.length===0&&ae(pe)},ut=q=>{var V=xt[q];delete xt[q];var re=V.rawConstructor,ae=V.rawDestructor,pe=V.fields,me=pe.map(Se=>Se.getterReturnType).concat(pe.map(Se=>Se.setterArgumentType));Mt([q],me,Se=>{var Ae={};return pe.forEach((Be,Ye)=>{var Qe=Be.fieldName,pt=Se[Ye],mr=Be.getter,Br=Be.getterContext,un=Se[Ye+pe.length],Zn=Be.setter,In=Be.setterContext;Ae[Qe]={read:pn=>pt.fromWireType(mr(Br,pn)),write:(pn,yc)=>{var $n=[];Zn(In,pn,un.toWireType($n,yc)),ar($n)}}}),[{name:V.name,fromWireType:Be=>{var Ye={};for(var Qe in Ae)Ye[Qe]=Ae[Qe].read(Be);return ae(Be),Ye},toWireType:(Be,Ye)=>{for(var Qe in Ae)if(!(Qe in Ye))throw new TypeError(`Missing field: "${Qe}"`);var pt=re();for(Qe in Ae)Ae[Qe].write(pt,Ye[Qe]);return Be!==null&&Be.push(ae,pt),pt},argPackAdvance:ct,readValueFromPointer:rr,destructorFunction:ae}]})},Vt=(q,V,re,ae,pe)=>{},zt=()=>{for(var q=new Array(256),V=0;V<256;++V)q[V]=String.fromCharCode(V);ht=q},ht,Et=q=>{for(var V="",re=q;$[re];)V+=ht[$[re++]];return V},Bt,He=q=>{throw new Bt(q)};function $t(q,V){let re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var ae=V.name;if(q||He(`type "${ae}" must have a positive integer typeid pointer`),Dt.hasOwnProperty(q)){if(re.ignoreDuplicateRegistrations)return;He(`Cannot register type '${ae}' twice`)}if(Dt[q]=V,delete Nt[q],kt.hasOwnProperty(q)){var pe=kt[q];delete kt[q],pe.forEach(me=>me())}}function Ct(q,V){let re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return $t(q,V,re)}var ct=8,Ht=(q,V,re,ae)=>{V=Et(V),Ct(q,{name:V,fromWireType:function(pe){return!!pe},toWireType:function(pe,me){return me?re:ae},argPackAdvance:ct,readValueFromPointer:function(pe){return this.fromWireType($[pe])},destructorFunction:null})},Rr=q=>({count:q.count,deleteScheduled:q.deleteScheduled,preservePointerOnDelete:q.preservePointerOnDelete,ptr:q.ptr,ptrType:q.ptrType,smartPtr:q.smartPtr,smartPtrType:q.smartPtrType}),Ut=q=>{function V(re){return re.$$.ptrType.registeredClass.name}He(V(q)+" instance already deleted")},Sr=!1,er=q=>{},kr=q=>{q.smartPtr?q.smartPtrType.rawDestructor(q.smartPtr):q.ptrType.registeredClass.rawDestructor(q.ptr)},bi=q=>{q.count.value-=1;var V=q.count.value===0;V&&kr(q)},wi=(q,V,re)=>{if(V===re)return q;if(re.baseClass===void 0)return null;var ae=wi(q,V,re.baseClass);return ae===null?null:re.downcast(ae)},xi={},Ti=()=>Object.keys(pi).length,Sn=()=>{var q=[];for(var V in pi)pi.hasOwnProperty(V)&&q.push(pi[V]);return q},di=[],Fs=()=>{for(;di.length;){var q=di.pop();q.$$.deleteScheduled=!1,q.delete()}},hi,jo=q=>{hi=q,di.length&&hi&&hi(Fs)},Uo=()=>{i.getInheritedInstanceCount=Ti,i.getLiveInheritedInstances=Sn,i.flushPendingDeletes=Fs,i.setDelayFunction=jo},pi={},oo=(q,V)=>{for(V===void 0&&He("ptr should not be undefined");q.baseClass;)V=q.upcast(V),q=q.baseClass;return V},ao=(q,V)=>(V=oo(q,V),pi[V]),_n=(q,V)=>{(!V.ptrType||!V.ptr)&&Lt("makeClassHandle requires ptr and ptrType");var re=!!V.smartPtrType,ae=!!V.smartPtr;return re!==ae&&Lt("Both smartPtrType and smartPtr must be specified"),V.count={value:1},Gi(Object.create(q,{$$:{value:V,writable:!0}}))};function $o(q){var V=this.getPointee(q);if(!V)return this.destructor(q),null;var re=ao(this.registeredClass,V);if(re!==void 0){if(re.$$.count.value===0)return re.$$.ptr=V,re.$$.smartPtr=q,re.clone();var ae=re.clone();return this.destructor(q),ae}function pe(){return this.isSmartPointer?_n(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:V,smartPtrType:this,smartPtr:q}):_n(this.registeredClass.instancePrototype,{ptrType:this,ptr:q})}var me=this.registeredClass.getActualType(V),Se=xi[me];if(!Se)return pe.call(this);var Ae;this.isConst?Ae=Se.constPointerType:Ae=Se.pointerType;var Be=wi(V,this.registeredClass,Ae.registeredClass);return Be===null?pe.call(this):this.isSmartPointer?_n(Ae.registeredClass.instancePrototype,{ptrType:Ae,ptr:Be,smartPtrType:this,smartPtr:q}):_n(Ae.registeredClass.instancePrototype,{ptrType:Ae,ptr:Be})}var Gi=q=>typeof FinalizationRegistry>"u"?(Gi=V=>V,q):(Sr=new FinalizationRegistry(V=>{bi(V.$$)}),Gi=V=>{var re=V.$$,ae=!!re.smartPtr;if(ae){var pe={$$:re};Sr.register(V,pe,V)}return V},er=V=>Sr.unregister(V),Gi(q)),qo=()=>{Object.assign(Ca.prototype,{isAliasOf(q){if(!(this instanceof Ca)||!(q instanceof Ca))return!1;var V=this.$$.ptrType.registeredClass,re=this.$$.ptr;q.$$=q.$$;for(var ae=q.$$.ptrType.registeredClass,pe=q.$$.ptr;V.baseClass;)re=V.upcast(re),V=V.baseClass;for(;ae.baseClass;)pe=ae.upcast(pe),ae=ae.baseClass;return V===ae&&re===pe},clone(){if(this.$$.ptr||Ut(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var q=Gi(Object.create(Object.getPrototypeOf(this),{$$:{value:Rr(this.$$)}}));return q.$$.count.value+=1,q.$$.deleteScheduled=!1,q},delete(){this.$$.ptr||Ut(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&He("Object already scheduled for deletion"),er(this),bi(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Ut(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&He("Object already scheduled for deletion"),di.push(this),di.length===1&&hi&&hi(Fs),this.$$.deleteScheduled=!0,this}})};function Ca(){}var co=(q,V)=>Object.defineProperty(V,"name",{value:q}),Lh=(q,V,re)=>{if(q[V].overloadTable===void 0){var ae=q[V];q[V]=function(){for(var pe=arguments.length,me=new Array(pe),Se=0;Se{i.hasOwnProperty(q)?((re===void 0||i[q].overloadTable!==void 0&&i[q].overloadTable[re]!==void 0)&&He(`Cannot register public name '${q}' twice`),Lh(i,q,q),i.hasOwnProperty(re)&&He(`Cannot register multiple overloads of a function with the same number of arguments (${re})!`),i[q].overloadTable[re]=V):(i[q]=V,re!==void 0&&(i[q].numArguments=re))},Fh=48,cf=57,jh=q=>{if(q===void 0)return"_unknown";q=q.replace(/[^a-zA-Z0-9_]/g,"$");var V=q.charCodeAt(0);return V>=Fh&&V<=cf?`_${q}`:q};function lf(q,V,re,ae,pe,me,Se,Ae){this.name=q,this.constructor=V,this.instancePrototype=re,this.rawDestructor=ae,this.baseClass=pe,this.getActualType=me,this.upcast=Se,this.downcast=Ae,this.pureVirtualFunctions=[]}var Du=(q,V,re)=>{for(;V!==re;)V.upcast||He(`Expected null or instance of ${re.name}, got an instance of ${V.name}`),q=V.upcast(q),V=V.baseClass;return q};function qy(q,V){if(V===null)return this.isReference&&He(`null is not a valid ${this.name}`),0;V.$$||He(`Cannot pass "${zr(V)}" as a ${this.name}`),V.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`);var re=V.$$.ptrType.registeredClass,ae=Du(V.$$.ptr,re,this.registeredClass);return ae}function r1(q,V){var re;if(V===null)return this.isReference&&He(`null is not a valid ${this.name}`),this.isSmartPointer?(re=this.rawConstructor(),q!==null&&q.push(this.rawDestructor,re),re):0;(!V||!V.$$)&&He(`Cannot pass "${zr(V)}" as a ${this.name}`),V.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&V.$$.ptrType.isConst&&He(`Cannot convert argument of type ${V.$$.smartPtrType?V.$$.smartPtrType.name:V.$$.ptrType.name} to parameter type ${this.name}`);var ae=V.$$.ptrType.registeredClass;if(re=Du(V.$$.ptr,ae,this.registeredClass),this.isSmartPointer)switch(V.$$.smartPtr===void 0&&He("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:V.$$.smartPtrType===this?re=V.$$.smartPtr:He(`Cannot convert argument of type ${V.$$.smartPtrType?V.$$.smartPtrType.name:V.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:re=V.$$.smartPtr;break;case 2:if(V.$$.smartPtrType===this)re=V.$$.smartPtr;else{var pe=V.clone();re=this.rawShare(re,zo.toHandle(()=>pe.delete())),q!==null&&q.push(this.rawDestructor,re)}break;default:He("Unsupporting sharing policy")}return re}function n1(q,V){if(V===null)return this.isReference&&He(`null is not a valid ${this.name}`),0;V.$$||He(`Cannot pass "${zr(V)}" as a ${this.name}`),V.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`),V.$$.ptrType.isConst&&He(`Cannot convert argument of type ${V.$$.ptrType.name} to parameter type ${this.name}`);var re=V.$$.ptrType.registeredClass,ae=Du(V.$$.ptr,re,this.registeredClass);return ae}var Nu=()=>{Object.assign(Bu.prototype,{getPointee(q){return this.rawGetPointee&&(q=this.rawGetPointee(q)),q},destructor(q){var V;(V=this.rawDestructor)===null||V===void 0||V.call(this,q)},argPackAdvance:ct,readValueFromPointer:rr,fromWireType:$o})};function Bu(q,V,re,ae,pe,me,Se,Ae,Be,Ye,Qe){this.name=q,this.registeredClass=V,this.isReference=re,this.isConst=ae,this.isSmartPointer=pe,this.pointeeType=me,this.sharingPolicy=Se,this.rawGetPointee=Ae,this.rawConstructor=Be,this.rawShare=Ye,this.rawDestructor=Qe,!pe&&V.baseClass===void 0?ae?(this.toWireType=qy,this.destructorFunction=null):(this.toWireType=n1,this.destructorFunction=null):this.toWireType=r1}var Uh=(q,V,re)=>{i.hasOwnProperty(q)||Lt("Replacing nonexistent public symbol"),i[q].overloadTable!==void 0&&re!==void 0?i[q].overloadTable[re]=V:(i[q]=V,i[q].argCount=re)},Lu=(q,V,re)=>{q=q.replace(/p/g,"i");var ae=i["dynCall_"+q];return ae(V,...re)},Vo=[],ds,hr=q=>{var V=Vo[q];return V||(q>=Vo.length&&(Vo.length=q+1),Vo[q]=V=ds.get(q)),V},i1=function(q,V){let re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(q.includes("j"))return Lu(q,V,re);var ae=hr(V)(...re);return ae},Aa=(q,V)=>function(){for(var re=arguments.length,ae=new Array(re),pe=0;pe{q=Et(q);function re(){return q.includes("j")?Aa(q,V):hr(V)}var ae=re();return typeof ae!="function"&&He(`unknown function pointer with signature ${q}: ${V}`),ae},s1=(q,V)=>{var re=co(V,function(ae){this.name=V,this.message=ae;var pe=new Error(ae).stack;pe!==void 0&&(this.stack=this.toString()+` +`),ZLe=t=>mu(t)?Ue(t):Ii(t),Nte=t=>{const e=ZLe(t);return GLe(e)?e:Ue(qr([F3,Ii(String(e.length)),e]))},XLe=t=>{if(JSON.stringify(t.slice(0,F3.length))!==JSON.stringify(F3))return t;const e=t.slice(F3.length),r=String(e.length).length;let n,i;try{i=Number(Ip(e.slice(0,r)))}catch{i=Number(Me(e.slice(0,r)))}return i>e.length||!Number.isInteger(i)?n=r-1:n=r,e.slice(n)},I$=async(t,e,r,n)=>new mt.reader.OnChainReader(n).isValidSignature(t,e,r);async function eFe(t){return Array.isArray(t)?Promise.all(t.map(e=>vi(e))):vi(t)}function tFe(t){return[t,...t.auxiliary||[]]}const rFe=1e4;class nFe{constructor(e,r,n){var i=this;this.account=void 0,this.signerReadyCallbacks=[],this.prompter=void 0,this.networks=void 0,this._openIntent=void 0,this._connectOptions=void 0,this.events=new kLe.EventEmitter2,this.onConnectOptionsChange=void 0,this.promptConnect=async function(s){if(!s&&!i._connectOptions)throw new Error("prompter connect options are empty");if(!i.prompter)return i.connect(s);const o=await i.prompter.promptConnect(s||i._connectOptions).catch(c=>({connected:!1})),a=o;return a.connected&&!a.session&&(a.session=await i.walletSession(s==null?void 0:s.networkId)),o},this.isSignedIn=async function(){return await i.signerReady(),!!i.account},this.getAccount=async function(){if(await i.signerReady(),i.account===void 0)throw new Error("signerReady failed resolve");return i.account},this.account=e,this.prompter=r,this.networks=n}defaultChainId(){var e,r;return(e=(r=this.prompter)==null?void 0:r.getDefaultChainId())!=null?e:this.networks[0].chainId}async signIn(e,r={}){this.setAccount(e);const{connect:n,defaultNetworkId:i}=r;if(n){const a=this._connectOptions;let c;if(this.prompter!==null){var s;c=await((s=this.prompter)==null?void 0:s.promptSignInConnect(a))}else c=await this.connect(a);this.notifyConnect(c),(!a||a.keepWalletOpened!==!0)&&this.notifyClose()}if(i&&this.defaultChainId()!==i){var o;await((o=this.prompter)==null?void 0:o.promptChangeNetwork(i))}}signOut(){this.account&&this.notifyDisconnect(),this.setAccount(null)}signerReset(){this.account=void 0}signerReady(e=rFe){return new Promise((r,n)=>{this.account!==void 0?r():(setTimeout(()=>{this.account===void 0&&(this.signerReadyCallbacks=[],n("signerReady timed out"))},e),this.signerReadyCallbacks.push(r))})}async connect(e){var r,n;if(!this.account)return{connected:!1,chainId:"0x0",error:"unable to connect without signed in account"};const i=(r=(n=e==null?void 0:e.networkId)!=null?n:this.defaultChainId())!=null?r:ge.MAINNET,s=a9e(i).chainId,o={connected:!0,chainId:zc(s)};if(e&&e.authorize){const a={app:e.app,origin:e.origin,expiry:e.expiry,nonce:e.authorizeNonce};try{o.proof=await jLe(this.account,s,a)}catch(c){return Ci.warn(`connect, signAuthorization failed for options: ${JSON.stringify(e)}, due to: ${c.message}`),{connected:!1,chainId:"0x0",error:`signAuthorization failed: ${c.message}`}}}return o.session=this.walletSession(s),o}async sendMessageRequest(e){var r;const i=Number(((r=e.clientVersion)==null?void 0:r.split(".")[0])||"0")<2,s={id:e.data.id,jsonrpc:"2.0",result:null,error:void 0};try{const o=await this.request({method:e.data.method,params:e.data.params,chainId:e.chainId});return $c({},e,{data:i?$c({},s,{result:o}):o})}catch(o){return $c({},e,{data:i?$c({},s,{error:o}):{error:o}})}}async request(e){await this.getAccount();try{var r,n;if((!this.account||this.account===null)&&!iFe.includes(e.method))throw HLe;const l=this.account;if(!l)throw new Error("WalletRequestHandler: wallet account is not configured");const f=(r=this.account)==null?void 0:r.providerFor((n=e.chainId)!=null?n:this.defaultChainId());if(!f)throw new Error(`WalletRequestHandler: wallet provider is not configured for chainId ${e.chainId}`);const u=sFe(f)?f:void 0;switch(e.method){case"net_version":{if(!u)throw new Error("Account provider doesn't support send method");return await u.send("net_version",[])}case"eth_chainId":{if(!u)throw new Error("Account provider doesn't support send method");return await u.send("eth_chainId",[])}case"eth_accounts":return[l.address];case"eth_getBalance":{const[p,g]=e.params,y=await f.getBalance(p,g);return Nv(y)}case"sequence_sign":case"personal_sign":case"eth_sign":{let p;switch(e.method){case"sequence_sign":case"personal_sign":{const[I,C]=e.params;p=I;break}case"eth_sign":{const[I,C]=e.params;p=C;break}}let g="";const y=Nte(p),b=e.method==="sequence_sign";if(this.prompter===null){var i;g=await l.signMessage(y,(i=e.chainId)!=null?i:this.defaultChainId(),b?"eip6492":"ignore")}else g=await this.prompter.promptSignMessage({chainId:e.chainId,message:Ue(y),eip6492:b},this.connectOptions);if(g&&g.length>0)return g;throw new Error("declined by user")}case"sequence_signTypedData_v4":case"eth_signTypedData":case"eth_signTypedData_v4":{const[p,g]=e.params;let y;if(typeof g=="string")try{y=JSON.parse(g)}catch(C){console.warn("walletRequestHandler: error parsing typedData",C)}else y=g;if(!y||!y.domain||!y.types||!y.message)throw new Error("invalid typedData object");let b="";const I=e.method==="sequence_signTypedData_v4";if(this.prompter===null){var s;b=await l.signTypedData(y.domain,y.types,y.message,(s=e.chainId)!=null?s:this.defaultChainId(),I?"eip6492":"ignore")}else b=await this.prompter.promptSignMessage({chainId:e.chainId,typedData:y,eip6492:I},this.connectOptions);if(b&&b.length>0)return b;throw new Error("declined by user")}case"eth_sendTransaction":{const p=tFe(e.params[0]).map(y=>("gas"in y&&y.gasLimit===void 0&&(y.gasLimit=y.gas,delete y.gas),y));_I(l.address,p);let g="";if(this.prompter===null){var o,a;const y=await l.sendTransaction(p,(o=e.chainId)!=null?o:this.defaultChainId());g=(a=y==null?void 0:y.hash)!=null?a:""}else g=await this.prompter.promptSendTransaction(p,e.chainId,this.connectOptions);if(g)return g;throw new Error("declined by user")}case"eth_signTransaction":{const[p]=e.params;if(Qt(p.from)!==l.address)throw new Error("sender address does not match wallet");if(_I(l.address,p),this.prompter===null){var c;return await l.signTransactions(p,(c=e.chainId)!=null?c:this.defaultChainId())}else return await this.prompter.promptSignTransaction(p,e.chainId,this.connectOptions)}case"eth_sendRawTransaction":if(mt.transaction.isSignedTransactionBundle(e.params[0])){const p=Number(e.params[0].chainId);return(await l.relayer(p).relay(e.params[0])).hash}else return(await f.broadcastTransaction(e.params[0])).hash;case"eth_getTransactionCount":{const p=Qt(e.params[0]),g=e.params[1],y=await f.getTransactionCount(p,g);return Nv(BigInt(y))}case"eth_blockNumber":return await f.getBlockNumber();case"eth_getBlockByNumber":return await f.getBlock(e.params[0]);case"eth_getBlockByHash":return await f.getBlock(e.params[0]);case"eth_getTransactionByHash":return await f.getTransaction(e.params[0]);case"eth_call":{const[p,g]=e.params;return await f.call($c({},p,{blockTag:g}))}case"eth_getCode":{const[p,g]=e.params;return await f.getCode(p,g)}case"eth_estimateGas":{const[p]=e.params;return await f.estimateGas(p)}case"eth_gasPrice":{const p=await f.getFeeData();return p.gasPrice===null?null:Nv(p.gasPrice)}case"wallet_switchEthereumChain":{const[p]=e.params;if(!p.chainId||p.chainId.length===0)throw new Error("invalid chainId");const g=BigInt(p.chainId);return this.setDefaultChainId(Number(g)),null}case"sequence_getWalletContext":return l.contexts;case"sequence_getWalletConfig":{const[p]=e.params;return p?[(await l.status(p)).onChain.config]:await Promise.all(l.networks.map(async function(g){return(await l.status(g.chainId)).onChain.config}))}case"sequence_getWalletState":{const[p]=e.params;return p?[T$(p,await l.status(p))]:await Promise.all(l.networks.map(async function(g){const y=await l.status(g.chainId);return T$(g.chainId,y)}))}case"sequence_getNetworks":return await this.getNetworks(!0);case"sequence_isSequence":return!0;case"sequence_updateConfig":throw new Error("sequence_updateConfig method is not allowed from a dapp");case"sequence_publishConfig":throw new Error("sequence_publishConfig method is not allowed from a dapp");case"sequence_gasRefundOptions":break;case"sequence_getNonce":break;case"sequence_relay":break;case"sequence_setDefaultNetwork":{const[p]=e.params;if(!p)throw new Error("invalid request, method argument defaultChainId cannot be empty");return this.setDefaultChainId(p),await this.getNetworks(!0)}default:{if(!u)throw new Error("Account provider doesn't support send method");return await u.send(e.method,e.params)}}}catch(l){throw Ci.error(l),{message:typeof l=="string"?l:(l==null?void 0:l.message)||"unkown error",code:4001}}}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}async getAddress(){var e,r;return(e=(r=this.account)==null?void 0:r.address)!=null?e:""}get openIntent(){return this._openIntent}setOpenIntent(e){this._openIntent=e}get connectOptions(){return this._connectOptions}setConnectOptions(e){var r;this._connectOptions=e,(r=this.onConnectOptionsChange)==null||r.call(this,e)}async setDefaultChainId(e){var r;return await((r=this.prompter)==null?void 0:r.promptChangeNetwork(e)),this.defaultChainId()}async getNetworks(e){return this.account?e?this.account.networks.map(r=>{const n=$c({},r);return n.provider=void 0,n.relayer=void 0,n}):this.account.networks:(Ci.warn("signer not set: getNetworks is returning an empty list"),[])}walletSession(e){if(!this.account)return;const r={walletContext:this.account.contexts,accountAddress:this.account.address,networks:this.account.networks.map(i=>$c({},i,{provider:void 0,relayer:void 0}))};if(e){const i=Iw(r.networks,e);if(i){var n;(n=r.networks)==null||n.forEach(s=>delete s.isDefaultChain),i.isDefaultChain=!0}}return r}notifyConnect(e,r){var n;if(console.log("emit connect",e),this.events.emit("connect",e),(n=e.session)!=null&&n.accountAddress){var i;this.events.emit("accountsChanged",[(i=e.session)==null?void 0:i.accountAddress],r)}}notifyDisconnect(e){this.events.emit("accountsChanged",[],e),this.events.emit("disconnect",void 0,e)}notifyChainChanged(e,r){this.events.emit("chainChanged",zc(e),r)}async notifyNetworks(e){const r=e||await this.getNetworks(!0);if(this.events.emit("networks",r),r.length>0){const n=r.find(i=>i.chainId===this.defaultChainId());n&&this.events.emit("chainChanged",zc(n.chainId))}else this.events.emit("chainChanged","0x0")}async notifyWalletContext(){if(!this.account){Ci.warn("signer not set: skipping to notify wallet context");return}const e=this.account.contexts;this.events.emit("walletContext",e)}notifyClose(e){this.events.emit("close",e)}setAccount(e){if(this.account=e,e!==void 0){for(let r=0;rc.canOnchainValidate||c.original.version===2&&n,o=await r.status(i);if(s(o))return!0;if(await e.promptConfirmWalletDeploy(i,this.connectOptions)){const c=await r.status(i);return s(c)?!0:(Ci.error("WalletRequestHandler: result for promptConfirmWalletDeploy is not correct"),!1)}return!1}}function T$(t,e){return{context:e.original.context,config:e.onChain.config,address:mt.context.addressOf(e.original.context,e.original.imageHash),chainId:t,deployed:e.onChain.deployed,imageHash:e.imageHash,lastImageHash:e.onChain.imageHash,published:!0,status:e}}const iFe=["net_version","eth_chainId","eth_getBalance","eth_getTransactionCount","eth_blockNumber","eth_getBlockByNumber","eth_getBlockByHash","eth_getTransactionByHash","eth_getCode","eth_estimateGas","eth_gasPrice","sequence_getWalletContext","sequence_getNetworks","sequence_setDefaultNetwork"];function sFe(t){return t&&typeof t=="object"&&typeof t.send=="function"&&typeof t.getNetwork=="function"}function oFe(t,e){if(t==null)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}class DE{get utils(){return this.provider.utils}constructor(e,r){this.client=e,this.provider=r,this.singleNetworkSigners={},this._isSequenceSigner=!0}async getAddress(){return this.client.getAddress()}connect(e){if(!KM.is(e))throw new Error("SequenceSigner can only be connected to a SequenceProvider");return new DE(this.client,e)}getSigner(e){if(!e)return this;const r=this.provider.toChainId(e);return this.singleNetworkSigners[r]||(this.singleNetworkSigners[r]=new Bte(this.client,this.provider,r)),this.singleNetworkSigners[r]}useChainId(e){return this.provider.toChainId(e)||this.client.getChainId()}async signMessage(e,r){const{eip6492:n=!0}=r||{},i=this.useChainId(r==null?void 0:r.chainId);return this.client.signMessage(e,{eip6492:n,chainId:i})}async signTypedData(e,r,n,i){const{eip6492:s=!0}=i||{},o=this.useChainId(i==null?void 0:i.chainId);return this.client.signTypedData({domain:e,types:r,message:n},{eip6492:s,chainId:o})}getProvider(e){return this.provider.getProvider(e)}async sendTransaction(e,r){const n=this.useChainId(r==null?void 0:r.chainId),i=await eFe(e),s=await this.client.sendTransaction(i,{chainId:n}),o=this.getProvider(n);try{return await new Promise(c=>{(async function f(){const u=await o.getTransaction(s);if(u!==null)return c(u);await o.once("block",f)})()})}catch(a){throw a.transactionHash=s,a}}async getWalletConfig(e){const r=this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}getNetworks(){return this.client.getNetworks()}async getBalance(e,r){return this.getProvider(r==null?void 0:r.chainId).getBalance(this.getAddress(),e)}async estimateGas(e,r){return this.getProvider(r==null?void 0:r.chainId).estimateGas(e)}async call(e,r){return this.getProvider(r==null?void 0:r.chainId).call(e)}getChainId(){return Promise.resolve(this.client.getChainId())}async getFeeData(e){return this.getProvider(e==null?void 0:e.chainId).getFeeData()}async resolveName(e){const r=await this.provider.resolveName(e);if(r===null)throw new Error(`ENS name not found: ${e}`);return r}_checkProvider(e){}getNonce(e){throw new Error("SequenceSigner does not support getNonce")}populateCall(e){throw new Error("SequenceSigner does not support populateCall")}populateTransaction(e){throw new Error("SequenceSigner does not support populateTransaction")}checkTransaction(e){throw new Error("SequenceSigner does not support checkTransaction")}getTransactionCount(e){throw new Error("SequenceSigner does not support getTransactionCount")}signTransaction(e){throw new Error("SequenceWallet does not support signTransaction, use sendTransaction instead.")}static is(e){return e&&typeof e=="object"&&e._isSequenceSigner===!0}}class Bte extends DE{constructor(e,r,n){super(e,r.getProvider(n)),this.chainId=n,this._isSingleNetworkSequenceSigner=!0}_useChainId(e){const r=this.provider.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This signer only supports the network ${this.chainId}, but ${r} was requested.`);return r||this.provider.toChainId(this.chainId)}useChainId(e){return this._useChainId(e)}getChainId(){return Promise.resolve(this.provider.toChainId(this.chainId))}getProvider(e){return super.getProvider(this._useChainId(e))}getSigner(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceSigner===!0}}class aFe{constructor(e){if(this.signer=e,Bte.is(e))throw new Error("WalletUtils does not support SingleNetworkSequenceSigner")}signMessage(e,r,n){return this.signer.signMessage(e,{chainId:r,eip6492:n})}signTypedData(e,r,n,i,s){return this.signer.signTypedData(e,r,n,{chainId:i,eip6492:s})}async isValidSignature(e,r,n,i){return I$(e,r,n,this.signer.getProvider(i))}async isValidMessageSignature(e,r,n,i){const s=this.signer.getProvider(i),o=Nte(r),a=OEe(o);return I$(e,a,n,s)}isValidTypedDataSignature(e,r,n,i){return this.isValidSignature(e,Dk(r),n,i)}}const cFe=["method"],P$=["connect","disconnect","chainChanged","accountsChanged"];class KM extends gJ{constructor(e,r,n=dM,i){super(e.getChainId(),i),this.client=e,this.providerFor=r,this.networks=n,this.options=i,this.singleNetworkProviders={},this._isSequenceProvider=!0,this.utils=void 0,this.signer=void 0,this.eip1193EventListeners=new Map,e.onConnect(s=>{var o;(o=this.eip1193EventListeners.get("connect"))==null||o.forEach(a=>a(s))}),e.onDisconnect(s=>{var o;(o=this.eip1193EventListeners.get("disconnect"))==null||o.forEach(a=>a(s))}),e.onDefaultChainIdChanged(s=>{var o;(o=this.eip1193EventListeners.get("chainChanged"))==null||o.forEach(a=>a(s))}),e.onAccountsChanged(s=>{var o;(o=this.eip1193EventListeners.get("accountsChanged"))==null||o.forEach(a=>a(s))}),this.signer=new DE(this.client,this),this.utils=new aFe(this.signer)}async on(e,r){if(P$.includes(e)){const n=this.eip1193EventListeners.get(e)||new Set;return n.add(r),this.eip1193EventListeners.set(e,n),this}return super.on(e,r)}async off(e,r){if(P$.includes(e)){const n=this.eip1193EventListeners.get(e);return n&&(r?n.delete(r):n.clear()),this}return super.off(e,r)}getSigner(e){return this.signer.getSigner(e)}connect(e){return this.client.connect(e)}disconnect(){return this.client.disconnect()}isConnected(){return this.client.isConnected()}getSession(){return this.client.getSession()}listAccounts(){return[this.client.getAddress()]}getAddress(){return this.client.getAddress()}getNetworks(){return this.client.getNetworks()}getChainId(){return this.client.getChainId()}setDefaultChainId(e){return this.client.setDefaultChainId(this.toChainId(e))}isOpened(){return this.client.isOpened()}closeWallet(){return this.client.closeWallet()}getWalletContext(){return this.client.getWalletContext()}async getWalletConfig(e){const r=await this.useChainId(e);return this.client.getOnchainWalletConfig({chainId:r})}authorize(e){return this.client.connect($c({},e,{authorize:!0}))}async openWallet(e,r){return await this.client.openWallet(e,r),!0}toChainId(e){if(e===void 0)return;const r=Iw(this.networks,e);if(!r)throw new Error(`Unsupported network ${e}`);return r.chainId}async useChainId(e){return this.toChainId(e)||this.client.getChainId()}getProvider(e){if(!e)return this;const r=this.toChainId(e);return this.singleNetworkProviders[r]||(this.singleNetworkProviders[r]=new lFe(this.client,this.providerFor,r,this.options)),this.singleNetworkProviders[r]}async _getSubprovider(e){const r=await this.useChainId(e),n=this.providerFor(r);if(!n)throw new Error(`Unsupported network ${r}`);return n}async _perform(e){var r;const{method:n}=e,i=oFe(e,cFe),s=await this._getSubprovider(),o=(r=s.getRpcRequest(e))!=null?r:{method:n,args:Object.values(i)};if(!o)throw new Error(`Unsupported method ${e.method}`);return s.send(o.method,o.args)}async perform(e,r){if(e==="eth_chainId")return zc(await this.useChainId());if(e==="eth_accounts")return[this.client.getAddress()];if(e==="wallet_switchEthereumChain"){const n=r[0],i=Lte(n);return this.setDefaultChainId(i)}return e==="eth_sendTransaction"||e==="eth_sign"||e==="eth_signTypedData"||e==="eth_signTypedData_v4"||e==="personal_sign"||e==="sequence_sign"||e==="sequence_signTypedData_v4"?this.client.request({method:e,params:r,chainId:this.getChainId()}):this._perform($c({method:e},r))}send(e,r){return this.perform(e,r)}request(e){return this.perform(e.method,e.params)}async _detectNetwork(){const e=this.client.getChainId(),r=Iw(this.networks,e);if(!r)throw new Error(`Unknown network ${e}`);return new ca(r.name,r.chainId)}async detectNetwork(){return this._detectNetwork()}async waitForTransaction(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).waitForTransaction(e,r,n)}async getBlockNumber(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getBlockNumber()}async getFeeData(e){return(await this._getSubprovider(e==null?void 0:e.chainId)).getFeeData()}async getBalance(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getBalance(e,r)}async getTransactionCount(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getTransactionCount(e,r)}async getCode(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getCode(e,r)}async getStorage(e,r,n,i){return(await this._getSubprovider(i==null?void 0:i.chainId)).getStorage(e,r,n)}async call(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).call(e)}async estimateGas(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).estimateGas(e)}async getBlock(e,r,n){return(await this._getSubprovider(n==null?void 0:n.chainId)).getBlock(e,r)}async getTransaction(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getTransaction(e)}async getLogs(e,r){return(await this._getSubprovider(r==null?void 0:r.chainId)).getLogs(e)}async supportsENS(){return(await this.getNetworks()).some(r=>r.chainId===1)}async getResolver(e){return await this.supportsENS()?(await this._getSubprovider(1)).getResolver(e):null}async resolveName(e){return vw(e)?e:await this.supportsENS()?(await this._getSubprovider(1)).resolveName(e):null}async lookupAddress(e){return await this.supportsENS()?(await this._getSubprovider(1)).lookupAddress(e):null}async getAvatar(e){return await this.supportsENS()?(await this._getSubprovider(1)).getAvatar(e):null}}KM.is=t=>t&&typeof t=="object"&&t._isSequenceProvider===!0;function Lte(t){return typeof t=="object"?Lte(t.chainId):Number(t)}class lFe extends KM{constructor(e,r,n,i){super(e,r,void 0,i),this.chainId=n,this._isSingleNetworkSequenceProvider=!0}_useChainId(e){const r=this.toChainId(e);if(r&&r!==this.chainId)throw new Error(`This provider only supports the network ${this.chainId}, but ${r} was requested.`);return r||super.toChainId(this.chainId)}useChainId(e){return Promise.resolve(this._useChainId(e))}getChainId(){return super.toChainId(this.chainId)}async getNetwork(){const e=await this.client.getNetworks(),r=Iw(e,this.chainId);if(!r)throw new Error(`Unsupported network ${this.chainId}`);return new ca(r.name,r.chainId)}getProvider(e){if(this._useChainId(e)!==this.chainId)throw new Error("Unreachable code");return this}getSigner(e){return super.getSigner(this._useChainId(e))}setDefaultChainId(e){throw new Error(`This provider only supports the network ${this.chainId}; use the parent provider to switch networks.`)}static is(e){return e&&typeof e=="object"&&e._isSingleNetworkSequenceProvider===!0}}class Zr{constructor(e){de(this,"networkStore",Ir(Nn));de(this,"authStore",Ir(li));de(this,"accountAddress",this.authStore.accountAddress.get());de(this,"availableExternalProviders",Or([]));de(this,"selectedExternalProvider",Or(void 0));de(this,"selectedExternalWalletAddress",Or(void 0));de(this,"isSendingTokenTransaction",Or(void 0));de(this,"isSendingCollectibleTransaction",Or(void 0));de(this,"isSendingSignedTokenTransaction",Or(void 0));de(this,"connectDetails",Or(void 0));de(this,"connectOptions",Or(void 0));de(this,"isSigningTxn",Or(!1));de(this,"isSigningMsg",Or(!1));de(this,"toSignPermission",Or(void 0));de(this,"toSignResult",Or(void 0));de(this,"toSignTxnDetails",Or(void 0));de(this,"toSignMsgDetails",Or(void 0));de(this,"isCheckingWalletDeployment",Or(!1));de(this,"signClientWarningType",Or(!1));de(this,"walletRequestHandler");de(this,"local",{lastConnectedExternalProviderInfo:new Np(dh.LAST_CONNECTED_EXTERNAL_PROVIDER_INFO)});de(this,"defaultNetwork",new Np(dh.DEFAULT_NETWORK));de(this,"getLastConnectedExternalProviderInfo",()=>this.local.lastConnectedExternalProviderInfo.get());de(this,"sendToken",async(e,r,n)=>{var i,s;try{const o=this.store.get(li).account,a=e.chainId;if(!o)throw new Error("No account found");const c=this.store.get(Nn).providerForChainId(a);this.isSendingTokenTransaction.set({tokenBalance:e,to:r,amount:n});const l=(i=this.selectedExternalProvider.get())==null?void 0:i.provider;if(!l)throw new Error("No external provider selected");const u=(await this.getExternalProviderAccounts(l))[0];await this.switchToChain(l,a);let p;if(!n)return{hash:""};if(e.contractType===hh.NATIVE?(console.info("Sending native token with address, on chainId: ",e.contractAddress,a),p={to:r,value:E6e(n)}):e.contractType===hh.ERC20&&(console.info("Sending ERC20 token with address, on chainId: ",e.contractAddress,a),p=await new Dn(e.contractAddress,jv,c).transfer.populateTransaction(r,W7(n,((s=e.contractInfo)==null?void 0:s.decimals)??18))),!p)throw this.isSendingTokenTransaction.set(void 0),new Error("Could not create transaction");let g;try{g=(await this.sendTransaction(o,l,u,p,a)).hash}catch(y){throw this.isSendingTokenTransaction.set(void 0),y}return{hash:g}}catch{throw this.isSendingTokenTransaction.set(void 0),new Error("Could not create transaction")}});de(this,"sendCollectible",async(e,r,n)=>{var i,s;try{const o=this.store.get(li).account,a=e.collectibleInfoParams.chainId;if(!o)throw new Error("No account found");const c=this.store.get(Nn).providerForChainId(a);this.isSendingCollectibleTransaction.set({collectibleInfo:e,to:r,amount:n});const l=(i=this.selectedExternalProvider.get())==null?void 0:i.provider;if(!l)throw new Error("No external provider selected");const u=(await this.getExternalProviderAccounts(l))[0];await this.switchToChain(l,a);let p;if(e.collectibleInfoParams.contractType==="ERC721")console.info("Sending ERC721 non-fungible token with address, on chainId: ",e.collectibleInfoParams.address,a),p=await new Dn(e.collectibleInfoParams.address,hM,c).safeTransferFrom.populateTransaction(o,r,e.collectibleInfoParams.tokenId);else if(e.collectibleInfoParams.contractType==="ERC1155"){console.info("Sending ERC1155 token with address, on chainId: ",e.collectibleInfoParams.address,a);const y=new Dn(e.collectibleInfoParams.address,pM,c);if(!n)return{hash:""};p=await y.safeTransferFrom.populateTransaction(o,r,e.collectibleInfoParams.tokenId,W7(n,((s=e==null?void 0:e.collectibleInfoResponse)==null?void 0:s.decimals)??18),"0x")}if(!p)throw this.isSendingCollectibleTransaction.set(void 0),new Error("Could not create transaction");let g;try{g=(await this.sendTransaction(o,l,u,p,a)).hash}catch(y){throw this.isSendingCollectibleTransaction.set(void 0),y}return{hash:g}}catch{throw this.isSendingCollectibleTransaction.set(void 0),new Error("Could not create transaction")}});de(this,"setExternalProvider",async e=>{if(!e){this.selectedExternalProvider.set(void 0),this.selectedExternalWalletAddress.set(void 0),this.local.lastConnectedExternalProviderInfo.set(void 0);return}const n=(await this.getExternalProviderAccounts(e.provider))[0];this.local.lastConnectedExternalProviderInfo.set(e.info),this.selectedExternalProvider.set(e),this.selectedExternalWalletAddress.set(n),e.provider.on("accountsChanged",async i=>{if(i.length===0){this.selectedExternalProvider.set(void 0),this.selectedExternalWalletAddress.set(void 0);return}if(i[0]!==n){const o=(await this.getExternalProviderAccounts(e.provider))[0];this.selectedExternalWalletAddress.set(o)}})});de(this,"resetSignObservables",()=>{this.isSigningTxn.set(!1),this.toSignTxnDetails.set(void 0),this.toSignMsgDetails.set(void 0),this.toSignPermission.set(void 0),this.toSignResult.set(void 0)});de(this,"checkWalletDeployment",async e=>{const r=this.store.get(li).account;if(!r)throw new Error("No account found");return(await r.status(e)).onChain.deployed});this.store=e,this.walletRequestHandler=new nFe(void 0,new fFe(e),this.networkStore.networks.get()),this.walletRequestHandler.onConnectOptionsChange=n=>{this.connectOptions.set(n)},this.availableExternalProviders.subscribe(n=>{const i=this.local.lastConnectedExternalProviderInfo.get(),s=n.find(o=>(i==null?void 0:i.name)===o.info.name);s&&this.setExternalProvider(s)});const r=this.store.get(li).account;this.walletRequestHandler.signIn(r??null)}async sendTransaction(e,r,n,i,s){const o=await e.status(s),a=await e.predecorateTransactions(i,o,s),c=await e.signTransactions(a,s,void 0,{serial:!0}),l=await e.decorateTransactions(c,o);await this.switchToChain(r,s);const f=await r.request({method:"eth_estimateGas",params:[{from:n,to:l.entrypoint,data:mt.transaction.encodeBundleExecData(l)}]});return{hash:await r.request({method:"eth_sendTransaction",params:[{from:n,to:l.entrypoint,data:mt.transaction.encodeBundleExecData(l),gas:f}]})}}async getExternalProviderAccounts(e){return new Promise((r,n)=>{var i;(i=e.sendAsync)==null||i.call(e,{method:"eth_requestAccounts",params:[]},(s,o)=>{s&&n(s),o.result.length===0&&n(new Error("No accounts found")),r(o.result)})})}async getExternalProviderAddress(e){return(await this.getExternalProviderAccounts(e))[0]}async switchToChain(e,r){return new Promise((n,i)=>{var s;(s=e.sendAsync)==null||s.call(e,{method:"wallet_switchEthereumChain",params:[{chainId:zc(r)}]},(o,a)=>{o&&i(o),n(a)})})}}class fFe{constructor(e){this.store=e}getDefaultChainId(){return this.store.get(Zr).defaultNetwork.get()??1}async promptChangeNetwork(e){return this.store.get(Nn).networks.get().some(n=>n.chainId===e)?(this.store.get(Zr).defaultNetwork.set(e),!0):!1}async promptConfirmWalletDeploy(e,r){if(console.log("prompt confirm wallet deploy:",e,r),!e)return Promise.resolve(!1);const n=await this.store.get(Zr).checkWalletDeployment(e);return new Promise((i,s)=>{i(!!n)})}async promptConnect(e){console.log("promptconnect",e);const r=this.store.get(li).account;return await this.store.get(Zr).walletRequestHandler.signIn(r??null),e&&this.store.get(Zr).walletRequestHandler.setConnectOptions(e),new Promise((n,i)=>{const s=this.store.get(Zr).connectDetails.subscribe(o=>{s(),!o||!o.connected?i("connect cancelled by user"):n(o)})})}async promptSignInConnect(e){return console.log("prompt sign in connect:",e),{connected:!1}}async promptSignMessage(e,r){return console.log("prompt sign message:",e,r),e.chainId?e.eip6492!==!0&&!(await this.store.get(li).account.status(e.chainId)).canOnchainValidate&&!await this.promptConfirmWalletDeploy(e.chainId,r)?(this.store.get(Zr).signClientWarningType.set("notDeployed"),Promise.reject("User rejected wallet deploy request")):(this.store.get(Zr).isSigningMsg.set(!0),this.store.get(Zr).toSignMsgDetails.set({message:e,chainId:e.chainId,options:r}),new Promise((n,i)=>{const s=this.store.get(Zr).toSignPermission.subscribe(()=>{s();const o=this.store.get(Zr).toSignPermission.get();if(this.store.get(Zr).toSignPermission.set(void 0),!o||o==="cancelled")i("request failed");else{const a=this.store.get(Zr).toSignResult.get();a&&n(a.hash)}})})):Promise.reject("No chainId found in message")}promptSignTransaction(e,r,n){console.log("prompt sign transaction:",e,r,n);let i;Array.isArray(e)?i=e:i=[e];const s=this.store.get(li).accountAddress.get();if(!s)throw new Error("Unknown account address");const o=mt.transaction.fromTransactionish(s,i);return console.log("prompt sign txn:",o,r,n),_I(s,i),new Promise((a,c)=>{this.store.get(Zr).toSignTxnDetails.set({txn:i,chainId:r,options:n}),this.store.get(Zr).isSigningTxn.set(!0);const l=this.store.get(Zr).toSignPermission.subscribe(()=>{l();const f=this.store.get(Zr).toSignPermission.get();if(this.store.get(Zr).toSignPermission.set(void 0),!f||f==="cancelled")c("request failed");else{const u=this.store.get(Zr).toSignResult.get();u&&a(u.hash)}})})}promptSendTransaction(e,r,n){return this.promptSignTransaction(e,r,n)}}async function Fte(t){return await PLe.init({projectId:lX,showQrModal:t,optionalChains:[1],metadata:{name:"Sequence Recovery Wallet External Wallet",description:"",url:"TODO_CHANGE_LATER",icons:[]}})}function uFe(){const[t,e]=D.useState(null),n=Ir(Zr).getLastConnectedExternalProviderInfo();return D.useEffect(()=>{async function i(){const s=await Fte(!1);await s.enable(),e(s)}return(n==null?void 0:n.name)==="WalletConnect"&&i(),()=>{t&&t.disconnect()}},[]),t}const k$=async(t,e,r=15)=>{let n,i=0;do{if(i>5&&await new Promise(s=>setTimeout(s,100*i)),n=await t.getTransactionReceipt(e),i===r){console.warn(`Could not get receipt for transaction ${e} after ${i} tries`);return}if(n)return n;i++}while(!n&&i<=r)};let L6=[];const cS={value:()=>L6,subscribe:t=>{function e(r){L6.some(n=>n.info.uuid===r.detail.info.uuid)||(L6=[...L6,r.detail],t())}return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)}},jte=()=>D.useSyncExternalStore(cS.subscribe,cS.value,cS.value);class NE{constructor(e){de(this,"authStore",Ir(li));de(this,"accountAddress",this.authStore.accountAddress.get());de(this,"isReady",Or(!1));de(this,"signClient");de(this,"currentRequestInfo");de(this,"allSessions",Or([]));de(this,"sessions",this.allSessions.readOnly());de(this,"createSignClient",async()=>{this.signClient=await OE.init({projectId:lX,metadata:{name:"Sequence Recovery Wallet",description:"Sequence Recovery Wallet - Recover Your Wallet",url:"http://localhost:5173",icons:["https://sequence.app/apple-touch-icon.png"]}}),this.signClient.on("session_proposal",this.onSessionProposal),this.signClient.on("session_request",this.onSessionRequest),this.signClient.on("session_ping",this.onSessionPing),this.signClient.on("session_event",this.onSessionEvent),this.signClient.on("session_update",this.onSessionUpdate),this.signClient.on("session_delete",this.onSessionDelete);const e=this.getSignClientSessions();e?this.allSessions.set(e):this.allSessions.set([]),this.isReady.set(!0)});de(this,"getSignClientSessions",()=>this.signClient.session.getAll().filter(r=>r.self.metadata.name!=="Sequence Recovery Wallet External Wallet"));de(this,"pair",async e=>{if(!this.signClient)throw new Error("WalletConnect signClient not initialized.");await this.signClient.core.pairing.pair({uri:e}),this.allSessions.set(this.getSignClientSessions())});de(this,"rejectRequest",()=>{var e;this.currentRequestInfo&&((e=this.signClient)==null||e.respond({topic:this.currentRequestInfo.topic,response:{id:this.currentRequestInfo.id,jsonrpc:"2.0",error:{message:"User rejected.",code:4001}}}))});de(this,"disconnectSession",async e=>{var n,i;const r=(n=this.signClient)==null?void 0:n.session.get(e);r&&(await((i=this.signClient)==null?void 0:i.engine.client.disconnect({topic:r.topic,reason:{message:"User disconnected.",code:6e3}})),this.allSessions.set(this.getSignClientSessions()??[]))});de(this,"disconnectAllSessions",async()=>{var r;(((r=this.signClient)==null?void 0:r.session.getAll())??[]).forEach(async n=>{var i;await((i=this.signClient)==null?void 0:i.engine.client.disconnect({topic:n.topic,reason:{message:"User disconnected.",code:6e3}}))}),this.allSessions.set([])});de(this,"onSessionProposal",async e=>{var l,f,u,p,g;console.log("onSessionProposal",e);const r=e.params.requiredNamespaces,n=e.params.optionalNamespaces,i=Object.keys(r).length===0?[]:r.eip155.chains??[],s=Object.keys(n).length===0?[]:n.eip155.chains??[],o=((l=i[0])==null?void 0:l.split(":").pop())??((f=s[0])==null?void 0:f.split(":").pop());if(!o)throw new Error("No chainId found in WalletConnect session proposal namespaces.");const a={app:e.params.proposer.metadata.name,origin:e.params.proposer.metadata.url,networkId:o,keepWalletOpened:!0},c=await this.store.get(Zr).walletRequestHandler.promptConnect(a);if(c&&c.connected){const b=this.store.get(Nn).networks.get(),I=i.map(_=>Number(_.split(":").pop())),C=s.map(_=>Number(_.split(":").pop())),L={eip155:{accounts:b.map(_=>_.chainId).filter(_=>[...I,...C].includes(_)).map(_=>"eip155:"+_+":"+this.accountAddress),methods:["eth_sendTransaction","eth_sign","personal_sign","eth_signTypedData","eth_signTypedData_v4","wallet_switchEthereumChain"],events:["chainChanged","accountsChanged","connect","disconnect"]}},F=await((u=this.signClient)==null?void 0:u.approve({id:e.id,namespaces:L})),z=await(F==null?void 0:F.acknowledged());console.log("session",z),this.allSessions.set(this.getSignClientSessions()??[]),(p=this.signClient)==null||p.core.pairing.getPairings().filter(_=>e.params.pairingTopic!==_.topic).forEach(async _=>{var $,ie;e.params.proposer.metadata.url===(($=_.peerMetadata)==null?void 0:$.url)&&await((ie=this.signClient)==null?void 0:ie.core.pairing.disconnect({topic:_.topic}))})}else(g=this.signClient)==null||g.reject({id:e.id,reason:{message:"User rejected.",code:5e3}})});de(this,"onSessionRequest",async e=>{var o,a,c;console.log("onSessionRequest",e);const r=e.params.chainId.split(":").pop(),n={jsonrpc:"2.0",id:e.id,method:e.params.request.method,params:e.params.request.params,chainId:Number(r)};n.method==="eth_sendTransaction"&&Array.isArray(n.params)&&n.params.forEach(l=>{delete l.nonce});const i=(o=this.signClient)==null?void 0:o.session.get(e.topic),s={app:(i==null?void 0:i.peer.metadata.name)??"",origin:i==null?void 0:i.peer.metadata.url,networkId:r};this.store.get(Zr).walletRequestHandler.setConnectOptions(s),this.currentRequestInfo={topic:e.topic,id:e.id};try{const l=await this.store.get(Zr).walletRequestHandler.request(n);(a=this.signClient)==null||a.respond({topic:e.topic,response:{id:e.id,jsonrpc:"2.0",result:l}})}catch(l){(c=this.signClient)==null||c.respond({topic:e.topic,response:{id:e.id,jsonrpc:"2.0",error:{message:l.message,code:l.code??4001}}})}this.currentRequestInfo=void 0});de(this,"onSessionPing",async e=>{console.log("onSessionPing",e)});de(this,"onSessionEvent",async e=>{console.log("onSessionEvent",e)});de(this,"onSessionUpdate",async e=>{console.log("onSessionUpdate",e)});de(this,"onSessionDelete",async e=>{console.log("onSessionDelete",e),this.allSessions.set(this.getSignClientSessions()??[])});this.store=e,this.createSignClient()}}const M$=["https://dweb.link/ipfs/","https://gateway.pinata.cloud/ipfs/","https://nftstorage.link/ipfs/","https://flk-ipfs.io/ipfs/","https://storry.tv/ipfs/","https://ipfs.io/ipfs/","https://hardbin.com/ipfs/","https://ipfs.runfission.com/ipfs/","https://ipfs.eth.aragon.network/ipfs/","https://4everland.io/ipfs/","https://w3s.link/ipfs/","https://trustless-gateway.link/ipfs/"],dFe="QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/1";class hFe{constructor(){de(this,"gatewayURL");de(this,"localStore");this.localStore=new Np(dh.GATEWAY_ADDRESS),this.gatewayURL=this.localStore.get(),this.findAccessibleGateway()}async findAccessibleGateway(){const e=this.localStore.get();if(e&&await this.isGatewayAccessible(e)){this.gatewayURL=e;return}for(const r of M$)if(await this.isGatewayAccessible(r)){this.gatewayURL=r,this.localStore.set(r);return}this.gatewayURL=M$[0],console.warn("No accessible IPFS gateways found, falling back to default")}async isGatewayAccessible(e){try{return await fetch(`${e}${dFe}`,{signal:AbortSignal.timeout(3e3)}),!0}catch{return!1}}async fetch(e){this.gatewayURL||await this.findAccessibleGateway();const r=await this.getGatewayURL(e);return fetch(r,{signal:AbortSignal.timeout(3e3)})}async getGatewayURL(e){if(this.gatewayURL||await this.findAccessibleGateway(),!e.startsWith("ipfs://"))throw new Error("Invalid IPFS URI");return e.replace("ipfs://",this.gatewayURL)}}class YM{constructor(e){de(this,"isFetchingBalances",Or(!1));de(this,"isFetchingCollectibleInfo",Or(!1));de(this,"ipfsGatewayHelper",new hFe);de(this,"userCollectibles",Or([]));de(this,"local",{userCollectibles:new Np(dh.COLLECTIBLES)});this.store=e;const r=this.store.get(Nn);pX(r.networks,n=>{const i=this.store.get(li).accountAddress.get();i&&n.length>0&&this.loadBalances(i)})}async loadBalances(e){const r=this.local.userCollectibles.get()??[];if(r.length===0)return;this.isFetchingBalances.set(!0);const n=[],i=r.map(async s=>{const o=await this.getCollectibleInfo(s);if(!o.isOwner){this.removeCollectible({collectibleInfoParams:s,collectibleInfoResponse:o});return}n.push({collectibleInfoParams:s,collectibleInfoResponse:o})});await Promise.allSettled(i),this.userCollectibles.set(n),this.isFetchingBalances.set(!1)}async getCollectibleInfo(e){const r=this.store.get(li).accountAddress.get();if(!r)throw new Error("No account found");const n=this.store.get(Nn).providerForChainId(e.chainId);this.isFetchingCollectibleInfo.set(!0);let i,s,o,a,c;if(e.contractType===hh.ERC721){const f=new Dn(e.address,hM,n),p=(await f.ownerOf(e.tokenId)).toLowerCase()===r.toLowerCase();if(!p)return this.isFetchingCollectibleInfo.set(!1),{isOwner:p,uri:""};i=await f.tokenURI(e.tokenId)}else if(e.contractType===hh.ERC1155){const f=new Dn(e.address,pM,n);if(a=await f.balanceOf(r,e.tokenId),!a)return this.isFetchingCollectibleInfo.set(!1),{isOwner:!1,uri:""};i=await f.uri(e.tokenId)}if(!i)throw new Error("Could not get collectible URI");i.includes("{id}")&&(i=i.replace("{id}",e.tokenId.toString()));let l;return i.startsWith("ipfs://")?l=await this.ipfsGatewayHelper.fetch(i).then(f=>f.json()):l=await fetch(i).then(f=>f.json()),l&&(c=l.decimals,s=l.image,o=l.name),s!=null&&s.startsWith("ipfs://")&&(s=await this.ipfsGatewayHelper.getGatewayURL(s)),a=a??BigInt(1),c=c??0,this.isFetchingCollectibleInfo.set(!1),{isOwner:!0,uri:i,image:s,name:o,balance:a,decimals:c}}async addCollectible(e){if(e.collectibleInfoResponse.isOwner){const r=this.local.userCollectibles.get()??[];if(r.some(n=>n.address===e.collectibleInfoParams.address&&n.tokenId===e.collectibleInfoParams.tokenId))throw new Error("Collectible already added");this.local.userCollectibles.set([...r,e.collectibleInfoParams]),this.isFetchingCollectibleInfo.set(!0),this.loadBalances(),this.isFetchingCollectibleInfo.set(!1)}}async removeCollectible(e){const n=(this.local.userCollectibles.get()??[]).filter(o=>o.address!==e.collectibleInfoParams.address||o.tokenId!==e.collectibleInfoParams.tokenId);this.local.userCollectibles.set(n);const s=this.userCollectibles.get().filter(o=>o.collectibleInfoParams.address!==e.collectibleInfoParams.address||o.collectibleInfoParams.tokenId!==e.collectibleInfoParams.tokenId);this.userCollectibles.set(s)}}function BE({chainId:t,paddingTop:e="1",paddingBottom:r="2"}){return W.jsx(xe,{background:"backgroundMuted",width:"fit",height:"fit",borderRadius:"sm",paddingTop:e,paddingBottom:r,paddingX:"2",children:W.jsx(Ge,{variant:"xsmall",color:"text100",children:ky(t)})})}function pFe({collectibleInfo:t,onSendClick:e,onRemoveClick:r}){return W.jsxs($r,{width:"full",flexDirection:"column",gap:"2",padding:"4",children:[W.jsx(xe,{flexDirection:"row",alignItems:"center",gap:"2",children:W.jsx(Ge,{variant:"medium",color:"text80",children:t.collectibleInfoResponse.name??"Collectible"})}),W.jsx(xe,{style:{height:"200px"},children:W.jsx(a8,{style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"},src:t.collectibleInfoResponse.image??"",width:"full"})}),W.jsx(xe,{justifyContent:"flex-end",children:W.jsx(Ge,{variant:"medium",color:"text100",children:t.collectibleInfoParams.contractType==="ERC1155"?Number(fh(t.collectibleInfoResponse.balance,t.collectibleInfoResponse.decimals??0)):1})}),W.jsxs(xe,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(BE,{chainId:t.collectibleInfoParams.chainId}),W.jsxs(xe,{children:[W.jsx(Zt,{size:"xs",label:"Send",variant:"primary",shape:"square",onClick:e}),r&&W.jsx(Zt,{marginLeft:"2",size:"xs",label:"Remove",shape:"square",onClick:r})]})]})]})}function vFe({onClose:t}){const r=Ir(Nn).networks.get(),n=r.filter(z=>z.type===Ft.MAINNET),i=Ir(YM),s=yn(i.isFetchingCollectibleInfo),o=h8(),[a,c]=D.useState(),[l,f]=D.useState(),[u,p]=D.useState(),[g,y]=D.useState(),[b,I]=D.useState(),[C,S]=D.useState(!1);D.useEffect(()=>{a&&l&&u&&g?i.getCollectibleInfo({chainId:a.chainId,address:l,tokenId:u,contractType:g}).then(z=>{I(z)}):I(void 0)},[a,l,u,g]);const O=n.map(z=>({label:z.title,value:z.chainId.toString()})),L=async()=>{a&&l&&b&&u&&g&&(await i.addCollectible({collectibleInfoParams:{chainId:a.chainId,address:l,tokenId:u,contractType:g},collectibleInfoResponse:b}),S(!1),o({variant:"success",title:"Collectible added"}),F(),t())},F=()=>{f(void 0),c(void 0),p(void 0),y(void 0)};return W.jsxs($r,{flexDirection:"column",paddingY:"4",paddingX:"8",marginBottom:"8",borderRadius:"md",width:"full",height:"full",alignItems:"center",disabled:C,children:[W.jsx(xe,{children:W.jsx(Ge,{variant:"medium",color:"text80",children:"Import ERC721 or ERC1155 Collectible"})}),W.jsxs(xe,{flexDirection:"column",width:"full",marginTop:"4",gap:"4",children:[W.jsx(M7,{label:"Collectible Network",labelLocation:"left",name:"collectibleNetwork",options:O,onValueChange:z=>c(r.find(_=>_.chainId===Number(z)))}),W.jsx(Wn,{width:"full",label:"Collectible Address",labelLocation:"left",name:"collectibleAddress",value:l??"",onChange:z=>{f(z.target.value)}}),W.jsx(M7,{label:"Collectible Type",labelLocation:"left",name:"collectibleType",options:[{value:"ERC721",label:"ERC721"},{value:"ERC1155",label:"ERC1155"}],onValueChange:z=>y(z)}),W.jsx(Wn,{width:"full",label:"Collectible Token ID",labelLocation:"left",name:"collectibleId",value:u??"",onKeyPress:z=>{/[0-9]/.test(z.key)||z.preventDefault()},onChange:z=>{if(z.target.value===""){p(void 0);return}p(z.target.value)}}),s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})}),b&&!b.isOwner&&!s&&W.jsx(xe,{alignItems:"center",justifyContent:"center",children:W.jsx(Ge,{variant:"medium",color:"warning",children:"You do not own this collectible"})}),b&&b.isOwner&&!s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx($r,{flexDirection:"column",gap:"2",children:W.jsxs(xe,{flexDirection:"row",gap:"6",children:[W.jsx("img",{src:b.image??"",alt:b.name??"",style:{width:"120px",height:"auto"}}),W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Ge,{variant:"medium",color:"text100",children:b.name??""}),W.jsx(W.Fragment,{children:b.balance&&W.jsxs(W.Fragment,{children:[W.jsx(Ge,{variant:"small",color:"text80",children:"Your Balance:"}),W.jsx(Ge,{variant:"medium",color:"text100",children:Number(fh(b.balance,b.decimals??0))})]})})]})]})})}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",disabled:C,onClick:()=>{F(),t()}}),W.jsx(Zt,{label:"Add",disabled:b===void 0||!b.isOwner||C,variant:"primary",size:"md",shape:"square",onClick:L})]})]})]})}function gFe({onSendClick:t}){const e=Ir(YM),r=yn(e.isFetchingBalances),n=yn(e.userCollectibles),i=D.useMemo(()=>n,[n]),[s,o]=D.useState(!1);return W.jsxs(W.Fragment,{children:[W.jsxs(xe,{width:"full",flexDirection:"row",flexWrap:"wrap",gap:"4",marginBottom:"8",children:[i.map(a=>W.jsx(xe,{width:"1/3",children:W.jsx(pFe,{collectibleInfo:a,onSendClick:()=>{t(a)},onRemoveClick:()=>{e.removeCollectible(a)}})},a.collectibleInfoParams.chainId+a.collectibleInfoParams.address+a.collectibleInfoParams.tokenId)),r&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})})]}),W.jsxs(xe,{width:"full",flexDirection:"column",alignItems:"center",justifyContent:"center",marginBottom:"4",children:[s&&W.jsx(vFe,{onClose:()=>o(!1)}),W.jsx(Zt,{label:"Import collectible",leftIcon:UH,variant:"primary",size:"md",shape:"square",onClick:()=>{o(!0)}})]})]})}function yFe({onClose:t}){const e=Ir(Nn),r=h8(),[n,i]=D.useState(),[s,o]=D.useState(),[a,c]=D.useState(),[l,f]=D.useState(),[u,p]=D.useState(),[g,y]=D.useState(),b=async()=>{n&&s&&a&&l&&await e.addNetwork({chainId:Number(n),name:s,title:s,type:Ft.MAINNET,rpcUrl:a,blockExplorer:{rootUrl:l},nativeToken:{name:u||"Ether",symbol:g||"ETH",decimals:18}})},I=()=>{i(void 0),o(void 0),c(void 0),f(void 0),p(void 0),y(void 0)};return W.jsxs(xe,{flexDirection:"column",width:"full",marginTop:"4",gap:"4",children:[W.jsx(Wn,{width:"full",label:"Chain ID",labelLocation:"left",name:"chainId",value:n??"",onChange:C=>{i(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Network Name",labelLocation:"left",name:"networkName",value:s??"",onChange:C=>{o(C.target.value)}}),W.jsx(Wn,{width:"full",label:"RPC URL",labelLocation:"left",name:"rpcUrl",value:a??"",onChange:C=>{c(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Block explorer URL",labelLocation:"left",name:"rpcUrl",value:l??"",onChange:C=>{f(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Native Token Name",labelLocation:"left",name:"tokenName",value:u??"",onChange:C=>{p(C.target.value)}}),W.jsx(Wn,{width:"full",label:"Native Token Symbol",labelLocation:"left",name:"tokenSymbol",value:g??"",onChange:C=>{y(C.target.value)}}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",onClick:()=>{I(),t()}}),W.jsx(Zt,{label:"Add",variant:"primary",size:"md",shape:"square",onClick:async()=>{try{await b(),r({variant:"success",title:"Network added",description:`You can now use ${s} network`}),I(),t()}catch(C){r({variant:"error",title:"Could not add network",description:C.message}),console.error(C)}}})]})]})}function R$({network:t}){var f,u;const e=Ir(Nn),n=yn(e.userAdditionNetworkChainIds).includes(t.chainId);D.useEffect(()=>{var p,g;(s!==t.rpcUrl||a!==((p=t.blockExplorer)==null?void 0:p.rootUrl))&&(o(t.rpcUrl),c(((g=t.blockExplorer)==null?void 0:g.rootUrl)??""))},[t]);const i=e.editedNetworkChainIds.get().includes(t.chainId),[s,o]=D.useState(t.rpcUrl),[a,c]=D.useState(((f=t.blockExplorer)==null?void 0:f.rootUrl)??""),l=s!==t.rpcUrl||a!==((u=t.blockExplorer)==null?void 0:u.rootUrl);return W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Ge,{fontWeight:"bold",color:"text100",children:t.title}),W.jsx(Wn,{label:"RPC URL",labelLocation:"left",name:"rpcUrl",spellCheck:!1,disabled:n,value:s??"",onChange:p=>{o(p.target.value)}}),W.jsx(Wn,{label:"Block Explorer URL",labelLocation:"left",name:"blockExplorerUrl",spellCheck:!1,disabled:n,value:a??"",onChange:p=>{c(p.target.value)}}),n&&W.jsxs(xe,{marginTop:"4",alignItems:"center",justifyContent:"flex-end",gap:"5",children:[W.jsx(Ge,{variant:"small",color:"text50",children:"Added by you"}),W.jsx(Zt,{label:"Remove",variant:"danger",size:"md",shape:"square",onClick:()=>e.removeNetwork(t.chainId)})]}),(l||i)&&!n&&W.jsxs(xe,{marginTop:"4",justifyContent:"flex-end",gap:"3",children:[W.jsx(W.Fragment,{children:i&&W.jsx(Zt,{label:"Reset to default",variant:"danger",size:"md",shape:"square",onClick:()=>e.resetNetworkEdit(t.chainId)})}),W.jsx(W.Fragment,{children:l&&W.jsx(Zt,{label:"Save",variant:"primary",size:"md",shape:"square",onClick:()=>{const p=t;p.rpcUrl=s,p.blockExplorer={rootUrl:a},p.relayer=_3(s),e.editNetwork(p)}})})]}),W.jsx(Sh,{})]})}function mFe(){const t=Ir(Nn),e=yn(t.networks),r=e.filter(f=>f.type===Ft.MAINNET),n=yn(t.userAdditionNetworkChainIds),i=r.sort((f,u)=>n.includes(f.chainId)?-1:1),s=e.filter(f=>f.type===Ft.TESTNET),[o,a]=D.useState(Ft.MAINNET),[c,l]=D.useState(!1);return W.jsxs(xe,{flexDirection:"column",paddingY:"4",paddingX:"8",background:"backgroundPrimary",width:"full",height:"full",alignItems:"center",children:[W.jsx(xe,{children:W.jsx(Ge,{variant:"large",color:"text80",children:"Networks"})}),W.jsx(xe,{width:"full",marginTop:"4",paddingBottom:"4",children:W.jsxs(vwe,{value:o,onValueChange:f=>a(f),children:[W.jsx(xe,{marginBottom:"10",children:W.jsx(pwe,{value:o,tabs:[{label:"Networks",value:Ft.MAINNET},{label:"Test Networks",value:Ft.TESTNET}]})}),W.jsx(HB,{value:Ft.MAINNET,children:W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsxs(xe,{width:"full",flexDirection:"column",alignItems:"flex-end",marginY:"4",children:[W.jsx(Zt,{label:"Add network",variant:"primary",size:"md",shape:"square",onClick:()=>{l(!0)}}),c&&W.jsx(yFe,{onClose:()=>l(!1)})]}),W.jsx(W.Fragment,{children:i.map((f,u)=>W.jsx(R$,{network:f},u))})]})}),W.jsx(HB,{value:Ft.TESTNET,children:W.jsx(xe,{flexDirection:"column",gap:"2",children:s.map((f,u)=>W.jsx(R$,{network:f},u))})})]})})]})}function lS({symbol:t,chainId:e,to:r,amount:n}){return W.jsxs(xe,{flexDirection:"column",width:"full",gap:"4",children:[W.jsx(Ge,{variant:"large",color:"text80",children:"Pending transaction"}),W.jsxs(xe,{background:"backgroundMuted",flexDirection:"row",width:"full",height:"fit",borderRadius:"sm",paddingX:"4",paddingY:"2",alignItems:"center",gap:"5",children:[W.jsx(lh,{size:"md"}),W.jsxs(xe,{flexDirection:"column",gap:"1",children:[W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"1",children:[W.jsxs(Ge,{variant:"small",color:"text100",children:["Sending ",n," ",t," on"]}),W.jsx(BE,{chainId:e,paddingTop:"0",paddingBottom:"1"}),W.jsxs(Ge,{variant:"small",color:"text80",children:["to ",r]})]}),W.jsx(Ge,{variant:"small",color:"text50",children:"Your external wallet will prompt you to confirm the transaction"})]})]})]})}function bFe({onSelectProvider:t}){const e=Ir(NE),r=jte(),[n,i]=D.useState(!1),s=()=>window.confirm("All WalletConnect Dapp sessions will be disconnected. If you would like to continue, click OK and connect to WalletConnect again."),o=async()=>{try{if(!n){if(e.allSessions.get().length!==0){if(!s())throw new Error("User rejected wallet connect modal");await e.disconnectAllSessions(),t();return}i(!0);const a=await Fte(!0);await a.connect();let c=hre(a);t(c)}}catch(a){console.error(a)}};return W.jsx(W.Fragment,{children:!n&&W.jsxs(xe,{flexDirection:"column",paddingY:"5",alignItems:"center",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:"Select an external wallet to send transactions"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs(xe,{flexDirection:"column",gap:"4",padding:"8",children:[W.jsx($r,{flexDirection:"row",alignItems:"center",gap:"2",cursor:"pointer",background:{base:"buttonGlass",hover:"backgroundSecondary"},onClick:()=>{o()},children:W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"2",children:[W.jsx("img",{src:"https://avatars.githubusercontent.com/u/37784886",alt:"Wallet Connect",style:{width:"20px",height:"20px"}}),W.jsx(Ge,{variant:"normal",color:"text100",children:"Wallet Connect"})]})}),r.map(a=>W.jsx($r,{flexDirection:"row",alignItems:"center",gap:"2",cursor:"pointer",background:{base:"buttonGlass",hover:"backgroundSecondary"},onClick:()=>t(a),children:W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"2",children:[W.jsx("img",{src:a.info.icon,alt:a.info.name,style:{width:"20px",height:"20px"}}),W.jsx(Ge,{variant:"normal",color:"text100",children:a.info.name})]})},a.info.uuid))]})]})})}function wFe({collectibleInfo:t,onClose:e}){var y,b,I;const r=KP("isMobile"),n=Ir(Zr),[i,s]=D.useState(void 0),[o,a]=D.useState(void 0),[c,l]=D.useState(!1),[f,u]=D.useState(!1);if(D.useEffect(()=>{const C=n.selectedExternalWalletAddress.get();c&&C&&a(n.selectedExternalWalletAddress.get())},[c]),D.useEffect(()=>{u(n.selectedExternalWalletAddress.get()!==void 0)},[n.selectedExternalWalletAddress]),!t)return null;const p=t.collectibleInfoParams.contractType==="ERC721",g=ky(t.collectibleInfoParams.chainId);return W.jsxs(xe,{flexDirection:"column",paddingY:"5",alignItems:"center",children:[W.jsxs(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:["Sending ",(y=t==null?void 0:t.collectibleInfoResponse)==null?void 0:y.name," on ",g]}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs(xe,{style:{minWidth:r?"100vw":"520px"},paddingX:"6",flexDirection:"column",gap:"4",width:"full",marginTop:"6",children:[W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Wn,{label:"Amount",labelLocation:"top",name:"amount",placeholder:"Enter amount",value:p?"1":i??"",onChange:C=>{s(C.target.value)},disabled:p,controls:W.jsx(W.Fragment,{children:t.collectibleInfoParams.contractType==="ERC1155"&&W.jsx(Zt,{label:"Max",variant:"text",size:"md",shape:"square",paddingRight:"2",onClick:()=>{var C,S;s(fh((C=t==null?void 0:t.collectibleInfoResponse)==null?void 0:C.balance,((S=t==null?void 0:t.collectibleInfoResponse)==null?void 0:S.decimals)??18))}})})}),W.jsxs(Ge,{variant:"small",color:"text50",children:["Current balance:"," ",fh((b=t==null?void 0:t.collectibleInfoResponse)==null?void 0:b.balance,((I=t==null?void 0:t.collectibleInfoResponse)==null?void 0:I.decimals)??18)]})]}),W.jsxs(xe,{flexDirection:"column",gap:"3",children:[W.jsx(Wn,{label:"To",labelLocation:"top",name:"to",placeholder:"0x...",value:o??"",onChange:C=>{a(C.target.value)},disabled:c}),W.jsx(eP,{label:f?"Send to connected external wallet address":"Connect external wallet to autofill address",checked:c,onCheckedChange:C=>l(C===!0),labelLocation:"right",disabled:!f})]}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",onClick:()=>{e()}}),W.jsx(Zt,{label:"Send",variant:"primary",size:"md",shape:"square",disabled:!(p&&o||!p&&o&&i),onClick:()=>{e(o,i)}})]})]})]})}function xFe({tokenBalance:t,onClose:e}){var g,y;const r=KP("isMobile"),n=Ir(Zr),[i,s]=D.useState(void 0),[o,a]=D.useState(void 0),[c,l]=D.useState(!1),[f,u]=D.useState(!1);if(D.useEffect(()=>{const b=n.selectedExternalWalletAddress.get();c&&b&&a(n.selectedExternalWalletAddress.get())},[c]),D.useEffect(()=>{u(n.selectedExternalWalletAddress.get()!==void 0)},[n.selectedExternalWalletAddress]),!t)return null;const p=ky(t.chainId);return W.jsxs(xe,{flexDirection:"column",paddingY:"5",alignItems:"center",children:[W.jsxs(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:["Sending ",(g=t==null?void 0:t.contractInfo)==null?void 0:g.symbol," on ",p]}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs(xe,{style:{minWidth:r?"100vw":"520px"},paddingX:"6",flexDirection:"column",gap:"4",width:"full",marginTop:"6",children:[W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Wn,{label:"Amount",labelLocation:"top",name:"amount",placeholder:"Enter amount",value:i??"",onChange:b=>{s(b.target.value)},controls:W.jsx(Zt,{label:"Max",variant:"text",size:"md",shape:"square",paddingRight:"2",onClick:()=>{var b;s(fh(t==null?void 0:t.balance,((b=t==null?void 0:t.contractInfo)==null?void 0:b.decimals)??18))}})}),W.jsxs(Ge,{variant:"small",color:"text50",children:["Current balance:"," ",fh(t==null?void 0:t.balance,((y=t==null?void 0:t.contractInfo)==null?void 0:y.decimals)??18)]})]}),W.jsxs(xe,{flexDirection:"column",gap:"3",children:[W.jsx(Wn,{label:"To",labelLocation:"top",name:"to",placeholder:"0x...",value:o??"",onChange:b=>{a(b.target.value)},disabled:c}),W.jsx(eP,{label:f?"Send to connected external wallet address":"Connect external wallet to autofill address",checked:c,onCheckedChange:b=>l(b===!0),labelLocation:"right",disabled:!f})]}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",onClick:()=>{e()}}),W.jsx(Zt,{label:"Send",variant:"primary",size:"md",shape:"square",disabled:!o||!i,onClick:()=>{o&&i&&e(o,i)}})]})]})]})}function EFe({onTokenListClick:t}){const e=Ir(li),r=rk();return W.jsxs(Kye,{children:[W.jsx(Zt,{as:Yye,label:"Settings",variant:"text"}),W.jsx(Qye,{side:"bottom",align:"end",sideOffset:20,children:W.jsxs(xe,{marginTop:"2",children:[W.jsx(HA,{onClick:t,children:W.jsx(xe,{padding:"1",children:W.jsx(Ge,{variant:"normal",fontWeight:"bold",children:"Token List"})})}),W.jsx(HA,{disabled:!0,children:W.jsx(xe,{width:"16",children:W.jsx(Sh,{color:"white"})})}),W.jsx(HA,{onClick:()=>{e.logout(),r("/")},children:W.jsx(xe,{padding:"1",children:W.jsx(Ge,{variant:"normal",fontWeight:"bold",children:"Log out"})})})]})})]})}function CFe(){const t=Ir(Tx),e=yn(t.userAddedTokens);return W.jsxs(xe,{flexDirection:"column",paddingY:"4",paddingX:"8",background:"backgroundPrimary",width:"full",height:"full",alignItems:"center",children:[W.jsxs(xe,{flexDirection:"column",alignItems:"center",gap:"4",marginBottom:"4",children:[W.jsx(Ge,{variant:"large",color:"text80",children:"Token List"}),W.jsx(Ge,{variant:"normal",color:"text50",children:"Tokens added by you can be removed here"})]}),W.jsxs(xe,{width:"full",height:"full",flexDirection:"column",marginTop:"4",paddingBottom:"12",gap:"4",children:[e.length===0&&W.jsx(xe,{height:"full",alignItems:"center",justifyContent:"center",children:W.jsx(Ge,{variant:"medium",color:"text50",marginBottom:"16",children:"You haven't added any tokens yet"})}),e.map((r,n)=>W.jsxs($r,{width:"full",flexDirection:"row",gap:"2",alignItems:"center",children:[W.jsxs(xe,{flexDirection:"column",gap:"2",children:[W.jsx(Ge,{variant:"medium",color:"text80",children:r.symbol}),W.jsx(Ge,{variant:"normal",color:"text50",children:r.address}),W.jsx(BE,{chainId:r.chainId})]}),W.jsx(xe,{marginLeft:"auto",children:W.jsx(Zt,{label:"Remove",variant:"danger",size:"md",shape:"square",onClick:()=>{t.removeToken(r)}})})]},n))]})]})}function AFe({onClose:t}){const r=Ir(Nn).networks.get(),n=r.filter(S=>S.type===Ft.MAINNET),i=Ir(Tx),s=yn(i.isFetchingTokenInfo),o=h8(),[a,c]=D.useState(),[l,f]=D.useState(),[u,p]=D.useState(),[g,y]=D.useState(!1);D.useEffect(()=>{a&&l?i.getTokenInfo(a.chainId,l).then(S=>{p(S)}):p(void 0)},[a,l]);const b=n.map(S=>({label:S.title,value:S.chainId.toString()})),I=async()=>{a&&l&&u&&(y(!0),await i.addToken({chainId:a.chainId,address:l,contractType:hh.ERC20,symbol:u.symbol,decimals:u.decimals}),y(!1),o({variant:"success",title:"Token added"}),C(),t())},C=()=>{f(void 0),c(void 0)};return W.jsxs($r,{flexDirection:"column",paddingY:"4",paddingX:"8",borderRadius:"md",width:"full",height:"full",alignItems:"center",disabled:g,children:[W.jsx(xe,{children:W.jsx(Ge,{variant:"medium",color:"text80",children:"Import ERC20 Token"})}),W.jsxs(xe,{flexDirection:"column",width:"full",marginTop:"4",gap:"4",children:[W.jsx(M7,{label:"Token Network",labelLocation:"left",name:"tokenNetwork",options:b,onValueChange:S=>c(r.find(O=>O.chainId===Number(S)))}),W.jsx(Wn,{width:"full",label:"Token Address",labelLocation:"left",name:"tokenAddress",value:l??"",onChange:S=>{f(S.target.value)}}),s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})}),u&&W.jsxs(W.Fragment,{children:[W.jsx(Wn,{width:"full",label:"Token Symbol",labelLocation:"left",name:"tokenSymbol",value:(u==null?void 0:u.symbol)??"",disabled:!0}),W.jsx(Wn,{width:"full",label:"Token Decimals",labelLocation:"left",name:"tokenDecimals",value:(u==null?void 0:u.decimals)??"",disabled:!0})]}),W.jsxs(xe,{alignItems:"center",justifyContent:"flex-end",gap:"8",marginTop:"4",children:[W.jsx(Zt,{label:"Cancel",variant:"text",size:"md",shape:"square",disabled:g,onClick:()=>{C(),t()}}),W.jsx(Zt,{label:"Add",disabled:u===void 0||g,variant:"primary",size:"md",shape:"square",onClick:I})]})]})]})}const SFe=(t,e)=>Math.floor(t*10**e)/10**e;function _Fe({disabled:t,tokenBalance:e,onSendClick:r,onRemoveClick:n}){var o,a;const i=fh(e.balance,((o=e.contractInfo)==null?void 0:o.decimals)??18),s=SFe(Number(i),5);return W.jsxs($r,{width:"full",flexDirection:"column",gap:"2",children:[W.jsxs(xe,{flexDirection:"row",alignItems:"center",children:[W.jsx(Ge,{variant:"medium",color:"text80",children:((a=e.contractInfo)==null?void 0:a.symbol)??"Native Token"}),W.jsx(xe,{marginLeft:"auto",children:W.jsx(Ge,{color:"text80",children:s})})]}),W.jsxs(xe,{flexDirection:"row",children:[W.jsx(BE,{chainId:e.chainId}),W.jsxs(xe,{marginLeft:"auto",gap:"2",children:[W.jsx(Zt,{size:"xs",label:"Send",variant:"primary",shape:"square",disabled:t,onClick:r}),n&&W.jsx(Zt,{size:"xs",label:"Remove",shape:"square",onClick:n})]})]})]})}function IFe({filterZeroBalances:t,onSendClick:e}){const r=Ir(Zr),n=Ir(Tx),i=yn(n.balances),s=yn(n.isFetchingBalances),o=yn(r.selectedExternalProvider)!==void 0,a=D.useMemo(()=>t?i.filter(u=>u.balance!=="0"):i,[i,t,s]),[c,l]=D.useState(!1),f=u=>u.contractType===hh.NATIVE?void 0:()=>{var p,g;n.removeToken({chainId:u.chainId,address:u.contractAddress,contractType:u.contractType,decimals:(p=u.contractInfo)==null?void 0:p.decimals,symbol:(g=u.contractInfo)==null?void 0:g.symbol})};return W.jsxs(W.Fragment,{children:[W.jsxs(xe,{width:"full",flexDirection:"column",gap:"4",marginBottom:"8",children:[a.map(u=>W.jsx(_Fe,{tokenBalance:u,disabled:!o,onSendClick:()=>e(u),onRemoveClick:f(u)},u.contractAddress+u.chainId)),s&&W.jsx(xe,{marginTop:"4",alignItems:"center",justifyContent:"center",children:W.jsx(lh,{size:"lg"})})]}),c&&W.jsx(AFe,{onClose:()=>l(!1)}),!c&&W.jsx(xe,{width:"full",alignItems:"center",justifyContent:"center",marginBottom:"4",children:W.jsx(Zt,{label:"Import token",leftIcon:UH,variant:"primary",size:"md",shape:"square",onClick:()=>{l(!0)}})})]})}function TFe({onClose:t}){var a;const e=Ir(Zr),r=yn(e.connectOptions),[n,i]=D.useState(!1),s=async()=>{if(n)return;i(!0);const c=await e.walletRequestHandler.connect(r);e.connectDetails.set(c),i(!1),t()},o=()=>{e.connectDetails.set({connected:!1}),t()};return W.jsx(xe,{children:r&&W.jsxs(xe,{flexDirection:"column",padding:"10",alignItems:"center",gap:"4",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"16",paddingBottom:"1",children:"Would you like to allow this dapp to connect to your wallet?"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[W.jsx(Ge,{variant:"md",color:"text100",children:r.app}),W.jsxs(xe,{flexDirection:"row",alignItems:"center",gap:"3",children:[W.jsx(Ge,{variant:"md",color:"text100",children:(a=r.origin)==null?void 0:a.split("//")[1]}),W.jsx(yu,{size:"xs",icon:J4,onClick:()=>window.open(r.origin,"_blank")})]})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Network"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${ky(Number(r.networkId))}`})]}),W.jsxs(xe,{flexDirection:{sm:"column",md:"row"},gap:"2",width:"full",marginTop:"6",children:[W.jsx(Zt,{width:"full",label:"Cancel",onClick:o,"data-id":"signingCancel"}),W.jsx(Zt,{width:"full",variant:"primary",label:n?"Authorizing…":"Connect",disabled:n,onClick:s,"data-id":"signingContinue"})]})]})})}function PFe({sessionList:t}){const e=Ir(NE);return W.jsxs(xe,{flexDirection:"column",gap:"2",children:[t.length!==0&&W.jsx(Ge,{variant:"large",color:"text80",marginTop:"6",marginBottom:"2",children:"Connected Dapps via WalletConnect"}),t.map((r,n)=>W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"2",padding:"2",children:[W.jsx(a8,{width:"8",height:"8",src:r.peer.metadata.icons[0]}),W.jsx(Ge,{variant:"normal",fontWeight:"bold",color:"text100",children:r.peer.metadata.name}),W.jsxs(xe,{gap:"2",children:[r.peer.metadata.url&&W.jsx(yu,{size:"xs",icon:J4,onClick:()=>window.open(r.peer.metadata.url,"_blank")}),W.jsx(yu,{size:"xs",icon:Vg,onClick:()=>{e.disconnectSession(r.topic)}})]})]},n))]})}function kFe({onClose:t}){var l,f;const e=Ir(Zr),r=Ir(li),n=e.toSignMsgDetails.get(),i=r.accountAddress.get(),[s,o]=D.useState(""),[a,c]=D.useState("");return D.useEffect(()=>{if(console.log("details",n),c(new Date().toLocaleString()),n!=null&&n.message.message){const u=XLe(n.message.message);try{o(Ip(u))}catch{o(Me(u))}}else n!=null&&n.message.typedData&&o(JSON.stringify(n.message.typedData,void 0,4))},[n]),W.jsx(xe,{children:n&&W.jsxs(xe,{flexDirection:"column",padding:"10",alignItems:"center",gap:"4",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",children:"Would you like to sign this message?"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Requested at"}),W.jsx(Ge,{variant:"md",color:"text100",children:a})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Origin"}),W.jsxs(xe,{alignItems:"center",gap:"3",children:[W.jsx(Ge,{variant:"md",color:"text100",children:(f=(l=n==null?void 0:n.options)==null?void 0:l.origin)==null?void 0:f.split("//")[1]}),W.jsx(yu,{size:"xs",icon:J4,onClick:()=>{var u;return window.open((u=n.options)==null?void 0:u.origin,"_blank")}})]})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Network"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${ky(n.chainId)}`})]}),W.jsxs($r,{flexDirection:"column",gap:"4",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Signee"}),W.jsx($r,{children:W.jsx(Ge,{variant:"md",color:"text100",children:`${i}`})})]}),W.jsx(GH,{label:"Message Content",children:W.jsx($r,{children:W.jsx(Ge,{variant:"code",color:"text80",style:{overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:s})})}),W.jsxs(xe,{flexDirection:{sm:"column",md:"row"},gap:"2",width:"full",marginTop:"10",children:[W.jsx(Zt,{width:"full",label:"Cancel",onClick:()=>{t()},"data-id":"signingCancel"}),W.jsx(Zt,{width:"full",variant:"primary",label:"Send",onClick:()=>{t(n)},"data-id":"signingContinue"})]})]})})}function MFe({onClose:t}){var I,C;const e=Ir(Zr),r=Ir(Nn),n=Ir(YM),[i,s]=D.useState("Unknown"),[o,a]=D.useState(null),[c,l]=D.useState({name:null}),[f,u]=D.useState(null),[p,g]=D.useState(""),y=e.toSignTxnDetails.get();D.useEffect(()=>{if(!y)return;g(new Date().toLocaleString());const S=r.providerForChainId(y.chainId??0),O=y.txn[0].data,L=y.txn[0].to;b(O,L,S)},[y]),D.useEffect(()=>{if(!y||!(y!=null&&y.txn[0].to)||!o)return;const S=y.txn[0].to,O={chainId:y.chainId,address:S,tokenId:o,contractType:i};n.getCollectibleInfo(O)},[i,o]);async function b(S,O,L){try{const F=new Dn(O,jv,L);try{const ie=await F.symbol();s("ERC20"),l({name:ie});const K=new $i(jv).parseTransaction({data:S}),P=await F.decimals();u(Number(fh(K==null?void 0:K.args[1],P??18)));return}catch{}const z=new Dn(O,C9e,L);if(await z.supportsInterface("0x80ac58cd")){s("ERC721");const ie=new Dn(O,hM,L),K=ie.interface.decodeFunctionData("safeTransferFrom",S).tokenId.toString();a(K);const P=await ie.name();l({name:P});return}if(await z.supportsInterface("0xd9b67a26")){s("ERC1155");const ie=new Dn(O,pM,L),K=ie.interface.decodeFunctionData("safeTransferFrom",S).id.toString();a(K);const P=await ie.uri(K);l({name:P});return}}catch(F){console.error("Error parsing contract type. The transaction is either using a smart contract that doesnt support ERC165 or the token is native:",F)}if(y!=null&&y.txn[0].value){s("Native Token"),l({name:`${ky((y==null?void 0:y.chainId)??1)} Native Token`});return}console.info("Token info could not be decoded for this transaction")}return W.jsx(xe,{children:y&&W.jsx(xe,{children:W.jsxs(xe,{flexDirection:"column",padding:"10",gap:"4",children:[W.jsx(Ge,{alignSelf:"center",variant:"md",fontWeight:"bold",color:"text100",children:"Would you like to approve this transaction?"}),W.jsx(Sh,{color:"gradientPrimary",width:"full",height:"px"}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Requested at"}),W.jsx(Ge,{variant:"md",color:"text100",children:p})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Origin"}),W.jsxs(xe,{alignItems:"center",gap:"3",children:[W.jsx(Ge,{variant:"md",color:"text100",children:(C=(I=y==null?void 0:y.options)==null?void 0:I.origin)==null?void 0:C.split("//")[1]}),W.jsx(yu,{size:"xs",icon:J4,onClick:()=>{var S;return window.open((S=y.options)==null?void 0:S.origin,"_blank")}})]})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Token Standard"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${i}`})]}),i==="ERC721"||i==="ERC1155"&&W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Token ID"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${o}`})]}),W.jsxs($r,{flexDirection:"row",justifyContent:"space-between",children:[W.jsx(Ge,{variant:"md",color:"text100",children:"Amount"}),W.jsx(Ge,{variant:"md",color:"text100",children:`${f??0} ${c.name}`})]}),W.jsx(GH,{label:"Transaction Data",children:W.jsx(xe,{flexDirection:"column",gap:"2",children:y.txn.map((S,O)=>W.jsx($r,{children:W.jsx(Ge,{variant:"code",color:"text80",style:{whiteSpace:"pre-wrap"},children:JSON.stringify(S,null,4)||"Native token transfer"})},O))})}),W.jsxs(xe,{flexDirection:{sm:"column",md:"row"},gap:"2",width:"full",marginTop:"10",children:[W.jsx(Zt,{width:"full",label:"Cancel",onClick:()=>{t()},"data-id":"signingCancel"}),W.jsx(Zt,{width:"full",variant:"primary",label:"Send",onClick:()=>{t(y)},"data-id":"signingContinue"})]})]})})})}function RFe({warningType:t}){return W.jsx(xe,{children:W.jsxs(xe,{flexDirection:"column",padding:"10",alignItems:"center",gap:"6",children:[W.jsx(Ge,{variant:"md",fontWeight:"bold",color:"text100",children:"Warning:"}),W.jsx(xe,{flexDirection:"column",children:W.jsx($r,{children:W.jsxs(Ge,{variant:"md",fontWeight:"bold",color:"text100",paddingX:"2",children:[t==="noProvider"&&'Please ensure that an external wallet is connected via the "Connect" button',t==="isWalletConnect"&&"Please switch your external wallet to an option other than WalletConnect",t==="notDeployed"&&"Please deploy our wallet on the required network before trying to sign messages"]})})})]})})}var Ute={},Fo={};Object.defineProperty(Fo,"__esModule",{value:!0});Fo.compactObject=Vte;Fo.deprecated=$Fe;var OFe=Fo.detectBrowser=qFe;Fo.disableLog=FFe;Fo.disableWarnings=jFe;Fo.extractVersion=j3;Fo.filterStats=VFe;Fo.log=UFe;Fo.walkStats=v4;Fo.wrapPeerConnectionEvent=LFe;function DFe(t,e,r){return e=NFe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function NFe(t){var e=BFe(t,"string");return gh(e)=="symbol"?e:e+""}function BFe(t,e){if(gh(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(gh(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gh(t){"@babel/helpers - typeof";return gh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gh(t)}var $te=!0,qte=!0;function j3(t,e,r){var n=t.match(e);return n&&n.length>=r&&parseInt(n[r],10)}function LFe(t,e,r){if(t.RTCPeerConnection){var n=t.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(o,a){if(o!==e)return i.apply(this,arguments);var c=function(f){var u=r(f);u&&(a.handleEvent?a.handleEvent(u):a(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(a,c),i.apply(this,[o,c])};var s=n.removeEventListener;n.removeEventListener=function(o,a){if(o!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(a))return s.apply(this,arguments);var c=this._eventMap[e].get(a);return this._eventMap[e].delete(a),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[o,c])},Object.defineProperty(n,"on"+e,{get:function(){return this["_on"+e]},set:function(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}}function FFe(t){return typeof t!="boolean"?new Error("Argument type: "+gh(t)+". Please use a boolean."):($te=t,t?"adapter.js logging disabled":"adapter.js logging enabled")}function jFe(t){return typeof t!="boolean"?new Error("Argument type: "+gh(t)+". Please use a boolean."):(qte=!t,"adapter.js deprecation warnings "+(t?"disabled":"enabled"))}function UFe(){if((typeof window>"u"?"undefined":gh(window))==="object"){if($te)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function $Fe(t,e){qte&&console.warn(t+" is deprecated, please use "+e+" instead.")}function qFe(t){var e={browser:null,version:null};if(typeof t>"u"||!t.navigator||!t.navigator.userAgent)return e.browser="Not a browser.",e;var r=t.navigator;if(r.userAgentData&&r.userAgentData.brands){var n=r.userAgentData.brands.find(function(i){return i.brand==="Chromium"});if(n)return{browser:"chrome",version:parseInt(n.version,10)}}if(r.mozGetUserMedia)e.browser="firefox",e.version=j3(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||t.isSecureContext===!1&&t.webkitRTCPeerConnection)e.browser="chrome",e.version=j3(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.RTCPeerConnection&&r.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=j3(r.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=t.RTCRtpTransceiver&&"currentDirection"in t.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function O$(t){return Object.prototype.toString.call(t)==="[object Object]"}function Vte(t){return O$(t)?Object.keys(t).reduce(function(e,r){var n=O$(t[r]),i=n?Vte(t[r]):t[r],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,DFe({},r,i))},{}):t}function v4(t,e,r){!e||r.has(e.id)||(r.set(e.id,e),Object.keys(e).forEach(function(n){n.endsWith("Id")?v4(t,t.get(e[n]),r):n.endsWith("Ids")&&e[n].forEach(function(i){v4(t,t.get(i),r)})}))}function VFe(t,e,r){var n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;var s=[];return t.forEach(function(o){o.type==="track"&&o.trackIdentifier===e.id&&s.push(o)}),s.forEach(function(o){t.forEach(function(a){a.type===n&&a.trackId===o.id&&v4(t,a,i)})}),i}Object.defineProperty(Ute,"__esModule",{value:!0});var zFe=Ute.shimGetUserMedia=WFe,HFe=GFe(Fo);function zte(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(zte=function(i){return i?r:e})(t)}function GFe(t,e){if(t&&t.__esModule)return t;if(t===null||gd(t)!="object"&&typeof t!="function")return{default:t};var r=zte(e);if(r&&r.has(t))return r.get(t);var n={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&{}.hasOwnProperty.call(t,s)){var o=i?Object.getOwnPropertyDescriptor(t,s):null;o&&(o.get||o.set)?Object.defineProperty(n,s,o):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}function gd(t){"@babel/helpers - typeof";return gd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gd(t)}var D$=HFe.log;function WFe(t,e){var r=t&&t.navigator;if(r.mediaDevices){var n=function(l){if(gd(l)!=="object"||l.mandatory||l.optional)return l;var f={};return Object.keys(l).forEach(function(u){if(!(u==="require"||u==="advanced"||u==="mediaSource")){var p=gd(l[u])==="object"?l[u]:{ideal:l[u]};p.exact!==void 0&&typeof p.exact=="number"&&(p.min=p.max=p.exact);var g=function(I,C){return I?I+C.charAt(0).toUpperCase()+C.slice(1):C==="deviceId"?"sourceId":C};if(p.ideal!==void 0){f.optional=f.optional||[];var y={};typeof p.ideal=="number"?(y[g("min",u)]=p.ideal,f.optional.push(y),y={},y[g("max",u)]=p.ideal,f.optional.push(y)):(y[g("",u)]=p.ideal,f.optional.push(y))}p.exact!==void 0&&typeof p.exact!="number"?(f.mandatory=f.mandatory||{},f.mandatory[g("",u)]=p.exact):["min","max"].forEach(function(b){p[b]!==void 0&&(f.mandatory=f.mandatory||{},f.mandatory[g(b,u)]=p[b])})}}),l.advanced&&(f.optional=(f.optional||[]).concat(l.advanced)),f},i=function(l,f){if(e.version>=61)return f(l);if(l=JSON.parse(JSON.stringify(l)),l&&gd(l.audio)==="object"){var u=function(I,C,S){C in I&&!(S in I)&&(I[S]=I[C],delete I[C])};l=JSON.parse(JSON.stringify(l)),u(l.audio,"autoGainControl","googAutoGainControl"),u(l.audio,"noiseSuppression","googNoiseSuppression"),l.audio=n(l.audio)}if(l&&gd(l.video)==="object"){var p=l.video.facingMode;p=p&&(gd(p)==="object"?p:{ideal:p});var g=e.version<66;if(p&&(p.exact==="user"||p.exact==="environment"||p.ideal==="user"||p.ideal==="environment")&&!(r.mediaDevices.getSupportedConstraints&&r.mediaDevices.getSupportedConstraints().facingMode&&!g)){delete l.video.facingMode;var y;if(p.exact==="environment"||p.ideal==="environment"?y=["back","rear"]:(p.exact==="user"||p.ideal==="user")&&(y=["front"]),y)return r.mediaDevices.enumerateDevices().then(function(b){b=b.filter(function(C){return C.kind==="videoinput"});var I=b.find(function(C){return y.some(function(S){return C.label.toLowerCase().includes(S)})});return!I&&b.length&&y.includes("back")&&(I=b[b.length-1]),I&&(l.video.deviceId=p.exact?{exact:I.deviceId}:{ideal:I.deviceId}),l.video=n(l.video),D$("chrome: "+JSON.stringify(l)),f(l)})}l.video=n(l.video)}return D$("chrome: "+JSON.stringify(l)),f(l)},s=function(l){return e.version>=64?l:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[l.name]||l.name,message:l.message,constraint:l.constraint||l.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},o=function(l,f,u){i(l,function(p){r.webkitGetUserMedia(p,f,function(g){u&&u(s(g))})})};if(r.getUserMedia=o.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(c){return i(c,function(l){return a(l).then(function(f){if(l.audio&&!f.getAudioTracks().length||l.video&&!f.getVideoTracks().length)throw f.getTracks().forEach(function(u){u.stop()}),new DOMException("","NotFoundError");return f},function(f){return Promise.reject(s(f))})})}}}}var Hte={};Object.defineProperty(Hte,"__esModule",{value:!0});var KFe=Hte.shimGetUserMedia=JFe,YFe=QFe(Fo);function Gte(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Gte=function(i){return i?r:e})(t)}function QFe(t,e){if(t&&t.__esModule)return t;if(t===null||Hv(t)!="object"&&typeof t!="function")return{default:t};var r=Gte(e);if(r&&r.has(t))return r.get(t);var n={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&{}.hasOwnProperty.call(t,s)){var o=i?Object.getOwnPropertyDescriptor(t,s):null;o&&(o.get||o.set)?Object.defineProperty(n,s,o):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}function Hv(t){"@babel/helpers - typeof";return Hv=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hv(t)}function JFe(t,e){var r=t&&t.navigator,n=t&&t.MediaStreamTrack;if(r.getUserMedia=function(c,l,f){YFe.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(c).then(l,f)},!(e.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(l,f,u){f in l&&!(u in l)&&(l[u]=l[f],delete l[f])},s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(c){return Hv(c)==="object"&&Hv(c.audio)==="object"&&(c=JSON.parse(JSON.stringify(c)),i(c.audio,"autoGainControl","mozAutoGainControl"),i(c.audio,"noiseSuppression","mozNoiseSuppression")),s(c)},n&&n.prototype.getSettings){var o=n.prototype.getSettings;n.prototype.getSettings=function(){var c=o.apply(this,arguments);return i(c,"mozAutoGainControl","autoGainControl"),i(c,"mozNoiseSuppression","noiseSuppression"),c}}if(n&&n.prototype.applyConstraints){var a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(c){return this.kind==="audio"&&Hv(c)==="object"&&(c=JSON.parse(JSON.stringify(c)),i(c,"autoGainControl","mozAutoGainControl"),i(c,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[c])}}}}var af={};Object.defineProperty(af,"__esModule",{value:!0});af.shimAudioContext=aje;af.shimCallbacksAPI=rje;af.shimConstraints=Yte;af.shimCreateOfferLegacy=oje;var ZFe=af.shimGetUserMedia=nje;af.shimLocalStreamsAPI=eje;af.shimRTCIceServerUrls=ije;af.shimRemoteStreamsAPI=tje;af.shimTrackEventTransceiver=sje;var Wte=XFe(Fo);function Kte(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Kte=function(i){return i?r:e})(t)}function XFe(t,e){if(t&&t.__esModule)return t;if(t===null||yh(t)!="object"&&typeof t!="function")return{default:t};var r=Kte(e);if(r&&r.has(t))return r.get(t);var n={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(s!=="default"&&{}.hasOwnProperty.call(t,s)){var o=i?Object.getOwnPropertyDescriptor(t,s):null;o&&(o.get||o.set)?Object.defineProperty(n,s,o):n[s]=t[s]}return n.default=t,r&&r.set(t,n),n}function yh(t){"@babel/helpers - typeof";return yh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yh(t)}function eje(t){if(!(yh(t)!=="object"||!t.RTCPeerConnection)){if("getLocalStreams"in t.RTCPeerConnection.prototype||(t.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in t.RTCPeerConnection.prototype)){var e=t.RTCPeerConnection.prototype.addTrack;t.RTCPeerConnection.prototype.addStream=function(n){var i=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(function(s){return e.call(i,s,n)}),n.getVideoTracks().forEach(function(s){return e.call(i,s,n)})},t.RTCPeerConnection.prototype.addTrack=function(n){for(var i=this,s=arguments.length,o=new Array(s>1?s-1:0),a=1;a=0)){n._remoteStreams.push(s);var o=new Event("addstream");o.stream=s,n.dispatchEvent(o)}})}),e.apply(n,arguments)}}}function rje(t){if(!(yh(t)!=="object"||!t.RTCPeerConnection)){var e=t.RTCPeerConnection.prototype,r=e.createOffer,n=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,o=e.addIceCandidate;e.createOffer=function(l,f){var u=arguments.length>=2?arguments[2]:arguments[0],p=r.apply(this,[u]);return f?(p.then(l,f),Promise.resolve()):p},e.createAnswer=function(l,f){var u=arguments.length>=2?arguments[2]:arguments[0],p=n.apply(this,[u]);return f?(p.then(l,f),Promise.resolve()):p};var a=function(l,f,u){var p=i.apply(this,[l]);return u?(p.then(f,u),Promise.resolve()):p};e.setLocalDescription=a,a=function(l,f,u){var p=s.apply(this,[l]);return u?(p.then(f,u),Promise.resolve()):p},e.setRemoteDescription=a,a=function(l,f,u){var p=o.apply(this,[l]);return u?(p.then(f,u),Promise.resolve()):p},e.addIceCandidate=a}}function nje(t){var e=t&&t.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){var r=e.mediaDevices,n=r.getUserMedia.bind(r);e.mediaDevices.getUserMedia=function(i){return n(Yte(i))}}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(s,o,a){e.mediaDevices.getUserMedia(s).then(o,a)}).bind(e))}function Yte(t){return t&&t.video!==void 0?Object.assign({},t,{video:Wte.compactObject(t.video)}):t}function ije(t){if(t.RTCPeerConnection){var e=t.RTCPeerConnection;t.RTCPeerConnection=function(n,i){if(n&&n.iceServers){for(var s=[],o=0;o{throw TypeError(t)},Jte=(t,e,r)=>e.has(t)||Qte("Cannot "+r),cje=(t,e,r)=>(Jte(t,e,"read from private field"),r?r.call(t):e.get(t)),lje=(t,e,r)=>e.has(t)?Qte("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),fje=(t,e,r,n)=>(Jte(t,e,"write to private field"),e.set(t,r),r);const N$=["Aztec","Codabar","Code128","Code39","Code93","DataBar","DataBarExpanded","DataMatrix","DXFilmEdge","EAN-13","EAN-8","ITF","Linear-Codes","Matrix-Codes","MaxiCode","MicroQRCode","None","PDF417","QRCode","rMQRCode","UPC-A","UPC-E"];function uje(t){return t.join("|")}function dje(t){const e=B$(t);let r=0,n=N$.length-1;for(;r<=n;){const i=Math.floor((r+n)/2),s=N$[i],o=B$(s);if(o===e)return s;o{const r=t.match(/_(.+?)\.wasm$/);return r?`https://fastly.jsdelivr.net/npm/zxing-wasm@1.2.15/dist/${r[1]}/${t}`:e+t}};let L$=new WeakMap;function QM(t,e){var r;const n=L$.get(t);if(n!=null&&n.modulePromise&&e===void 0)return n.modulePromise;const i=(r=n==null?void 0:n.moduleOverrides)!=null?r:bje,s=t({...i});return L$.set(t,{moduleOverrides:i,modulePromise:s}),s}async function wje(t,e,r=ly){const n={...ly,...r},i=await QM(t),{size:s}=e,o=new Uint8Array(await e.arrayBuffer()),a=i._malloc(s);i.HEAPU8.set(o,a);const c=i.readBarcodesFromImage(a,s,Zte(i,n));i._free(a);const l=[];for(let f=0;f{var t,e=typeof document<"u"&&((t=document.currentScript)==null?void 0:t.tagName.toUpperCase())==="SCRIPT"?document.currentScript.src:void 0;return function(r={}){var n,i=r,s,o,a=new Promise((q,V)=>{s=q,o=V}),c=typeof window=="object",l=typeof Bun<"u",f=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var u=Object.assign({},i),p="./this.program",g="";function y(q){return i.locateFile?i.locateFile(q,g):g+q}var b,I;if(c||f||l){var C;f?g=self.location.href:typeof document<"u"&&((C=document.currentScript)===null||C===void 0?void 0:C.tagName.toUpperCase())==="SCRIPT"&&(g=document.currentScript.src),e&&(g=e),g.startsWith("blob:")?g="":g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1),f&&(I=q=>{var V=new XMLHttpRequest;return V.open("GET",q,!1),V.responseType="arraybuffer",V.send(null),new Uint8Array(V.response)}),b=q=>fetch(q,{credentials:"same-origin"}).then(V=>V.ok?V.arrayBuffer():Promise.reject(new Error(V.status+" : "+V.url)))}var S=i.print||console.log.bind(console),O=i.printErr||console.error.bind(console);Object.assign(i,u),u=null,i.arguments&&i.arguments,i.thisProgram&&(p=i.thisProgram);var L=i.wasmBinary,F,z=!1,_,$,ie,ce,K,P,M,v;function m(){var q=F.buffer;i.HEAP8=_=new Int8Array(q),i.HEAP16=ie=new Int16Array(q),i.HEAPU8=$=new Uint8Array(q),i.HEAPU16=ce=new Uint16Array(q),i.HEAP32=K=new Int32Array(q),i.HEAPU32=P=new Uint32Array(q),i.HEAPF32=M=new Float32Array(q),i.HEAPF64=v=new Float64Array(q)}var R=[],B=[],E=[];function x(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)k(i.preRun.shift());Je(R)}function w(){Je(B)}function T(){if(i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)oe(i.postRun.shift());Je(E)}function k(q){R.unshift(q)}function H(q){B.unshift(q)}function oe(q){E.unshift(q)}var j=0,X=null;function G(q){var V;j++,(V=i.monitorRunDependencies)===null||V===void 0||V.call(i,j)}function Z(q){var V;if(j--,(V=i.monitorRunDependencies)===null||V===void 0||V.call(i,j),j==0&&X){var re=X;X=null,re()}}function ee(q){var V;(V=i.onAbort)===null||V===void 0||V.call(i,q),q="Aborted("+q+")",O(q),z=!0,q+=". Build with -sASSERTIONS for more info.";var re=new WebAssembly.RuntimeError(q);throw o(re),re}var N="data:application/octet-stream;base64,",te=q=>q.startsWith(N);function fe(){var q="zxing_reader.wasm";return te(q)?q:y(q)}var Ee;function _e(q){if(q==Ee&&L)return new Uint8Array(L);if(I)return I(q);throw"both async and sync fetching of the wasm failed"}function Re(q){return L?Promise.resolve().then(()=>_e(q)):b(q).then(V=>new Uint8Array(V),()=>_e(q))}function Te(q,V,re){return Re(q).then(ae=>WebAssembly.instantiate(ae,V)).then(re,ae=>{O(`failed to asynchronously prepare wasm: ${ae}`),ee(ae)})}function De(q,V,re,ae){return!q&&typeof WebAssembly.instantiateStreaming=="function"&&!te(V)&&typeof fetch=="function"?fetch(V,{credentials:"same-origin"}).then(pe=>{var me=WebAssembly.instantiateStreaming(pe,re);return me.then(ae,function(Se){return O(`wasm streaming compile failed: ${Se}`),O("falling back to ArrayBuffer instantiation"),Te(V,re,ae)})}):Te(V,re,ae)}function ze(){return{a:Zy}}function et(){var q,V=ze();function re(pe,me){return hn=pe.exports,F=hn.za,m(),ds=hn.Da,H(hn.Aa),Z(),hn}G();function ae(pe){re(pe.instance)}if(i.instantiateWasm)try{return i.instantiateWasm(V,re)}catch(pe){O(`Module.instantiateWasm callback failed with error: ${pe}`),o(pe)}return(q=Ee)!==null&&q!==void 0||(Ee=fe()),De(L,Ee,V,ae).catch(o),{}}var Je=q=>{for(;q.length>0;)q.shift()(i)};i.noExitRuntime;var ke=q=>ho(q),Ne=()=>em(),tt=[],Ze=0,st=q=>{var V=new lt(q);return V.get_caught()||(V.set_caught(!0),Ze--),V.set_rethrown(!1),tt.push(V),Xx(q),Jx(q)},nt=0,We=()=>{yr(0,0);var q=tt.pop();Zx(q.excPtr),nt=0};class lt{constructor(V){this.excPtr=V,this.ptr=V-24}set_type(V){P[this.ptr+4>>2]=V}get_type(){return P[this.ptr+4>>2]}set_destructor(V){P[this.ptr+8>>2]=V}get_destructor(){return P[this.ptr+8>>2]}set_caught(V){V=V?1:0,_[this.ptr+12]=V}get_caught(){return _[this.ptr+12]!=0}set_rethrown(V){V=V?1:0,_[this.ptr+13]=V}get_rethrown(){return _[this.ptr+13]!=0}init(V,re){this.set_adjusted_ptr(0),this.set_type(V),this.set_destructor(re)}set_adjusted_ptr(V){P[this.ptr+16>>2]=V}get_adjusted_ptr(){return P[this.ptr+16>>2]}}var vt=q=>{throw nt||(nt=q),nt},Ke=q=>df(q),gt=q=>{var V=nt;if(!V)return Ke(0),0;var re=new lt(V);re.set_adjusted_ptr(V);var ae=re.get_type();if(!ae)return Ke(0),V;for(var pe of q){if(pe===0||pe===ae)break;var me=re.ptr+16;if(e2(pe,ae,me))return Ke(pe),V}return Ke(ae),V},wt=()=>gt([]),rt=q=>gt([q]),It=(q,V)=>gt([q,V]),At=()=>{var q=tt.pop();q||ee("no exception to throw");var V=q.excPtr;throw q.get_rethrown()||(tt.push(q),q.set_rethrown(!0),q.set_caught(!1),Ze++),nt=V,nt},Tt=(q,V,re)=>{var ae=new lt(q);throw ae.init(V,re),nt=q,Ze++,nt},Xt=()=>Ze,lr=()=>{ee("")},xt={},ar=q=>{for(;q.length;){var V=q.pop(),re=q.pop();re(V)}};function rr(q){return this.fromWireType(P[q>>2])}var kt={},Dt={},Nt={},dt,Lt=q=>{throw new dt(q)},Mt=(q,V,re)=>{q.forEach(Ae=>Nt[Ae]=V);function ae(Ae){var Be=re(Ae);Be.length!==q.length&&Lt("Mismatched type converter count");for(var Ye=0;Ye{Dt.hasOwnProperty(Ae)?pe[Be]=Dt[Ae]:(me.push(Ae),kt.hasOwnProperty(Ae)||(kt[Ae]=[]),kt[Ae].push(()=>{pe[Be]=Dt[Ae],++Se,Se===me.length&&ae(pe)}))}),me.length===0&&ae(pe)},ut=q=>{var V=xt[q];delete xt[q];var re=V.rawConstructor,ae=V.rawDestructor,pe=V.fields,me=pe.map(Se=>Se.getterReturnType).concat(pe.map(Se=>Se.setterArgumentType));Mt([q],me,Se=>{var Ae={};return pe.forEach((Be,Ye)=>{var Qe=Be.fieldName,pt=Se[Ye],mr=Be.getter,Br=Be.getterContext,un=Se[Ye+pe.length],Zn=Be.setter,In=Be.setterContext;Ae[Qe]={read:pn=>pt.fromWireType(mr(Br,pn)),write:(pn,yc)=>{var $n=[];Zn(In,pn,un.toWireType($n,yc)),ar($n)}}}),[{name:V.name,fromWireType:Be=>{var Ye={};for(var Qe in Ae)Ye[Qe]=Ae[Qe].read(Be);return ae(Be),Ye},toWireType:(Be,Ye)=>{for(var Qe in Ae)if(!(Qe in Ye))throw new TypeError(`Missing field: "${Qe}"`);var pt=re();for(Qe in Ae)Ae[Qe].write(pt,Ye[Qe]);return Be!==null&&Be.push(ae,pt),pt},argPackAdvance:ct,readValueFromPointer:rr,destructorFunction:ae}]})},Vt=(q,V,re,ae,pe)=>{},zt=()=>{for(var q=new Array(256),V=0;V<256;++V)q[V]=String.fromCharCode(V);ht=q},ht,Et=q=>{for(var V="",re=q;$[re];)V+=ht[$[re++]];return V},Bt,He=q=>{throw new Bt(q)};function $t(q,V){let re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var ae=V.name;if(q||He(`type "${ae}" must have a positive integer typeid pointer`),Dt.hasOwnProperty(q)){if(re.ignoreDuplicateRegistrations)return;He(`Cannot register type '${ae}' twice`)}if(Dt[q]=V,delete Nt[q],kt.hasOwnProperty(q)){var pe=kt[q];delete kt[q],pe.forEach(me=>me())}}function Ct(q,V){let re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return $t(q,V,re)}var ct=8,Ht=(q,V,re,ae)=>{V=Et(V),Ct(q,{name:V,fromWireType:function(pe){return!!pe},toWireType:function(pe,me){return me?re:ae},argPackAdvance:ct,readValueFromPointer:function(pe){return this.fromWireType($[pe])},destructorFunction:null})},Rr=q=>({count:q.count,deleteScheduled:q.deleteScheduled,preservePointerOnDelete:q.preservePointerOnDelete,ptr:q.ptr,ptrType:q.ptrType,smartPtr:q.smartPtr,smartPtrType:q.smartPtrType}),Ut=q=>{function V(re){return re.$$.ptrType.registeredClass.name}He(V(q)+" instance already deleted")},Sr=!1,er=q=>{},kr=q=>{q.smartPtr?q.smartPtrType.rawDestructor(q.smartPtr):q.ptrType.registeredClass.rawDestructor(q.ptr)},bi=q=>{q.count.value-=1;var V=q.count.value===0;V&&kr(q)},wi=(q,V,re)=>{if(V===re)return q;if(re.baseClass===void 0)return null;var ae=wi(q,V,re.baseClass);return ae===null?null:re.downcast(ae)},xi={},Ti=()=>Object.keys(pi).length,Sn=()=>{var q=[];for(var V in pi)pi.hasOwnProperty(V)&&q.push(pi[V]);return q},di=[],Fs=()=>{for(;di.length;){var q=di.pop();q.$$.deleteScheduled=!1,q.delete()}},hi,jo=q=>{hi=q,di.length&&hi&&hi(Fs)},Uo=()=>{i.getInheritedInstanceCount=Ti,i.getLiveInheritedInstances=Sn,i.flushPendingDeletes=Fs,i.setDelayFunction=jo},pi={},oo=(q,V)=>{for(V===void 0&&He("ptr should not be undefined");q.baseClass;)V=q.upcast(V),q=q.baseClass;return V},ao=(q,V)=>(V=oo(q,V),pi[V]),_n=(q,V)=>{(!V.ptrType||!V.ptr)&&Lt("makeClassHandle requires ptr and ptrType");var re=!!V.smartPtrType,ae=!!V.smartPtr;return re!==ae&&Lt("Both smartPtrType and smartPtr must be specified"),V.count={value:1},Gi(Object.create(q,{$$:{value:V,writable:!0}}))};function $o(q){var V=this.getPointee(q);if(!V)return this.destructor(q),null;var re=ao(this.registeredClass,V);if(re!==void 0){if(re.$$.count.value===0)return re.$$.ptr=V,re.$$.smartPtr=q,re.clone();var ae=re.clone();return this.destructor(q),ae}function pe(){return this.isSmartPointer?_n(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:V,smartPtrType:this,smartPtr:q}):_n(this.registeredClass.instancePrototype,{ptrType:this,ptr:q})}var me=this.registeredClass.getActualType(V),Se=xi[me];if(!Se)return pe.call(this);var Ae;this.isConst?Ae=Se.constPointerType:Ae=Se.pointerType;var Be=wi(V,this.registeredClass,Ae.registeredClass);return Be===null?pe.call(this):this.isSmartPointer?_n(Ae.registeredClass.instancePrototype,{ptrType:Ae,ptr:Be,smartPtrType:this,smartPtr:q}):_n(Ae.registeredClass.instancePrototype,{ptrType:Ae,ptr:Be})}var Gi=q=>typeof FinalizationRegistry>"u"?(Gi=V=>V,q):(Sr=new FinalizationRegistry(V=>{bi(V.$$)}),Gi=V=>{var re=V.$$,ae=!!re.smartPtr;if(ae){var pe={$$:re};Sr.register(V,pe,V)}return V},er=V=>Sr.unregister(V),Gi(q)),qo=()=>{Object.assign(Ca.prototype,{isAliasOf(q){if(!(this instanceof Ca)||!(q instanceof Ca))return!1;var V=this.$$.ptrType.registeredClass,re=this.$$.ptr;q.$$=q.$$;for(var ae=q.$$.ptrType.registeredClass,pe=q.$$.ptr;V.baseClass;)re=V.upcast(re),V=V.baseClass;for(;ae.baseClass;)pe=ae.upcast(pe),ae=ae.baseClass;return V===ae&&re===pe},clone(){if(this.$$.ptr||Ut(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var q=Gi(Object.create(Object.getPrototypeOf(this),{$$:{value:Rr(this.$$)}}));return q.$$.count.value+=1,q.$$.deleteScheduled=!1,q},delete(){this.$$.ptr||Ut(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&He("Object already scheduled for deletion"),er(this),bi(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Ut(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&He("Object already scheduled for deletion"),di.push(this),di.length===1&&hi&&hi(Fs),this.$$.deleteScheduled=!0,this}})};function Ca(){}var co=(q,V)=>Object.defineProperty(V,"name",{value:q}),Lh=(q,V,re)=>{if(q[V].overloadTable===void 0){var ae=q[V];q[V]=function(){for(var pe=arguments.length,me=new Array(pe),Se=0;Se{i.hasOwnProperty(q)?((re===void 0||i[q].overloadTable!==void 0&&i[q].overloadTable[re]!==void 0)&&He(`Cannot register public name '${q}' twice`),Lh(i,q,q),i.hasOwnProperty(re)&&He(`Cannot register multiple overloads of a function with the same number of arguments (${re})!`),i[q].overloadTable[re]=V):(i[q]=V,re!==void 0&&(i[q].numArguments=re))},Fh=48,cf=57,jh=q=>{if(q===void 0)return"_unknown";q=q.replace(/[^a-zA-Z0-9_]/g,"$");var V=q.charCodeAt(0);return V>=Fh&&V<=cf?`_${q}`:q};function lf(q,V,re,ae,pe,me,Se,Ae){this.name=q,this.constructor=V,this.instancePrototype=re,this.rawDestructor=ae,this.baseClass=pe,this.getActualType=me,this.upcast=Se,this.downcast=Ae,this.pureVirtualFunctions=[]}var Du=(q,V,re)=>{for(;V!==re;)V.upcast||He(`Expected null or instance of ${re.name}, got an instance of ${V.name}`),q=V.upcast(q),V=V.baseClass;return q};function qy(q,V){if(V===null)return this.isReference&&He(`null is not a valid ${this.name}`),0;V.$$||He(`Cannot pass "${zr(V)}" as a ${this.name}`),V.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`);var re=V.$$.ptrType.registeredClass,ae=Du(V.$$.ptr,re,this.registeredClass);return ae}function r1(q,V){var re;if(V===null)return this.isReference&&He(`null is not a valid ${this.name}`),this.isSmartPointer?(re=this.rawConstructor(),q!==null&&q.push(this.rawDestructor,re),re):0;(!V||!V.$$)&&He(`Cannot pass "${zr(V)}" as a ${this.name}`),V.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&V.$$.ptrType.isConst&&He(`Cannot convert argument of type ${V.$$.smartPtrType?V.$$.smartPtrType.name:V.$$.ptrType.name} to parameter type ${this.name}`);var ae=V.$$.ptrType.registeredClass;if(re=Du(V.$$.ptr,ae,this.registeredClass),this.isSmartPointer)switch(V.$$.smartPtr===void 0&&He("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:V.$$.smartPtrType===this?re=V.$$.smartPtr:He(`Cannot convert argument of type ${V.$$.smartPtrType?V.$$.smartPtrType.name:V.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:re=V.$$.smartPtr;break;case 2:if(V.$$.smartPtrType===this)re=V.$$.smartPtr;else{var pe=V.clone();re=this.rawShare(re,zo.toHandle(()=>pe.delete())),q!==null&&q.push(this.rawDestructor,re)}break;default:He("Unsupporting sharing policy")}return re}function n1(q,V){if(V===null)return this.isReference&&He(`null is not a valid ${this.name}`),0;V.$$||He(`Cannot pass "${zr(V)}" as a ${this.name}`),V.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`),V.$$.ptrType.isConst&&He(`Cannot convert argument of type ${V.$$.ptrType.name} to parameter type ${this.name}`);var re=V.$$.ptrType.registeredClass,ae=Du(V.$$.ptr,re,this.registeredClass);return ae}var Nu=()=>{Object.assign(Bu.prototype,{getPointee(q){return this.rawGetPointee&&(q=this.rawGetPointee(q)),q},destructor(q){var V;(V=this.rawDestructor)===null||V===void 0||V.call(this,q)},argPackAdvance:ct,readValueFromPointer:rr,fromWireType:$o})};function Bu(q,V,re,ae,pe,me,Se,Ae,Be,Ye,Qe){this.name=q,this.registeredClass=V,this.isReference=re,this.isConst=ae,this.isSmartPointer=pe,this.pointeeType=me,this.sharingPolicy=Se,this.rawGetPointee=Ae,this.rawConstructor=Be,this.rawShare=Ye,this.rawDestructor=Qe,!pe&&V.baseClass===void 0?ae?(this.toWireType=qy,this.destructorFunction=null):(this.toWireType=n1,this.destructorFunction=null):this.toWireType=r1}var Uh=(q,V,re)=>{i.hasOwnProperty(q)||Lt("Replacing nonexistent public symbol"),i[q].overloadTable!==void 0&&re!==void 0?i[q].overloadTable[re]=V:(i[q]=V,i[q].argCount=re)},Lu=(q,V,re)=>{q=q.replace(/p/g,"i");var ae=i["dynCall_"+q];return ae(V,...re)},Vo=[],ds,hr=q=>{var V=Vo[q];return V||(q>=Vo.length&&(Vo.length=q+1),Vo[q]=V=ds.get(q)),V},i1=function(q,V){let re=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(q.includes("j"))return Lu(q,V,re);var ae=hr(V)(...re);return ae},Aa=(q,V)=>function(){for(var re=arguments.length,ae=new Array(re),pe=0;pe{q=Et(q);function re(){return q.includes("j")?Aa(q,V):hr(V)}var ae=re();return typeof ae!="function"&&He(`unknown function pointer with signature ${q}: ${V}`),ae},s1=(q,V)=>{var re=co(V,function(ae){this.name=V,this.message=ae;var pe=new Error(ae).stack;pe!==void 0&&(this.stack=this.toString()+` `+pe.replace(/^Error(:[^\n]*)?\n/,""))});return re.prototype=Object.create(q.prototype),re.prototype.constructor=re,re.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},re},$h,qh=q=>{var V=gc(q),re=Et(V);return uo(V),re},Fu=(q,V)=>{var re=[],ae={};function pe(me){if(!ae[me]&&!Dt[me]){if(Nt[me]){Nt[me].forEach(pe);return}re.push(me),ae[me]=!0}}throw V.forEach(pe),new $h(`${q}: `+re.map(qh).join([", "]))},vc=(q,V,re,ae,pe,me,Se,Ae,Be,Ye,Qe,pt,mr)=>{Qe=Et(Qe),me=hs(pe,me),Ae&&(Ae=hs(Se,Ae)),Ye&&(Ye=hs(Be,Ye)),mr=hs(pt,mr);var Br=jh(Qe);pc(Br,function(){Fu(`Cannot construct ${Qe} due to unbound types`,[ae])}),Mt([q,V,re],ae?[ae]:[],un=>{un=un[0];var Zn,In;ae?(Zn=un.registeredClass,In=Zn.instancePrototype):In=Ca.prototype;var pn=co(Qe,function(){if(Object.getPrototypeOf(this)!==yc)throw new Bt("Use 'new' to construct "+Qe);if($n.constructor_body===void 0)throw new Bt(Qe+" has no accessible constructor");for(var l2=arguments.length,b1=new Array(l2),w1=0;w1{for(var re=[],ae=0;ae>2]);return re};function o1(q){for(var V=1;V{var Se=ju(V,re);pe=hs(ae,pe),Mt([],[q],Ae=>{Ae=Ae[0];var Be=`constructor ${Ae.name}`;if(Ae.registeredClass.constructor_body===void 0&&(Ae.registeredClass.constructor_body=[]),Ae.registeredClass.constructor_body[V-1]!==void 0)throw new Bt(`Cannot register multiple constructors with identical number of parameters (${V-1}) for class '${Ae.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return Ae.registeredClass.constructor_body[V-1]=()=>{Fu(`Cannot construct ${Ae.name} due to unbound types`,Se)},Mt([],Se,Ye=>(Ye.splice(1,0,null),Ae.registeredClass.constructor_body[V-1]=nl(Be,Ye,null,pe,me),[])),[]})},Uu=q=>{q=q.trim();const V=q.indexOf("(");return V!==-1?q.substr(0,V):q},zy=(q,V,re,ae,pe,me,Se,Ae,Be,Ye)=>{var Qe=ju(re,ae);V=Et(V),V=Uu(V),me=hs(pe,me),Mt([],[q],pt=>{pt=pt[0];var mr=`${pt.name}.${V}`;V.startsWith("@@")&&(V=Symbol[V.substring(2)]),Ae&&pt.registeredClass.pureVirtualFunctions.push(V);function Br(){Fu(`Cannot call ${mr} due to unbound types`,Qe)}var un=pt.registeredClass.instancePrototype,Zn=un[V];return Zn===void 0||Zn.overloadTable===void 0&&Zn.className!==pt.name&&Zn.argCount===re-2?(Br.argCount=re-2,Br.className=pt.name,un[V]=Br):(Lh(un,V,mr),un[V].overloadTable[re-2]=Br),Mt([],Qe,In=>{var pn=nl(mr,In,pt,me,Se);return un[V].overloadTable===void 0?(pn.argCount=re-2,un[V]=pn):un[V].overloadTable[re-2]=pn,[]}),[]})},il=[],lo=[],$u=q=>{q>9&&--lo[q+1]===0&&(lo[q]=void 0,il.push(q))},ff=()=>lo.length/2-5-il.length,a1=()=>{lo.push(0,1,void 0,1,null,1,!0,1,!1,1),i.count_emval_handles=ff},zo={toValue:q=>(q||He("Cannot use deleted val. handle = "+q),lo[q]),toHandle:q=>{switch(q){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const V=il.pop()||lo.length;return lo[V]=q,lo[V+1]=1,V}}}},Wr={name:"emscripten::val",fromWireType:q=>{var V=zo.toValue(q);return $u(q),V},toWireType:(q,V)=>zo.toHandle(V),argPackAdvance:ct,readValueFromPointer:rr,destructorFunction:null},Kr=q=>Ct(q,Wr),le=(q,V,re)=>{switch(V){case 1:return re?function(ae){return this.fromWireType(_[ae])}:function(ae){return this.fromWireType($[ae])};case 2:return re?function(ae){return this.fromWireType(ie[ae>>1])}:function(ae){return this.fromWireType(ce[ae>>1])};case 4:return re?function(ae){return this.fromWireType(K[ae>>2])}:function(ae){return this.fromWireType(P[ae>>2])};default:throw new TypeError(`invalid integer width (${V}): ${q}`)}},we=(q,V,re,ae)=>{V=Et(V);function pe(){}pe.values={},Ct(q,{name:V,constructor:pe,fromWireType:function(me){return this.constructor.values[me]},toWireType:(me,Se)=>Se.value,argPackAdvance:ct,readValueFromPointer:le(V,re,ae),destructorFunction:null}),pc(V,pe)},$e=(q,V)=>{var re=Dt[q];return re===void 0&&He(`${V} has unknown type ${qh(q)}`),re},yt=(q,V,re)=>{var ae=$e(q,"enum");V=Et(V);var pe=ae.constructor,me=Object.create(ae.constructor.prototype,{value:{value:re},constructor:{value:co(`${ae.name}_${V}`,function(){})}});pe.values[re]=me,pe[V]=me},zr=q=>{if(q===null)return"null";var V=typeof q;return V==="object"||V==="array"||V==="function"?q.toString():""+q},tr=(q,V)=>{switch(V){case 4:return function(re){return this.fromWireType(M[re>>2])};case 8:return function(re){return this.fromWireType(v[re>>3])};default:throw new TypeError(`invalid float width (${V}): ${q}`)}},ln=(q,V,re)=>{V=Et(V),Ct(q,{name:V,fromWireType:ae=>ae,toWireType:(ae,pe)=>pe,argPackAdvance:ct,readValueFromPointer:tr(V,re),destructorFunction:null})},jn=(q,V,re,ae,pe,me,Se,Ae)=>{var Be=ju(V,re);q=Et(q),q=Uu(q),pe=hs(ae,pe),pc(q,function(){Fu(`Cannot call ${q} due to unbound types`,Be)},V-1),Mt([],Be,Ye=>{var Qe=[Ye[0],null].concat(Ye.slice(1));return Uh(q,nl(q,Qe,null,pe,me),V-1),[]})},wr=(q,V,re)=>{switch(V){case 1:return re?ae=>_[ae]:ae=>$[ae];case 2:return re?ae=>ie[ae>>1]:ae=>ce[ae>>1];case 4:return re?ae=>K[ae>>2]:ae=>P[ae>>2];default:throw new TypeError(`invalid integer width (${V}): ${q}`)}},en=(q,V,re,ae,pe)=>{V=Et(V);var me=Qe=>Qe;if(ae===0){var Se=32-8*re;me=Qe=>Qe<>>Se}var Ae=V.includes("unsigned"),Be=(Qe,pt)=>{},Ye;Ae?Ye=function(Qe,pt){return Be(pt,this.name),pt>>>0}:Ye=function(Qe,pt){return Be(pt,this.name),pt},Ct(q,{name:V,fromWireType:me,toWireType:Ye,argPackAdvance:ct,readValueFromPointer:wr(V,re,ae!==0),destructorFunction:null})},Pn=(q,V,re)=>{var ae=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],pe=ae[V];function me(Se){var Ae=P[Se>>2],Be=P[Se+4>>2];return new pe(_.buffer,Be,Ae)}re=Et(re),Ct(q,{name:re,fromWireType:me,argPackAdvance:ct,readValueFromPointer:me},{ignoreDuplicateRegistrations:!0})},ps=Object.assign({optional:!0},Wr),Un=(q,V)=>{Ct(q,ps)},fn=(q,V,re,ae)=>{if(!(ae>0))return 0;for(var pe=re,me=re+ae-1,Se=0;Se=55296&&Ae<=57343){var Be=q.charCodeAt(++Se);Ae=65536+((Ae&1023)<<10)|Be&1023}if(Ae<=127){if(re>=me)break;V[re++]=Ae}else if(Ae<=2047){if(re+1>=me)break;V[re++]=192|Ae>>6,V[re++]=128|Ae&63}else if(Ae<=65535){if(re+2>=me)break;V[re++]=224|Ae>>12,V[re++]=128|Ae>>6&63,V[re++]=128|Ae&63}else{if(re+3>=me)break;V[re++]=240|Ae>>18,V[re++]=128|Ae>>12&63,V[re++]=128|Ae>>6&63,V[re++]=128|Ae&63}}return V[re]=0,re-pe},Yn=(q,V,re)=>fn(q,$,V,re),Ho=q=>{for(var V=0,re=0;re=55296&&ae<=57343?(V+=4,++re):V+=3}return V},js=typeof TextDecoder<"u"?new TextDecoder:void 0,Go=(q,V,re)=>{for(var ae=V+re,pe=V;q[pe]&&!(pe>=ae);)++pe;if(pe-V>16&&q.buffer&&js)return js.decode(q.subarray(V,pe));for(var me="";V>10,56320|Ye&1023)}}return me},Vh=(q,V)=>q?Go($,q,V):"",uf=(q,V)=>{V=Et(V);var re=V==="std::string";Ct(q,{name:V,fromWireType(ae){var pe=P[ae>>2],me=ae+4,Se;if(re)for(var Ae=me,Be=0;Be<=pe;++Be){var Ye=me+Be;if(Be==pe||$[Ye]==0){var Qe=Ye-Ae,pt=Vh(Ae,Qe);Se===void 0?Se=pt:(Se+="\0",Se+=pt),Ae=Ye+1}}else{for(var mr=new Array(pe),Be=0;Be>2]=me,re&&Se)Yn(pe,Be,me+1);else if(Se)for(var Ye=0;Ye255&&(uo(Be),He("String has UTF-16 code units that do not fit in 8 bits")),$[Be+Ye]=Qe}else for(var Ye=0;Ye{for(var re=q,ae=re>>1,pe=ae+V/2;!(ae>=pe)&&ce[ae];)++ae;if(re=ae<<1,re-q>32&&Qn)return Qn.decode($.subarray(q,re));for(var me="",Se=0;!(Se>=V/2);++Se){var Ae=ie[q+Se*2>>1];if(Ae==0)break;me+=String.fromCharCode(Ae)}return me},fo=(q,V,re)=>{var ae;if((ae=re)!==null&&ae!==void 0||(re=2147483647),re<2)return 0;re-=2;for(var pe=V,me=re>1]=Ae,V+=2}return ie[V>>1]=0,V-pe},FE=q=>q.length*2,Hx=(q,V)=>{for(var re=0,ae="";!(re>=V/4);){var pe=K[q+re*4>>2];if(pe==0)break;if(++re,pe>=65536){var me=pe-65536;ae+=String.fromCharCode(55296|me>>10,56320|me&1023)}else ae+=String.fromCharCode(pe)}return ae},sl=(q,V,re)=>{var ae;if((ae=re)!==null&&ae!==void 0||(re=2147483647),re<4)return 0;for(var pe=V,me=pe+re-4,Se=0;Se=55296&&Ae<=57343){var Be=q.charCodeAt(++Se);Ae=65536+((Ae&1023)<<10)|Be&1023}if(K[V>>2]=Ae,V+=4,V+4>me)break}return K[V>>2]=0,V-pe},c1=q=>{for(var V=0,re=0;re=55296&&ae<=57343&&++re,V+=4}return V},Hy=(q,V,re)=>{re=Et(re);var ae,pe,me,Se;V===2?(ae=LE,pe=fo,Se=FE,me=Ae=>ce[Ae>>1]):V===4&&(ae=Hx,pe=sl,Se=c1,me=Ae=>P[Ae>>2]),Ct(q,{name:re,fromWireType:Ae=>{for(var Be=P[Ae>>2],Ye,Qe=Ae+4,pt=0;pt<=Be;++pt){var mr=Ae+4+pt*V;if(pt==Be||me(mr)==0){var Br=mr-Qe,un=ae(Qe,Br);Ye===void 0?Ye=un:(Ye+="\0",Ye+=un),Qe=mr+V}}return uo(Ae),Ye},toWireType:(Ae,Be)=>{typeof Be!="string"&&He(`Cannot pass non-string to C++ string type ${re}`);var Ye=Se(Be),Qe=Xy(4+Ye+V);return P[Qe>>2]=Ye/V,pe(Be,Qe+4,Ye+V),Ae!==null&&Ae.push(uo,Qe),Qe},argPackAdvance:ct,readValueFromPointer:rr,destructorFunction(Ae){uo(Ae)}})},dn=(q,V,re,ae,pe,me)=>{xt[q]={name:Et(V),rawConstructor:hs(re,ae),rawDestructor:hs(pe,me),fields:[]}},ol=(q,V,re,ae,pe,me,Se,Ae,Be,Ye)=>{xt[q].fields.push({fieldName:Et(V),getterReturnType:re,getter:hs(ae,pe),getterContext:me,setterArgumentType:Se,setter:hs(Ae,Be),setterContext:Ye})},Gy=(q,V)=>{V=Et(V),Ct(q,{isVoid:!0,name:V,argPackAdvance:0,fromWireType:()=>{},toWireType:(re,ae)=>{}})},jE=(q,V,re)=>$.copyWithin(q,V,V+re),zh=[],UE=(q,V,re,ae)=>(q=zh[q],V=zo.toValue(V),q(null,V,re,ae)),$E={},qE=q=>{var V=$E[q];return V===void 0?Et(q):V},Wy=()=>{if(typeof globalThis=="object")return globalThis;function q(V){V.$$$embind_global$$$=V;var re=typeof $$$embind_global$$$=="object"&&V.$$$embind_global$$$==V;return re||delete V.$$$embind_global$$$,re}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&q(global)?$$$embind_global$$$=global:typeof self=="object"&&q(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},l1=q=>q===0?zo.toHandle(Wy()):(q=qE(q),zo.toHandle(Wy()[q])),qu=q=>{var V=zh.length;return zh.push(q),V},VE=(q,V)=>{for(var re=new Array(q),ae=0;ae>2],"parameter "+ae);return re},Gx=Reflect.construct,Wx=(q,V,re)=>{var ae=[],pe=q.toWireType(ae,re);return ae.length&&(P[V>>2]=zo.toHandle(ae)),pe},Ky=(q,V,re)=>{var ae=VE(q,V),pe=ae.shift();q--;var me=new Array(q),Se=(Be,Ye,Qe,pt)=>{for(var mr=0,Br=0;BrBe.name).join(", ")}) => ${pe.name}>`;return qu(co(Ae,Se))},Yy=q=>{q>9&&(lo[q+1]+=1)},Kx=q=>{var V=zo.toValue(q);ar(V),$u(q)},zE=(q,V)=>{q=$e(q,"_emval_take_value");var re=q.readValueFromPointer(V);return zo.toHandle(re)},Qy=(q,V,re,ae)=>{var pe=new Date().getFullYear(),me=new Date(pe,0,1),Se=new Date(pe,6,1),Ae=me.getTimezoneOffset(),Be=Se.getTimezoneOffset(),Ye=Math.max(Ae,Be);P[q>>2]=Ye*60,K[V>>2]=+(Ae!=Be);var Qe=Br=>{var un=Br>=0?"-":"+",Zn=Math.abs(Br),In=String(Math.floor(Zn/60)).padStart(2,"0"),pn=String(Zn%60).padStart(2,"0");return`UTC${un}${In}${pn}`},pt=Qe(Ae),mr=Qe(Be);Be2147483648,HE=(q,V)=>Math.ceil(q/V)*V,Yx=q=>{var V=F.buffer,re=(q-V.byteLength+65535)/65536;try{return F.grow(re),m(),1}catch{}},Us=q=>{var V=$.length;q>>>=0;var re=Jy();if(q>re)return!1;for(var ae=1;ae<=4;ae*=2){var pe=V*(1+.2/ae);pe=Math.min(pe,q+100663296);var me=Math.min(re,HE(Math.max(q,pe),65536)),Se=Yx(me);if(Se)return!0}return!1},Hh={},Gh=()=>p||"./this.program",Vu=()=>{if(!Vu.strings){var q=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",V={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:q,_:Gh()};for(var re in Hh)Hh[re]===void 0?delete V[re]:V[re]=Hh[re];var ae=[];for(var re in V)ae.push(`${re}=${V[re]}`);Vu.strings=ae}return Vu.strings},Qx=(q,V)=>{for(var re=0;re{var re=0;return Vu().forEach((ae,pe)=>{var me=V+re;P[q+pe*4>>2]=me,Qx(ae,me),re+=ae.length+1}),0},WE=(q,V)=>{var re=Vu();P[q>>2]=re.length;var ae=0;return re.forEach(pe=>ae+=pe.length+1),P[V>>2]=ae,0},KE=q=>52;function YE(q,V,re,ae,pe){return 70}var QE=[null,[],[]],zu=(q,V)=>{var re=QE[q];V===0||V===10?((q===1?S:O)(Go(re,0)),re.length=0):re.push(V)},JE=(q,V,re,ae)=>{for(var pe=0,me=0;me>2],Ae=P[V+4>>2];V+=8;for(var Be=0;Be>2]=pe,0},ZE=q=>q;dt=i.InternalError=class extends Error{constructor(q){super(q),this.name="InternalError"}},zt(),Bt=i.BindingError=class extends Error{constructor(q){super(q),this.name="BindingError"}},qo(),Uo(),Nu(),$h=i.UnboundTypeError=s1(Error,"UnboundTypeError"),a1();var Zy={t:st,x:We,a:wt,j:rt,k:It,O:At,q:Tt,ga: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(i.dynCall_iiiiijj=hn.Sa)(q,V,re,ae,pe,me,Se,Ae,Be),i.dynCall_iiiiiijj=(q,V,re,ae,pe,me,Se,Ae,Be,Ye)=>(i.dynCall_iiiiiijj=hn.Ta)(q,V,re,ae,pe,me,Se,Ae,Be,Ye);function Hu(q,V){var re=Ne();try{return hr(q)(V)}catch(ae){if(ke(re),ae!==ae+0)throw ae;yr(1,0)}}function be(q,V,re,ae){var pe=Ne();try{hr(q)(V,re,ae)}catch(me){if(ke(pe),me!==me+0)throw me;yr(1,0)}}function Oe(q,V,re){var ae=Ne();try{hr(q)(V,re)}catch(pe){if(ke(ae),pe!==pe+0)throw pe;yr(1,0)}}function Pe(q,V,re,ae){var pe=Ne();try{return hr(q)(V,re,ae)}catch(me){if(ke(pe),me!==me+0)throw me;yr(1,0)}}function bt(q,V,re,ae,pe){var me=Ne();try{return hr(q)(V,re,ae,pe)}catch(Se){if(ke(me),Se!==Se+0)throw Se;yr(1,0)}}function Jt(q,V){var re=Ne();try{hr(q)(V)}catch(ae){if(ke(re),ae!==ae+0)throw ae;yr(1,0)}}function Nr(q,V,re){var ae=Ne();try{return hr(q)(V,re)}catch(pe){if(ke(ae),pe!==pe+0)throw pe;yr(1,0)}}function Jn(q){var V=Ne();try{hr(q)()}catch(re){if(ke(V),re!==re+0)throw re;yr(1,0)}}function tn(q,V,re,ae,pe,me,Se,Ae,Be,Ye,Qe){var pt=Ne();try{hr(q)(V,re,ae,pe,me,Se,Ae,Be,Ye,Qe)}catch(mr){if(ke(pt),mr!==mr+0)throw mr;yr(1,0)}}function tm(q,V,re,ae,pe){var me=Ne();try{hr(q)(V,re,ae,pe)}catch(Se){if(ke(me),Se!==Se+0)throw Se;yr(1,0)}}function XE(q,V,re,ae,pe){var me=Ne();try{return hr(q)(V,re,ae,pe)}catch(Se){if(ke(me),Se!==Se+0)throw Se;yr(1,0)}}function po(q,V,re,ae,pe,me){var Se=Ne();try{return hr(q)(V,re,ae,pe,me)}catch(Ae){if(ke(Se),Ae!==Ae+0)throw Ae;yr(1,0)}}function f1(q,V,re,ae,pe,me){var Se=Ne();try{hr(q)(V,re,ae,pe,me)}catch(Ae){if(ke(Se),Ae!==Ae+0)throw Ae;yr(1,0)}}function eC(q,V,re,ae,pe,me,Se){var Ae=Ne();try{return hr(q)(V,re,ae,pe,me,Se)}catch(Be){if(ke(Ae),Be!==Be+0)throw Be;yr(1,0)}}function Gu(q,V,re,ae,pe,me,Se,Ae){var Be=Ne();try{hr(q)(V,re,ae,pe,me,Se,Ae)}catch(Ye){if(ke(Be),Ye!==Ye+0)throw Ye;yr(1,0)}}function u1(q,V,re,ae,pe,me,Se,Ae,Be){var Ye=Ne();try{hr(q)(V,re,ae,pe,me,Se,Ae,Be)}catch(Qe){if(ke(Ye),Qe!==Qe+0)throw Qe;yr(1,0)}}function d1(q){var V=Ne();try{return hr(q)()}catch(re){if(ke(V),re!==re+0)throw re;yr(1,0)}}function Hr(q,V,re,ae,pe,me,Se,Ae,Be){var Ye=Ne();try{return hr(q)(V,re,ae,pe,me,Se,Ae,Be)}catch(Qe){if(ke(Ye),Qe!==Qe+0)throw Qe;yr(1,0)}}function tC(q,V,re,ae,pe,me,Se){var Ae=Ne();try{return hr(q)(V,re,ae,pe,me,Se)}catch(Be){if(ke(Ae),Be!==Be+0)throw Be;yr(1,0)}}function n2(q,V,re,ae){var pe=Ne();try{return hr(q)(V,re,ae)}catch(me){if(ke(pe),me!==me+0)throw me;yr(1,0)}}function h1(q,V,re,ae){var pe=Ne();try{return hr(q)(V,re,ae)}catch(me){if(ke(pe),me!==me+0)throw me;yr(1,0)}}function rC(q,V,re,ae,pe,me,Se,Ae){var Be=Ne();try{hr(q)(V,re,ae,pe,me,Se,Ae)}catch(Ye){if(ke(Be),Ye!==Ye+0)throw Ye;yr(1,0)}}function nC(q,V,re,ae,pe,me){var Se=Ne();try{return hr(q)(V,re,ae,pe,me)}catch(Ae){if(ke(Se),Ae!==Ae+0)throw Ae;yr(1,0)}}function iC(q,V,re,ae,pe,me,Se,Ae,Be,Ye){var Qe=Ne();try{return hr(q)(V,re,ae,pe,me,Se,Ae,Be,Ye)}catch(pt){if(ke(Qe),pt!==pt+0)throw pt;yr(1,0)}}function p1(q,V,re){var ae=Ne();try{return hr(q)(V,re)}catch(pe){if(ke(ae),pe!==pe+0)throw pe;yr(1,0)}}function al(q,V,re,ae,pe){var me=Ne();try{return hr(q)(V,re,ae,pe)}catch(Se){if(ke(me),Se!==Se+0)throw Se;yr(1,0)}}function v1(q,V,re,ae,pe,me,Se,Ae,Be,Ye){var Qe=Ne();try{hr(q)(V,re,ae,pe,me,Se,Ae,Be,Ye)}catch(pt){if(ke(Qe),pt!==pt+0)throw pt;yr(1,0)}}function i2(q,V,re,ae,pe,me,Se,Ae){var Be=Ne();try{return hr(q)(V,re,ae,pe,me,Se,Ae)}catch(Ye){if(ke(Be),Ye!==Ye+0)throw Ye;yr(1,0)}}function g1(q,V,re,ae,pe,me,Se){var Ae=Ne();try{hr(q)(V,re,ae,pe,me,Se)}catch(Be){if(ke(Ae),Be!==Be+0)throw Be;yr(1,0)}}function s2(q,V,re,ae){var pe=Ne();try{return hr(q)(V,re,ae)}catch(me){if(ke(pe),me!==me+0)throw me;yr(1,0)}}function o2(q,V,re,ae,pe,me,Se,Ae,Be,Ye,Qe,pt){var mr=Ne();try{return hr(q)(V,re,ae,pe,me,Se,Ae,Be,Ye,Qe,pt)}catch(Br){if(ke(mr),Br!==Br+0)throw Br;yr(1,0)}}function y1(q,V,re,ae,pe,me,Se,Ae,Be,Ye,Qe,pt,mr,Br,un,Zn){var In=Ne();try{hr(q)(V,re,ae,pe,me,Se,Ae,Be,Ye,Qe,pt,mr,Br,un,Zn)}catch(pn){if(ke(In),pn!==pn+0)throw pn;yr(1,0)}}function a2(q,V,re,ae){var pe=Ne();try{return t2(q,V,re,ae)}catch(me){if(ke(pe),me!==me+0)throw me;yr(1,0)}}function Wh(q,V,re,ae,pe){var me=Ne();try{return r2(q,V,re,ae,pe)}catch(Se){if(ke(me),Se!==Se+0)throw Se;yr(1,0)}}var Sa;X=function q(){Sa||Kh(),Sa||(X=q)};function Kh(){if(j>0||(x(),j>0))return;function q(){var V;Sa||(Sa=!0,i.calledRun=!0,!z&&(w(),s(i),(V=i.onRuntimeInitialized)===null||V===void 0||V.call(i),T()))}i.setStatus?(i.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>i.setStatus(""),1),q()},1)):q()}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Kh(),n=a,n}})();function Eje(t){return QM(JM,t)}async function Cje(t,e){return wje(JM,t,e)}async function Aje(t,e){return xje(JM,t,e)}const ere=[["aztec","Aztec"],["code_128","Code128"],["code_39","Code39"],["code_93","Code93"],["codabar","Codabar"],["databar","DataBar"],["databar_expanded","DataBarExpanded"],["data_matrix","DataMatrix"],["dx_film_edge","DXFilmEdge"],["ean_13","EAN-13"],["ean_8","EAN-8"],["itf","ITF"],["maxi_code","MaxiCode"],["micro_qr_code","MicroQRCode"],["pdf417","PDF417"],["qr_code","QRCode"],["rm_qr_code","rMQRCode"],["upc_a","UPC-A"],["upc_e","UPC-E"],["linear_codes","Linear-Codes"],["matrix_codes","Matrix-Codes"]],Sje=[...ere,["unknown"]].map(t=>t[0]),II=new Map(ere);function _je(t){for(const[e,r]of II)if(t===r)return e;return"unknown"}function Ije(t){if(tre(t))return{width:t.naturalWidth,height:t.naturalHeight};if(rre(t))return{width:t.width.baseVal.value,height:t.height.baseVal.value};if(nre(t))return{width:t.videoWidth,height:t.videoHeight};if(sre(t))return{width:t.width,height:t.height};if(are(t))return{width:t.displayWidth,height:t.displayHeight};if(ire(t))return{width:t.width,height:t.height};if(ore(t))return{width:t.width,height:t.height};throw new TypeError("The provided value is not of type '(Blob or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or ImageData or OffscreenCanvas or SVGImageElement or VideoFrame)'.")}function tre(t){var e,r;try{return t instanceof((r=(e=t==null?void 0:t.ownerDocument)==null?void 0:e.defaultView)==null?void 0:r.HTMLImageElement)}catch{return!1}}function rre(t){var e,r;try{return t instanceof((r=(e=t==null?void 0:t.ownerDocument)==null?void 0:e.defaultView)==null?void 0:r.SVGImageElement)}catch{return!1}}function nre(t){var e,r;try{return t instanceof((r=(e=t==null?void 0:t.ownerDocument)==null?void 0:e.defaultView)==null?void 0:r.HTMLVideoElement)}catch{return!1}}function ire(t){var e,r;try{return t instanceof((r=(e=t==null?void 0:t.ownerDocument)==null?void 0:e.defaultView)==null?void 0:r.HTMLCanvasElement)}catch{return!1}}function sre(t){try{return t instanceof ImageBitmap||Object.prototype.toString.call(t)==="[object ImageBitmap]"}catch{return!1}}function ore(t){try{return t instanceof OffscreenCanvas||Object.prototype.toString.call(t)==="[object OffscreenCanvas]"}catch{return!1}}function are(t){try{return t instanceof VideoFrame||Object.prototype.toString.call(t)==="[object VideoFrame]"}catch{return!1}}function cre(t){try{return t instanceof Blob||Object.prototype.toString.call(t)==="[object Blob]"}catch{return!1}}function Tje(t){try{return t instanceof ImageData||Object.prototype.toString.call(t)==="[object ImageData]"}catch{return!1}}function Pje(t,e){try{const r=new OffscreenCanvas(t,e);if(r.getContext("2d")instanceof OffscreenCanvasRenderingContext2D)return r;throw void 0}catch{const r=document.createElement("canvas");return r.width=t,r.height=e,r}}async function lre(t){if(tre(t)&&!await Oje(t))throw new DOMException("Failed to load or decode HTMLImageElement.","InvalidStateError");if(rre(t)&&!await Dje(t))throw new DOMException("Failed to load or decode SVGImageElement.","InvalidStateError");if(are(t)&&Nje(t))throw new DOMException("VideoFrame is closed.","InvalidStateError");if(nre(t)&&(t.readyState===0||t.readyState===1))throw new DOMException("Invalid element or state.","InvalidStateError");if(sre(t)&&Lje(t))throw new DOMException("The image source is detached.","InvalidStateError");const{width:e,height:r}=Ije(t);if(e===0||r===0)return null;const n=Pje(e,r).getContext("2d");n.drawImage(t,0,0);try{return n.getImageData(0,0,e,r)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function kje(t){let e;try{if(globalThis.createImageBitmap)e=await createImageBitmap(t);else if(globalThis.Image){e=new Image;let r="";try{r=URL.createObjectURL(t),e.src=r,await e.decode()}finally{URL.revokeObjectURL(r)}}else return t}catch{throw new DOMException("Failed to load or decode Blob.","InvalidStateError")}return await lre(e)}function Mje(t){const{width:e,height:r}=t;if(e===0||r===0)return null;const n=t.getContext("2d");try{return n.getImageData(0,0,e,r)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function Rje(t){if(cre(t))return await kje(t);if(Tje(t)){if(Bje(t))throw new DOMException("The image data has been detached.","InvalidStateError");return t}return ire(t)||ore(t)?Mje(t):await lre(t)}async function Oje(t){try{return await t.decode(),!0}catch{return!1}}async function Dje(t){var e;try{return await((e=t.decode)==null?void 0:e.call(t)),!0}catch{return!1}}function Nje(t){return t.format===null}function Bje(t){return t.data.buffer.byteLength===0}function Lje(t){return t.width===0&&t.height===0}function F$(t,e){return Fje(t)?new DOMException(`${e}: ${t.message}`,t.name):jje(t)?new t.constructor(`${e}: ${t.message}`):new Error(`${e}: ${t}`)}function Fje(t){return t instanceof DOMException||Object.prototype.toString.call(t)==="[object DOMException]"}function jje(t){return t instanceof Error||Object.prototype.toString.call(t)==="[object Error]"}var U3;class TI extends EventTarget{constructor(e={}){var r;super(),lje(this,U3);try{const n=(r=e==null?void 0:e.formats)==null?void 0:r.filter(i=>i!=="unknown");if((n==null?void 0:n.length)===0)throw new TypeError("Hint option provided, but is empty.");for(const i of n??[])if(!II.has(i))throw new TypeError(`Failed to read the 'formats' property from 'BarcodeDetectorOptions': The provided value '${i}' is not a valid enum value of type BarcodeFormat.`);fje(this,U3,n??[]),Eje().then(i=>{this.dispatchEvent(new CustomEvent("load",{detail:i}))}).catch(i=>{this.dispatchEvent(new CustomEvent("error",{detail:i}))})}catch(n){throw F$(n,"Failed to construct 'BarcodeDetector'")}}static async getSupportedFormats(){return Sje.filter(e=>e!=="unknown")}async detect(e){try{const r=await Rje(e);if(r===null)return[];let n;const i={tryHarder:!0,returnCodabarStartEnd:!0,formats:cje(this,U3).map(s=>II.get(s))};try{cre(r)?n=await Cje(r,i):n=await Aje(r,i)}catch(s){throw console.error(s),new DOMException("Barcode detection service unavailable.","NotSupportedError")}return n.map(s=>{const{topLeft:{x:o,y:a},topRight:{x:c,y:l},bottomLeft:{x:f,y:u},bottomRight:{x:p,y:g}}=s.position,y=Math.min(o,c,f,p),b=Math.min(a,l,u,g),I=Math.max(o,c,f,p),C=Math.max(a,l,u,g);return{boundingBox:new DOMRectReadOnly(y,b,I-y,C-b),rawValue:s.text,format:_je(s.format),cornerPoints:[{x:o,y:a},{x:c,y:l},{x:p,y:g},{x:f,y:u}]}})}catch(r){throw F$(r,"Failed to execute 'detect' on 'BarcodeDetector'")}}}U3=new WeakMap;globalThis.BarcodeDetector!=null||(globalThis.BarcodeDetector=TI);function Uje(t){const{onClick:e,disabled:r,className:n}=t,i={cursor:r?"default":"pointer",stroke:r?"grey":"yellow",strokeLineJoin:"round",strokeLineCap:"round",strokeWidth:1.5,...t.style};return qt.createElement("svg",{onClick:r?void 0:e,className:n,style:i,width:"28px",height:"28px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},qt.createElement("path",{d:"M3 3L6.00007 6.00007M21 21L19.8455 19.8221M9.74194 4.06811C9.83646 4.04279 9.93334 4.02428 10.0319 4.01299C10.1453 4 10.2683 4 10.5141 4H13.5327C13.7786 4 13.9015 4 14.015 4.01299C14.6068 4.08078 15.1375 4.40882 15.4628 4.90782C15.5252 5.00345 15.5802 5.11345 15.6901 5.33333C15.7451 5.44329 15.7726 5.49827 15.8037 5.54609C15.9664 5.79559 16.2318 5.95961 16.5277 5.9935C16.5844 6 16.6459 6 16.7688 6H17.8234C18.9435 6 19.5036 6 19.9314 6.21799C20.3077 6.40973 20.6137 6.71569 20.8055 7.09202C21.0234 7.51984 21.0234 8.0799 21.0234 9.2V15.3496M19.8455 19.8221C19.4278 20 18.8702 20 17.8234 20H6.22344C5.10333 20 4.54328 20 4.11546 19.782C3.73913 19.5903 3.43317 19.2843 3.24142 18.908C3.02344 18.4802 3.02344 17.9201 3.02344 16.8V9.2C3.02344 8.0799 3.02344 7.51984 3.24142 7.09202C3.43317 6.71569 3.73913 6.40973 4.11546 6.21799C4.51385 6.015 5.0269 6.00103 6.00007 6.00007M19.8455 19.8221L14.5619 14.5619M14.5619 14.5619C14.0349 15.4243 13.0847 16 12 16C10.3431 16 9 14.6569 9 13C9 11.9153 9.57566 10.9651 10.4381 10.4381M14.5619 14.5619L10.4381 10.4381M10.4381 10.4381L6.00007 6.00007"}))}function $je(t){const{onClick:e,disabled:r,className:n}=t,i={cursor:r?"default":"pointer",stroke:r?"grey":"yellow",strokeLineJoin:"round",strokeLineCap:"round",strokeWidth:1.5,...t.style};return qt.createElement("svg",{onClick:r?void 0:e,className:n,style:i,width:"28px",height:"28px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},qt.createElement("path",{d:"M12 16C13.6569 16 15 14.6569 15 13C15 11.3431 13.6569 10 12 10C10.3431 10 9 11.3431 9 13C9 14.6569 10.3431 16 12 16Z"}),qt.createElement("path",{d:"M3 16.8V9.2C3 8.0799 3 7.51984 3.21799 7.09202C3.40973 6.71569 3.71569 6.40973 4.09202 6.21799C4.51984 6 5.0799 6 6.2 6H7.25464C7.37758 6 7.43905 6 7.49576 5.9935C7.79166 5.95961 8.05705 5.79559 8.21969 5.54609C8.25086 5.49827 8.27836 5.44328 8.33333 5.33333C8.44329 5.11342 8.49827 5.00346 8.56062 4.90782C8.8859 4.40882 9.41668 4.08078 10.0085 4.01299C10.1219 4 10.2448 4 10.4907 4H13.5093C13.7552 4 13.8781 4 13.9915 4.01299C14.5833 4.08078 15.1141 4.40882 15.4394 4.90782C15.5017 5.00345 15.5567 5.11345 15.6667 5.33333C15.7216 5.44329 15.7491 5.49827 15.7803 5.54609C15.943 5.79559 16.2083 5.95961 16.5042 5.9935C16.561 6 16.6224 6 16.7454 6H17.8C18.9201 6 19.4802 6 19.908 6.21799C20.2843 6.40973 20.5903 6.71569 20.782 7.09202C21 7.51984 21 8.0799 21 9.2V16.8C21 17.9201 21 18.4802 20.782 18.908C20.5903 19.2843 20.2843 19.5903 19.908 19.782C19.4802 20 18.9201 20 17.8 20H6.2C5.0799 20 4.51984 20 4.09202 19.782C3.71569 19.5903 3.40973 19.2843 3.21799 18.908C3 18.4802 3 17.9201 3 16.8Z"}))}function qje(t){const{scanning:e,startScanning:r,stopScanning:n}=t,[i,s]=D.useState(!1);function o(){s(!0),e?n():r(),setTimeout(()=>s(!1),1e3)}return qt.createElement("div",{style:{bottom:85,right:3,position:"absolute",zIndex:2,cursor:i?"default":"pointer"}},e?qt.createElement(Uje,{disabled:i,onClick:o}):qt.createElement($je,{disabled:i,onClick:o}))}function Vje(t){const{onClick:e,className:r,style:n}=t;return qt.createElement("svg",{onClick:e,width:"30px",height:"30px",viewBox:"0 0 24 24",className:r,style:n,xmlns:"http://www.w3.org/2000/svg"},qt.createElement("path",{strokeWidth:.2,stroke:"yellow",fill:"yellow",d:"M13.225 9l5.025-7h-7.972l-3.3 11h5.359l-2.452 8.648.75.364L20.374 9zm.438 3H8.322l2.7-9H16.3l-5.025 7h7.101l-6.7 8.953z"}))}function zje(t){const{onClick:e,className:r,style:n}=t;return qt.createElement("svg",{onClick:e,width:"30px",height:"30px",viewBox:"0 0 24 24",className:r,style:n,xmlns:"http://www.w3.org/2000/svg"},qt.createElement("path",{strokeWidth:.2,stroke:"yellow",fill:"yellow",d:"M14.516 15.158l.714.714-4.595 6.14-.75-.364L12.337 13H6.978L8.22 8.861l.803.803L8.322 12h3.036l1.793 1.792-1.475 5.16zm5.984 4.05L4.793 3.5l.707-.707 3.492 3.492L10.278 2h7.972l-5.025 7h7.149l-3.71 4.957 4.543 4.543zM12.707 10l3.243 3.243L18.376 10zM9.795 7.088l2.079 2.079L16.3 3h-5.278z"}))}function Hje(t){const{status:e,scanning:r,torchToggle:n}=t;function i(s){n(s)}return r&&n?qt.createElement("div",{style:{bottom:35,right:3,position:"absolute",zIndex:2,cursor:"pointer"}},e?qt.createElement(zje,{onClick:()=>i(!1)}):qt.createElement(Vje,{onClick:()=>i(!0)})):null}function Gje(t){const{onClick:e,className:r,disabled:n=!1}=t,i={cursor:n?"default":"pointer",stroke:n?"grey":"yellow",fill:n?"grey":"yellow",...t.style};return qt.createElement("svg",{onClick:n?void 0:e,width:"30px",height:"30px",viewBox:"0 0 24 24",className:r,style:i,xmlns:"http://www.w3.org/2000/svg"},qt.createElement("path",{strokeWidth:.3,d:"M16.279,17.039c-1.396,1.209 -3.216,1.941 -5.206,1.941c-4.393,0 -7.96,-3.567 -7.96,-7.96c-0,-4.393 3.567,-7.96 7.96,-7.96c4.393,0 7.96,3.567 7.96,7.96c-0,2.044 -0.772,3.909 -2.04,5.319l0.165,0.165c1.194,1.194 2.388,2.388 3.583,3.582c0.455,0.456 -0.252,1.163 -0.707,0.708l-3.755,-3.755Zm1.754,-6.019c-0,-3.841 -3.119,-6.96 -6.96,-6.96c-3.842,0 -6.96,3.119 -6.96,6.96c-0,3.841 3.118,6.96 6.96,6.96c3.841,0 6.96,-3.119 6.96,-6.96Zm-7.46,0.5l-1.5,0c-0.645,0 -0.643,-1 -0,-1l1.5,0l-0,-1.5c-0,-0.645 1,-0.643 1,0l-0,1.5l1.5,0c0.645,0 0.643,1 -0,1l-1.5,0l-0,1.5c-0,0.645 -1,0.643 -1,0l-0,-1.5Z"}))}function Wje(t){const{onClick:e,className:r,disabled:n=!1}=t,i={cursor:n?"default":"pointer",stroke:n?"grey":"yellow",fill:n?"grey":"yellow",...t.style};return qt.createElement("svg",{onClick:n?void 0:e,width:"30px",height:"30px",viewBox:"0 0 24 24",className:r,style:i,xmlns:"http://www.w3.org/2000/svg"},qt.createElement("path",{strokeWidth:.3,d:"M16.279,17.039c-1.396,1.209 -3.216,1.941 -5.206,1.941c-4.393,0 -7.96,-3.567 -7.96,-7.96c-0,-4.393 3.567,-7.96 7.96,-7.96c4.393,0 7.96,3.567 7.96,7.96c-0,2.044 -0.772,3.909 -2.04,5.319l0.165,0.165c1.194,1.194 2.388,2.388 3.583,3.582c0.455,0.456 -0.252,1.163 -0.707,0.708l-3.755,-3.755Zm1.754,-6.019c-0,-3.841 -3.119,-6.96 -6.96,-6.96c-3.842,0 -6.96,3.119 -6.96,6.96c-0,3.841 3.118,6.96 6.96,6.96c3.841,0 6.96,-3.119 6.96,-6.96Zm-4.96,-0.5c0.645,0 0.643,1 -0,1l-4,0c-0.645,0 -0.643,-1 -0,-1l4,0Z"}))}function Kje(t){const{scanning:e,capabilities:r,onZoom:n,value:i}=t;if(!e||!n)return null;const s=(r.max-r.min)/3;return qt.createElement(D.Fragment,null,qt.createElement("div",{style:{bottom:130,right:3,position:"absolute",zIndex:2,cursor:"pointer"}},qt.createElement(Wje,{disabled:i<=r.min,onClick:function(){n(Math.max(i-s,r.min))}})),qt.createElement("div",{style:{bottom:180,right:3,position:"absolute",zIndex:2,cursor:"pointer"}},qt.createElement(Gje,{disabled:i>=r.max,onClick:function(){n(Math.min(i+s,r.max))}})))}function Yje(t){const{scanning:e,loading:r,capabilities:n,border:i=35,onOff:s,torch:o,zoom:a,startScanning:c,stopScanning:l}=t,f="rgba(255, 0, 0, 0.5)";return qt.createElement("div",{style:{position:"relative"}},qt.createElement("svg",{viewBox:"0 0 100 100",style:{top:0,left:0,zIndex:1,boxSizing:"border-box",border:`${i>=35?i:35}px solid rgba(0, 0, 0, 0.2)`}},r&&qt.createElement("text",{x:"50",y:"50",textAnchor:"middle",fill:"black",fontSize:"8",fontFamily:"Arial",fontWeight:"bold"},"Loading ...",qt.createElement("animate",{attributeName:"opacity",values:"0;1;0",dur:"2s",repeatCount:"indefinite"})),qt.createElement("path",{fill:"none",d:"M23,0 L0,0 L0,23",stroke:f,strokeWidth:3}),qt.createElement("path",{fill:"none",d:"M0,77 L0,100 L23,100",stroke:f,strokeWidth:3}),qt.createElement("path",{fill:"none",d:"M77,100 L100,100 L100,77",stroke:f,strokeWidth:3}),qt.createElement("path",{fill:"none",d:"M100,23 L100,0 77,0",stroke:f,strokeWidth:3})),s&&qt.createElement(qje,{scanning:e,startScanning:c,stopScanning:l}),o&&n.torch&&qt.createElement(Hje,{scanning:e,status:o.status,torchToggle:o.toggle}),a&&n.zoom&&qt.createElement(Kje,{scanning:e,capabilities:n.zoom,value:a.value,onZoom:a.onChange}))}const Qje={facingMode:"environment",width:{min:640,ideal:720,max:1920},height:{min:640,ideal:720,max:1080}},Jje={audio:!0,tracker:void 0,onOff:!1,finder:!0,torch:!0,zoom:!1},Zje={width:"100%",height:"100%",position:"relative"},Xje={top:0,left:0,width:"100%",height:"100%",display:"block",overflow:"hidden"};var eUe=function(t){let e,r=!1;return(...n)=>(r||(e=t(n),r=!0),e)}(()=>{const t=OFe(window);switch(t.browser){case"chrome":zFe(window,t);break;case"firefox":KFe(window,t);break;case"safari":ZFe(window,t);break;default:throw new Error("Unsupported browser")}});const tUe="data:audio/mp3;base64,//PkZAAhghE0AKToAJra/n0FQygAAAGIkYJgmCYXBMAAGCTJz3zhCEM//z//1hz//8MMMMN08ssV6e5DDWIQreAgCvFKy8bXgIKMkUDDBgzJwIBtkRMQAocxIFdxghQGKDoEziAzQxOBOdH92i/iGi+zDCAEIX46a73HrSybZw1x3JZjXp7dSNy/P68rjcbt7p7fakMP5LVMyzCaj1pjvejYYAIDgDGzECjEAk1Jl3559HIon8hzlfPVTCvGJZzfcKSxXfyMWM88//9VKSxXdtnb9vomOuuRyiWVYbf+X8zp6fKGHIdycuWMMMMMMKSnp+6wsYc/9f/7z7rPPWHN556p6fP8MMMP///PPP/7+GHK9PT6p7f/unldP2np7YeHjweiYA4GLNAgAiI7u57n5//oc5/yfk6znOcPhwOBwggHCMpA4HA4KEyHOc5znO+hPIc5//+fqJh8XQPh90JU5xQinOf//87/zvP+ggAYuhCKHxdA+Hxd0EA4KKHA4ciB3kOXfXB/gmf8p/B96lAMKAgAADU+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U$=t=>fre(t)||!ure(t);function dre(t,e){if(U$(t)||U$(e))return t===e;if(fb(t)&&fb(e))return t.getTime()===e.getTime();const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const i of r){const s=t[i];if(!n.includes(i))return!1;if(i!=="ref"){const o=e[i];if(fb(s)&&fb(o)||j$(s)&&j$(o)||Array.isArray(s)&&Array.isArray(o)?!dre(s,o):s!==o)return!1}}return!0}function F6(t){if(t===null)throw new Error("Canvas should always be defined when component is mounted.");const e=t.getContext("2d");if(e===null)throw new Error("Canvas 2D context should be non-null");e.clearRect(0,0,t.width,t.height)}function rUe(t){var e;const{onScan:r,constraints:n,formats:i=["qr_code"],paused:s=!1,components:o,children:a,styles:c,classNames:l,allowMultiple:f,scanDelay:u,onError:p}=t,g=D.useRef(null),y=D.useRef(null),b=D.useRef(null),I=D.useMemo(()=>({...Qje,...n}),[n]),C=D.useMemo(()=>({...Jje,...o}),[o]),[S,O]=D.useState(!1),[L,F]=D.useState(!0),[z,_]=D.useState(I),$=function(){const v=D.useRef(Promise.resolve({type:"stop",data:{}})),m=D.useRef(null),R=D.useRef(null),[B,E]=D.useState({}),[x,w]=D.useState({}),T=D.useCallback(async(X,G)=>{var Z,ee,N;if(!window.isSecureContext)throw new Error("camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP.");if(((Z=navigator==null?void 0:navigator.mediaDevices)===null||Z===void 0?void 0:Z.getUserMedia)===void 0)throw new Error("this browser has no Stream API support");eUe();const te=await navigator.mediaDevices.getUserMedia({audio:!1,video:G});X.srcObject!==void 0?X.srcObject=te:X.mozSrcObject!==void 0?X.mozSrcObject=te:window.URL.createObjectURL?X.src=window.URL.createObjectURL(te):window.webkitURL?X.src=window.webkitURL.createObjectURL(te):X.src=te.id,await Promise.race([X.play(),new Promise(Ee=>setTimeout(Ee,3e3)).then(()=>{throw new Error("Loading camera stream timed out after 3 seconds.")})]),await new Promise(Ee=>setTimeout(Ee,500));const[fe]=te.getVideoTracks();return w(fe.getSettings()),E((N=(ee=fe==null?void 0:fe.getCapabilities)===null||ee===void 0?void 0:ee.call(fe))!==null&&N!==void 0?N:{}),m.current=te,R.current=fe,{type:"start",data:{videoEl:X,stream:te,constraints:G}}},[]),k=D.useCallback(async(X,G)=>{X.src="",X.srcObject=null,X.load();for(const Z of G.getTracks())G.removeTrack(Z),Z.stop();return m.current=null,R.current=null,w({}),{type:"stop",data:{}}},[]),H=D.useCallback(async(X,{constraints:G,restart:Z=!1})=>{if(v.current=v.current.then(ee=>{if(ee.type==="start"){const{data:{videoEl:N,stream:te,constraints:fe}}=ee;return Z||X!==N||G!==fe?k(N,te).then(()=>T(X,G)):ee}return T(X,G)}),(await v.current).type==="stop")throw new Error("Something went wrong with the camera task queue (start task).")},[T,k]),oe=D.useCallback(async()=>{if(v.current=v.current.then(X=>{if(X.type==="stop")return X;const{data:{videoEl:G,stream:Z}}=X;return k(G,Z)}),(await v.current).type==="start")throw new Error("Something went wrong with the camera task queue (stop task).")},[k]),j=D.useCallback(async X=>{const G=R.current;if(!G)throw new Error("No active video track found.");{X.advanced&&X.advanced[0].zoom&&G.getCapabilities().torch&&await G.applyConstraints({advanced:[{torch:!1}]}),await G.applyConstraints(X);const Z=G.getCapabilities(),ee=G.getSettings();E(Z),w(ee)}},[]);return D.useEffect(()=>()=>{(async()=>await oe())()},[oe]),{capabilities:B,settings:x,startCamera:H,stopCamera:oe,updateConstraints:j}}(),{startScanning:ie,stopScanning:ce}=function(v){const{videoElementRef:m,onScan:R,onFound:B,retryDelay:E=100,scanDelay:x=0,formats:w=[],audio:T=!0,allowMultiple:k=!1}=v,H=D.useRef(new TI({formats:w})),oe=D.useRef(null),j=D.useRef(null);D.useEffect(()=>{H.current=new TI({formats:w})},[w]),D.useEffect(()=>{typeof window<"u"&&T&&(oe.current=new Audio(tUe))},[T]);const X=D.useCallback(G=>async Z=>{if(m.current!==null&&m.current.readyState>1){const{lastScan:ee,contentBefore:N,lastScanHadContent:te}=G;if(Z-ee!N.includes(De.rawValue)),_e=fe.length>0;let Re=G.lastOnScan;(Ee||k&&_e&&Z-Re>=x)&&(T&&oe.current&&oe.current.paused&&oe.current.play().catch(De=>console.error("Error playing the sound",De)),Re=Z,R(fe)),_e&&B(fe),!_e&&te&&B(fe);const Te={lastScan:Z,lastOnScan:Re,lastScanHadContent:_e,contentBefore:Ee?fe.map(De=>De.rawValue):N};j.current=window.requestAnimationFrame(X(Te))}}},[m.current,R,B,E]);return{startScanning:D.useCallback(()=>{const G=performance.now(),Z={lastScan:G,lastOnScan:G,contentBefore:[],lastScanHadContent:!1};j.current=window.requestAnimationFrame(X(Z))},[X]),stopScanning:D.useCallback(()=>{j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null)},[])}}({videoElementRef:g,onScan:r,onFound:v=>function(m,R,B,E){const x=B;if(x==null)throw new Error("onFound handler should only be called when component is mounted. Thus tracking canvas is always defined.");const w=R;if(w==null)throw new Error("onFound handler should only be called when component is mounted. Thus video element is always defined.");if(m.length===0||E===void 0)F6(x);else{const T=w.offsetWidth,k=w.offsetHeight,H=w.videoWidth,oe=w.videoHeight,j=Math.max(T/H,k/oe),X=H*j,G=oe*j,Z=X/H,ee=G/oe,N=(T-X)/2,te=(k-G)/2,fe=({x:Te,y:De})=>({x:Math.floor(Te*Z),y:Math.floor(De*ee)}),Ee=({x:Te,y:De})=>({x:Math.floor(Te+N),y:Math.floor(De+te)}),_e=m.map(Te=>{const{boundingBox:De,cornerPoints:ze}=Te,{x:et,y:Je}=Ee(fe({x:De.x,y:De.y})),{x:ke,y:Ne}=fe({x:De.width,y:De.height});return{...Te,cornerPoints:ze.map(tt=>Ee(fe(tt))),boundingBox:DOMRectReadOnly.fromRect({x:et,y:Je,width:ke,height:Ne})}});x.width=w.offsetWidth,x.height=w.offsetHeight;const Re=x.getContext("2d");if(Re===null)throw new Error("onFound handler should only be called when component is mounted. Thus tracking canvas 2D context is always defined.");E(_e,Re)}}(v,g.current,b.current,C.tracker),formats:i,audio:C.audio,allowMultiple:f,retryDelay:C.tracker===void 0?500:10,scanDelay:u});D.useEffect(()=>(O(!0),()=>{O(!1)}),[]),D.useEffect(()=>{S&&(ce(),ie())},[o==null?void 0:o.tracker]),D.useEffect(()=>{if(!dre(I,z)){const v=I;n!=null&&n.deviceId&&delete v.facingMode,_(v)}},[n]);const K=D.useMemo(()=>({constraints:z,shouldStream:S&&!s}),[z,S,s]),P=async()=>{const v=g.current;if(v==null)throw new Error("Video should be defined when component is mounted.");const m=y.current;if(m==null)throw new Error("Canvas should be defined when component is mounted.");const R=m.getContext("2d");if(R==null)throw new Error("Canvas should be defined when component is mounted.");if(K.shouldStream){await $.stopCamera(),F(!1);try{await $.startCamera(v,K),v?F(!0):await $.stopCamera()}catch(B){p==null||p(B),console.error("error",B)}}else m.width=v.videoWidth,m.height=v.videoHeight,R.drawImage(v,0,0,v.videoWidth,v.videoHeight),await $.stopCamera(),F(!1)};D.useEffect(()=>{(async()=>await P())()},[K]);const M=D.useMemo(()=>K.shouldStream&&L,[K.shouldStream,L]);return D.useEffect(()=>{if(M){if(y.current===void 0)throw new Error("shouldScan effect should only be triggered when component is mounted. Thus pause frame canvas is defined");if(F6(y.current),b.current===void 0)throw new Error("shouldScan effect should only be triggered when component is mounted. Thus tracking canvas is defined");if(F6(b.current),g.current==null)throw new Error("shouldScan effect should only be triggered when component is mounted. Thus video element is defined");ie()}},[M]),qt.createElement("div",{style:{...Zje,...c==null?void 0:c.container},className:l==null?void 0:l.container},qt.createElement("video",{ref:g,style:{...Xje,...c==null?void 0:c.video,visibility:s?"hidden":"visible"},className:l==null?void 0:l.video,autoPlay:!0,muted:!0,playsInline:!0}),qt.createElement("canvas",{ref:y,style:{display:s?"block":"none",position:"absolute",top:0,left:0,width:"100%"}}),qt.createElement("canvas",{ref:b,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%"}}),qt.createElement("div",{style:{top:0,left:0,position:"absolute",width:"100%",height:"100%"}},C.finder&&qt.createElement(Yje,{scanning:L,capabilities:$.capabilities,loading:!1,onOff:C.onOff,zoom:C.zoom&&$.settings.zoom?{value:$.settings.zoom,onChange:async v=>{const m={...z,advanced:[{zoom:v}]};await $.updateConstraints(m)}}:void 0,torch:C.torch?{status:(e=$.settings.torch)!==null&&e!==void 0&&e,toggle:async v=>{const m={...z,advanced:[{torch:v}]};await $.updateConstraints(m)}}:void 0,startScanning:async()=>await P(),stopScanning:async()=>{await $.stopCamera(),F6(b.current),F(!1)},border:c==null?void 0:c.finderBorder}),a))}function nUe({onQrUri:t}){const e=Ir(NE),[r,n]=D.useState(""),i=async()=>{if(r){console.log(r);try{await e.pair(r)}catch(s){console.error(s),t(!1)}}t(!0)};return W.jsxs(xe,{flexDirection:"column",justifyContent:"space-between",padding:"12",gap:"3",children:[W.jsx(rUe,{onScan:s=>{s[0].rawValue&&n(s[0].rawValue)},styles:{video:{transform:"scaleX(-1)",borderRadius:"10px"}}}),W.jsxs(xe,{children:[W.jsx(Wn,{label:"Paste Connection String",labelLocation:"top",name:"signClientUri",value:r??"",onChange:s=>{n(s.target.value)}}),W.jsx(xe,{justifyContent:"flex-end",children:W.jsx(Zt,{marginTop:"4",variant:"primary",size:"md",shape:"square",label:"Connect Dapp",disabled:!r,onClick:()=>{r&&i()}})})]})]})}const hre=t=>({info:{walletId:"",uuid:"",name:"WalletConnect",icon:"https://avatars.githubusercontent.com/u/37784886"},provider:t});function iUe(){var _e,Re;const t=jte(),e=Ir(li),r=Ir(Tx),n=Ir(Zr),i=Ir(NE),s=yn(e.accountAddress),o=yn(n.isSigningTxn),a=yn(n.isSigningMsg),c=yn(i.allSessions),l=h8(),f=KP("isMobile"),u=uFe();D.useEffect(()=>{if(u&&u.connected&&!n.selectedExternalProvider.get()){let Te=hre(u),De=n.availableExternalProviders.get();De?n.availableExternalProviders.set([Te,...De]):n.availableExternalProviders.set([Te])}},[u]),D.useEffect(()=>{t.length>0&&n.availableExternalProviders.set(t)},[t]);const p=yn(n.selectedExternalProvider),g=yn(n.selectedExternalWalletAddress),y=yn(n.isSendingTokenTransaction),b=yn(n.isSendingCollectibleTransaction),I=yn(n.isSendingSignedTokenTransaction),C=Ir(Nn),[S,O]=D.useState(!0),[L,F]=D.useState(void 0),[z,_]=D.useState(void 0),[$,ie]=D.useState(!1),[ce,K]=D.useState(!1),[P,M]=D.useState(!1),[v,m]=D.useState(!1),[R,B]=D.useState(!1),[E,x]=D.useState(!1),[w,T]=D.useState(!1),k=yn(n.signClientWarningType),H=Te=>{_(void 0),n.isSendingCollectibleTransaction.set(void 0),F(Te),B(!0)},oe=Te=>{F(void 0),n.isSendingTokenTransaction.set(void 0),_(Te),x(!0)},j=async(Te=!1)=>{(p===void 0||Te)&&M(!0)},X=async()=>{n.setExternalProvider(void 0);const Te=p;(Te==null?void 0:Te.info.name)==="WalletConnect"&&Te.provider.disconnect()},G=async(Te,De)=>{if(!n.selectedExternalProvider.get()){console.warn("No external provider selected");return}var ze;let et;try{if(L)ze=L.chainId,et=await n.sendToken(L,Te,De);else if(z)ze=z.collectibleInfoParams.chainId,et=await n.sendCollectible(z,Te,De);else{console.warn("No pending send found");return}}catch(Ne){Ne.code===4001&&l({variant:"error",title:"User denied transaction signature."}),console.error(Ne);return}const Je=C.providerForChainId(ze),ke=await k$(Je,et.hash);ke&&l({variant:"success",title:"Transaction confirmed",description:"You can view the transaction details on your connected external wallet"}),L&&r.updateTokenBalance(L),F(void 0),_(void 0),n.isSendingTokenTransaction.set(void 0),n.isSendingCollectibleTransaction.set(void 0),console.log("receipt",ke)},Z=async(Te,De)=>{const ze=C.providerForChainId(De);await k$(ze,Te)&&(n.isSendingSignedTokenTransaction.set(void 0),l({variant:"success",title:"Sign transaction confirmed",description:"You can view the transaction details on your connected external wallet"}))},ee=()=>{i.rejectRequest(),n.toSignPermission.set("cancelled")};async function N(Te){var ke;const De=async(Ne,tt,Ze)=>{try{const st=await n.getExternalProviderAddress(ze);if(!st)throw new Error("No provider address found");return console.log("sendTransaction chainId",tt),await n.sendTransaction(et,ze,st,Ne,tt)}catch(st){throw n.isSendingSignedTokenTransaction.set(void 0),st}},ze=(ke=n.selectedExternalProvider.get())==null?void 0:ke.provider,et=e.account;let Je;if(Te)try{n.isSendingSignedTokenTransaction.set(Te),Je=await De(Te.txn,Te.chainId,Te.options),Z(Je.hash,Te.chainId),n.toSignResult.set(Je),n.toSignPermission.set("approved")}catch(Ne){throw n.isSendingSignedTokenTransaction.set(void 0),ee(),Ne}}async function te(Te){const De=async(Je,ke)=>{try{let Ne;if(Je.message)console.log("signMessage chainId",Je.chainId),Ne=await ze.signMessage(Je.message,Je.chainId,Je.eip6492?"eip6492":"throw");else if(Je.typedData){const tt=Je.typedData;Ne=await ze.signTypedData(tt.domain,tt.types,tt.message,Je.chainId,Je.eip6492?"eip6492":"throw")}if(!Ne)throw new Error("Account sign method failed");return{hash:Ne}}catch(Ne){throw Ne}},ze=e.account;let et;if(Te)try{et=await De(Te.message),n.toSignResult.set(et),n.toSignPermission.set("approved")}catch(Je){throw n.isSendingSignedTokenTransaction.set(void 0),ee(),Je}}const fe=async()=>{var Te;((Te=n.selectedExternalProvider.get())==null?void 0:Te.info.name)==="WalletConnect"?n.signClientWarningType.set("isWalletConnect"):T(!0)},Ee=async()=>{m(!0)};return W.jsxs(W.Fragment,{children:[W.jsxs(xe,{flexDirection:"column",background:"backgroundPrimary",width:"full",height:"full",alignItems:"center",justifyContent:"center",children:[W.jsxs(xe,{flexDirection:"row",width:"full",background:"backgroundMuted",paddingX:"8",paddingY:"4",alignItems:"center",children:[W.jsx("img",{src:vM,alt:"Sequence Logo",width:"40"}),W.jsxs(xe,{marginLeft:"auto",children:[W.jsx(Zt,{label:"Networks",variant:"text",marginRight:"8",onClick:()=>ie(!0)}),W.jsx(EFe,{onTokenListClick:()=>K(!0)})]})]}),W.jsxs(xe,{width:"full",paddingX:"8",style:{maxWidth:"800px"},marginBottom:"16",children:[W.jsxs($r,{flexDirection:"column",alignItems:"center",padding:"6",marginTop:"10",children:[W.jsx(Ge,{variant:"large",color:"text80",marginBottom:"4",children:"Your recovered wallet address"}),W.jsx(Ge,{variant:"normal",fontWeight:"bold",color:"text100",children:s}),W.jsx(PFe,{sessionList:c}),W.jsx(Zt,{marginTop:"4",variant:"primary",size:"sm",shape:"square",label:"Connect to a Dapp with WalletConnect",leftIcon:Kpe,onClick:()=>{fe()}})]}),W.jsxs($r,{alignItems:"center",flexDirection:"column",padding:"6",marginTop:"4",children:[W.jsx(Ge,{variant:"large",color:"text80",marginBottom:"4",children:p?"Your external wallet that will be used to relay transactions":"Connect an external wallet to relay transactions"}),p&&W.jsx(xe,{flexDirection:"row",alignItems:"center",gap:"2",children:W.jsxs(xe,{flexDirection:"column",alignItems:"center",gap:"2",children:[W.jsxs(xe,{flexDirection:"row",gap:"2",children:[W.jsx("img",{src:p.info.icon,alt:p.info.name,style:{width:"20px",height:"20px"}}),W.jsx(Ge,{variant:"normal",color:"text100",children:p.info.name})]}),g&&W.jsxs(Ge,{variant:"normal",color:"text100",children:["(",g,")"]}),W.jsxs(xe,{flexDirection:"row",children:[W.jsx(Zt,{size:"xs",label:"Change external wallet",variant:"text",shape:"square",marginRight:"10",onClick:()=>j(!0)}),W.jsx(Zt,{size:"xs",label:"Disconnect",variant:"text",shape:"square",onClick:()=>X()})]})]})}),!p&&W.jsx(Zt,{label:"Connect",variant:"primary",size:"md",shape:"square",onClick:j})]}),y&&W.jsx(xe,{marginTop:"8",alignItems:"center",justifyContent:"center",children:W.jsx(lS,{symbol:((Re=(_e=y.tokenBalance)==null?void 0:_e.contractInfo)==null?void 0:Re.symbol)??"",chainId:y.tokenBalance.chainId,to:y.to,amount:y.amount})}),b&&W.jsx(xe,{marginTop:"8",alignItems:"center",justifyContent:"center",children:W.jsx(lS,{symbol:b.collectibleInfo.collectibleInfoResponse.name??"",chainId:b.collectibleInfo.collectibleInfoParams.chainId,to:b.to,amount:b.amount})}),I&&W.jsx(xe,{marginTop:"8",alignItems:"center",justifyContent:"center",children:W.jsx(lS,{symbol:"tokens",chainId:I.chainId,to:I.txn[0].to,amount:String(Number(I.txn[0].value))})}),W.jsxs(xe,{flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",marginTop:"8",children:[W.jsxs(xe,{width:"full",flexDirection:"row",alignItems:"center",marginBottom:"4",children:[W.jsx(Ge,{variant:"large",color:"text80",children:"Coins"}),W.jsx(xe,{marginLeft:"auto",children:W.jsx(swe,{label:"Filter zero balances",checked:S,onCheckedChange:O})})]}),W.jsx(IFe,{filterZeroBalances:S,onSendClick:H})]}),W.jsxs(xe,{flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",marginTop:"8",children:[W.jsx(Ge,{variant:"large",color:"text80",marginBottom:"4",children:"Collectibles"}),W.jsx(gFe,{onSendClick:oe})]})]})]}),$&&W.jsx(Tc,{onClose:()=>ie(!1),children:W.jsx(mFe,{})}),ce&&W.jsx(Tc,{onClose:()=>K(!1),children:W.jsx(CFe,{})}),P&&W.jsx(Tc,{size:"md",onClose:()=>M(!1),children:W.jsx(bFe,{onSelectProvider:async Te=>{var De,ze;Te&&(((De=n.selectedExternalProvider.get())==null?void 0:De.info.name)==="WalletConnect"&&await((ze=n.selectedExternalProvider.get())==null?void 0:ze.provider).disconnect(),n.setExternalProvider(Te)),M(!1)}})}),v&&W.jsx(Tc,{size:"md",onClose:()=>m(!1),children:W.jsx(TFe,{onClose:()=>m(!1)})}),w&&W.jsx(Tc,{size:"md",contentProps:{style:{width:f?"100%":"600px",height:f?"":"750px"}},onClose:()=>T(!1),children:W.jsx(nUe,{onQrUri:Te=>{Te&&Ee(),T(!1)}})}),o&&W.jsx(Tc,{isDismissible:!1,size:"md",contentProps:{style:{width:f?"100%":"800px",maxHeight:"100%",overflowY:"auto"}},children:W.jsx(MFe,{onClose:Te=>{var De;n.isSigningTxn.set(!1),Te?n.selectedExternalProvider.get()===void 0?(ee(),n.signClientWarningType.set("noProvider")):((De=n.selectedExternalProvider.get())==null?void 0:De.info.name)==="WalletConnect"?(ee(),n.signClientWarningType.set("isWalletConnect")):N(Te):ee()}})}),a&&W.jsx(Tc,{isDismissible:!1,size:"md",contentProps:{style:{width:f?"100%":"800px",maxHeight:"90%",overflowY:"auto"}},children:W.jsx(kFe,{onClose:Te=>{var De;n.isSigningMsg.set(!1),Te?n.selectedExternalProvider.get()===void 0?(ee(),n.signClientWarningType.set("noProvider")):((De=n.selectedExternalProvider.get())==null?void 0:De.info.name)==="WalletConnect"?(ee(),n.signClientWarningType.set("isWalletConnect")):te(Te):ee()}})}),k&&W.jsx(Tc,{size:"md",onClose:()=>n.signClientWarningType.set(!1),children:W.jsx(RFe,{warningType:k})}),R&&W.jsx(Tc,{size:"md",onClose:()=>B(!1),children:W.jsx(xFe,{tokenBalance:L,onClose:(Te,De)=>{B(!1),Te&&De&&G(Te,De)}})}),E&&W.jsx(Tc,{size:"md",onClose:()=>x(!1),children:W.jsx(wFe,{collectibleInfo:z,onClose:(Te,De)=>{x(!1),(Te&&(z==null?void 0:z.collectibleInfoParams.contractType)==="ERC721"||Te&&De)&&G(Te,De)}})})]})}const sUe=()=>{const t=Ir(li),e=yn(t.accountAddress);return W.jsx(M2e,{basename:"/wallet-recovery-app",children:W.jsxs(A2e,{children:[W.jsx(i3,{path:"/",element:e?W.jsx(JA,{replace:!0,to:"/wallet"}):W.jsx(_9e,{})}),W.jsx(i3,{path:"recovery",element:e?W.jsx(JA,{replace:!0,to:"/wallet"}):W.jsx(P9e,{})}),W.jsx(i3,{path:"wallet",element:e?W.jsx(iUe,{}):W.jsx(JA,{replace:!0,to:"/"})})]})})},oUe=Nxe();L7.createRoot(document.getElementById("root")).render(W.jsx(qt.StrictMode,{children:W.jsx(Bxe,{store:oUe,children:W.jsx(Rme,{theme:"dark",children:W.jsx(Vwe,{children:W.jsx(sUe,{})})})})}));export{R9e as _}; diff --git a/assets/index-Mx8kZtbv.js b/assets/index-BSEof6bf.js similarity index 98% rename from assets/index-Mx8kZtbv.js rename to assets/index-BSEof6bf.js index f25acb0..8ab60e1 100644 --- a/assets/index-Mx8kZtbv.js +++ b/assets/index-BSEof6bf.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BHJ6sBpm.js","assets/index-BTMLuAci.js","assets/index-AnxZPkAf.css"])))=>i.map(i=>d[i]); -import{_ as pe}from"./index-BTMLuAci.js";const me=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,he=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/wallet-recovery-app/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},F=e=>typeof e=="object"&&e!==null,C=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>F(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const w=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(w,!0),l.set(o,[g,w]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(w,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(C.has(O)){const[y,H]=C.get(O);A.value=c(y,H(),I)}Object.defineProperty(w,j,A)}),Object.preventExtensions(w)},d=new WeakMap,f=[1,1],W=o=>{if(!F(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,w=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],w(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const k=r[3](A(U));y.set(U,[r,k])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&w(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),k=Reflect.get(i,a,h);if(U&&(e(k,r)||d.has(r)&&e(k,d.get(r))))return!0;Z(a),F(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(L=>{r.status="fulfilled",r.value=L,w(["resolve",[a],L])}).catch(L=>{r.status="rejected",r.reason=L,w(["reject",[a],L])});else{!C.has(r)&&s(r)&&(V=W(r));const L=!x.has(V)&&C.get(V);L&&H(a,L)}return Reflect.set(i,a,V,h),w(["set",[a],r,k]),!0}});d.set(o,R);const fe=[q,O,c,ue];return C.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,C,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=C.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function we(e,t){const s=C.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return D(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=Buffer.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},be=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:be,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(we(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),b={state:_,subscribe(e){return D(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),$={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;Ie.initialize(),b.setChains(e.chains),b.setIsAuth(!!e.enableAuthMode),b.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),b.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var _e=Object.defineProperty,se=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=We({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",$.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Le=Object.defineProperty,oe=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Ce.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Pe.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ne={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=$.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=b.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Ae({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=$.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),b.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),J={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=b.state;if(m.removeWalletConnectDeepLink(),b.setWalletConnectUri(e==null?void 0:e.uri),b.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=b.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var Me=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))De.call(t,s)&&le(e,s,t[s]);return e};function Ue(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const N=P({themeMode:Ue()?"dark":"light"}),ce={state:N,subscribe(e){return D(N,()=>e(N))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(N.themeMode=t),s&&(N.themeVariables=je({},s))}},S=P({open:!1,message:"",variant:"success"}),Re={state:S,subscribe(e){return D(S,()=>e(S))},openToast(e,t){S.open=!0,S.message=e,S.variant=t},closeToast(){S.open=!1}};class Te{constructor(t){this.openModal=J.open,this.closeModal=J.close,this.subscribeModal=J.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-BHJ6sBpm.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),b.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,Ne as E,J as M,b as O,de as R,ce as T,Re as a,Ie as b,$ as c,Ve as i}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DbcaNW7X.js","assets/index-B10cr2A7.js","assets/index-AnxZPkAf.css"])))=>i.map(i=>d[i]); +import{_ as pe}from"./index-B10cr2A7.js";const me=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,he=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/wallet-recovery-app/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},F=e=>typeof e=="object"&&e!==null,C=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>F(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const w=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(w,!0),l.set(o,[g,w]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(w,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(C.has(O)){const[y,H]=C.get(O);A.value=c(y,H(),I)}Object.defineProperty(w,j,A)}),Object.preventExtensions(w)},d=new WeakMap,f=[1,1],W=o=>{if(!F(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,w=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],w(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const k=r[3](A(U));y.set(U,[r,k])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&w(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),k=Reflect.get(i,a,h);if(U&&(e(k,r)||d.has(r)&&e(k,d.get(r))))return!0;Z(a),F(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(L=>{r.status="fulfilled",r.value=L,w(["resolve",[a],L])}).catch(L=>{r.status="rejected",r.reason=L,w(["reject",[a],L])});else{!C.has(r)&&s(r)&&(V=W(r));const L=!x.has(V)&&C.get(V);L&&H(a,L)}return Reflect.set(i,a,V,h),w(["set",[a],r,k]),!0}});d.set(o,R);const fe=[q,O,c,ue];return C.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,C,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=C.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function we(e,t){const s=C.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return D(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=Buffer.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},be=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:be,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(we(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),b={state:_,subscribe(e){return D(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),$={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;Ie.initialize(),b.setChains(e.chains),b.setIsAuth(!!e.enableAuthMode),b.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),b.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var _e=Object.defineProperty,se=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=We({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",$.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Le=Object.defineProperty,oe=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Ce.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Pe.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ne={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=$.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=b.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Ae({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=$.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),b.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),J={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=b.state;if(m.removeWalletConnectDeepLink(),b.setWalletConnectUri(e==null?void 0:e.uri),b.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=b.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var Me=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))De.call(t,s)&&le(e,s,t[s]);return e};function Ue(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const N=P({themeMode:Ue()?"dark":"light"}),ce={state:N,subscribe(e){return D(N,()=>e(N))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(N.themeMode=t),s&&(N.themeVariables=je({},s))}},S=P({open:!1,message:"",variant:"success"}),Re={state:S,subscribe(e){return D(S,()=>e(S))},openToast(e,t){S.open=!0,S.message=e,S.variant=t},closeToast(){S.open=!1}};class Te{constructor(t){this.openModal=J.open,this.closeModal=J.close,this.subscribeModal=J.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-DbcaNW7X.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),b.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,Ne as E,J as M,b as O,de as R,ce as T,Re as a,Ie as b,$ as c,Ve as i}; diff --git a/assets/index-BHJ6sBpm.js b/assets/index-DbcaNW7X.js similarity index 99% rename from assets/index-BHJ6sBpm.js rename to assets/index-DbcaNW7X.js index f136f40..c4f629e 100644 --- a/assets/index-BHJ6sBpm.js +++ b/assets/index-DbcaNW7X.js @@ -1,4 +1,4 @@ -import{T as xt,M as re,R as N,E as k,C as x,a as X,b as Wo,O as Z,c as ht}from"./index-Mx8kZtbv.js";import"./index-BTMLuAci.js";/** +import{T as xt,M as re,R as N,E as k,C as x,a as X,b as Wo,O as Z,c as ht}from"./index-BSEof6bf.js";import"./index-B10cr2A7.js";/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause diff --git a/index.html b/index.html index bf58ee3..a67c29d 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Sequence Wallet Recovery - +