From 61f75ec6b81586c27e8f14385ef847b259ba7b72 Mon Sep 17 00:00:00 2001 From: status-im-auto Date: Wed, 13 Nov 2024 05:25:40 +0000 Subject: [PATCH] Updates --- buddybook/.vite/manifest.json | 62 +++++++++---------- .../{ccip-DU5pFHxb.js => ccip-BfnZBgwN.js} | 2 +- ...{events-xQ4utD7e.js => events-DyQEop7s.js} | 2 +- .../{index-Cu6T4rb4.js => index-BE2r4h4L.js} | 2 +- .../{index-xz6stGwY.js => index-BhnqxX7Q.js} | 2 +- .../{index-uonIXzgQ.js => index-BpI4vT-j.js} | 12 ++-- .../{index-DOzQxzSO.js => index-CHNnLDtA.js} | 2 +- .../{index-DlENImLn.js => index-Ctx71FWU.js} | 2 +- .../{index-BpmIcSNW.js => index-DskNhwDJ.js} | 2 +- .../{index-Dzj92ueM.js => index-Dt2-TQyK.js} | 4 +- ...ex.es-C5jEvyUt.js => index.es-BwINMB1n.js} | 6 +- ...3-ajt6.js => inherits_browser-B8fZ3Rhe.js} | 2 +- buddybook/index.html | 2 +- flush-notes/404.html | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 flush-notes/index.html | 2 +- flush-notes/index.txt | 2 +- flush-notes/view.html | 2 +- flush-notes/view.txt | 2 +- 20 files changed, 56 insertions(+), 56 deletions(-) rename buddybook/assets/{ccip-DU5pFHxb.js => ccip-BfnZBgwN.js} (97%) rename buddybook/assets/{events-xQ4utD7e.js => events-DyQEop7s.js} (98%) rename buddybook/assets/{index-Cu6T4rb4.js => index-BE2r4h4L.js} (99%) rename buddybook/assets/{index-xz6stGwY.js => index-BhnqxX7Q.js} (99%) rename buddybook/assets/{index-uonIXzgQ.js => index-BpI4vT-j.js} (98%) rename buddybook/assets/{index-DOzQxzSO.js => index-CHNnLDtA.js} (99%) rename buddybook/assets/{index-DlENImLn.js => index-Ctx71FWU.js} (99%) rename buddybook/assets/{index-BpmIcSNW.js => index-DskNhwDJ.js} (96%) rename buddybook/assets/{index-Dzj92ueM.js => index-Dt2-TQyK.js} (98%) rename buddybook/assets/{index.es-C5jEvyUt.js => index.es-BwINMB1n.js} (99%) rename buddybook/assets/{inherits_browser-Bb3-ajt6.js => inherits_browser-B8fZ3Rhe.js} (85%) rename flush-notes/_next/static/{QYaJ0AjbbxerL0dOZkk5s => vaotwJXvn9hargiuIvufd}/_buildManifest.js (100%) rename flush-notes/_next/static/{QYaJ0AjbbxerL0dOZkk5s => vaotwJXvn9hargiuIvufd}/_ssgManifest.js (100%) diff --git a/buddybook/.vite/manifest.json b/buddybook/.vite/manifest.json index 6e95705..7b2ad37 100644 --- a/buddybook/.vite/manifest.json +++ b/buddybook/.vite/manifest.json @@ -1,6 +1,6 @@ { - "_events-xQ4utD7e.js": { - "file": "assets/events-xQ4utD7e.js", + "_events-DyQEop7s.js": { + "file": "assets/events-DyQEop7s.js", "name": "events", "imports": [ "index.html" @@ -10,28 +10,28 @@ "file": "assets/hooks.module-D0gf0yJl.js", "name": "hooks.module" }, - "_index-BpmIcSNW.js": { - "file": "assets/index-BpmIcSNW.js", + "_index-BE2r4h4L.js": { + "file": "assets/index-BE2r4h4L.js", "name": "index", "isDynamicEntry": true, "imports": [ "index.html", - "_events-xQ4utD7e.js" - ] - }, - "_index-Cu6T4rb4.js": { - "file": "assets/index-Cu6T4rb4.js", - "name": "index", - "isDynamicEntry": true, - "imports": [ - "index.html", - "_inherits_browser-Bb3-ajt6.js", + "_inherits_browser-B8fZ3Rhe.js", "_hooks.module-D0gf0yJl.js", - "_events-xQ4utD7e.js" + "_events-DyQEop7s.js" ] }, - "_index-Dzj92ueM.js": { - "file": "assets/index-Dzj92ueM.js", + "_index-DskNhwDJ.js": { + "file": "assets/index-DskNhwDJ.js", + "name": "index", + "isDynamicEntry": true, + "imports": [ + "index.html", + "_events-DyQEop7s.js" + ] + }, + "_index-Dt2-TQyK.js": { + "file": "assets/index-Dt2-TQyK.js", "name": "index", "isDynamicEntry": true, "imports": [ @@ -41,24 +41,24 @@ "node_modules/@walletconnect/modal-ui/dist/index.js" ] }, - "_inherits_browser-Bb3-ajt6.js": { - "file": "assets/inherits_browser-Bb3-ajt6.js", + "_inherits_browser-B8fZ3Rhe.js": { + "file": "assets/inherits_browser-B8fZ3Rhe.js", "name": "inherits_browser", "imports": [ "index.html" ] }, "index.html": { - "file": "assets/index-uonIXzgQ.js", + "file": "assets/index-BpI4vT-j.js", "name": "index", "src": "index.html", "isEntry": true, "dynamicImports": [ "node_modules/viem/_esm/utils/ccip.js", "node_modules/@coinbase/wallet-sdk/dist/index.js", - "_index-Cu6T4rb4.js", + "_index-BE2r4h4L.js", "node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js", - "_index-BpmIcSNW.js", + "_index-DskNhwDJ.js", "node_modules/@walletconnect/ethereum-provider/dist/index.es.js" ], "css": [ @@ -66,7 +66,7 @@ ] }, "node_modules/@coinbase/wallet-sdk/dist/index.js": { - "file": "assets/index-xz6stGwY.js", + "file": "assets/index-BhnqxX7Q.js", "name": "index", "src": "node_modules/@coinbase/wallet-sdk/dist/index.js", "isDynamicEntry": true, @@ -76,7 +76,7 @@ ] }, "node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js": { - "file": "assets/index-DlENImLn.js", + "file": "assets/index-Ctx71FWU.js", "name": "index", "src": "node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js", "isDynamicEntry": true, @@ -85,31 +85,31 @@ ] }, "node_modules/@walletconnect/ethereum-provider/dist/index.es.js": { - "file": "assets/index.es-C5jEvyUt.js", + "file": "assets/index.es-BwINMB1n.js", "name": "index.es", "src": "node_modules/@walletconnect/ethereum-provider/dist/index.es.js", "isDynamicEntry": true, "imports": [ "index.html", - "_events-xQ4utD7e.js", - "_inherits_browser-Bb3-ajt6.js" + "_events-DyQEop7s.js", + "_inherits_browser-B8fZ3Rhe.js" ], "dynamicImports": [ - "_index-Dzj92ueM.js" + "_index-Dt2-TQyK.js" ] }, "node_modules/@walletconnect/modal-ui/dist/index.js": { - "file": "assets/index-DOzQxzSO.js", + "file": "assets/index-CHNnLDtA.js", "name": "index", "src": "node_modules/@walletconnect/modal-ui/dist/index.js", "isDynamicEntry": true, "imports": [ - "_index-Dzj92ueM.js", + "_index-Dt2-TQyK.js", "index.html" ] }, "node_modules/viem/_esm/utils/ccip.js": { - "file": "assets/ccip-DU5pFHxb.js", + "file": "assets/ccip-BfnZBgwN.js", "name": "ccip", "src": "node_modules/viem/_esm/utils/ccip.js", "isDynamicEntry": true, diff --git a/buddybook/assets/ccip-DU5pFHxb.js b/buddybook/assets/ccip-BfnZBgwN.js similarity index 97% rename from buddybook/assets/ccip-DU5pFHxb.js rename to buddybook/assets/ccip-BfnZBgwN.js index bcec42c..767ade6 100644 --- a/buddybook/assets/ccip-DU5pFHxb.js +++ b/buddybook/assets/ccip-BfnZBgwN.js @@ -1 +1 @@ -import{i as h,I as m,B as p,w,x as g,y as E,z as O,c as x,e as b,H as y,A as M}from"./index-uonIXzgQ.js";function R(r,a){if(!h(r,{strict:!1}))throw new m({address:r});if(!h(a,{strict:!1}))throw new m({address:a});return r.toLowerCase()===a.toLowerCase()}class S extends p{constructor({callbackSelector:a,cause:t,data:n,extraData:i,sender:d,urls:s}){var c;super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],(c=t.metaMessages)!=null&&c.length?"":[],"Offchain Gateway Call:",s&&[" Gateway URL(s):",...s.map(f=>` ${w(f)}`)],` Sender: ${d}`,` Data: ${n}`,` Callback selector: ${a}`,` Extra data: ${i}`].flat(),name:"OffchainLookupError"})}}class $ extends p{constructor({result:a,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${w(t)}`,`Response: ${g(a)}`],name:"OffchainLookupResponseMalformedError"})}}class A extends p{constructor({sender:a,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${a}`],name:"OffchainLookupSenderMismatchError"})}}const D="0x556f1830",C={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function G(r,{blockNumber:a,blockTag:t,data:n,to:i}){const{args:d}=E({data:n,abi:[C]}),[s,c,f,u,o]=d,{ccipRead:e}=r,k=e&&typeof(e==null?void 0:e.request)=="function"?e.request:T;try{if(!R(i,s))throw new A({sender:s,to:i});const l=await k({data:f,sender:s,urls:c}),{data:L}=await O(r,{blockNumber:a,blockTag:t,data:x([u,b([{type:"bytes"},{type:"bytes"}],[l,o])]),to:i});return L}catch(l){throw new S({callbackSelector:u,cause:l,data:n,extraData:o,sender:s,urls:c})}}async function T({data:r,sender:a,urls:t}){var i;let n=new Error("An unknown error occurred.");for(let d=0;d` ${w(f)}`)],` Sender: ${d}`,` Data: ${n}`,` Callback selector: ${a}`,` Extra data: ${i}`].flat(),name:"OffchainLookupError"})}}class $ extends p{constructor({result:a,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${w(t)}`,`Response: ${g(a)}`],name:"OffchainLookupResponseMalformedError"})}}class A extends p{constructor({sender:a,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${a}`],name:"OffchainLookupSenderMismatchError"})}}const D="0x556f1830",C={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function G(r,{blockNumber:a,blockTag:t,data:n,to:i}){const{args:d}=E({data:n,abi:[C]}),[s,c,f,u,o]=d,{ccipRead:e}=r,k=e&&typeof(e==null?void 0:e.request)=="function"?e.request:T;try{if(!R(i,s))throw new A({sender:s,to:i});const l=await k({data:f,sender:s,urls:c}),{data:L}=await O(r,{blockNumber:a,blockTag:t,data:x([u,b([{type:"bytes"},{type:"bytes"}],[l,o])]),to:i});return L}catch(l){throw new S({callbackSelector:u,cause:l,data:n,extraData:o,sender:s,urls:c})}}async function T({data:r,sender:a,urls:t}){var i;let n=new Error("An unknown error occurred.");for(let d=0;d0&&(s=n[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var c=f[e];if(c===void 0)return!1;if(typeof c=="function")d(c,this,n);else for(var h=c.length,O=E(c,h),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,j(u)}return t}o.prototype.addListener=function(e,n){return g(this,e,n,!1)};o.prototype.on=o.prototype.addListener;o.prototype.prependListener=function(e,n){return g(this,e,n,!0)};function R(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=R.bind(r);return i.listener=n,r.wrapFn=i,i}o.prototype.once=function(e,n){return v(n),this.on(e,_(this,e,n)),this};o.prototype.prependOnceListener=function(e,n){return v(n),this.prependListener(e,_(this,e,n)),this};o.prototype.removeListener=function(e,n){var r,i,f,s,u;if(v(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(f=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){u=r[s].listener,f=s;break}if(f<0)return this;f===0?r.shift():N(r,f),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||n)}return this};o.prototype.off=o.prototype.removeListener;o.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var f=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(e,n[i]);return this};function w(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?M(i):E(i,i.length)}o.prototype.listeners=function(e){return w(this,e,!0)};o.prototype.rawListeners=function(e){return w(this,e,!1)};o.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):b.call(t,e)};o.prototype.listenerCount=b;function b(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]};function E(t,e){for(var n=new Array(e),r=0;r0&&(s=n[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var c=f[e];if(c===void 0)return!1;if(typeof c=="function")d(c,this,n);else for(var h=c.length,O=E(c,h),r=0;r0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,j(u)}return t}o.prototype.addListener=function(e,n){return g(this,e,n,!1)};o.prototype.on=o.prototype.addListener;o.prototype.prependListener=function(e,n){return g(this,e,n,!0)};function R(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=R.bind(r);return i.listener=n,r.wrapFn=i,i}o.prototype.once=function(e,n){return v(n),this.on(e,_(this,e,n)),this};o.prototype.prependOnceListener=function(e,n){return v(n),this.prependListener(e,_(this,e,n)),this};o.prototype.removeListener=function(e,n){var r,i,f,s,u;if(v(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(f=-1,s=r.length-1;s>=0;s--)if(r[s]===n||r[s].listener===n){u=r[s].listener,f=s;break}if(f<0)return this;f===0?r.shift():N(r,f),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||n)}return this};o.prototype.off=o.prototype.removeListener;o.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var f=Object.keys(r),s;for(i=0;i=0;i--)this.removeListener(e,n[i]);return this};function w(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?M(i):E(i,i.length)}o.prototype.listeners=function(e){return w(this,e,!0)};o.prototype.rawListeners=function(e){return w(this,e,!1)};o.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):b.call(t,e)};o.prototype.listenerCount=b;function b(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?l(this._events):[]};function E(t,e){for(var n=new Array(e),r=0;r{let r;switch(e){case"standard":return r=t,`data:image/svg+xml,%3Csvg width='${t}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return r=t,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${t}' height='${r}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return r=(.1*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return r=(.25*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return r=(.1*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return r=(.25*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return r=t,`data:image/svg+xml,%3Csvg width='${t}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};oi.walletLogo=hu;var ai={};Object.defineProperty(ai,"__esModule",{value:!0});ai.LINK_API_URL=void 0;ai.LINK_API_URL="https://www.walletlink.org";var q={},Vs={exports:{}};Vs.exports;(function(e){(function(t,r){function n(S,o){if(!S)throw new Error(o||"Assertion failed")}function i(S,o){S.super_=o;var u=function(){};u.prototype=o.prototype,S.prototype=new u,S.prototype.constructor=S}function s(S,o,u){if(s.isBN(S))return S;this.negative=0,this.words=null,this.length=0,this.red=null,S!==null&&((o==="le"||o==="be")&&(u=o,o=10),this._init(S||0,o||10,u||"be"))}typeof t=="object"?t.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var a;try{typeof window<"u"&&typeof window.Buffer<"u"?a=window.Buffer:a=Ws.Buffer}catch{}s.isBN=function(o){return o instanceof s?!0:o!==null&&typeof o=="object"&&o.constructor.wordSize===s.wordSize&&Array.isArray(o.words)},s.max=function(o,u){return o.cmp(u)>0?o:u},s.min=function(o,u){return o.cmp(u)<0?o:u},s.prototype._init=function(o,u,f){if(typeof o=="number")return this._initNumber(o,u,f);if(typeof o=="object")return this._initArray(o,u,f);u==="hex"&&(u=16),n(u===(u|0)&&u>=2&&u<=36),o=o.toString().replace(/\s+/g,"");var p=0;o[0]==="-"&&(p++,this.negative=1),p=0;p-=3)E=o[p]|o[p-1]<<8|o[p-2]<<16,this.words[v]|=E<>>26-k&67108863,k+=24,k>=26&&(k-=26,v++);else if(f==="le")for(p=0,v=0;p>>26-k&67108863,k+=24,k>=26&&(k-=26,v++);return this._strip()};function l(S,o){var u=S.charCodeAt(o);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;n(!1,"Invalid character in "+S)}function d(S,o,u){var f=l(S,u);return u-1>=o&&(f|=l(S,u-1)<<4),f}s.prototype._parseHex=function(o,u,f){this.length=Math.ceil((o.length-u)/6),this.words=new Array(this.length);for(var p=0;p=u;p-=2)k=d(o,u,p)<=18?(v-=18,E+=1,this.words[E]|=k>>>26):v+=8;else{var g=o.length-u;for(p=g%2===0?u+1:u;p=18?(v-=18,E+=1,this.words[E]|=k>>>26):v+=8}this._strip()};function h(S,o,u,f){for(var p=0,v=0,E=Math.min(S.length,u),k=o;k=49?v=g-49+10:g>=17?v=g-17+10:v=g,n(g>=0&&v1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=R}catch{s.prototype.inspect=R}else s.prototype.inspect=R;function R(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],C=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],x=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(o,u){o=o||10,u=u|0||1;var f;if(o===16||o==="hex"){f="";for(var p=0,v=0,E=0;E>>24-p&16777215,p+=2,p>=26&&(p-=26,E--),v!==0||E!==this.length-1?f=y[6-g.length]+g+f:f=g+f}for(v!==0&&(f=v.toString(16)+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(o===(o|0)&&o>=2&&o<=36){var c=C[o],w=x[o];f="";var U=this.clone();for(U.negative=0;!U.isZero();){var H=U.modrn(w).toString(o);U=U.idivn(w),U.isZero()?f=H+f:f=y[c-H.length]+H+f}for(this.isZero()&&(f="0"+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var o=this.words[0];return this.length===2?o+=this.words[1]*67108864:this.length===3&&this.words[2]===1?o+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-o:o},s.prototype.toJSON=function(){return this.toString(16,2)},a&&(s.prototype.toBuffer=function(o,u){return this.toArrayLike(a,o,u)}),s.prototype.toArray=function(o,u){return this.toArrayLike(Array,o,u)};var B=function(o,u){return o.allocUnsafe?o.allocUnsafe(u):new o(u)};s.prototype.toArrayLike=function(o,u,f){this._strip();var p=this.byteLength(),v=f||Math.max(1,p);n(p<=v,"byte array longer than desired length"),n(v>0,"Requested array length <= 0");var E=B(o,v),k=u==="le"?"LE":"BE";return this["_toArrayLike"+k](E,p),E},s.prototype._toArrayLikeLE=function(o,u){for(var f=0,p=0,v=0,E=0;v>8&255),f>16&255),E===6?(f>24&255),p=0,E=0):(p=k>>>24,E+=2)}if(f=0&&(o[f--]=k>>8&255),f>=0&&(o[f--]=k>>16&255),E===6?(f>=0&&(o[f--]=k>>24&255),p=0,E=0):(p=k>>>24,E+=2)}if(f>=0)for(o[f--]=p;f>=0;)o[f--]=0},Math.clz32?s.prototype._countBits=function(o){return 32-Math.clz32(o)}:s.prototype._countBits=function(o){var u=o,f=0;return u>=4096&&(f+=13,u>>>=13),u>=64&&(f+=7,u>>>=7),u>=8&&(f+=4,u>>>=4),u>=2&&(f+=2,u>>>=2),f+u},s.prototype._zeroBits=function(o){if(o===0)return 26;var u=o,f=0;return u&8191||(f+=13,u>>>=13),u&127||(f+=7,u>>>=7),u&15||(f+=4,u>>>=4),u&3||(f+=2,u>>>=2),u&1||f++,f},s.prototype.bitLength=function(){var o=this.words[this.length-1],u=this._countBits(o);return(this.length-1)*26+u};function O(S){for(var o=new Array(S.bitLength()),u=0;u>>p&1}return o}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var o=0,u=0;uo.length?this.clone().ior(o):o.clone().ior(this)},s.prototype.uor=function(o){return this.length>o.length?this.clone().iuor(o):o.clone().iuor(this)},s.prototype.iuand=function(o){var u;this.length>o.length?u=o:u=this;for(var f=0;fo.length?this.clone().iand(o):o.clone().iand(this)},s.prototype.uand=function(o){return this.length>o.length?this.clone().iuand(o):o.clone().iuand(this)},s.prototype.iuxor=function(o){var u,f;this.length>o.length?(u=this,f=o):(u=o,f=this);for(var p=0;po.length?this.clone().ixor(o):o.clone().ixor(this)},s.prototype.uxor=function(o){return this.length>o.length?this.clone().iuxor(o):o.clone().iuxor(this)},s.prototype.inotn=function(o){n(typeof o=="number"&&o>=0);var u=Math.ceil(o/26)|0,f=o%26;this._expand(u),f>0&&u--;for(var p=0;p0&&(this.words[p]=~this.words[p]&67108863>>26-f),this._strip()},s.prototype.notn=function(o){return this.clone().inotn(o)},s.prototype.setn=function(o,u){n(typeof o=="number"&&o>=0);var f=o/26|0,p=o%26;return this._expand(f+1),u?this.words[f]=this.words[f]|1<o.length?(f=this,p=o):(f=o,p=this);for(var v=0,E=0;E>>26;for(;v!==0&&E>>26;if(this.length=f.length,v!==0)this.words[this.length]=v,this.length++;else if(f!==this)for(;Eo.length?this.clone().iadd(o):o.clone().iadd(this)},s.prototype.isub=function(o){if(o.negative!==0){o.negative=0;var u=this.iadd(o);return o.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(o),this.negative=1,this._normSign();var f=this.cmp(o);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var p,v;f>0?(p=this,v=o):(p=o,v=this);for(var E=0,k=0;k>26,this.words[k]=u&67108863;for(;E!==0&&k>26,this.words[k]=u&67108863;if(E===0&&k>>26,U=g&67108863,H=Math.min(c,o.length-1),V=Math.max(0,c-S.length+1);V<=H;V++){var A=c-V|0;p=S.words[A]|0,v=o.words[V]|0,E=p*v+U,w+=E/67108864|0,U=E&67108863}u.words[c]=U|0,g=w|0}return g!==0?u.words[c]=g|0:u.length--,u._strip()}var T=function(o,u,f){var p=o.words,v=u.words,E=f.words,k=0,g,c,w,U=p[0]|0,H=U&8191,V=U>>>13,A=p[1]|0,I=A&8191,$=A>>>13,K=p[2]|0,G=K&8191,b=K>>>13,_=p[3]|0,P=_&8191,j=_>>>13,ue=p[4]|0,J=ue&8191,Y=ue>>>13,at=p[5]|0,he=at&8191,pe=at>>>13,Ht=p[6]|0,ge=Ht&8191,de=Ht>>>13,xt=p[7]|0,fe=xt&8191,le=xt>>>13,nt=p[8]|0,ce=nt&8191,me=nt>>>13,wr=p[9]|0,ve=wr&8191,be=wr>>>13,_r=v[0]|0,we=_r&8191,_e=_r>>>13,yr=v[1]|0,ye=yr&8191,Ee=yr>>>13,Er=v[2]|0,Se=Er&8191,Re=Er>>>13,Sr=v[3]|0,Me=Sr&8191,ke=Sr>>>13,Rr=v[4]|0,Ce=Rr&8191,Ie=Rr>>>13,Mr=v[5]|0,xe=Mr&8191,Ae=Mr>>>13,kr=v[6]|0,Te=kr&8191,Ne=kr>>>13,Cr=v[7]|0,Le=Cr&8191,Oe=Cr>>>13,Ir=v[8]|0,Pe=Ir&8191,$e=Ir>>>13,xr=v[9]|0,Be=xr&8191,De=xr>>>13;f.negative=o.negative^u.negative,f.length=19,g=Math.imul(H,we),c=Math.imul(H,_e),c=c+Math.imul(V,we)|0,w=Math.imul(V,_e);var Ut=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,g=Math.imul(I,we),c=Math.imul(I,_e),c=c+Math.imul($,we)|0,w=Math.imul($,_e),g=g+Math.imul(H,ye)|0,c=c+Math.imul(H,Ee)|0,c=c+Math.imul(V,ye)|0,w=w+Math.imul(V,Ee)|0;var Wt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,g=Math.imul(G,we),c=Math.imul(G,_e),c=c+Math.imul(b,we)|0,w=Math.imul(b,_e),g=g+Math.imul(I,ye)|0,c=c+Math.imul(I,Ee)|0,c=c+Math.imul($,ye)|0,w=w+Math.imul($,Ee)|0,g=g+Math.imul(H,Se)|0,c=c+Math.imul(H,Re)|0,c=c+Math.imul(V,Se)|0,w=w+Math.imul(V,Re)|0;var Vt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,g=Math.imul(P,we),c=Math.imul(P,_e),c=c+Math.imul(j,we)|0,w=Math.imul(j,_e),g=g+Math.imul(G,ye)|0,c=c+Math.imul(G,Ee)|0,c=c+Math.imul(b,ye)|0,w=w+Math.imul(b,Ee)|0,g=g+Math.imul(I,Se)|0,c=c+Math.imul(I,Re)|0,c=c+Math.imul($,Se)|0,w=w+Math.imul($,Re)|0,g=g+Math.imul(H,Me)|0,c=c+Math.imul(H,ke)|0,c=c+Math.imul(V,Me)|0,w=w+Math.imul(V,ke)|0;var zt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(zt>>>26)|0,zt&=67108863,g=Math.imul(J,we),c=Math.imul(J,_e),c=c+Math.imul(Y,we)|0,w=Math.imul(Y,_e),g=g+Math.imul(P,ye)|0,c=c+Math.imul(P,Ee)|0,c=c+Math.imul(j,ye)|0,w=w+Math.imul(j,Ee)|0,g=g+Math.imul(G,Se)|0,c=c+Math.imul(G,Re)|0,c=c+Math.imul(b,Se)|0,w=w+Math.imul(b,Re)|0,g=g+Math.imul(I,Me)|0,c=c+Math.imul(I,ke)|0,c=c+Math.imul($,Me)|0,w=w+Math.imul($,ke)|0,g=g+Math.imul(H,Ce)|0,c=c+Math.imul(H,Ie)|0,c=c+Math.imul(V,Ce)|0,w=w+Math.imul(V,Ie)|0;var qt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(qt>>>26)|0,qt&=67108863,g=Math.imul(he,we),c=Math.imul(he,_e),c=c+Math.imul(pe,we)|0,w=Math.imul(pe,_e),g=g+Math.imul(J,ye)|0,c=c+Math.imul(J,Ee)|0,c=c+Math.imul(Y,ye)|0,w=w+Math.imul(Y,Ee)|0,g=g+Math.imul(P,Se)|0,c=c+Math.imul(P,Re)|0,c=c+Math.imul(j,Se)|0,w=w+Math.imul(j,Re)|0,g=g+Math.imul(G,Me)|0,c=c+Math.imul(G,ke)|0,c=c+Math.imul(b,Me)|0,w=w+Math.imul(b,ke)|0,g=g+Math.imul(I,Ce)|0,c=c+Math.imul(I,Ie)|0,c=c+Math.imul($,Ce)|0,w=w+Math.imul($,Ie)|0,g=g+Math.imul(H,xe)|0,c=c+Math.imul(H,Ae)|0,c=c+Math.imul(V,xe)|0,w=w+Math.imul(V,Ae)|0;var Jt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,g=Math.imul(ge,we),c=Math.imul(ge,_e),c=c+Math.imul(de,we)|0,w=Math.imul(de,_e),g=g+Math.imul(he,ye)|0,c=c+Math.imul(he,Ee)|0,c=c+Math.imul(pe,ye)|0,w=w+Math.imul(pe,Ee)|0,g=g+Math.imul(J,Se)|0,c=c+Math.imul(J,Re)|0,c=c+Math.imul(Y,Se)|0,w=w+Math.imul(Y,Re)|0,g=g+Math.imul(P,Me)|0,c=c+Math.imul(P,ke)|0,c=c+Math.imul(j,Me)|0,w=w+Math.imul(j,ke)|0,g=g+Math.imul(G,Ce)|0,c=c+Math.imul(G,Ie)|0,c=c+Math.imul(b,Ce)|0,w=w+Math.imul(b,Ie)|0,g=g+Math.imul(I,xe)|0,c=c+Math.imul(I,Ae)|0,c=c+Math.imul($,xe)|0,w=w+Math.imul($,Ae)|0,g=g+Math.imul(H,Te)|0,c=c+Math.imul(H,Ne)|0,c=c+Math.imul(V,Te)|0,w=w+Math.imul(V,Ne)|0;var Gt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,g=Math.imul(fe,we),c=Math.imul(fe,_e),c=c+Math.imul(le,we)|0,w=Math.imul(le,_e),g=g+Math.imul(ge,ye)|0,c=c+Math.imul(ge,Ee)|0,c=c+Math.imul(de,ye)|0,w=w+Math.imul(de,Ee)|0,g=g+Math.imul(he,Se)|0,c=c+Math.imul(he,Re)|0,c=c+Math.imul(pe,Se)|0,w=w+Math.imul(pe,Re)|0,g=g+Math.imul(J,Me)|0,c=c+Math.imul(J,ke)|0,c=c+Math.imul(Y,Me)|0,w=w+Math.imul(Y,ke)|0,g=g+Math.imul(P,Ce)|0,c=c+Math.imul(P,Ie)|0,c=c+Math.imul(j,Ce)|0,w=w+Math.imul(j,Ie)|0,g=g+Math.imul(G,xe)|0,c=c+Math.imul(G,Ae)|0,c=c+Math.imul(b,xe)|0,w=w+Math.imul(b,Ae)|0,g=g+Math.imul(I,Te)|0,c=c+Math.imul(I,Ne)|0,c=c+Math.imul($,Te)|0,w=w+Math.imul($,Ne)|0,g=g+Math.imul(H,Le)|0,c=c+Math.imul(H,Oe)|0,c=c+Math.imul(V,Le)|0,w=w+Math.imul(V,Oe)|0;var Zt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,g=Math.imul(ce,we),c=Math.imul(ce,_e),c=c+Math.imul(me,we)|0,w=Math.imul(me,_e),g=g+Math.imul(fe,ye)|0,c=c+Math.imul(fe,Ee)|0,c=c+Math.imul(le,ye)|0,w=w+Math.imul(le,Ee)|0,g=g+Math.imul(ge,Se)|0,c=c+Math.imul(ge,Re)|0,c=c+Math.imul(de,Se)|0,w=w+Math.imul(de,Re)|0,g=g+Math.imul(he,Me)|0,c=c+Math.imul(he,ke)|0,c=c+Math.imul(pe,Me)|0,w=w+Math.imul(pe,ke)|0,g=g+Math.imul(J,Ce)|0,c=c+Math.imul(J,Ie)|0,c=c+Math.imul(Y,Ce)|0,w=w+Math.imul(Y,Ie)|0,g=g+Math.imul(P,xe)|0,c=c+Math.imul(P,Ae)|0,c=c+Math.imul(j,xe)|0,w=w+Math.imul(j,Ae)|0,g=g+Math.imul(G,Te)|0,c=c+Math.imul(G,Ne)|0,c=c+Math.imul(b,Te)|0,w=w+Math.imul(b,Ne)|0,g=g+Math.imul(I,Le)|0,c=c+Math.imul(I,Oe)|0,c=c+Math.imul($,Le)|0,w=w+Math.imul($,Oe)|0,g=g+Math.imul(H,Pe)|0,c=c+Math.imul(H,$e)|0,c=c+Math.imul(V,Pe)|0,w=w+Math.imul(V,$e)|0;var Kt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,g=Math.imul(ve,we),c=Math.imul(ve,_e),c=c+Math.imul(be,we)|0,w=Math.imul(be,_e),g=g+Math.imul(ce,ye)|0,c=c+Math.imul(ce,Ee)|0,c=c+Math.imul(me,ye)|0,w=w+Math.imul(me,Ee)|0,g=g+Math.imul(fe,Se)|0,c=c+Math.imul(fe,Re)|0,c=c+Math.imul(le,Se)|0,w=w+Math.imul(le,Re)|0,g=g+Math.imul(ge,Me)|0,c=c+Math.imul(ge,ke)|0,c=c+Math.imul(de,Me)|0,w=w+Math.imul(de,ke)|0,g=g+Math.imul(he,Ce)|0,c=c+Math.imul(he,Ie)|0,c=c+Math.imul(pe,Ce)|0,w=w+Math.imul(pe,Ie)|0,g=g+Math.imul(J,xe)|0,c=c+Math.imul(J,Ae)|0,c=c+Math.imul(Y,xe)|0,w=w+Math.imul(Y,Ae)|0,g=g+Math.imul(P,Te)|0,c=c+Math.imul(P,Ne)|0,c=c+Math.imul(j,Te)|0,w=w+Math.imul(j,Ne)|0,g=g+Math.imul(G,Le)|0,c=c+Math.imul(G,Oe)|0,c=c+Math.imul(b,Le)|0,w=w+Math.imul(b,Oe)|0,g=g+Math.imul(I,Pe)|0,c=c+Math.imul(I,$e)|0,c=c+Math.imul($,Pe)|0,w=w+Math.imul($,$e)|0,g=g+Math.imul(H,Be)|0,c=c+Math.imul(H,De)|0,c=c+Math.imul(V,Be)|0,w=w+Math.imul(V,De)|0;var Qt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,g=Math.imul(ve,ye),c=Math.imul(ve,Ee),c=c+Math.imul(be,ye)|0,w=Math.imul(be,Ee),g=g+Math.imul(ce,Se)|0,c=c+Math.imul(ce,Re)|0,c=c+Math.imul(me,Se)|0,w=w+Math.imul(me,Re)|0,g=g+Math.imul(fe,Me)|0,c=c+Math.imul(fe,ke)|0,c=c+Math.imul(le,Me)|0,w=w+Math.imul(le,ke)|0,g=g+Math.imul(ge,Ce)|0,c=c+Math.imul(ge,Ie)|0,c=c+Math.imul(de,Ce)|0,w=w+Math.imul(de,Ie)|0,g=g+Math.imul(he,xe)|0,c=c+Math.imul(he,Ae)|0,c=c+Math.imul(pe,xe)|0,w=w+Math.imul(pe,Ae)|0,g=g+Math.imul(J,Te)|0,c=c+Math.imul(J,Ne)|0,c=c+Math.imul(Y,Te)|0,w=w+Math.imul(Y,Ne)|0,g=g+Math.imul(P,Le)|0,c=c+Math.imul(P,Oe)|0,c=c+Math.imul(j,Le)|0,w=w+Math.imul(j,Oe)|0,g=g+Math.imul(G,Pe)|0,c=c+Math.imul(G,$e)|0,c=c+Math.imul(b,Pe)|0,w=w+Math.imul(b,$e)|0,g=g+Math.imul(I,Be)|0,c=c+Math.imul(I,De)|0,c=c+Math.imul($,Be)|0,w=w+Math.imul($,De)|0;var Yt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,g=Math.imul(ve,Se),c=Math.imul(ve,Re),c=c+Math.imul(be,Se)|0,w=Math.imul(be,Re),g=g+Math.imul(ce,Me)|0,c=c+Math.imul(ce,ke)|0,c=c+Math.imul(me,Me)|0,w=w+Math.imul(me,ke)|0,g=g+Math.imul(fe,Ce)|0,c=c+Math.imul(fe,Ie)|0,c=c+Math.imul(le,Ce)|0,w=w+Math.imul(le,Ie)|0,g=g+Math.imul(ge,xe)|0,c=c+Math.imul(ge,Ae)|0,c=c+Math.imul(de,xe)|0,w=w+Math.imul(de,Ae)|0,g=g+Math.imul(he,Te)|0,c=c+Math.imul(he,Ne)|0,c=c+Math.imul(pe,Te)|0,w=w+Math.imul(pe,Ne)|0,g=g+Math.imul(J,Le)|0,c=c+Math.imul(J,Oe)|0,c=c+Math.imul(Y,Le)|0,w=w+Math.imul(Y,Oe)|0,g=g+Math.imul(P,Pe)|0,c=c+Math.imul(P,$e)|0,c=c+Math.imul(j,Pe)|0,w=w+Math.imul(j,$e)|0,g=g+Math.imul(G,Be)|0,c=c+Math.imul(G,De)|0,c=c+Math.imul(b,Be)|0,w=w+Math.imul(b,De)|0;var Xt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,g=Math.imul(ve,Me),c=Math.imul(ve,ke),c=c+Math.imul(be,Me)|0,w=Math.imul(be,ke),g=g+Math.imul(ce,Ce)|0,c=c+Math.imul(ce,Ie)|0,c=c+Math.imul(me,Ce)|0,w=w+Math.imul(me,Ie)|0,g=g+Math.imul(fe,xe)|0,c=c+Math.imul(fe,Ae)|0,c=c+Math.imul(le,xe)|0,w=w+Math.imul(le,Ae)|0,g=g+Math.imul(ge,Te)|0,c=c+Math.imul(ge,Ne)|0,c=c+Math.imul(de,Te)|0,w=w+Math.imul(de,Ne)|0,g=g+Math.imul(he,Le)|0,c=c+Math.imul(he,Oe)|0,c=c+Math.imul(pe,Le)|0,w=w+Math.imul(pe,Oe)|0,g=g+Math.imul(J,Pe)|0,c=c+Math.imul(J,$e)|0,c=c+Math.imul(Y,Pe)|0,w=w+Math.imul(Y,$e)|0,g=g+Math.imul(P,Be)|0,c=c+Math.imul(P,De)|0,c=c+Math.imul(j,Be)|0,w=w+Math.imul(j,De)|0;var er=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(er>>>26)|0,er&=67108863,g=Math.imul(ve,Ce),c=Math.imul(ve,Ie),c=c+Math.imul(be,Ce)|0,w=Math.imul(be,Ie),g=g+Math.imul(ce,xe)|0,c=c+Math.imul(ce,Ae)|0,c=c+Math.imul(me,xe)|0,w=w+Math.imul(me,Ae)|0,g=g+Math.imul(fe,Te)|0,c=c+Math.imul(fe,Ne)|0,c=c+Math.imul(le,Te)|0,w=w+Math.imul(le,Ne)|0,g=g+Math.imul(ge,Le)|0,c=c+Math.imul(ge,Oe)|0,c=c+Math.imul(de,Le)|0,w=w+Math.imul(de,Oe)|0,g=g+Math.imul(he,Pe)|0,c=c+Math.imul(he,$e)|0,c=c+Math.imul(pe,Pe)|0,w=w+Math.imul(pe,$e)|0,g=g+Math.imul(J,Be)|0,c=c+Math.imul(J,De)|0,c=c+Math.imul(Y,Be)|0,w=w+Math.imul(Y,De)|0;var tr=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(tr>>>26)|0,tr&=67108863,g=Math.imul(ve,xe),c=Math.imul(ve,Ae),c=c+Math.imul(be,xe)|0,w=Math.imul(be,Ae),g=g+Math.imul(ce,Te)|0,c=c+Math.imul(ce,Ne)|0,c=c+Math.imul(me,Te)|0,w=w+Math.imul(me,Ne)|0,g=g+Math.imul(fe,Le)|0,c=c+Math.imul(fe,Oe)|0,c=c+Math.imul(le,Le)|0,w=w+Math.imul(le,Oe)|0,g=g+Math.imul(ge,Pe)|0,c=c+Math.imul(ge,$e)|0,c=c+Math.imul(de,Pe)|0,w=w+Math.imul(de,$e)|0,g=g+Math.imul(he,Be)|0,c=c+Math.imul(he,De)|0,c=c+Math.imul(pe,Be)|0,w=w+Math.imul(pe,De)|0;var rs=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(rs>>>26)|0,rs&=67108863,g=Math.imul(ve,Te),c=Math.imul(ve,Ne),c=c+Math.imul(be,Te)|0,w=Math.imul(be,Ne),g=g+Math.imul(ce,Le)|0,c=c+Math.imul(ce,Oe)|0,c=c+Math.imul(me,Le)|0,w=w+Math.imul(me,Oe)|0,g=g+Math.imul(fe,Pe)|0,c=c+Math.imul(fe,$e)|0,c=c+Math.imul(le,Pe)|0,w=w+Math.imul(le,$e)|0,g=g+Math.imul(ge,Be)|0,c=c+Math.imul(ge,De)|0,c=c+Math.imul(de,Be)|0,w=w+Math.imul(de,De)|0;var ns=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(ns>>>26)|0,ns&=67108863,g=Math.imul(ve,Le),c=Math.imul(ve,Oe),c=c+Math.imul(be,Le)|0,w=Math.imul(be,Oe),g=g+Math.imul(ce,Pe)|0,c=c+Math.imul(ce,$e)|0,c=c+Math.imul(me,Pe)|0,w=w+Math.imul(me,$e)|0,g=g+Math.imul(fe,Be)|0,c=c+Math.imul(fe,De)|0,c=c+Math.imul(le,Be)|0,w=w+Math.imul(le,De)|0;var is=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(is>>>26)|0,is&=67108863,g=Math.imul(ve,Pe),c=Math.imul(ve,$e),c=c+Math.imul(be,Pe)|0,w=Math.imul(be,$e),g=g+Math.imul(ce,Be)|0,c=c+Math.imul(ce,De)|0,c=c+Math.imul(me,Be)|0,w=w+Math.imul(me,De)|0;var ss=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(ss>>>26)|0,ss&=67108863,g=Math.imul(ve,Be),c=Math.imul(ve,De),c=c+Math.imul(be,Be)|0,w=Math.imul(be,De);var os=(k+g|0)+((c&8191)<<13)|0;return k=(w+(c>>>13)|0)+(os>>>26)|0,os&=67108863,E[0]=Ut,E[1]=Wt,E[2]=Vt,E[3]=zt,E[4]=qt,E[5]=Jt,E[6]=Gt,E[7]=Zt,E[8]=Kt,E[9]=Qt,E[10]=Yt,E[11]=Xt,E[12]=er,E[13]=tr,E[14]=rs,E[15]=ns,E[16]=is,E[17]=ss,E[18]=os,k!==0&&(E[19]=k,f.length++),f};Math.imul||(T=M);function N(S,o,u){u.negative=o.negative^S.negative,u.length=S.length+o.length;for(var f=0,p=0,v=0;v>>26)|0,p+=E>>>26,E&=67108863}u.words[v]=k,f=E,E=p}return f!==0?u.words[v]=f:u.length--,u._strip()}function D(S,o,u){return N(S,o,u)}s.prototype.mulTo=function(o,u){var f,p=this.length+o.length;return this.length===10&&o.length===10?f=T(this,o,u):p<63?f=M(this,o,u):p<1024?f=N(this,o,u):f=D(this,o,u),f},s.prototype.mul=function(o){var u=new s(null);return u.words=new Array(this.length+o.length),this.mulTo(o,u)},s.prototype.mulf=function(o){var u=new s(null);return u.words=new Array(this.length+o.length),D(this,o,u)},s.prototype.imul=function(o){return this.clone().mulTo(o,this)},s.prototype.imuln=function(o){var u=o<0;u&&(o=-o),n(typeof o=="number"),n(o<67108864);for(var f=0,p=0;p>=26,f+=v/67108864|0,f+=E>>>26,this.words[p]=E&67108863}return f!==0&&(this.words[p]=f,this.length++),u?this.ineg():this},s.prototype.muln=function(o){return this.clone().imuln(o)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(o){var u=O(o);if(u.length===0)return new s(1);for(var f=this,p=0;p=0);var u=o%26,f=(o-u)/26,p=67108863>>>26-u<<26-u,v;if(u!==0){var E=0;for(v=0;v>>26-u}E&&(this.words[v]=E,this.length++)}if(f!==0){for(v=this.length-1;v>=0;v--)this.words[v+f]=this.words[v];for(v=0;v=0);var p;u?p=(u-u%26)/26:p=0;var v=o%26,E=Math.min((o-v)/26,this.length),k=67108863^67108863>>>v<E)for(this.length-=E,c=0;c=0&&(w!==0||c>=p);c--){var U=this.words[c]|0;this.words[c]=w<<26-v|U>>>v,w=U&k}return g&&w!==0&&(g.words[g.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(o,u,f){return n(this.negative===0),this.iushrn(o,u,f)},s.prototype.shln=function(o){return this.clone().ishln(o)},s.prototype.ushln=function(o){return this.clone().iushln(o)},s.prototype.shrn=function(o){return this.clone().ishrn(o)},s.prototype.ushrn=function(o){return this.clone().iushrn(o)},s.prototype.testn=function(o){n(typeof o=="number"&&o>=0);var u=o%26,f=(o-u)/26,p=1<=0);var u=o%26,f=(o-u)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(u!==0&&f++,this.length=Math.min(f,this.length),u!==0){var p=67108863^67108863>>>u<=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},s.prototype.isubn=function(o){if(n(typeof o=="number"),n(o<67108864),o<0)return this.iaddn(-o);if(this.negative!==0)return this.negative=0,this.iaddn(o),this.negative=1,this;if(this.words[0]-=o,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u>26)-(g/67108864|0),this.words[v+f]=E&67108863}for(;v>26,this.words[v+f]=E&67108863;if(k===0)return this._strip();for(n(k===-1),k=0,v=0;v>26,this.words[v]=E&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(o,u){var f=this.length-o.length,p=this.clone(),v=o,E=v.words[v.length-1]|0,k=this._countBits(E);f=26-k,f!==0&&(v=v.ushln(f),p.iushln(f),E=v.words[v.length-1]|0);var g=p.length-v.length,c;if(u!=="mod"){c=new s(null),c.length=g+1,c.words=new Array(c.length);for(var w=0;w=0;H--){var V=(p.words[v.length+H]|0)*67108864+(p.words[v.length+H-1]|0);for(V=Math.min(V/E|0,67108863),p._ishlnsubmul(v,V,H);p.negative!==0;)V--,p.negative=0,p._ishlnsubmul(v,1,H),p.isZero()||(p.negative^=1);c&&(c.words[H]=V)}return c&&c._strip(),p._strip(),u!=="div"&&f!==0&&p.iushrn(f),{div:c||null,mod:p}},s.prototype.divmod=function(o,u,f){if(n(!o.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var p,v,E;return this.negative!==0&&o.negative===0?(E=this.neg().divmod(o,u),u!=="mod"&&(p=E.div.neg()),u!=="div"&&(v=E.mod.neg(),f&&v.negative!==0&&v.iadd(o)),{div:p,mod:v}):this.negative===0&&o.negative!==0?(E=this.divmod(o.neg(),u),u!=="mod"&&(p=E.div.neg()),{div:p,mod:E.mod}):this.negative&o.negative?(E=this.neg().divmod(o.neg(),u),u!=="div"&&(v=E.mod.neg(),f&&v.negative!==0&&v.isub(o)),{div:E.div,mod:v}):o.length>this.length||this.cmp(o)<0?{div:new s(0),mod:this}:o.length===1?u==="div"?{div:this.divn(o.words[0]),mod:null}:u==="mod"?{div:null,mod:new s(this.modrn(o.words[0]))}:{div:this.divn(o.words[0]),mod:new s(this.modrn(o.words[0]))}:this._wordDiv(o,u)},s.prototype.div=function(o){return this.divmod(o,"div",!1).div},s.prototype.mod=function(o){return this.divmod(o,"mod",!1).mod},s.prototype.umod=function(o){return this.divmod(o,"mod",!0).mod},s.prototype.divRound=function(o){var u=this.divmod(o);if(u.mod.isZero())return u.div;var f=u.div.negative!==0?u.mod.isub(o):u.mod,p=o.ushrn(1),v=o.andln(1),E=f.cmp(p);return E<0||v===1&&E===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},s.prototype.modrn=function(o){var u=o<0;u&&(o=-o),n(o<=67108863);for(var f=(1<<26)%o,p=0,v=this.length-1;v>=0;v--)p=(f*p+(this.words[v]|0))%o;return u?-p:p},s.prototype.modn=function(o){return this.modrn(o)},s.prototype.idivn=function(o){var u=o<0;u&&(o=-o),n(o<=67108863);for(var f=0,p=this.length-1;p>=0;p--){var v=(this.words[p]|0)+f*67108864;this.words[p]=v/o|0,f=v%o}return this._strip(),u?this.ineg():this},s.prototype.divn=function(o){return this.clone().idivn(o)},s.prototype.egcd=function(o){n(o.negative===0),n(!o.isZero());var u=this,f=o.clone();u.negative!==0?u=u.umod(o):u=u.clone();for(var p=new s(1),v=new s(0),E=new s(0),k=new s(1),g=0;u.isEven()&&f.isEven();)u.iushrn(1),f.iushrn(1),++g;for(var c=f.clone(),w=u.clone();!u.isZero();){for(var U=0,H=1;!(u.words[0]&H)&&U<26;++U,H<<=1);if(U>0)for(u.iushrn(U);U-- >0;)(p.isOdd()||v.isOdd())&&(p.iadd(c),v.isub(w)),p.iushrn(1),v.iushrn(1);for(var V=0,A=1;!(f.words[0]&A)&&V<26;++V,A<<=1);if(V>0)for(f.iushrn(V);V-- >0;)(E.isOdd()||k.isOdd())&&(E.iadd(c),k.isub(w)),E.iushrn(1),k.iushrn(1);u.cmp(f)>=0?(u.isub(f),p.isub(E),v.isub(k)):(f.isub(u),E.isub(p),k.isub(v))}return{a:E,b:k,gcd:f.iushln(g)}},s.prototype._invmp=function(o){n(o.negative===0),n(!o.isZero());var u=this,f=o.clone();u.negative!==0?u=u.umod(o):u=u.clone();for(var p=new s(1),v=new s(0),E=f.clone();u.cmpn(1)>0&&f.cmpn(1)>0;){for(var k=0,g=1;!(u.words[0]&g)&&k<26;++k,g<<=1);if(k>0)for(u.iushrn(k);k-- >0;)p.isOdd()&&p.iadd(E),p.iushrn(1);for(var c=0,w=1;!(f.words[0]&w)&&c<26;++c,w<<=1);if(c>0)for(f.iushrn(c);c-- >0;)v.isOdd()&&v.iadd(E),v.iushrn(1);u.cmp(f)>=0?(u.isub(f),p.isub(v)):(f.isub(u),v.isub(p))}var U;return u.cmpn(1)===0?U=p:U=v,U.cmpn(0)<0&&U.iadd(o),U},s.prototype.gcd=function(o){if(this.isZero())return o.abs();if(o.isZero())return this.abs();var u=this.clone(),f=o.clone();u.negative=0,f.negative=0;for(var p=0;u.isEven()&&f.isEven();p++)u.iushrn(1),f.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;f.isEven();)f.iushrn(1);var v=u.cmp(f);if(v<0){var E=u;u=f,f=E}else if(v===0||f.cmpn(1)===0)break;u.isub(f)}while(!0);return f.iushln(p)},s.prototype.invm=function(o){return this.egcd(o).a.umod(o)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(o){return this.words[0]&o},s.prototype.bincn=function(o){n(typeof o=="number");var u=o%26,f=(o-u)/26,p=1<>>26,k&=67108863,this.words[E]=k}return v!==0&&(this.words[E]=v,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(o){var u=o<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var f;if(this.length>1)f=1;else{u&&(o=-o),n(o<=67108863,"Number is too big");var p=this.words[0]|0;f=p===o?0:po.length)return 1;if(this.length=0;f--){var p=this.words[f]|0,v=o.words[f]|0;if(p!==v){pv&&(u=1);break}}return u},s.prototype.gtn=function(o){return this.cmpn(o)===1},s.prototype.gt=function(o){return this.cmp(o)===1},s.prototype.gten=function(o){return this.cmpn(o)>=0},s.prototype.gte=function(o){return this.cmp(o)>=0},s.prototype.ltn=function(o){return this.cmpn(o)===-1},s.prototype.lt=function(o){return this.cmp(o)===-1},s.prototype.lten=function(o){return this.cmpn(o)<=0},s.prototype.lte=function(o){return this.cmp(o)<=0},s.prototype.eqn=function(o){return this.cmpn(o)===0},s.prototype.eq=function(o){return this.cmp(o)===0},s.red=function(o){return new X(o)},s.prototype.toRed=function(o){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),o.convertTo(this)._forceRed(o)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(o){return this.red=o,this},s.prototype.forceRed=function(o){return n(!this.red,"Already a number in reduction context"),this._forceRed(o)},s.prototype.redAdd=function(o){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,o)},s.prototype.redIAdd=function(o){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,o)},s.prototype.redSub=function(o){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,o)},s.prototype.redISub=function(o){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,o)},s.prototype.redShl=function(o){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,o)},s.prototype.redMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.mul(this,o)},s.prototype.redIMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.imul(this,o)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(o){return n(this.red&&!o.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,o)};var L={k256:null,p224:null,p192:null,p25519:null};function F(S,o){this.name=S,this.p=new s(o,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var o=new s(null);return o.words=new Array(Math.ceil(this.n/13)),o},F.prototype.ireduce=function(o){var u=o,f;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),f=u.bitLength();while(f>this.n);var p=f0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},F.prototype.split=function(o,u){o.iushrn(this.n,0,u)},F.prototype.imulK=function(o){return o.imul(this.k)};function W(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(W,F),W.prototype.split=function(o,u){for(var f=4194303,p=Math.min(o.length,9),v=0;v>>22,E=k}E>>>=22,o.words[v-10]=E,E===0&&o.length>10?o.length-=10:o.length-=9},W.prototype.imulK=function(o){o.words[o.length]=0,o.words[o.length+1]=0,o.length+=2;for(var u=0,f=0;f>>=26,o.words[f]=v,u=p}return u!==0&&(o.words[o.length++]=u),o},s._prime=function(o){if(L[o])return L[o];var u;if(o==="k256")u=new W;else if(o==="p224")u=new te;else if(o==="p192")u=new Z;else if(o==="p25519")u=new z;else throw new Error("Unknown prime "+o);return L[o]=u,u};function X(S){if(typeof S=="string"){var o=s._prime(S);this.m=o.p,this.prime=o}else n(S.gtn(1),"modulus must be greater than 1"),this.m=S,this.prime=null}X.prototype._verify1=function(o){n(o.negative===0,"red works only with positives"),n(o.red,"red works only with red numbers")},X.prototype._verify2=function(o,u){n((o.negative|u.negative)===0,"red works only with positives"),n(o.red&&o.red===u.red,"red works only with red numbers")},X.prototype.imod=function(o){return this.prime?this.prime.ireduce(o)._forceRed(this):(m(o,o.umod(this.m)._forceRed(this)),o)},X.prototype.neg=function(o){return o.isZero()?o.clone():this.m.sub(o)._forceRed(this)},X.prototype.add=function(o,u){this._verify2(o,u);var f=o.add(u);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},X.prototype.iadd=function(o,u){this._verify2(o,u);var f=o.iadd(u);return f.cmp(this.m)>=0&&f.isub(this.m),f},X.prototype.sub=function(o,u){this._verify2(o,u);var f=o.sub(u);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},X.prototype.isub=function(o,u){this._verify2(o,u);var f=o.isub(u);return f.cmpn(0)<0&&f.iadd(this.m),f},X.prototype.shl=function(o,u){return this._verify1(o),this.imod(o.ushln(u))},X.prototype.imul=function(o,u){return this._verify2(o,u),this.imod(o.imul(u))},X.prototype.mul=function(o,u){return this._verify2(o,u),this.imod(o.mul(u))},X.prototype.isqr=function(o){return this.imul(o,o.clone())},X.prototype.sqr=function(o){return this.mul(o,o)},X.prototype.sqrt=function(o){if(o.isZero())return o.clone();var u=this.m.andln(3);if(n(u%2===1),u===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(o,f)}for(var p=this.m.subn(1),v=0;!p.isZero()&&p.andln(1)===0;)v++,p.iushrn(1);n(!p.isZero());var E=new s(1).toRed(this),k=E.redNeg(),g=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new s(2*c*c).toRed(this);this.pow(c,g).cmp(k)!==0;)c.redIAdd(k);for(var w=this.pow(c,p),U=this.pow(o,p.addn(1).iushrn(1)),H=this.pow(o,p),V=v;H.cmp(E)!==0;){for(var A=H,I=0;A.cmp(E)!==0;I++)A=A.redSqr();n(I=0;v--){for(var w=u.words[v],U=c-1;U>=0;U--){var H=w>>U&1;if(E!==p[0]&&(E=this.sqr(E)),H===0&&k===0){g=0;continue}k<<=1,k|=H,g++,!(g!==f&&(v!==0||U!==0))&&(E=this.mul(E,p[k]),g=0,k=0)}c=26}return E},X.prototype.convertTo=function(o){var u=o.umod(this.m);return u===o?u.clone():u},X.prototype.convertFrom=function(o){var u=o.clone();return u.red=null,u},s.mont=function(o){return new ne(o)};function ne(S){X.call(this,S),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ne,X),ne.prototype.convertTo=function(o){return this.imod(o.ushln(this.shift))},ne.prototype.convertFrom=function(o){var u=this.imod(o.mul(this.rinv));return u.red=null,u},ne.prototype.imul=function(o,u){if(o.isZero()||u.isZero())return o.words[0]=0,o.length=1,o;var f=o.imul(u),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=f.isub(p).iushrn(this.shift),E=v;return v.cmp(this.m)>=0?E=v.isub(this.m):v.cmpn(0)<0&&(E=v.iadd(this.m)),E._forceRed(this)},ne.prototype.mul=function(o,u){if(o.isZero()||u.isZero())return new s(0)._forceRed(this);var f=o.mul(u),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=f.isub(p).iushrn(this.shift),E=v;return v.cmp(this.m)>=0?E=v.isub(this.m):v.cmpn(0)<0&&(E=v.iadd(this.m)),E._forceRed(this)},ne.prototype.invm=function(o){var u=this.imod(o._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(e,Q)})(Vs);var ci=Vs.exports,gn={},Nt={};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.errorValues=Nt.standardErrorCodes=void 0;Nt.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};Nt.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var li={},ui={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serialize=e.getErrorCode=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=Nt,r="Unspecified error message.";e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function n(y,C=r){if(y&&Number.isInteger(y)){const x=y.toString();if(m(t.errorValues,x))return t.errorValues[x].message;if(d(y))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return C}e.getMessageFromCode=n;function i(y){if(!Number.isInteger(y))return!1;const C=y.toString();return!!(t.errorValues[C]||d(y))}e.isValidCode=i;function s(y){var C;if(typeof y=="number")return y;if(a(y))return(C=y.code)!==null&&C!==void 0?C:y.errorCode}e.getErrorCode=s;function a(y){return typeof y=="object"&&y!==null&&(typeof y.code=="number"||typeof y.errorCode=="number")}function l(y,{shouldIncludeStack:C=!1}={}){const x={};if(y&&typeof y=="object"&&!Array.isArray(y)&&m(y,"code")&&i(y.code)){const B=y;x.code=B.code,B.message&&typeof B.message=="string"?(x.message=B.message,m(B,"data")&&(x.data=B.data)):(x.message=n(x.code),x.data={originalError:h(y)})}else x.code=t.standardErrorCodes.rpc.internal,x.message=R(y,"message")?y.message:r,x.data={originalError:h(y)};return C&&(x.stack=R(y,"stack")?y.stack:void 0),x}e.serialize=l;function d(y){return y>=-32099&&y<=-32e3}function h(y){return y&&typeof y=="object"&&!Array.isArray(y)?Object.assign({},y):y}function m(y,C){return Object.prototype.hasOwnProperty.call(y,C)}function R(y,C){return typeof y=="object"&&y!==null&&C in y&&typeof y[C]=="string"}})(ui);Object.defineProperty(li,"__esModule",{value:!0});li.standardErrors=void 0;const Ge=Nt,cc=ui;li.standardErrors={rpc:{parse:e=>ct(Ge.standardErrorCodes.rpc.parse,e),invalidRequest:e=>ct(Ge.standardErrorCodes.rpc.invalidRequest,e),invalidParams:e=>ct(Ge.standardErrorCodes.rpc.invalidParams,e),methodNotFound:e=>ct(Ge.standardErrorCodes.rpc.methodNotFound,e),internal:e=>ct(Ge.standardErrorCodes.rpc.internal,e),server:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return ct(t,e)},invalidInput:e=>ct(Ge.standardErrorCodes.rpc.invalidInput,e),resourceNotFound:e=>ct(Ge.standardErrorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>ct(Ge.standardErrorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>ct(Ge.standardErrorCodes.rpc.transactionRejected,e),methodNotSupported:e=>ct(Ge.standardErrorCodes.rpc.methodNotSupported,e),limitExceeded:e=>ct(Ge.standardErrorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>Ar(Ge.standardErrorCodes.provider.userRejectedRequest,e),unauthorized:e=>Ar(Ge.standardErrorCodes.provider.unauthorized,e),unsupportedMethod:e=>Ar(Ge.standardErrorCodes.provider.unsupportedMethod,e),disconnected:e=>Ar(Ge.standardErrorCodes.provider.disconnected,e),chainDisconnected:e=>Ar(Ge.standardErrorCodes.provider.chainDisconnected,e),unsupportedChain:e=>Ar(Ge.standardErrorCodes.provider.unsupportedChain,e),custom:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:r,data:n}=e;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new hc(t,r,n)}}};function ct(e,t){const[r,n]=lc(t);return new uc(e,r||(0,cc.getMessageFromCode)(e),n)}function Ar(e,t){const[r,n]=lc(t);return new hc(e,r||(0,cc.getMessageFromCode)(e),n)}function lc(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:r}=e;if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,r]}}return[]}let uc=class extends Error{constructor(t,r,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string.');super(r),this.code=t,n!==void 0&&(this.data=n)}},hc=class extends uc{constructor(t,r,n){if(!du(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,r,n)}};function du(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}var hi={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.isErrorResponse=void 0;function fu(e){return e.errorMessage!==void 0}Kr.isErrorResponse=fu;var Qr={};Object.defineProperty(Qr,"__esModule",{value:!0});Qr.LIB_VERSION=void 0;Qr.LIB_VERSION="3.9.3";Object.defineProperty(hi,"__esModule",{value:!0});hi.serializeError=void 0;const pu=Kr,gu=Qr,mu=Nt,vu=ui;function bu(e,t){const r=(0,vu.serialize)(wu(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");n.searchParams.set("version",gu.LIB_VERSION),n.searchParams.set("code",r.code.toString());const i=_u(r.data,t);return i&&n.searchParams.set("method",i),n.searchParams.set("message",r.message),Object.assign(Object.assign({},r),{docUrl:n.href})}hi.serializeError=bu;function wu(e){return typeof e=="string"?{message:e,code:mu.standardErrorCodes.rpc.internal}:(0,pu.isErrorResponse)(e)?Object.assign(Object.assign({},e),{message:e.errorMessage,code:e.errorCode,data:{method:e.method}}):e}function _u(e,t){const r=e==null?void 0:e.method;if(r)return r;if(t!==void 0){if(typeof t=="string")return t;if(Array.isArray(t)){if(t.length>0)return t[0].method}else return t.method}}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.standardErrors=e.standardErrorCodes=e.serializeError=e.getMessageFromCode=e.getErrorCode=void 0;const t=Nt;Object.defineProperty(e,"standardErrorCodes",{enumerable:!0,get:function(){return t.standardErrorCodes}});const r=li;Object.defineProperty(e,"standardErrors",{enumerable:!0,get:function(){return r.standardErrors}});const n=hi;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return n.serializeError}});const i=ui;Object.defineProperty(e,"getErrorCode",{enumerable:!0,get:function(){return i.getErrorCode}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return i.getMessageFromCode}})})(gn);var Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.ProviderType=Ve.RegExpString=Ve.IntNumber=Ve.BigIntString=Ve.AddressString=Ve.HexString=Ve.OpaqueType=void 0;function mn(){return e=>e}Ve.OpaqueType=mn;Ve.HexString=mn();Ve.AddressString=mn();Ve.BigIntString=mn();function yu(e){return Math.floor(e)}Ve.IntNumber=yu;Ve.RegExpString=mn();var Ao;(function(e){e.CoinbaseWallet="CoinbaseWallet",e.MetaMask="MetaMask",e.Unselected=""})(Ao||(Ve.ProviderType=Ao={}));var Eu=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(q,"__esModule",{value:!0});q.isMobileWeb=q.getLocation=q.isInIFrame=q.createQrUrl=q.getFavicon=q.range=q.isBigNumber=q.ensureParsedJSONObject=q.ensureBN=q.ensureRegExpString=q.ensureIntNumber=q.ensureBuffer=q.ensureAddressString=q.ensureEvenLengthHexString=q.ensureHexString=q.isHexString=q.prepend0x=q.strip0x=q.has0xPrefix=q.hexStringFromIntNumber=q.intNumberFromHexString=q.bigIntStringFromBN=q.hexStringFromBuffer=q.hexStringToUint8Array=q.uint8ArrayToHex=q.randomBytesHex=void 0;const $t=Eu(ci),pr=gn,dt=Ve,dc=/^[0-9]*$/,fc=/^[a-f0-9]*$/;function Su(e){return pc(crypto.getRandomValues(new Uint8Array(e)))}q.randomBytesHex=Su;function pc(e){return[...e].map(t=>t.toString(16).padStart(2,"0")).join("")}q.uint8ArrayToHex=pc;function Ru(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>parseInt(t,16)))}q.hexStringToUint8Array=Ru;function Mu(e,t=!1){const r=e.toString("hex");return(0,dt.HexString)(t?`0x${r}`:r)}q.hexStringFromBuffer=Mu;function ku(e){return(0,dt.BigIntString)(e.toString(10))}q.bigIntStringFromBN=ku;function Cu(e){return(0,dt.IntNumber)(new $t.default(bn(e,!1),16).toNumber())}q.intNumberFromHexString=Cu;function Iu(e){return(0,dt.HexString)(`0x${new $t.default(e).toString(16)}`)}q.hexStringFromIntNumber=Iu;function zs(e){return e.startsWith("0x")||e.startsWith("0X")}q.has0xPrefix=zs;function di(e){return zs(e)?e.slice(2):e}q.strip0x=di;function gc(e){return zs(e)?`0x${e.slice(2)}`:`0x${e}`}q.prepend0x=gc;function vn(e){if(typeof e!="string")return!1;const t=di(e).toLowerCase();return fc.test(t)}q.isHexString=vn;function mc(e,t=!1){if(typeof e=="string"){const r=di(e).toLowerCase();if(fc.test(r))return(0,dt.HexString)(t?`0x${r}`:r)}throw pr.standardErrors.rpc.invalidParams(`"${String(e)}" is not a hexadecimal string`)}q.ensureHexString=mc;function bn(e,t=!1){let r=mc(e,!1);return r.length%2===1&&(r=(0,dt.HexString)(`0${r}`)),t?(0,dt.HexString)(`0x${r}`):r}q.ensureEvenLengthHexString=bn;function xu(e){if(typeof e=="string"){const t=di(e).toLowerCase();if(vn(t)&&t.length===40)return(0,dt.AddressString)(gc(t))}throw pr.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(e)}`)}q.ensureAddressString=xu;function Au(e){if(Buffer.isBuffer(e))return e;if(typeof e=="string"){if(vn(e)){const t=bn(e,!1);return Buffer.from(t,"hex")}return Buffer.from(e,"utf8")}throw pr.standardErrors.rpc.invalidParams(`Not binary data: ${String(e)}`)}q.ensureBuffer=Au;function vc(e){if(typeof e=="number"&&Number.isInteger(e))return(0,dt.IntNumber)(e);if(typeof e=="string"){if(dc.test(e))return(0,dt.IntNumber)(Number(e));if(vn(e))return(0,dt.IntNumber)(new $t.default(bn(e,!1),16).toNumber())}throw pr.standardErrors.rpc.invalidParams(`Not an integer: ${String(e)}`)}q.ensureIntNumber=vc;function Tu(e){if(e instanceof RegExp)return(0,dt.RegExpString)(e.toString());throw pr.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(e)}`)}q.ensureRegExpString=Tu;function Nu(e){if(e!==null&&($t.default.isBN(e)||bc(e)))return new $t.default(e.toString(10),10);if(typeof e=="number")return new $t.default(vc(e));if(typeof e=="string"){if(dc.test(e))return new $t.default(e,10);if(vn(e))return new $t.default(bn(e,!1),16)}throw pr.standardErrors.rpc.invalidParams(`Not an integer: ${String(e)}`)}q.ensureBN=Nu;function Lu(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw pr.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(e)}`)}q.ensureParsedJSONObject=Lu;function bc(e){if(e==null||typeof e.constructor!="function")return!1;const{constructor:t}=e;return typeof t.config=="function"&&typeof t.EUCLID=="number"}q.isBigNumber=bc;function Ou(e,t){return Array.from({length:t-e},(r,n)=>e+n)}q.range=Ou;function Pu(){const e=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:t,host:r}=document.location,n=e?e.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?t+n:`${t}//${r}${n}`}q.getFavicon=Pu;function $u(e,t,r,n,i,s){const a=n?"parent-id":"id",l=new URLSearchParams({[a]:e,secret:t,server:r,v:i,chainId:s.toString()}).toString();return`${r}/#/link?${l}`}q.createQrUrl=$u;function wc(){try{return window.frameElement!==null}catch{return!1}}q.isInIFrame=wc;function Bu(){try{return wc()&&window.top?window.top.location:window.location}catch{return window.location}}q.getLocation=Bu;function Du(){var e;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((e=window==null?void 0:window.navigator)===null||e===void 0?void 0:e.userAgent)}q.isMobileWeb=Du;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});fi.ScopedLocalStorage=void 0;class Fu{constructor(t){this.scope=t}setItem(t,r){localStorage.setItem(this.scopedKey(t),r)}getItem(t){return localStorage.getItem(this.scopedKey(t))}removeItem(t){localStorage.removeItem(this.scopedKey(t))}clear(){const t=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(t){return`${this.scope}:${t}`}}fi.ScopedLocalStorage=Fu;var Ur={};const ju=Zr(uu);var wn={},_n={},Yr={};Object.defineProperty(Yr,"__esModule",{value:!0});Yr.EVENTS=void 0;Yr.EVENTS={STARTED_CONNECTING:"walletlink_sdk.started.connecting",CONNECTED_STATE_CHANGE:"walletlink_sdk.connected",DISCONNECTED:"walletlink_sdk.disconnected",METADATA_DESTROYED:"walletlink_sdk_metadata_destroyed",LINKED:"walletlink_sdk.linked",FAILURE:"walletlink_sdk.generic_failure",SESSION_CONFIG_RECEIVED:"walletlink_sdk.session_config_event_received",ETH_ACCOUNTS_STATE:"walletlink_sdk.eth_accounts_state",SESSION_STATE_CHANGE:"walletlink_sdk.session_state_change",UNLINKED_ERROR_STATE:"walletlink_sdk.unlinked_error_state",SKIPPED_CLEARING_SESSION:"walletlink_sdk.skipped_clearing_session",GENERAL_ERROR:"walletlink_sdk.general_error",WEB3_REQUEST:"walletlink_sdk.web3.request",WEB3_REQUEST_PUBLISHED:"walletlink_sdk.web3.request_published",WEB3_RESPONSE:"walletlink_sdk.web3.response",METHOD_NOT_IMPLEMENTED:"walletlink_sdk.method_not_implemented",UNKNOWN_ADDRESS_ENCOUNTERED:"walletlink_sdk.unknown_address_encountered"};var ht={};Object.defineProperty(ht,"__esModule",{value:!0});ht.RelayAbstract=ht.APP_VERSION_KEY=ht.LOCAL_STORAGE_ADDRESSES_KEY=ht.WALLET_USER_NAME_KEY=void 0;const To=gn;ht.WALLET_USER_NAME_KEY="walletUsername";ht.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";ht.APP_VERSION_KEY="AppVersion";class Hu{async makeEthereumJSONRPCRequest(t,r){if(!r)throw new Error("Error: No jsonRpcUrl provided");return window.fetch(r,{method:"POST",body:JSON.stringify(t),mode:"cors",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(n=>{if(!n)throw To.standardErrors.rpc.parse({});const i=n,{error:s}=i;if(s)throw(0,To.serializeError)(s,t.method);return i})}}ht.RelayAbstract=Hu;var Xr={},_c={exports:{}},Ps={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh */(function(e,t){var r=ii,n=r.Buffer;function i(a,l){for(var d in a)l[d]=a[d]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=s);function s(a,l,d){return n(a,l,d)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(a,l,d){if(typeof a=="number")throw new TypeError("Argument must not be a number");return n(a,l,d)},s.alloc=function(a,l,d){if(typeof a!="number")throw new TypeError("Argument must be a number");var h=n(a);return l!==void 0?typeof d=="string"?h.fill(l,d):h.fill(l):h.fill(0),h},s.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return n(a)},s.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(a)}})(Ps,Ps.exports);var jt=Ps.exports,yc=jt.Buffer;function pi(e,t){this._block=yc.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}pi.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=yc.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s};pi.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var en=pi,Uu=vt,Ec=en,Wu=jt.Buffer,Vu=[1518500249,1859775393,-1894007588,-899497514],zu=new Array(80);function yn(){this.init(),this._w=zu,Ec.call(this,64,56)}Uu(yn,Ec);yn.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function qu(e){return e<<5|e>>>27}function Ju(e){return e<<30|e>>>2}function Gu(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}yn.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,a=this._e|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<80;++l)t[l]=t[l-3]^t[l-8]^t[l-14]^t[l-16];for(var d=0;d<80;++d){var h=~~(d/20),m=qu(r)+Gu(h,n,i,s)+a+t[d]+Vu[h]|0;a=s,s=i,i=Ju(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0};yn.prototype._hash=function(){var e=Wu.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Zu=yn,Ku=vt,Sc=en,Qu=jt.Buffer,Yu=[1518500249,1859775393,-1894007588,-899497514],Xu=new Array(80);function En(){this.init(),this._w=Xu,Sc.call(this,64,56)}Ku(En,Sc);En.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function eh(e){return e<<1|e>>>31}function th(e){return e<<5|e>>>27}function rh(e){return e<<30|e>>>2}function nh(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}En.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,a=this._e|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<80;++l)t[l]=eh(t[l-3]^t[l-8]^t[l-14]^t[l-16]);for(var d=0;d<80;++d){var h=~~(d/20),m=th(r)+nh(h,n,i,s)+a+t[d]+Yu[h]|0;a=s,s=i,i=rh(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0};En.prototype._hash=function(){var e=Qu.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var ih=En,sh=vt,Rc=en,oh=jt.Buffer,ah=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],ch=new Array(64);function Sn(){this.init(),this._w=ch,Rc.call(this,64,56)}sh(Sn,Rc);Sn.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function lh(e,t,r){return r^e&(t^r)}function uh(e,t,r){return e&t|r&(e|t)}function hh(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function dh(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function fh(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function ph(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Sn.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,a=this._e|0,l=this._f|0,d=this._g|0,h=this._h|0,m=0;m<16;++m)t[m]=e.readInt32BE(m*4);for(;m<64;++m)t[m]=ph(t[m-2])+t[m-7]+fh(t[m-15])+t[m-16]|0;for(var R=0;R<64;++R){var y=h+dh(a)+lh(a,l,d)+ah[R]+t[R]|0,C=hh(r)+uh(r,n,i)|0;h=d,d=l,l=a,a=s+y|0,s=i,i=n,n=r,r=y+C|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0,this._f=l+this._f|0,this._g=d+this._g|0,this._h=h+this._h|0};Sn.prototype._hash=function(){var e=oh.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var Mc=Sn,gh=vt,mh=Mc,vh=en,bh=jt.Buffer,wh=new Array(64);function gi(){this.init(),this._w=wh,vh.call(this,64,56)}gh(gi,mh);gi.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};gi.prototype._hash=function(){var e=bh.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var _h=gi,yh=vt,kc=en,Eh=jt.Buffer,No=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Sh=new Array(160);function Rn(){this.init(),this._w=Sh,kc.call(this,128,112)}yh(Rn,kc);Rn.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Lo(e,t,r){return r^e&(t^r)}function Oo(e,t,r){return e&t|r&(e|t)}function Po(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function $o(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Rh(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function Mh(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function kh(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Ch(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function qe(e,t){return e>>>0>>0?1:0}Rn.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,s=this._dh|0,a=this._eh|0,l=this._fh|0,d=this._gh|0,h=this._hh|0,m=this._al|0,R=this._bl|0,y=this._cl|0,C=this._dl|0,x=this._el|0,B=this._fl|0,O=this._gl|0,M=this._hl|0,T=0;T<32;T+=2)t[T]=e.readInt32BE(T*4),t[T+1]=e.readInt32BE(T*4+4);for(;T<160;T+=2){var N=t[T-30],D=t[T-15*2+1],L=Rh(N,D),F=Mh(D,N);N=t[T-2*2],D=t[T-2*2+1];var W=kh(N,D),te=Ch(D,N),Z=t[T-7*2],z=t[T-7*2+1],X=t[T-16*2],ne=t[T-16*2+1],S=F+z|0,o=L+Z+qe(S,F)|0;S=S+te|0,o=o+W+qe(S,te)|0,S=S+ne|0,o=o+X+qe(S,ne)|0,t[T]=o,t[T+1]=S}for(var u=0;u<160;u+=2){o=t[u],S=t[u+1];var f=Oo(r,n,i),p=Oo(m,R,y),v=Po(r,m),E=Po(m,r),k=$o(a,x),g=$o(x,a),c=No[u],w=No[u+1],U=Lo(a,l,d),H=Lo(x,B,O),V=M+g|0,A=h+k+qe(V,M)|0;V=V+H|0,A=A+U+qe(V,H)|0,V=V+w|0,A=A+c+qe(V,w)|0,V=V+S|0,A=A+o+qe(V,S)|0;var I=E+p|0,$=v+f+qe(I,E)|0;h=d,M=O,d=l,O=B,l=a,B=x,x=C+V|0,a=s+A+qe(x,C)|0,s=i,C=y,i=n,y=R,n=r,R=m,m=V+I|0,r=A+$+qe(m,V)|0}this._al=this._al+m|0,this._bl=this._bl+R|0,this._cl=this._cl+y|0,this._dl=this._dl+C|0,this._el=this._el+x|0,this._fl=this._fl+B|0,this._gl=this._gl+O|0,this._hl=this._hl+M|0,this._ah=this._ah+r+qe(this._al,m)|0,this._bh=this._bh+n+qe(this._bl,R)|0,this._ch=this._ch+i+qe(this._cl,y)|0,this._dh=this._dh+s+qe(this._dl,C)|0,this._eh=this._eh+a+qe(this._el,x)|0,this._fh=this._fh+l+qe(this._fl,B)|0,this._gh=this._gh+d+qe(this._gl,O)|0,this._hh=this._hh+h+qe(this._hl,M)|0};Rn.prototype._hash=function(){var e=Eh.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var Cc=Rn,Ih=vt,xh=Cc,Ah=en,Th=jt.Buffer,Nh=new Array(160);function mi(){this.init(),this._w=Nh,Ah.call(this,128,112)}Ih(mi,xh);mi.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};mi.prototype._hash=function(){var e=Th.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var Lh=mi,gr=_c.exports=function(t){t=t.toLowerCase();var r=gr[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};gr.sha=Zu;gr.sha1=ih;gr.sha224=_h;gr.sha256=Mc;gr.sha384=Lh;gr.sha512=Cc;var Oh=_c.exports;Object.defineProperty(Xr,"__esModule",{value:!0});Xr.Session=void 0;const Bo=Oh,Do=q,Fo="session:id",jo="session:secret",Ho="session:linked";class qs{constructor(t,r,n,i){this._storage=t,this._id=r||(0,Do.randomBytesHex)(16),this._secret=n||(0,Do.randomBytesHex)(32),this._key=new Bo.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!i}static load(t){const r=t.getItem(Fo),n=t.getItem(Ho),i=t.getItem(jo);return r&&i?new qs(t,r,i,n==="1"):null}static hash(t){return new Bo.sha256().update(t).digest("hex")}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(t){this._linked=t,this.persistLinked()}save(){return this._storage.setItem(Fo,this._id),this._storage.setItem(jo,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(Ho,this._linked?"1":"0")}}Xr.Session=qs;var vi={},bi={};Object.defineProperty(bi,"__esModule",{value:!0});bi.Cipher=void 0;const jn=q;class Ph{constructor(t){this.secret=t}async encrypt(t){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",(0,jn.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,s.encode(t)),l=16,d=a.slice(a.byteLength-l),h=a.slice(0,a.byteLength-l),m=new Uint8Array(d),R=new Uint8Array(h),y=new Uint8Array([...n,...m,...R]);return(0,jn.uint8ArrayToHex)(y)}async decrypt(t){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const s=await crypto.subtle.importKey("raw",(0,jn.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=(0,jn.hexStringToUint8Array)(t),l=a.slice(0,12),d=a.slice(12,28),h=a.slice(28),m=new Uint8Array([...h,...d]),R={name:"AES-GCM",iv:new Uint8Array(l)};try{const y=await window.crypto.subtle.decrypt(R,s,m),C=new TextDecoder;n(C.decode(y))}catch(y){i(y)}})()})}}bi.Cipher=Ph;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});wi.WalletLinkHTTP=void 0;class $h{constructor(t,r,n){this.linkAPIUrl=t,this.sessionId=r;const i=`${r}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(t){return Promise.all(t.map(r=>fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(r=>console.error("Unabled to mark event as failed:",r))}async fetchUnseenEvents(){var t;const r=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(r.ok){const{events:n,error:i}=await r.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const s=(t=n==null?void 0:n.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&t!==void 0?t:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${r.status}`)}}wi.WalletLinkHTTP=$h;var Wr={};Object.defineProperty(Wr,"__esModule",{value:!0});Wr.WalletLinkWebSocket=Wr.ConnectionState=void 0;var Br;(function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED"})(Br||(Wr.ConnectionState=Br={}));class Bh{setConnectionStateListener(t){this.connectionStateListener=t}setIncomingDataListener(t){this.incomingDataListener=t}constructor(t,r=WebSocket){this.WebSocketClass=r,this.webSocket=null,this.pendingData=[],this.url=t.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((t,r)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(s){r(s);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,Br.CONNECTING),i.onclose=s=>{var a;this.clearWebSocket(),r(new Error(`websocket error ${s.code}: ${s.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Br.DISCONNECTED)},i.onopen=s=>{var a;t(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Br.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(d=>this.sendData(d)),this.pendingData=[])},i.onmessage=s=>{var a,l;if(s.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const d=JSON.parse(s.data);(l=this.incomingDataListener)===null||l===void 0||l.call(this,d)}catch{}}})}disconnect(){var t;const{webSocket:r}=this;if(r){this.clearWebSocket(),(t=this.connectionStateListener)===null||t===void 0||t.call(this,Br.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{r.close()}catch{}}}sendData(t){const{webSocket:r}=this;if(!r){this.pendingData.push(t),this.connect();return}r.send(t)}clearWebSocket(){const{webSocket:t}=this;t&&(this.webSocket=null,t.onclose=null,t.onerror=null,t.onmessage=null,t.onopen=null)}}Wr.WalletLinkWebSocket=Bh;Object.defineProperty(vi,"__esModule",{value:!0});vi.WalletLinkConnection=void 0;const Tr=Ve,Dh=bi,_t=Yr,Uo=ht,Nr=Xr,Fh=wi,Hn=Wr,Wo=1e4,jh=6e4;class Hh{constructor({session:t,linkAPIUrl:r,listener:n,diagnostic:i,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,Tr.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=l=>{if(!l)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",h=>l.JsonRpcUrl&&this.handleChainUpdated(h,l.JsonRpcUrl)]]).forEach((h,m)=>{const R=l[m];R!==void 0&&h(R)})},this.handleDestroyed=l=>{var d,h;l==="1"&&((d=this.listener)===null||d===void 0||d.resetAndReload(),(h=this.diagnostic)===null||h===void 0||h.log(_t.EVENTS.METADATA_DESTROYED,{alreadyDestroyed:this.isDestroyed,sessionIdHash:Nr.Session.hash(this.session.id)}))},this.handleAccountUpdated=async l=>{var d,h;try{const m=await this.cipher.decrypt(l);(d=this.listener)===null||d===void 0||d.accountUpdated(m)}catch{(h=this.diagnostic)===null||h===void 0||h.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"selectedAddress"})}},this.handleMetadataUpdated=async(l,d)=>{var h,m;try{const R=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.metadataUpdated(l,R)}catch{(m=this.diagnostic)===null||m===void 0||m.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:l})}},this.handleWalletUsernameUpdated=async l=>{this.handleMetadataUpdated(Uo.WALLET_USER_NAME_KEY,l)},this.handleAppVersionUpdated=async l=>{this.handleMetadataUpdated(Uo.APP_VERSION_KEY,l)},this.handleChainUpdated=async(l,d)=>{var h,m;try{const R=await this.cipher.decrypt(l),y=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.chainUpdated(R,y)}catch{(m=this.diagnostic)===null||m===void 0||m.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"chainId|jsonRpcUrl"})}},this.session=t,this.cipher=new Dh.Cipher(t.secret),this.diagnostic=i,this.listener=n;const a=new Hn.WalletLinkWebSocket(`${r}/rpc`,s);a.setConnectionStateListener(async l=>{var d;(d=this.diagnostic)===null||d===void 0||d.log(_t.EVENTS.CONNECTED_STATE_CHANGE,{state:l,sessionIdHash:Nr.Session.hash(t.id)});let h=!1;switch(l){case Hn.ConnectionState.DISCONNECTED:if(!this.destroyed){const m=async()=>{await new Promise(R=>setTimeout(R,5e3)),this.destroyed||a.connect().catch(()=>{m()})};m()}break;case Hn.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),h=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},Wo),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case Hn.ConnectionState.CONNECTING:break}this.connected!==h&&(this.connected=h)}),a.setIncomingDataListener(l=>{var d,h,m;switch(l.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const R=l.type==="IsLinkedOK"?l.linked:void 0;(d=this.diagnostic)===null||d===void 0||d.log(_t.EVENTS.LINKED,{sessionIdHash:Nr.Session.hash(t.id),linked:R,type:l.type,onlineGuests:l.onlineGuests}),this.linked=R||l.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{(h=this.diagnostic)===null||h===void 0||h.log(_t.EVENTS.SESSION_CONFIG_RECEIVED,{sessionIdHash:Nr.Session.hash(t.id),metadata_keys:l&&l.metadata?Object.keys(l.metadata):void 0}),this.handleSessionMetadataUpdated(l.metadata);break}case"Event":{this.handleIncomingEvent(l);break}}l.id!==void 0&&((m=this.requestResolutions.get(l.id))===null||m===void 0||m(l))}),this.ws=a,this.http=new Fh.WalletLinkHTTP(r,t.id,t.key)}connect(){var t;if(this.destroyed)throw new Error("instance is destroyed");(t=this.diagnostic)===null||t===void 0||t.log(_t.EVENTS.STARTED_CONNECTING,{sessionIdHash:Nr.Session.hash(this.session.id)}),this.ws.connect()}destroy(){var t;this.destroyed=!0,this.ws.disconnect(),(t=this.diagnostic)===null||t===void 0||t.log(_t.EVENTS.DISCONNECTED,{sessionIdHash:Nr.Session.hash(this.session.id)}),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(t){var r,n;this._connected=t,t&&((r=this.onceConnected)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.connectedUpdated(t)}setOnceConnected(t){return new Promise(r=>{this.connected?t().then(r):this.onceConnected=()=>{t().then(r),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(t){var r,n;this._linked=t,t&&((r=this.onceLinked)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(t)}setOnceLinked(t){return new Promise(r=>{this.linked?t().then(r):this.onceLinked=()=>{t().then(r),this.onceLinked=void 0}})}async handleIncomingEvent(t){var r,n;if(!(t.type!=="Event"||t.event!=="Web3Response"))try{const i=await this.cipher.decrypt(t.data),s=JSON.parse(i);if(s.type!=="WEB3_RESPONSE")return;(r=this.listener)===null||r===void 0||r.handleWeb3ResponseMessage(s)}catch{(n=this.diagnostic)===null||n===void 0||n.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"incomingEvent"})}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(t=>setTimeout(t,250));try{await this.fetchUnseenEventsAPI()}catch(t){console.error("Unable to check for unseen events",t)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(r=>this.handleIncomingEvent(r))}async setSessionMetadata(t,r){const n={type:"SetSessionConfig",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[t]:r}};return this.setOnceConnected(async()=>{const i=await this.makeRequest(n);if(i.type==="Fail")throw new Error(i.error||"failed to set session metadata")})}async publishEvent(t,r,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},r),{origin:location.origin,relaySource:window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:t,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const a=await this.makeRequest(s);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(t){this.ws.sendData(JSON.stringify(t))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Wo*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(t,r=jh){const n=t.id;this.sendData(t);let i;return Promise.race([new Promise((s,a)=>{i=window.setTimeout(()=>{a(new Error(`request ${n} timed out`))},r)}),new Promise(s=>{this.requestResolutions.set(n,a=>{clearTimeout(i),s(a),this.requestResolutions.delete(n)})})])}async authenticate(){const t={type:"HostSession",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},r=await this.makeRequest(t);if(r.type==="Fail")throw new Error(r.error||"failed to authentcate")}sendIsLinked(){const t={type:"IsLinked",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(t)}sendGetSessionConfig(){const t={type:"GetSessionConfig",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(t)}}vi.WalletLinkConnection=Hh;var Mn={},kn={},Js={};Object.defineProperty(Js,"__esModule",{value:!0});Js.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var Uh=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(kn,"__esModule",{value:!0});kn.injectCssReset=void 0;const Wh=Uh(Js);function Vh(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(Wh.default)),document.documentElement.appendChild(e)}kn.injectCssReset=Vh;var _i={};const tt=Zr(cu);var yi={};function Ic(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t65536?(n[0]=240|(i&1835008)>>>18,n[1]=128|(i&258048)>>>12,n[2]=128|(i&4032)>>>6,n[3]=128|i&63):i>2048?(n[0]=224|(i&61440)>>>12,n[1]=128|(i&4032)>>>6,n[2]=128|i&63):i>128?(n[0]=192|(i&1984)>>>6,n[1]=128|i&63):n[0]=i,this.parsedData.push(n)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}xc.prototype={getLength:function(e){return this.parsedData.length},write:function(e){for(var t=0,r=this.parsedData.length;t=7&&this.setupTypeNumber(e),this.dataCache==null&&(this.dataCache=kt.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var n=-1;n<=7;n++)t+n<=-1||this.moduleCount<=t+n||(0<=r&&r<=6&&(n==0||n==6)||0<=n&&n<=6&&(r==0||r==6)||2<=r&&r<=4&&2<=n&&n<=4?this.modules[e+r][t+n]=!0:this.modules[e+r][t+n]=!1)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=je.getLostPoint(this);(r==0||e>n)&&(e=n,t=r)}return t},createMovieClip:function(e,t,r){var n=e.createEmptyMovieClip(t,r),i=1;this.make();for(var s=0;s>r&1)==1;this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(var r=0;r<18;r++){var n=!e&&(t>>r&1)==1;this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,n=je.getBCHTypeInfo(r),i=0;i<15;i++){var s=!e&&(n>>i&1)==1;i<6?this.modules[i][8]=s:i<8?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(var i=0;i<15;i++){var s=!e&&(n>>i&1)==1;i<8?this.modules[8][this.moduleCount-i-1]=s:i<9?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,n=this.moduleCount-1,i=7,s=0,a=this.moduleCount-1;a>0;a-=2)for(a==6&&a--;;){for(var l=0;l<2;l++)if(this.modules[n][a-l]==null){var d=!1;s>>i&1)==1);var h=je.getMask(t,n,a-l);h&&(d=!d),this.modules[n][a-l]=d,i--,i==-1&&(s++,i=7)}if(n+=r,n<0||this.moduleCount<=n){n-=r,r=-r;break}}}};kt.PAD0=236;kt.PAD1=17;kt.createData=function(e,t,r){for(var n=Mt.getRSBlocks(e,t),i=new Ac,s=0;sl*8)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+l*8+")");for(i.getLengthInBits()+4<=l*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=l*8||(i.put(kt.PAD0,8),i.getLengthInBits()>=l*8));)i.put(kt.PAD1,8);return kt.createBytes(i,n)};kt.createBytes=function(e,t){for(var r=0,n=0,i=0,s=new Array(t.length),a=new Array(t.length),l=0;l=0?C.get(x):0}}for(var B=0,m=0;m=0;)t^=je.G15<=0;)t^=je.G18<>>=1;return t},getPatternPosition:function(e){return je.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case Ot.PATTERN000:return(t+r)%2==0;case Ot.PATTERN001:return t%2==0;case Ot.PATTERN010:return r%3==0;case Ot.PATTERN011:return(t+r)%3==0;case Ot.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2==0;case Ot.PATTERN101:return t*r%2+t*r%3==0;case Ot.PATTERN110:return(t*r%2+t*r%3)%2==0;case Ot.PATTERN111:return(t*r%3+(t+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new Dr([1],0),r=0;r5&&(r+=3+s-5)}for(var n=0;n=256;)e-=255;return Je.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var Ze=0;Ze<8;Ze++)Je.EXP_TABLE[Ze]=1<>>7-e%8&1)==1},put:function(e,t){for(var r=0;r>>t-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var as=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function Tc(e){if(this.options={padding:4,width:256,height:256,typeNumber:4,color:"#000000",background:"#ffffff",ecl:"M",image:{svg:"",width:0,height:0}},typeof e=="string"&&(e={content:e}),e)for(var t in e)this.options[t]=e[t];if(typeof this.options.content!="string")throw new Error("Expected 'content' as string!");if(this.options.content.length===0)throw new Error("Expected 'content' to be non-empty!");if(!(this.options.padding>=0))throw new Error("Expected 'padding' value to be non-negative!");if(!(this.options.width>0)||!(this.options.height>0))throw new Error("Expected 'width' or 'height' value to be higher than zero!");function r(d){switch(d){case"L":return Bt.L;case"M":return Bt.M;case"Q":return Bt.Q;case"H":return Bt.H;default:throw new Error("Unknwon error correction level: "+d)}}function n(d,h){for(var m=i(d),R=1,y=0,C=0,x=as.length;C<=x;C++){var B=as[C];if(!B)throw new Error("Content too long: expected "+y+" but got "+m);switch(h){case"L":y=B[0];break;case"M":y=B[1];break;case"Q":y=B[2];break;case"H":y=B[3];break;default:throw new Error("Unknwon error correction level: "+h)}if(m<=y)break;R++}if(R>as.length)throw new Error("Content too long");return R}function i(d){var h=encodeURI(d).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return h.length+(h.length!=d?3:0)}var s=this.options.content,a=n(s,this.options.ecl),l=r(this.options.ecl);this.qrcode=new kt(a,l),this.qrcode.addData(s),this.qrcode.make()}Tc.prototype.svg=function(e){var t=this.options||{},r=this.qrcode.modules;typeof e>"u"&&(e={container:t.container||"svg"});for(var n=typeof t.pretty<"u"?!!t.pretty:!0,i=n?" ":"",s=n?`\r +import{E as xo,f as Q,j as Zr,p as ii,q as su,r as ou,h as au}from"./index-BpI4vT-j.js";import{r as Ws,i as vt}from"./inherits_browser-B8fZ3Rhe.js";import{p as cu,a as lu}from"./hooks.module-D0gf0yJl.js";import{e as si}from"./events-DyQEop7s.js";const uu=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:xo,default:xo},Symbol.toStringTag,{value:"Module"}));var ac={},hn={},oi={};Object.defineProperty(oi,"__esModule",{value:!0});oi.walletLogo=void 0;const hu=(e,t)=>{let r;switch(e){case"standard":return r=t,`data:image/svg+xml,%3Csvg width='${t}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return r=t,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${t}' height='${r}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return r=(.1*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return r=(.25*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return r=(.1*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return r=(.25*t).toFixed(2),`data:image/svg+xml,%3Csvg width='${t}' height='${r}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return r=t,`data:image/svg+xml,%3Csvg width='${t}' height='${r}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};oi.walletLogo=hu;var ai={};Object.defineProperty(ai,"__esModule",{value:!0});ai.LINK_API_URL=void 0;ai.LINK_API_URL="https://www.walletlink.org";var q={},Vs={exports:{}};Vs.exports;(function(e){(function(t,r){function n(S,o){if(!S)throw new Error(o||"Assertion failed")}function i(S,o){S.super_=o;var u=function(){};u.prototype=o.prototype,S.prototype=new u,S.prototype.constructor=S}function s(S,o,u){if(s.isBN(S))return S;this.negative=0,this.words=null,this.length=0,this.red=null,S!==null&&((o==="le"||o==="be")&&(u=o,o=10),this._init(S||0,o||10,u||"be"))}typeof t=="object"?t.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var a;try{typeof window<"u"&&typeof window.Buffer<"u"?a=window.Buffer:a=Ws.Buffer}catch{}s.isBN=function(o){return o instanceof s?!0:o!==null&&typeof o=="object"&&o.constructor.wordSize===s.wordSize&&Array.isArray(o.words)},s.max=function(o,u){return o.cmp(u)>0?o:u},s.min=function(o,u){return o.cmp(u)<0?o:u},s.prototype._init=function(o,u,f){if(typeof o=="number")return this._initNumber(o,u,f);if(typeof o=="object")return this._initArray(o,u,f);u==="hex"&&(u=16),n(u===(u|0)&&u>=2&&u<=36),o=o.toString().replace(/\s+/g,"");var p=0;o[0]==="-"&&(p++,this.negative=1),p=0;p-=3)E=o[p]|o[p-1]<<8|o[p-2]<<16,this.words[v]|=E<>>26-k&67108863,k+=24,k>=26&&(k-=26,v++);else if(f==="le")for(p=0,v=0;p>>26-k&67108863,k+=24,k>=26&&(k-=26,v++);return this._strip()};function l(S,o){var u=S.charCodeAt(o);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;n(!1,"Invalid character in "+S)}function d(S,o,u){var f=l(S,u);return u-1>=o&&(f|=l(S,u-1)<<4),f}s.prototype._parseHex=function(o,u,f){this.length=Math.ceil((o.length-u)/6),this.words=new Array(this.length);for(var p=0;p=u;p-=2)k=d(o,u,p)<=18?(v-=18,E+=1,this.words[E]|=k>>>26):v+=8;else{var g=o.length-u;for(p=g%2===0?u+1:u;p=18?(v-=18,E+=1,this.words[E]|=k>>>26):v+=8}this._strip()};function h(S,o,u,f){for(var p=0,v=0,E=Math.min(S.length,u),k=o;k=49?v=g-49+10:g>=17?v=g-17+10:v=g,n(g>=0&&v1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=R}catch{s.prototype.inspect=R}else s.prototype.inspect=R;function R(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],C=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],x=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(o,u){o=o||10,u=u|0||1;var f;if(o===16||o==="hex"){f="";for(var p=0,v=0,E=0;E>>24-p&16777215,p+=2,p>=26&&(p-=26,E--),v!==0||E!==this.length-1?f=y[6-g.length]+g+f:f=g+f}for(v!==0&&(f=v.toString(16)+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(o===(o|0)&&o>=2&&o<=36){var c=C[o],w=x[o];f="";var U=this.clone();for(U.negative=0;!U.isZero();){var H=U.modrn(w).toString(o);U=U.idivn(w),U.isZero()?f=H+f:f=y[c-H.length]+H+f}for(this.isZero()&&(f="0"+f);f.length%u!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var o=this.words[0];return this.length===2?o+=this.words[1]*67108864:this.length===3&&this.words[2]===1?o+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-o:o},s.prototype.toJSON=function(){return this.toString(16,2)},a&&(s.prototype.toBuffer=function(o,u){return this.toArrayLike(a,o,u)}),s.prototype.toArray=function(o,u){return this.toArrayLike(Array,o,u)};var B=function(o,u){return o.allocUnsafe?o.allocUnsafe(u):new o(u)};s.prototype.toArrayLike=function(o,u,f){this._strip();var p=this.byteLength(),v=f||Math.max(1,p);n(p<=v,"byte array longer than desired length"),n(v>0,"Requested array length <= 0");var E=B(o,v),k=u==="le"?"LE":"BE";return this["_toArrayLike"+k](E,p),E},s.prototype._toArrayLikeLE=function(o,u){for(var f=0,p=0,v=0,E=0;v>8&255),f>16&255),E===6?(f>24&255),p=0,E=0):(p=k>>>24,E+=2)}if(f=0&&(o[f--]=k>>8&255),f>=0&&(o[f--]=k>>16&255),E===6?(f>=0&&(o[f--]=k>>24&255),p=0,E=0):(p=k>>>24,E+=2)}if(f>=0)for(o[f--]=p;f>=0;)o[f--]=0},Math.clz32?s.prototype._countBits=function(o){return 32-Math.clz32(o)}:s.prototype._countBits=function(o){var u=o,f=0;return u>=4096&&(f+=13,u>>>=13),u>=64&&(f+=7,u>>>=7),u>=8&&(f+=4,u>>>=4),u>=2&&(f+=2,u>>>=2),f+u},s.prototype._zeroBits=function(o){if(o===0)return 26;var u=o,f=0;return u&8191||(f+=13,u>>>=13),u&127||(f+=7,u>>>=7),u&15||(f+=4,u>>>=4),u&3||(f+=2,u>>>=2),u&1||f++,f},s.prototype.bitLength=function(){var o=this.words[this.length-1],u=this._countBits(o);return(this.length-1)*26+u};function O(S){for(var o=new Array(S.bitLength()),u=0;u>>p&1}return o}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var o=0,u=0;uo.length?this.clone().ior(o):o.clone().ior(this)},s.prototype.uor=function(o){return this.length>o.length?this.clone().iuor(o):o.clone().iuor(this)},s.prototype.iuand=function(o){var u;this.length>o.length?u=o:u=this;for(var f=0;fo.length?this.clone().iand(o):o.clone().iand(this)},s.prototype.uand=function(o){return this.length>o.length?this.clone().iuand(o):o.clone().iuand(this)},s.prototype.iuxor=function(o){var u,f;this.length>o.length?(u=this,f=o):(u=o,f=this);for(var p=0;po.length?this.clone().ixor(o):o.clone().ixor(this)},s.prototype.uxor=function(o){return this.length>o.length?this.clone().iuxor(o):o.clone().iuxor(this)},s.prototype.inotn=function(o){n(typeof o=="number"&&o>=0);var u=Math.ceil(o/26)|0,f=o%26;this._expand(u),f>0&&u--;for(var p=0;p0&&(this.words[p]=~this.words[p]&67108863>>26-f),this._strip()},s.prototype.notn=function(o){return this.clone().inotn(o)},s.prototype.setn=function(o,u){n(typeof o=="number"&&o>=0);var f=o/26|0,p=o%26;return this._expand(f+1),u?this.words[f]=this.words[f]|1<o.length?(f=this,p=o):(f=o,p=this);for(var v=0,E=0;E>>26;for(;v!==0&&E>>26;if(this.length=f.length,v!==0)this.words[this.length]=v,this.length++;else if(f!==this)for(;Eo.length?this.clone().iadd(o):o.clone().iadd(this)},s.prototype.isub=function(o){if(o.negative!==0){o.negative=0;var u=this.iadd(o);return o.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(o),this.negative=1,this._normSign();var f=this.cmp(o);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var p,v;f>0?(p=this,v=o):(p=o,v=this);for(var E=0,k=0;k>26,this.words[k]=u&67108863;for(;E!==0&&k>26,this.words[k]=u&67108863;if(E===0&&k>>26,U=g&67108863,H=Math.min(c,o.length-1),V=Math.max(0,c-S.length+1);V<=H;V++){var A=c-V|0;p=S.words[A]|0,v=o.words[V]|0,E=p*v+U,w+=E/67108864|0,U=E&67108863}u.words[c]=U|0,g=w|0}return g!==0?u.words[c]=g|0:u.length--,u._strip()}var T=function(o,u,f){var p=o.words,v=u.words,E=f.words,k=0,g,c,w,U=p[0]|0,H=U&8191,V=U>>>13,A=p[1]|0,I=A&8191,$=A>>>13,K=p[2]|0,G=K&8191,b=K>>>13,_=p[3]|0,P=_&8191,j=_>>>13,ue=p[4]|0,J=ue&8191,Y=ue>>>13,at=p[5]|0,he=at&8191,pe=at>>>13,Ht=p[6]|0,ge=Ht&8191,de=Ht>>>13,xt=p[7]|0,fe=xt&8191,le=xt>>>13,nt=p[8]|0,ce=nt&8191,me=nt>>>13,wr=p[9]|0,ve=wr&8191,be=wr>>>13,_r=v[0]|0,we=_r&8191,_e=_r>>>13,yr=v[1]|0,ye=yr&8191,Ee=yr>>>13,Er=v[2]|0,Se=Er&8191,Re=Er>>>13,Sr=v[3]|0,Me=Sr&8191,ke=Sr>>>13,Rr=v[4]|0,Ce=Rr&8191,Ie=Rr>>>13,Mr=v[5]|0,xe=Mr&8191,Ae=Mr>>>13,kr=v[6]|0,Te=kr&8191,Ne=kr>>>13,Cr=v[7]|0,Le=Cr&8191,Oe=Cr>>>13,Ir=v[8]|0,Pe=Ir&8191,$e=Ir>>>13,xr=v[9]|0,Be=xr&8191,De=xr>>>13;f.negative=o.negative^u.negative,f.length=19,g=Math.imul(H,we),c=Math.imul(H,_e),c=c+Math.imul(V,we)|0,w=Math.imul(V,_e);var Ut=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,g=Math.imul(I,we),c=Math.imul(I,_e),c=c+Math.imul($,we)|0,w=Math.imul($,_e),g=g+Math.imul(H,ye)|0,c=c+Math.imul(H,Ee)|0,c=c+Math.imul(V,ye)|0,w=w+Math.imul(V,Ee)|0;var Wt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,g=Math.imul(G,we),c=Math.imul(G,_e),c=c+Math.imul(b,we)|0,w=Math.imul(b,_e),g=g+Math.imul(I,ye)|0,c=c+Math.imul(I,Ee)|0,c=c+Math.imul($,ye)|0,w=w+Math.imul($,Ee)|0,g=g+Math.imul(H,Se)|0,c=c+Math.imul(H,Re)|0,c=c+Math.imul(V,Se)|0,w=w+Math.imul(V,Re)|0;var Vt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,g=Math.imul(P,we),c=Math.imul(P,_e),c=c+Math.imul(j,we)|0,w=Math.imul(j,_e),g=g+Math.imul(G,ye)|0,c=c+Math.imul(G,Ee)|0,c=c+Math.imul(b,ye)|0,w=w+Math.imul(b,Ee)|0,g=g+Math.imul(I,Se)|0,c=c+Math.imul(I,Re)|0,c=c+Math.imul($,Se)|0,w=w+Math.imul($,Re)|0,g=g+Math.imul(H,Me)|0,c=c+Math.imul(H,ke)|0,c=c+Math.imul(V,Me)|0,w=w+Math.imul(V,ke)|0;var zt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(zt>>>26)|0,zt&=67108863,g=Math.imul(J,we),c=Math.imul(J,_e),c=c+Math.imul(Y,we)|0,w=Math.imul(Y,_e),g=g+Math.imul(P,ye)|0,c=c+Math.imul(P,Ee)|0,c=c+Math.imul(j,ye)|0,w=w+Math.imul(j,Ee)|0,g=g+Math.imul(G,Se)|0,c=c+Math.imul(G,Re)|0,c=c+Math.imul(b,Se)|0,w=w+Math.imul(b,Re)|0,g=g+Math.imul(I,Me)|0,c=c+Math.imul(I,ke)|0,c=c+Math.imul($,Me)|0,w=w+Math.imul($,ke)|0,g=g+Math.imul(H,Ce)|0,c=c+Math.imul(H,Ie)|0,c=c+Math.imul(V,Ce)|0,w=w+Math.imul(V,Ie)|0;var qt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(qt>>>26)|0,qt&=67108863,g=Math.imul(he,we),c=Math.imul(he,_e),c=c+Math.imul(pe,we)|0,w=Math.imul(pe,_e),g=g+Math.imul(J,ye)|0,c=c+Math.imul(J,Ee)|0,c=c+Math.imul(Y,ye)|0,w=w+Math.imul(Y,Ee)|0,g=g+Math.imul(P,Se)|0,c=c+Math.imul(P,Re)|0,c=c+Math.imul(j,Se)|0,w=w+Math.imul(j,Re)|0,g=g+Math.imul(G,Me)|0,c=c+Math.imul(G,ke)|0,c=c+Math.imul(b,Me)|0,w=w+Math.imul(b,ke)|0,g=g+Math.imul(I,Ce)|0,c=c+Math.imul(I,Ie)|0,c=c+Math.imul($,Ce)|0,w=w+Math.imul($,Ie)|0,g=g+Math.imul(H,xe)|0,c=c+Math.imul(H,Ae)|0,c=c+Math.imul(V,xe)|0,w=w+Math.imul(V,Ae)|0;var Jt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,g=Math.imul(ge,we),c=Math.imul(ge,_e),c=c+Math.imul(de,we)|0,w=Math.imul(de,_e),g=g+Math.imul(he,ye)|0,c=c+Math.imul(he,Ee)|0,c=c+Math.imul(pe,ye)|0,w=w+Math.imul(pe,Ee)|0,g=g+Math.imul(J,Se)|0,c=c+Math.imul(J,Re)|0,c=c+Math.imul(Y,Se)|0,w=w+Math.imul(Y,Re)|0,g=g+Math.imul(P,Me)|0,c=c+Math.imul(P,ke)|0,c=c+Math.imul(j,Me)|0,w=w+Math.imul(j,ke)|0,g=g+Math.imul(G,Ce)|0,c=c+Math.imul(G,Ie)|0,c=c+Math.imul(b,Ce)|0,w=w+Math.imul(b,Ie)|0,g=g+Math.imul(I,xe)|0,c=c+Math.imul(I,Ae)|0,c=c+Math.imul($,xe)|0,w=w+Math.imul($,Ae)|0,g=g+Math.imul(H,Te)|0,c=c+Math.imul(H,Ne)|0,c=c+Math.imul(V,Te)|0,w=w+Math.imul(V,Ne)|0;var Gt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,g=Math.imul(fe,we),c=Math.imul(fe,_e),c=c+Math.imul(le,we)|0,w=Math.imul(le,_e),g=g+Math.imul(ge,ye)|0,c=c+Math.imul(ge,Ee)|0,c=c+Math.imul(de,ye)|0,w=w+Math.imul(de,Ee)|0,g=g+Math.imul(he,Se)|0,c=c+Math.imul(he,Re)|0,c=c+Math.imul(pe,Se)|0,w=w+Math.imul(pe,Re)|0,g=g+Math.imul(J,Me)|0,c=c+Math.imul(J,ke)|0,c=c+Math.imul(Y,Me)|0,w=w+Math.imul(Y,ke)|0,g=g+Math.imul(P,Ce)|0,c=c+Math.imul(P,Ie)|0,c=c+Math.imul(j,Ce)|0,w=w+Math.imul(j,Ie)|0,g=g+Math.imul(G,xe)|0,c=c+Math.imul(G,Ae)|0,c=c+Math.imul(b,xe)|0,w=w+Math.imul(b,Ae)|0,g=g+Math.imul(I,Te)|0,c=c+Math.imul(I,Ne)|0,c=c+Math.imul($,Te)|0,w=w+Math.imul($,Ne)|0,g=g+Math.imul(H,Le)|0,c=c+Math.imul(H,Oe)|0,c=c+Math.imul(V,Le)|0,w=w+Math.imul(V,Oe)|0;var Zt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,g=Math.imul(ce,we),c=Math.imul(ce,_e),c=c+Math.imul(me,we)|0,w=Math.imul(me,_e),g=g+Math.imul(fe,ye)|0,c=c+Math.imul(fe,Ee)|0,c=c+Math.imul(le,ye)|0,w=w+Math.imul(le,Ee)|0,g=g+Math.imul(ge,Se)|0,c=c+Math.imul(ge,Re)|0,c=c+Math.imul(de,Se)|0,w=w+Math.imul(de,Re)|0,g=g+Math.imul(he,Me)|0,c=c+Math.imul(he,ke)|0,c=c+Math.imul(pe,Me)|0,w=w+Math.imul(pe,ke)|0,g=g+Math.imul(J,Ce)|0,c=c+Math.imul(J,Ie)|0,c=c+Math.imul(Y,Ce)|0,w=w+Math.imul(Y,Ie)|0,g=g+Math.imul(P,xe)|0,c=c+Math.imul(P,Ae)|0,c=c+Math.imul(j,xe)|0,w=w+Math.imul(j,Ae)|0,g=g+Math.imul(G,Te)|0,c=c+Math.imul(G,Ne)|0,c=c+Math.imul(b,Te)|0,w=w+Math.imul(b,Ne)|0,g=g+Math.imul(I,Le)|0,c=c+Math.imul(I,Oe)|0,c=c+Math.imul($,Le)|0,w=w+Math.imul($,Oe)|0,g=g+Math.imul(H,Pe)|0,c=c+Math.imul(H,$e)|0,c=c+Math.imul(V,Pe)|0,w=w+Math.imul(V,$e)|0;var Kt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,g=Math.imul(ve,we),c=Math.imul(ve,_e),c=c+Math.imul(be,we)|0,w=Math.imul(be,_e),g=g+Math.imul(ce,ye)|0,c=c+Math.imul(ce,Ee)|0,c=c+Math.imul(me,ye)|0,w=w+Math.imul(me,Ee)|0,g=g+Math.imul(fe,Se)|0,c=c+Math.imul(fe,Re)|0,c=c+Math.imul(le,Se)|0,w=w+Math.imul(le,Re)|0,g=g+Math.imul(ge,Me)|0,c=c+Math.imul(ge,ke)|0,c=c+Math.imul(de,Me)|0,w=w+Math.imul(de,ke)|0,g=g+Math.imul(he,Ce)|0,c=c+Math.imul(he,Ie)|0,c=c+Math.imul(pe,Ce)|0,w=w+Math.imul(pe,Ie)|0,g=g+Math.imul(J,xe)|0,c=c+Math.imul(J,Ae)|0,c=c+Math.imul(Y,xe)|0,w=w+Math.imul(Y,Ae)|0,g=g+Math.imul(P,Te)|0,c=c+Math.imul(P,Ne)|0,c=c+Math.imul(j,Te)|0,w=w+Math.imul(j,Ne)|0,g=g+Math.imul(G,Le)|0,c=c+Math.imul(G,Oe)|0,c=c+Math.imul(b,Le)|0,w=w+Math.imul(b,Oe)|0,g=g+Math.imul(I,Pe)|0,c=c+Math.imul(I,$e)|0,c=c+Math.imul($,Pe)|0,w=w+Math.imul($,$e)|0,g=g+Math.imul(H,Be)|0,c=c+Math.imul(H,De)|0,c=c+Math.imul(V,Be)|0,w=w+Math.imul(V,De)|0;var Qt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,g=Math.imul(ve,ye),c=Math.imul(ve,Ee),c=c+Math.imul(be,ye)|0,w=Math.imul(be,Ee),g=g+Math.imul(ce,Se)|0,c=c+Math.imul(ce,Re)|0,c=c+Math.imul(me,Se)|0,w=w+Math.imul(me,Re)|0,g=g+Math.imul(fe,Me)|0,c=c+Math.imul(fe,ke)|0,c=c+Math.imul(le,Me)|0,w=w+Math.imul(le,ke)|0,g=g+Math.imul(ge,Ce)|0,c=c+Math.imul(ge,Ie)|0,c=c+Math.imul(de,Ce)|0,w=w+Math.imul(de,Ie)|0,g=g+Math.imul(he,xe)|0,c=c+Math.imul(he,Ae)|0,c=c+Math.imul(pe,xe)|0,w=w+Math.imul(pe,Ae)|0,g=g+Math.imul(J,Te)|0,c=c+Math.imul(J,Ne)|0,c=c+Math.imul(Y,Te)|0,w=w+Math.imul(Y,Ne)|0,g=g+Math.imul(P,Le)|0,c=c+Math.imul(P,Oe)|0,c=c+Math.imul(j,Le)|0,w=w+Math.imul(j,Oe)|0,g=g+Math.imul(G,Pe)|0,c=c+Math.imul(G,$e)|0,c=c+Math.imul(b,Pe)|0,w=w+Math.imul(b,$e)|0,g=g+Math.imul(I,Be)|0,c=c+Math.imul(I,De)|0,c=c+Math.imul($,Be)|0,w=w+Math.imul($,De)|0;var Yt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,g=Math.imul(ve,Se),c=Math.imul(ve,Re),c=c+Math.imul(be,Se)|0,w=Math.imul(be,Re),g=g+Math.imul(ce,Me)|0,c=c+Math.imul(ce,ke)|0,c=c+Math.imul(me,Me)|0,w=w+Math.imul(me,ke)|0,g=g+Math.imul(fe,Ce)|0,c=c+Math.imul(fe,Ie)|0,c=c+Math.imul(le,Ce)|0,w=w+Math.imul(le,Ie)|0,g=g+Math.imul(ge,xe)|0,c=c+Math.imul(ge,Ae)|0,c=c+Math.imul(de,xe)|0,w=w+Math.imul(de,Ae)|0,g=g+Math.imul(he,Te)|0,c=c+Math.imul(he,Ne)|0,c=c+Math.imul(pe,Te)|0,w=w+Math.imul(pe,Ne)|0,g=g+Math.imul(J,Le)|0,c=c+Math.imul(J,Oe)|0,c=c+Math.imul(Y,Le)|0,w=w+Math.imul(Y,Oe)|0,g=g+Math.imul(P,Pe)|0,c=c+Math.imul(P,$e)|0,c=c+Math.imul(j,Pe)|0,w=w+Math.imul(j,$e)|0,g=g+Math.imul(G,Be)|0,c=c+Math.imul(G,De)|0,c=c+Math.imul(b,Be)|0,w=w+Math.imul(b,De)|0;var Xt=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,g=Math.imul(ve,Me),c=Math.imul(ve,ke),c=c+Math.imul(be,Me)|0,w=Math.imul(be,ke),g=g+Math.imul(ce,Ce)|0,c=c+Math.imul(ce,Ie)|0,c=c+Math.imul(me,Ce)|0,w=w+Math.imul(me,Ie)|0,g=g+Math.imul(fe,xe)|0,c=c+Math.imul(fe,Ae)|0,c=c+Math.imul(le,xe)|0,w=w+Math.imul(le,Ae)|0,g=g+Math.imul(ge,Te)|0,c=c+Math.imul(ge,Ne)|0,c=c+Math.imul(de,Te)|0,w=w+Math.imul(de,Ne)|0,g=g+Math.imul(he,Le)|0,c=c+Math.imul(he,Oe)|0,c=c+Math.imul(pe,Le)|0,w=w+Math.imul(pe,Oe)|0,g=g+Math.imul(J,Pe)|0,c=c+Math.imul(J,$e)|0,c=c+Math.imul(Y,Pe)|0,w=w+Math.imul(Y,$e)|0,g=g+Math.imul(P,Be)|0,c=c+Math.imul(P,De)|0,c=c+Math.imul(j,Be)|0,w=w+Math.imul(j,De)|0;var er=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(er>>>26)|0,er&=67108863,g=Math.imul(ve,Ce),c=Math.imul(ve,Ie),c=c+Math.imul(be,Ce)|0,w=Math.imul(be,Ie),g=g+Math.imul(ce,xe)|0,c=c+Math.imul(ce,Ae)|0,c=c+Math.imul(me,xe)|0,w=w+Math.imul(me,Ae)|0,g=g+Math.imul(fe,Te)|0,c=c+Math.imul(fe,Ne)|0,c=c+Math.imul(le,Te)|0,w=w+Math.imul(le,Ne)|0,g=g+Math.imul(ge,Le)|0,c=c+Math.imul(ge,Oe)|0,c=c+Math.imul(de,Le)|0,w=w+Math.imul(de,Oe)|0,g=g+Math.imul(he,Pe)|0,c=c+Math.imul(he,$e)|0,c=c+Math.imul(pe,Pe)|0,w=w+Math.imul(pe,$e)|0,g=g+Math.imul(J,Be)|0,c=c+Math.imul(J,De)|0,c=c+Math.imul(Y,Be)|0,w=w+Math.imul(Y,De)|0;var tr=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(tr>>>26)|0,tr&=67108863,g=Math.imul(ve,xe),c=Math.imul(ve,Ae),c=c+Math.imul(be,xe)|0,w=Math.imul(be,Ae),g=g+Math.imul(ce,Te)|0,c=c+Math.imul(ce,Ne)|0,c=c+Math.imul(me,Te)|0,w=w+Math.imul(me,Ne)|0,g=g+Math.imul(fe,Le)|0,c=c+Math.imul(fe,Oe)|0,c=c+Math.imul(le,Le)|0,w=w+Math.imul(le,Oe)|0,g=g+Math.imul(ge,Pe)|0,c=c+Math.imul(ge,$e)|0,c=c+Math.imul(de,Pe)|0,w=w+Math.imul(de,$e)|0,g=g+Math.imul(he,Be)|0,c=c+Math.imul(he,De)|0,c=c+Math.imul(pe,Be)|0,w=w+Math.imul(pe,De)|0;var rs=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(rs>>>26)|0,rs&=67108863,g=Math.imul(ve,Te),c=Math.imul(ve,Ne),c=c+Math.imul(be,Te)|0,w=Math.imul(be,Ne),g=g+Math.imul(ce,Le)|0,c=c+Math.imul(ce,Oe)|0,c=c+Math.imul(me,Le)|0,w=w+Math.imul(me,Oe)|0,g=g+Math.imul(fe,Pe)|0,c=c+Math.imul(fe,$e)|0,c=c+Math.imul(le,Pe)|0,w=w+Math.imul(le,$e)|0,g=g+Math.imul(ge,Be)|0,c=c+Math.imul(ge,De)|0,c=c+Math.imul(de,Be)|0,w=w+Math.imul(de,De)|0;var ns=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(ns>>>26)|0,ns&=67108863,g=Math.imul(ve,Le),c=Math.imul(ve,Oe),c=c+Math.imul(be,Le)|0,w=Math.imul(be,Oe),g=g+Math.imul(ce,Pe)|0,c=c+Math.imul(ce,$e)|0,c=c+Math.imul(me,Pe)|0,w=w+Math.imul(me,$e)|0,g=g+Math.imul(fe,Be)|0,c=c+Math.imul(fe,De)|0,c=c+Math.imul(le,Be)|0,w=w+Math.imul(le,De)|0;var is=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(is>>>26)|0,is&=67108863,g=Math.imul(ve,Pe),c=Math.imul(ve,$e),c=c+Math.imul(be,Pe)|0,w=Math.imul(be,$e),g=g+Math.imul(ce,Be)|0,c=c+Math.imul(ce,De)|0,c=c+Math.imul(me,Be)|0,w=w+Math.imul(me,De)|0;var ss=(k+g|0)+((c&8191)<<13)|0;k=(w+(c>>>13)|0)+(ss>>>26)|0,ss&=67108863,g=Math.imul(ve,Be),c=Math.imul(ve,De),c=c+Math.imul(be,Be)|0,w=Math.imul(be,De);var os=(k+g|0)+((c&8191)<<13)|0;return k=(w+(c>>>13)|0)+(os>>>26)|0,os&=67108863,E[0]=Ut,E[1]=Wt,E[2]=Vt,E[3]=zt,E[4]=qt,E[5]=Jt,E[6]=Gt,E[7]=Zt,E[8]=Kt,E[9]=Qt,E[10]=Yt,E[11]=Xt,E[12]=er,E[13]=tr,E[14]=rs,E[15]=ns,E[16]=is,E[17]=ss,E[18]=os,k!==0&&(E[19]=k,f.length++),f};Math.imul||(T=M);function N(S,o,u){u.negative=o.negative^S.negative,u.length=S.length+o.length;for(var f=0,p=0,v=0;v>>26)|0,p+=E>>>26,E&=67108863}u.words[v]=k,f=E,E=p}return f!==0?u.words[v]=f:u.length--,u._strip()}function D(S,o,u){return N(S,o,u)}s.prototype.mulTo=function(o,u){var f,p=this.length+o.length;return this.length===10&&o.length===10?f=T(this,o,u):p<63?f=M(this,o,u):p<1024?f=N(this,o,u):f=D(this,o,u),f},s.prototype.mul=function(o){var u=new s(null);return u.words=new Array(this.length+o.length),this.mulTo(o,u)},s.prototype.mulf=function(o){var u=new s(null);return u.words=new Array(this.length+o.length),D(this,o,u)},s.prototype.imul=function(o){return this.clone().mulTo(o,this)},s.prototype.imuln=function(o){var u=o<0;u&&(o=-o),n(typeof o=="number"),n(o<67108864);for(var f=0,p=0;p>=26,f+=v/67108864|0,f+=E>>>26,this.words[p]=E&67108863}return f!==0&&(this.words[p]=f,this.length++),u?this.ineg():this},s.prototype.muln=function(o){return this.clone().imuln(o)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(o){var u=O(o);if(u.length===0)return new s(1);for(var f=this,p=0;p=0);var u=o%26,f=(o-u)/26,p=67108863>>>26-u<<26-u,v;if(u!==0){var E=0;for(v=0;v>>26-u}E&&(this.words[v]=E,this.length++)}if(f!==0){for(v=this.length-1;v>=0;v--)this.words[v+f]=this.words[v];for(v=0;v=0);var p;u?p=(u-u%26)/26:p=0;var v=o%26,E=Math.min((o-v)/26,this.length),k=67108863^67108863>>>v<E)for(this.length-=E,c=0;c=0&&(w!==0||c>=p);c--){var U=this.words[c]|0;this.words[c]=w<<26-v|U>>>v,w=U&k}return g&&w!==0&&(g.words[g.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(o,u,f){return n(this.negative===0),this.iushrn(o,u,f)},s.prototype.shln=function(o){return this.clone().ishln(o)},s.prototype.ushln=function(o){return this.clone().iushln(o)},s.prototype.shrn=function(o){return this.clone().ishrn(o)},s.prototype.ushrn=function(o){return this.clone().iushrn(o)},s.prototype.testn=function(o){n(typeof o=="number"&&o>=0);var u=o%26,f=(o-u)/26,p=1<=0);var u=o%26,f=(o-u)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(u!==0&&f++,this.length=Math.min(f,this.length),u!==0){var p=67108863^67108863>>>u<=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},s.prototype.isubn=function(o){if(n(typeof o=="number"),n(o<67108864),o<0)return this.iaddn(-o);if(this.negative!==0)return this.negative=0,this.iaddn(o),this.negative=1,this;if(this.words[0]-=o,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u>26)-(g/67108864|0),this.words[v+f]=E&67108863}for(;v>26,this.words[v+f]=E&67108863;if(k===0)return this._strip();for(n(k===-1),k=0,v=0;v>26,this.words[v]=E&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(o,u){var f=this.length-o.length,p=this.clone(),v=o,E=v.words[v.length-1]|0,k=this._countBits(E);f=26-k,f!==0&&(v=v.ushln(f),p.iushln(f),E=v.words[v.length-1]|0);var g=p.length-v.length,c;if(u!=="mod"){c=new s(null),c.length=g+1,c.words=new Array(c.length);for(var w=0;w=0;H--){var V=(p.words[v.length+H]|0)*67108864+(p.words[v.length+H-1]|0);for(V=Math.min(V/E|0,67108863),p._ishlnsubmul(v,V,H);p.negative!==0;)V--,p.negative=0,p._ishlnsubmul(v,1,H),p.isZero()||(p.negative^=1);c&&(c.words[H]=V)}return c&&c._strip(),p._strip(),u!=="div"&&f!==0&&p.iushrn(f),{div:c||null,mod:p}},s.prototype.divmod=function(o,u,f){if(n(!o.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var p,v,E;return this.negative!==0&&o.negative===0?(E=this.neg().divmod(o,u),u!=="mod"&&(p=E.div.neg()),u!=="div"&&(v=E.mod.neg(),f&&v.negative!==0&&v.iadd(o)),{div:p,mod:v}):this.negative===0&&o.negative!==0?(E=this.divmod(o.neg(),u),u!=="mod"&&(p=E.div.neg()),{div:p,mod:E.mod}):this.negative&o.negative?(E=this.neg().divmod(o.neg(),u),u!=="div"&&(v=E.mod.neg(),f&&v.negative!==0&&v.isub(o)),{div:E.div,mod:v}):o.length>this.length||this.cmp(o)<0?{div:new s(0),mod:this}:o.length===1?u==="div"?{div:this.divn(o.words[0]),mod:null}:u==="mod"?{div:null,mod:new s(this.modrn(o.words[0]))}:{div:this.divn(o.words[0]),mod:new s(this.modrn(o.words[0]))}:this._wordDiv(o,u)},s.prototype.div=function(o){return this.divmod(o,"div",!1).div},s.prototype.mod=function(o){return this.divmod(o,"mod",!1).mod},s.prototype.umod=function(o){return this.divmod(o,"mod",!0).mod},s.prototype.divRound=function(o){var u=this.divmod(o);if(u.mod.isZero())return u.div;var f=u.div.negative!==0?u.mod.isub(o):u.mod,p=o.ushrn(1),v=o.andln(1),E=f.cmp(p);return E<0||v===1&&E===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},s.prototype.modrn=function(o){var u=o<0;u&&(o=-o),n(o<=67108863);for(var f=(1<<26)%o,p=0,v=this.length-1;v>=0;v--)p=(f*p+(this.words[v]|0))%o;return u?-p:p},s.prototype.modn=function(o){return this.modrn(o)},s.prototype.idivn=function(o){var u=o<0;u&&(o=-o),n(o<=67108863);for(var f=0,p=this.length-1;p>=0;p--){var v=(this.words[p]|0)+f*67108864;this.words[p]=v/o|0,f=v%o}return this._strip(),u?this.ineg():this},s.prototype.divn=function(o){return this.clone().idivn(o)},s.prototype.egcd=function(o){n(o.negative===0),n(!o.isZero());var u=this,f=o.clone();u.negative!==0?u=u.umod(o):u=u.clone();for(var p=new s(1),v=new s(0),E=new s(0),k=new s(1),g=0;u.isEven()&&f.isEven();)u.iushrn(1),f.iushrn(1),++g;for(var c=f.clone(),w=u.clone();!u.isZero();){for(var U=0,H=1;!(u.words[0]&H)&&U<26;++U,H<<=1);if(U>0)for(u.iushrn(U);U-- >0;)(p.isOdd()||v.isOdd())&&(p.iadd(c),v.isub(w)),p.iushrn(1),v.iushrn(1);for(var V=0,A=1;!(f.words[0]&A)&&V<26;++V,A<<=1);if(V>0)for(f.iushrn(V);V-- >0;)(E.isOdd()||k.isOdd())&&(E.iadd(c),k.isub(w)),E.iushrn(1),k.iushrn(1);u.cmp(f)>=0?(u.isub(f),p.isub(E),v.isub(k)):(f.isub(u),E.isub(p),k.isub(v))}return{a:E,b:k,gcd:f.iushln(g)}},s.prototype._invmp=function(o){n(o.negative===0),n(!o.isZero());var u=this,f=o.clone();u.negative!==0?u=u.umod(o):u=u.clone();for(var p=new s(1),v=new s(0),E=f.clone();u.cmpn(1)>0&&f.cmpn(1)>0;){for(var k=0,g=1;!(u.words[0]&g)&&k<26;++k,g<<=1);if(k>0)for(u.iushrn(k);k-- >0;)p.isOdd()&&p.iadd(E),p.iushrn(1);for(var c=0,w=1;!(f.words[0]&w)&&c<26;++c,w<<=1);if(c>0)for(f.iushrn(c);c-- >0;)v.isOdd()&&v.iadd(E),v.iushrn(1);u.cmp(f)>=0?(u.isub(f),p.isub(v)):(f.isub(u),v.isub(p))}var U;return u.cmpn(1)===0?U=p:U=v,U.cmpn(0)<0&&U.iadd(o),U},s.prototype.gcd=function(o){if(this.isZero())return o.abs();if(o.isZero())return this.abs();var u=this.clone(),f=o.clone();u.negative=0,f.negative=0;for(var p=0;u.isEven()&&f.isEven();p++)u.iushrn(1),f.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;f.isEven();)f.iushrn(1);var v=u.cmp(f);if(v<0){var E=u;u=f,f=E}else if(v===0||f.cmpn(1)===0)break;u.isub(f)}while(!0);return f.iushln(p)},s.prototype.invm=function(o){return this.egcd(o).a.umod(o)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(o){return this.words[0]&o},s.prototype.bincn=function(o){n(typeof o=="number");var u=o%26,f=(o-u)/26,p=1<>>26,k&=67108863,this.words[E]=k}return v!==0&&(this.words[E]=v,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(o){var u=o<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var f;if(this.length>1)f=1;else{u&&(o=-o),n(o<=67108863,"Number is too big");var p=this.words[0]|0;f=p===o?0:po.length)return 1;if(this.length=0;f--){var p=this.words[f]|0,v=o.words[f]|0;if(p!==v){pv&&(u=1);break}}return u},s.prototype.gtn=function(o){return this.cmpn(o)===1},s.prototype.gt=function(o){return this.cmp(o)===1},s.prototype.gten=function(o){return this.cmpn(o)>=0},s.prototype.gte=function(o){return this.cmp(o)>=0},s.prototype.ltn=function(o){return this.cmpn(o)===-1},s.prototype.lt=function(o){return this.cmp(o)===-1},s.prototype.lten=function(o){return this.cmpn(o)<=0},s.prototype.lte=function(o){return this.cmp(o)<=0},s.prototype.eqn=function(o){return this.cmpn(o)===0},s.prototype.eq=function(o){return this.cmp(o)===0},s.red=function(o){return new X(o)},s.prototype.toRed=function(o){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),o.convertTo(this)._forceRed(o)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(o){return this.red=o,this},s.prototype.forceRed=function(o){return n(!this.red,"Already a number in reduction context"),this._forceRed(o)},s.prototype.redAdd=function(o){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,o)},s.prototype.redIAdd=function(o){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,o)},s.prototype.redSub=function(o){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,o)},s.prototype.redISub=function(o){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,o)},s.prototype.redShl=function(o){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,o)},s.prototype.redMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.mul(this,o)},s.prototype.redIMul=function(o){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,o),this.red.imul(this,o)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(o){return n(this.red&&!o.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,o)};var L={k256:null,p224:null,p192:null,p25519:null};function F(S,o){this.name=S,this.p=new s(o,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var o=new s(null);return o.words=new Array(Math.ceil(this.n/13)),o},F.prototype.ireduce=function(o){var u=o,f;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),f=u.bitLength();while(f>this.n);var p=f0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},F.prototype.split=function(o,u){o.iushrn(this.n,0,u)},F.prototype.imulK=function(o){return o.imul(this.k)};function W(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(W,F),W.prototype.split=function(o,u){for(var f=4194303,p=Math.min(o.length,9),v=0;v>>22,E=k}E>>>=22,o.words[v-10]=E,E===0&&o.length>10?o.length-=10:o.length-=9},W.prototype.imulK=function(o){o.words[o.length]=0,o.words[o.length+1]=0,o.length+=2;for(var u=0,f=0;f>>=26,o.words[f]=v,u=p}return u!==0&&(o.words[o.length++]=u),o},s._prime=function(o){if(L[o])return L[o];var u;if(o==="k256")u=new W;else if(o==="p224")u=new te;else if(o==="p192")u=new Z;else if(o==="p25519")u=new z;else throw new Error("Unknown prime "+o);return L[o]=u,u};function X(S){if(typeof S=="string"){var o=s._prime(S);this.m=o.p,this.prime=o}else n(S.gtn(1),"modulus must be greater than 1"),this.m=S,this.prime=null}X.prototype._verify1=function(o){n(o.negative===0,"red works only with positives"),n(o.red,"red works only with red numbers")},X.prototype._verify2=function(o,u){n((o.negative|u.negative)===0,"red works only with positives"),n(o.red&&o.red===u.red,"red works only with red numbers")},X.prototype.imod=function(o){return this.prime?this.prime.ireduce(o)._forceRed(this):(m(o,o.umod(this.m)._forceRed(this)),o)},X.prototype.neg=function(o){return o.isZero()?o.clone():this.m.sub(o)._forceRed(this)},X.prototype.add=function(o,u){this._verify2(o,u);var f=o.add(u);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},X.prototype.iadd=function(o,u){this._verify2(o,u);var f=o.iadd(u);return f.cmp(this.m)>=0&&f.isub(this.m),f},X.prototype.sub=function(o,u){this._verify2(o,u);var f=o.sub(u);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},X.prototype.isub=function(o,u){this._verify2(o,u);var f=o.isub(u);return f.cmpn(0)<0&&f.iadd(this.m),f},X.prototype.shl=function(o,u){return this._verify1(o),this.imod(o.ushln(u))},X.prototype.imul=function(o,u){return this._verify2(o,u),this.imod(o.imul(u))},X.prototype.mul=function(o,u){return this._verify2(o,u),this.imod(o.mul(u))},X.prototype.isqr=function(o){return this.imul(o,o.clone())},X.prototype.sqr=function(o){return this.mul(o,o)},X.prototype.sqrt=function(o){if(o.isZero())return o.clone();var u=this.m.andln(3);if(n(u%2===1),u===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(o,f)}for(var p=this.m.subn(1),v=0;!p.isZero()&&p.andln(1)===0;)v++,p.iushrn(1);n(!p.isZero());var E=new s(1).toRed(this),k=E.redNeg(),g=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new s(2*c*c).toRed(this);this.pow(c,g).cmp(k)!==0;)c.redIAdd(k);for(var w=this.pow(c,p),U=this.pow(o,p.addn(1).iushrn(1)),H=this.pow(o,p),V=v;H.cmp(E)!==0;){for(var A=H,I=0;A.cmp(E)!==0;I++)A=A.redSqr();n(I=0;v--){for(var w=u.words[v],U=c-1;U>=0;U--){var H=w>>U&1;if(E!==p[0]&&(E=this.sqr(E)),H===0&&k===0){g=0;continue}k<<=1,k|=H,g++,!(g!==f&&(v!==0||U!==0))&&(E=this.mul(E,p[k]),g=0,k=0)}c=26}return E},X.prototype.convertTo=function(o){var u=o.umod(this.m);return u===o?u.clone():u},X.prototype.convertFrom=function(o){var u=o.clone();return u.red=null,u},s.mont=function(o){return new ne(o)};function ne(S){X.call(this,S),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(ne,X),ne.prototype.convertTo=function(o){return this.imod(o.ushln(this.shift))},ne.prototype.convertFrom=function(o){var u=this.imod(o.mul(this.rinv));return u.red=null,u},ne.prototype.imul=function(o,u){if(o.isZero()||u.isZero())return o.words[0]=0,o.length=1,o;var f=o.imul(u),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=f.isub(p).iushrn(this.shift),E=v;return v.cmp(this.m)>=0?E=v.isub(this.m):v.cmpn(0)<0&&(E=v.iadd(this.m)),E._forceRed(this)},ne.prototype.mul=function(o,u){if(o.isZero()||u.isZero())return new s(0)._forceRed(this);var f=o.mul(u),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=f.isub(p).iushrn(this.shift),E=v;return v.cmp(this.m)>=0?E=v.isub(this.m):v.cmpn(0)<0&&(E=v.iadd(this.m)),E._forceRed(this)},ne.prototype.invm=function(o){var u=this.imod(o._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(e,Q)})(Vs);var ci=Vs.exports,gn={},Nt={};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.errorValues=Nt.standardErrorCodes=void 0;Nt.standardErrorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}};Nt.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}};var li={},ui={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serialize=e.getErrorCode=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=Nt,r="Unspecified error message.";e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function n(y,C=r){if(y&&Number.isInteger(y)){const x=y.toString();if(m(t.errorValues,x))return t.errorValues[x].message;if(d(y))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return C}e.getMessageFromCode=n;function i(y){if(!Number.isInteger(y))return!1;const C=y.toString();return!!(t.errorValues[C]||d(y))}e.isValidCode=i;function s(y){var C;if(typeof y=="number")return y;if(a(y))return(C=y.code)!==null&&C!==void 0?C:y.errorCode}e.getErrorCode=s;function a(y){return typeof y=="object"&&y!==null&&(typeof y.code=="number"||typeof y.errorCode=="number")}function l(y,{shouldIncludeStack:C=!1}={}){const x={};if(y&&typeof y=="object"&&!Array.isArray(y)&&m(y,"code")&&i(y.code)){const B=y;x.code=B.code,B.message&&typeof B.message=="string"?(x.message=B.message,m(B,"data")&&(x.data=B.data)):(x.message=n(x.code),x.data={originalError:h(y)})}else x.code=t.standardErrorCodes.rpc.internal,x.message=R(y,"message")?y.message:r,x.data={originalError:h(y)};return C&&(x.stack=R(y,"stack")?y.stack:void 0),x}e.serialize=l;function d(y){return y>=-32099&&y<=-32e3}function h(y){return y&&typeof y=="object"&&!Array.isArray(y)?Object.assign({},y):y}function m(y,C){return Object.prototype.hasOwnProperty.call(y,C)}function R(y,C){return typeof y=="object"&&y!==null&&C in y&&typeof y[C]=="string"}})(ui);Object.defineProperty(li,"__esModule",{value:!0});li.standardErrors=void 0;const Ge=Nt,cc=ui;li.standardErrors={rpc:{parse:e=>ct(Ge.standardErrorCodes.rpc.parse,e),invalidRequest:e=>ct(Ge.standardErrorCodes.rpc.invalidRequest,e),invalidParams:e=>ct(Ge.standardErrorCodes.rpc.invalidParams,e),methodNotFound:e=>ct(Ge.standardErrorCodes.rpc.methodNotFound,e),internal:e=>ct(Ge.standardErrorCodes.rpc.internal,e),server:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return ct(t,e)},invalidInput:e=>ct(Ge.standardErrorCodes.rpc.invalidInput,e),resourceNotFound:e=>ct(Ge.standardErrorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>ct(Ge.standardErrorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>ct(Ge.standardErrorCodes.rpc.transactionRejected,e),methodNotSupported:e=>ct(Ge.standardErrorCodes.rpc.methodNotSupported,e),limitExceeded:e=>ct(Ge.standardErrorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>Ar(Ge.standardErrorCodes.provider.userRejectedRequest,e),unauthorized:e=>Ar(Ge.standardErrorCodes.provider.unauthorized,e),unsupportedMethod:e=>Ar(Ge.standardErrorCodes.provider.unsupportedMethod,e),disconnected:e=>Ar(Ge.standardErrorCodes.provider.disconnected,e),chainDisconnected:e=>Ar(Ge.standardErrorCodes.provider.chainDisconnected,e),unsupportedChain:e=>Ar(Ge.standardErrorCodes.provider.unsupportedChain,e),custom:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:r,data:n}=e;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new hc(t,r,n)}}};function ct(e,t){const[r,n]=lc(t);return new uc(e,r||(0,cc.getMessageFromCode)(e),n)}function Ar(e,t){const[r,n]=lc(t);return new hc(e,r||(0,cc.getMessageFromCode)(e),n)}function lc(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:r}=e;if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,r]}}return[]}let uc=class extends Error{constructor(t,r,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string.');super(r),this.code=t,n!==void 0&&(this.data=n)}},hc=class extends uc{constructor(t,r,n){if(!du(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,r,n)}};function du(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}var hi={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.isErrorResponse=void 0;function fu(e){return e.errorMessage!==void 0}Kr.isErrorResponse=fu;var Qr={};Object.defineProperty(Qr,"__esModule",{value:!0});Qr.LIB_VERSION=void 0;Qr.LIB_VERSION="3.9.3";Object.defineProperty(hi,"__esModule",{value:!0});hi.serializeError=void 0;const pu=Kr,gu=Qr,mu=Nt,vu=ui;function bu(e,t){const r=(0,vu.serialize)(wu(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");n.searchParams.set("version",gu.LIB_VERSION),n.searchParams.set("code",r.code.toString());const i=_u(r.data,t);return i&&n.searchParams.set("method",i),n.searchParams.set("message",r.message),Object.assign(Object.assign({},r),{docUrl:n.href})}hi.serializeError=bu;function wu(e){return typeof e=="string"?{message:e,code:mu.standardErrorCodes.rpc.internal}:(0,pu.isErrorResponse)(e)?Object.assign(Object.assign({},e),{message:e.errorMessage,code:e.errorCode,data:{method:e.method}}):e}function _u(e,t){const r=e==null?void 0:e.method;if(r)return r;if(t!==void 0){if(typeof t=="string")return t;if(Array.isArray(t)){if(t.length>0)return t[0].method}else return t.method}}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.standardErrors=e.standardErrorCodes=e.serializeError=e.getMessageFromCode=e.getErrorCode=void 0;const t=Nt;Object.defineProperty(e,"standardErrorCodes",{enumerable:!0,get:function(){return t.standardErrorCodes}});const r=li;Object.defineProperty(e,"standardErrors",{enumerable:!0,get:function(){return r.standardErrors}});const n=hi;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return n.serializeError}});const i=ui;Object.defineProperty(e,"getErrorCode",{enumerable:!0,get:function(){return i.getErrorCode}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return i.getMessageFromCode}})})(gn);var Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.ProviderType=Ve.RegExpString=Ve.IntNumber=Ve.BigIntString=Ve.AddressString=Ve.HexString=Ve.OpaqueType=void 0;function mn(){return e=>e}Ve.OpaqueType=mn;Ve.HexString=mn();Ve.AddressString=mn();Ve.BigIntString=mn();function yu(e){return Math.floor(e)}Ve.IntNumber=yu;Ve.RegExpString=mn();var Ao;(function(e){e.CoinbaseWallet="CoinbaseWallet",e.MetaMask="MetaMask",e.Unselected=""})(Ao||(Ve.ProviderType=Ao={}));var Eu=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(q,"__esModule",{value:!0});q.isMobileWeb=q.getLocation=q.isInIFrame=q.createQrUrl=q.getFavicon=q.range=q.isBigNumber=q.ensureParsedJSONObject=q.ensureBN=q.ensureRegExpString=q.ensureIntNumber=q.ensureBuffer=q.ensureAddressString=q.ensureEvenLengthHexString=q.ensureHexString=q.isHexString=q.prepend0x=q.strip0x=q.has0xPrefix=q.hexStringFromIntNumber=q.intNumberFromHexString=q.bigIntStringFromBN=q.hexStringFromBuffer=q.hexStringToUint8Array=q.uint8ArrayToHex=q.randomBytesHex=void 0;const $t=Eu(ci),pr=gn,dt=Ve,dc=/^[0-9]*$/,fc=/^[a-f0-9]*$/;function Su(e){return pc(crypto.getRandomValues(new Uint8Array(e)))}q.randomBytesHex=Su;function pc(e){return[...e].map(t=>t.toString(16).padStart(2,"0")).join("")}q.uint8ArrayToHex=pc;function Ru(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>parseInt(t,16)))}q.hexStringToUint8Array=Ru;function Mu(e,t=!1){const r=e.toString("hex");return(0,dt.HexString)(t?`0x${r}`:r)}q.hexStringFromBuffer=Mu;function ku(e){return(0,dt.BigIntString)(e.toString(10))}q.bigIntStringFromBN=ku;function Cu(e){return(0,dt.IntNumber)(new $t.default(bn(e,!1),16).toNumber())}q.intNumberFromHexString=Cu;function Iu(e){return(0,dt.HexString)(`0x${new $t.default(e).toString(16)}`)}q.hexStringFromIntNumber=Iu;function zs(e){return e.startsWith("0x")||e.startsWith("0X")}q.has0xPrefix=zs;function di(e){return zs(e)?e.slice(2):e}q.strip0x=di;function gc(e){return zs(e)?`0x${e.slice(2)}`:`0x${e}`}q.prepend0x=gc;function vn(e){if(typeof e!="string")return!1;const t=di(e).toLowerCase();return fc.test(t)}q.isHexString=vn;function mc(e,t=!1){if(typeof e=="string"){const r=di(e).toLowerCase();if(fc.test(r))return(0,dt.HexString)(t?`0x${r}`:r)}throw pr.standardErrors.rpc.invalidParams(`"${String(e)}" is not a hexadecimal string`)}q.ensureHexString=mc;function bn(e,t=!1){let r=mc(e,!1);return r.length%2===1&&(r=(0,dt.HexString)(`0${r}`)),t?(0,dt.HexString)(`0x${r}`):r}q.ensureEvenLengthHexString=bn;function xu(e){if(typeof e=="string"){const t=di(e).toLowerCase();if(vn(t)&&t.length===40)return(0,dt.AddressString)(gc(t))}throw pr.standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(e)}`)}q.ensureAddressString=xu;function Au(e){if(Buffer.isBuffer(e))return e;if(typeof e=="string"){if(vn(e)){const t=bn(e,!1);return Buffer.from(t,"hex")}return Buffer.from(e,"utf8")}throw pr.standardErrors.rpc.invalidParams(`Not binary data: ${String(e)}`)}q.ensureBuffer=Au;function vc(e){if(typeof e=="number"&&Number.isInteger(e))return(0,dt.IntNumber)(e);if(typeof e=="string"){if(dc.test(e))return(0,dt.IntNumber)(Number(e));if(vn(e))return(0,dt.IntNumber)(new $t.default(bn(e,!1),16).toNumber())}throw pr.standardErrors.rpc.invalidParams(`Not an integer: ${String(e)}`)}q.ensureIntNumber=vc;function Tu(e){if(e instanceof RegExp)return(0,dt.RegExpString)(e.toString());throw pr.standardErrors.rpc.invalidParams(`Not a RegExp: ${String(e)}`)}q.ensureRegExpString=Tu;function Nu(e){if(e!==null&&($t.default.isBN(e)||bc(e)))return new $t.default(e.toString(10),10);if(typeof e=="number")return new $t.default(vc(e));if(typeof e=="string"){if(dc.test(e))return new $t.default(e,10);if(vn(e))return new $t.default(bn(e,!1),16)}throw pr.standardErrors.rpc.invalidParams(`Not an integer: ${String(e)}`)}q.ensureBN=Nu;function Lu(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw pr.standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(e)}`)}q.ensureParsedJSONObject=Lu;function bc(e){if(e==null||typeof e.constructor!="function")return!1;const{constructor:t}=e;return typeof t.config=="function"&&typeof t.EUCLID=="number"}q.isBigNumber=bc;function Ou(e,t){return Array.from({length:t-e},(r,n)=>e+n)}q.range=Ou;function Pu(){const e=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:t,host:r}=document.location,n=e?e.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?null:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?t+n:`${t}//${r}${n}`}q.getFavicon=Pu;function $u(e,t,r,n,i,s){const a=n?"parent-id":"id",l=new URLSearchParams({[a]:e,secret:t,server:r,v:i,chainId:s.toString()}).toString();return`${r}/#/link?${l}`}q.createQrUrl=$u;function wc(){try{return window.frameElement!==null}catch{return!1}}q.isInIFrame=wc;function Bu(){try{return wc()&&window.top?window.top.location:window.location}catch{return window.location}}q.getLocation=Bu;function Du(){var e;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((e=window==null?void 0:window.navigator)===null||e===void 0?void 0:e.userAgent)}q.isMobileWeb=Du;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});fi.ScopedLocalStorage=void 0;class Fu{constructor(t){this.scope=t}setItem(t,r){localStorage.setItem(this.scopedKey(t),r)}getItem(t){return localStorage.getItem(this.scopedKey(t))}removeItem(t){localStorage.removeItem(this.scopedKey(t))}clear(){const t=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(t){return`${this.scope}:${t}`}}fi.ScopedLocalStorage=Fu;var Ur={};const ju=Zr(uu);var wn={},_n={},Yr={};Object.defineProperty(Yr,"__esModule",{value:!0});Yr.EVENTS=void 0;Yr.EVENTS={STARTED_CONNECTING:"walletlink_sdk.started.connecting",CONNECTED_STATE_CHANGE:"walletlink_sdk.connected",DISCONNECTED:"walletlink_sdk.disconnected",METADATA_DESTROYED:"walletlink_sdk_metadata_destroyed",LINKED:"walletlink_sdk.linked",FAILURE:"walletlink_sdk.generic_failure",SESSION_CONFIG_RECEIVED:"walletlink_sdk.session_config_event_received",ETH_ACCOUNTS_STATE:"walletlink_sdk.eth_accounts_state",SESSION_STATE_CHANGE:"walletlink_sdk.session_state_change",UNLINKED_ERROR_STATE:"walletlink_sdk.unlinked_error_state",SKIPPED_CLEARING_SESSION:"walletlink_sdk.skipped_clearing_session",GENERAL_ERROR:"walletlink_sdk.general_error",WEB3_REQUEST:"walletlink_sdk.web3.request",WEB3_REQUEST_PUBLISHED:"walletlink_sdk.web3.request_published",WEB3_RESPONSE:"walletlink_sdk.web3.response",METHOD_NOT_IMPLEMENTED:"walletlink_sdk.method_not_implemented",UNKNOWN_ADDRESS_ENCOUNTERED:"walletlink_sdk.unknown_address_encountered"};var ht={};Object.defineProperty(ht,"__esModule",{value:!0});ht.RelayAbstract=ht.APP_VERSION_KEY=ht.LOCAL_STORAGE_ADDRESSES_KEY=ht.WALLET_USER_NAME_KEY=void 0;const To=gn;ht.WALLET_USER_NAME_KEY="walletUsername";ht.LOCAL_STORAGE_ADDRESSES_KEY="Addresses";ht.APP_VERSION_KEY="AppVersion";class Hu{async makeEthereumJSONRPCRequest(t,r){if(!r)throw new Error("Error: No jsonRpcUrl provided");return window.fetch(r,{method:"POST",body:JSON.stringify(t),mode:"cors",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(n=>{if(!n)throw To.standardErrors.rpc.parse({});const i=n,{error:s}=i;if(s)throw(0,To.serializeError)(s,t.method);return i})}}ht.RelayAbstract=Hu;var Xr={},_c={exports:{}},Ps={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh */(function(e,t){var r=ii,n=r.Buffer;function i(a,l){for(var d in a)l[d]=a[d]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=s);function s(a,l,d){return n(a,l,d)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(a,l,d){if(typeof a=="number")throw new TypeError("Argument must not be a number");return n(a,l,d)},s.alloc=function(a,l,d){if(typeof a!="number")throw new TypeError("Argument must be a number");var h=n(a);return l!==void 0?typeof d=="string"?h.fill(l,d):h.fill(l):h.fill(0),h},s.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return n(a)},s.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(a)}})(Ps,Ps.exports);var jt=Ps.exports,yc=jt.Buffer;function pi(e,t){this._block=yc.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}pi.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=yc.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s};pi.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var en=pi,Uu=vt,Ec=en,Wu=jt.Buffer,Vu=[1518500249,1859775393,-1894007588,-899497514],zu=new Array(80);function yn(){this.init(),this._w=zu,Ec.call(this,64,56)}Uu(yn,Ec);yn.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function qu(e){return e<<5|e>>>27}function Ju(e){return e<<30|e>>>2}function Gu(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}yn.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,a=this._e|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<80;++l)t[l]=t[l-3]^t[l-8]^t[l-14]^t[l-16];for(var d=0;d<80;++d){var h=~~(d/20),m=qu(r)+Gu(h,n,i,s)+a+t[d]+Vu[h]|0;a=s,s=i,i=Ju(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0};yn.prototype._hash=function(){var e=Wu.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Zu=yn,Ku=vt,Sc=en,Qu=jt.Buffer,Yu=[1518500249,1859775393,-1894007588,-899497514],Xu=new Array(80);function En(){this.init(),this._w=Xu,Sc.call(this,64,56)}Ku(En,Sc);En.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function eh(e){return e<<1|e>>>31}function th(e){return e<<5|e>>>27}function rh(e){return e<<30|e>>>2}function nh(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}En.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,a=this._e|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<80;++l)t[l]=eh(t[l-3]^t[l-8]^t[l-14]^t[l-16]);for(var d=0;d<80;++d){var h=~~(d/20),m=th(r)+nh(h,n,i,s)+a+t[d]+Yu[h]|0;a=s,s=i,i=rh(n),n=r,r=m}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0};En.prototype._hash=function(){var e=Qu.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var ih=En,sh=vt,Rc=en,oh=jt.Buffer,ah=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],ch=new Array(64);function Sn(){this.init(),this._w=ch,Rc.call(this,64,56)}sh(Sn,Rc);Sn.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function lh(e,t,r){return r^e&(t^r)}function uh(e,t,r){return e&t|r&(e|t)}function hh(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function dh(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function fh(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function ph(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Sn.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,a=this._e|0,l=this._f|0,d=this._g|0,h=this._h|0,m=0;m<16;++m)t[m]=e.readInt32BE(m*4);for(;m<64;++m)t[m]=ph(t[m-2])+t[m-7]+fh(t[m-15])+t[m-16]|0;for(var R=0;R<64;++R){var y=h+dh(a)+lh(a,l,d)+ah[R]+t[R]|0,C=hh(r)+uh(r,n,i)|0;h=d,d=l,l=a,a=s+y|0,s=i,i=n,n=r,r=y+C|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0,this._f=l+this._f|0,this._g=d+this._g|0,this._h=h+this._h|0};Sn.prototype._hash=function(){var e=oh.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var Mc=Sn,gh=vt,mh=Mc,vh=en,bh=jt.Buffer,wh=new Array(64);function gi(){this.init(),this._w=wh,vh.call(this,64,56)}gh(gi,mh);gi.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};gi.prototype._hash=function(){var e=bh.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var _h=gi,yh=vt,kc=en,Eh=jt.Buffer,No=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Sh=new Array(160);function Rn(){this.init(),this._w=Sh,kc.call(this,128,112)}yh(Rn,kc);Rn.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Lo(e,t,r){return r^e&(t^r)}function Oo(e,t,r){return e&t|r&(e|t)}function Po(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function $o(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Rh(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function Mh(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function kh(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Ch(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function qe(e,t){return e>>>0>>0?1:0}Rn.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,s=this._dh|0,a=this._eh|0,l=this._fh|0,d=this._gh|0,h=this._hh|0,m=this._al|0,R=this._bl|0,y=this._cl|0,C=this._dl|0,x=this._el|0,B=this._fl|0,O=this._gl|0,M=this._hl|0,T=0;T<32;T+=2)t[T]=e.readInt32BE(T*4),t[T+1]=e.readInt32BE(T*4+4);for(;T<160;T+=2){var N=t[T-30],D=t[T-15*2+1],L=Rh(N,D),F=Mh(D,N);N=t[T-2*2],D=t[T-2*2+1];var W=kh(N,D),te=Ch(D,N),Z=t[T-7*2],z=t[T-7*2+1],X=t[T-16*2],ne=t[T-16*2+1],S=F+z|0,o=L+Z+qe(S,F)|0;S=S+te|0,o=o+W+qe(S,te)|0,S=S+ne|0,o=o+X+qe(S,ne)|0,t[T]=o,t[T+1]=S}for(var u=0;u<160;u+=2){o=t[u],S=t[u+1];var f=Oo(r,n,i),p=Oo(m,R,y),v=Po(r,m),E=Po(m,r),k=$o(a,x),g=$o(x,a),c=No[u],w=No[u+1],U=Lo(a,l,d),H=Lo(x,B,O),V=M+g|0,A=h+k+qe(V,M)|0;V=V+H|0,A=A+U+qe(V,H)|0,V=V+w|0,A=A+c+qe(V,w)|0,V=V+S|0,A=A+o+qe(V,S)|0;var I=E+p|0,$=v+f+qe(I,E)|0;h=d,M=O,d=l,O=B,l=a,B=x,x=C+V|0,a=s+A+qe(x,C)|0,s=i,C=y,i=n,y=R,n=r,R=m,m=V+I|0,r=A+$+qe(m,V)|0}this._al=this._al+m|0,this._bl=this._bl+R|0,this._cl=this._cl+y|0,this._dl=this._dl+C|0,this._el=this._el+x|0,this._fl=this._fl+B|0,this._gl=this._gl+O|0,this._hl=this._hl+M|0,this._ah=this._ah+r+qe(this._al,m)|0,this._bh=this._bh+n+qe(this._bl,R)|0,this._ch=this._ch+i+qe(this._cl,y)|0,this._dh=this._dh+s+qe(this._dl,C)|0,this._eh=this._eh+a+qe(this._el,x)|0,this._fh=this._fh+l+qe(this._fl,B)|0,this._gh=this._gh+d+qe(this._gl,O)|0,this._hh=this._hh+h+qe(this._hl,M)|0};Rn.prototype._hash=function(){var e=Eh.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var Cc=Rn,Ih=vt,xh=Cc,Ah=en,Th=jt.Buffer,Nh=new Array(160);function mi(){this.init(),this._w=Nh,Ah.call(this,128,112)}Ih(mi,xh);mi.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};mi.prototype._hash=function(){var e=Th.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var Lh=mi,gr=_c.exports=function(t){t=t.toLowerCase();var r=gr[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};gr.sha=Zu;gr.sha1=ih;gr.sha224=_h;gr.sha256=Mc;gr.sha384=Lh;gr.sha512=Cc;var Oh=_c.exports;Object.defineProperty(Xr,"__esModule",{value:!0});Xr.Session=void 0;const Bo=Oh,Do=q,Fo="session:id",jo="session:secret",Ho="session:linked";class qs{constructor(t,r,n,i){this._storage=t,this._id=r||(0,Do.randomBytesHex)(16),this._secret=n||(0,Do.randomBytesHex)(32),this._key=new Bo.sha256().update(`${this._id}, ${this._secret} WalletLink`).digest("hex"),this._linked=!!i}static load(t){const r=t.getItem(Fo),n=t.getItem(Ho),i=t.getItem(jo);return r&&i?new qs(t,r,i,n==="1"):null}static hash(t){return new Bo.sha256().update(t).digest("hex")}get id(){return this._id}get secret(){return this._secret}get key(){return this._key}get linked(){return this._linked}set linked(t){this._linked=t,this.persistLinked()}save(){return this._storage.setItem(Fo,this._id),this._storage.setItem(jo,this._secret),this.persistLinked(),this}persistLinked(){this._storage.setItem(Ho,this._linked?"1":"0")}}Xr.Session=qs;var vi={},bi={};Object.defineProperty(bi,"__esModule",{value:!0});bi.Cipher=void 0;const jn=q;class Ph{constructor(t){this.secret=t}async encrypt(t){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",(0,jn.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,s.encode(t)),l=16,d=a.slice(a.byteLength-l),h=a.slice(0,a.byteLength-l),m=new Uint8Array(d),R=new Uint8Array(h),y=new Uint8Array([...n,...m,...R]);return(0,jn.uint8ArrayToHex)(y)}async decrypt(t){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const s=await crypto.subtle.importKey("raw",(0,jn.hexStringToUint8Array)(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=(0,jn.hexStringToUint8Array)(t),l=a.slice(0,12),d=a.slice(12,28),h=a.slice(28),m=new Uint8Array([...h,...d]),R={name:"AES-GCM",iv:new Uint8Array(l)};try{const y=await window.crypto.subtle.decrypt(R,s,m),C=new TextDecoder;n(C.decode(y))}catch(y){i(y)}})()})}}bi.Cipher=Ph;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});wi.WalletLinkHTTP=void 0;class $h{constructor(t,r,n){this.linkAPIUrl=t,this.sessionId=r;const i=`${r}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(t){return Promise.all(t.map(r=>fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(r=>console.error("Unabled to mark event as failed:",r))}async fetchUnseenEvents(){var t;const r=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(r.ok){const{events:n,error:i}=await r.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const s=(t=n==null?void 0:n.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&t!==void 0?t:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${r.status}`)}}wi.WalletLinkHTTP=$h;var Wr={};Object.defineProperty(Wr,"__esModule",{value:!0});Wr.WalletLinkWebSocket=Wr.ConnectionState=void 0;var Br;(function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED"})(Br||(Wr.ConnectionState=Br={}));class Bh{setConnectionStateListener(t){this.connectionStateListener=t}setIncomingDataListener(t){this.incomingDataListener=t}constructor(t,r=WebSocket){this.WebSocketClass=r,this.webSocket=null,this.pendingData=[],this.url=t.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((t,r)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(s){r(s);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,Br.CONNECTING),i.onclose=s=>{var a;this.clearWebSocket(),r(new Error(`websocket error ${s.code}: ${s.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Br.DISCONNECTED)},i.onopen=s=>{var a;t(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,Br.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(d=>this.sendData(d)),this.pendingData=[])},i.onmessage=s=>{var a,l;if(s.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const d=JSON.parse(s.data);(l=this.incomingDataListener)===null||l===void 0||l.call(this,d)}catch{}}})}disconnect(){var t;const{webSocket:r}=this;if(r){this.clearWebSocket(),(t=this.connectionStateListener)===null||t===void 0||t.call(this,Br.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{r.close()}catch{}}}sendData(t){const{webSocket:r}=this;if(!r){this.pendingData.push(t),this.connect();return}r.send(t)}clearWebSocket(){const{webSocket:t}=this;t&&(this.webSocket=null,t.onclose=null,t.onerror=null,t.onmessage=null,t.onopen=null)}}Wr.WalletLinkWebSocket=Bh;Object.defineProperty(vi,"__esModule",{value:!0});vi.WalletLinkConnection=void 0;const Tr=Ve,Dh=bi,_t=Yr,Uo=ht,Nr=Xr,Fh=wi,Hn=Wr,Wo=1e4,jh=6e4;class Hh{constructor({session:t,linkAPIUrl:r,listener:n,diagnostic:i,WebSocketClass:s=WebSocket}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=(0,Tr.IntNumber)(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=l=>{if(!l)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",h=>l.JsonRpcUrl&&this.handleChainUpdated(h,l.JsonRpcUrl)]]).forEach((h,m)=>{const R=l[m];R!==void 0&&h(R)})},this.handleDestroyed=l=>{var d,h;l==="1"&&((d=this.listener)===null||d===void 0||d.resetAndReload(),(h=this.diagnostic)===null||h===void 0||h.log(_t.EVENTS.METADATA_DESTROYED,{alreadyDestroyed:this.isDestroyed,sessionIdHash:Nr.Session.hash(this.session.id)}))},this.handleAccountUpdated=async l=>{var d,h;try{const m=await this.cipher.decrypt(l);(d=this.listener)===null||d===void 0||d.accountUpdated(m)}catch{(h=this.diagnostic)===null||h===void 0||h.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"selectedAddress"})}},this.handleMetadataUpdated=async(l,d)=>{var h,m;try{const R=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.metadataUpdated(l,R)}catch{(m=this.diagnostic)===null||m===void 0||m.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:l})}},this.handleWalletUsernameUpdated=async l=>{this.handleMetadataUpdated(Uo.WALLET_USER_NAME_KEY,l)},this.handleAppVersionUpdated=async l=>{this.handleMetadataUpdated(Uo.APP_VERSION_KEY,l)},this.handleChainUpdated=async(l,d)=>{var h,m;try{const R=await this.cipher.decrypt(l),y=await this.cipher.decrypt(d);(h=this.listener)===null||h===void 0||h.chainUpdated(R,y)}catch{(m=this.diagnostic)===null||m===void 0||m.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"chainId|jsonRpcUrl"})}},this.session=t,this.cipher=new Dh.Cipher(t.secret),this.diagnostic=i,this.listener=n;const a=new Hn.WalletLinkWebSocket(`${r}/rpc`,s);a.setConnectionStateListener(async l=>{var d;(d=this.diagnostic)===null||d===void 0||d.log(_t.EVENTS.CONNECTED_STATE_CHANGE,{state:l,sessionIdHash:Nr.Session.hash(t.id)});let h=!1;switch(l){case Hn.ConnectionState.DISCONNECTED:if(!this.destroyed){const m=async()=>{await new Promise(R=>setTimeout(R,5e3)),this.destroyed||a.connect().catch(()=>{m()})};m()}break;case Hn.ConnectionState.CONNECTED:try{await this.authenticate(),this.sendIsLinked(),this.sendGetSessionConfig(),h=!0}catch{}this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},Wo),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case Hn.ConnectionState.CONNECTING:break}this.connected!==h&&(this.connected=h)}),a.setIncomingDataListener(l=>{var d,h,m;switch(l.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const R=l.type==="IsLinkedOK"?l.linked:void 0;(d=this.diagnostic)===null||d===void 0||d.log(_t.EVENTS.LINKED,{sessionIdHash:Nr.Session.hash(t.id),linked:R,type:l.type,onlineGuests:l.onlineGuests}),this.linked=R||l.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{(h=this.diagnostic)===null||h===void 0||h.log(_t.EVENTS.SESSION_CONFIG_RECEIVED,{sessionIdHash:Nr.Session.hash(t.id),metadata_keys:l&&l.metadata?Object.keys(l.metadata):void 0}),this.handleSessionMetadataUpdated(l.metadata);break}case"Event":{this.handleIncomingEvent(l);break}}l.id!==void 0&&((m=this.requestResolutions.get(l.id))===null||m===void 0||m(l))}),this.ws=a,this.http=new Fh.WalletLinkHTTP(r,t.id,t.key)}connect(){var t;if(this.destroyed)throw new Error("instance is destroyed");(t=this.diagnostic)===null||t===void 0||t.log(_t.EVENTS.STARTED_CONNECTING,{sessionIdHash:Nr.Session.hash(this.session.id)}),this.ws.connect()}destroy(){var t;this.destroyed=!0,this.ws.disconnect(),(t=this.diagnostic)===null||t===void 0||t.log(_t.EVENTS.DISCONNECTED,{sessionIdHash:Nr.Session.hash(this.session.id)}),this.listener=void 0}get isDestroyed(){return this.destroyed}get connected(){return this._connected}set connected(t){var r,n;this._connected=t,t&&((r=this.onceConnected)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.connectedUpdated(t)}setOnceConnected(t){return new Promise(r=>{this.connected?t().then(r):this.onceConnected=()=>{t().then(r),this.onceConnected=void 0}})}get linked(){return this._linked}set linked(t){var r,n;this._linked=t,t&&((r=this.onceLinked)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(t)}setOnceLinked(t){return new Promise(r=>{this.linked?t().then(r):this.onceLinked=()=>{t().then(r),this.onceLinked=void 0}})}async handleIncomingEvent(t){var r,n;if(!(t.type!=="Event"||t.event!=="Web3Response"))try{const i=await this.cipher.decrypt(t.data),s=JSON.parse(i);if(s.type!=="WEB3_RESPONSE")return;(r=this.listener)===null||r===void 0||r.handleWeb3ResponseMessage(s)}catch{(n=this.diagnostic)===null||n===void 0||n.log(_t.EVENTS.GENERAL_ERROR,{message:"Had error decrypting",value:"incomingEvent"})}}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(t=>setTimeout(t,250));try{await this.fetchUnseenEventsAPI()}catch(t){console.error("Unable to check for unseen events",t)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(r=>this.handleIncomingEvent(r))}async setSessionMetadata(t,r){const n={type:"SetSessionConfig",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id,metadata:{[t]:r}};return this.setOnceConnected(async()=>{const i=await this.makeRequest(n);if(i.type==="Fail")throw new Error(i.error||"failed to set session metadata")})}async publishEvent(t,r,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},r),{origin:location.origin,relaySource:window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id,event:t,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const a=await this.makeRequest(s);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(t){this.ws.sendData(JSON.stringify(t))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Wo*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(t,r=jh){const n=t.id;this.sendData(t);let i;return Promise.race([new Promise((s,a)=>{i=window.setTimeout(()=>{a(new Error(`request ${n} timed out`))},r)}),new Promise(s=>{this.requestResolutions.set(n,a=>{clearTimeout(i),s(a),this.requestResolutions.delete(n)})})])}async authenticate(){const t={type:"HostSession",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key},r=await this.makeRequest(t);if(r.type==="Fail")throw new Error(r.error||"failed to authentcate")}sendIsLinked(){const t={type:"IsLinked",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(t)}sendGetSessionConfig(){const t={type:"GetSessionConfig",id:(0,Tr.IntNumber)(this.nextReqId++),sessionId:this.session.id};this.sendData(t)}}vi.WalletLinkConnection=Hh;var Mn={},kn={},Js={};Object.defineProperty(Js,"__esModule",{value:!0});Js.default='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';var Uh=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(kn,"__esModule",{value:!0});kn.injectCssReset=void 0;const Wh=Uh(Js);function Vh(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(Wh.default)),document.documentElement.appendChild(e)}kn.injectCssReset=Vh;var _i={};const tt=Zr(cu);var yi={};function Ic(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t65536?(n[0]=240|(i&1835008)>>>18,n[1]=128|(i&258048)>>>12,n[2]=128|(i&4032)>>>6,n[3]=128|i&63):i>2048?(n[0]=224|(i&61440)>>>12,n[1]=128|(i&4032)>>>6,n[2]=128|i&63):i>128?(n[0]=192|(i&1984)>>>6,n[1]=128|i&63):n[0]=i,this.parsedData.push(n)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}xc.prototype={getLength:function(e){return this.parsedData.length},write:function(e){for(var t=0,r=this.parsedData.length;t=7&&this.setupTypeNumber(e),this.dataCache==null&&(this.dataCache=kt.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var n=-1;n<=7;n++)t+n<=-1||this.moduleCount<=t+n||(0<=r&&r<=6&&(n==0||n==6)||0<=n&&n<=6&&(r==0||r==6)||2<=r&&r<=4&&2<=n&&n<=4?this.modules[e+r][t+n]=!0:this.modules[e+r][t+n]=!1)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=je.getLostPoint(this);(r==0||e>n)&&(e=n,t=r)}return t},createMovieClip:function(e,t,r){var n=e.createEmptyMovieClip(t,r),i=1;this.make();for(var s=0;s>r&1)==1;this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(var r=0;r<18;r++){var n=!e&&(t>>r&1)==1;this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,n=je.getBCHTypeInfo(r),i=0;i<15;i++){var s=!e&&(n>>i&1)==1;i<6?this.modules[i][8]=s:i<8?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(var i=0;i<15;i++){var s=!e&&(n>>i&1)==1;i<8?this.modules[8][this.moduleCount-i-1]=s:i<9?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,n=this.moduleCount-1,i=7,s=0,a=this.moduleCount-1;a>0;a-=2)for(a==6&&a--;;){for(var l=0;l<2;l++)if(this.modules[n][a-l]==null){var d=!1;s>>i&1)==1);var h=je.getMask(t,n,a-l);h&&(d=!d),this.modules[n][a-l]=d,i--,i==-1&&(s++,i=7)}if(n+=r,n<0||this.moduleCount<=n){n-=r,r=-r;break}}}};kt.PAD0=236;kt.PAD1=17;kt.createData=function(e,t,r){for(var n=Mt.getRSBlocks(e,t),i=new Ac,s=0;sl*8)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+l*8+")");for(i.getLengthInBits()+4<=l*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=l*8||(i.put(kt.PAD0,8),i.getLengthInBits()>=l*8));)i.put(kt.PAD1,8);return kt.createBytes(i,n)};kt.createBytes=function(e,t){for(var r=0,n=0,i=0,s=new Array(t.length),a=new Array(t.length),l=0;l=0?C.get(x):0}}for(var B=0,m=0;m=0;)t^=je.G15<=0;)t^=je.G18<>>=1;return t},getPatternPosition:function(e){return je.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case Ot.PATTERN000:return(t+r)%2==0;case Ot.PATTERN001:return t%2==0;case Ot.PATTERN010:return r%3==0;case Ot.PATTERN011:return(t+r)%3==0;case Ot.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2==0;case Ot.PATTERN101:return t*r%2+t*r%3==0;case Ot.PATTERN110:return(t*r%2+t*r%3)%2==0;case Ot.PATTERN111:return(t*r%3+(t+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new Dr([1],0),r=0;r5&&(r+=3+s-5)}for(var n=0;n=256;)e-=255;return Je.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var Ze=0;Ze<8;Ze++)Je.EXP_TABLE[Ze]=1<>>7-e%8&1)==1},put:function(e,t){for(var r=0;r>>t-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var as=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function Tc(e){if(this.options={padding:4,width:256,height:256,typeNumber:4,color:"#000000",background:"#ffffff",ecl:"M",image:{svg:"",width:0,height:0}},typeof e=="string"&&(e={content:e}),e)for(var t in e)this.options[t]=e[t];if(typeof this.options.content!="string")throw new Error("Expected 'content' as string!");if(this.options.content.length===0)throw new Error("Expected 'content' to be non-empty!");if(!(this.options.padding>=0))throw new Error("Expected 'padding' value to be non-negative!");if(!(this.options.width>0)||!(this.options.height>0))throw new Error("Expected 'width' or 'height' value to be higher than zero!");function r(d){switch(d){case"L":return Bt.L;case"M":return Bt.M;case"Q":return Bt.Q;case"H":return Bt.H;default:throw new Error("Unknwon error correction level: "+d)}}function n(d,h){for(var m=i(d),R=1,y=0,C=0,x=as.length;C<=x;C++){var B=as[C];if(!B)throw new Error("Content too long: expected "+y+" but got "+m);switch(h){case"L":y=B[0];break;case"M":y=B[1];break;case"Q":y=B[2];break;case"H":y=B[3];break;default:throw new Error("Unknwon error correction level: "+h)}if(m<=y)break;R++}if(R>as.length)throw new Error("Content too long");return R}function i(d){var h=encodeURI(d).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return h.length+(h.length!=d?3:0)}var s=this.options.content,a=n(s,this.options.ecl),l=r(this.options.ecl);this.qrcode=new kt(a,l),this.qrcode.addData(s),this.qrcode.make()}Tc.prototype.svg=function(e){var t=this.options||{},r=this.qrcode.modules;typeof e>"u"&&(e={container:t.container||"svg"});for(var n=typeof t.pretty<"u"?!!t.pretty:!0,i=n?" ":"",s=n?`\r `:"",a=t.width,l=t.height,d=r.length,h=a/(d+2*t.padding),m=l/(d+2*t.padding),R=typeof t.join<"u"?!!t.join:!1,y=typeof t.swap<"u"?!!t.swap:!1,C=typeof t.xmlDeclaration<"u"?!!t.xmlDeclaration:!0,x=typeof t.predefined<"u"?!!t.predefined:!1,B=x?i+''+s:"",O=i+''+s,M="",T="",N=0;N'+s:M+=i+''+s}}R&&(M=i+'');let X="";if(this.options.image!==void 0&&this.options.image.svg){const S=a*this.options.image.width/100,o=l*this.options.image.height/100,u=a/2-S/2,f=l/2-o/2;X+=``,X+=this.options.image.svg+s,X+=""}var ne="";switch(e.container){case"svg":C&&(ne+=''+s),ne+=''+s,ne+=B+O+M,ne+=X,ne+="";break;case"svg-viewbox":C&&(ne+=''+s),ne+=''+s,ne+=B+O+M,ne+=X,ne+="";break;case"g":ne+=''+s,ne+=B+O+M,ne+=X,ne+="";break;default:ne+=(B+O+M+X).replace(/^\s+/,"");break}return ne};var Zh=Tc,Kh=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ki,"__esModule",{value:!0});ki.QRCode=void 0;const Qh=tt,qo=Ei,Yh=Kh(Zh),Xh=e=>{const[t,r]=(0,qo.useState)("");return(0,qo.useEffect)(()=>{var n,i;const s=new Yh.default({content:e.content,background:e.bgColor||"#ffffff",color:e.fgColor||"#000000",container:"svg",ecl:"M",width:(n=e.width)!==null&&n!==void 0?n:256,height:(i=e.height)!==null&&i!==void 0?i:256,padding:0,image:e.image}),a=Buffer.from(s.svg(),"utf8").toString("base64");r(`data:image/svg+xml;base64,${a}`)},[e.bgColor,e.content,e.fgColor,e.height,e.image,e.width]),t?(0,Qh.h)("img",{src:t,alt:"QR Code"}):null};ki.QRCode=Xh;var Ci={},Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.default=".-cbwsdk-css-reset .-cbwsdk-spinner{display:inline-block}.-cbwsdk-css-reset .-cbwsdk-spinner svg{display:inline-block;animation:2s linear infinite -cbwsdk-spinner-svg}.-cbwsdk-css-reset .-cbwsdk-spinner svg circle{animation:1.9s ease-in-out infinite both -cbwsdk-spinner-circle;display:block;fill:rgba(0,0,0,0);stroke-dasharray:283;stroke-dashoffset:280;stroke-linecap:round;stroke-width:10px;transform-origin:50% 50%}@keyframes -cbwsdk-spinner-svg{0%{transform:rotateZ(0deg)}100%{transform:rotateZ(360deg)}}@keyframes -cbwsdk-spinner-circle{0%,25%{stroke-dashoffset:280;transform:rotate(0)}50%,75%{stroke-dashoffset:75;transform:rotate(45deg)}100%{stroke-dashoffset:280;transform:rotate(360deg)}}";var ed=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ci,"__esModule",{value:!0});Ci.Spinner=void 0;const Wn=tt,td=ed(Gs),rd=e=>{var t;const r=(t=e.size)!==null&&t!==void 0?t:64,n=e.color||"#000";return(0,Wn.h)("div",{class:"-cbwsdk-spinner"},(0,Wn.h)("style",null,td.default),(0,Wn.h)("svg",{viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",style:{width:r,height:r}},(0,Wn.h)("circle",{style:{cx:50,cy:50,r:45,stroke:n}})))};Ci.Spinner=rd;var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.default=".-cbwsdk-css-reset .-cbwsdk-connect-content{height:430px;width:700px;border-radius:12px;padding:30px}.-cbwsdk-css-reset .-cbwsdk-connect-content.light{background:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content.dark{background:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-header{display:flex;align-items:center;justify-content:space-between;margin:0 0 30px}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading{font-style:normal;font-weight:500;font-size:28px;line-height:36px;margin:0}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-heading.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-layout{display:flex;flex-direction:row}.-cbwsdk-css-reset .-cbwsdk-connect-content-column-left{margin-right:30px;display:flex;flex-direction:column;justify-content:space-between}.-cbwsdk-css-reset .-cbwsdk-connect-content-column-right{flex:25%;margin-right:34px}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-wrapper{width:220px;height:220px;border-radius:12px;display:flex;justify-content:center;align-items:center;background:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting{position:absolute;top:0;bottom:0;left:0;right:0;display:flex;flex-direction:column;align-items:center;justify-content:center}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.light{background-color:rgba(255,255,255,.95)}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.light>p{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.dark{background-color:rgba(10,11,13,.9)}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting.dark>p{color:#fff}.-cbwsdk-css-reset .-cbwsdk-connect-content-qr-connecting>p{font-size:12px;font-weight:bold;margin-top:16px}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app{border-radius:8px;font-size:14px;line-height:20px;padding:12px;width:339px}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app.light{background:#eef0f3;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-connect-content-update-app.dark{background:#1e2025;color:#8a919e}.-cbwsdk-css-reset .-cbwsdk-cancel-button{-webkit-appearance:none;border:none;background:none;cursor:pointer;padding:0;margin:0}.-cbwsdk-css-reset .-cbwsdk-cancel-button-x{position:relative;display:block;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-wallet-steps{padding:0 0 0 16px;margin:0;width:100%;list-style:decimal}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item{list-style-type:decimal;display:list-item;font-style:normal;font-weight:400;font-size:16px;line-height:24px;margin-top:20px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-item-wrapper{display:flex;align-items:center}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-pad-left{margin-left:6px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon{display:flex;border-radius:50%;height:24px;width:24px}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon svg{margin:auto;display:block}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon.light{background:#0052ff}.-cbwsdk-css-reset .-cbwsdk-wallet-steps-icon.dark{background:#588af5}.-cbwsdk-css-reset .-cbwsdk-connect-item{align-items:center;display:flex;flex-direction:row;padding:16px 24px;gap:12px;cursor:pointer;border-radius:100px;font-weight:600}.-cbwsdk-css-reset .-cbwsdk-connect-item.light{background:#f5f8ff;color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-connect-item.dark{background:#001033;color:#588af5}.-cbwsdk-css-reset .-cbwsdk-connect-item-copy-wrapper{margin:0 4px 0 8px}.-cbwsdk-css-reset .-cbwsdk-connect-item-title{margin:0 0 0;font-size:16px;line-height:24px;font-weight:500}.-cbwsdk-css-reset .-cbwsdk-connect-item-description{font-weight:400;font-size:14px;line-height:20px;margin:0}";var Nc=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Vr,"__esModule",{value:!0});Vr.CoinbaseWalletSteps=Vr.ConnectContent=void 0;const hr=Nc(Cn),oe=tt,nd=q,id=Qr,sd=Si,od=Ri,ad=Mi,cd=ki,ld=Ci,ud=Nc(Zs),cs={title:"Coinbase Wallet app",description:"Connect with your self-custody wallet",steps:Lc},hd=e=>e==="light"?"#FFFFFF":"#0A0B0D";function dd(e){const{theme:t}=e,r=(0,nd.createQrUrl)(e.sessionId,e.sessionSecret,e.linkAPIUrl,e.isParentConnection,e.version,e.chainId),n=cs.steps;return(0,oe.h)("div",{"data-testid":"connect-content",className:(0,hr.default)("-cbwsdk-connect-content",t)},(0,oe.h)("style",null,ud.default),(0,oe.h)("div",{className:"-cbwsdk-connect-content-header"},(0,oe.h)("h2",{className:(0,hr.default)("-cbwsdk-connect-content-heading",t)},"Scan to connect with our mobile app"),e.onCancel&&(0,oe.h)("button",{type:"button",className:"-cbwsdk-cancel-button",onClick:e.onCancel},(0,oe.h)(sd.CloseIcon,{fill:t==="light"?"#0A0B0D":"#FFFFFF"}))),(0,oe.h)("div",{className:"-cbwsdk-connect-content-layout"},(0,oe.h)("div",{className:"-cbwsdk-connect-content-column-left"},(0,oe.h)(fd,{title:cs.title,description:cs.description,theme:t})),(0,oe.h)("div",{className:"-cbwsdk-connect-content-column-right"},(0,oe.h)("div",{className:"-cbwsdk-connect-content-qr-wrapper"},(0,oe.h)(cd.QRCode,{content:r,width:200,height:200,fgColor:"#000",bgColor:"transparent"}),(0,oe.h)("input",{type:"hidden",name:"cbw-cbwsdk-version",value:id.LIB_VERSION}),(0,oe.h)("input",{type:"hidden",value:r})),(0,oe.h)(n,{theme:t}),!e.isConnected&&(0,oe.h)("div",{"data-testid":"connecting-spinner",className:(0,hr.default)("-cbwsdk-connect-content-qr-connecting",t)},(0,oe.h)(ld.Spinner,{size:36,color:t==="dark"?"#FFF":"#000"}),(0,oe.h)("p",null,"Connecting...")))))}Vr.ConnectContent=dd;function fd({title:e,description:t,theme:r}){return(0,oe.h)("div",{className:(0,hr.default)("-cbwsdk-connect-item",r)},(0,oe.h)("div",null,(0,oe.h)(od.CoinbaseWalletRound,null)),(0,oe.h)("div",{className:"-cbwsdk-connect-item-copy-wrapper"},(0,oe.h)("h3",{className:"-cbwsdk-connect-item-title"},e),(0,oe.h)("p",{className:"-cbwsdk-connect-item-description"},t)))}function Lc({theme:e}){return(0,oe.h)("ol",{className:"-cbwsdk-wallet-steps"},(0,oe.h)("li",{className:(0,hr.default)("-cbwsdk-wallet-steps-item",e)},(0,oe.h)("div",{className:"-cbwsdk-wallet-steps-item-wrapper"},"Open Coinbase Wallet app")),(0,oe.h)("li",{className:(0,hr.default)("-cbwsdk-wallet-steps-item",e)},(0,oe.h)("div",{className:"-cbwsdk-wallet-steps-item-wrapper"},(0,oe.h)("span",null,"Tap ",(0,oe.h)("strong",null,"Scan")," "),(0,oe.h)("span",{className:(0,hr.default)("-cbwsdk-wallet-steps-pad-left","-cbwsdk-wallet-steps-icon",e)},(0,oe.h)(ad.QRCodeIcon,{fill:hd(e)})))))}Vr.CoinbaseWalletSteps=Lc;var Ii={},xi={};Object.defineProperty(xi,"__esModule",{value:!0});xi.ArrowLeftIcon=void 0;const Jo=tt;function pd(e){return(0,Jo.h)("svg",Object.assign({width:"16",height:"16",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},e),(0,Jo.h)("path",{d:"M8.60675 0.155884L7.37816 1.28209L12.7723 7.16662H0V8.83328H12.6548L6.82149 14.6666L8 15.8451L15.8201 8.02501L8.60675 0.155884Z"}))}xi.ArrowLeftIcon=pd;var Ai={};Object.defineProperty(Ai,"__esModule",{value:!0});Ai.LaptopIcon=void 0;const ls=tt;function gd(e){return(0,ls.h)("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 14 14",xmlns:"http://www.w3.org/2000/svg"},e),(0,ls.h)("path",{d:"M1.8001 2.2002H12.2001V9.40019H1.8001V2.2002ZM3.4001 3.8002V7.80019H10.6001V3.8002H3.4001Z"}),(0,ls.h)("path",{d:"M13.4001 10.2002H0.600098C0.600098 11.0838 1.31644 11.8002 2.2001 11.8002H11.8001C12.6838 11.8002 13.4001 11.0838 13.4001 10.2002Z"}))}Ai.LaptopIcon=gd;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});Ti.SafeIcon=void 0;const Go=tt;function md(e){return(0,Go.h)("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 14 14",xmlns:"http://www.w3.org/2000/svg"},e),(0,Go.h)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0.600098 0.600098V11.8001H13.4001V0.600098H0.600098ZM7.0001 9.2001C5.3441 9.2001 4.0001 7.8561 4.0001 6.2001C4.0001 4.5441 5.3441 3.2001 7.0001 3.2001C8.6561 3.2001 10.0001 4.5441 10.0001 6.2001C10.0001 7.8561 8.6561 9.2001 7.0001 9.2001ZM0.600098 12.6001H3.8001V13.4001H0.600098V12.6001ZM10.2001 12.6001H13.4001V13.4001H10.2001V12.6001ZM8.8001 6.2001C8.8001 7.19421 7.99421 8.0001 7.0001 8.0001C6.00598 8.0001 5.2001 7.19421 5.2001 6.2001C5.2001 5.20598 6.00598 4.4001 7.0001 4.4001C7.99421 4.4001 8.8001 5.20598 8.8001 6.2001Z"}))}Ti.SafeIcon=md;var Ks={};Object.defineProperty(Ks,"__esModule",{value:!0});Ks.default=".-cbwsdk-css-reset .-cbwsdk-try-extension{display:flex;margin-top:12px;height:202px;width:700px;border-radius:12px;padding:30px}.-cbwsdk-css-reset .-cbwsdk-try-extension.light{background:#fff}.-cbwsdk-css-reset .-cbwsdk-try-extension.dark{background:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-try-extension-column-half{flex:50%}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading{font-style:normal;font-weight:500;font-size:25px;line-height:32px;margin:0;max-width:204px}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading.light{color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-try-extension-heading.dark{color:#fff}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta{appearance:none;border:none;background:none;color:#0052ff;cursor:pointer;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta.light{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta.dark{color:#588af5}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta-wrapper{display:flex;align-items:center;margin-top:12px}.-cbwsdk-css-reset .-cbwsdk-try-extension-cta-icon{display:block;margin-left:4px;height:14px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list{display:flex;flex-direction:column;justify-content:center;align-items:center;margin:0;padding:0;list-style:none;height:100%}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item{display:flex;align-items:center;flex-flow:nowrap;margin-top:24px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item:first-of-type{margin-top:0}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon-wrapper{display:block}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon{display:flex;height:32px;width:32px;border-radius:50%}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon svg{margin:auto;display:block}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon.light{background:#eef0f3}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-icon.dark{background:#1e2025}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy{display:block;font-weight:400;font-size:14px;line-height:20px;padding-left:12px}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy.light{color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-try-extension-list-item-copy.dark{color:#8a919e}";var Oc=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ii,"__esModule",{value:!0});Ii.TryExtensionContent=void 0;const rr=Oc(Cn),We=tt,us=Ei,vd=xi,bd=Ai,wd=Ti,_d=Oc(Ks);function yd({theme:e}){const[t,r]=(0,us.useState)(!1),n=(0,us.useCallback)(()=>{window.open("https://api.wallet.coinbase.com/rpc/v2/desktop/chrome","_blank")},[]),i=(0,us.useCallback)(()=>{t?window.location.reload():(n(),r(!0))},[n,t]);return(0,We.h)("div",{class:(0,rr.default)("-cbwsdk-try-extension",e)},(0,We.h)("style",null,_d.default),(0,We.h)("div",{class:"-cbwsdk-try-extension-column-half"},(0,We.h)("h3",{class:(0,rr.default)("-cbwsdk-try-extension-heading",e)},"Or try the Coinbase Wallet browser extension"),(0,We.h)("div",{class:"-cbwsdk-try-extension-cta-wrapper"},(0,We.h)("button",{class:(0,rr.default)("-cbwsdk-try-extension-cta",e),onClick:i},t?"Refresh":"Install"),(0,We.h)("div",null,!t&&(0,We.h)(vd.ArrowLeftIcon,{class:"-cbwsdk-try-extension-cta-icon",fill:e==="light"?"#0052FF":"#588AF5"})))),(0,We.h)("div",{class:"-cbwsdk-try-extension-column-half"},(0,We.h)("ul",{class:"-cbwsdk-try-extension-list"},(0,We.h)("li",{class:"-cbwsdk-try-extension-list-item"},(0,We.h)("div",{class:"-cbwsdk-try-extension-list-item-icon-wrapper"},(0,We.h)("span",{class:(0,rr.default)("-cbwsdk-try-extension-list-item-icon",e)},(0,We.h)(bd.LaptopIcon,{fill:e==="light"?"#0A0B0D":"#FFFFFF"}))),(0,We.h)("div",{class:(0,rr.default)("-cbwsdk-try-extension-list-item-copy",e)},"Connect with dapps with just one click on your desktop browser")),(0,We.h)("li",{class:"-cbwsdk-try-extension-list-item"},(0,We.h)("div",{class:"-cbwsdk-try-extension-list-item-icon-wrapper"},(0,We.h)("span",{class:(0,rr.default)("-cbwsdk-try-extension-list-item-icon",e)},(0,We.h)(wd.SafeIcon,{fill:e==="light"?"#0A0B0D":"#FFFFFF"}))),(0,We.h)("div",{class:(0,rr.default)("-cbwsdk-try-extension-list-item-copy",e)},"Add an additional layer of security by using a supported Ledger hardware wallet")))))}Ii.TryExtensionContent=yd;var Qs={};Object.defineProperty(Qs,"__esModule",{value:!0});Qs.default=".-cbwsdk-css-reset .-cbwsdk-connect-dialog{z-index:2147483647;position:fixed;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop{z-index:2147483647;position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop.light{background-color:rgba(0,0,0,.5)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop.dark{background-color:rgba(50,53,61,.4)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-box{display:flex;position:relative;flex-direction:column;transform:scale(1);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-box-hidden{opacity:0;transform:scale(0.85)}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-container{display:block}.-cbwsdk-css-reset .-cbwsdk-connect-dialog-container-hidden{display:none}";var Pc=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(yi,"__esModule",{value:!0});yi.ConnectDialog=void 0;const hs=Pc(Cn),nr=tt,ds=Ei,Ed=Vr,Sd=Ii,Rd=Pc(Qs),Md=e=>{const{isOpen:t,darkMode:r}=e,[n,i]=(0,ds.useState)(!t),[s,a]=(0,ds.useState)(!t);(0,ds.useEffect)(()=>{const d=[window.setTimeout(()=>{a(!t)},10)];return t?i(!1):d.push(window.setTimeout(()=>{i(!0)},360)),()=>{d.forEach(window.clearTimeout)}},[t]);const l=r?"dark":"light";return(0,nr.h)("div",{class:(0,hs.default)("-cbwsdk-connect-dialog-container",n&&"-cbwsdk-connect-dialog-container-hidden")},(0,nr.h)("style",null,Rd.default),(0,nr.h)("div",{class:(0,hs.default)("-cbwsdk-connect-dialog-backdrop",l,s&&"-cbwsdk-connect-dialog-backdrop-hidden")}),(0,nr.h)("div",{class:"-cbwsdk-connect-dialog"},(0,nr.h)("div",{class:(0,hs.default)("-cbwsdk-connect-dialog-box",s&&"-cbwsdk-connect-dialog-box-hidden")},e.connectDisabled?null:(0,nr.h)(Ed.ConnectContent,{theme:l,version:e.version,sessionId:e.sessionId,sessionSecret:e.sessionSecret,linkAPIUrl:e.linkAPIUrl,isConnected:e.isConnected,isParentConnection:e.isParentConnection,chainId:e.chainId,onCancel:e.onCancel}),(0,nr.h)(Sd.TryExtensionContent,{theme:l}))))};yi.ConnectDialog=Md;Object.defineProperty(_i,"__esModule",{value:!0});_i.LinkFlow=void 0;const fs=tt,kd=yi;class Cd{constructor(t){this.connected=!1,this.chainId=1,this.isOpen=!1,this.onCancel=null,this.root=null,this.connectDisabled=!1,this.darkMode=t.darkMode,this.version=t.version,this.sessionId=t.sessionId,this.sessionSecret=t.sessionSecret,this.linkAPIUrl=t.linkAPIUrl,this.isParentConnection=t.isParentConnection}attach(t){this.root=document.createElement("div"),this.root.className="-cbwsdk-link-flow-root",t.appendChild(this.root),this.render()}setConnected(t){this.connected!==t&&(this.connected=t,this.render())}setChainId(t){this.chainId!==t&&(this.chainId=t,this.render())}detach(){var t;this.root&&((0,fs.render)(null,this.root),(t=this.root.parentElement)===null||t===void 0||t.removeChild(this.root))}setConnectDisabled(t){this.connectDisabled=t}open(t){this.isOpen=!0,this.onCancel=t.onCancel,this.render()}close(){this.isOpen=!1,this.onCancel=null,this.render()}render(){this.root&&(0,fs.render)((0,fs.h)(kd.ConnectDialog,{darkMode:this.darkMode,version:this.version,sessionId:this.sessionId,sessionSecret:this.sessionSecret,linkAPIUrl:this.linkAPIUrl,isOpen:this.isOpen,isConnected:this.connected,isParentConnection:this.isParentConnection,chainId:this.chainId,onCancel:this.onCancel,connectDisabled:this.connectDisabled}),this.root)}}_i.LinkFlow=Cd;var Ys={},Xs={};Object.defineProperty(Xs,"__esModule",{value:!0});Xs.default=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}";(function(e){var t=Q&&Q.__importDefault||function(R){return R&&R.__esModule?R:{default:R}};Object.defineProperty(e,"__esModule",{value:!0}),e.SnackbarInstance=e.SnackbarContainer=e.Snackbar=void 0;const r=t(Cn),n=tt,i=Ei,s=t(Xs),a="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",l="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class d{constructor(y){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=y.darkMode}attach(y){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",y.appendChild(this.root),this.render()}presentItem(y){const C=this.nextItemKey++;return this.items.set(C,y),this.render(),()=>{this.items.delete(C),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,n.render)((0,n.h)("div",null,(0,n.h)(e.SnackbarContainer,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([y,C])=>(0,n.h)(e.SnackbarInstance,Object.assign({},C,{key:y}))))),this.root)}}e.Snackbar=d;const h=R=>(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-container")},(0,n.h)("style",null,s.default),(0,n.h)("div",{class:"-cbwsdk-snackbar"},R.children));e.SnackbarContainer=h;const m=({autoExpand:R,message:y,menuItems:C})=>{const[x,B]=(0,i.useState)(!0),[O,M]=(0,i.useState)(R??!1);(0,i.useEffect)(()=>{const N=[window.setTimeout(()=>{B(!1)},1),window.setTimeout(()=>{M(!0)},1e4)];return()=>{N.forEach(window.clearTimeout)}});const T=()=>{M(!O)};return(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-instance",x&&"-cbwsdk-snackbar-instance-hidden",O&&"-cbwsdk-snackbar-instance-expanded")},(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:T},(0,n.h)("img",{src:a,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},y),(0,n.h)("div",{class:"-gear-container"},!O&&(0,n.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,n.h)("img",{src:l,class:"-gear-icon",title:"Expand"}))),C&&C.length>0&&(0,n.h)("div",{class:"-cbwsdk-snackbar-instance-menu"},C.map((N,D)=>(0,n.h)("div",{class:(0,r.default)("-cbwsdk-snackbar-instance-menu-item",N.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:N.onClick,key:D},(0,n.h)("svg",{width:N.svgWidth,height:N.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.h)("path",{"fill-rule":N.defaultFillRule,"clip-rule":N.defaultClipRule,d:N.path,fill:"#AAAAAA"})),(0,n.h)("span",{class:(0,r.default)("-cbwsdk-snackbar-instance-menu-item-info",N.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},N.info)))))};e.SnackbarInstance=m})(Ys);Object.defineProperty(Mn,"__esModule",{value:!0});Mn.WalletLinkRelayUI=void 0;const Id=kn,xd=_i,Ad=Ys;class Td{constructor(t){this.standalone=null,this.attached=!1,this.snackbar=new Ad.Snackbar({darkMode:t.darkMode}),this.linkFlow=new xd.LinkFlow({darkMode:t.darkMode,version:t.version,sessionId:t.session.id,sessionSecret:t.session.secret,linkAPIUrl:t.linkAPIUrl,isParentConnection:!1})}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const t=document.documentElement,r=document.createElement("div");r.className="-cbwsdk-css-reset",t.appendChild(r),this.linkFlow.attach(r),this.snackbar.attach(r),this.attached=!0,(0,Id.injectCssReset)()}setConnected(t){this.linkFlow.setConnected(t)}setChainId(t){this.linkFlow.setChainId(t)}setConnectDisabled(t){this.linkFlow.setConnectDisabled(t)}addEthereumChain(){}watchAsset(){}switchEthereumChain(){}requestEthereumAccounts(t){this.linkFlow.open({onCancel:t.onCancel})}hideRequestEthereumAccounts(){this.linkFlow.close()}signEthereumMessage(){}signEthereumTransaction(){}submitEthereumTransaction(){}ethereumAddressFromSignedMessage(){}showConnecting(t){let r;return t.isUnlinkedErrorState?r={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]}:r={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:t.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]},this.snackbar.presentItem(r)}reloadUI(){document.location.reload()}inlineAccountsResponse(){return!1}inlineAddEthereumChain(){return!1}inlineWatchAsset(){return!1}inlineSwitchEthereumChain(){return!1}setStandalone(t){this.standalone=t}isStandalone(){var t;return(t=this.standalone)!==null&&t!==void 0?t:!1}}Mn.WalletLinkRelayUI=Td;Object.defineProperty(_n,"__esModule",{value:!0});_n.WalletLinkRelay=void 0;const Lr=gn,Nd=Ve,Fe=q,ir=Yr,Zo=ht,Pt=Xr,Ld=vi,sr=Kr,Od=Mn;class Tt extends Zo.RelayAbstract{constructor(t){var r;super(),this.accountsCallback=null,this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.chainCallback=null,this.dappDefaultChain=1,this.appName="",this.appLogoUrl=null,this.linkedUpdated=a=>{var l;this.isLinked=a;const d=this.storage.getItem(Zo.LOCAL_STORAGE_ADDRESSES_KEY);if(a&&(this.session.linked=a),this.isUnlinkedErrorState=!1,d){const h=d.split(" "),m=this.storage.getItem("IsStandaloneSigning")==="true";if(h[0]!==""&&!a&&this.session.linked&&!m){this.isUnlinkedErrorState=!0;const R=this.getSessionIdHash();(l=this.diagnostic)===null||l===void 0||l.log(ir.EVENTS.UNLINKED_ERROR_STATE,{sessionIdHash:R})}}},this.metadataUpdated=(a,l)=>{this.storage.setItem(a,l)},this.chainUpdated=(a,l)=>{this.chainCallbackParams.chainId===a&&this.chainCallbackParams.jsonRpcUrl===l||(this.chainCallbackParams={chainId:a,jsonRpcUrl:l},this.chainCallback&&this.chainCallback(a,l))},this.accountUpdated=a=>{this.accountsCallback&&this.accountsCallback([a]),Tt.accountRequestCallbackIds.size>0&&(Array.from(Tt.accountRequestCallbackIds.values()).forEach(l=>{const d={type:"WEB3_RESPONSE",id:l,response:{method:"requestEthereumAccounts",result:[a]}};this.invokeCallback(Object.assign(Object.assign({},d),{id:l}))}),Tt.accountRequestCallbackIds.clear())},this.connectedUpdated=a=>{this.ui.setConnected(a)},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=t.linkAPIUrl,this.storage=t.storage,this.options=t;const{session:n,ui:i,connection:s}=this.subscribe();this._session=n,this.connection=s,this.relayEventManager=t.relayEventManager,this.diagnostic=t.diagnosticLogger,this._reloadOnDisconnect=(r=t.reloadOnDisconnect)!==null&&r!==void 0?r:!0,this.ui=i}subscribe(){const t=Pt.Session.load(this.storage)||new Pt.Session(this.storage).save(),{linkAPIUrl:r,diagnostic:n}=this,i=new Ld.WalletLinkConnection({session:t,linkAPIUrl:r,diagnostic:n,listener:this}),{version:s,darkMode:a}=this.options,l=this.options.uiConstructor({linkAPIUrl:r,version:s,darkMode:a,session:t});return i.connect(),{session:t,ui:l,connection:i}}attachUI(){this.ui.attach()}resetAndReload(){Promise.race([this.connection.setSessionMetadata("__destroyed","1"),new Promise(t=>setTimeout(()=>t(null),1e3))]).then(()=>{var t,r;const n=this.ui.isStandalone();(t=this.diagnostic)===null||t===void 0||t.log(ir.EVENTS.SESSION_STATE_CHANGE,{method:"relay::resetAndReload",sessionMetadataChange:"__destroyed, 1",sessionIdHash:this.getSessionIdHash()}),this.connection.destroy();const i=Pt.Session.load(this.storage);if((i==null?void 0:i.id)===this._session.id?this.storage.clear():i&&((r=this.diagnostic)===null||r===void 0||r.log(ir.EVENTS.SKIPPED_CLEARING_SESSION,{sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:Pt.Session.hash(i.id)})),this._reloadOnDisconnect){this.ui.reloadUI();return}this.accountsCallback&&this.accountsCallback([],!0);const{session:s,ui:a,connection:l}=this.subscribe();this._session=s,this.connection=l,this.ui=a,n&&this.ui.setStandalone&&this.ui.setStandalone(!0),this.options.headlessMode||this.attachUI()}).catch(t=>{var r;(r=this.diagnostic)===null||r===void 0||r.log(ir.EVENTS.FAILURE,{method:"relay::resetAndReload",message:`failed to reset and reload with ${t}`,sessionIdHash:this.getSessionIdHash()})})}setAppInfo(t,r){this.appName=t,this.appLogoUrl=r}getStorageItem(t){return this.storage.getItem(t)}get session(){return this._session}setStorageItem(t,r){this.storage.setItem(t,r)}signEthereumMessage(t,r,n,i){return this.sendRequest({method:"signEthereumMessage",params:{message:(0,Fe.hexStringFromBuffer)(t,!0),address:r,addPrefix:n,typedDataJson:i||null}})}ethereumAddressFromSignedMessage(t,r,n){return this.sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:(0,Fe.hexStringFromBuffer)(t,!0),signature:(0,Fe.hexStringFromBuffer)(r,!0),addPrefix:n}})}signEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:(0,Fe.bigIntStringFromBN)(t.weiValue),data:(0,Fe.hexStringFromBuffer)(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?(0,Fe.bigIntStringFromBN)(t.gasPriceInWei):null,maxFeePerGas:t.gasPriceInWei?(0,Fe.bigIntStringFromBN)(t.gasPriceInWei):null,maxPriorityFeePerGas:t.gasPriceInWei?(0,Fe.bigIntStringFromBN)(t.gasPriceInWei):null,gasLimit:t.gasLimit?(0,Fe.bigIntStringFromBN)(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:(0,Fe.bigIntStringFromBN)(t.weiValue),data:(0,Fe.hexStringFromBuffer)(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?(0,Fe.bigIntStringFromBN)(t.gasPriceInWei):null,maxFeePerGas:t.maxFeePerGas?(0,Fe.bigIntStringFromBN)(t.maxFeePerGas):null,maxPriorityFeePerGas:t.maxPriorityFeePerGas?(0,Fe.bigIntStringFromBN)(t.maxPriorityFeePerGas):null,gasLimit:t.gasLimit?(0,Fe.bigIntStringFromBN)(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!0}})}submitEthereumTransaction(t,r){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:(0,Fe.hexStringFromBuffer)(t,!0),chainId:r}})}scanQRCode(t){return this.sendRequest({method:"scanQRCode",params:{regExp:t}})}getQRCodeUrl(){return(0,Fe.createQrUrl)(this._session.id,this._session.secret,this.linkAPIUrl,!1,this.options.version,this.dappDefaultChain)}genericRequest(t,r){return this.sendRequest({method:"generic",params:{action:r,data:t}})}sendGenericMessage(t){return this.sendRequest(t)}sendRequest(t){let r=null;const n=(0,Fe.randomBytesHex)(8),i=a=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,t.method,a),r==null||r()};return{promise:new Promise((a,l)=>{this.ui.isStandalone()||(r=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload})),this.relayEventManager.callbacks.set(n,d=>{if(r==null||r(),(0,sr.isErrorResponse)(d))return l(new Error(d.errorMessage));a(d)}),this.ui.isStandalone()?this.sendRequestStandalone(n,t):this.publishWeb3RequestEvent(n,t)}),cancel:i}}setConnectDisabled(t){this.ui.setConnectDisabled(t)}setAccountsCallback(t){this.accountsCallback=t}setChainCallback(t){this.chainCallback=t}setDappDefaultChainCallback(t){this.dappDefaultChain=t,this.ui instanceof Od.WalletLinkRelayUI&&this.ui.setChainId(t)}publishWeb3RequestEvent(t,r){var n;const i={type:"WEB3_REQUEST",id:t,request:r},s=Pt.Session.load(this.storage);(n=this.diagnostic)===null||n===void 0||n.log(ir.EVENTS.WEB3_REQUEST,{eventId:i.id,method:`relay::${r.method}`,sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:s?Pt.Session.hash(s.id):"",isSessionMismatched:((s==null?void 0:s.id)!==this._session.id).toString()}),this.publishEvent("Web3Request",i,!0).then(a=>{var l;(l=this.diagnostic)===null||l===void 0||l.log(ir.EVENTS.WEB3_REQUEST_PUBLISHED,{eventId:i.id,method:`relay::${r.method}`,sessionIdHash:this.getSessionIdHash(),storedSessionIdHash:s?Pt.Session.hash(s.id):"",isSessionMismatched:((s==null?void 0:s.id)!==this._session.id).toString()})}).catch(a=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i.id,response:{method:r.method,errorMessage:a.message}})})}publishWeb3RequestCanceledEvent(t){const r={type:"WEB3_REQUEST_CANCELED",id:t};this.publishEvent("Web3RequestCanceled",r,!1).then()}publishEvent(t,r,n){return this.connection.publishEvent(t,r,n)}handleWeb3ResponseMessage(t){var r;const{response:n}=t;if((r=this.diagnostic)===null||r===void 0||r.log(ir.EVENTS.WEB3_RESPONSE,{eventId:t.id,method:`relay::${n.method}`,sessionIdHash:this.getSessionIdHash()}),n.method==="requestEthereumAccounts"){Tt.accountRequestCallbackIds.forEach(i=>this.invokeCallback(Object.assign(Object.assign({},t),{id:i}))),Tt.accountRequestCallbackIds.clear();return}this.invokeCallback(t)}handleErrorResponse(t,r,n,i){var s;const a=(s=n==null?void 0:n.message)!==null&&s!==void 0?s:(0,Lr.getMessageFromCode)(i);this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:t,response:{method:r,errorMessage:a,errorCode:i}})}invokeCallback(t){const r=this.relayEventManager.callbacks.get(t.id);r&&(r(t.response),this.relayEventManager.callbacks.delete(t.id))}requestEthereumAccounts(){const t={method:"requestEthereumAccounts",params:{appName:this.appName,appLogoUrl:this.appLogoUrl||null}},r=(0,Fe.randomBytesHex)(8),n=s=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,t.method,s)};return{promise:new Promise((s,a)=>{if(this.relayEventManager.callbacks.set(r,l=>{if(this.ui.hideRequestEthereumAccounts(),(0,sr.isErrorResponse)(l))return a(new Error(l.errorMessage));s(l)}),this.ui.inlineAccountsResponse()){const l=d=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:r,response:{method:"requestEthereumAccounts",result:d}})};this.ui.requestEthereumAccounts({onCancel:n,onAccounts:l})}else{const l=Lr.standardErrors.provider.userRejectedRequest("User denied account authorization");this.ui.requestEthereumAccounts({onCancel:()=>n(l)})}Tt.accountRequestCallbackIds.add(r),!this.ui.inlineAccountsResponse()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(r,t)}),cancel:n}}selectProvider(t){const r={method:"selectProvider",params:{providerOptions:t}},n=(0,Fe.randomBytesHex)(8),i=a=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,r.method,a)},s=new Promise((a,l)=>{this.relayEventManager.callbacks.set(n,m=>{if((0,sr.isErrorResponse)(m))return l(new Error(m.errorMessage));a(m)});const d=m=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n,response:{method:"selectProvider",result:Nd.ProviderType.Unselected}})},h=m=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:n,response:{method:"selectProvider",result:m}})};this.ui.selectProvider&&this.ui.selectProvider({onApprove:h,onCancel:d,providerOptions:t})});return{cancel:i,promise:s}}watchAsset(t,r,n,i,s,a){const l={method:"watchAsset",params:{type:t,options:{address:r,symbol:n,decimals:i,image:s},chainId:a}};let d=null;const h=(0,Fe.randomBytesHex)(8),m=y=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,l.method,y),d==null||d()};this.ui.inlineWatchAsset()||(d=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:m,onResetConnection:this.resetAndReload}));const R=new Promise((y,C)=>{this.relayEventManager.callbacks.set(h,O=>{if(d==null||d(),(0,sr.isErrorResponse)(O))return C(new Error(O.errorMessage));y(O)});const x=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"watchAsset",result:!1}})},B=()=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"watchAsset",result:!0}})};this.ui.inlineWatchAsset()&&this.ui.watchAsset({onApprove:B,onCancel:x,type:t,address:r,symbol:n,decimals:i,image:s,chainId:a}),!this.ui.inlineWatchAsset()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(h,l)});return{cancel:m,promise:R}}addEthereumChain(t,r,n,i,s,a){const l={method:"addEthereumChain",params:{chainId:t,rpcUrls:r,blockExplorerUrls:i,chainName:s,iconUrls:n,nativeCurrency:a}};let d=null;const h=(0,Fe.randomBytesHex)(8),m=y=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,l.method,y),d==null||d()};return this.ui.inlineAddEthereumChain(t)||(d=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:m,onResetConnection:this.resetAndReload})),{promise:new Promise((y,C)=>{this.relayEventManager.callbacks.set(h,O=>{if(d==null||d(),(0,sr.isErrorResponse)(O))return C(new Error(O.errorMessage));y(O)});const x=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"addEthereumChain",result:{isApproved:!1,rpcUrl:""}}})},B=O=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:h,response:{method:"addEthereumChain",result:{isApproved:!0,rpcUrl:O}}})};this.ui.inlineAddEthereumChain(t)&&this.ui.addEthereumChain({onCancel:x,onApprove:B,chainId:l.params.chainId,rpcUrls:l.params.rpcUrls,blockExplorerUrls:l.params.blockExplorerUrls,chainName:l.params.chainName,iconUrls:l.params.iconUrls,nativeCurrency:l.params.nativeCurrency}),!this.ui.inlineAddEthereumChain(t)&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(h,l)}),cancel:m}}switchEthereumChain(t,r){const n={method:"switchEthereumChain",params:Object.assign({chainId:t},{address:r})},i=(0,Fe.randomBytesHex)(8),s=l=>{this.publishWeb3RequestCanceledEvent(i),this.handleErrorResponse(i,n.method,l)};return{promise:new Promise((l,d)=>{this.relayEventManager.callbacks.set(i,R=>{if((0,sr.isErrorResponse)(R)&&R.errorCode)return d(Lr.standardErrors.provider.custom({code:R.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if((0,sr.isErrorResponse)(R))return d(new Error(R.errorMessage));l(R)});const h=R=>{var y;if(R){const C=(y=(0,Lr.getErrorCode)(R))!==null&&y!==void 0?y:Lr.standardErrorCodes.provider.unsupportedChain;this.handleErrorResponse(i,"switchEthereumChain",R instanceof Error?R:Lr.standardErrors.provider.unsupportedChain(t),C)}else this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i,response:{method:"switchEthereumChain",result:{isApproved:!1,rpcUrl:""}}})},m=R=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:i,response:{method:"switchEthereumChain",result:{isApproved:!0,rpcUrl:R}}})};this.ui.switchEthereumChain({onCancel:h,onApprove:m,chainId:n.params.chainId,address:n.params.address}),!this.ui.inlineSwitchEthereumChain()&&!this.ui.isStandalone()&&this.publishWeb3RequestEvent(i,n)}),cancel:s}}inlineAddEthereumChain(t){return this.ui.inlineAddEthereumChain(t)}getSessionIdHash(){return Pt.Session.hash(this._session.id)}sendRequestStandalone(t,r){const n=s=>{this.handleErrorResponse(t,r.method,s)},i=s=>{this.handleWeb3ResponseMessage({type:"WEB3_RESPONSE",id:t,response:s})};switch(r.method){case"signEthereumMessage":this.ui.signEthereumMessage({request:r,onSuccess:i,onCancel:n});break;case"signEthereumTransaction":this.ui.signEthereumTransaction({request:r,onSuccess:i,onCancel:n});break;case"submitEthereumTransaction":this.ui.submitEthereumTransaction({request:r,onSuccess:i,onCancel:n});break;case"ethereumAddressFromSignedMessage":this.ui.ethereumAddressFromSignedMessage({request:r,onSuccess:i});break;default:n();break}}}_n.WalletLinkRelay=Tt;Tt.accountRequestCallbackIds=new Set;var In={},Ni={},$c={};(function(e){var t=Q&&Q.__createBinding||(Object.create?function(n,i,s,a){a===void 0&&(a=s);var l=Object.getOwnPropertyDescriptor(i,s);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,a,l)}:function(n,i,s,a){a===void 0&&(a=s),n[a]=i[s]}),r=Q&&Q.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&t(i,n,s)};Object.defineProperty(e,"__esModule",{value:!0}),r(Ys,e)})($c);var eo={};Object.defineProperty(eo,"__esModule",{value:!0});eo.default=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";var Bc=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ni,"__esModule",{value:!0});Ni.RedirectDialog=void 0;const Pd=Bc(Cn),Rt=tt,$d=kn,Bd=$c,Dd=Bc(eo);class Fd{constructor(){this.root=null}attach(){const t=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",t.appendChild(this.root),(0,$d.injectCssReset)()}present(t){this.render(t)}clear(){this.render(null)}render(t){this.root&&((0,Rt.render)(null,this.root),t&&(0,Rt.render)((0,Rt.h)(jd,Object.assign({},t,{onDismiss:()=>{this.clear()}})),this.root))}}Ni.RedirectDialog=Fd;const jd=({title:e,buttonText:t,darkMode:r,onButtonClick:n,onDismiss:i})=>{const s=r?"dark":"light";return(0,Rt.h)(Bd.SnackbarContainer,{darkMode:r},(0,Rt.h)("div",{class:"-cbwsdk-redirect-dialog"},(0,Rt.h)("style",null,Dd.default),(0,Rt.h)("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),(0,Rt.h)("div",{class:(0,Pd.default)("-cbwsdk-redirect-dialog-box",s)},(0,Rt.h)("p",null,e),(0,Rt.h)("button",{onClick:n},t))))};Object.defineProperty(In,"__esModule",{value:!0});In.MobileRelayUI=void 0;const Hd=Ni;class Ud{constructor(t){this.attached=!1,this.darkMode=!1,this.redirectDialog=new Hd.RedirectDialog,this.darkMode=t.darkMode}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}setConnected(t){}redirectToCoinbaseWallet(t){const r=new URL("https://go.cb-w.com/walletlink");r.searchParams.append("redirect_url",window.location.href),t&&r.searchParams.append("wl_url",t);const n=document.createElement("a");n.target="cbw-opener",n.href=r.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(t){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",darkMode:this.darkMode,onButtonClick:()=>{this.redirectToCoinbaseWallet(t)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(t)},99)}showConnecting(t){return()=>{this.redirectDialog.clear()}}hideRequestEthereumAccounts(){this.redirectDialog.clear()}requestEthereumAccounts(){}addEthereumChain(){}watchAsset(){}selectProvider(){}switchEthereumChain(){}signEthereumMessage(){}signEthereumTransaction(){}submitEthereumTransaction(){}ethereumAddressFromSignedMessage(){}reloadUI(){}setStandalone(){}setConnectDisabled(){}inlineAccountsResponse(){return!1}inlineAddEthereumChain(){return!1}inlineWatchAsset(){return!1}inlineSwitchEthereumChain(){return!1}isStandalone(){return!1}}In.MobileRelayUI=Ud;Object.defineProperty(wn,"__esModule",{value:!0});wn.MobileRelay=void 0;const Wd=q,Vd=_n,zd=In;class qd extends Vd.WalletLinkRelay{constructor(t){var r;super(t),this._enableMobileWalletLink=(r=t.enableMobileWalletLink)!==null&&r!==void 0?r:!1}requestEthereumAccounts(){return this._enableMobileWalletLink?super.requestEthereumAccounts():{promise:new Promise(()=>{const t=(0,Wd.getLocation)();t.href=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(t.href)}`}),cancel:()=>{}}}publishWeb3RequestEvent(t,r){if(super.publishWeb3RequestEvent(t,r),!(this._enableMobileWalletLink&&this.ui instanceof zd.MobileRelayUI))return;let n=!1;switch(r.method){case"requestEthereumAccounts":case"connectAndSignIn":n=!0,this.ui.openCoinbaseWalletDeeplink(this.getQRCodeUrl());break;case"switchEthereumChain":return;default:n=!0,this.ui.openCoinbaseWalletDeeplink();break}n&&window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0})}handleWeb3ResponseMessage(t){super.handleWeb3ResponseMessage(t)}connectAndSignIn(t){if(!this._enableMobileWalletLink)throw new Error("connectAndSignIn is supported only when enableMobileWalletLink is on");return this.sendRequest({method:"connectAndSignIn",params:{appName:this.appName,appLogoUrl:this.appLogoUrl,domain:window.location.hostname,aud:window.location.href,version:"1",type:"eip4361",nonce:t.nonce,iat:new Date().toISOString(),chainId:`eip155:${this.dappDefaultChain}`,statement:t.statement,resources:t.resources}})}}wn.MobileRelay=qd;var $s={exports:{}},Dc=si.EventEmitter,ps,Ko;function Jd(){if(Ko)return ps;Ko=1;function e(x,B){var O=Object.keys(x);if(Object.getOwnPropertySymbols){var M=Object.getOwnPropertySymbols(x);B&&(M=M.filter(function(T){return Object.getOwnPropertyDescriptor(x,T).enumerable})),O.push.apply(O,M)}return O}function t(x){for(var B=1;B0?this.tail.next=M:this.head=M,this.tail=M,++this.length}},{key:"unshift",value:function(O){var M={data:O,next:this.head};this.length===0&&(this.tail=M),this.head=M,++this.length}},{key:"shift",value:function(){if(this.length!==0){var O=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,O}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(O){if(this.length===0)return"";for(var M=this.head,T=""+M.data;M=M.next;)T+=O+M.data;return T}},{key:"concat",value:function(O){if(this.length===0)return h.alloc(0);for(var M=h.allocUnsafe(O>>>0),T=this.head,N=0;T;)C(T.data,M,N),N+=T.data.length,T=T.next;return M}},{key:"consume",value:function(O,M){var T;return OD.length?D.length:O;if(L===D.length?N+=D:N+=D.slice(0,O),O-=L,O===0){L===D.length?(++T,M.next?this.head=M.next:this.head=this.tail=null):(this.head=M,M.data=D.slice(L));break}++T}return this.length-=T,N}},{key:"_getBuffer",value:function(O){var M=h.allocUnsafe(O),T=this.head,N=1;for(T.data.copy(M),O-=T.data.length;T=T.next;){var D=T.data,L=O>D.length?D.length:O;if(D.copy(M,M.length-O,0,L),O-=L,O===0){L===D.length?(++N,T.next?this.head=T.next:this.head=this.tail=null):(this.head=T,T.data=D.slice(L));break}++N}return this.length-=N,M}},{key:y,value:function(O,M){return R(this,t(t({},M),{},{depth:0,customInspect:!1}))}}]),x}(),ps}var or={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};function Gd(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,or.nextTick(Bs,this,e)):or.nextTick(Bs,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(s){!t&&s?r._writableState?r._writableState.errorEmitted?or.nextTick(Xn,r):(r._writableState.errorEmitted=!0,or.nextTick(Qo,r,s)):or.nextTick(Qo,r,s):t?(or.nextTick(Xn,r),t(s)):or.nextTick(Xn,r)}),this)}function Qo(e,t){Bs(e,t),Xn(e)}function Xn(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function Zd(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Bs(e,t){e.emit("error",t)}function Kd(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}var Fc={destroy:Gd,undestroy:Zd,errorOrDestroy:Kd},mr={};function Qd(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var jc={};function pt(e,t,r){r||(r=Error);function n(s,a,l){return typeof t=="string"?t:t(s,a,l)}var i=function(s){Qd(a,s);function a(l,d,h){return s.call(this,n(l,d,h))||this}return a}(r);i.prototype.name=r.name,i.prototype.code=e,jc[e]=i}function Yo(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function Yd(e,t,r){return e.substr(0,t.length)===t}function Xd(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function ef(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}pt("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);pt("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&Yd(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Xd(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Yo(t,"type"));else{var s=ef(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(s," ").concat(n," ").concat(Yo(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);pt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");pt("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});pt("ERR_STREAM_PREMATURE_CLOSE","Premature close");pt("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});pt("ERR_MULTIPLE_CALLBACK","Callback called multiple times");pt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");pt("ERR_STREAM_WRITE_AFTER_END","write after end");pt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);pt("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);pt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");mr.codes=jc;var tf=mr.codes.ERR_INVALID_OPT_VALUE;function rf(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function nf(e,t,r,n){var i=rf(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var s=n?r:"highWaterMark";throw new tf(s,i)}return Math.floor(i)}return e.objectMode?16:16*1024}var Hc={getHighWaterMark:nf},sf=of;function of(e,t){if(gs("noDeprecation"))return e;var r=!1;function n(){if(!r){if(gs("throwDeprecation"))throw new Error(t);gs("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function gs(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var ms,Xo;function Uc(){if(Xo)return ms;Xo=1;var e={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};ms=Z;function t(A){var I=this;this.next=null,this.entry=null,this.finish=function(){V(I,A)}}var r;Z.WritableState=W;var n={deprecate:sf},i=Dc,s=ii.Buffer,a=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function l(A){return s.from(A)}function d(A){return s.isBuffer(A)||A instanceof a}var h=Fc,m=Hc,R=m.getHighWaterMark,y=mr.codes,C=y.ERR_INVALID_ARG_TYPE,x=y.ERR_METHOD_NOT_IMPLEMENTED,B=y.ERR_MULTIPLE_CALLBACK,O=y.ERR_STREAM_CANNOT_PIPE,M=y.ERR_STREAM_DESTROYED,T=y.ERR_STREAM_NULL_VALUES,N=y.ERR_STREAM_WRITE_AFTER_END,D=y.ERR_UNKNOWN_ENCODING,L=h.errorOrDestroy;vt(Z,i);function F(){}function W(A,I,$){r=r||zr(),A=A||{},typeof $!="boolean"&&($=I instanceof r),this.objectMode=!!A.objectMode,$&&(this.objectMode=this.objectMode||!!A.writableObjectMode),this.highWaterMark=R(this,A,"writableHighWaterMark",$),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var K=A.decodeStrings===!1;this.decodeStrings=!K,this.defaultEncoding=A.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(G){p(I,G)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=A.emitClose!==!1,this.autoDestroy=!!A.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}W.prototype.getBuffer=function(){for(var I=this.bufferedRequest,$=[];I;)$.push(I),I=I.next;return $},function(){try{Object.defineProperty(W.prototype,"buffer",{get:n.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var te;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(te=Function.prototype[Symbol.hasInstance],Object.defineProperty(Z,Symbol.hasInstance,{value:function(I){return te.call(this,I)?!0:this!==Z?!1:I&&I._writableState instanceof W}})):te=function(I){return I instanceof this};function Z(A){r=r||zr();var I=this instanceof r;if(!I&&!te.call(Z,this))return new Z(A);this._writableState=new W(A,this,I),this.writable=!0,A&&(typeof A.write=="function"&&(this._write=A.write),typeof A.writev=="function"&&(this._writev=A.writev),typeof A.destroy=="function"&&(this._destroy=A.destroy),typeof A.final=="function"&&(this._final=A.final)),i.call(this)}Z.prototype.pipe=function(){L(this,new O)};function z(A,I){var $=new N;L(A,$),e.nextTick(I,$)}function X(A,I,$,K){var G;return $===null?G=new T:typeof $!="string"&&!I.objectMode&&(G=new C("chunk",["string","Buffer"],$)),G?(L(A,G),e.nextTick(K,G),!1):!0}Z.prototype.write=function(A,I,$){var K=this._writableState,G=!1,b=!K.objectMode&&d(A);return b&&!s.isBuffer(A)&&(A=l(A)),typeof I=="function"&&($=I,I=null),b?I="buffer":I||(I=K.defaultEncoding),typeof $!="function"&&($=F),K.ending?z(this,$):(b||X(this,K,A,$))&&(K.pendingcb++,G=S(this,K,b,A,I,$)),G},Z.prototype.cork=function(){this._writableState.corked++},Z.prototype.uncork=function(){var A=this._writableState;A.corked&&(A.corked--,!A.writing&&!A.corked&&!A.bufferProcessing&&A.bufferedRequest&&k(this,A))},Z.prototype.setDefaultEncoding=function(I){if(typeof I=="string"&&(I=I.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((I+"").toLowerCase())>-1))throw new D(I);return this._writableState.defaultEncoding=I,this},Object.defineProperty(Z.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function ne(A,I,$){return!A.objectMode&&A.decodeStrings!==!1&&typeof I=="string"&&(I=s.from(I,$)),I}Object.defineProperty(Z.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function S(A,I,$,K,G,b){if(!$){var _=ne(I,K,G);K!==_&&($=!0,G="buffer",K=_)}var P=I.objectMode?1:K.length;I.length+=P;var j=I.length>5===6?2:M>>4===14?3:M>>3===30?4:M>>6===2?-1:-2}function a(M,T,N){var D=T.length-1;if(D=0?(L>0&&(M.lastNeed=L-1),L):--D=0?(L>0&&(M.lastNeed=L-2),L):--D=0?(L>0&&(L===2?L=0:M.lastNeed=L-3),L):0))}function l(M,T,N){if((T[0]&192)!==128)return M.lastNeed=0,"�";if(M.lastNeed>1&&T.length>1){if((T[1]&192)!==128)return M.lastNeed=1,"�";if(M.lastNeed>2&&T.length>2&&(T[2]&192)!==128)return M.lastNeed=2,"�"}}function d(M){var T=this.lastTotal-this.lastNeed,N=l(this,M);if(N!==void 0)return N;if(this.lastNeed<=M.length)return M.copy(this.lastChar,T,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);M.copy(this.lastChar,T,0,M.length),this.lastNeed-=M.length}function h(M,T){var N=a(this,M,T);if(!this.lastNeed)return M.toString("utf8",T);this.lastTotal=N;var D=M.length-(N-this.lastNeed);return M.copy(this.lastChar,0,D),M.toString("utf8",T,D)}function m(M){var T=M&&M.length?this.write(M):"";return this.lastNeed?T+"�":T}function R(M,T){if((M.length-T)%2===0){var N=M.toString("utf16le",T);if(N){var D=N.charCodeAt(N.length-1);if(D>=55296&&D<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=M[M.length-2],this.lastChar[1]=M[M.length-1],N.slice(0,-1)}return N}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=M[M.length-1],M.toString("utf16le",T,M.length-1)}function y(M){var T=M&&M.length?this.write(M):"";if(this.lastNeed){var N=this.lastTotal-this.lastNeed;return T+this.lastChar.toString("utf16le",0,N)}return T}function C(M,T){var N=(M.length-T)%3;return N===0?M.toString("base64",T):(this.lastNeed=3-N,this.lastTotal=3,N===1?this.lastChar[0]=M[M.length-1]:(this.lastChar[0]=M[M.length-2],this.lastChar[1]=M[M.length-1]),M.toString("base64",T,M.length-N))}function x(M){var T=M&&M.length?this.write(M):"";return this.lastNeed?T+this.lastChar.toString("base64",0,3-this.lastNeed):T}function B(M){return M.toString(this.encoding)}function O(M){return M&&M.length?this.write(M):""}return bs}var na=mr.codes.ERR_STREAM_PREMATURE_CLOSE;function af(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i0)if(typeof _!="string"&&!J.objectMode&&Object.getPrototypeOf(_)!==i.prototype&&(_=a(_)),j)J.endEmitted?F(b,new T):ne(b,J,_,!0);else if(J.ended)F(b,new O);else{if(J.destroyed)return!1;J.reading=!1,J.decoder&&!P?(_=J.decoder.write(_),J.objectMode||_.length!==0?ne(b,J,_,!1):k(b,J)):ne(b,J,_,!1)}else j||(J.reading=!1,k(b,J))}return!J.ended&&(J.length=o?b=o:(b--,b|=b>>>1,b|=b>>>2,b|=b>>>4,b|=b>>>8,b|=b>>>16,b++),b}function f(b,_){return b<=0||_.length===0&&_.ended?0:_.objectMode?1:b!==b?_.flowing&&_.length?_.buffer.head.data.length:_.length:(b>_.highWaterMark&&(_.highWaterMark=u(b)),b<=_.length?b:_.ended?_.length:(_.needReadable=!0,0))}z.prototype.read=function(b){h("read",b),b=parseInt(b,10);var _=this._readableState,P=b;if(b!==0&&(_.emittedReadable=!1),b===0&&_.needReadable&&((_.highWaterMark!==0?_.length>=_.highWaterMark:_.length>0)||_.ended))return h("read: emitReadable",_.length,_.ended),_.length===0&&_.ended?$(this):v(this),null;if(b=f(b,_),b===0&&_.ended)return _.length===0&&$(this),null;var j=_.needReadable;h("need readable",j),(_.length===0||_.length-b<_.highWaterMark)&&(j=!0,h("length less than watermark",j)),_.ended||_.reading?(j=!1,h("reading or ended",j)):j&&(h("do read"),_.reading=!0,_.sync=!0,_.length===0&&(_.needReadable=!0),this._read(_.highWaterMark),_.sync=!1,_.reading||(b=f(P,_)));var ue;return b>0?ue=I(b,_):ue=null,ue===null?(_.needReadable=_.length<=_.highWaterMark,b=0):(_.length-=b,_.awaitDrain=0),_.length===0&&(_.ended||(_.needReadable=!0),P!==b&&_.ended&&$(this)),ue!==null&&this.emit("data",ue),ue};function p(b,_){if(h("onEofChunk"),!_.ended){if(_.decoder){var P=_.decoder.end();P&&P.length&&(_.buffer.push(P),_.length+=_.objectMode?1:P.length)}_.ended=!0,_.sync?v(b):(_.needReadable=!1,_.emittedReadable||(_.emittedReadable=!0,E(b)))}}function v(b){var _=b._readableState;h("emitReadable",_.needReadable,_.emittedReadable),_.needReadable=!1,_.emittedReadable||(h("emitReadable",_.flowing),_.emittedReadable=!0,e.nextTick(E,b))}function E(b){var _=b._readableState;h("emitReadable_",_.destroyed,_.length,_.ended),!_.destroyed&&(_.length||_.ended)&&(b.emit("readable"),_.emittedReadable=!1),_.needReadable=!_.flowing&&!_.ended&&_.length<=_.highWaterMark,A(b)}function k(b,_){_.readingMore||(_.readingMore=!0,e.nextTick(g,b,_))}function g(b,_){for(;!_.reading&&!_.ended&&(_.length<_.highWaterMark||_.flowing&&_.length===0);){var P=_.length;if(h("maybeReadMore read 0"),b.read(0),P===_.length)break}_.readingMore=!1}z.prototype._read=function(b){F(this,new M("_read()"))},z.prototype.pipe=function(b,_){var P=this,j=this._readableState;switch(j.pipesCount){case 0:j.pipes=b;break;case 1:j.pipes=[j.pipes,b];break;default:j.pipes.push(b);break}j.pipesCount+=1,h("pipe count=%d opts=%j",j.pipesCount,_);var ue=(!_||_.end!==!1)&&b!==e.stdout&&b!==e.stderr,J=ue?at:le;j.endEmitted?e.nextTick(J):P.once("end",J),b.on("unpipe",Y);function Y(nt,ce){h("onunpipe"),nt===P&&ce&&ce.hasUnpiped===!1&&(ce.hasUnpiped=!0,Ht())}function at(){h("onend"),b.end()}var he=c(P);b.on("drain",he);var pe=!1;function Ht(){h("cleanup"),b.removeListener("close",xt),b.removeListener("finish",fe),b.removeListener("drain",he),b.removeListener("error",de),b.removeListener("unpipe",Y),P.removeListener("end",at),P.removeListener("end",le),P.removeListener("data",ge),pe=!0,j.awaitDrain&&(!b._writableState||b._writableState.needDrain)&&he()}P.on("data",ge);function ge(nt){h("ondata");var ce=b.write(nt);h("dest.write",ce),ce===!1&&((j.pipesCount===1&&j.pipes===b||j.pipesCount>1&&G(j.pipes,b)!==-1)&&!pe&&(h("false write response, pause",j.awaitDrain),j.awaitDrain++),P.pause())}function de(nt){h("onerror",nt),le(),b.removeListener("error",de),r(b,"error")===0&&F(b,nt)}te(b,"error",de);function xt(){b.removeListener("finish",fe),le()}b.once("close",xt);function fe(){h("onfinish"),b.removeListener("close",xt),le()}b.once("finish",fe);function le(){h("unpipe"),P.unpipe(b)}return b.emit("pipe",P),j.flowing||(h("pipe resume"),P.resume()),b};function c(b){return function(){var P=b._readableState;h("pipeOnDrain",P.awaitDrain),P.awaitDrain&&P.awaitDrain--,P.awaitDrain===0&&r(b,"data")&&(P.flowing=!0,A(b))}}z.prototype.unpipe=function(b){var _=this._readableState,P={hasUnpiped:!1};if(_.pipesCount===0)return this;if(_.pipesCount===1)return b&&b!==_.pipes?this:(b||(b=_.pipes),_.pipes=null,_.pipesCount=0,_.flowing=!1,b&&b.emit("unpipe",this,P),this);if(!b){var j=_.pipes,ue=_.pipesCount;_.pipes=null,_.pipesCount=0,_.flowing=!1;for(var J=0;J0,j.flowing!==!1&&this.resume()):b==="readable"&&!j.endEmitted&&!j.readableListening&&(j.readableListening=j.needReadable=!0,j.flowing=!1,j.emittedReadable=!1,h("on readable",j.length,j.reading),j.length?v(this):j.reading||e.nextTick(U,this)),P},z.prototype.addListener=z.prototype.on,z.prototype.removeListener=function(b,_){var P=n.prototype.removeListener.call(this,b,_);return b==="readable"&&e.nextTick(w,this),P},z.prototype.removeAllListeners=function(b){var _=n.prototype.removeAllListeners.apply(this,arguments);return(b==="readable"||b===void 0)&&e.nextTick(w,this),_};function w(b){var _=b._readableState;_.readableListening=b.listenerCount("readable")>0,_.resumeScheduled&&!_.paused?_.flowing=!0:b.listenerCount("data")>0&&b.resume()}function U(b){h("readable nexttick read 0"),b.read(0)}z.prototype.resume=function(){var b=this._readableState;return b.flowing||(h("resume"),b.flowing=!b.readableListening,H(this,b)),b.paused=!1,this};function H(b,_){_.resumeScheduled||(_.resumeScheduled=!0,e.nextTick(V,b,_))}function V(b,_){h("resume",_.reading),_.reading||b.read(0),_.resumeScheduled=!1,b.emit("resume"),A(b),_.flowing&&!_.reading&&b.read(0)}z.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function A(b){var _=b._readableState;for(h("flow",_.flowing);_.flowing&&b.read()!==null;);}z.prototype.wrap=function(b){var _=this,P=this._readableState,j=!1;b.on("end",function(){if(h("wrapped end"),P.decoder&&!P.ended){var Y=P.decoder.end();Y&&Y.length&&_.push(Y)}_.push(null)}),b.on("data",function(Y){if(h("wrapped data"),P.decoder&&(Y=P.decoder.write(Y)),!(P.objectMode&&Y==null)&&!(!P.objectMode&&(!Y||!Y.length))){var at=_.push(Y);at||(j=!0,b.pause())}});for(var ue in b)this[ue]===void 0&&typeof b[ue]=="function"&&(this[ue]=function(at){return function(){return b[at].apply(b,arguments)}}(ue));for(var J=0;J=_.length?(_.decoder?P=_.buffer.join(""):_.buffer.length===1?P=_.buffer.first():P=_.buffer.concat(_.length),_.buffer.clear()):P=_.buffer.consume(b,_.decoder),P}function $(b){var _=b._readableState;h("endReadable",_.endEmitted),_.endEmitted||(_.ended=!0,e.nextTick(K,_,b))}function K(b,_){if(h("endReadableNT",b.endEmitted,b.length),!b.endEmitted&&b.length===0&&(b.endEmitted=!0,_.readable=!1,_.emit("end"),b.autoDestroy)){var P=_._writableState;(!P||P.autoDestroy&&P.finished)&&_.destroy()}}typeof Symbol=="function"&&(z.from=function(b,_){return L===void 0&&(L=hf()),L(z,b,_)});function G(b,_){for(var P=0,j=b.length;P0;return Sf(a,d,h,function(m){i||(i=m),m&&s.forEach(la),!d&&(s.forEach(la),n(i))})});return t.reduce(Rf)}var Cf=kf;(function(e,t){t=e.exports=Vc(),t.Stream=t,t.Readable=t,t.Writable=Uc(),t.Duplex=zr(),t.Transform=zc,t.PassThrough=bf,t.finished=to,t.pipeline=Cf})($s,$s.exports);var Gc=$s.exports;const{Transform:If}=Gc;var xf=e=>class Zc extends If{constructor(r,n,i,s,a){super(a),this._rate=r,this._capacity=n,this._delimitedSuffix=i,this._hashBitLength=s,this._options=a,this._state=new e,this._state.initialize(r,n),this._finalized=!1}_transform(r,n,i){let s=null;try{this.update(r,n)}catch(a){s=a}i(s)}_flush(r){let n=null;try{this.push(this.digest())}catch(i){n=i}r(n)}update(r,n){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,n)),this._state.absorb(r),this}digest(r){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let n=this._state.squeeze(this._hashBitLength/8);return r!==void 0&&(n=n.toString(r)),this._resetState(),n}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new Zc(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const{Transform:Af}=Gc;var Tf=e=>class Kc extends Af{constructor(r,n,i,s){super(s),this._rate=r,this._capacity=n,this._delimitedSuffix=i,this._options=s,this._state=new e,this._state.initialize(r,n),this._finalized=!1}_transform(r,n,i){let s=null;try{this.update(r,n)}catch(a){s=a}i(s)}_flush(){}_read(r){this.push(this.squeeze(r))}update(r,n){if(!Buffer.isBuffer(r)&&typeof r!="string")throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(r)||(r=Buffer.from(r,n)),this._state.absorb(r),this}squeeze(r,n){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let i=this._state.squeeze(r);return n!==void 0&&(i=i.toString(n)),i}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const r=new Kc(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(r._state),r._finalized=this._finalized,r}};const Nf=xf,Lf=Tf;var Of=function(e){const t=Nf(e),r=Lf(e);return function(n,i){switch(typeof n=="string"?n.toLowerCase():n){case"keccak224":return new t(1152,448,null,224,i);case"keccak256":return new t(1088,512,null,256,i);case"keccak384":return new t(832,768,null,384,i);case"keccak512":return new t(576,1024,null,512,i);case"sha3-224":return new t(1152,448,6,224,i);case"sha3-256":return new t(1088,512,6,256,i);case"sha3-384":return new t(832,768,6,384,i);case"sha3-512":return new t(576,1024,6,512,i);case"shake128":return new r(1344,256,31,i);case"shake256":return new r(1088,512,31,i);default:throw new Error("Invald algorithm: "+n)}}},Qc={};const ua=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];Qc.p1600=function(e){for(let t=0;t<24;++t){const r=e[0]^e[10]^e[20]^e[30]^e[40],n=e[1]^e[11]^e[21]^e[31]^e[41],i=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],l=e[5]^e[15]^e[25]^e[35]^e[45],d=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],m=e[8]^e[18]^e[28]^e[38]^e[48],R=e[9]^e[19]^e[29]^e[39]^e[49];let y=m^(i<<1|s>>>31),C=R^(s<<1|i>>>31);const x=e[0]^y,B=e[1]^C,O=e[10]^y,M=e[11]^C,T=e[20]^y,N=e[21]^C,D=e[30]^y,L=e[31]^C,F=e[40]^y,W=e[41]^C;y=r^(a<<1|l>>>31),C=n^(l<<1|a>>>31);const te=e[2]^y,Z=e[3]^C,z=e[12]^y,X=e[13]^C,ne=e[22]^y,S=e[23]^C,o=e[32]^y,u=e[33]^C,f=e[42]^y,p=e[43]^C;y=i^(d<<1|h>>>31),C=s^(h<<1|d>>>31);const v=e[4]^y,E=e[5]^C,k=e[14]^y,g=e[15]^C,c=e[24]^y,w=e[25]^C,U=e[34]^y,H=e[35]^C,V=e[44]^y,A=e[45]^C;y=a^(m<<1|R>>>31),C=l^(R<<1|m>>>31);const I=e[6]^y,$=e[7]^C,K=e[16]^y,G=e[17]^C,b=e[26]^y,_=e[27]^C,P=e[36]^y,j=e[37]^C,ue=e[46]^y,J=e[47]^C;y=d^(r<<1|n>>>31),C=h^(n<<1|r>>>31);const Y=e[8]^y,at=e[9]^C,he=e[18]^y,pe=e[19]^C,Ht=e[28]^y,ge=e[29]^C,de=e[38]^y,xt=e[39]^C,fe=e[48]^y,le=e[49]^C,nt=x,ce=B,me=M<<4|O>>>28,wr=O<<4|M>>>28,ve=T<<3|N>>>29,be=N<<3|T>>>29,_r=L<<9|D>>>23,we=D<<9|L>>>23,_e=F<<18|W>>>14,yr=W<<18|F>>>14,ye=te<<1|Z>>>31,Ee=Z<<1|te>>>31,Er=X<<12|z>>>20,Se=z<<12|X>>>20,Re=ne<<10|S>>>22,Sr=S<<10|ne>>>22,Me=u<<13|o>>>19,ke=o<<13|u>>>19,Rr=f<<2|p>>>30,Ce=p<<2|f>>>30,Ie=E<<30|v>>>2,Mr=v<<30|E>>>2,xe=k<<6|g>>>26,Ae=g<<6|k>>>26,kr=w<<11|c>>>21,Te=c<<11|w>>>21,Ne=U<<15|H>>>17,Cr=H<<15|U>>>17,Le=A<<29|V>>>3,Oe=V<<29|A>>>3,Ir=I<<28|$>>>4,Pe=$<<28|I>>>4,$e=G<<23|K>>>9,xr=K<<23|G>>>9,Be=b<<25|_>>>7,De=_<<25|b>>>7,Ut=P<<21|j>>>11,Wt=j<<21|P>>>11,Vt=J<<24|ue>>>8,zt=ue<<24|J>>>8,qt=Y<<27|at>>>5,Jt=at<<27|Y>>>5,Gt=he<<20|pe>>>12,Zt=pe<<20|he>>>12,Kt=ge<<7|Ht>>>25,Qt=Ht<<7|ge>>>25,Yt=de<<8|xt>>>24,Xt=xt<<8|de>>>24,er=fe<<14|le>>>18,tr=le<<14|fe>>>18;e[0]=nt^~Er&kr,e[1]=ce^~Se&Te,e[10]=Ir^~Gt&ve,e[11]=Pe^~Zt&be,e[20]=ye^~xe&Be,e[21]=Ee^~Ae&De,e[30]=qt^~me&Re,e[31]=Jt^~wr&Sr,e[40]=Ie^~$e&Kt,e[41]=Mr^~xr&Qt,e[2]=Er^~kr&Ut,e[3]=Se^~Te&Wt,e[12]=Gt^~ve&Me,e[13]=Zt^~be&ke,e[22]=xe^~Be&Yt,e[23]=Ae^~De&Xt,e[32]=me^~Re&Ne,e[33]=wr^~Sr&Cr,e[42]=$e^~Kt&_r,e[43]=xr^~Qt&we,e[4]=kr^~Ut&er,e[5]=Te^~Wt&tr,e[14]=ve^~Me&Le,e[15]=be^~ke&Oe,e[24]=Be^~Yt&_e,e[25]=De^~Xt&yr,e[34]=Re^~Ne&Vt,e[35]=Sr^~Cr&zt,e[44]=Kt^~_r&Rr,e[45]=Qt^~we&Ce,e[6]=Ut^~er&nt,e[7]=Wt^~tr&ce,e[16]=Me^~Le&Ir,e[17]=ke^~Oe&Pe,e[26]=Yt^~_e&ye,e[27]=Xt^~yr&Ee,e[36]=Ne^~Vt&qt,e[37]=Cr^~zt&Jt,e[46]=_r^~Rr&Ie,e[47]=we^~Ce&Mr,e[8]=er^~nt&Er,e[9]=tr^~ce&Se,e[18]=Le^~Ir&Gt,e[19]=Oe^~Pe&Zt,e[28]=_e^~ye&xe,e[29]=yr^~Ee&Ae,e[38]=Vt^~qt&me,e[39]=zt^~Jt&wr,e[48]=Rr^~Ie&$e,e[49]=Ce^~Mr&xr,e[0]^=ua[t*2],e[1]^=ua[t*2+1]}};const ti=Qc;function tn(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}tn.prototype.initialize=function(e,t){for(let r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1};tn.prototype.absorb=function(e){for(let t=0;t>>8*(this.count%4)&255,this.count+=1,this.count===this.blockSize&&(ti.p1600(this.state),this.count=0);return t};tn.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing};var Pf=tn,$f=Of(Pf);const Bf=$f,Df=ci;function Yc(e){return Buffer.allocUnsafe(e).fill(0)}function Xc(e,t,r){const n=Yc(t);return e=Pi(e),r?e.length"u")throw new Error("Not an array?");if(r=il(e),r!=="dynamic"&&r!==0&&t.length>r)throw new Error("Elements exceed array size: "+r);i=[],e=e.slice(0,e.lastIndexOf("[")),typeof t=="string"&&(t=JSON.parse(t));for(s in t)i.push(St(e,t[s]));if(r==="dynamic"){var a=St("uint256",t.length);i.unshift(a)}return Buffer.concat(i)}else{if(e==="bytes")return t=new Buffer(t),i=Buffer.concat([St("uint256",t.length),t]),t.length%32!==0&&(i=Buffer.concat([i,dr.zeros(32-t.length%32)])),i;if(e.startsWith("bytes")){if(r=Fr(e),r<1||r>32)throw new Error("Invalid bytes width: "+r);return dr.setLengthRight(t,32)}else if(e.startsWith("uint")){if(r=Fr(e),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=ar(t),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());if(n<0)throw new Error("Supplied uint is negative");return n.toArrayLike(Buffer,"be",32)}else if(e.startsWith("int")){if(r=Fr(e),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=ar(t),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());return n.toTwos(256).toArrayLike(Buffer,"be",32)}else if(e.startsWith("ufixed")){if(r=ha(e),n=ar(t),n<0)throw new Error("Supplied ufixed is negative");return St("uint256",n.mul(new lr(2).pow(new lr(r[1]))))}else if(e.startsWith("fixed"))return r=ha(e),St("int256",ar(t).mul(new lr(2).pow(new lr(r[1]))))}throw new Error("Unsupported or invalid type: "+e)}function Wf(e){return e==="string"||e==="bytes"||il(e)==="dynamic"}function Vf(e){return e.lastIndexOf("]")===e.length-1}function zf(e,t){var r=[],n=[],i=32*e.length;for(var s in e){var a=nl(e[s]),l=t[s],d=St(a,l);Wf(a)?(r.push(St("uint256",i)),n.push(d),i+=d.length):r.push(d)}return Buffer.concat(r.concat(n))}function sl(e,t){if(e.length!==t.length)throw new Error("Number of types are not matching the values");for(var r,n,i=[],s=0;s32)throw new Error("Invalid bytes width: "+r);i.push(dr.setLengthRight(l,r))}else if(a.startsWith("uint")){if(r=Fr(a),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);if(n=ar(l),n.bitLength()>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+n.bitLength());i.push(n.toArrayLike(Buffer,"be",r/8))}else if(a.startsWith("int")){if(r=Fr(a),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);if(n=ar(l),n.bitLength()>r)throw new Error("Supplied int exceeds width: "+r+" vs "+n.bitLength());i.push(n.toTwos(r).toArrayLike(Buffer,"be",r/8))}else throw new Error("Unsupported or invalid type: "+a)}return Buffer.concat(i)}function qf(e,t){return dr.keccak(sl(e,t))}var Jf={rawEncode:zf,solidityPack:sl,soliditySHA3:qf};const mt=rl,un=Jf,ol={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},Ss={encodeData(e,t,r,n=!0){const i=["bytes32"],s=[this.hashType(e,r)];if(n){const a=(l,d,h)=>{if(r[d]!==void 0)return["bytes32",h==null?"0x0000000000000000000000000000000000000000000000000000000000000000":mt.keccak(this.encodeData(d,h,r,n))];if(h===void 0)throw new Error(`missing value for field ${l} of type ${d}`);if(d==="bytes")return["bytes32",mt.keccak(h)];if(d==="string")return typeof h=="string"&&(h=Buffer.from(h,"utf8")),["bytes32",mt.keccak(h)];if(d.lastIndexOf("]")===d.length-1){const m=d.slice(0,d.lastIndexOf("[")),R=h.map(y=>a(l,m,y));return["bytes32",mt.keccak(un.rawEncode(R.map(([y])=>y),R.map(([,y])=>y)))]}return[d,h]};for(const l of r[e]){const[d,h]=a(l.name,l.type,t[l.name]);i.push(d),s.push(h)}}else for(const a of r[e]){let l=t[a.name];if(l!==void 0)if(a.type==="bytes")i.push("bytes32"),l=mt.keccak(l),s.push(l);else if(a.type==="string")i.push("bytes32"),typeof l=="string"&&(l=Buffer.from(l,"utf8")),l=mt.keccak(l),s.push(l);else if(r[a.type]!==void 0)i.push("bytes32"),l=mt.keccak(this.encodeData(a.type,l,r,n)),s.push(l);else{if(a.type.lastIndexOf("]")===a.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(a.type),s.push(l)}}return un.rawEncode(i,s)},encodeType(e,t){let r="",n=this.findTypeDependencies(e,t).filter(i=>i!==e);n=[e].concat(n.sort());for(const i of n){if(!t[i])throw new Error("No type definition specified: "+i);r+=i+"("+t[i].map(({name:a,type:l})=>l+" "+a).join(",")+")"}return r},findTypeDependencies(e,t,r=[]){if(e=e.match(/^\w*/)[0],r.includes(e)||t[e]===void 0)return r;r.push(e);for(const n of t[e])for(const i of this.findTypeDependencies(n.type,t,r))!r.includes(i)&&r.push(i);return r},hashStruct(e,t,r,n=!0){return mt.keccak(this.encodeData(e,t,r,n))},hashType(e,t){return mt.keccak(this.encodeType(e,t))},sanitizeData(e){const t={};for(const r in ol.properties)e[r]&&(t[r]=e[r]);return t.types&&(t.types=Object.assign({EIP712Domain:[]},t.types)),t},hash(e,t=!0){const r=this.sanitizeData(e),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",r.domain,r.types,t)),r.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(r.primaryType,r.message,r.types,t)),mt.keccak(Buffer.concat(n))}};var Gf={TYPED_MESSAGE_SCHEMA:ol,TypedDataUtils:Ss,hashForSignTypedDataLegacy:function(e){return Zf(e.data)},hashForSignTypedData_v3:function(e){return Ss.hash(e.data,!1)},hashForSignTypedData_v4:function(e){return Ss.hash(e.data)}};function Zf(e){const t=new Error("Expect argument to be non-empty array");if(typeof e!="object"||!e.length)throw t;const r=e.map(function(s){return s.type==="bytes"?mt.toBuffer(s.value):s.value}),n=e.map(function(s){return s.type}),i=e.map(function(s){if(!s.name)throw t;return s.type+" "+s.name});return un.soliditySHA3(["bytes32","bytes32"],[un.soliditySHA3(new Array(e.length).fill("string"),i),un.soliditySHA3(n,r)])}var qr={};Object.defineProperty(qr,"__esModule",{value:!0});qr.filterFromParam=qr.FilterPolyfill=void 0;const $r=Ve,Ye=q,Kf=5*60*1e3,cr={jsonrpc:"2.0",id:0};class Qf{constructor(t){this.logFilters=new Map,this.blockFilters=new Set,this.pendingTransactionFilters=new Set,this.cursors=new Map,this.timeouts=new Map,this.nextFilterId=(0,$r.IntNumber)(1),this.REQUEST_THROTTLE_INTERVAL=1e3,this.lastFetchTimestamp=new Date(0),this.resolvers=[],this.provider=t}async newFilter(t){const r=al(t),n=this.makeFilterId(),i=await this.setInitialCursorPosition(n,r.fromBlock);return console.info(`Installing new log filter(${n}):`,r,"initial cursor position:",i),this.logFilters.set(n,r),this.setFilterTimeout(n),(0,Ye.hexStringFromIntNumber)(n)}async newBlockFilter(){const t=this.makeFilterId(),r=await this.setInitialCursorPosition(t,"latest");return console.info(`Installing new block filter (${t}) with initial cursor position:`,r),this.blockFilters.add(t),this.setFilterTimeout(t),(0,Ye.hexStringFromIntNumber)(t)}async newPendingTransactionFilter(){const t=this.makeFilterId(),r=await this.setInitialCursorPosition(t,"latest");return console.info(`Installing new block filter (${t}) with initial cursor position:`,r),this.pendingTransactionFilters.add(t),this.setFilterTimeout(t),(0,Ye.hexStringFromIntNumber)(t)}uninstallFilter(t){const r=(0,Ye.intNumberFromHexString)(t);return console.info(`Uninstalling filter (${r})`),this.deleteFilter(r),!0}getFilterChanges(t){const r=(0,Ye.intNumberFromHexString)(t);return this.timeouts.has(r)&&this.setFilterTimeout(r),this.logFilters.has(r)?this.getLogFilterChanges(r):this.blockFilters.has(r)?this.getBlockFilterChanges(r):this.pendingTransactionFilters.has(r)?this.getPendingTransactionFilterChanges(r):Promise.resolve(Vn())}async getFilterLogs(t){const r=(0,Ye.intNumberFromHexString)(t),n=this.logFilters.get(r);return n?this.sendAsyncPromise(Object.assign(Object.assign({},cr),{method:"eth_getLogs",params:[da(n)]})):Vn()}makeFilterId(){return(0,$r.IntNumber)(++this.nextFilterId)}sendAsyncPromise(t){return new Promise((r,n)=>{this.provider.sendAsync(t,(i,s)=>{if(i)return n(i);if(Array.isArray(s)||s==null)return n(new Error(`unexpected response received: ${JSON.stringify(s)}`));r(s)})})}deleteFilter(t){console.info(`Deleting filter (${t})`),this.logFilters.delete(t),this.blockFilters.delete(t),this.pendingTransactionFilters.delete(t),this.cursors.delete(t),this.timeouts.delete(t)}async getLogFilterChanges(t){const r=this.logFilters.get(t),n=this.cursors.get(t);if(!n||!r)return Vn();const i=await this.getCurrentBlockHeight(),s=r.toBlock==="latest"?i:r.toBlock;if(n>i||n>Number(r.toBlock))return zn();console.info(`Fetching logs from ${n} to ${s} for filter ${t}`);const a=await this.sendAsyncPromise(Object.assign(Object.assign({},cr),{method:"eth_getLogs",params:[da(Object.assign(Object.assign({},r),{fromBlock:n,toBlock:s}))]}));if(Array.isArray(a.result)){const l=a.result.map(h=>(0,Ye.intNumberFromHexString)(h.blockNumber||"0x0")),d=Math.max(...l);if(d&&d>n){const h=(0,$r.IntNumber)(d+1);console.info(`Moving cursor position for filter (${t}) from ${n} to ${h}`),this.cursors.set(t,h)}}return a}async getBlockFilterChanges(t){const r=this.cursors.get(t);if(!r)return Vn();const n=await this.getCurrentBlockHeight();if(r>n)return zn();console.info(`Fetching blocks from ${r} to ${n} for filter (${t})`);const i=(await Promise.all((0,Ye.range)(r,n+1).map(a=>this.getBlockHashByNumber((0,$r.IntNumber)(a))))).filter(a=>!!a),s=(0,$r.IntNumber)(r+i.length);return console.info(`Moving cursor position for filter (${t}) from ${r} to ${s}`),this.cursors.set(t,s),Object.assign(Object.assign({},cr),{result:i})}async getPendingTransactionFilterChanges(t){return Promise.resolve(zn())}async setInitialCursorPosition(t,r){const n=await this.getCurrentBlockHeight(),i=typeof r=="number"&&r>n?r:n;return this.cursors.set(t,i),i}setFilterTimeout(t){const r=this.timeouts.get(t);r&&window.clearTimeout(r);const n=window.setTimeout(()=>{console.info(`Filter (${t}) timed out`),this.deleteFilter(t)},Kf);this.timeouts.set(t,n)}async getCurrentBlockHeight(){const t=new Date;if(t.getTime()-this.lastFetchTimestamp.getTime()>this.REQUEST_THROTTLE_INTERVAL){this.lastFetchTimestamp=t;const r=await this._getCurrentBlockHeight();this.currentBlockHeight=r,this.resolvers.forEach(n=>n(r)),this.resolvers=[]}return this.currentBlockHeight?this.currentBlockHeight:new Promise(r=>this.resolvers.push(r))}async _getCurrentBlockHeight(){const{result:t}=await this.sendAsyncPromise(Object.assign(Object.assign({},cr),{method:"eth_blockNumber",params:[]}));return(0,Ye.intNumberFromHexString)((0,Ye.ensureHexString)(t))}async getBlockHashByNumber(t){const r=await this.sendAsyncPromise(Object.assign(Object.assign({},cr),{method:"eth_getBlockByNumber",params:[(0,Ye.hexStringFromIntNumber)(t),!1]}));return r.result&&typeof r.result.hash=="string"?(0,Ye.ensureHexString)(r.result.hash):null}}qr.FilterPolyfill=Qf;function al(e){return{fromBlock:fa(e.fromBlock),toBlock:fa(e.toBlock),addresses:e.address===void 0?null:Array.isArray(e.address)?e.address:[e.address],topics:e.topics||[]}}qr.filterFromParam=al;function da(e){const t={fromBlock:pa(e.fromBlock),toBlock:pa(e.toBlock),topics:e.topics};return e.addresses!==null&&(t.address=e.addresses),t}function fa(e){if(e===void 0||e==="latest"||e==="pending")return"latest";if(e==="earliest")return(0,$r.IntNumber)(0);if((0,Ye.isHexString)(e))return(0,Ye.intNumberFromHexString)(e);throw new Error(`Invalid block option: ${String(e)}`)}function pa(e){return e==="latest"?e:(0,Ye.hexStringFromIntNumber)(e)}function Vn(){return Object.assign(Object.assign({},cr),{error:{code:-32e3,message:"filter not found"}})}function zn(){return Object.assign(Object.assign({},cr),{result:[]})}var $i={},cl={},Bi={},ro=Yf;function Yf(e){e=e||{};var t=e.max||Number.MAX_SAFE_INTEGER,r=typeof e.start<"u"?e.start:Math.floor(Math.random()*t);return function(){return r=r%t,r++}}const ga=(e,t)=>function(){const r=t.promiseModule,n=new Array(arguments.length);for(let i=0;i{t.errorFirst?n.push(function(a,l){if(t.multiArgs){const d=new Array(arguments.length-1);for(let h=1;h{t=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},t);const r=i=>{const s=a=>typeof a=="string"?i===a:a.test(i);return t.include?t.include.some(s):!t.exclude.some(s)};let n;typeof e=="function"?n=function(){return t.excludeMain?e.apply(this,arguments):ga(e,t).apply(this,arguments)}:n=Object.create(Object.getPrototypeOf(e));for(const i in e){const s=e[i];n[i]=typeof s=="function"&&r(i)?ga(s,t):s}return n},xn={},An={};Object.defineProperty(An,"__esModule",{value:!0});const e0=si;function ma(e,t,r){try{Reflect.apply(e,t,r)}catch(n){setTimeout(()=>{throw n})}}function t0(e){const t=e.length,r=new Array(t);for(let n=0;n0&&([a]=r),a instanceof Error)throw a;const l=new Error(`Unhandled error.${a?` (${a.message})`:""}`);throw l.context=a,l}const s=i[t];if(s===void 0)return!1;if(typeof s=="function")ma(s,this,r);else{const a=s.length,l=t0(s);for(let d=0;de+t,va=["sync","latest"];class a0 extends i0.default{constructor(t){super(),this._blockResetDuration=t.blockResetDuration||20*s0,this._usePastBlocks=t.usePastBlocks||!1,this._currentBlock=null,this._isRunning=!1,this._onNewListener=this._onNewListener.bind(this),this._onRemoveListener=this._onRemoveListener.bind(this),this._resetCurrentBlock=this._resetCurrentBlock.bind(this),this._setupInternalEvents()}async destroy(){this._cancelBlockResetTimeout(),await this._maybeEnd(),super.removeAllListeners()}isRunning(){return this._isRunning}getCurrentBlock(){return this._currentBlock}async getLatestBlock(){return this._currentBlock?this._currentBlock:await new Promise(r=>this.once("latest",r))}removeAllListeners(t){return t?super.removeAllListeners(t):super.removeAllListeners(),this._setupInternalEvents(),this._onRemoveListener(),this}_setupInternalEvents(){this.removeListener("newListener",this._onNewListener),this.removeListener("removeListener",this._onRemoveListener),this.on("newListener",this._onNewListener),this.on("removeListener",this._onRemoveListener)}_onNewListener(t){va.includes(t)&&this._maybeStart()}_onRemoveListener(){this._getBlockTrackerEventCount()>0||this._maybeEnd()}async _maybeStart(){this._isRunning||(this._isRunning=!0,this._cancelBlockResetTimeout(),await this._start(),this.emit("_started"))}async _maybeEnd(){this._isRunning&&(this._isRunning=!1,this._setupBlockResetTimeout(),await this._end(),this.emit("_ended"))}_getBlockTrackerEventCount(){return va.map(t=>this.listenerCount(t)).reduce(o0)}_shouldUseNewBlock(t){const r=this._currentBlock;if(!r)return!0;const n=ba(t),i=ba(r);return this._usePastBlocks&&ni}_newPotentialLatest(t){this._shouldUseNewBlock(t)&&this._setCurrentBlock(t)}_setCurrentBlock(t){const r=this._currentBlock;this._currentBlock=t,this.emit("latest",t),this.emit("sync",{oldBlock:r,newBlock:t})}_setupBlockResetTimeout(){this._cancelBlockResetTimeout(),this._blockResetTimeout=setTimeout(this._resetCurrentBlock,this._blockResetDuration),this._blockResetTimeout.unref&&this._blockResetTimeout.unref()}_cancelBlockResetTimeout(){this._blockResetTimeout&&clearTimeout(this._blockResetTimeout)}_resetCurrentBlock(){this._currentBlock=null}}xn.BaseBlockTracker=a0;function ba(e){return Number.parseInt(e,16)}var ll={},ul={},Ke={};class hl extends TypeError{constructor(t,r){let n;const{message:i,explanation:s,...a}=t,{path:l}=t,d=l.length===0?i:`At path: ${l.join(".")} -- ${i}`;super(s??d),s!=null&&(this.cause=d),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...r()])}}function c0(e){return ft(e)&&typeof e[Symbol.iterator]=="function"}function ft(e){return typeof e=="object"&&e!=null}function wa(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function ze(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function l0(e){const{done:t,value:r}=e.next();return t?void 0:r}function u0(e,t,r,n){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});const{path:i,branch:s}=t,{type:a}=r,{refinement:l,message:d=`Expected a value of type \`${a}\`${l?` with refinement \`${l}\``:""}, but received: \`${ze(n)}\``}=e;return{value:n,type:a,refinement:l,key:i[i.length-1],path:i,branch:s,...e,message:d}}function*Ds(e,t,r,n){c0(e)||(e=[e]);for(const i of e){const s=u0(i,t,r,n);s&&(yield s)}}function*no(e,t,r={}){const{path:n=[],branch:i=[e],coerce:s=!1,mask:a=!1}=r,l={path:n,branch:i};if(s&&(e=t.coercer(e,l),a&&t.type!=="type"&&ft(t.schema)&&ft(e)&&!Array.isArray(e)))for(const h in e)t.schema[h]===void 0&&delete e[h];let d="valid";for(const h of t.validator(e,l))h.explanation=r.message,d="not_valid",yield[h,void 0];for(let[h,m,R]of t.entries(e,l)){const y=no(m,R,{path:h===void 0?n:[...n,h],branch:h===void 0?i:[...i,m],coerce:s,mask:a,message:r.message});for(const C of y)C[0]?(d=C[0].refinement!=null?"not_refined":"not_valid",yield[C[0],void 0]):s&&(m=C[1],h===void 0?e=m:e instanceof Map?e.set(h,m):e instanceof Set?e.add(m):ft(e)&&(m!==void 0||h in e)&&(e[h]=m))}if(d!=="not_valid")for(const h of t.refiner(e,l))h.explanation=r.message,d="not_refined",yield[h,void 0];d==="valid"&&(yield[void 0,e])}class Ue{constructor(t){const{type:r,schema:n,validator:i,refiner:s,coercer:a=d=>d,entries:l=function*(){}}=t;this.type=r,this.schema=n,this.entries=l,this.coercer=a,i?this.validator=(d,h)=>{const m=i(d,h);return Ds(m,h,this,d)}:this.validator=()=>[],s?this.refiner=(d,h)=>{const m=s(d,h);return Ds(m,h,this,d)}:this.refiner=()=>[]}assert(t,r){return dl(t,this,r)}create(t,r){return fl(t,this,r)}is(t){return io(t,this)}mask(t,r){return pl(t,this,r)}validate(t,r={}){return rn(t,this,r)}}function dl(e,t,r){const n=rn(e,t,{message:r});if(n[0])throw n[0]}function fl(e,t,r){const n=rn(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function pl(e,t,r){const n=rn(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function io(e,t){return!rn(e,t)[0]}function rn(e,t,r={}){const n=no(e,t,r),i=l0(n);return i[0]?[new hl(i[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,i[1]]}function h0(...e){const t=e[0].type==="type",r=e.map(i=>i.schema),n=Object.assign({},...r);return t?Nn(n):Tn(n)}function rt(e,t){return new Ue({type:e,schema:null,validator:t})}function d0(e,t){return new Ue({...e,refiner:(r,n)=>r===void 0||e.refiner(r,n),validator(r,n){return r===void 0?!0:(t(r,n),e.validator(r,n))}})}function f0(e){return new Ue({type:"dynamic",schema:null,*entries(t,r){yield*e(t,r).entries(t,r)},validator(t,r){return e(t,r).validator(t,r)},coercer(t,r){return e(t,r).coercer(t,r)},refiner(t,r){return e(t,r).refiner(t,r)}})}function p0(e){let t;return new Ue({type:"lazy",schema:null,*entries(r,n){t??(t=e()),yield*t.entries(r,n)},validator(r,n){return t??(t=e()),t.validator(r,n)},coercer(r,n){return t??(t=e()),t.coercer(r,n)},refiner(r,n){return t??(t=e()),t.refiner(r,n)}})}function g0(e,t){const{schema:r}=e,n={...r};for(const i of t)delete n[i];switch(e.type){case"type":return Nn(n);default:return Tn(n)}}function m0(e){const t=e instanceof Ue,r=t?{...e.schema}:{...e};for(const n in r)r[n]=gl(r[n]);return t&&e.type==="type"?Nn(r):Tn(r)}function v0(e,t){const{schema:r}=e,n={};for(const i of t)n[i]=r[i];switch(e.type){case"type":return Nn(n);default:return Tn(n)}}function b0(e,t){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),rt(e,t)}function w0(){return rt("any",()=>!0)}function _0(e){return new Ue({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[r,n]of t.entries())yield[r,n,e]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${ze(t)}`}})}function y0(){return rt("bigint",e=>typeof e=="bigint")}function E0(){return rt("boolean",e=>typeof e=="boolean")}function S0(){return rt("date",e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${ze(e)}`)}function R0(e){const t={},r=e.map(n=>ze(n)).join();for(const n of e)t[n]=n;return new Ue({type:"enums",schema:t,validator(n){return e.includes(n)||`Expected one of \`${r}\`, but received: ${ze(n)}`}})}function M0(){return rt("func",e=>typeof e=="function"||`Expected a function, but received: ${ze(e)}`)}function k0(e){return rt("instance",t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${ze(t)}`)}function C0(){return rt("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${ze(e)}`)}function I0(e){return new Ue({type:"intersection",schema:null,*entries(t,r){for(const n of e)yield*n.entries(t,r)},*validator(t,r){for(const n of e)yield*n.validator(t,r)},*refiner(t,r){for(const n of e)yield*n.refiner(t,r)}})}function x0(e){const t=ze(e),r=typeof e;return new Ue({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${ze(n)}`}})}function A0(e,t){return new Ue({type:"map",schema:null,*entries(r){if(e&&t&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,e],yield[n,i,t]},coercer(r){return r instanceof Map?new Map(r):r},validator(r){return r instanceof Map||`Expected a \`Map\` object, but received: ${ze(r)}`}})}function so(){return rt("never",()=>!1)}function T0(e){return new Ue({...e,validator:(t,r)=>t===null||e.validator(t,r),refiner:(t,r)=>t===null||e.refiner(t,r)})}function N0(){return rt("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${ze(e)}`)}function Tn(e){const t=e?Object.keys(e):[],r=so();return new Ue({type:"object",schema:e||null,*entries(n){if(e&&ft(n)){const i=new Set(Object.keys(n));for(const s of t)i.delete(s),yield[s,n[s],e[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return ft(n)||`Expected an object, but received: ${ze(n)}`},coercer(n){return ft(n)?{...n}:n}})}function gl(e){return new Ue({...e,validator:(t,r)=>t===void 0||e.validator(t,r),refiner:(t,r)=>t===void 0||e.refiner(t,r)})}function L0(e,t){return new Ue({type:"record",schema:null,*entries(r){if(ft(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator(r){return ft(r)||`Expected an object, but received: ${ze(r)}`}})}function O0(){return rt("regexp",e=>e instanceof RegExp)}function P0(e){return new Ue({type:"set",schema:null,*entries(t){if(e&&t instanceof Set)for(const r of t)yield[r,r,e]},coercer(t){return t instanceof Set?new Set(t):t},validator(t){return t instanceof Set||`Expected a \`Set\` object, but received: ${ze(t)}`}})}function ml(){return rt("string",e=>typeof e=="string"||`Expected a string, but received: ${ze(e)}`)}function $0(e){const t=so();return new Ue({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(e.length,r.length);for(let i=0;ir.type).join(" | ");return new Ue({type:"union",schema:null,coercer(r){for(const n of e){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of e){const[...a]=no(r,s,n),[l]=a;if(l[0])for(const[d]of a)d&&i.push(d);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${ze(r)}`,...i]}})}function vl(){return rt("unknown",()=>!0)}function oo(e,t,r){return new Ue({...e,coercer:(n,i)=>io(n,t)?e.coercer(r(n,i),i):e.coercer(n,i)})}function D0(e,t,r={}){return oo(e,vl(),n=>{const i=typeof t=="function"?t():t;if(n===void 0)return i;if(!r.strict&&wa(n)&&wa(i)){const s={...n};let a=!1;for(const l in i)s[l]===void 0&&(s[l]=i[l],a=!0);if(a)return s}return n})}function F0(e){return oo(e,ml(),t=>t.trim())}function j0(e){return vr(e,"empty",t=>{const r=bl(t);return r===0||`Expected an empty ${e.type} but received one with a size of \`${r}\``})}function bl(e){return e instanceof Map||e instanceof Set?e.size:e.length}function H0(e,t,r={}){const{exclusive:n}=r;return vr(e,"max",i=>n?in?i>t:i>=t||`Expected a ${e.type} greater than ${n?"":"or equal to "}${t} but received \`${i}\``)}function W0(e){return vr(e,"nonempty",t=>bl(t)>0||`Expected a nonempty ${e.type} but received an empty one`)}function V0(e,t){return vr(e,"pattern",r=>t.test(r)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${r}"`)}function z0(e,t,r=t){const n=`Expected a ${e.type}`,i=t===r?`of \`${t}\``:`between \`${t}\` and \`${r}\``;return vr(e,"size",s=>{if(typeof s=="number"||s instanceof Date)return t<=s&&s<=r||`${n} ${i} but received \`${s}\``;if(s instanceof Map||s instanceof Set){const{size:a}=s;return t<=a&&a<=r||`${n} with a size ${i} but received one with a size of \`${a}\``}else{const{length:a}=s;return t<=a&&a<=r||`${n} with a length ${i} but received one with a length of \`${a}\``}})}function vr(e,t,r){return new Ue({...e,*refiner(n,i){yield*e.refiner(n,i);const s=r(n,i),a=Ds(s,i,e,n);for(const l of a)yield{...l,refinement:t}}})}const q0=Object.freeze(Object.defineProperty({__proto__:null,Struct:Ue,StructError:hl,any:w0,array:_0,assert:dl,assign:h0,bigint:y0,boolean:E0,coerce:oo,create:fl,date:S0,defaulted:D0,define:rt,deprecated:d0,dynamic:f0,empty:j0,enums:R0,func:M0,instance:k0,integer:C0,intersection:I0,is:io,lazy:p0,literal:x0,map:A0,mask:pl,max:H0,min:U0,never:so,nonempty:W0,nullable:T0,number:N0,object:Tn,omit:g0,optional:gl,partial:m0,pattern:V0,pick:v0,record:L0,refine:vr,regexp:O0,set:P0,size:z0,string:ml,struct:b0,trimmed:F0,tuple:$0,type:Nn,union:B0,unknown:vl,validate:rn},Symbol.toStringTag,{value:"Module"})),br=Zr(q0);Object.defineProperty(Ke,"__esModule",{value:!0});Ke.assertExhaustive=Ke.assertStruct=Ke.assert=Ke.AssertionError=void 0;const J0=br;function G0(e){return typeof e=="object"&&e!==null&&"message"in e}function Z0(e){var t,r;return typeof((r=(t=e==null?void 0:e.prototype)===null||t===void 0?void 0:t.constructor)===null||r===void 0?void 0:r.name)=="string"}function K0(e){const t=G0(e)?e.message:String(e);return t.endsWith(".")?t.slice(0,-1):t}function wl(e,t){return Z0(e)?new e({message:t}):e({message:t})}class ao extends Error{constructor(t){super(t.message),this.code="ERR_ASSERTION"}}Ke.AssertionError=ao;function Q0(e,t="Assertion failed.",r=ao){if(!e)throw t instanceof Error?t:wl(r,t)}Ke.assert=Q0;function Y0(e,t,r="Assertion failed",n=ao){try{(0,J0.assert)(e,t)}catch(i){throw wl(n,`${r}: ${K0(i)}.`)}}Ke.assertStruct=Y0;function X0(e){throw new Error("Invalid branch reached. Should be detected during compilation.")}Ke.assertExhaustive=X0;var Ln={};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.base64=void 0;const e1=br,t1=Ke,r1=(e,t={})=>{var r,n;const i=(r=t.paddingRequired)!==null&&r!==void 0?r:!1,s=(n=t.characterSet)!==null&&n!==void 0?n:"base64";let a;s==="base64"?a=String.raw`[A-Za-z0-9+\/]`:((0,t1.assert)(s==="base64url"),a=String.raw`[-_A-Za-z0-9]`);let l;return i?l=new RegExp(`^(?:${a}{4})*(?:${a}{3}=|${a}{2}==)?$`,"u"):l=new RegExp(`^(?:${a}{4})*(?:${a}{2,3}|${a}{3}=|${a}{2}==)?$`,"u"),(0,e1.pattern)(e,l)};Ln.base64=r1;var ae={},On={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.remove0x=e.add0x=e.assertIsStrictHexString=e.assertIsHexString=e.isStrictHexString=e.isHexString=e.StrictHexStruct=e.HexStruct=void 0;const t=br,r=Ke;e.HexStruct=(0,t.pattern)((0,t.string)(),/^(?:0x)?[0-9a-f]+$/iu),e.StrictHexStruct=(0,t.pattern)((0,t.string)(),/^0x[0-9a-f]+$/iu);function n(h){return(0,t.is)(h,e.HexStruct)}e.isHexString=n;function i(h){return(0,t.is)(h,e.StrictHexStruct)}e.isStrictHexString=i;function s(h){(0,r.assert)(n(h),"Value must be a hexadecimal string.")}e.assertIsHexString=s;function a(h){(0,r.assert)(i(h),'Value must be a hexadecimal string, starting with "0x".')}e.assertIsStrictHexString=a;function l(h){return h.startsWith("0x")?h:h.startsWith("0X")?`0x${h.substring(2)}`:`0x${h}`}e.add0x=l;function d(h){return h.startsWith("0x")||h.startsWith("0X")?h.substring(2):h}e.remove0x=d})(On);Object.defineProperty(ae,"__esModule",{value:!0});ae.createDataView=ae.concatBytes=ae.valueToBytes=ae.stringToBytes=ae.numberToBytes=ae.signedBigIntToBytes=ae.bigIntToBytes=ae.hexToBytes=ae.bytesToString=ae.bytesToNumber=ae.bytesToSignedBigInt=ae.bytesToBigInt=ae.bytesToHex=ae.assertIsBytes=ae.isBytes=void 0;const ot=Ke,Fs=On,_a=48,ya=58,Ea=87;function n1(){const e=[];return()=>{if(e.length===0)for(let t=0;t<256;t++)e.push(t.toString(16).padStart(2,"0"));return e}}const i1=n1();function co(e){return e instanceof Uint8Array}ae.isBytes=co;function nn(e){(0,ot.assert)(co(e),"Value must be a Uint8Array.")}ae.assertIsBytes=nn;function _l(e){if(nn(e),e.length===0)return"0x";const t=i1(),r=new Array(e.length);for(let n=0;n=BigInt(0),"Value must be a non-negative bigint.");const t=e.toString(16);return Di(t)}ae.bigIntToBytes=El;function c1(e,t){(0,ot.assert)(t>0);const r=e>>BigInt(31);return!((~e&r)+(e&~r)>>BigInt(t*8+-1))}function l1(e,t){(0,ot.assert)(typeof e=="bigint","Value must be a bigint."),(0,ot.assert)(typeof t=="number","Byte length must be a number."),(0,ot.assert)(t>0,"Byte length must be greater than 0."),(0,ot.assert)(c1(e,t),"Byte length is too small to represent the given value.");let r=e;const n=new Uint8Array(t);for(let i=0;i>=BigInt(8);return n.reverse()}ae.signedBigIntToBytes=l1;function Sl(e){(0,ot.assert)(typeof e=="number","Value must be a number."),(0,ot.assert)(e>=0,"Value must be a non-negative number."),(0,ot.assert)(Number.isSafeInteger(e),"Value is not a safe integer. Use `bigIntToBytes` instead.");const t=e.toString(16);return Di(t)}ae.numberToBytes=Sl;function Rl(e){return(0,ot.assert)(typeof e=="string","Value must be a string."),new TextEncoder().encode(e)}ae.stringToBytes=Rl;function Ml(e){if(typeof e=="bigint")return El(e);if(typeof e=="number")return Sl(e);if(typeof e=="string")return e.startsWith("0x")?Di(e):Rl(e);if(co(e))return e;throw new TypeError(`Unsupported value type: "${typeof e}".`)}ae.valueToBytes=Ml;function u1(e){const t=new Array(e.length);let r=0;for(let i=0;it.call(r,n,i,this))}get(t){return Xe(this,gt,"f").get(t)}has(t){return Xe(this,gt,"f").has(t)}keys(){return Xe(this,gt,"f").keys()}values(){return Xe(this,gt,"f").values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map(([t,r])=>`${String(t)} => ${String(r)}`).join(", ")} `:""}}`}}Jr.FrozenMap=lo;class uo{constructor(t){yt.set(this,void 0),Il(this,yt,new Set(t),"f"),Object.freeze(this)}get size(){return Xe(this,yt,"f").size}[(yt=new WeakMap,Symbol.iterator)](){return Xe(this,yt,"f")[Symbol.iterator]()}entries(){return Xe(this,yt,"f").entries()}forEach(t,r){return Xe(this,yt,"f").forEach((n,i,s)=>t.call(r,n,i,this))}has(t){return Xe(this,yt,"f").has(t)}keys(){return Xe(this,yt,"f").keys()}values(){return Xe(this,yt,"f").values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map(t=>String(t)).join(", ")} `:""}}`}}Jr.FrozenSet=uo;Object.freeze(lo);Object.freeze(lo.prototype);Object.freeze(uo);Object.freeze(uo.prototype);var xl={};Object.defineProperty(xl,"__esModule",{value:!0});var Al={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getJsonRpcIdValidator=e.assertIsJsonRpcError=e.isJsonRpcError=e.assertIsJsonRpcFailure=e.isJsonRpcFailure=e.assertIsJsonRpcSuccess=e.isJsonRpcSuccess=e.assertIsJsonRpcResponse=e.isJsonRpcResponse=e.assertIsPendingJsonRpcResponse=e.isPendingJsonRpcResponse=e.JsonRpcResponseStruct=e.JsonRpcFailureStruct=e.JsonRpcSuccessStruct=e.PendingJsonRpcResponseStruct=e.assertIsJsonRpcRequest=e.isJsonRpcRequest=e.assertIsJsonRpcNotification=e.isJsonRpcNotification=e.JsonRpcNotificationStruct=e.JsonRpcRequestStruct=e.JsonRpcParamsStruct=e.JsonRpcErrorStruct=e.JsonRpcIdStruct=e.JsonRpcVersionStruct=e.jsonrpc2=e.getJsonSize=e.isValidJson=e.JsonStruct=e.UnsafeJsonStruct=void 0;const t=br,r=Ke,n=()=>(0,t.define)("finite number",L=>(0,t.is)(L,(0,t.number)())&&Number.isFinite(L));e.UnsafeJsonStruct=(0,t.union)([(0,t.literal)(null),(0,t.boolean)(),n(),(0,t.string)(),(0,t.array)((0,t.lazy)(()=>e.UnsafeJsonStruct)),(0,t.record)((0,t.string)(),(0,t.lazy)(()=>e.UnsafeJsonStruct))]),e.JsonStruct=(0,t.define)("Json",(L,F)=>{function W(te,Z){const X=[...Z.validator(te,F)];return X.length>0?X:!0}try{const te=W(L,e.UnsafeJsonStruct);return te!==!0?te:W(JSON.parse(JSON.stringify(L)),e.UnsafeJsonStruct)}catch(te){return te instanceof RangeError?"Circular reference detected":!1}});function i(L){return(0,t.is)(L,e.JsonStruct)}e.isValidJson=i;function s(L){(0,r.assertStruct)(L,e.JsonStruct,"Invalid JSON value");const F=JSON.stringify(L);return new TextEncoder().encode(F).byteLength}e.getJsonSize=s,e.jsonrpc2="2.0",e.JsonRpcVersionStruct=(0,t.literal)(e.jsonrpc2),e.JsonRpcIdStruct=(0,t.nullable)((0,t.union)([(0,t.number)(),(0,t.string)()])),e.JsonRpcErrorStruct=(0,t.object)({code:(0,t.integer)(),message:(0,t.string)(),data:(0,t.optional)(e.JsonStruct),stack:(0,t.optional)((0,t.string)())}),e.JsonRpcParamsStruct=(0,t.optional)((0,t.union)([(0,t.record)((0,t.string)(),e.JsonStruct),(0,t.array)(e.JsonStruct)])),e.JsonRpcRequestStruct=(0,t.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,method:(0,t.string)(),params:e.JsonRpcParamsStruct}),e.JsonRpcNotificationStruct=(0,t.omit)(e.JsonRpcRequestStruct,["id"]);function a(L){return(0,t.is)(L,e.JsonRpcNotificationStruct)}e.isJsonRpcNotification=a;function l(L,F){(0,r.assertStruct)(L,e.JsonRpcNotificationStruct,"Invalid JSON-RPC notification",F)}e.assertIsJsonRpcNotification=l;function d(L){return(0,t.is)(L,e.JsonRpcRequestStruct)}e.isJsonRpcRequest=d;function h(L,F){(0,r.assertStruct)(L,e.JsonRpcRequestStruct,"Invalid JSON-RPC request",F)}e.assertIsJsonRpcRequest=h,e.PendingJsonRpcResponseStruct=(0,t.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,result:(0,t.optional)((0,t.unknown)()),error:(0,t.optional)(e.JsonRpcErrorStruct)}),e.JsonRpcSuccessStruct=(0,t.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,result:e.JsonStruct}),e.JsonRpcFailureStruct=(0,t.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,error:e.JsonRpcErrorStruct}),e.JsonRpcResponseStruct=(0,t.union)([e.JsonRpcSuccessStruct,e.JsonRpcFailureStruct]);function m(L){return(0,t.is)(L,e.PendingJsonRpcResponseStruct)}e.isPendingJsonRpcResponse=m;function R(L,F){(0,r.assertStruct)(L,e.PendingJsonRpcResponseStruct,"Invalid pending JSON-RPC response",F)}e.assertIsPendingJsonRpcResponse=R;function y(L){return(0,t.is)(L,e.JsonRpcResponseStruct)}e.isJsonRpcResponse=y;function C(L,F){(0,r.assertStruct)(L,e.JsonRpcResponseStruct,"Invalid JSON-RPC response",F)}e.assertIsJsonRpcResponse=C;function x(L){return(0,t.is)(L,e.JsonRpcSuccessStruct)}e.isJsonRpcSuccess=x;function B(L,F){(0,r.assertStruct)(L,e.JsonRpcSuccessStruct,"Invalid JSON-RPC success response",F)}e.assertIsJsonRpcSuccess=B;function O(L){return(0,t.is)(L,e.JsonRpcFailureStruct)}e.isJsonRpcFailure=O;function M(L,F){(0,r.assertStruct)(L,e.JsonRpcFailureStruct,"Invalid JSON-RPC failure response",F)}e.assertIsJsonRpcFailure=M;function T(L){return(0,t.is)(L,e.JsonRpcErrorStruct)}e.isJsonRpcError=T;function N(L,F){(0,r.assertStruct)(L,e.JsonRpcErrorStruct,"Invalid JSON-RPC error",F)}e.assertIsJsonRpcError=N;function D(L){const{permitEmptyString:F,permitFractions:W,permitNull:te}=Object.assign({permitEmptyString:!0,permitFractions:!1,permitNull:!0},L);return z=>!!(typeof z=="number"&&(W||Number.isInteger(z))||typeof z=="string"&&(F||z.length>0)||te&&z===null)}e.getJsonRpcIdValidator=D})(Al);var Tl={};Object.defineProperty(Tl,"__esModule",{value:!0});var Gr={},E1=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Gr,"__esModule",{value:!0});Gr.createModuleLogger=Gr.createProjectLogger=void 0;const S1=E1(su),R1=(0,S1.default)("metamask");function M1(e){return R1.extend(e)}Gr.createProjectLogger=M1;function k1(e,t){return e.extend(t)}Gr.createModuleLogger=k1;var Nl={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.calculateNumberSize=e.calculateStringSize=e.isASCII=e.isPlainObject=e.ESCAPE_CHARACTERS_REGEXP=e.JsonSize=e.hasProperty=e.isObject=e.isNullOrUndefined=e.isNonEmptyArray=void 0;function t(h){return Array.isArray(h)&&h.length>0}e.isNonEmptyArray=t;function r(h){return h==null}e.isNullOrUndefined=r;function n(h){return!!h&&typeof h=="object"&&!Array.isArray(h)}e.isObject=n;const i=(h,m)=>Object.hasOwnProperty.call(h,m);e.hasProperty=i,function(h){h[h.Null=4]="Null",h[h.Comma=1]="Comma",h[h.Wrapper=1]="Wrapper",h[h.True=4]="True",h[h.False=5]="False",h[h.Quote=1]="Quote",h[h.Colon=1]="Colon",h[h.Date=24]="Date"}(e.JsonSize||(e.JsonSize={})),e.ESCAPE_CHARACTERS_REGEXP=/"|\\|\n|\r|\t/gu;function s(h){if(typeof h!="object"||h===null)return!1;try{let m=h;for(;Object.getPrototypeOf(m)!==null;)m=Object.getPrototypeOf(m);return Object.getPrototypeOf(h)===m}catch{return!1}}e.isPlainObject=s;function a(h){return h.charCodeAt(0)<=127}e.isASCII=a;function l(h){var m;return h.split("").reduce((y,C)=>a(C)?y+1:y+2,0)+((m=h.match(e.ESCAPE_CHARACTERS_REGEXP))!==null&&m!==void 0?m:[]).length}e.calculateStringSize=l;function d(h){return h.toString().length}e.calculateNumberSize=d})(Nl);var It={};Object.defineProperty(It,"__esModule",{value:!0});It.hexToBigInt=It.hexToNumber=It.bigIntToHex=It.numberToHex=void 0;const jr=Ke,fn=On,C1=e=>((0,jr.assert)(typeof e=="number","Value must be a number."),(0,jr.assert)(e>=0,"Value must be a non-negative number."),(0,jr.assert)(Number.isSafeInteger(e),"Value is not a safe integer. Use `bigIntToHex` instead."),(0,fn.add0x)(e.toString(16)));It.numberToHex=C1;const I1=e=>((0,jr.assert)(typeof e=="bigint","Value must be a bigint."),(0,jr.assert)(e>=0,"Value must be a non-negative bigint."),(0,fn.add0x)(e.toString(16)));It.bigIntToHex=I1;const x1=e=>{(0,fn.assertIsHexString)(e);const t=parseInt(e,16);return(0,jr.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `hexToBigInt` instead."),t};It.hexToNumber=x1;const A1=e=>((0,fn.assertIsHexString)(e),BigInt((0,fn.add0x)(e)));It.hexToBigInt=A1;var Ll={};Object.defineProperty(Ll,"__esModule",{value:!0});var Ol={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.timeSince=e.inMilliseconds=e.Duration=void 0,function(s){s[s.Millisecond=1]="Millisecond",s[s.Second=1e3]="Second",s[s.Minute=6e4]="Minute",s[s.Hour=36e5]="Hour",s[s.Day=864e5]="Day",s[s.Week=6048e5]="Week",s[s.Year=31536e6]="Year"}(e.Duration||(e.Duration={}));const t=s=>Number.isInteger(s)&&s>=0,r=(s,a)=>{if(!t(s))throw new Error(`"${a}" must be a non-negative integer. Received: "${s}".`)};function n(s,a){return r(s,"count"),s*a}e.inMilliseconds=n;function i(s){return r(s,"timestamp"),Date.now()-s}e.timeSince=i})(Ol);var Pl={};Object.defineProperty(Pl,"__esModule",{value:!0});var $l={},js={exports:{}};const T1="2.0.0",Bl=256,N1=Number.MAX_SAFE_INTEGER||9007199254740991,L1=16,O1=Bl-6,P1=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var Hi={MAX_LENGTH:Bl,MAX_SAFE_COMPONENT_LENGTH:L1,MAX_SAFE_BUILD_LENGTH:O1,MAX_SAFE_INTEGER:N1,RELEASE_TYPES:P1,SEMVER_SPEC_VERSION:T1,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},$1={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},Rs={};const B1=typeof $1=="object"&&Rs&&Rs.NODE_DEBUG&&/\bsemver\b/i.test(Rs.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};var Ui=B1;(function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=Hi,s=Ui;t=e.exports={};const a=t.re=[],l=t.safeRe=[],d=t.src=[],h=t.t={};let m=0;const R="[a-zA-Z0-9-]",y=[["\\s",1],["\\d",i],[R,n]],C=B=>{for(const[O,M]of y)B=B.split(`${O}*`).join(`${O}{0,${M}}`).split(`${O}+`).join(`${O}{1,${M}}`);return B},x=(B,O,M)=>{const T=C(O),N=m++;s(B,N,O),h[B]=N,d[N]=O,a[N]=new RegExp(O,M?"g":void 0),l[N]=new RegExp(T,M?"g":void 0)};x("NUMERICIDENTIFIER","0|[1-9]\\d*"),x("NUMERICIDENTIFIERLOOSE","\\d+"),x("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${R}*`),x("MAINVERSION",`(${d[h.NUMERICIDENTIFIER]})\\.(${d[h.NUMERICIDENTIFIER]})\\.(${d[h.NUMERICIDENTIFIER]})`),x("MAINVERSIONLOOSE",`(${d[h.NUMERICIDENTIFIERLOOSE]})\\.(${d[h.NUMERICIDENTIFIERLOOSE]})\\.(${d[h.NUMERICIDENTIFIERLOOSE]})`),x("PRERELEASEIDENTIFIER",`(?:${d[h.NUMERICIDENTIFIER]}|${d[h.NONNUMERICIDENTIFIER]})`),x("PRERELEASEIDENTIFIERLOOSE",`(?:${d[h.NUMERICIDENTIFIERLOOSE]}|${d[h.NONNUMERICIDENTIFIER]})`),x("PRERELEASE",`(?:-(${d[h.PRERELEASEIDENTIFIER]}(?:\\.${d[h.PRERELEASEIDENTIFIER]})*))`),x("PRERELEASELOOSE",`(?:-?(${d[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${d[h.PRERELEASEIDENTIFIERLOOSE]})*))`),x("BUILDIDENTIFIER",`${R}+`),x("BUILD",`(?:\\+(${d[h.BUILDIDENTIFIER]}(?:\\.${d[h.BUILDIDENTIFIER]})*))`),x("FULLPLAIN",`v?${d[h.MAINVERSION]}${d[h.PRERELEASE]}?${d[h.BUILD]}?`),x("FULL",`^${d[h.FULLPLAIN]}$`),x("LOOSEPLAIN",`[v=\\s]*${d[h.MAINVERSIONLOOSE]}${d[h.PRERELEASELOOSE]}?${d[h.BUILD]}?`),x("LOOSE",`^${d[h.LOOSEPLAIN]}$`),x("GTLT","((?:<|>)?=?)"),x("XRANGEIDENTIFIERLOOSE",`${d[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),x("XRANGEIDENTIFIER",`${d[h.NUMERICIDENTIFIER]}|x|X|\\*`),x("XRANGEPLAIN",`[v=\\s]*(${d[h.XRANGEIDENTIFIER]})(?:\\.(${d[h.XRANGEIDENTIFIER]})(?:\\.(${d[h.XRANGEIDENTIFIER]})(?:${d[h.PRERELEASE]})?${d[h.BUILD]}?)?)?`),x("XRANGEPLAINLOOSE",`[v=\\s]*(${d[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[h.XRANGEIDENTIFIERLOOSE]})(?:${d[h.PRERELEASELOOSE]})?${d[h.BUILD]}?)?)?`),x("XRANGE",`^${d[h.GTLT]}\\s*${d[h.XRANGEPLAIN]}$`),x("XRANGELOOSE",`^${d[h.GTLT]}\\s*${d[h.XRANGEPLAINLOOSE]}$`),x("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),x("COERCE",`${d[h.COERCEPLAIN]}(?:$|[^\\d])`),x("COERCEFULL",d[h.COERCEPLAIN]+`(?:${d[h.PRERELEASE]})?(?:${d[h.BUILD]})?(?:$|[^\\d])`),x("COERCERTL",d[h.COERCE],!0),x("COERCERTLFULL",d[h.COERCEFULL],!0),x("LONETILDE","(?:~>?)"),x("TILDETRIM",`(\\s*)${d[h.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",x("TILDE",`^${d[h.LONETILDE]}${d[h.XRANGEPLAIN]}$`),x("TILDELOOSE",`^${d[h.LONETILDE]}${d[h.XRANGEPLAINLOOSE]}$`),x("LONECARET","(?:\\^)"),x("CARETTRIM",`(\\s*)${d[h.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",x("CARET",`^${d[h.LONECARET]}${d[h.XRANGEPLAIN]}$`),x("CARETLOOSE",`^${d[h.LONECARET]}${d[h.XRANGEPLAINLOOSE]}$`),x("COMPARATORLOOSE",`^${d[h.GTLT]}\\s*(${d[h.LOOSEPLAIN]})$|^$`),x("COMPARATOR",`^${d[h.GTLT]}\\s*(${d[h.FULLPLAIN]})$|^$`),x("COMPARATORTRIM",`(\\s*)${d[h.GTLT]}\\s*(${d[h.LOOSEPLAIN]}|${d[h.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",x("HYPHENRANGE",`^\\s*(${d[h.XRANGEPLAIN]})\\s+-\\s+(${d[h.XRANGEPLAIN]})\\s*$`),x("HYPHENRANGELOOSE",`^\\s*(${d[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${d[h.XRANGEPLAINLOOSE]})\\s*$`),x("STAR","(<|>)?=?\\s*\\*"),x("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),x("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(js,js.exports);var Pn=js.exports;const D1=Object.freeze({loose:!0}),F1=Object.freeze({}),j1=e=>e?typeof e!="object"?D1:e:F1;var ho=j1;const Ra=/^[0-9]+$/,Dl=(e,t)=>{const r=Ra.test(e),n=Ra.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:eDl(t,e);var Fl={compareIdentifiers:Dl,rcompareIdentifiers:H1};const qn=Ui,{MAX_LENGTH:Ma,MAX_SAFE_INTEGER:Jn}=Hi,{safeRe:ka,t:Ca}=Pn,U1=ho,{compareIdentifiers:Or}=Fl;let W1=class Et{constructor(t,r){if(r=U1(r),t instanceof Et){if(t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>Ma)throw new TypeError(`version is longer than ${Ma} characters`);qn("SemVer",t,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;const n=t.trim().match(r.loose?ka[Ca.LOOSE]:ka[Ca.FULL]);if(!n)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>Jn||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Jn||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Jn||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){const s=+i;if(s>=0&&s=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(r===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(r){let s=[r,i];n===!1&&(s=[r]),Or(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var et=W1;const Ia=et,V1=(e,t,r=!1)=>{if(e instanceof Ia)return e;try{return new Ia(e,t)}catch(n){if(!r)return null;throw n}};var sn=V1;const z1=sn,q1=(e,t)=>{const r=z1(e,t);return r?r.version:null};var J1=q1;const G1=sn,Z1=(e,t)=>{const r=G1(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};var K1=Z1;const xa=et,Q1=(e,t,r,n,i)=>{typeof r=="string"&&(i=n,n=r,r=void 0);try{return new xa(e instanceof xa?e.version:e,r).inc(t,n,i).version}catch{return null}};var Y1=Q1;const Aa=sn,X1=(e,t)=>{const r=Aa(e,null,!0),n=Aa(t,null,!0),i=r.compare(n);if(i===0)return null;const s=i>0,a=s?r:n,l=s?n:r,d=!!a.prerelease.length;if(!!l.prerelease.length&&!d)return!l.patch&&!l.minor?"major":a.patch?"patch":a.minor?"minor":"major";const m=d?"pre":"";return r.major!==n.major?m+"major":r.minor!==n.minor?m+"minor":r.patch!==n.patch?m+"patch":"prerelease"};var ep=X1;const tp=et,rp=(e,t)=>new tp(e,t).major;var np=rp;const ip=et,sp=(e,t)=>new ip(e,t).minor;var op=sp;const ap=et,cp=(e,t)=>new ap(e,t).patch;var lp=cp;const up=sn,hp=(e,t)=>{const r=up(e,t);return r&&r.prerelease.length?r.prerelease:null};var dp=hp;const Ta=et,fp=(e,t,r)=>new Ta(e,r).compare(new Ta(t,r));var bt=fp;const pp=bt,gp=(e,t,r)=>pp(t,e,r);var mp=gp;const vp=bt,bp=(e,t)=>vp(e,t,!0);var wp=bp;const Na=et,_p=(e,t,r)=>{const n=new Na(e,r),i=new Na(t,r);return n.compare(i)||n.compareBuild(i)};var fo=_p;const yp=fo,Ep=(e,t)=>e.sort((r,n)=>yp(r,n,t));var Sp=Ep;const Rp=fo,Mp=(e,t)=>e.sort((r,n)=>Rp(n,r,t));var kp=Mp;const Cp=bt,Ip=(e,t,r)=>Cp(e,t,r)>0;var Wi=Ip;const xp=bt,Ap=(e,t,r)=>xp(e,t,r)<0;var po=Ap;const Tp=bt,Np=(e,t,r)=>Tp(e,t,r)===0;var jl=Np;const Lp=bt,Op=(e,t,r)=>Lp(e,t,r)!==0;var Hl=Op;const Pp=bt,$p=(e,t,r)=>Pp(e,t,r)>=0;var go=$p;const Bp=bt,Dp=(e,t,r)=>Bp(e,t,r)<=0;var mo=Dp;const Fp=jl,jp=Hl,Hp=Wi,Up=go,Wp=po,Vp=mo,zp=(e,t,r,n)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e===r;case"!==":return typeof e=="object"&&(e=e.version),typeof r=="object"&&(r=r.version),e!==r;case"":case"=":case"==":return Fp(e,r,n);case"!=":return jp(e,r,n);case">":return Hp(e,r,n);case">=":return Up(e,r,n);case"<":return Wp(e,r,n);case"<=":return Vp(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}};var Ul=zp;const qp=et,Jp=sn,{safeRe:Gn,t:Zn}=Pn,Gp=(e,t)=>{if(e instanceof qp)return e;if(typeof e=="number"&&(e=String(e)),typeof e!="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?Gn[Zn.COERCEFULL]:Gn[Zn.COERCE]);else{const d=t.includePrerelease?Gn[Zn.COERCERTLFULL]:Gn[Zn.COERCERTL];let h;for(;(h=d.exec(e))&&(!r||r.index+r[0].length!==e.length);)(!r||h.index+h[0].length!==r.index+r[0].length)&&(r=h),d.lastIndex=h.index+h[1].length+h[2].length;d.lastIndex=-1}if(r===null)return null;const n=r[2],i=r[3]||"0",s=r[4]||"0",a=t.includePrerelease&&r[5]?`-${r[5]}`:"",l=t.includePrerelease&&r[6]?`+${r[6]}`:"";return Jp(`${n}.${i}.${s}${a}${l}`,t)};var Zp=Gp;class Kp{constructor(){this.max=1e3,this.map=new Map}get(t){const r=this.map.get(t);if(r!==void 0)return this.map.delete(t),this.map.set(t,r),r}delete(t){return this.map.delete(t)}set(t,r){if(!this.delete(t)&&r!==void 0){if(this.map.size>=this.max){const i=this.map.keys().next().value;this.delete(i)}this.map.set(t,r)}return this}}var Qp=Kp,Ms,La;function wt(){if(La)return Ms;La=1;const e=/\s+/g;class t{constructor(u,f){if(f=i(f),u instanceof t)return u.loose===!!f.loose&&u.includePrerelease===!!f.includePrerelease?u:new t(u.raw,f);if(u instanceof s)return this.raw=u.value,this.set=[[u]],this.formatted=void 0,this;if(this.options=f,this.loose=!!f.loose,this.includePrerelease=!!f.includePrerelease,this.raw=u.trim().replace(e," "),this.set=this.raw.split("||").map(p=>this.parseRange(p.trim())).filter(p=>p.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const p=this.set[0];if(this.set=this.set.filter(v=>!B(v[0])),this.set.length===0)this.set=[p];else if(this.set.length>1){for(const v of this.set)if(v.length===1&&O(v[0])){this.set=[v];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let u=0;u0&&(this.formatted+="||");const f=this.set[u];for(let p=0;p0&&(this.formatted+=" "),this.formatted+=f[p].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(u){const p=((this.options.includePrerelease&&C)|(this.options.loose&&x))+":"+u,v=n.get(p);if(v)return v;const E=this.options.loose,k=E?d[h.HYPHENRANGELOOSE]:d[h.HYPHENRANGE];u=u.replace(k,ne(this.options.includePrerelease)),a("hyphen replace",u),u=u.replace(d[h.COMPARATORTRIM],m),a("comparator trim",u),u=u.replace(d[h.TILDETRIM],R),a("tilde trim",u),u=u.replace(d[h.CARETTRIM],y),a("caret trim",u);let g=u.split(" ").map(H=>T(H,this.options)).join(" ").split(/\s+/).map(H=>X(H,this.options));E&&(g=g.filter(H=>(a("loose invalid filter",H,this.options),!!H.match(d[h.COMPARATORLOOSE])))),a("range list",g);const c=new Map,w=g.map(H=>new s(H,this.options));for(const H of w){if(B(H))return[H];c.set(H.value,H)}c.size>1&&c.has("")&&c.delete("");const U=[...c.values()];return n.set(p,U),U}intersects(u,f){if(!(u instanceof t))throw new TypeError("a Range is required");return this.set.some(p=>M(p,f)&&u.set.some(v=>M(v,f)&&p.every(E=>v.every(k=>E.intersects(k,f)))))}test(u){if(!u)return!1;if(typeof u=="string")try{u=new l(u,this.options)}catch{return!1}for(let f=0;fo.value==="<0.0.0-0",O=o=>o.value==="",M=(o,u)=>{let f=!0;const p=o.slice();let v=p.pop();for(;f&&p.length;)f=p.every(E=>v.intersects(E,u)),v=p.pop();return f},T=(o,u)=>(a("comp",o,u),o=F(o,u),a("caret",o),o=D(o,u),a("tildes",o),o=te(o,u),a("xrange",o),o=z(o,u),a("stars",o),o),N=o=>!o||o.toLowerCase()==="x"||o==="*",D=(o,u)=>o.trim().split(/\s+/).map(f=>L(f,u)).join(" "),L=(o,u)=>{const f=u.loose?d[h.TILDELOOSE]:d[h.TILDE];return o.replace(f,(p,v,E,k,g)=>{a("tilde",o,p,v,E,k,g);let c;return N(v)?c="":N(E)?c=`>=${v}.0.0 <${+v+1}.0.0-0`:N(k)?c=`>=${v}.${E}.0 <${v}.${+E+1}.0-0`:g?(a("replaceTilde pr",g),c=`>=${v}.${E}.${k}-${g} <${v}.${+E+1}.0-0`):c=`>=${v}.${E}.${k} <${v}.${+E+1}.0-0`,a("tilde return",c),c})},F=(o,u)=>o.trim().split(/\s+/).map(f=>W(f,u)).join(" "),W=(o,u)=>{a("caret",o,u);const f=u.loose?d[h.CARETLOOSE]:d[h.CARET],p=u.includePrerelease?"-0":"";return o.replace(f,(v,E,k,g,c)=>{a("caret",o,v,E,k,g,c);let w;return N(E)?w="":N(k)?w=`>=${E}.0.0${p} <${+E+1}.0.0-0`:N(g)?E==="0"?w=`>=${E}.${k}.0${p} <${E}.${+k+1}.0-0`:w=`>=${E}.${k}.0${p} <${+E+1}.0.0-0`:c?(a("replaceCaret pr",c),E==="0"?k==="0"?w=`>=${E}.${k}.${g}-${c} <${E}.${k}.${+g+1}-0`:w=`>=${E}.${k}.${g}-${c} <${E}.${+k+1}.0-0`:w=`>=${E}.${k}.${g}-${c} <${+E+1}.0.0-0`):(a("no pr"),E==="0"?k==="0"?w=`>=${E}.${k}.${g}${p} <${E}.${k}.${+g+1}-0`:w=`>=${E}.${k}.${g}${p} <${E}.${+k+1}.0-0`:w=`>=${E}.${k}.${g} <${+E+1}.0.0-0`),a("caret return",w),w})},te=(o,u)=>(a("replaceXRanges",o,u),o.split(/\s+/).map(f=>Z(f,u)).join(" ")),Z=(o,u)=>{o=o.trim();const f=u.loose?d[h.XRANGELOOSE]:d[h.XRANGE];return o.replace(f,(p,v,E,k,g,c)=>{a("xRange",o,p,v,E,k,g,c);const w=N(E),U=w||N(k),H=U||N(g),V=H;return v==="="&&V&&(v=""),c=u.includePrerelease?"-0":"",w?v===">"||v==="<"?p="<0.0.0-0":p="*":v&&V?(U&&(k=0),g=0,v===">"?(v=">=",U?(E=+E+1,k=0,g=0):(k=+k+1,g=0)):v==="<="&&(v="<",U?E=+E+1:k=+k+1),v==="<"&&(c="-0"),p=`${v+E}.${k}.${g}${c}`):U?p=`>=${E}.0.0${c} <${+E+1}.0.0-0`:H&&(p=`>=${E}.${k}.0${c} <${E}.${+k+1}.0-0`),a("xRange return",p),p})},z=(o,u)=>(a("replaceStars",o,u),o.trim().replace(d[h.STAR],"")),X=(o,u)=>(a("replaceGTE0",o,u),o.trim().replace(d[u.includePrerelease?h.GTE0PRE:h.GTE0],"")),ne=o=>(u,f,p,v,E,k,g,c,w,U,H,V)=>(N(p)?f="":N(v)?f=`>=${p}.0.0${o?"-0":""}`:N(E)?f=`>=${p}.${v}.0${o?"-0":""}`:k?f=`>=${f}`:f=`>=${f}${o?"-0":""}`,N(w)?c="":N(U)?c=`<${+w+1}.0.0-0`:N(H)?c=`<${w}.${+U+1}.0-0`:V?c=`<=${w}.${U}.${H}-${V}`:o?c=`<${w}.${U}.${+H+1}-0`:c=`<=${c}`,`${f} ${c}`.trim()),S=(o,u,f)=>{for(let p=0;p0){const v=o[p].semver;if(v.major===u.major&&v.minor===u.minor&&v.patch===u.patch)return!0}return!1}return!0};return Ms}var ks,Oa;function Vi(){if(Oa)return ks;Oa=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(m,R){if(R=r(R),m instanceof t){if(m.loose===!!R.loose)return m;m=m.value}m=m.trim().split(/\s+/).join(" "),a("comparator",m,R),this.options=R,this.loose=!!R.loose,this.parse(m),this.semver===e?this.value="":this.value=this.operator+this.semver.version,a("comp",this)}parse(m){const R=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],y=m.match(R);if(!y)throw new TypeError(`Invalid comparator: ${m}`);this.operator=y[1]!==void 0?y[1]:"",this.operator==="="&&(this.operator=""),y[2]?this.semver=new l(y[2],this.options.loose):this.semver=e}toString(){return this.value}test(m){if(a("Comparator.test",m,this.options.loose),this.semver===e||m===e)return!0;if(typeof m=="string")try{m=new l(m,this.options)}catch{return!1}return s(m,this.operator,this.semver,this.options)}intersects(m,R){if(!(m instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new d(m.value,R).test(this.value):m.operator===""?m.value===""?!0:new d(this.value,R).test(m.semver):(R=r(R),R.includePrerelease&&(this.value==="<0.0.0-0"||m.value==="<0.0.0-0")||!R.includePrerelease&&(this.value.startsWith("<0.0.0")||m.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&m.operator.startsWith(">")||this.operator.startsWith("<")&&m.operator.startsWith("<")||this.semver.version===m.semver.version&&this.operator.includes("=")&&m.operator.includes("=")||s(this.semver,"<",m.semver,R)&&this.operator.startsWith(">")&&m.operator.startsWith("<")||s(this.semver,">",m.semver,R)&&this.operator.startsWith("<")&&m.operator.startsWith(">")))}}ks=t;const r=ho,{safeRe:n,t:i}=Pn,s=Ul,a=Ui,l=et,d=wt();return ks}const Yp=wt(),Xp=(e,t,r)=>{try{t=new Yp(t,r)}catch{return!1}return t.test(e)};var zi=Xp;const eg=wt(),tg=(e,t)=>new eg(e,t).set.map(r=>r.map(n=>n.value).join(" ").trim().split(" "));var rg=tg;const ng=et,ig=wt(),sg=(e,t,r)=>{let n=null,i=null,s=null;try{s=new ig(t,r)}catch{return null}return e.forEach(a=>{s.test(a)&&(!n||i.compare(a)===-1)&&(n=a,i=new ng(n,r))}),n};var og=sg;const ag=et,cg=wt(),lg=(e,t,r)=>{let n=null,i=null,s=null;try{s=new cg(t,r)}catch{return null}return e.forEach(a=>{s.test(a)&&(!n||i.compare(a)===1)&&(n=a,i=new ag(n,r))}),n};var ug=lg;const Cs=et,hg=wt(),Pa=Wi,dg=(e,t)=>{e=new hg(e,t);let r=new Cs("0.0.0");if(e.test(r)||(r=new Cs("0.0.0-0"),e.test(r)))return r;r=null;for(let n=0;n{const l=new Cs(a.semver.version);switch(a.operator){case">":l.prerelease.length===0?l.patch++:l.prerelease.push(0),l.raw=l.format();case"":case">=":(!s||Pa(l,s))&&(s=l);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${a.operator}`)}}),s&&(!r||Pa(r,s))&&(r=s)}return r&&e.test(r)?r:null};var fg=dg;const pg=wt(),gg=(e,t)=>{try{return new pg(e,t).range||"*"}catch{return null}};var mg=gg;const vg=et,Wl=Vi(),{ANY:bg}=Wl,wg=wt(),_g=zi,$a=Wi,Ba=po,yg=mo,Eg=go,Sg=(e,t,r,n)=>{e=new vg(e,n),t=new wg(t,n);let i,s,a,l,d;switch(r){case">":i=$a,s=yg,a=Ba,l=">",d=">=";break;case"<":i=Ba,s=Eg,a=$a,l="<",d="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(_g(e,t,n))return!1;for(let h=0;h{C.semver===bg&&(C=new Wl(">=0.0.0")),R=R||C,y=y||C,i(C.semver,R.semver,n)?R=C:a(C.semver,y.semver,n)&&(y=C)}),R.operator===l||R.operator===d||(!y.operator||y.operator===l)&&s(e,y.semver))return!1;if(y.operator===d&&a(e,y.semver))return!1}return!0};var vo=Sg;const Rg=vo,Mg=(e,t,r)=>Rg(e,t,">",r);var kg=Mg;const Cg=vo,Ig=(e,t,r)=>Cg(e,t,"<",r);var xg=Ig;const Da=wt(),Ag=(e,t,r)=>(e=new Da(e,r),t=new Da(t,r),e.intersects(t,r));var Tg=Ag;const Ng=zi,Lg=bt;var Og=(e,t,r)=>{const n=[];let i=null,s=null;const a=e.sort((m,R)=>Lg(m,R,r));for(const m of a)Ng(m,t,r)?(s=m,i||(i=m)):(s&&n.push([i,s]),s=null,i=null);i&&n.push([i,null]);const l=[];for(const[m,R]of n)m===R?l.push(m):!R&&m===a[0]?l.push("*"):R?m===a[0]?l.push(`<=${R}`):l.push(`${m} - ${R}`):l.push(`>=${m}`);const d=l.join(" || "),h=typeof t.raw=="string"?t.raw:String(t);return d.length{if(e===t)return!0;e=new Fa(e,r),t=new Fa(t,r);let n=!1;e:for(const i of e.set){for(const s of t.set){const a=Bg(i,s,r);if(n=n||a!==null,a)continue e}if(n)return!1}return!0},$g=[new bo(">=0.0.0-0")],ja=[new bo(">=0.0.0")],Bg=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===Is){if(t.length===1&&t[0].semver===Is)return!0;r.includePrerelease?e=$g:e=ja}if(t.length===1&&t[0].semver===Is){if(r.includePrerelease)return!0;t=ja}const n=new Set;let i,s;for(const C of e)C.operator===">"||C.operator===">="?i=Ha(i,C,r):C.operator==="<"||C.operator==="<="?s=Ua(s,C,r):n.add(C.semver);if(n.size>1)return null;let a;if(i&&s){if(a=wo(i.semver,s.semver,r),a>0)return null;if(a===0&&(i.operator!==">="||s.operator!=="<="))return null}for(const C of n){if(i&&!an(C,String(i),r)||s&&!an(C,String(s),r))return null;for(const x of t)if(!an(C,String(x),r))return!1;return!0}let l,d,h,m,R=s&&!r.includePrerelease&&s.semver.prerelease.length?s.semver:!1,y=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;R&&R.prerelease.length===1&&s.operator==="<"&&R.prerelease[0]===0&&(R=!1);for(const C of t){if(m=m||C.operator===">"||C.operator===">=",h=h||C.operator==="<"||C.operator==="<=",i){if(y&&C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===y.major&&C.semver.minor===y.minor&&C.semver.patch===y.patch&&(y=!1),C.operator===">"||C.operator===">="){if(l=Ha(i,C,r),l===C&&l!==i)return!1}else if(i.operator===">="&&!an(i.semver,String(C),r))return!1}if(s){if(R&&C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===R.major&&C.semver.minor===R.minor&&C.semver.patch===R.patch&&(R=!1),C.operator==="<"||C.operator==="<="){if(d=Ua(s,C,r),d===C&&d!==s)return!1}else if(s.operator==="<="&&!an(s.semver,String(C),r))return!1}if(!C.operator&&(s||i)&&a!==0)return!1}return!(i&&h&&!s&&a!==0||s&&m&&!i&&a!==0||y||R)},Ha=(e,t,r)=>{if(!e)return t;const n=wo(e.semver,t.semver,r);return n>0?e:n<0||t.operator===">"&&e.operator===">="?t:e},Ua=(e,t,r)=>{if(!e)return t;const n=wo(e.semver,t.semver,r);return n<0?e:n>0||t.operator==="<"&&e.operator==="<="?t:e};var Dg=Pg;const xs=Pn,Wa=Hi,Fg=et,Va=Fl,jg=sn,Hg=J1,Ug=K1,Wg=Y1,Vg=ep,zg=np,qg=op,Jg=lp,Gg=dp,Zg=bt,Kg=mp,Qg=wp,Yg=fo,Xg=Sp,em=kp,tm=Wi,rm=po,nm=jl,im=Hl,sm=go,om=mo,am=Ul,cm=Zp,lm=Vi(),um=wt(),hm=zi,dm=rg,fm=og,pm=ug,gm=fg,mm=mg,vm=vo,bm=kg,wm=xg,_m=Tg,ym=Og,Em=Dg;var Sm={parse:jg,valid:Hg,clean:Ug,inc:Wg,diff:Vg,major:zg,minor:qg,patch:Jg,prerelease:Gg,compare:Zg,rcompare:Kg,compareLoose:Qg,compareBuild:Yg,sort:Xg,rsort:em,gt:tm,lt:rm,eq:nm,neq:im,gte:sm,lte:om,cmp:am,coerce:cm,Comparator:lm,Range:um,satisfies:hm,toComparators:dm,maxSatisfying:fm,minSatisfying:pm,minVersion:gm,validRange:mm,outside:vm,gtr:bm,ltr:wm,intersects:_m,simplifyRange:ym,subset:Em,SemVer:Fg,re:xs.re,src:xs.src,tokens:xs.t,SEMVER_SPEC_VERSION:Wa.SEMVER_SPEC_VERSION,RELEASE_TYPES:Wa.RELEASE_TYPES,compareIdentifiers:Va.compareIdentifiers,rcompareIdentifiers:Va.rcompareIdentifiers};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.satisfiesVersionRange=e.gtRange=e.gtVersion=e.assertIsSemVerRange=e.assertIsSemVerVersion=e.isValidSemVerRange=e.isValidSemVerVersion=e.VersionRangeStruct=e.VersionStruct=void 0;const t=Sm,r=br,n=Ke;e.VersionStruct=(0,r.refine)((0,r.string)(),"Version",R=>(0,t.valid)(R)===null?`Expected SemVer version, got "${R}"`:!0),e.VersionRangeStruct=(0,r.refine)((0,r.string)(),"Version range",R=>(0,t.validRange)(R)===null?`Expected SemVer range, got "${R}"`:!0);function i(R){return(0,r.is)(R,e.VersionStruct)}e.isValidSemVerVersion=i;function s(R){return(0,r.is)(R,e.VersionRangeStruct)}e.isValidSemVerRange=s;function a(R){(0,n.assertStruct)(R,e.VersionStruct)}e.assertIsSemVerVersion=a;function l(R){(0,n.assertStruct)(R,e.VersionRangeStruct)}e.assertIsSemVerRange=l;function d(R,y){return(0,t.gt)(R,y)}e.gtVersion=d;function h(R,y){return(0,t.gtr)(R,y)}e.gtRange=h;function m(R,y){return(0,t.satisfies)(R,y,{includePrerelease:!0})}e.satisfiesVersionRange=m})($l);(function(e){var t=Q&&Q.__createBinding||(Object.create?function(n,i,s,a){a===void 0&&(a=s);var l=Object.getOwnPropertyDescriptor(i,s);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,a,l)}:function(n,i,s,a){a===void 0&&(a=s),n[a]=i[s]}),r=Q&&Q.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&t(i,n,s)};Object.defineProperty(e,"__esModule",{value:!0}),r(Ke,e),r(Ln,e),r(ae,e),r(Fi,e),r(Ct,e),r(Jr,e),r(xl,e),r(On,e),r(Al,e),r(Tl,e),r(Gr,e),r(Nl,e),r(It,e),r(Ll,e),r(Ol,e),r(Pl,e),r($l,e)})(ul);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createModuleLogger=e.projectLogger=void 0;const t=ul;Object.defineProperty(e,"createModuleLogger",{enumerable:!0,get:function(){return t.createModuleLogger}}),e.projectLogger=(0,t.createProjectLogger)("eth-block-tracker")})(ll);var Vl=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Bi,"__esModule",{value:!0});Bi.PollingBlockTracker=void 0;const Rm=Vl(ro),Mm=Vl(Xf),km=xn,za=ll,qa=(0,za.createModuleLogger)(za.projectLogger,"polling-block-tracker"),Cm=(0,Rm.default)(),Im=1e3;class xm extends km.BaseBlockTracker{constructor(t={}){var r;if(!t.provider)throw new Error("PollingBlockTracker - no provider specified.");super(Object.assign(Object.assign({},t),{blockResetDuration:(r=t.blockResetDuration)!==null&&r!==void 0?r:t.pollingInterval})),this._provider=t.provider,this._pollingInterval=t.pollingInterval||20*Im,this._retryTimeout=t.retryTimeout||this._pollingInterval/10,this._keepEventLoopActive=t.keepEventLoopActive===void 0?!0:t.keepEventLoopActive,this._setSkipCacheFlag=t.setSkipCacheFlag||!1}async checkForLatestBlock(){return await this._updateLatestBlock(),await this.getLatestBlock()}async _start(){this._synchronize()}async _end(){}async _synchronize(){for(var t;this._isRunning;)try{await this._updateLatestBlock();const r=Ja(this._pollingInterval,!this._keepEventLoopActive);this.emit("_waitingForNextIteration"),await r}catch(r){const n=new Error(`PollingBlockTracker - encountered an error while attempting to update latest block: ${(t=r.stack)!==null&&t!==void 0?t:r}`);try{this.emit("error",n)}catch{console.error(n)}const i=Ja(this._retryTimeout,!this._keepEventLoopActive);this.emit("_waitingForNextIteration"),await i}}async _updateLatestBlock(){const t=await this._fetchLatestBlock();this._newPotentialLatest(t)}async _fetchLatestBlock(){const t={jsonrpc:"2.0",id:Cm(),method:"eth_blockNumber",params:[]};this._setSkipCacheFlag&&(t.skipCache=!0),qa("Making request",t);const r=await(0,Mm.default)(n=>this._provider.sendAsync(t,n))();if(qa("Got response",r),r.error)throw new Error(`PollingBlockTracker - encountered error fetching block: ${r.error.message}`);return r.result}}Bi.PollingBlockTracker=xm;function Ja(e,t){return new Promise(r=>{const n=setTimeout(r,e);n.unref&&t&&n.unref()})}var qi={},Am=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qi,"__esModule",{value:!0});qi.SubscribeBlockTracker=void 0;const Tm=Am(ro),Nm=xn,Lm=(0,Tm.default)();class Om extends Nm.BaseBlockTracker{constructor(t={}){if(!t.provider)throw new Error("SubscribeBlockTracker - no provider specified.");super(t),this._provider=t.provider,this._subscriptionId=null}async checkForLatestBlock(){return await this.getLatestBlock()}async _start(){if(this._subscriptionId===void 0||this._subscriptionId===null)try{const t=await this._call("eth_blockNumber");this._subscriptionId=await this._call("eth_subscribe","newHeads"),this._provider.on("data",this._handleSubData.bind(this)),this._newPotentialLatest(t)}catch(t){this.emit("error",t)}}async _end(){if(this._subscriptionId!==null&&this._subscriptionId!==void 0)try{await this._call("eth_unsubscribe",this._subscriptionId),this._subscriptionId=null}catch(t){this.emit("error",t)}}_call(t,...r){return new Promise((n,i)=>{this._provider.sendAsync({id:Lm(),method:t,params:r,jsonrpc:"2.0"},(s,a)=>{s?i(s):n(a.result)})})}_handleSubData(t,r){var n;r.method==="eth_subscription"&&((n=r.params)===null||n===void 0?void 0:n.subscription)===this._subscriptionId&&this._newPotentialLatest(r.params.result.number)}}qi.SubscribeBlockTracker=Om;(function(e){var t=Q&&Q.__createBinding||(Object.create?function(n,i,s,a){a===void 0&&(a=s),Object.defineProperty(n,a,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,a){a===void 0&&(a=s),n[a]=i[s]}),r=Q&&Q.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&t(i,n,s)};Object.defineProperty(e,"__esModule",{value:!0}),r(Bi,e),r(qi,e)})(cl);var _o={},Ji={},$n={};Object.defineProperty($n,"__esModule",{value:!0});$n.getUniqueId=void 0;const zl=4294967295;let As=Math.floor(Math.random()*zl);function Pm(){return As=(As+1)%zl,As}$n.getUniqueId=Pm;Object.defineProperty(Ji,"__esModule",{value:!0});Ji.createIdRemapMiddleware=void 0;const $m=$n;function Bm(){return(e,t,r,n)=>{const i=e.id,s=$m.getUniqueId();e.id=s,t.id=s,r(a=>{e.id=i,t.id=i,a()})}}Ji.createIdRemapMiddleware=Bm;var Gi={};Object.defineProperty(Gi,"__esModule",{value:!0});Gi.createAsyncMiddleware=void 0;function Dm(e){return async(t,r,n,i)=>{let s;const a=new Promise(m=>{s=m});let l=null,d=!1;const h=async()=>{d=!0,n(m=>{l=m,s()}),await a};try{await e(t,r,h),d?(await a,l(null)):i(null)}catch(m){l?l(m):i(m)}}}Gi.createAsyncMiddleware=Dm;var Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});Zi.createScaffoldMiddleware=void 0;function Fm(e){return(t,r,n,i)=>{const s=e[t.method];return s===void 0?n():typeof s=="function"?s(t,r,n,i):(r.result=s,i())}}Zi.createScaffoldMiddleware=Fm;var Bn={},yo={};Object.defineProperty(yo,"__esModule",{value:!0});const jm=si;function Ga(e,t,r){try{Reflect.apply(e,t,r)}catch(n){setTimeout(()=>{throw n})}}function Hm(e){const t=e.length,r=new Array(t);for(let n=0;n0&&([a]=r),a instanceof Error)throw a;const l=new Error(`Unhandled error.${a?` (${a.message})`:""}`);throw l.context=a,l}const s=i[t];if(s===void 0)return!1;if(typeof s=="function")Ga(s,this,r);else{const a=s.length,l=Hm(s);for(let d=0;d"u"&&(n=Gl()),Hs(e,"",0,[],void 0,0,n);var i;try{ur.length===0?i=JSON.stringify(e,t,r):i=JSON.stringify(e,Kl(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;fr.length!==0;){var s=fr.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function Hr(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),fr.push([n,r,t,i])):ur.push([t,r,e]):(n[r]=e,fr.push([n,r,t]))}function Hs(e,t,r,n,i,s,a){s+=1;var l;if(typeof e=="object"&&e!==null){for(l=0;la.depthLimit){Hr(ri,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){Hr(ri,e,t,i);return}if(n.push(e),Array.isArray(e))for(l=0;lt?1:0}function Zl(e,t,r,n){typeof n>"u"&&(n=Gl());var i=Us(e,"",0,[],void 0,0,n)||e,s;try{ur.length===0?s=JSON.stringify(i,t,r):s=JSON.stringify(i,Kl(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;fr.length!==0;){var a=fr.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return s}function Us(e,t,r,n,i,s,a){s+=1;var l;if(typeof e=="object"&&e!==null){for(l=0;la.depthLimit){Hr(ri,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){Hr(ri,e,t,i);return}if(n.push(e),Array.isArray(e))for(l=0;l0)for(var n=0;n=1e3&&e<=4999}function Gm(e,t){if(t!=="[Circular]")return t}var Eo={},Ft={};Object.defineProperty(Ft,"__esModule",{value:!0});Ft.errorValues=Ft.errorCodes=void 0;Ft.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};Ft.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=Ft,r=Dt,n=t.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",s={code:n,message:a(n)};e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function a(y,C=i){if(Number.isInteger(y)){const x=y.toString();if(R(t.errorValues,x))return t.errorValues[x].message;if(h(y))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return C}e.getMessageFromCode=a;function l(y){if(!Number.isInteger(y))return!1;const C=y.toString();return!!(t.errorValues[C]||h(y))}e.isValidCode=l;function d(y,{fallbackError:C=s,shouldIncludeStack:x=!1}={}){var B,O;if(!C||!Number.isInteger(C.code)||typeof C.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(y instanceof r.EthereumRpcError)return y.serialize();const M={};if(y&&typeof y=="object"&&!Array.isArray(y)&&R(y,"code")&&l(y.code)){const N=y;M.code=N.code,N.message&&typeof N.message=="string"?(M.message=N.message,R(N,"data")&&(M.data=N.data)):(M.message=a(M.code),M.data={originalError:m(y)})}else{M.code=C.code;const N=(B=y)===null||B===void 0?void 0:B.message;M.message=N&&typeof N=="string"?N:C.message,M.data={originalError:m(y)}}const T=(O=y)===null||O===void 0?void 0:O.stack;return x&&y&&T&&typeof T=="string"&&(M.stack=T),M}e.serializeError=d;function h(y){return y>=-32099&&y<=-32e3}function m(y){return y&&typeof y=="object"&&!Array.isArray(y)?Object.assign({},y):y}function R(y,C){return Object.prototype.hasOwnProperty.call(y,C)}})(Eo);var Ki={};Object.defineProperty(Ki,"__esModule",{value:!0});Ki.ethErrors=void 0;const So=Dt,Yl=Eo,Qe=Ft;Ki.ethErrors={rpc:{parse:e=>lt(Qe.errorCodes.rpc.parse,e),invalidRequest:e=>lt(Qe.errorCodes.rpc.invalidRequest,e),invalidParams:e=>lt(Qe.errorCodes.rpc.invalidParams,e),methodNotFound:e=>lt(Qe.errorCodes.rpc.methodNotFound,e),internal:e=>lt(Qe.errorCodes.rpc.internal,e),server:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return lt(t,e)},invalidInput:e=>lt(Qe.errorCodes.rpc.invalidInput,e),resourceNotFound:e=>lt(Qe.errorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>lt(Qe.errorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>lt(Qe.errorCodes.rpc.transactionRejected,e),methodNotSupported:e=>lt(Qe.errorCodes.rpc.methodNotSupported,e),limitExceeded:e=>lt(Qe.errorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>cn(Qe.errorCodes.provider.userRejectedRequest,e),unauthorized:e=>cn(Qe.errorCodes.provider.unauthorized,e),unsupportedMethod:e=>cn(Qe.errorCodes.provider.unsupportedMethod,e),disconnected:e=>cn(Qe.errorCodes.provider.disconnected,e),chainDisconnected:e=>cn(Qe.errorCodes.provider.chainDisconnected,e),custom:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:r,data:n}=e;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new So.EthereumProviderError(t,r,n)}}};function lt(e,t){const[r,n]=Xl(t);return new So.EthereumRpcError(e,r||Yl.getMessageFromCode(e),n)}function cn(e,t){const[r,n]=Xl(t);return new So.EthereumProviderError(e,r||Yl.getMessageFromCode(e),n)}function Xl(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:r}=e;if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,r]}}return[]}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMessageFromCode=e.serializeError=e.EthereumProviderError=e.EthereumRpcError=e.ethErrors=e.errorCodes=void 0;const t=Dt;Object.defineProperty(e,"EthereumRpcError",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,"EthereumProviderError",{enumerable:!0,get:function(){return t.EthereumProviderError}});const r=Eo;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});const n=Ki;Object.defineProperty(e,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});const i=Ft;Object.defineProperty(e,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})})(ql);var Zm=Q&&Q.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Bn,"__esModule",{value:!0});Bn.JsonRpcEngine=void 0;const Km=Zm(yo),ut=ql;class At extends Km.default{constructor(){super(),this._middleware=[]}push(t){this._middleware.push(t)}handle(t,r){if(r&&typeof r!="function")throw new Error('"callback" must be a function if provided.');return Array.isArray(t)?r?this._handleBatch(t,r):this._handleBatch(t):r?this._handle(t,r):this._promiseHandle(t)}asMiddleware(){return async(t,r,n,i)=>{try{const[s,a,l]=await At._runAllMiddleware(t,r,this._middleware);return a?(await At._runReturnHandlers(l),i(s)):n(async d=>{try{await At._runReturnHandlers(l)}catch(h){return d(h)}return d()})}catch(s){return i(s)}}}async _handleBatch(t,r){try{const n=await Promise.all(t.map(this._promiseHandle.bind(this)));return r?r(null,n):n}catch(n){if(r)return r(n);throw n}}_promiseHandle(t){return new Promise(r=>{this._handle(t,(n,i)=>{r(i)})})}async _handle(t,r){if(!t||Array.isArray(t)||typeof t!="object"){const a=new ut.EthereumRpcError(ut.errorCodes.rpc.invalidRequest,`Requests must be plain objects. Received: ${typeof t}`,{request:t});return r(a,{id:void 0,jsonrpc:"2.0",error:a})}if(typeof t.method!="string"){const a=new ut.EthereumRpcError(ut.errorCodes.rpc.invalidRequest,`Must specify a string method. Received: ${typeof t.method}`,{request:t});return r(a,{id:t.id,jsonrpc:"2.0",error:a})}const n=Object.assign({},t),i={id:n.id,jsonrpc:n.jsonrpc};let s=null;try{await this._processRequest(n,i)}catch(a){s=a}return s&&(delete i.result,i.error||(i.error=ut.serializeError(s))),r(s,i)}async _processRequest(t,r){const[n,i,s]=await At._runAllMiddleware(t,r,this._middleware);if(At._checkForCompletion(t,r,i),await At._runReturnHandlers(s),n)throw n}static async _runAllMiddleware(t,r,n){const i=[];let s=null,a=!1;for(const l of n)if([s,a]=await At._runMiddleware(t,r,l,i),a)break;return[s,a,i.reverse()]}static _runMiddleware(t,r,n,i){return new Promise(s=>{const a=d=>{const h=d||r.error;h&&(r.error=ut.serializeError(h)),s([h,!0])},l=d=>{r.error?a(r.error):(d&&(typeof d!="function"&&a(new ut.EthereumRpcError(ut.errorCodes.rpc.internal,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof d}" for request: diff --git a/buddybook/assets/index-xz6stGwY.js b/buddybook/assets/index-BhnqxX7Q.js similarity index 99% rename from buddybook/assets/index-xz6stGwY.js rename to buddybook/assets/index-BhnqxX7Q.js index 00f9b67..b952d3e 100644 --- a/buddybook/assets/index-xz6stGwY.js +++ b/buddybook/assets/index-BhnqxX7Q.js @@ -1,3 +1,3 @@ -import{j as rt,l as at,m as ot,o as ct,E as dt}from"./index-uonIXzgQ.js";import{B as Y,_ as h,h as ae,y as lt}from"./hooks.module-D0gf0yJl.js";const ht=(t,e)=>{let s;switch(t){case"standard":return s=e,`data:image/svg+xml,%3Csvg width='${e}' height='${s}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return s=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${s}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return s=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return s=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return s=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return s=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return s=e,`data:image/svg+xml,%3Csvg width='${e}' height='${s}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};class v{constructor(e,s){this.scope=e,this.module=s}storeObject(e,s){this.setItem(e,JSON.stringify(s))}loadObject(e){const s=this.getItem(e);return s?JSON.parse(s):void 0}setItem(e,s){localStorage.setItem(this.scopedKey(e),s)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),s=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new v("CBWSDK").clear(),new v("walletlink").clear()}}const u={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},J={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},Ie="Unspecified error message.",ut="Unspecified server error.";function te(t,e=Ie){if(t&&Number.isInteger(t)){const s=t.toString();if(Q(J,s))return J[s].message;if(Se(t))return ut}return e}function pt(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!(J[e]||Se(t))}function ft(t,{shouldIncludeStack:e=!1}={}){const s={};if(t&&typeof t=="object"&&!Array.isArray(t)&&Q(t,"code")&&pt(t.code)){const n=t;s.code=n.code,n.message&&typeof n.message=="string"?(s.message=n.message,Q(n,"data")&&(s.data=n.data)):(s.message=te(s.code),s.data={originalError:oe(t)})}else s.code=u.rpc.internal,s.message=ce(t,"message")?t.message:Ie,s.data={originalError:oe(t)};return e&&(s.stack=ce(t,"stack")?t.stack:void 0),s}function Se(t){return t>=-32099&&t<=-32e3}function oe(t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.assign({},t):t}function Q(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function ce(t,e){return typeof t=="object"&&t!==null&&e in t&&typeof t[e]=="string"}const l={rpc:{parse:t=>b(u.rpc.parse,t),invalidRequest:t=>b(u.rpc.invalidRequest,t),invalidParams:t=>b(u.rpc.invalidParams,t),methodNotFound:t=>b(u.rpc.methodNotFound,t),internal:t=>b(u.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return b(e,t)},invalidInput:t=>b(u.rpc.invalidInput,t),resourceNotFound:t=>b(u.rpc.resourceNotFound,t),resourceUnavailable:t=>b(u.rpc.resourceUnavailable,t),transactionRejected:t=>b(u.rpc.transactionRejected,t),methodNotSupported:t=>b(u.rpc.methodNotSupported,t),limitExceeded:t=>b(u.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>P(u.provider.userRejectedRequest,t),unauthorized:t=>P(u.provider.unauthorized,t),unsupportedMethod:t=>P(u.provider.unsupportedMethod,t),disconnected:t=>P(u.provider.disconnected,t),chainDisconnected:t=>P(u.provider.chainDisconnected,t),unsupportedChain:t=>P(u.provider.unsupportedChain,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:s,data:n}=t;if(!s||typeof s!="string")throw new Error('"message" must be a nonempty string');return new Ae(e,s,n)}}};function b(t,e){const[s,n]=Me(e);return new xe(t,s||te(t),n)}function P(t,e){const[s,n]=Me(e);return new Ae(t,s||te(t),n)}function Me(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:s}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,s]}}return[]}class xe extends Error{constructor(e,s,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!s||typeof s!="string")throw new Error('"message" must be a nonempty string.');super(s),this.code=e,n!==void 0&&(this.data=n)}}class Ae extends xe{constructor(e,s,n){if(!gt(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,s,n)}}function gt(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}function se(){return t=>t}const B=se(),mt=se(),wt=se();function I(t){return Math.floor(t)}const _e=/^[0-9]*$/,Le=/^[a-f0-9]*$/;function _(t){return ne(crypto.getRandomValues(new Uint8Array(t)))}function ne(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function H(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function O(t,e=!1){const s=t.toString("hex");return B(e?`0x${s}`:s)}function z(t){return O(X(t),!0)}function k(t){return wt(t.toString(10))}function A(t){return B(`0x${BigInt(t).toString(16)}`)}function Pe(t){return t.startsWith("0x")||t.startsWith("0X")}function ie(t){return Pe(t)?t.slice(2):t}function Re(t){return Pe(t)?`0x${t.slice(2)}`:`0x${t}`}function K(t){if(typeof t!="string")return!1;const e=ie(t).toLowerCase();return Le.test(e)}function bt(t,e=!1){if(typeof t=="string"){const s=ie(t).toLowerCase();if(Le.test(s))return B(e?`0x${s}`:s)}throw l.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}function re(t,e=!1){let s=bt(t,!1);return s.length%2===1&&(s=B(`0${s}`)),e?B(`0x${s}`):s}function x(t){if(typeof t=="string"){const e=ie(t).toLowerCase();if(K(e)&&e.length===40)return mt(Re(e))}throw l.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}function X(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(K(t)){const e=re(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw l.rpc.invalidParams(`Not binary data: ${String(t)}`)}function j(t){if(typeof t=="number"&&Number.isInteger(t))return I(t);if(typeof t=="string"){if(_e.test(t))return I(Number(t));if(K(t))return I(Number(BigInt(re(t,!0))))}throw l.rpc.invalidParams(`Not an integer: ${String(t)}`)}function D(t){if(t!==null&&(typeof t=="bigint"||vt(t)))return BigInt(t.toString(10));if(typeof t=="number")return BigInt(j(t));if(typeof t=="string"){if(_e.test(t))return BigInt(t);if(K(t))return BigInt(re(t,!0))}throw l.rpc.invalidParams(`Not an integer: ${String(t)}`)}function yt(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw l.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}function vt(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}function kt(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:s}=document.location,n=t?t.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?`${e}//${s}/favicon.ico`:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${s}${n}`}async function Et(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function Ct(t,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function It(t,e){const s=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:s},t,new TextEncoder().encode(e));return{iv:s,cipherText:n}}async function St(t,{iv:e,cipherText:s}){const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,s);return new TextDecoder().decode(n)}function Ne(t){switch(t){case"public":return"spki";case"private":return"pkcs8"}}async function Te(t,e){const s=Ne(t),n=await crypto.subtle.exportKey(s,e);return ne(new Uint8Array(n))}async function De(t,e){const s=Ne(t),n=H(e).buffer;return await crypto.subtle.importKey(s,new Uint8Array(n),{name:"ECDH",namedCurve:"P-256"},!0,t==="private"?["deriveKey"]:[])}async function Mt(t,e){const s=JSON.stringify(t,(n,i)=>{if(!(i instanceof Error))return i;const r=i;return Object.assign(Object.assign({},r.code?{code:r.code}:{}),{message:r.message})});return It(e,s)}async function xt(t,e){return JSON.parse(await St(e,t))}const Z={storageKey:"ownPrivateKey",keyType:"private"},F={storageKey:"ownPublicKey",keyType:"public"},$={storageKey:"peerPublicKey",keyType:"public"};class At{constructor(){this.storage=new v("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey($,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(F.storageKey),this.storage.removeItem(Z.storageKey),this.storage.removeItem($.storageKey)}async generateKeyPair(){const e=await Et();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(Z,e.privateKey),await this.storeKey(F,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Z)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(F)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey($)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await Ct(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const s=this.storage.getItem(e.storageKey);return s?De(e.keyType,s):null}async storeKey(e,s){const n=await Te(e.keyType,s);this.storage.setItem(e.storageKey,n)}}const T="4.2.1",Oe="@coinbase/wallet-sdk";async function je(t,e){const s=Object.assign(Object.assign({},t),{jsonrpc:"2.0",id:crypto.randomUUID()}),n=await window.fetch(e,{method:"POST",body:JSON.stringify(s),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":T,"X-Cbw-Sdk-Platform":Oe}}),{result:i,error:r}=await n.json();if(r)throw r;return i}function _t(){return globalThis.coinbaseWalletExtension}function Lt(){var t,e;try{const s=globalThis;return(t=s.ethereum)!==null&&t!==void 0?t:(e=s.top)===null||e===void 0?void 0:e.ethereum}catch{return}}function Ue({metadata:t,preference:e}){var s,n;const{appName:i,appLogoUrl:r,appChainIds:a}=t;if(e.options!=="smartWalletOnly"){const c=_t();if(c)return(s=c.setAppInfo)===null||s===void 0||s.call(c,i,r,a,e),c}const o=Lt();if(o!=null&&o.isCoinbaseBrowser)return(n=o.setAppInfo)===null||n===void 0||n.call(o,i,r,a,e),o}function Pt(t){if(!t||typeof t!="object"||Array.isArray(t))throw l.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:t});const{method:e,params:s}=t;if(typeof e!="string"||e.length===0)throw l.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:t});if(s!==void 0&&!Array.isArray(s)&&(typeof s!="object"||s===null))throw l.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:t});switch(e){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw l.provider.unsupportedMethod()}}const de="accounts",le="activeChain",he="availableChains",ue="walletCapabilities";class Rt{constructor(e){var s,n,i;this.metadata=e.metadata,this.communicator=e.communicator,this.callback=e.callback,this.keyManager=new At,this.storage=new v("CBWSDK","SCWStateManager"),this.accounts=(s=this.storage.loadObject(de))!==null&&s!==void 0?s:[],this.chain=this.storage.loadObject(le)||{id:(i=(n=e.metadata.appChainIds)===null||n===void 0?void 0:n[0])!==null&&i!==void 0?i:1},this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(e){var s,n;const i=await this.createRequestMessage({handshake:{method:e.method,params:Object.assign({},this.metadata,(s=e.params)!==null&&s!==void 0?s:{})}}),r=await this.communicator.postRequestAndWaitForResponse(i);if("failure"in r.content)throw r.content.failure;const a=await De("public",r.sender);await this.keyManager.setPeerPublicKey(a);const c=(await this.decryptResponseMessage(r)).result;if("error"in c)throw c.error;const d=c.value;this.accounts=d,this.storage.storeObject(de,d),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",d)}async request(e){var s;if(this.accounts.length===0)throw l.provider.unauthorized();switch(e.method){case"eth_requestAccounts":return(s=this.callback)===null||s===void 0||s.call(this,"connect",{chainId:A(this.chain.id)}),this.accounts;case"eth_accounts":return this.accounts;case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return A(this.chain.id);case"wallet_getCapabilities":return this.storage.loadObject(ue);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(e);case"eth_ecRecover":case"personal_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(e);default:if(!this.chain.rpcUrl)throw l.rpc.internal("No RPC URL set for chain");return je(e,this.chain.rpcUrl)}}async sendRequestToPopup(e){var s,n;await((n=(s=this.communicator).waitForPopupLoaded)===null||n===void 0?void 0:n.call(s));const i=await this.sendEncryptedRequest(e),a=(await this.decryptResponseMessage(i)).result;if("error"in a)throw a.error;return a.value}async cleanup(){var e,s;this.storage.clear(),await this.keyManager.clear(),this.accounts=[],this.chain={id:(s=(e=this.metadata.appChainIds)===null||e===void 0?void 0:e[0])!==null&&s!==void 0?s:1}}async handleSwitchChainRequest(e){var s;const n=e.params;if(!n||!(!((s=n[0])===null||s===void 0)&&s.chainId))throw l.rpc.invalidParams();const i=j(n[0].chainId);if(this.updateChain(i))return null;const a=await this.sendRequestToPopup(e);return a===null&&this.updateChain(i),a}async sendEncryptedRequest(e){const s=await this.keyManager.getSharedSecret();if(!s)throw l.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await Mt({action:e,chainId:this.chain.id},s),i=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(i)}async createRequestMessage(e){const s=await Te("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:s,content:e,timestamp:new Date}}async decryptResponseMessage(e){var s,n;const i=e.content;if("failure"in i)throw i.failure;const r=await this.keyManager.getSharedSecret();if(!r)throw l.provider.unauthorized("Invalid session");const a=await xt(i.encrypted,r),o=(s=a.data)===null||s===void 0?void 0:s.chains;if(o){const d=Object.entries(o).map(([g,p])=>({id:Number(g),rpcUrl:p}));this.storage.storeObject(he,d),this.updateChain(this.chain.id,d)}const c=(n=a.data)===null||n===void 0?void 0:n.capabilities;return c&&this.storage.storeObject(ue,c),a}updateChain(e,s){var n;const i=s??this.storage.loadObject(he),r=i==null?void 0:i.find(a=>a.id===e);return r?(r!==this.chain&&(this.chain=r,this.storage.storeObject(le,r),(n=this.callback)===null||n===void 0||n.call(this,"chainChanged",A(r.id))),!0):!1}}const Nt=rt(at),{keccak_256:Tt}=Nt;function We(t){return Buffer.allocUnsafe(t).fill(0)}function Dt(t){return t.toString(2).length}function Be(t,e){let s=t.toString(16);s.length%2!==0&&(s="0"+s);const n=s.match(/.{1,2}/g).map(i=>parseInt(i,16));for(;n.length"u")throw new Error("Not an array?");if(s=Ze(t),s!=="dynamic"&&s!==0&&e.length>s)throw new Error("Elements exceed array size: "+s);i=[],t=t.slice(0,t.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(r in e)i.push(E(t,e[r]));if(s==="dynamic"){var a=E("uint256",e.length);i.unshift(a)}return Buffer.concat(i)}else{if(t==="bytes")return e=new Buffer(e),i=Buffer.concat([E("uint256",e.length),e]),e.length%32!==0&&(i=Buffer.concat([i,w.zeros(32-e.length%32)])),i;if(t.startsWith("bytes")){if(s=R(t),s<1||s>32)throw new Error("Invalid bytes width: "+s);return w.setLengthRight(e,32)}else if(t.startsWith("uint")){if(s=R(t),s%8||s<8||s>256)throw new Error("Invalid uint width: "+s);n=L(e);const o=w.bitLengthFromBigInt(n);if(o>s)throw new Error("Supplied uint exceeds width: "+s+" vs "+o);if(n<0)throw new Error("Supplied uint is negative");return w.bufferBEFromBigInt(n,32)}else if(t.startsWith("int")){if(s=R(t),s%8||s<8||s>256)throw new Error("Invalid int width: "+s);n=L(e);const o=w.bitLengthFromBigInt(n);if(o>s)throw new Error("Supplied int exceeds width: "+s+" vs "+o);const c=w.twosFromBigInt(n,256);return w.bufferBEFromBigInt(c,32)}else if(t.startsWith("ufixed")){if(s=pe(t),n=L(e),n<0)throw new Error("Supplied ufixed is negative");return E("uint256",n*BigInt(2)**BigInt(s[1]))}else if(t.startsWith("fixed"))return s=pe(t),E("int256",L(e)*BigInt(2)**BigInt(s[1]))}throw new Error("Unsupported or invalid type: "+t)}function qt(t){return t==="string"||t==="bytes"||Ze(t)==="dynamic"}function Ht(t){return t.lastIndexOf("]")===t.length-1}function Kt(t,e){var s=[],n=[],i=32*t.length;for(var r in t){var a=ze(t[r]),o=e[r],c=E(a,o);qt(a)?(s.push(E("uint256",i)),n.push(c),i+=c.length):s.push(c)}return Buffer.concat(s.concat(n))}function Fe(t,e){if(t.length!==e.length)throw new Error("Number of types are not matching the values");for(var s,n,i=[],r=0;r32)throw new Error("Invalid bytes width: "+s);i.push(w.setLengthRight(o,s))}else if(a.startsWith("uint")){if(s=R(a),s%8||s<8||s>256)throw new Error("Invalid uint width: "+s);n=L(o);const c=w.bitLengthFromBigInt(n);if(c>s)throw new Error("Supplied uint exceeds width: "+s+" vs "+c);i.push(w.bufferBEFromBigInt(n,s/8))}else if(a.startsWith("int")){if(s=R(a),s%8||s<8||s>256)throw new Error("Invalid int width: "+s);n=L(o);const c=w.bitLengthFromBigInt(n);if(c>s)throw new Error("Supplied int exceeds width: "+s+" vs "+c);const d=w.twosFromBigInt(n,s);i.push(w.bufferBEFromBigInt(d,s/8))}else throw new Error("Unsupported or invalid type: "+a)}return Buffer.concat(i)}function Vt(t,e){return w.keccak(Fe(t,e))}var zt={rawEncode:Kt,solidityPack:Fe,soliditySHA3:Vt};const y=Ve,U=zt,$e={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},G={encodeData(t,e,s,n=!0){const i=["bytes32"],r=[this.hashType(t,s)];if(n){const a=(o,c,d)=>{if(s[c]!==void 0)return["bytes32",d==null?"0x0000000000000000000000000000000000000000000000000000000000000000":y.keccak(this.encodeData(c,d,s,n))];if(d===void 0)throw new Error(`missing value for field ${o} of type ${c}`);if(c==="bytes")return["bytes32",y.keccak(d)];if(c==="string")return typeof d=="string"&&(d=Buffer.from(d,"utf8")),["bytes32",y.keccak(d)];if(c.lastIndexOf("]")===c.length-1){const g=c.slice(0,c.lastIndexOf("[")),p=d.map(f=>a(o,g,f));return["bytes32",y.keccak(U.rawEncode(p.map(([f])=>f),p.map(([,f])=>f)))]}return[c,d]};for(const o of s[t]){const[c,d]=a(o.name,o.type,e[o.name]);i.push(c),r.push(d)}}else for(const a of s[t]){let o=e[a.name];if(o!==void 0)if(a.type==="bytes")i.push("bytes32"),o=y.keccak(o),r.push(o);else if(a.type==="string")i.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=y.keccak(o),r.push(o);else if(s[a.type]!==void 0)i.push("bytes32"),o=y.keccak(this.encodeData(a.type,o,s,n)),r.push(o);else{if(a.type.lastIndexOf("]")===a.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(a.type),r.push(o)}}return U.rawEncode(i,r)},encodeType(t,e){let s="",n=this.findTypeDependencies(t,e).filter(i=>i!==t);n=[t].concat(n.sort());for(const i of n){if(!e[i])throw new Error("No type definition specified: "+i);s+=i+"("+e[i].map(({name:a,type:o})=>o+" "+a).join(",")+")"}return s},findTypeDependencies(t,e,s=[]){if(t=t.match(/^\w*/)[0],s.includes(t)||e[t]===void 0)return s;s.push(t);for(const n of e[t])for(const i of this.findTypeDependencies(n.type,e,s))!s.includes(i)&&s.push(i);return s},hashStruct(t,e,s,n=!0){return y.keccak(this.encodeData(t,e,s,n))},hashType(t,e){return y.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const s in $e.properties)t[s]&&(e[s]=t[s]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,e=!0){const s=this.sanitizeData(t),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",s.domain,s.types,e)),s.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(s.primaryType,s.message,s.types,e)),y.keccak(Buffer.concat(n))}};var q={TYPED_MESSAGE_SCHEMA:$e,TypedDataUtils:G,hashForSignTypedDataLegacy:function(t){return Zt(t.data)},hashForSignTypedData_v3:function(t){return G.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return G.hash(t.data)}};function Zt(t){const e=new Error("Expect argument to be non-empty array");if(typeof t!="object"||!t.length)throw e;const s=t.map(function(r){return r.type==="bytes"?y.toBuffer(r.value):r.value}),n=t.map(function(r){return r.type}),i=t.map(function(r){if(!r.name)throw e;return r.type+" "+r.name});return U.soliditySHA3(["bytes32","bytes32"],[U.soliditySHA3(new Array(t.length).fill("string"),i),U.soliditySHA3(n,s)])}const Ft="walletUsername",ee="Addresses",$t="AppVersion";function m(t){return t.errorMessage!==void 0}class Gt{constructor(e){this.secret=e}async encrypt(e){const s=this.secret;if(s.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",H(s),{name:"aes-gcm"},!1,["encrypt","decrypt"]),r=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,r.encode(e)),o=16,c=a.slice(a.byteLength-o),d=a.slice(0,a.byteLength-o),g=new Uint8Array(c),p=new Uint8Array(d),f=new Uint8Array([...n,...g,...p]);return ne(f)}async decrypt(e){const s=this.secret;if(s.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const r=await crypto.subtle.importKey("raw",H(s),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=H(e),o=a.slice(0,12),c=a.slice(12,28),d=a.slice(28),g=new Uint8Array([...d,...c]),p={name:"AES-GCM",iv:new Uint8Array(o)};try{const f=await window.crypto.subtle.decrypt(p,r,g),C=new TextDecoder;n(C.decode(f))}catch(f){i(f)}})()})}}class Yt{constructor(e,s,n){this.linkAPIUrl=e,this.sessionId=s;const i=`${s}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(s=>fetch(`${this.linkAPIUrl}/events/${s.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(s=>console.error("Unabled to mark event as failed:",s))}async fetchUnseenEvents(){var e;const s=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(s.ok){const{events:n,error:i}=await s.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const r=(e=n==null?void 0:n.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(r),r}throw new Error(`Check unseen events failed: ${s.status}`)}}var M;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(M||(M={}));class Jt{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,s=WebSocket){this.WebSocketClass=s,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,s)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(r){s(r);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,M.CONNECTING),i.onclose=r=>{var a;this.clearWebSocket(),s(new Error(`websocket error ${r.code}: ${r.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,M.DISCONNECTED)},i.onopen=r=>{var a;e(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,M.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(c=>this.sendData(c)),this.pendingData=[])},i.onmessage=r=>{var a,o;if(r.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(r.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var e;const{webSocket:s}=this;if(s){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,M.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{s.close()}catch{}}}sendData(e){const{webSocket:s}=this;if(!s){this.pendingData.push(e),this.connect();return}s.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}const fe=1e4,Qt=6e4;class Xt{constructor({session:e,linkAPIUrl:s,listener:n}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=I(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=r=>{if(!r)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",o=>r.JsonRpcUrl&&this.handleChainUpdated(o,r.JsonRpcUrl)]]).forEach((o,c)=>{const d=r[c];d!==void 0&&o(d)})},this.handleDestroyed=r=>{var a;r==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async r=>{var a;const o=await this.cipher.decrypt(r);(a=this.listener)===null||a===void 0||a.accountUpdated(o)},this.handleMetadataUpdated=async(r,a)=>{var o;const c=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.metadataUpdated(r,c)},this.handleWalletUsernameUpdated=async r=>{this.handleMetadataUpdated(Ft,r)},this.handleAppVersionUpdated=async r=>{this.handleMetadataUpdated($t,r)},this.handleChainUpdated=async(r,a)=>{var o;const c=await this.cipher.decrypt(r),d=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.chainUpdated(c,d)},this.session=e,this.cipher=new Gt(e.secret),this.listener=n;const i=new Jt(`${s}/rpc`,WebSocket);i.setConnectionStateListener(async r=>{let a=!1;switch(r){case M.DISCONNECTED:if(!this.destroyed){const o=async()=>{await new Promise(c=>setTimeout(c,5e3)),this.destroyed||i.connect().catch(()=>{o()})};o()}break;case M.CONNECTED:a=await this.handleConnected(),this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},fe),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case M.CONNECTING:break}this.connected!==a&&(this.connected=a)}),i.setIncomingDataListener(r=>{var a;switch(r.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const o=r.type==="IsLinkedOK"?r.linked:void 0;this.linked=o||r.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(r.metadata);break}case"Event":{this.handleIncomingEvent(r);break}}r.id!==void 0&&((a=this.requestResolutions.get(r.id))===null||a===void 0||a(r))}),this.ws=i,this.http=new Yt(s,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:I(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.ws.disconnect(),this.listener=void 0)}get connected(){return this._connected}set connected(e){this._connected=e}get linked(){return this._linked}set linked(e){var s,n;this._linked=e,e&&((s=this.onceLinked)===null||s===void 0||s.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(s=>{this.linked?e().then(s):this.onceLinked=()=>{e().then(s),this.onceLinked=void 0}})}async handleIncomingEvent(e){var s;if(e.type!=="Event"||e.event!=="Web3Response")return;const n=await this.cipher.decrypt(e.data),i=JSON.parse(n);if(i.type!=="WEB3_RESPONSE")return;const{id:r,response:a}=i;(s=this.listener)===null||s===void 0||s.handleWeb3ResponseMessage(r,a)}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(s=>this.handleIncomingEvent(s))}async publishEvent(e,s,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},s),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),r={type:"PublishEvent",id:I(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const a=await this.makeRequest(r);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>fe*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,s={timeout:Qt}){const n=e.id;this.sendData(e);let i;return Promise.race([new Promise((r,a)=>{i=window.setTimeout(()=>{a(new Error(`request ${n} timed out`))},s.timeout)}),new Promise(r=>{this.requestResolutions.set(n,a=>{clearTimeout(i),r(a),this.requestResolutions.delete(n)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:I(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:I(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:I(this.nextReqId++),sessionId:this.session.id}),!0)}}class es{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,s=Re(e.toString(16));return this.callbacks.get(s)&&this.callbacks.delete(s),e}}const ge="session:id",me="session:secret",we="session:linked";class N{constructor(e,s,n,i=!1){this.storage=e,this.id=s,this.secret=n,this.key=ot(ct(`${s}, ${n} WalletLink`)),this._linked=!!i}static create(e){const s=_(16),n=_(32);return new N(e,s,n).save()}static load(e){const s=e.getItem(ge),n=e.getItem(we),i=e.getItem(me);return s&&i?new N(e,s,i,n==="1"):null}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this.storage.setItem(ge,this.id),this.storage.setItem(me,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(we,this._linked?"1":"0")}}function ts(){try{return window.frameElement!==null}catch{return!1}}function ss(){try{return ts()&&window.top?window.top.location:window.location}catch{return window.location}}function ns(){var t;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t=window==null?void 0:window.navigator)===null||t===void 0?void 0:t.userAgent)}function Ge(){var t,e;return(e=(t=window==null?void 0:window.matchMedia)===null||t===void 0?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}const is='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';function Ye(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(is)),document.documentElement.appendChild(t)}function Je(t){var e,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e{this.items.delete(s),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&Y(h("div",null,h(Qe,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,s])=>h(ds,Object.assign({},s,{key:e}))))),this.root)}}const Qe=t=>h("div",{class:W("-cbwsdk-snackbar-container")},h("style",null,rs),h("div",{class:"-cbwsdk-snackbar"},t.children)),ds=({autoExpand:t,message:e,menuItems:s})=>{const[n,i]=ae(!0),[r,a]=ae(t??!1);lt(()=>{const c=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{a(!0)},1e4)];return()=>{c.forEach(window.clearTimeout)}});const o=()=>{a(!r)};return h("div",{class:W("-cbwsdk-snackbar-instance",n&&"-cbwsdk-snackbar-instance-hidden",r&&"-cbwsdk-snackbar-instance-expanded")},h("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},h("img",{src:as,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",h("div",{class:"-cbwsdk-snackbar-instance-header-message"},e),h("div",{class:"-gear-container"},!r&&h("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),h("img",{src:os,class:"-gear-icon",title:"Expand"}))),s&&s.length>0&&h("div",{class:"-cbwsdk-snackbar-instance-menu"},s.map((c,d)=>h("div",{class:W("-cbwsdk-snackbar-instance-menu-item",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:c.onClick,key:d},h("svg",{width:c.svgWidth,height:c.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("path",{"fill-rule":c.defaultFillRule,"clip-rule":c.defaultClipRule,d:c.path,fill:"#AAAAAA"})),h("span",{class:W("-cbwsdk-snackbar-instance-menu-item-info",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},c.info)))))};class ls{constructor(){this.attached=!1,this.snackbar=new cs}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,s=document.createElement("div");s.className="-cbwsdk-css-reset",e.appendChild(s),this.snackbar.attach(s),this.attached=!0,Ye()}showConnecting(e){let s;return e.isUnlinkedErrorState?s={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:s={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(s)}}const hs=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class us{constructor(){this.root=null,this.darkMode=Ge()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),Ye()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&(Y(null,this.root),e&&Y(h(ps,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const ps=({title:t,buttonText:e,darkMode:s,onButtonClick:n,onDismiss:i})=>{const r=s?"dark":"light";return h(Qe,{darkMode:s},h("div",{class:"-cbwsdk-redirect-dialog"},h("style",null,hs),h("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),h("div",{class:W("-cbwsdk-redirect-dialog-box",r)},h("p",null,t),h("button",{onClick:n},e))))},fs="https://keys.coinbase.com/connect",be="https://www.walletlink.org",gs="https://go.cb-w.com/walletlink";class ye{constructor(){this.attached=!1,this.redirectDialog=new us}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const s=new URL(gs);s.searchParams.append("redirect_url",ss().href),e&&s.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=s.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}class S{constructor(e){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=ns(),this.linkedUpdated=r=>{this.isLinked=r;const a=this.storage.getItem(ee);if(r&&(this._session.linked=r),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!r&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(r,a)=>{this.storage.setItem(r,a)},this.chainUpdated=(r,a)=>{this.chainCallbackParams.chainId===r&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:r,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(a,Number.parseInt(r,10)))},this.accountUpdated=r=>{this.accountsCallback&&this.accountsCallback([r]),S.accountRequestCallbackIds.size>0&&(Array.from(S.accountRequestCallbackIds.values()).forEach(a=>{this.invokeCallback(a,{method:"requestEthereumAccounts",result:[r]})}),S.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage,this.metadata=e.metadata,this.accountsCallback=e.accountsCallback,this.chainCallback=e.chainCallback;const{session:s,ui:n,connection:i}=this.subscribe();this._session=s,this.connection=i,this.relayEventManager=new es,this.ui=n,this.ui.attach()}subscribe(){const e=N.load(this.storage)||N.create(this.storage),{linkAPIUrl:s}=this,n=new Xt({session:e,linkAPIUrl:s,listener:this}),i=this.isMobileWeb?new ye:new ls;return n.connect(),{session:e,ui:i,connection:n}}resetAndReload(){this.connection.destroy().then(()=>{const e=N.load(this.storage);(e==null?void 0:e.id)===this._session.id&&v.clearAll(),document.location.reload()}).catch(e=>{})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:k(e.weiValue),data:O(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?k(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?k(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?k(e.gasPriceInWei):null,gasLimit:e.gasLimit?k(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:k(e.weiValue),data:O(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?k(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?k(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?k(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?k(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,s){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:O(e,!0),chainId:s}})}getWalletLinkSession(){return this._session}sendRequest(e){let s=null;const n=_(8),i=r=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,r),s==null||s()};return new Promise((r,a)=>{s=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,o=>{if(s==null||s(),m(o))return a(new Error(o.errorMessage));r(o)}),this.publishWeb3RequestEvent(n,e)})}publishWeb3RequestEvent(e,s){const n={type:"WEB3_REQUEST",id:e,request:s};this.publishEvent("Web3Request",n,!0).then(i=>{}).catch(i=>{this.handleWeb3ResponseMessage(n.id,{method:s.method,errorMessage:i.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(s.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof ye)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const s={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",s,!1).then()}publishEvent(e,s,n){return this.connection.publishEvent(e,s,n)}handleWeb3ResponseMessage(e,s){if(s.method==="requestEthereumAccounts"){S.accountRequestCallbackIds.forEach(n=>this.invokeCallback(n,s)),S.accountRequestCallbackIds.clear();return}this.invokeCallback(e,s)}handleErrorResponse(e,s,n){var i;const r=(i=n==null?void 0:n.message)!==null&&i!==void 0?i:"Unspecified error message.";this.handleWeb3ResponseMessage(e,{method:s,errorMessage:r})}invokeCallback(e,s){const n=this.relayEventManager.callbacks.get(e);n&&(n(s),this.relayEventManager.callbacks.delete(e))}requestEthereumAccounts(){const{appName:e,appLogoUrl:s}=this.metadata,n={method:"requestEthereumAccounts",params:{appName:e,appLogoUrl:s}},i=_(8);return new Promise((r,a)=>{this.relayEventManager.callbacks.set(i,o=>{if(m(o))return a(new Error(o.errorMessage));r(o)}),S.accountRequestCallbackIds.add(i),this.publishWeb3RequestEvent(i,n)})}watchAsset(e,s,n,i,r,a){const o={method:"watchAsset",params:{type:e,options:{address:s,symbol:n,decimals:i,image:r},chainId:a}};let c=null;const d=_(8),g=p=>{this.publishWeb3RequestCanceledEvent(d),this.handleErrorResponse(d,o.method,p),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:g,onResetConnection:this.resetAndReload}),new Promise((p,f)=>{this.relayEventManager.callbacks.set(d,C=>{if(c==null||c(),m(C))return f(new Error(C.errorMessage));p(C)}),this.publishWeb3RequestEvent(d,o)})}addEthereumChain(e,s,n,i,r,a){const o={method:"addEthereumChain",params:{chainId:e,rpcUrls:s,blockExplorerUrls:i,chainName:r,iconUrls:n,nativeCurrency:a}};let c=null;const d=_(8),g=p=>{this.publishWeb3RequestCanceledEvent(d),this.handleErrorResponse(d,o.method,p),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:g,onResetConnection:this.resetAndReload}),new Promise((p,f)=>{this.relayEventManager.callbacks.set(d,C=>{if(c==null||c(),m(C))return f(new Error(C.errorMessage));p(C)}),this.publishWeb3RequestEvent(d,o)})}switchEthereumChain(e,s){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:s})};let i=null;const r=_(8),a=o=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,n.method,o),i==null||i()};return i=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:a,onResetConnection:this.resetAndReload}),new Promise((o,c)=>{this.relayEventManager.callbacks.set(r,d=>{if(i==null||i(),m(d)&&d.errorCode)return c(l.provider.custom({code:d.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(m(d))return c(new Error(d.errorMessage));o(d)}),this.publishWeb3RequestEvent(r,n)})}}S.accountRequestCallbackIds=new Set;const ve="DefaultChainId",ke="DefaultJsonRpcUrl";class Xe{constructor(e){this._relay=null,this._addresses=[],this.metadata=e.metadata,this._storage=new v("walletlink",be),this.callback=e.callback||null;const s=this._storage.getItem(ee);if(s){const n=s.split(" ");n[0]!==""&&(this._addresses=n.map(i=>x(i)))}this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:s,secret:n}=e.getWalletLinkSession();return{id:s,secret:n}}async handshake(){await this._eth_requestAccounts()}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(ke))!==null&&e!==void 0?e:void 0}set jsonRpcUrl(e){this._storage.setItem(ke,e)}updateProviderInfo(e,s){var n;this.jsonRpcUrl=e;const i=this.getChainId();this._storage.setItem(ve,s.toString(10)),j(s)!==i&&((n=this.callback)===null||n===void 0||n.call(this,"chainChanged",A(s)))}async watchAsset(e){const s=Array.isArray(e)?e[0]:e;if(!s.type)throw l.rpc.invalidParams("Type is required");if((s==null?void 0:s.type)!=="ERC20")throw l.rpc.invalidParams(`Asset of type '${s.type}' is not supported`);if(!(s!=null&&s.options))throw l.rpc.invalidParams("Options are required");if(!(s!=null&&s.options.address))throw l.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:i,symbol:r,image:a,decimals:o}=s.options,d=await this.initializeRelay().watchAsset(s.type,i,r,o,a,n==null?void 0:n.toString());return m(d)?!1:!!d.result}async addEthereumChain(e){var s,n;const i=e[0];if(((s=i.rpcUrls)===null||s===void 0?void 0:s.length)===0)throw l.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!i.chainName||i.chainName.trim()==="")throw l.rpc.invalidParams("chainName is a required field");if(!i.nativeCurrency)throw l.rpc.invalidParams("nativeCurrency is a required field");const r=Number.parseInt(i.chainId,16);if(r===this.getChainId())return!1;const a=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:c=[],chainName:d,iconUrls:g=[],nativeCurrency:p}=i,f=await a.addEthereumChain(r.toString(),o,g,c,d,p);if(m(f))return!1;if(((n=f.result)===null||n===void 0?void 0:n.isApproved)===!0)return this.updateProviderInfo(o[0],r),null;throw l.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(e){const s=e[0],n=Number.parseInt(s.chainId,16),r=await this.initializeRelay().switchEthereumChain(n.toString(10),this.selectedAddress||void 0);if(m(r))throw r;const a=r.result;return a.isApproved&&a.rpcUrl.length>0&&this.updateProviderInfo(a.rpcUrl,n),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(e,s){var n;if(!Array.isArray(e))throw new Error("addresses is not an array");const i=e.map(r=>x(r));JSON.stringify(i)!==JSON.stringify(this._addresses)&&(this._addresses=i,(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",i),this._storage.setItem(ee,i.join(" ")))}async request(e){const s=e.params||[];switch(e.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return A(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(e);case"personal_sign":return this.personalSign(e);case"eth_signTransaction":return this._eth_signTransaction(s);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(s);case"eth_sendTransaction":return this._eth_sendTransaction(s);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(e);case"wallet_addEthereumChain":return this.addEthereumChain(s);case"wallet_switchEthereumChain":return this.switchEthereumChain(s);case"wallet_watchAsset":return this.watchAsset(s);default:if(!this.jsonRpcUrl)throw l.rpc.internal("No RPC URL set for chain");return je(e,this.jsonRpcUrl)}}_ensureKnownAddress(e){const s=x(e);if(!this._addresses.map(i=>x(i)).includes(s))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const s=e.from?x(e.from):this.selectedAddress;if(!s)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(s);const n=e.to?x(e.to):null,i=e.value!=null?D(e.value):BigInt(0),r=e.data?X(e.data):Buffer.alloc(0),a=e.nonce!=null?j(e.nonce):null,o=e.gasPrice!=null?D(e.gasPrice):null,c=e.maxFeePerGas!=null?D(e.maxFeePerGas):null,d=e.maxPriorityFeePerGas!=null?D(e.maxPriorityFeePerGas):null,g=e.gas!=null?D(e.gas):null,p=e.chainId?j(e.chainId):this.getChainId();return{fromAddress:s,toAddress:n,weiValue:i,data:r,nonce:a,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:d,gasLimit:g,chainId:p}}async ecRecover(e){const{method:s,params:n}=e;if(!Array.isArray(n))throw l.rpc.invalidParams();const r=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:z(n[0]),signature:z(n[1]),addPrefix:s==="personal_ecRecover"}});if(m(r))throw r;return r.result}getChainId(){var e;return Number.parseInt((e=this._storage.getItem(ve))!==null&&e!==void 0?e:"1",10)}async _eth_requestAccounts(){var e,s;if(this._addresses.length>0)return(e=this.callback)===null||e===void 0||e.call(this,"connect",{chainId:A(this.getChainId())}),this._addresses;const i=await this.initializeRelay().requestEthereumAccounts();if(m(i))throw i;if(!i.result)throw new Error("accounts received is empty");return this._setAddresses(i.result),(s=this.callback)===null||s===void 0||s.call(this,"connect",{chainId:A(this.getChainId())}),this._addresses}async personalSign({params:e}){if(!Array.isArray(e))throw l.rpc.invalidParams();const s=e[1],n=e[0];this._ensureKnownAddress(s);const r=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:x(s),message:z(n),addPrefix:!0,typedDataJson:null}});if(m(r))throw r;return r.result}async _eth_signTransaction(e){const s=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signEthereumTransaction(s);if(m(i))throw i;return i.result}async _eth_sendRawTransaction(e){const s=X(e[0]),i=await this.initializeRelay().submitEthereumTransaction(s,this.getChainId());if(m(i))throw i;return i.result}async _eth_sendTransaction(e){const s=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signAndSubmitEthereumTransaction(s);if(m(i))throw i;return i.result}async signTypedData(e){const{method:s,params:n}=e;if(!Array.isArray(n))throw l.rpc.invalidParams();const i=d=>{const g={eth_signTypedData_v1:q.hashForSignTypedDataLegacy,eth_signTypedData_v3:q.hashForSignTypedData_v3,eth_signTypedData_v4:q.hashForSignTypedData_v4,eth_signTypedData:q.hashForSignTypedData_v4};return O(g[s]({data:yt(d)}),!0)},r=n[s==="eth_signTypedData_v1"?1:0],a=n[s==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(r);const c=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:x(r),message:i(a),typedDataJson:JSON.stringify(a,null,2),addPrefix:!1}});if(m(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new S({linkAPIUrl:be,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const et="SignerType",tt=new v("CBWSDK","SignerConfigurator");function ms(){return tt.getItem(et)}function ws(t){tt.setItem(et,t)}async function bs(t){const{communicator:e,metadata:s,handshakeRequest:n,callback:i}=t;vs(e,s,i).catch(()=>{});const r={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},t.preference),{handshakeRequest:n})},{data:a}=await e.postRequestAndWaitForResponse(r);return a}function ys(t){const{signerType:e,metadata:s,communicator:n,callback:i}=t;switch(e){case"scw":return new Rt({metadata:s,callback:i,communicator:n});case"walletlink":return new Xe({metadata:s,callback:i})}}async function vs(t,e,s){await t.onMessage(({event:i})=>i==="WalletLinkSessionRequest");const n=new Xe({metadata:e,callback:s});t.postMessage({event:"WalletLinkUpdate",data:{session:n.getSession()}}),await n.handshake(),t.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}const ks=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app. +import{j as rt,l as at,m as ot,o as ct,E as dt}from"./index-BpI4vT-j.js";import{B as Y,_ as h,h as ae,y as lt}from"./hooks.module-D0gf0yJl.js";const ht=(t,e)=>{let s;switch(t){case"standard":return s=e,`data:image/svg+xml,%3Csvg width='${e}' height='${s}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return s=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${s}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return s=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return s=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return s=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return s=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${s}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return s=e,`data:image/svg+xml,%3Csvg width='${e}' height='${s}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};class v{constructor(e,s){this.scope=e,this.module=s}storeObject(e,s){this.setItem(e,JSON.stringify(s))}loadObject(e){const s=this.getItem(e);return s?JSON.parse(s):void 0}setItem(e,s){localStorage.setItem(this.scopedKey(e),s)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),s=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new v("CBWSDK").clear(),new v("walletlink").clear()}}const u={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},J={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},Ie="Unspecified error message.",ut="Unspecified server error.";function te(t,e=Ie){if(t&&Number.isInteger(t)){const s=t.toString();if(Q(J,s))return J[s].message;if(Se(t))return ut}return e}function pt(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!(J[e]||Se(t))}function ft(t,{shouldIncludeStack:e=!1}={}){const s={};if(t&&typeof t=="object"&&!Array.isArray(t)&&Q(t,"code")&&pt(t.code)){const n=t;s.code=n.code,n.message&&typeof n.message=="string"?(s.message=n.message,Q(n,"data")&&(s.data=n.data)):(s.message=te(s.code),s.data={originalError:oe(t)})}else s.code=u.rpc.internal,s.message=ce(t,"message")?t.message:Ie,s.data={originalError:oe(t)};return e&&(s.stack=ce(t,"stack")?t.stack:void 0),s}function Se(t){return t>=-32099&&t<=-32e3}function oe(t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.assign({},t):t}function Q(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function ce(t,e){return typeof t=="object"&&t!==null&&e in t&&typeof t[e]=="string"}const l={rpc:{parse:t=>b(u.rpc.parse,t),invalidRequest:t=>b(u.rpc.invalidRequest,t),invalidParams:t=>b(u.rpc.invalidParams,t),methodNotFound:t=>b(u.rpc.methodNotFound,t),internal:t=>b(u.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return b(e,t)},invalidInput:t=>b(u.rpc.invalidInput,t),resourceNotFound:t=>b(u.rpc.resourceNotFound,t),resourceUnavailable:t=>b(u.rpc.resourceUnavailable,t),transactionRejected:t=>b(u.rpc.transactionRejected,t),methodNotSupported:t=>b(u.rpc.methodNotSupported,t),limitExceeded:t=>b(u.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>P(u.provider.userRejectedRequest,t),unauthorized:t=>P(u.provider.unauthorized,t),unsupportedMethod:t=>P(u.provider.unsupportedMethod,t),disconnected:t=>P(u.provider.disconnected,t),chainDisconnected:t=>P(u.provider.chainDisconnected,t),unsupportedChain:t=>P(u.provider.unsupportedChain,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:s,data:n}=t;if(!s||typeof s!="string")throw new Error('"message" must be a nonempty string');return new Ae(e,s,n)}}};function b(t,e){const[s,n]=Me(e);return new xe(t,s||te(t),n)}function P(t,e){const[s,n]=Me(e);return new Ae(t,s||te(t),n)}function Me(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:s}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,s]}}return[]}class xe extends Error{constructor(e,s,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!s||typeof s!="string")throw new Error('"message" must be a nonempty string.');super(s),this.code=e,n!==void 0&&(this.data=n)}}class Ae extends xe{constructor(e,s,n){if(!gt(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,s,n)}}function gt(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}function se(){return t=>t}const B=se(),mt=se(),wt=se();function I(t){return Math.floor(t)}const _e=/^[0-9]*$/,Le=/^[a-f0-9]*$/;function _(t){return ne(crypto.getRandomValues(new Uint8Array(t)))}function ne(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function H(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function O(t,e=!1){const s=t.toString("hex");return B(e?`0x${s}`:s)}function z(t){return O(X(t),!0)}function k(t){return wt(t.toString(10))}function A(t){return B(`0x${BigInt(t).toString(16)}`)}function Pe(t){return t.startsWith("0x")||t.startsWith("0X")}function ie(t){return Pe(t)?t.slice(2):t}function Re(t){return Pe(t)?`0x${t.slice(2)}`:`0x${t}`}function K(t){if(typeof t!="string")return!1;const e=ie(t).toLowerCase();return Le.test(e)}function bt(t,e=!1){if(typeof t=="string"){const s=ie(t).toLowerCase();if(Le.test(s))return B(e?`0x${s}`:s)}throw l.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}function re(t,e=!1){let s=bt(t,!1);return s.length%2===1&&(s=B(`0${s}`)),e?B(`0x${s}`):s}function x(t){if(typeof t=="string"){const e=ie(t).toLowerCase();if(K(e)&&e.length===40)return mt(Re(e))}throw l.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}function X(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(K(t)){const e=re(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw l.rpc.invalidParams(`Not binary data: ${String(t)}`)}function j(t){if(typeof t=="number"&&Number.isInteger(t))return I(t);if(typeof t=="string"){if(_e.test(t))return I(Number(t));if(K(t))return I(Number(BigInt(re(t,!0))))}throw l.rpc.invalidParams(`Not an integer: ${String(t)}`)}function D(t){if(t!==null&&(typeof t=="bigint"||vt(t)))return BigInt(t.toString(10));if(typeof t=="number")return BigInt(j(t));if(typeof t=="string"){if(_e.test(t))return BigInt(t);if(K(t))return BigInt(re(t,!0))}throw l.rpc.invalidParams(`Not an integer: ${String(t)}`)}function yt(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw l.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}function vt(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}function kt(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:s}=document.location,n=t?t.getAttribute("href"):null;return!n||n.startsWith("javascript:")||n.startsWith("vbscript:")?`${e}//${s}/favicon.ico`:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("data:")?n:n.startsWith("//")?e+n:`${e}//${s}${n}`}async function Et(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function Ct(t,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function It(t,e){const s=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:s},t,new TextEncoder().encode(e));return{iv:s,cipherText:n}}async function St(t,{iv:e,cipherText:s}){const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,s);return new TextDecoder().decode(n)}function Ne(t){switch(t){case"public":return"spki";case"private":return"pkcs8"}}async function Te(t,e){const s=Ne(t),n=await crypto.subtle.exportKey(s,e);return ne(new Uint8Array(n))}async function De(t,e){const s=Ne(t),n=H(e).buffer;return await crypto.subtle.importKey(s,new Uint8Array(n),{name:"ECDH",namedCurve:"P-256"},!0,t==="private"?["deriveKey"]:[])}async function Mt(t,e){const s=JSON.stringify(t,(n,i)=>{if(!(i instanceof Error))return i;const r=i;return Object.assign(Object.assign({},r.code?{code:r.code}:{}),{message:r.message})});return It(e,s)}async function xt(t,e){return JSON.parse(await St(e,t))}const Z={storageKey:"ownPrivateKey",keyType:"private"},F={storageKey:"ownPublicKey",keyType:"public"},$={storageKey:"peerPublicKey",keyType:"public"};class At{constructor(){this.storage=new v("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey($,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(F.storageKey),this.storage.removeItem(Z.storageKey),this.storage.removeItem($.storageKey)}async generateKeyPair(){const e=await Et();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(Z,e.privateKey),await this.storeKey(F,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Z)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(F)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey($)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await Ct(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const s=this.storage.getItem(e.storageKey);return s?De(e.keyType,s):null}async storeKey(e,s){const n=await Te(e.keyType,s);this.storage.setItem(e.storageKey,n)}}const T="4.2.1",Oe="@coinbase/wallet-sdk";async function je(t,e){const s=Object.assign(Object.assign({},t),{jsonrpc:"2.0",id:crypto.randomUUID()}),n=await window.fetch(e,{method:"POST",body:JSON.stringify(s),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":T,"X-Cbw-Sdk-Platform":Oe}}),{result:i,error:r}=await n.json();if(r)throw r;return i}function _t(){return globalThis.coinbaseWalletExtension}function Lt(){var t,e;try{const s=globalThis;return(t=s.ethereum)!==null&&t!==void 0?t:(e=s.top)===null||e===void 0?void 0:e.ethereum}catch{return}}function Ue({metadata:t,preference:e}){var s,n;const{appName:i,appLogoUrl:r,appChainIds:a}=t;if(e.options!=="smartWalletOnly"){const c=_t();if(c)return(s=c.setAppInfo)===null||s===void 0||s.call(c,i,r,a,e),c}const o=Lt();if(o!=null&&o.isCoinbaseBrowser)return(n=o.setAppInfo)===null||n===void 0||n.call(o,i,r,a,e),o}function Pt(t){if(!t||typeof t!="object"||Array.isArray(t))throw l.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:t});const{method:e,params:s}=t;if(typeof e!="string"||e.length===0)throw l.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:t});if(s!==void 0&&!Array.isArray(s)&&(typeof s!="object"||s===null))throw l.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:t});switch(e){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw l.provider.unsupportedMethod()}}const de="accounts",le="activeChain",he="availableChains",ue="walletCapabilities";class Rt{constructor(e){var s,n,i;this.metadata=e.metadata,this.communicator=e.communicator,this.callback=e.callback,this.keyManager=new At,this.storage=new v("CBWSDK","SCWStateManager"),this.accounts=(s=this.storage.loadObject(de))!==null&&s!==void 0?s:[],this.chain=this.storage.loadObject(le)||{id:(i=(n=e.metadata.appChainIds)===null||n===void 0?void 0:n[0])!==null&&i!==void 0?i:1},this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(e){var s,n;const i=await this.createRequestMessage({handshake:{method:e.method,params:Object.assign({},this.metadata,(s=e.params)!==null&&s!==void 0?s:{})}}),r=await this.communicator.postRequestAndWaitForResponse(i);if("failure"in r.content)throw r.content.failure;const a=await De("public",r.sender);await this.keyManager.setPeerPublicKey(a);const c=(await this.decryptResponseMessage(r)).result;if("error"in c)throw c.error;const d=c.value;this.accounts=d,this.storage.storeObject(de,d),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",d)}async request(e){var s;if(this.accounts.length===0)throw l.provider.unauthorized();switch(e.method){case"eth_requestAccounts":return(s=this.callback)===null||s===void 0||s.call(this,"connect",{chainId:A(this.chain.id)}),this.accounts;case"eth_accounts":return this.accounts;case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return A(this.chain.id);case"wallet_getCapabilities":return this.storage.loadObject(ue);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(e);case"eth_ecRecover":case"personal_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(e);default:if(!this.chain.rpcUrl)throw l.rpc.internal("No RPC URL set for chain");return je(e,this.chain.rpcUrl)}}async sendRequestToPopup(e){var s,n;await((n=(s=this.communicator).waitForPopupLoaded)===null||n===void 0?void 0:n.call(s));const i=await this.sendEncryptedRequest(e),a=(await this.decryptResponseMessage(i)).result;if("error"in a)throw a.error;return a.value}async cleanup(){var e,s;this.storage.clear(),await this.keyManager.clear(),this.accounts=[],this.chain={id:(s=(e=this.metadata.appChainIds)===null||e===void 0?void 0:e[0])!==null&&s!==void 0?s:1}}async handleSwitchChainRequest(e){var s;const n=e.params;if(!n||!(!((s=n[0])===null||s===void 0)&&s.chainId))throw l.rpc.invalidParams();const i=j(n[0].chainId);if(this.updateChain(i))return null;const a=await this.sendRequestToPopup(e);return a===null&&this.updateChain(i),a}async sendEncryptedRequest(e){const s=await this.keyManager.getSharedSecret();if(!s)throw l.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await Mt({action:e,chainId:this.chain.id},s),i=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(i)}async createRequestMessage(e){const s=await Te("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:s,content:e,timestamp:new Date}}async decryptResponseMessage(e){var s,n;const i=e.content;if("failure"in i)throw i.failure;const r=await this.keyManager.getSharedSecret();if(!r)throw l.provider.unauthorized("Invalid session");const a=await xt(i.encrypted,r),o=(s=a.data)===null||s===void 0?void 0:s.chains;if(o){const d=Object.entries(o).map(([g,p])=>({id:Number(g),rpcUrl:p}));this.storage.storeObject(he,d),this.updateChain(this.chain.id,d)}const c=(n=a.data)===null||n===void 0?void 0:n.capabilities;return c&&this.storage.storeObject(ue,c),a}updateChain(e,s){var n;const i=s??this.storage.loadObject(he),r=i==null?void 0:i.find(a=>a.id===e);return r?(r!==this.chain&&(this.chain=r,this.storage.storeObject(le,r),(n=this.callback)===null||n===void 0||n.call(this,"chainChanged",A(r.id))),!0):!1}}const Nt=rt(at),{keccak_256:Tt}=Nt;function We(t){return Buffer.allocUnsafe(t).fill(0)}function Dt(t){return t.toString(2).length}function Be(t,e){let s=t.toString(16);s.length%2!==0&&(s="0"+s);const n=s.match(/.{1,2}/g).map(i=>parseInt(i,16));for(;n.length"u")throw new Error("Not an array?");if(s=Ze(t),s!=="dynamic"&&s!==0&&e.length>s)throw new Error("Elements exceed array size: "+s);i=[],t=t.slice(0,t.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(r in e)i.push(E(t,e[r]));if(s==="dynamic"){var a=E("uint256",e.length);i.unshift(a)}return Buffer.concat(i)}else{if(t==="bytes")return e=new Buffer(e),i=Buffer.concat([E("uint256",e.length),e]),e.length%32!==0&&(i=Buffer.concat([i,w.zeros(32-e.length%32)])),i;if(t.startsWith("bytes")){if(s=R(t),s<1||s>32)throw new Error("Invalid bytes width: "+s);return w.setLengthRight(e,32)}else if(t.startsWith("uint")){if(s=R(t),s%8||s<8||s>256)throw new Error("Invalid uint width: "+s);n=L(e);const o=w.bitLengthFromBigInt(n);if(o>s)throw new Error("Supplied uint exceeds width: "+s+" vs "+o);if(n<0)throw new Error("Supplied uint is negative");return w.bufferBEFromBigInt(n,32)}else if(t.startsWith("int")){if(s=R(t),s%8||s<8||s>256)throw new Error("Invalid int width: "+s);n=L(e);const o=w.bitLengthFromBigInt(n);if(o>s)throw new Error("Supplied int exceeds width: "+s+" vs "+o);const c=w.twosFromBigInt(n,256);return w.bufferBEFromBigInt(c,32)}else if(t.startsWith("ufixed")){if(s=pe(t),n=L(e),n<0)throw new Error("Supplied ufixed is negative");return E("uint256",n*BigInt(2)**BigInt(s[1]))}else if(t.startsWith("fixed"))return s=pe(t),E("int256",L(e)*BigInt(2)**BigInt(s[1]))}throw new Error("Unsupported or invalid type: "+t)}function qt(t){return t==="string"||t==="bytes"||Ze(t)==="dynamic"}function Ht(t){return t.lastIndexOf("]")===t.length-1}function Kt(t,e){var s=[],n=[],i=32*t.length;for(var r in t){var a=ze(t[r]),o=e[r],c=E(a,o);qt(a)?(s.push(E("uint256",i)),n.push(c),i+=c.length):s.push(c)}return Buffer.concat(s.concat(n))}function Fe(t,e){if(t.length!==e.length)throw new Error("Number of types are not matching the values");for(var s,n,i=[],r=0;r32)throw new Error("Invalid bytes width: "+s);i.push(w.setLengthRight(o,s))}else if(a.startsWith("uint")){if(s=R(a),s%8||s<8||s>256)throw new Error("Invalid uint width: "+s);n=L(o);const c=w.bitLengthFromBigInt(n);if(c>s)throw new Error("Supplied uint exceeds width: "+s+" vs "+c);i.push(w.bufferBEFromBigInt(n,s/8))}else if(a.startsWith("int")){if(s=R(a),s%8||s<8||s>256)throw new Error("Invalid int width: "+s);n=L(o);const c=w.bitLengthFromBigInt(n);if(c>s)throw new Error("Supplied int exceeds width: "+s+" vs "+c);const d=w.twosFromBigInt(n,s);i.push(w.bufferBEFromBigInt(d,s/8))}else throw new Error("Unsupported or invalid type: "+a)}return Buffer.concat(i)}function Vt(t,e){return w.keccak(Fe(t,e))}var zt={rawEncode:Kt,solidityPack:Fe,soliditySHA3:Vt};const y=Ve,U=zt,$e={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},G={encodeData(t,e,s,n=!0){const i=["bytes32"],r=[this.hashType(t,s)];if(n){const a=(o,c,d)=>{if(s[c]!==void 0)return["bytes32",d==null?"0x0000000000000000000000000000000000000000000000000000000000000000":y.keccak(this.encodeData(c,d,s,n))];if(d===void 0)throw new Error(`missing value for field ${o} of type ${c}`);if(c==="bytes")return["bytes32",y.keccak(d)];if(c==="string")return typeof d=="string"&&(d=Buffer.from(d,"utf8")),["bytes32",y.keccak(d)];if(c.lastIndexOf("]")===c.length-1){const g=c.slice(0,c.lastIndexOf("[")),p=d.map(f=>a(o,g,f));return["bytes32",y.keccak(U.rawEncode(p.map(([f])=>f),p.map(([,f])=>f)))]}return[c,d]};for(const o of s[t]){const[c,d]=a(o.name,o.type,e[o.name]);i.push(c),r.push(d)}}else for(const a of s[t]){let o=e[a.name];if(o!==void 0)if(a.type==="bytes")i.push("bytes32"),o=y.keccak(o),r.push(o);else if(a.type==="string")i.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=y.keccak(o),r.push(o);else if(s[a.type]!==void 0)i.push("bytes32"),o=y.keccak(this.encodeData(a.type,o,s,n)),r.push(o);else{if(a.type.lastIndexOf("]")===a.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(a.type),r.push(o)}}return U.rawEncode(i,r)},encodeType(t,e){let s="",n=this.findTypeDependencies(t,e).filter(i=>i!==t);n=[t].concat(n.sort());for(const i of n){if(!e[i])throw new Error("No type definition specified: "+i);s+=i+"("+e[i].map(({name:a,type:o})=>o+" "+a).join(",")+")"}return s},findTypeDependencies(t,e,s=[]){if(t=t.match(/^\w*/)[0],s.includes(t)||e[t]===void 0)return s;s.push(t);for(const n of e[t])for(const i of this.findTypeDependencies(n.type,e,s))!s.includes(i)&&s.push(i);return s},hashStruct(t,e,s,n=!0){return y.keccak(this.encodeData(t,e,s,n))},hashType(t,e){return y.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const s in $e.properties)t[s]&&(e[s]=t[s]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,e=!0){const s=this.sanitizeData(t),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",s.domain,s.types,e)),s.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(s.primaryType,s.message,s.types,e)),y.keccak(Buffer.concat(n))}};var q={TYPED_MESSAGE_SCHEMA:$e,TypedDataUtils:G,hashForSignTypedDataLegacy:function(t){return Zt(t.data)},hashForSignTypedData_v3:function(t){return G.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return G.hash(t.data)}};function Zt(t){const e=new Error("Expect argument to be non-empty array");if(typeof t!="object"||!t.length)throw e;const s=t.map(function(r){return r.type==="bytes"?y.toBuffer(r.value):r.value}),n=t.map(function(r){return r.type}),i=t.map(function(r){if(!r.name)throw e;return r.type+" "+r.name});return U.soliditySHA3(["bytes32","bytes32"],[U.soliditySHA3(new Array(t.length).fill("string"),i),U.soliditySHA3(n,s)])}const Ft="walletUsername",ee="Addresses",$t="AppVersion";function m(t){return t.errorMessage!==void 0}class Gt{constructor(e){this.secret=e}async encrypt(e){const s=this.secret;if(s.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",H(s),{name:"aes-gcm"},!1,["encrypt","decrypt"]),r=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,r.encode(e)),o=16,c=a.slice(a.byteLength-o),d=a.slice(0,a.byteLength-o),g=new Uint8Array(c),p=new Uint8Array(d),f=new Uint8Array([...n,...g,...p]);return ne(f)}async decrypt(e){const s=this.secret;if(s.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const r=await crypto.subtle.importKey("raw",H(s),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=H(e),o=a.slice(0,12),c=a.slice(12,28),d=a.slice(28),g=new Uint8Array([...d,...c]),p={name:"AES-GCM",iv:new Uint8Array(o)};try{const f=await window.crypto.subtle.decrypt(p,r,g),C=new TextDecoder;n(C.decode(f))}catch(f){i(f)}})()})}}class Yt{constructor(e,s,n){this.linkAPIUrl=e,this.sessionId=s;const i=`${s}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(s=>fetch(`${this.linkAPIUrl}/events/${s.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(s=>console.error("Unabled to mark event as failed:",s))}async fetchUnseenEvents(){var e;const s=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(s.ok){const{events:n,error:i}=await s.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const r=(e=n==null?void 0:n.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(r),r}throw new Error(`Check unseen events failed: ${s.status}`)}}var M;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(M||(M={}));class Jt{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,s=WebSocket){this.WebSocketClass=s,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,s)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(r){s(r);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,M.CONNECTING),i.onclose=r=>{var a;this.clearWebSocket(),s(new Error(`websocket error ${r.code}: ${r.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,M.DISCONNECTED)},i.onopen=r=>{var a;e(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,M.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(c=>this.sendData(c)),this.pendingData=[])},i.onmessage=r=>{var a,o;if(r.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(r.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var e;const{webSocket:s}=this;if(s){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,M.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{s.close()}catch{}}}sendData(e){const{webSocket:s}=this;if(!s){this.pendingData.push(e),this.connect();return}s.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}const fe=1e4,Qt=6e4;class Xt{constructor({session:e,linkAPIUrl:s,listener:n}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=I(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=r=>{if(!r)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",o=>r.JsonRpcUrl&&this.handleChainUpdated(o,r.JsonRpcUrl)]]).forEach((o,c)=>{const d=r[c];d!==void 0&&o(d)})},this.handleDestroyed=r=>{var a;r==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async r=>{var a;const o=await this.cipher.decrypt(r);(a=this.listener)===null||a===void 0||a.accountUpdated(o)},this.handleMetadataUpdated=async(r,a)=>{var o;const c=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.metadataUpdated(r,c)},this.handleWalletUsernameUpdated=async r=>{this.handleMetadataUpdated(Ft,r)},this.handleAppVersionUpdated=async r=>{this.handleMetadataUpdated($t,r)},this.handleChainUpdated=async(r,a)=>{var o;const c=await this.cipher.decrypt(r),d=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.chainUpdated(c,d)},this.session=e,this.cipher=new Gt(e.secret),this.listener=n;const i=new Jt(`${s}/rpc`,WebSocket);i.setConnectionStateListener(async r=>{let a=!1;switch(r){case M.DISCONNECTED:if(!this.destroyed){const o=async()=>{await new Promise(c=>setTimeout(c,5e3)),this.destroyed||i.connect().catch(()=>{o()})};o()}break;case M.CONNECTED:a=await this.handleConnected(),this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},fe),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case M.CONNECTING:break}this.connected!==a&&(this.connected=a)}),i.setIncomingDataListener(r=>{var a;switch(r.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const o=r.type==="IsLinkedOK"?r.linked:void 0;this.linked=o||r.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(r.metadata);break}case"Event":{this.handleIncomingEvent(r);break}}r.id!==void 0&&((a=this.requestResolutions.get(r.id))===null||a===void 0||a(r))}),this.ws=i,this.http=new Yt(s,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:I(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.ws.disconnect(),this.listener=void 0)}get connected(){return this._connected}set connected(e){this._connected=e}get linked(){return this._linked}set linked(e){var s,n;this._linked=e,e&&((s=this.onceLinked)===null||s===void 0||s.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(s=>{this.linked?e().then(s):this.onceLinked=()=>{e().then(s),this.onceLinked=void 0}})}async handleIncomingEvent(e){var s;if(e.type!=="Event"||e.event!=="Web3Response")return;const n=await this.cipher.decrypt(e.data),i=JSON.parse(n);if(i.type!=="WEB3_RESPONSE")return;const{id:r,response:a}=i;(s=this.listener)===null||s===void 0||s.handleWeb3ResponseMessage(r,a)}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(s=>this.handleIncomingEvent(s))}async publishEvent(e,s,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},s),{origin:location.origin,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),r={type:"PublishEvent",id:I(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const a=await this.makeRequest(r);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>fe*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,s={timeout:Qt}){const n=e.id;this.sendData(e);let i;return Promise.race([new Promise((r,a)=>{i=window.setTimeout(()=>{a(new Error(`request ${n} timed out`))},s.timeout)}),new Promise(r=>{this.requestResolutions.set(n,a=>{clearTimeout(i),r(a),this.requestResolutions.delete(n)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:I(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:I(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:I(this.nextReqId++),sessionId:this.session.id}),!0)}}class es{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,s=Re(e.toString(16));return this.callbacks.get(s)&&this.callbacks.delete(s),e}}const ge="session:id",me="session:secret",we="session:linked";class N{constructor(e,s,n,i=!1){this.storage=e,this.id=s,this.secret=n,this.key=ot(ct(`${s}, ${n} WalletLink`)),this._linked=!!i}static create(e){const s=_(16),n=_(32);return new N(e,s,n).save()}static load(e){const s=e.getItem(ge),n=e.getItem(we),i=e.getItem(me);return s&&i?new N(e,s,i,n==="1"):null}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this.storage.setItem(ge,this.id),this.storage.setItem(me,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(we,this._linked?"1":"0")}}function ts(){try{return window.frameElement!==null}catch{return!1}}function ss(){try{return ts()&&window.top?window.top.location:window.location}catch{return window.location}}function ns(){var t;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t=window==null?void 0:window.navigator)===null||t===void 0?void 0:t.userAgent)}function Ge(){var t,e;return(e=(t=window==null?void 0:window.matchMedia)===null||t===void 0?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}const is='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';function Ye(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(is)),document.documentElement.appendChild(t)}function Je(t){var e,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e{this.items.delete(s),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&Y(h("div",null,h(Qe,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,s])=>h(ds,Object.assign({},s,{key:e}))))),this.root)}}const Qe=t=>h("div",{class:W("-cbwsdk-snackbar-container")},h("style",null,rs),h("div",{class:"-cbwsdk-snackbar"},t.children)),ds=({autoExpand:t,message:e,menuItems:s})=>{const[n,i]=ae(!0),[r,a]=ae(t??!1);lt(()=>{const c=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{a(!0)},1e4)];return()=>{c.forEach(window.clearTimeout)}});const o=()=>{a(!r)};return h("div",{class:W("-cbwsdk-snackbar-instance",n&&"-cbwsdk-snackbar-instance-hidden",r&&"-cbwsdk-snackbar-instance-expanded")},h("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},h("img",{src:as,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",h("div",{class:"-cbwsdk-snackbar-instance-header-message"},e),h("div",{class:"-gear-container"},!r&&h("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),h("img",{src:os,class:"-gear-icon",title:"Expand"}))),s&&s.length>0&&h("div",{class:"-cbwsdk-snackbar-instance-menu"},s.map((c,d)=>h("div",{class:W("-cbwsdk-snackbar-instance-menu-item",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:c.onClick,key:d},h("svg",{width:c.svgWidth,height:c.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},h("path",{"fill-rule":c.defaultFillRule,"clip-rule":c.defaultClipRule,d:c.path,fill:"#AAAAAA"})),h("span",{class:W("-cbwsdk-snackbar-instance-menu-item-info",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},c.info)))))};class ls{constructor(){this.attached=!1,this.snackbar=new cs}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,s=document.createElement("div");s.className="-cbwsdk-css-reset",e.appendChild(s),this.snackbar.attach(s),this.attached=!0,Ye()}showConnecting(e){let s;return e.isUnlinkedErrorState?s={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:s={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(s)}}const hs=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class us{constructor(){this.root=null,this.darkMode=Ge()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),Ye()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&(Y(null,this.root),e&&Y(h(ps,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const ps=({title:t,buttonText:e,darkMode:s,onButtonClick:n,onDismiss:i})=>{const r=s?"dark":"light";return h(Qe,{darkMode:s},h("div",{class:"-cbwsdk-redirect-dialog"},h("style",null,hs),h("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),h("div",{class:W("-cbwsdk-redirect-dialog-box",r)},h("p",null,t),h("button",{onClick:n},e))))},fs="https://keys.coinbase.com/connect",be="https://www.walletlink.org",gs="https://go.cb-w.com/walletlink";class ye{constructor(){this.attached=!1,this.redirectDialog=new us}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const s=new URL(gs);s.searchParams.append("redirect_url",ss().href),e&&s.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=s.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}class S{constructor(e){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=ns(),this.linkedUpdated=r=>{this.isLinked=r;const a=this.storage.getItem(ee);if(r&&(this._session.linked=r),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!r&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(r,a)=>{this.storage.setItem(r,a)},this.chainUpdated=(r,a)=>{this.chainCallbackParams.chainId===r&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:r,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(a,Number.parseInt(r,10)))},this.accountUpdated=r=>{this.accountsCallback&&this.accountsCallback([r]),S.accountRequestCallbackIds.size>0&&(Array.from(S.accountRequestCallbackIds.values()).forEach(a=>{this.invokeCallback(a,{method:"requestEthereumAccounts",result:[r]})}),S.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage,this.metadata=e.metadata,this.accountsCallback=e.accountsCallback,this.chainCallback=e.chainCallback;const{session:s,ui:n,connection:i}=this.subscribe();this._session=s,this.connection=i,this.relayEventManager=new es,this.ui=n,this.ui.attach()}subscribe(){const e=N.load(this.storage)||N.create(this.storage),{linkAPIUrl:s}=this,n=new Xt({session:e,linkAPIUrl:s,listener:this}),i=this.isMobileWeb?new ye:new ls;return n.connect(),{session:e,ui:i,connection:n}}resetAndReload(){this.connection.destroy().then(()=>{const e=N.load(this.storage);(e==null?void 0:e.id)===this._session.id&&v.clearAll(),document.location.reload()}).catch(e=>{})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:k(e.weiValue),data:O(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?k(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?k(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?k(e.gasPriceInWei):null,gasLimit:e.gasLimit?k(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:k(e.weiValue),data:O(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?k(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?k(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?k(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?k(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,s){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:O(e,!0),chainId:s}})}getWalletLinkSession(){return this._session}sendRequest(e){let s=null;const n=_(8),i=r=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,r),s==null||s()};return new Promise((r,a)=>{s=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,o=>{if(s==null||s(),m(o))return a(new Error(o.errorMessage));r(o)}),this.publishWeb3RequestEvent(n,e)})}publishWeb3RequestEvent(e,s){const n={type:"WEB3_REQUEST",id:e,request:s};this.publishEvent("Web3Request",n,!0).then(i=>{}).catch(i=>{this.handleWeb3ResponseMessage(n.id,{method:s.method,errorMessage:i.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(s.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof ye)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const s={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",s,!1).then()}publishEvent(e,s,n){return this.connection.publishEvent(e,s,n)}handleWeb3ResponseMessage(e,s){if(s.method==="requestEthereumAccounts"){S.accountRequestCallbackIds.forEach(n=>this.invokeCallback(n,s)),S.accountRequestCallbackIds.clear();return}this.invokeCallback(e,s)}handleErrorResponse(e,s,n){var i;const r=(i=n==null?void 0:n.message)!==null&&i!==void 0?i:"Unspecified error message.";this.handleWeb3ResponseMessage(e,{method:s,errorMessage:r})}invokeCallback(e,s){const n=this.relayEventManager.callbacks.get(e);n&&(n(s),this.relayEventManager.callbacks.delete(e))}requestEthereumAccounts(){const{appName:e,appLogoUrl:s}=this.metadata,n={method:"requestEthereumAccounts",params:{appName:e,appLogoUrl:s}},i=_(8);return new Promise((r,a)=>{this.relayEventManager.callbacks.set(i,o=>{if(m(o))return a(new Error(o.errorMessage));r(o)}),S.accountRequestCallbackIds.add(i),this.publishWeb3RequestEvent(i,n)})}watchAsset(e,s,n,i,r,a){const o={method:"watchAsset",params:{type:e,options:{address:s,symbol:n,decimals:i,image:r},chainId:a}};let c=null;const d=_(8),g=p=>{this.publishWeb3RequestCanceledEvent(d),this.handleErrorResponse(d,o.method,p),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:g,onResetConnection:this.resetAndReload}),new Promise((p,f)=>{this.relayEventManager.callbacks.set(d,C=>{if(c==null||c(),m(C))return f(new Error(C.errorMessage));p(C)}),this.publishWeb3RequestEvent(d,o)})}addEthereumChain(e,s,n,i,r,a){const o={method:"addEthereumChain",params:{chainId:e,rpcUrls:s,blockExplorerUrls:i,chainName:r,iconUrls:n,nativeCurrency:a}};let c=null;const d=_(8),g=p=>{this.publishWeb3RequestCanceledEvent(d),this.handleErrorResponse(d,o.method,p),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:g,onResetConnection:this.resetAndReload}),new Promise((p,f)=>{this.relayEventManager.callbacks.set(d,C=>{if(c==null||c(),m(C))return f(new Error(C.errorMessage));p(C)}),this.publishWeb3RequestEvent(d,o)})}switchEthereumChain(e,s){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:s})};let i=null;const r=_(8),a=o=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,n.method,o),i==null||i()};return i=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:a,onResetConnection:this.resetAndReload}),new Promise((o,c)=>{this.relayEventManager.callbacks.set(r,d=>{if(i==null||i(),m(d)&&d.errorCode)return c(l.provider.custom({code:d.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(m(d))return c(new Error(d.errorMessage));o(d)}),this.publishWeb3RequestEvent(r,n)})}}S.accountRequestCallbackIds=new Set;const ve="DefaultChainId",ke="DefaultJsonRpcUrl";class Xe{constructor(e){this._relay=null,this._addresses=[],this.metadata=e.metadata,this._storage=new v("walletlink",be),this.callback=e.callback||null;const s=this._storage.getItem(ee);if(s){const n=s.split(" ");n[0]!==""&&(this._addresses=n.map(i=>x(i)))}this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:s,secret:n}=e.getWalletLinkSession();return{id:s,secret:n}}async handshake(){await this._eth_requestAccounts()}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(ke))!==null&&e!==void 0?e:void 0}set jsonRpcUrl(e){this._storage.setItem(ke,e)}updateProviderInfo(e,s){var n;this.jsonRpcUrl=e;const i=this.getChainId();this._storage.setItem(ve,s.toString(10)),j(s)!==i&&((n=this.callback)===null||n===void 0||n.call(this,"chainChanged",A(s)))}async watchAsset(e){const s=Array.isArray(e)?e[0]:e;if(!s.type)throw l.rpc.invalidParams("Type is required");if((s==null?void 0:s.type)!=="ERC20")throw l.rpc.invalidParams(`Asset of type '${s.type}' is not supported`);if(!(s!=null&&s.options))throw l.rpc.invalidParams("Options are required");if(!(s!=null&&s.options.address))throw l.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:i,symbol:r,image:a,decimals:o}=s.options,d=await this.initializeRelay().watchAsset(s.type,i,r,o,a,n==null?void 0:n.toString());return m(d)?!1:!!d.result}async addEthereumChain(e){var s,n;const i=e[0];if(((s=i.rpcUrls)===null||s===void 0?void 0:s.length)===0)throw l.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!i.chainName||i.chainName.trim()==="")throw l.rpc.invalidParams("chainName is a required field");if(!i.nativeCurrency)throw l.rpc.invalidParams("nativeCurrency is a required field");const r=Number.parseInt(i.chainId,16);if(r===this.getChainId())return!1;const a=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:c=[],chainName:d,iconUrls:g=[],nativeCurrency:p}=i,f=await a.addEthereumChain(r.toString(),o,g,c,d,p);if(m(f))return!1;if(((n=f.result)===null||n===void 0?void 0:n.isApproved)===!0)return this.updateProviderInfo(o[0],r),null;throw l.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(e){const s=e[0],n=Number.parseInt(s.chainId,16),r=await this.initializeRelay().switchEthereumChain(n.toString(10),this.selectedAddress||void 0);if(m(r))throw r;const a=r.result;return a.isApproved&&a.rpcUrl.length>0&&this.updateProviderInfo(a.rpcUrl,n),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(e,s){var n;if(!Array.isArray(e))throw new Error("addresses is not an array");const i=e.map(r=>x(r));JSON.stringify(i)!==JSON.stringify(this._addresses)&&(this._addresses=i,(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",i),this._storage.setItem(ee,i.join(" ")))}async request(e){const s=e.params||[];switch(e.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return A(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(e);case"personal_sign":return this.personalSign(e);case"eth_signTransaction":return this._eth_signTransaction(s);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(s);case"eth_sendTransaction":return this._eth_sendTransaction(s);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(e);case"wallet_addEthereumChain":return this.addEthereumChain(s);case"wallet_switchEthereumChain":return this.switchEthereumChain(s);case"wallet_watchAsset":return this.watchAsset(s);default:if(!this.jsonRpcUrl)throw l.rpc.internal("No RPC URL set for chain");return je(e,this.jsonRpcUrl)}}_ensureKnownAddress(e){const s=x(e);if(!this._addresses.map(i=>x(i)).includes(s))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const s=e.from?x(e.from):this.selectedAddress;if(!s)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(s);const n=e.to?x(e.to):null,i=e.value!=null?D(e.value):BigInt(0),r=e.data?X(e.data):Buffer.alloc(0),a=e.nonce!=null?j(e.nonce):null,o=e.gasPrice!=null?D(e.gasPrice):null,c=e.maxFeePerGas!=null?D(e.maxFeePerGas):null,d=e.maxPriorityFeePerGas!=null?D(e.maxPriorityFeePerGas):null,g=e.gas!=null?D(e.gas):null,p=e.chainId?j(e.chainId):this.getChainId();return{fromAddress:s,toAddress:n,weiValue:i,data:r,nonce:a,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:d,gasLimit:g,chainId:p}}async ecRecover(e){const{method:s,params:n}=e;if(!Array.isArray(n))throw l.rpc.invalidParams();const r=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:z(n[0]),signature:z(n[1]),addPrefix:s==="personal_ecRecover"}});if(m(r))throw r;return r.result}getChainId(){var e;return Number.parseInt((e=this._storage.getItem(ve))!==null&&e!==void 0?e:"1",10)}async _eth_requestAccounts(){var e,s;if(this._addresses.length>0)return(e=this.callback)===null||e===void 0||e.call(this,"connect",{chainId:A(this.getChainId())}),this._addresses;const i=await this.initializeRelay().requestEthereumAccounts();if(m(i))throw i;if(!i.result)throw new Error("accounts received is empty");return this._setAddresses(i.result),(s=this.callback)===null||s===void 0||s.call(this,"connect",{chainId:A(this.getChainId())}),this._addresses}async personalSign({params:e}){if(!Array.isArray(e))throw l.rpc.invalidParams();const s=e[1],n=e[0];this._ensureKnownAddress(s);const r=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:x(s),message:z(n),addPrefix:!0,typedDataJson:null}});if(m(r))throw r;return r.result}async _eth_signTransaction(e){const s=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signEthereumTransaction(s);if(m(i))throw i;return i.result}async _eth_sendRawTransaction(e){const s=X(e[0]),i=await this.initializeRelay().submitEthereumTransaction(s,this.getChainId());if(m(i))throw i;return i.result}async _eth_sendTransaction(e){const s=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signAndSubmitEthereumTransaction(s);if(m(i))throw i;return i.result}async signTypedData(e){const{method:s,params:n}=e;if(!Array.isArray(n))throw l.rpc.invalidParams();const i=d=>{const g={eth_signTypedData_v1:q.hashForSignTypedDataLegacy,eth_signTypedData_v3:q.hashForSignTypedData_v3,eth_signTypedData_v4:q.hashForSignTypedData_v4,eth_signTypedData:q.hashForSignTypedData_v4};return O(g[s]({data:yt(d)}),!0)},r=n[s==="eth_signTypedData_v1"?1:0],a=n[s==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(r);const c=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:x(r),message:i(a),typedDataJson:JSON.stringify(a,null,2),addPrefix:!1}});if(m(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new S({linkAPIUrl:be,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const et="SignerType",tt=new v("CBWSDK","SignerConfigurator");function ms(){return tt.getItem(et)}function ws(t){tt.setItem(et,t)}async function bs(t){const{communicator:e,metadata:s,handshakeRequest:n,callback:i}=t;vs(e,s,i).catch(()=>{});const r={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},t.preference),{handshakeRequest:n})},{data:a}=await e.postRequestAndWaitForResponse(r);return a}function ys(t){const{signerType:e,metadata:s,communicator:n,callback:i}=t;switch(e){case"scw":return new Rt({metadata:s,callback:i,communicator:n});case"walletlink":return new Xe({metadata:s,callback:i})}}async function vs(t,e,s){await t.onMessage(({event:i})=>i==="WalletLinkSessionRequest");const n=new Xe({metadata:e,callback:s});t.postMessage({event:"WalletLinkUpdate",data:{session:n.getSession()}}),await n.handshake(),t.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}const ks=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app. Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,Es=()=>{let t;return{getCrossOriginOpenerPolicy:()=>t===void 0?"undefined":t,checkCrossOriginOpenerPolicy:async()=>{if(typeof window>"u"){t="non-browser-env";return}try{const e=`${window.location.origin}${window.location.pathname}`,s=await fetch(e,{method:"HEAD"});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=s.headers.get("Cross-Origin-Opener-Policy");t=n??"null",t==="same-origin"&&console.error(ks)}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}}}},{checkCrossOriginOpenerPolicy:st,getCrossOriginOpenerPolicy:Cs}=Es(),Ee=420,Ce=540;function Is(t){const e=(window.innerWidth-Ee)/2+window.screenX,s=(window.innerHeight-Ce)/2+window.screenY;Ms(t);const n=window.open(t,"Smart Wallet",`width=${Ee}, height=${Ce}, left=${e}, top=${s}`);if(n==null||n.focus(),!n)throw l.rpc.internal("Pop up window failed to open");return n}function Ss(t){t&&!t.closed&&t.close()}function Ms(t){const e={sdkName:Oe,sdkVersion:T,origin:window.location.origin,coop:Cs()};for(const[s,n]of Object.entries(e))t.searchParams.append(s,n.toString())}class xs{constructor({url:e=fs,metadata:s,preference:n}){this.popup=null,this.listeners=new Map,this.postMessage=async i=>{(await this.waitForPopupLoaded()).postMessage(i,this.url.origin)},this.postRequestAndWaitForResponse=async i=>{const r=this.onMessage(({requestId:a})=>a===i.id);return this.postMessage(i),await r},this.onMessage=async i=>new Promise((r,a)=>{const o=c=>{if(c.origin!==this.url.origin)return;const d=c.data;i(d)&&(r(d),window.removeEventListener("message",o),this.listeners.delete(o))};window.addEventListener("message",o),this.listeners.set(o,{reject:a})}),this.disconnect=()=>{Ss(this.popup),this.popup=null,this.listeners.forEach(({reject:i},r)=>{i(l.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",r)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=Is(this.url),this.onMessage(({event:i})=>i==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:i})=>i==="PopupLoaded").then(i=>{this.postMessage({requestId:i.id,data:{version:T,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw l.rpc.internal();return this.popup})),this.url=new URL(e),this.metadata=s,this.preference=n}}function As(t){const e=ft(_s(t),{shouldIncludeStack:!0}),s=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return s.searchParams.set("version",T),s.searchParams.set("code",e.code.toString()),s.searchParams.set("message",e.message),Object.assign(Object.assign({},e),{docUrl:s.href})}function _s(t){var e;if(typeof t=="string")return{message:t,code:u.rpc.internal};if(m(t)){const s=t.errorMessage,n=(e=t.errorCode)!==null&&e!==void 0?e:s.match(/(denied|rejected)/i)?u.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},t),{message:s,code:n,data:{method:t.method}})}return t}class Ls extends dt{}var Ps=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i(i||(i=Rs(n)),i)}}export{Os as CoinbaseWalletSDK,js as createCoinbaseWalletSDK,Os as default}; diff --git a/buddybook/assets/index-uonIXzgQ.js b/buddybook/assets/index-BpI4vT-j.js similarity index 98% rename from buddybook/assets/index-uonIXzgQ.js rename to buddybook/assets/index-BpI4vT-j.js index 9cf3ebc..cb30e76 100644 --- a/buddybook/assets/index-uonIXzgQ.js +++ b/buddybook/assets/index-BpI4vT-j.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-xz6stGwY.js","assets/hooks.module-D0gf0yJl.js","assets/index-Cu6T4rb4.js","assets/inherits_browser-Bb3-ajt6.js","assets/events-xQ4utD7e.js","assets/index-BpmIcSNW.js","assets/index.es-C5jEvyUt.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BhnqxX7Q.js","assets/hooks.module-D0gf0yJl.js","assets/index-BE2r4h4L.js","assets/inherits_browser-B8fZ3Rhe.js","assets/events-DyQEop7s.js","assets/index-DskNhwDJ.js","assets/index.es-BwINMB1n.js"])))=>i.map(i=>d[i]); var nu=Object.defineProperty;var Bs=o=>{throw TypeError(o)};var ru=(o,et,tt)=>et in o?nu(o,et,{enumerable:!0,configurable:!0,writable:!0,value:tt}):o[et]=tt;var Ct=(o,et,tt)=>ru(o,typeof et!="symbol"?et+"":et,tt),is=(o,et,tt)=>et.has(o)||Bs("Cannot "+tt);var Mt=(o,et,tt)=>(is(o,et,"read from private field"),tt?tt.call(o):et.get(o)),fn=(o,et,tt)=>et.has(o)?Bs("Cannot add the same private member more than once"):et instanceof WeakSet?et.add(o):et.set(o,tt),un=(o,et,tt,nt)=>(is(o,et,"write to private field"),nt?nt.call(o,tt):et.set(o,tt),tt),gn=(o,et,tt)=>(is(o,et,"access private method"),tt);var br=(o,et,tt,nt)=>({set _(rt){un(o,et,rt,tt)},get _(){return Mt(o,et,nt)}});function _mergeNamespaces(o,et){for(var tt=0;ttnt[rt]})}}}return Object.freeze(Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}))}(function(){const et=document.createElement("link").relList;if(et&&et.supports&&et.supports("modulepreload"))return;for(const rt of document.querySelectorAll('link[rel="modulepreload"]'))nt(rt);new MutationObserver(rt=>{for(const ot of rt)if(ot.type==="childList")for(const it of ot.addedNodes)it.tagName==="LINK"&&it.rel==="modulepreload"&&nt(it)}).observe(document,{childList:!0,subtree:!0});function tt(rt){const ot={};return rt.integrity&&(ot.integrity=rt.integrity),rt.referrerPolicy&&(ot.referrerPolicy=rt.referrerPolicy),rt.crossOrigin==="use-credentials"?ot.credentials="include":rt.crossOrigin==="anonymous"?ot.credentials="omit":ot.credentials="same-origin",ot}function nt(rt){if(rt.ep)return;rt.ep=!0;const ot=tt(rt);fetch(rt.href,ot)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function getDefaultExportFromCjs(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function getAugmentedNamespace(o){if(o.__esModule)return o;var et=o.default;if(typeof et=="function"){var tt=function nt(){return this instanceof nt?Reflect.construct(et,arguments,this.constructor):et.apply(this,arguments)};tt.prototype=et.prototype}else tt={};return Object.defineProperty(tt,"__esModule",{value:!0}),Object.keys(o).forEach(function(nt){var rt=Object.getOwnPropertyDescriptor(o,nt);Object.defineProperty(tt,nt,rt.get?rt:{enumerable:!0,get:function(){return o[nt]}})}),tt}var jsxRuntime={exports:{}},reactJsxRuntime_production_min={},react={exports:{}},react_production_min={};/** * @license React * react.production.min.js @@ -75,7 +75,7 @@ Error generating stack: `+ot.message+` `).slice(0,-1)}function serializeStateMapping(o){if(!(!o||o.length===0))return o.reduce((et,{slot:tt,value:nt})=>{if(tt.length!==66)throw new InvalidBytesLengthError({size:tt.length,targetSize:66,type:"hex"});if(nt.length!==66)throw new InvalidBytesLengthError({size:nt.length,targetSize:66,type:"hex"});return et[tt]=nt,et},{})}function serializeAccountStateOverride(o){const{balance:et,nonce:tt,state:nt,stateDiff:rt,code:ot}=o,it={};if(ot!==void 0&&(it.code=ot),et!==void 0&&(it.balance=numberToHex(et)),tt!==void 0&&(it.nonce=numberToHex(tt)),nt!==void 0&&(it.state=serializeStateMapping(nt)),rt!==void 0){if(it.state)throw new StateAssignmentConflictError;it.stateDiff=serializeStateMapping(rt)}return it}function serializeStateOverride(o){if(!o)return;const et={};for(const{address:tt,...nt}of o){if(!isAddress(tt,{strict:!1}))throw new InvalidAddressError({address:tt});if(et[tt])throw new AccountStateConflictError({address:tt});et[tt]=serializeAccountStateOverride(nt)}return et}async function getBalance$1(o,{address:et,blockNumber:tt,blockTag:nt="latest"}){const rt=tt?numberToHex(tt):void 0,ot=await o.request({method:"eth_getBalance",params:[et,rt||nt]});return BigInt(ot)}function blobsToCommitments(o){const{kzg:et}=o,tt=o.to??(typeof o.blobs[0]=="string"?"hex":"bytes"),nt=typeof o.blobs[0]=="string"?o.blobs.map(ot=>hexToBytes$3(ot)):o.blobs,rt=[];for(const ot of nt)rt.push(Uint8Array.from(et.blobToKzgCommitment(ot)));return tt==="bytes"?rt:rt.map(ot=>bytesToHex$4(ot))}function blobsToProofs(o){const{kzg:et}=o,tt=o.to??(typeof o.blobs[0]=="string"?"hex":"bytes"),nt=typeof o.blobs[0]=="string"?o.blobs.map(it=>hexToBytes$3(it)):o.blobs,rt=typeof o.commitments[0]=="string"?o.commitments.map(it=>hexToBytes$3(it)):o.commitments,ot=[];for(let it=0;itbytesToHex$4(it))}function setBigUint64$1(o,et,tt,nt){if(typeof o.setBigUint64=="function")return o.setBigUint64(et,tt,nt);const rt=BigInt(32),ot=BigInt(4294967295),it=Number(tt>>rt&ot),st=Number(tt&ot),at=nt?4:0,ct=nt?0:4;o.setUint32(et+at,it,nt),o.setUint32(et+ct,st,nt)}const Chi=(o,et,tt)=>o&et^~o&tt,Maj=(o,et,tt)=>o&et^o&tt^et&tt;class HashMD extends Hash{constructor(et,tt,nt,rt){super(),this.blockLen=et,this.outputLen=tt,this.padOffset=nt,this.isLE=rt,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(et),this.view=createView$1(this.buffer)}update(et){exists$1(this);const{view:tt,buffer:nt,blockLen:rt}=this;et=toBytes$2(et);const ot=et.length;for(let it=0;itrt-it&&(this.process(nt,0),it=0);for(let dt=it;dtlt.length)throw new Error("_sha2: outputLen bigger than state");for(let dt=0;dt>>3,ft=rotr(pt,17)^rotr(pt,19)^pt>>>10;SHA256_W[dt]=ft+SHA256_W[dt-7]+mt+SHA256_W[dt-16]|0}let{A:nt,B:rt,C:ot,D:it,E:st,F:at,G:ct,H:lt}=this;for(let dt=0;dt<64;dt++){const ht=rotr(st,6)^rotr(st,11)^rotr(st,25),pt=lt+ht+Chi(st,at,ct)+SHA256_K[dt]+SHA256_W[dt]|0,ft=(rotr(nt,2)^rotr(nt,13)^rotr(nt,22))+Maj(nt,rt,ot)|0;lt=ct,ct=at,at=st,st=it+pt|0,it=ot,ot=rt,rt=nt,nt=pt+ft|0}nt=nt+this.A|0,rt=rt+this.B|0,ot=ot+this.C|0,it=it+this.D|0,st=st+this.E|0,at=at+this.F|0,ct=ct+this.G|0,lt=lt+this.H|0,this.set(nt,rt,ot,it,st,at,ct,lt)}roundClean(){SHA256_W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const sha256$2=wrapConstructor(()=>new SHA256);function sha256$1(o,et){return sha256$2(isHex(o,{strict:!1})?toBytes$3(o):o)}function commitmentToVersionedHash(o){const{commitment:et,version:tt=1}=o,nt=o.to??(typeof et=="string"?"hex":"bytes"),rt=sha256$1(et);return rt.set([tt],0),nt==="bytes"?rt:bytesToHex$4(rt)}function commitmentsToVersionedHashes(o){const{commitments:et,version:tt}=o,nt=o.to??(typeof et[0]=="string"?"hex":"bytes"),rt=[];for(const ot of et)rt.push(commitmentToVersionedHash({commitment:ot,to:nt,version:tt}));return rt}const blobsPerTransaction=6,bytesPerFieldElement=32,fieldElementsPerBlob=4096,bytesPerBlob=bytesPerFieldElement*fieldElementsPerBlob,maxBytesPerTransaction=bytesPerBlob*blobsPerTransaction-1-1*fieldElementsPerBlob*blobsPerTransaction,versionedHashVersionKzg=1;class BlobSizeTooLargeError extends BaseError$3{constructor({maxSize:et,size:tt}){super("Blob size is too large.",{metaMessages:[`Max: ${et} bytes`,`Given: ${tt} bytes`],name:"BlobSizeTooLargeError"})}}class EmptyBlobError extends BaseError$3{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class InvalidVersionedHashSizeError extends BaseError$3{constructor({hash:et,size:tt}){super(`Versioned hash "${et}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${tt}`],name:"InvalidVersionedHashSizeError"})}}class InvalidVersionedHashVersionError extends BaseError$3{constructor({hash:et,version:tt}){super(`Versioned hash "${et}" version is invalid.`,{metaMessages:[`Expected: ${versionedHashVersionKzg}`,`Received: ${tt}`],name:"InvalidVersionedHashVersionError"})}}function toBlobs(o){const et=o.to??(typeof o.data=="string"?"hex":"bytes"),tt=typeof o.data=="string"?hexToBytes$3(o.data):o.data,nt=size$2(tt);if(!nt)throw new EmptyBlobError;if(nt>maxBytesPerTransaction)throw new BlobSizeTooLargeError({maxSize:maxBytesPerTransaction,size:nt});const rt=[];let ot=!0,it=0;for(;ot;){const st=createCursor(new Uint8Array(bytesPerBlob));let at=0;for(;atst.bytes):rt.map(st=>bytesToHex$4(st.bytes))}function toBlobSidecars(o){const{data:et,kzg:tt,to:nt}=o,rt=o.blobs??toBlobs({data:et,to:nt}),ot=o.commitments??blobsToCommitments({blobs:rt,kzg:tt,to:nt}),it=o.proofs??blobsToProofs({blobs:rt,commitments:ot,kzg:tt,to:nt}),st=[];for(let at=0;at1||tt[0]>1)throw new InvalidBytesBooleanError(tt);return!!tt[0]}function bytesToNumber$1(o,et={}){typeof et.size<"u"&&assertSize(o,{size:et.size});const tt=bytesToHex$4(o,et);return hexToNumber$2(tt,et)}function bytesToString(o,et={}){let tt=o;return typeof et.size<"u"&&(assertSize(tt,{size:et.size}),tt=trim$1(tt,{dir:"right"})),new TextDecoder().decode(tt)}function decodeAbiParameters(o,et){const tt=typeof et=="string"?hexToBytes$3(et):et,nt=createCursor(tt);if(size$2(tt)===0&&o.length>0)throw new AbiDecodingZeroDataError;if(size$2(et)&&size$2(et)<32)throw new AbiDecodingDataSizeTooSmallError({data:typeof et=="string"?et:bytesToHex$4(et),params:o,size:size$2(et)});let rt=0;const ot=[];for(let it=0;it48?bytesToBigInt(rt,{signed:tt}):bytesToNumber$1(rt,{signed:tt}),32]}function decodeTuple(o,et,{staticPosition:tt}){const nt=et.components.length===0||et.components.some(({name:it})=>!it),rt=nt?[]:{};let ot=0;if(hasDynamicChild(et)){const it=bytesToNumber$1(o.readBytes(sizeOfOffset)),st=tt+it;for(let at=0;atkeccak256$1(toBytes$3(o));function hashSignature(o){return hash(o)}const version$7="1.0.6";let BaseError$2=class ks extends Error{constructor(et,tt={}){var it;const nt=tt.cause instanceof ks?tt.cause.details:(it=tt.cause)!=null&&it.message?tt.cause.message:tt.details,rt=tt.cause instanceof ks&&tt.cause.docsPath||tt.docsPath,ot=[et||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...rt?[`Docs: https://abitype.dev${rt}`]:[],...nt?[`Details: ${nt}`]:[],`Version: abitype@${version$7}`].join(` `);super(ot),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),tt.cause&&(this.cause=tt.cause),this.details=nt,this.docsPath=rt,this.metaMessages=tt.metaMessages,this.shortMessage=et}};function execTyped(o,et){const tt=o.exec(et);return tt==null?void 0:tt.groups}const bytesRegex=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,integerRegex=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,isTupleRegex=/^\(.+?\).*?$/,tupleRegex=/^tuple(?(\[(\d*)\])*)$/;function formatAbiParameter(o){let et=o.type;if(tupleRegex.test(o.type)&&"components"in o){et="(";const tt=o.components.length;for(let rt=0;rt[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isErrorSignature(o){return errorSignatureRegex.test(o)}function execErrorSignature(o){return execTyped(errorSignatureRegex,o)}const eventSignatureRegex=/^event (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)$/;function isEventSignature(o){return eventSignatureRegex.test(o)}function execEventSignature(o){return execTyped(eventSignatureRegex,o)}const functionSignatureRegex=/^function (?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)(?: (?external|public{1}))?(?: (?pure|view|nonpayable|payable{1}))?(?: returns\s?\((?.*?)\))?$/;function isFunctionSignature(o){return functionSignatureRegex.test(o)}function execFunctionSignature(o){return execTyped(functionSignatureRegex,o)}const structSignatureRegex=/^struct (?[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?.*?)\}$/;function isStructSignature(o){return structSignatureRegex.test(o)}function execStructSignature(o){return execTyped(structSignatureRegex,o)}const constructorSignatureRegex=/^constructor\((?.*?)\)(?:\s(?payable{1}))?$/;function isConstructorSignature(o){return constructorSignatureRegex.test(o)}function execConstructorSignature(o){return execTyped(constructorSignatureRegex,o)}const fallbackSignatureRegex=/^fallback\(\) external(?:\s(?payable{1}))?$/;function isFallbackSignature(o){return fallbackSignatureRegex.test(o)}const receiveSignatureRegex=/^receive\(\) external payable$/;function isReceiveSignature(o){return receiveSignatureRegex.test(o)}const eventModifiers=new Set(["indexed"]),functionModifiers=new Set(["calldata","memory","storage"]);class UnknownTypeError extends BaseError$2{constructor({type:et}){super("Unknown type.",{metaMessages:[`Type "${et}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class UnknownSolidityTypeError extends BaseError$2{constructor({type:et}){super("Unknown type.",{metaMessages:[`Type "${et}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class InvalidParameterError extends BaseError$2{constructor({param:et}){super("Invalid ABI parameter.",{details:et}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class SolidityProtectedKeywordError extends BaseError$2{constructor({param:et,name:tt}){super("Invalid ABI parameter.",{details:et,metaMessages:[`"${tt}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class InvalidModifierError extends BaseError$2{constructor({param:et,type:tt,modifier:nt}){super("Invalid ABI parameter.",{details:et,metaMessages:[`Modifier "${nt}" not allowed${tt?` in "${tt}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class InvalidFunctionModifierError extends BaseError$2{constructor({param:et,type:tt,modifier:nt}){super("Invalid ABI parameter.",{details:et,metaMessages:[`Modifier "${nt}" not allowed${tt?` in "${tt}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${nt}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class InvalidAbiTypeParameterError extends BaseError$2{constructor({abiParameter:et}){super("Invalid ABI parameter.",{details:JSON.stringify(et,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}let InvalidSignatureError$1=class extends BaseError$2{constructor({signature:et,type:tt}){super(`Invalid ${tt} signature.`,{details:et}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}};class UnknownSignatureError extends BaseError$2{constructor({signature:et}){super("Unknown signature.",{details:et}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class InvalidStructSignatureError extends BaseError$2{constructor({signature:et}){super("Invalid struct signature.",{details:et,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class CircularReferenceError extends BaseError$2{constructor({type:et}){super("Circular reference detected.",{metaMessages:[`Struct "${et}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class InvalidParenthesisError extends BaseError$2{constructor({current:et,depth:tt}){super("Unbalanced parentheses.",{metaMessages:[`"${et.trim()}" has too many ${tt>0?"opening":"closing"} parentheses.`],details:`Depth "${tt}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function getParameterCacheKey(o,et){return et?`${et}:${o}`:o}const parameterCache=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function parseSignature(o,et={}){if(isFunctionSignature(o)){const tt=execFunctionSignature(o);if(!tt)throw new InvalidSignatureError$1({signature:o,type:"function"});const nt=splitParameters(tt.parameters),rt=[],ot=nt.length;for(let st=0;st[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,abiParameterWithTupleRegex=/^\((?.+?)\)(?(?:\[\d*?\])+?)?(?:\s(?calldata|indexed|memory|storage{1}))?(?:\s(?[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,dynamicIntegerRegex=/^u?int$/;function parseAbiParameter(o,et){var dt,ht;const tt=getParameterCacheKey(o,et==null?void 0:et.type);if(parameterCache.has(tt))return parameterCache.get(tt);const nt=isTupleRegex.test(o),rt=execTyped(nt?abiParameterWithTupleRegex:abiParameterWithoutTupleRegex,o);if(!rt)throw new InvalidParameterError({param:o});if(rt.name&&isSolidityKeyword(rt.name))throw new SolidityProtectedKeywordError({param:o,name:rt.name});const ot=rt.name?{name:rt.name}:{},it=rt.modifier==="indexed"?{indexed:!0}:{},st=(et==null?void 0:et.structs)??{};let at,ct={};if(nt){at="tuple";const pt=splitParameters(rt.type),mt=[],ft=pt.length;for(let yt=0;yt[a-zA-Z$_][a-zA-Z0-9$_]*)(?(?:\[\d*?\])+?)?$/;function resolveStructs(o,et,tt=new Set){const nt=[],rt=o.length;for(let ot=0;ot{const et=typeof o=="string"?o:formatAbiItem(o);return normalizeSignature$1(et)};function toSignatureHash(o){return hashSignature(toSignature(o))}const toEventSelector=toSignatureHash,toFunctionSelector=o=>slice(toSignatureHash(o),0,4);function getAbiItem(o){const{abi:et,args:tt=[],name:nt}=o,rt=isHex(nt,{strict:!1}),ot=et.filter(st=>rt?st.type==="function"?toFunctionSelector(st)===nt:st.type==="event"?toEventSelector(st)===nt:!1:"name"in st&&st.name===nt);if(ot.length===0)return;if(ot.length===1)return ot[0];let it;for(const st of ot){if(!("inputs"in st))continue;if(!tt||tt.length===0){if(!st.inputs||st.inputs.length===0)return st;continue}if(!st.inputs||st.inputs.length===0||st.inputs.length!==tt.length)continue;if(tt.every((ct,lt)=>{const dt="inputs"in st&&st.inputs[lt];return dt?isArgOfType(ct,dt):!1})){if(it&&"inputs"in it&&it.inputs){const ct=getAmbiguousTypes(st.inputs,it.inputs,tt);if(ct)throw new AbiItemAmbiguityError({abiItem:st,type:ct[0]},{abiItem:it,type:ct[1]})}it=st}}return it||ot[0]}function isArgOfType(o,et){const tt=typeof o,nt=et.type;switch(nt){case"address":return isAddress(o,{strict:!1});case"bool":return tt==="boolean";case"function":return tt==="string";case"string":return tt==="string";default:return nt==="tuple"&&"components"in et?Object.values(et.components).every((rt,ot)=>isArgOfType(Object.values(o)[ot],rt)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(nt)?tt==="number"||tt==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(nt)?tt==="string"||o instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(nt)?Array.isArray(o)&&o.every(rt=>isArgOfType(rt,{...et,type:nt.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function getAmbiguousTypes(o,et,tt){for(const nt in o){const rt=o[nt],ot=et[nt];if(rt.type==="tuple"&&ot.type==="tuple"&&"components"in rt&&"components"in ot)return getAmbiguousTypes(rt.components,ot.components,tt[nt]);const it=[rt.type,ot.type];if(it.includes("address")&&it.includes("bytes20")?!0:it.includes("address")&&it.includes("string")?isAddress(tt[nt],{strict:!1}):it.includes("address")&&it.includes("bytes")?isAddress(tt[nt],{strict:!1}):!1)return it}}const docsPath$1="/docs/contract/decodeFunctionResult";function decodeFunctionResult(o){const{abi:et,args:tt,functionName:nt,data:rt}=o;let ot=et[0];if(nt){const st=getAbiItem({abi:et,args:tt,name:nt});if(!st)throw new AbiFunctionNotFoundError(nt,{docsPath:docsPath$1});ot=st}if(ot.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath:docsPath$1});if(!ot.outputs)throw new AbiFunctionOutputsNotFoundError(ot.name,{docsPath:docsPath$1});const it=decodeAbiParameters(ot.outputs,rt);if(it&&it.length>1)return it;if(it&&it.length===1)return it[0]}const docsPath="/docs/contract/encodeFunctionData";function prepareEncodeFunctionData(o){const{abi:et,args:tt,functionName:nt}=o;let rt=et[0];if(nt){const ot=getAbiItem({abi:et,args:tt,name:nt});if(!ot)throw new AbiFunctionNotFoundError(nt,{docsPath});rt=ot}if(rt.type!=="function")throw new AbiFunctionNotFoundError(void 0,{docsPath});return{abi:[rt],functionName:toFunctionSelector(formatAbiItem$1(rt))}}function encodeFunctionData(o){const{args:et}=o,{abi:tt,functionName:nt}=(()=>{var st;return o.abi.length===1&&((st=o.functionName)!=null&&st.startsWith("0x"))?o:prepareEncodeFunctionData(o)})(),rt=tt[0],ot=nt,it="inputs"in rt&&rt.inputs?encodeAbiParameters(rt.inputs,et??[]):void 0;return concatHex([ot,it??"0x"])}function getChainContractAddress({blockNumber:o,chain:et,contract:tt}){var rt;const nt=(rt=et==null?void 0:et.contracts)==null?void 0:rt[tt];if(!nt)throw new ChainDoesNotSupportContract({chain:et,contract:{name:tt}});if(o&&nt.blockCreated&&nt.blockCreated>o)throw new ChainDoesNotSupportContract({blockNumber:o,chain:et,contract:{name:tt,blockCreated:nt.blockCreated}});return nt.address}const panicReasons={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},solidityError={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},solidityPanic={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function decodeErrorResult(o){const{abi:et,data:tt}=o,nt=slice(tt,0,4);if(nt==="0x")throw new AbiDecodingZeroDataError;const ot=[...et||[],solidityError,solidityPanic].find(it=>it.type==="error"&&nt===toFunctionSelector(formatAbiItem$1(it)));if(!ot)throw new AbiErrorSignatureNotFoundError(nt,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:ot,args:"inputs"in ot&&ot.inputs&&ot.inputs.length>0?decodeAbiParameters(ot.inputs,slice(tt,4)):void 0,errorName:ot.name}}function formatAbiItemWithArgs({abiItem:o,args:et,includeFunctionName:tt=!0,includeName:nt=!1}){if("name"in o&&"inputs"in o&&o.inputs)return`${tt?o.name:""}(${o.inputs.map((rt,ot)=>`${nt&&rt.name?`${rt.name}: `:""}${typeof et[ot]=="object"?stringify$2(et[ot]):et[ot]}`).join(", ")})`}class CallExecutionError extends BaseError$3{constructor(et,{account:tt,docsPath:nt,chain:rt,data:ot,gas:it,gasPrice:st,maxFeePerGas:at,maxPriorityFeePerGas:ct,nonce:lt,to:dt,value:ht,stateOverride:pt}){var yt;const mt=tt?parseAccount(tt):void 0;let ft=prettyPrint({from:mt==null?void 0:mt.address,to:dt,value:typeof ht<"u"&&`${formatEther(ht)} ${((yt=rt==null?void 0:rt.nativeCurrency)==null?void 0:yt.symbol)||"ETH"}`,data:ot,gas:it,gasPrice:typeof st<"u"&&`${formatGwei(st)} gwei`,maxFeePerGas:typeof at<"u"&&`${formatGwei(at)} gwei`,maxPriorityFeePerGas:typeof ct<"u"&&`${formatGwei(ct)} gwei`,nonce:lt});pt&&(ft+=` ${prettyStateOverride(pt)}`),super(et.shortMessage,{cause:et,docsPath:nt,metaMessages:[...et.metaMessages?[...et.metaMessages," "]:[],"Raw Call Arguments:",ft].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=et}}class ContractFunctionExecutionError extends BaseError$3{constructor(et,{abi:tt,args:nt,contractAddress:rt,docsPath:ot,functionName:it,sender:st}){const at=getAbiItem({abi:tt,args:nt,name:it}),ct=at?formatAbiItemWithArgs({abiItem:at,args:nt,includeFunctionName:!1,includeName:!1}):void 0,lt=at?formatAbiItem$1(at,{includeName:!0}):void 0,dt=prettyPrint({address:rt&&getContractAddress(rt),function:lt,args:ct&&ct!=="()"&&`${[...Array((it==null?void 0:it.length)??0).keys()].map(()=>" ").join("")}${ct}`,sender:st});super(et.shortMessage||`An unknown error occurred while executing the contract function "${it}".`,{cause:et,docsPath:ot,metaMessages:[...et.metaMessages?[...et.metaMessages," "]:[],dt&&"Contract Call:",dt].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=tt,this.args=nt,this.cause=et,this.contractAddress=rt,this.functionName=it,this.sender=st}}class ContractFunctionRevertedError extends BaseError$3{constructor({abi:et,data:tt,functionName:nt,message:rt}){let ot,it,st,at;if(tt&&tt!=="0x")try{it=decodeErrorResult({abi:et,data:tt});const{abiItem:lt,errorName:dt,args:ht}=it;if(dt==="Error")at=ht[0];else if(dt==="Panic"){const[pt]=ht;at=panicReasons[pt]}else{const pt=lt?formatAbiItem$1(lt,{includeName:!0}):void 0,mt=lt&&ht?formatAbiItemWithArgs({abiItem:lt,args:ht,includeFunctionName:!1,includeName:!1}):void 0;st=[pt?`Error: ${pt}`:"",mt&&mt!=="()"?` ${[...Array((dt==null?void 0:dt.length)??0).keys()].map(()=>" ").join("")}${mt}`:""]}}catch(lt){ot=lt}else rt&&(at=rt);let ct;ot instanceof AbiErrorSignatureNotFoundError&&(ct=ot.signature,st=[`Unable to decode signature "${ct}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${ct}.`]),super(at&&at!=="execution reverted"||ct?[`The contract function "${nt}" reverted with the following ${ct?"signature":"reason"}:`,at||ct].join(` -`):`The contract function "${nt}" reverted.`,{cause:ot,metaMessages:st,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=it,this.reason=at,this.signature=ct}}class ContractFunctionZeroDataError extends BaseError$3{constructor({functionName:et}){super(`The contract function "${et}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${et}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class CounterfactualDeploymentFailedError extends BaseError$3{constructor({factory:et}){super(`Deployment for counterfactual contract call failed${et?` for factory "${et}".`:""}`,{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class RawContractError extends BaseError$3{constructor({data:et,message:tt}){super(tt||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=et}}function isNullUniversalResolverError(o,et){var nt,rt,ot,it,st,at;if(!(o instanceof BaseError$3))return!1;const tt=o.walk(ct=>ct instanceof ContractFunctionRevertedError);return tt instanceof ContractFunctionRevertedError?!!(((nt=tt.data)==null?void 0:nt.errorName)==="ResolverNotFound"||((rt=tt.data)==null?void 0:rt.errorName)==="ResolverWildcardNotSupported"||((ot=tt.data)==null?void 0:ot.errorName)==="ResolverNotContract"||((it=tt.data)==null?void 0:it.errorName)==="ResolverError"||((st=tt.data)==null?void 0:st.errorName)==="HttpError"||(at=tt.reason)!=null&&at.includes("Wildcard on non-extended resolvers is not supported")||et==="reverse"&&tt.reason===panicReasons[50]):!1}function encodedLabelToLabelhash(o){if(o.length!==66||o.indexOf("[")!==0||o.indexOf("]")!==65)return null;const et=`0x${o.slice(1,65)}`;return isHex(et)?et:null}function namehash(o){let et=new Uint8Array(32).fill(0);if(!o)return bytesToHex$4(et);const tt=o.split(".");for(let nt=tt.length-1;nt>=0;nt-=1){const rt=encodedLabelToLabelhash(tt[nt]),ot=rt?toBytes$3(rt):keccak256$1(stringToBytes(tt[nt]),"bytes");et=keccak256$1(concat$3([et,ot]),"bytes")}return bytesToHex$4(et)}function encodeLabelhash(o){return`[${o.slice(2)}]`}function labelhash(o){const et=new Uint8Array(32).fill(0);return o?encodedLabelToLabelhash(o)||keccak256$1(stringToBytes(o)):bytesToHex$4(et)}function packetToBytes(o){const et=o.replace(/^\.|\.$/gm,"");if(et.length===0)return new Uint8Array(1);const tt=new Uint8Array(stringToBytes(et).byteLength+2);let nt=0;const rt=et.split(".");for(let ot=0;ot255&&(it=stringToBytes(encodeLabelhash(labelhash(rt[ot])))),tt[nt]=it.length,tt.set(it,nt+1),nt+=it.length+1}return tt.byteLength!==nt+1?tt.slice(0,nt+1):tt}const EXECUTION_REVERTED_ERROR_CODE=3;function getContractError(o,{abi:et,address:tt,args:nt,docsPath:rt,functionName:ot,sender:it}){const{code:st,data:at,message:ct,shortMessage:lt}=o instanceof RawContractError?o:o instanceof BaseError$3?o.walk(ht=>"data"in ht)||o.walk():{},dt=o instanceof AbiDecodingZeroDataError?new ContractFunctionZeroDataError({functionName:ot}):[EXECUTION_REVERTED_ERROR_CODE,InternalRpcError.code].includes(st)&&(at||ct||lt)?new ContractFunctionRevertedError({abi:et,data:typeof at=="object"?at.data:at,functionName:ot,message:lt??ct}):o;return new ContractFunctionExecutionError(dt,{abi:et,args:nt,contractAddress:tt,docsPath:rt,functionName:ot,sender:it})}const aggregate3Signature="0x82ad56cb",deploylessCallViaBytecodeBytecode="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",deploylessCallViaFactoryBytecode="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe";function getCallError(o,{docsPath:et,...tt}){const nt=(()=>{const rt=getNodeError(o,tt);return rt instanceof UnknownNodeError?o:rt})();return new CallExecutionError(nt,{docsPath:et,...tt})}function withResolvers(){let o=()=>{},et=()=>{};return{promise:new Promise((nt,rt)=>{o=nt,et=rt}),resolve:o,reject:et}}const schedulerCache=new Map;function createBatchScheduler({fn:o,id:et,shouldSplitBatch:tt,wait:nt=0,sort:rt}){const ot=async()=>{const lt=at();it();const dt=lt.map(({args:ht})=>ht);dt.length!==0&&o(dt).then(ht=>{rt&&Array.isArray(ht)&&ht.sort(rt);for(let pt=0;pt{for(let pt=0;ptschedulerCache.delete(et),st=()=>at().map(({args:lt})=>lt),at=()=>schedulerCache.get(et)||[],ct=lt=>schedulerCache.set(et,[...at(),lt]);return{flush:it,async schedule(lt){const{promise:dt,resolve:ht,reject:pt}=withResolvers();return(tt==null?void 0:tt([...st(),lt]))&&ot(),at().length>0?(ct({args:lt,resolve:ht,reject:pt}),dt):(ct({args:lt,resolve:ht,reject:pt}),setTimeout(ot,nt),dt)}}}async function call(o,et){var jt,Ot,Bt,zt;const{account:tt=o.account,batch:nt=!!((jt=o.batch)!=null&&jt.multicall),blockNumber:rt,blockTag:ot="latest",accessList:it,blobs:st,code:at,data:ct,factory:lt,factoryData:dt,gas:ht,gasPrice:pt,maxFeePerBlobGas:mt,maxFeePerGas:ft,maxPriorityFeePerGas:yt,nonce:gt,to:xt,value:vt,stateOverride:bt,...Et}=et,wt=tt?parseAccount(tt):void 0;if(at&&(lt||dt))throw new BaseError$3("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(at&&xt)throw new BaseError$3("Cannot provide both `code` & `to` as parameters.");const kt=at&&ct,It=lt&&dt&&xt&&ct,Rt=kt||It,Pt=kt?toDeploylessCallViaBytecodeData({code:at,data:ct}):It?toDeploylessCallViaFactoryData({data:ct,factory:lt,factoryData:dt,to:xt}):ct;try{assertRequest(et);const Yt=(rt?numberToHex(rt):void 0)||ot,Ht=serializeStateOverride(bt),Ut=(zt=(Bt=(Ot=o.chain)==null?void 0:Ot.formatters)==null?void 0:Bt.transactionRequest)==null?void 0:zt.format,Lt=(Ut||formatTransactionRequest)({...extract$1(Et,{format:Ut}),from:wt==null?void 0:wt.address,accessList:it,blobs:st,data:Pt,gas:ht,gasPrice:pt,maxFeePerBlobGas:mt,maxFeePerGas:ft,maxPriorityFeePerGas:yt,nonce:gt,to:Rt?void 0:xt,value:vt});if(nt&&shouldPerformMulticall({request:Lt})&&!Ht)try{return await scheduleMulticall(o,{...Lt,blockNumber:rt,blockTag:ot})}catch(Qt){if(!(Qt instanceof ClientChainNotConfiguredError)&&!(Qt instanceof ChainDoesNotSupportContract))throw Qt}const Zt=await o.request({method:"eth_call",params:Ht?[Lt,Yt,Ht]:[Lt,Yt]});return Zt==="0x"?{data:void 0}:{data:Zt}}catch(Ft){const Yt=getRevertErrorData(Ft),{offchainLookup:Ht,offchainLookupSignature:Ut}=await __vitePreload(async()=>{const{offchainLookup:qt,offchainLookupSignature:Lt}=await import("./ccip-DU5pFHxb.js");return{offchainLookup:qt,offchainLookupSignature:Lt}},[]);if(o.ccipRead!==!1&&(Yt==null?void 0:Yt.slice(0,10))===Ut&&xt)return{data:await Ht(o,{data:Yt,to:xt})};throw Rt&&(Yt==null?void 0:Yt.slice(0,10))==="0x101bb98d"?new CounterfactualDeploymentFailedError({factory:lt}):getCallError(Ft,{...et,account:wt,chain:o.chain})}}function shouldPerformMulticall({request:o}){const{data:et,to:tt,...nt}=o;return!(!et||et.startsWith(aggregate3Signature)||!tt||Object.values(nt).filter(rt=>typeof rt<"u").length>0)}async function scheduleMulticall(o,et){var ft;const{batchSize:tt=1024,wait:nt=0}=typeof((ft=o.batch)==null?void 0:ft.multicall)=="object"?o.batch.multicall:{},{blockNumber:rt,blockTag:ot="latest",data:it,multicallAddress:st,to:at}=et;let ct=st;if(!ct){if(!o.chain)throw new ClientChainNotConfiguredError;ct=getChainContractAddress({blockNumber:rt,chain:o.chain,contract:"multicall3"})}const dt=(rt?numberToHex(rt):void 0)||ot,{schedule:ht}=createBatchScheduler({id:`${o.uid}.${dt}`,wait:nt,shouldSplitBatch(yt){return yt.reduce((xt,{data:vt})=>xt+(vt.length-2),0)>tt*2},fn:async yt=>{const gt=yt.map(bt=>({allowFailure:!0,callData:bt.data,target:bt.to})),xt=encodeFunctionData({abi:multicall3Abi,args:[gt],functionName:"aggregate3"}),vt=await o.request({method:"eth_call",params:[{data:xt,to:ct},dt]});return decodeFunctionResult({abi:multicall3Abi,args:[gt],functionName:"aggregate3",data:vt||"0x"})}}),[{returnData:pt,success:mt}]=await ht({data:it,to:at});if(!mt)throw new RawContractError({data:pt});return pt==="0x"?{data:void 0}:{data:pt}}function toDeploylessCallViaBytecodeData(o){const{code:et,data:tt}=o;return encodeDeployData({abi:parseAbi(["constructor(bytes, bytes)"]),bytecode:deploylessCallViaBytecodeBytecode,args:[et,tt]})}function toDeploylessCallViaFactoryData(o){const{data:et,factory:tt,factoryData:nt,to:rt}=o;return encodeDeployData({abi:parseAbi(["constructor(address, bytes, address, bytes)"]),bytecode:deploylessCallViaFactoryBytecode,args:[rt,et,tt,nt]})}function getRevertErrorData(o){var tt;if(!(o instanceof BaseError$3))return;const et=o.walk();return typeof(et==null?void 0:et.data)=="object"?(tt=et.data)==null?void 0:tt.data:et.data}async function readContract$1(o,et){const{abi:tt,address:nt,args:rt,functionName:ot,...it}=et,st=encodeFunctionData({abi:tt,args:rt,functionName:ot});try{const{data:at}=await getAction$1(o,call,"call")({...it,data:st,to:nt});return decodeFunctionResult({abi:tt,args:rt,functionName:ot,data:at||"0x"})}catch(at){throw getContractError(at,{abi:tt,address:nt,args:rt,docsPath:"/docs/contract/readContract",functionName:ot})}}async function getEnsAddress$1(o,{blockNumber:et,blockTag:tt,coinType:nt,name:rt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!o.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:et,chain:o.chain,contract:"ensUniversalResolver"})}try{const ct=encodeFunctionData({abi:addressResolverAbi,functionName:"addr",...nt!=null?{args:[namehash(rt),BigInt(nt)]}:{args:[namehash(rt)]}}),lt={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(rt)),ct],blockNumber:et,blockTag:tt},dt=getAction$1(o,readContract$1,"readContract"),ht=ot?await dt({...lt,args:[...lt.args,ot]}):await dt(lt);if(ht[0]==="0x")return null;const pt=decodeFunctionResult({abi:addressResolverAbi,args:nt!=null?[namehash(rt),BigInt(nt)]:void 0,functionName:"addr",data:ht[0]});return pt==="0x"||trim$1(pt)==="0x00"?null:pt}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}class EnsAvatarInvalidMetadataError extends BaseError$3{constructor({data:et}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(et)}`],name:"EnsAvatarInvalidMetadataError"})}}class EnsAvatarInvalidNftUriError extends BaseError$3{constructor({reason:et}){super(`ENS NFT avatar URI is invalid. ${et}`,{name:"EnsAvatarInvalidNftUriError"})}}class EnsAvatarUriResolutionError extends BaseError$3{constructor({uri:et}){super(`Unable to resolve ENS avatar URI "${et}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class EnsAvatarUnsupportedNamespaceError extends BaseError$3{constructor({namespace:et}){super(`ENS NFT avatar namespace "${et}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const networkRegex=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ipfsHashRegex=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,base64Regex=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,dataURIRegex=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function isImageUri(o){try{const et=await fetch(o,{method:"HEAD"});if(et.status===200){const tt=et.headers.get("content-type");return tt==null?void 0:tt.startsWith("image/")}return!1}catch(et){return typeof et=="object"&&typeof et.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(tt=>{const nt=new Image;nt.onload=()=>{tt(!0)},nt.onerror=()=>{tt(!1)},nt.src=o})}}function getGateway(o,et){return o?o.endsWith("/")?o.slice(0,-1):o:et}function resolveAvatarUri({uri:o,gatewayUrls:et}){const tt=base64Regex.test(o);if(tt)return{uri:o,isOnChain:!0,isEncoded:tt};const nt=getGateway(et==null?void 0:et.ipfs,"https://ipfs.io"),rt=getGateway(et==null?void 0:et.arweave,"https://arweave.net"),ot=o.match(networkRegex),{protocol:it,subpath:st,target:at,subtarget:ct=""}=(ot==null?void 0:ot.groups)||{},lt=it==="ipns:/"||st==="ipns/",dt=it==="ipfs:/"||st==="ipfs/"||ipfsHashRegex.test(o);if(o.startsWith("http")&&!lt&&!dt){let pt=o;return et!=null&&et.arweave&&(pt=o.replace(/https:\/\/arweave.net/g,et==null?void 0:et.arweave)),{uri:pt,isOnChain:!1,isEncoded:!1}}if((lt||dt)&&at)return{uri:`${nt}/${lt?"ipns":"ipfs"}/${at}${ct}`,isOnChain:!1,isEncoded:!1};if(it==="ar:/"&&at)return{uri:`${rt}/${at}${ct||""}`,isOnChain:!1,isEncoded:!1};let ht=o.replace(dataURIRegex,"");if(ht.startsWith("rt.json());return await parseAvatarUri({gatewayUrls:o,uri:getJsonImage(tt)})}catch{throw new EnsAvatarUriResolutionError({uri:et})}}async function parseAvatarUri({gatewayUrls:o,uri:et}){const{uri:tt,isOnChain:nt}=resolveAvatarUri({uri:et,gatewayUrls:o});if(nt||await isImageUri(tt))return tt;throw new EnsAvatarUriResolutionError({uri:et})}function parseNftUri(o){let et=o;et.startsWith("did:nft:")&&(et=et.replace("did:nft:","").replace(/_/g,"/"));const[tt,nt,rt]=et.split("/"),[ot,it]=tt.split(":"),[st,at]=nt.split(":");if(!ot||ot.toLowerCase()!=="eip155")throw new EnsAvatarInvalidNftUriError({reason:"Only EIP-155 supported"});if(!it)throw new EnsAvatarInvalidNftUriError({reason:"Chain ID not found"});if(!at)throw new EnsAvatarInvalidNftUriError({reason:"Contract address not found"});if(!rt)throw new EnsAvatarInvalidNftUriError({reason:"Token ID not found"});if(!st)throw new EnsAvatarInvalidNftUriError({reason:"ERC namespace not found"});return{chainID:Number.parseInt(it),namespace:st.toLowerCase(),contractAddress:at,tokenID:rt}}async function getNftTokenUri(o,{nft:et}){if(et.namespace==="erc721")return readContract$1(o,{address:et.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(et.tokenID)]});if(et.namespace==="erc1155")return readContract$1(o,{address:et.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(et.tokenID)]});throw new EnsAvatarUnsupportedNamespaceError({namespace:et.namespace})}async function parseAvatarRecord(o,{gatewayUrls:et,record:tt}){return/eip155:/i.test(tt)?parseNftAvatarUri(o,{gatewayUrls:et,record:tt}):parseAvatarUri({uri:tt,gatewayUrls:et})}async function parseNftAvatarUri(o,{gatewayUrls:et,record:tt}){const nt=parseNftUri(tt),rt=await getNftTokenUri(o,{nft:nt}),{uri:ot,isOnChain:it,isEncoded:st}=resolveAvatarUri({uri:rt,gatewayUrls:et});if(it&&(ot.includes("data:application/json;base64,")||ot.startsWith("{"))){const ct=st?atob(ot.replace("data:application/json;base64,","")):ot,lt=JSON.parse(ct);return parseAvatarUri({uri:getJsonImage(lt),gatewayUrls:et})}let at=nt.tokenID;return nt.namespace==="erc1155"&&(at=at.replace("0x","").padStart(64,"0")),getMetadataAvatarUri({gatewayUrls:et,uri:ot.replace(/(?:0x)?{id}/,at)})}async function getEnsText(o,{blockNumber:et,blockTag:tt,name:nt,key:rt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!o.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:et,chain:o.chain,contract:"ensUniversalResolver"})}try{const ct={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(nt)),encodeFunctionData({abi:textResolverAbi,functionName:"text",args:[namehash(nt),rt]})],blockNumber:et,blockTag:tt},lt=getAction$1(o,readContract$1,"readContract"),dt=ot?await lt({...ct,args:[...ct.args,ot]}):await lt(ct);if(dt[0]==="0x")return null;const ht=decodeFunctionResult({abi:textResolverAbi,functionName:"text",data:dt[0]});return ht===""?null:ht}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}async function getEnsAvatar$1(o,{blockNumber:et,blockTag:tt,assetGatewayUrls:nt,name:rt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){const at=await getAction$1(o,getEnsText,"getEnsText")({blockNumber:et,blockTag:tt,key:"avatar",name:rt,universalResolverAddress:st,gatewayUrls:ot,strict:it});if(!at)return null;try{return await parseAvatarRecord(o,{record:at,gatewayUrls:nt})}catch{return null}}async function getEnsName$1(o,{address:et,blockNumber:tt,blockTag:nt,gatewayUrls:rt,strict:ot,universalResolverAddress:it}){let st=it;if(!st){if(!o.chain)throw new Error("client chain not configured. universalResolverAddress is required.");st=getChainContractAddress({blockNumber:tt,chain:o.chain,contract:"ensUniversalResolver"})}const at=`${et.toLowerCase().substring(2)}.addr.reverse`;try{const ct={address:st,abi:universalResolverReverseAbi,functionName:"reverse",args:[toHex(packetToBytes(at))],blockNumber:tt,blockTag:nt},lt=getAction$1(o,readContract$1,"readContract"),[dt,ht]=rt?await lt({...ct,args:[...ct.args,rt]}):await lt(ct);return et.toLowerCase()!==ht.toLowerCase()?null:dt}catch(ct){if(ot)throw ct;if(isNullUniversalResolverError(ct,"reverse"))return null;throw ct}}const promiseCache$1=new Map,responseCache=new Map;function getCache(o){const et=(rt,ot)=>({clear:()=>ot.delete(rt),get:()=>ot.get(rt),set:it=>ot.set(rt,it)}),tt=et(o,promiseCache$1),nt=et(o,responseCache);return{clear:()=>{tt.clear(),nt.clear()},promise:tt,response:nt}}async function withCache(o,{cacheKey:et,cacheTime:tt=Number.POSITIVE_INFINITY}){const nt=getCache(et),rt=nt.response.get();if(rt&&tt>0&&new Date().getTime()-rt.created.getTime()`blockNumber.${o}`;async function getBlockNumber$1(o,{cacheTime:et=o.cacheTime}={}){const tt=await withCache(()=>o.request({method:"eth_blockNumber"}),{cacheKey:cacheKey(o.uid),cacheTime:et});return BigInt(tt)}function formatLog(o,{args:et,eventName:tt}={}){return{...o,blockHash:o.blockHash?o.blockHash:null,blockNumber:o.blockNumber?BigInt(o.blockNumber):null,logIndex:o.logIndex?Number(o.logIndex):null,transactionHash:o.transactionHash?o.transactionHash:null,transactionIndex:o.transactionIndex?Number(o.transactionIndex):null,...tt?{args:et,eventName:tt}:{}}}const receiptStatuses={"0x0":"reverted","0x1":"success"};function formatTransactionReceipt(o){const et={...o,blockNumber:o.blockNumber?BigInt(o.blockNumber):null,contractAddress:o.contractAddress?o.contractAddress:null,cumulativeGasUsed:o.cumulativeGasUsed?BigInt(o.cumulativeGasUsed):null,effectiveGasPrice:o.effectiveGasPrice?BigInt(o.effectiveGasPrice):null,gasUsed:o.gasUsed?BigInt(o.gasUsed):null,logs:o.logs?o.logs.map(tt=>formatLog(tt)):null,to:o.to?o.to:null,transactionIndex:o.transactionIndex?hexToNumber$2(o.transactionIndex):null,status:o.status?receiptStatuses[o.status]:null,type:o.type?transactionType[o.type]||o.type:null};return o.blobGasPrice&&(et.blobGasPrice=BigInt(o.blobGasPrice)),o.blobGasUsed&&(et.blobGasUsed=BigInt(o.blobGasUsed)),et}const defineTransactionReceipt=defineFormatter("transactionReceipt",formatTransactionReceipt);async function multicall$1(o,et){var yt;const{allowFailure:tt=!0,batchSize:nt,blockNumber:rt,blockTag:ot,multicallAddress:it,stateOverride:st}=et,at=et.contracts,ct=nt??(typeof((yt=o.batch)==null?void 0:yt.multicall)=="object"&&o.batch.multicall.batchSize||1024);let lt=it;if(!lt){if(!o.chain)throw new Error("client chain not configured. multicallAddress is required.");lt=getChainContractAddress({blockNumber:rt,chain:o.chain,contract:"multicall3"})}const dt=[[]];let ht=0,pt=0;for(let gt=0;gt0&&pt>ct&&dt[ht].length>0&&(ht++,pt=(wt.length-2)/2,dt[ht]=[]),dt[ht]=[...dt[ht],{allowFailure:!0,callData:wt,target:vt}]}catch(wt){const kt=getContractError(wt,{abi:xt,address:vt,args:bt,docsPath:"/docs/contract/multicall",functionName:Et});if(!tt)throw kt;dt[ht]=[...dt[ht],{allowFailure:!0,callData:"0x",target:vt}]}}const mt=await Promise.allSettled(dt.map(gt=>getAction$1(o,readContract$1,"readContract")({abi:multicall3Abi,address:lt,args:[gt],blockNumber:rt,blockTag:ot,functionName:"aggregate3",stateOverride:st}))),ft=[];for(let gt=0;gtlistenersCache.get(o)||[],ot=()=>{const lt=rt();listenersCache.set(o,lt.filter(dt=>dt.id!==nt))},it=()=>{const lt=cleanupCache.get(o);rt().length===1&<&<(),ot()},st=rt();if(listenersCache.set(o,[...st,{id:nt,fns:et}]),st&&st.length>0)return it;const at={};for(const lt in et)at[lt]=(...dt)=>{var pt,mt;const ht=rt();if(ht.length!==0)for(const ft of ht)(mt=(pt=ft.fns)[lt])==null||mt.call(pt,...dt)};const ct=tt(at);return typeof ct=="function"&&cleanupCache.set(o,ct),it}async function wait$1(o){return new Promise(et=>setTimeout(et,o))}function poll(o,{emitOnBegin:et,initialWaitTime:tt,interval:nt}){let rt=!0;const ot=()=>rt=!1;return(async()=>{let st;et&&(st=await o({unpoll:ot}));const at=await(tt==null?void 0:tt(st))??nt;await wait$1(at);const ct=async()=>{rt&&(await o({unpoll:ot}),await wait$1(nt),ct())};ct()})(),ot}function watchBlockNumber$1(o,{emitOnBegin:et=!1,emitMissed:tt=!1,onBlockNumber:nt,onError:rt,poll:ot,pollingInterval:it=o.pollingInterval}){const st=typeof ot<"u"?ot:!(o.transport.type==="webSocket"||o.transport.type==="fallback"&&o.transport.transports[0].config.type==="webSocket");let at;return st?(()=>{const dt=stringify$2(["watchBlockNumber",o.uid,et,tt,it]);return observe(dt,{onBlockNumber:nt,onError:rt},ht=>poll(async()=>{var pt;try{const mt=await getAction$1(o,getBlockNumber$1,"getBlockNumber")({cacheTime:0});if(at){if(mt===at)return;if(mt-at>1&&tt)for(let ft=at+1n;ftat)&&(ht.onBlockNumber(mt,at),at=mt)}catch(mt){(pt=ht.onError)==null||pt.call(ht,mt)}},{emitOnBegin:et,interval:it}))})():(()=>{const dt=stringify$2(["watchBlockNumber",o.uid,et,tt]);return observe(dt,{onBlockNumber:nt,onError:rt},ht=>{let pt=!0,mt=()=>pt=!1;return(async()=>{try{const ft=(()=>{if(o.transport.type==="fallback"){const gt=o.transport.transports.find(xt=>xt.config.type==="webSocket");return gt?gt.value:o.transport}return o.transport})(),{unsubscribe:yt}=await ft.subscribe({params:["newHeads"],onData(gt){var vt;if(!pt)return;const xt=hexToBigInt((vt=gt.result)==null?void 0:vt.number);ht.onBlockNumber(xt,at),at=xt},onError(gt){var xt;(xt=ht.onError)==null||xt.call(ht,gt)}});mt=yt,pt||mt()}catch(ft){rt==null||rt(ft)}})(),()=>mt()})})()}const promiseCache=new LruMap(8192);function withDedupe(o,{enabled:et=!0,id:tt}){if(!et||!tt)return o();if(promiseCache.get(tt))return promiseCache.get(tt);const nt=o().finally(()=>promiseCache.delete(tt));return promiseCache.set(tt,nt),nt}function withRetry(o,{delay:et=100,retryCount:tt=2,shouldRetry:nt=()=>!0}={}){return new Promise((rt,ot)=>{const it=async({count:st=0}={})=>{const at=async({error:ct})=>{const lt=typeof et=="function"?et({count:st,error:ct}):et;lt&&await wait$1(lt),it({count:st+1})};try{const ct=await o();rt(ct)}catch(ct){if(st{const{dedupe:rt=!1,retryDelay:ot=150,retryCount:it=3,uid:st}={...et,...nt},at=rt?keccak256$1(stringToHex(`${st}.${stringify$2(tt)}`)):void 0;return withDedupe(()=>withRetry(async()=>{try{return await o(tt)}catch(ct){const lt=ct;switch(lt.code){case ParseRpcError.code:throw new ParseRpcError(lt);case InvalidRequestRpcError.code:throw new InvalidRequestRpcError(lt);case MethodNotFoundRpcError.code:throw new MethodNotFoundRpcError(lt,{method:tt.method});case InvalidParamsRpcError.code:throw new InvalidParamsRpcError(lt);case InternalRpcError.code:throw new InternalRpcError(lt);case InvalidInputRpcError.code:throw new InvalidInputRpcError(lt);case ResourceNotFoundRpcError.code:throw new ResourceNotFoundRpcError(lt);case ResourceUnavailableRpcError.code:throw new ResourceUnavailableRpcError(lt);case TransactionRejectedRpcError.code:throw new TransactionRejectedRpcError(lt);case MethodNotSupportedRpcError.code:throw new MethodNotSupportedRpcError(lt,{method:tt.method});case LimitExceededRpcError.code:throw new LimitExceededRpcError(lt);case JsonRpcVersionUnsupportedError.code:throw new JsonRpcVersionUnsupportedError(lt);case UserRejectedRequestError.code:throw new UserRejectedRequestError(lt);case UnauthorizedProviderError.code:throw new UnauthorizedProviderError(lt);case UnsupportedProviderMethodError.code:throw new UnsupportedProviderMethodError(lt);case ProviderDisconnectedError.code:throw new ProviderDisconnectedError(lt);case ChainDisconnectedError.code:throw new ChainDisconnectedError(lt);case SwitchChainError.code:throw new SwitchChainError(lt);case 5e3:throw new UserRejectedRequestError(lt);default:throw ct instanceof BaseError$3?ct:new UnknownRpcError(lt)}}},{delay:({count:ct,error:lt})=>{var dt;if(lt&< instanceof HttpRequestError){const ht=(dt=lt==null?void 0:lt.headers)==null?void 0:dt.get("Retry-After");if(ht!=null&&ht.match(/\d/))return Number.parseInt(ht)*1e3}return~~(1<shouldRetry(ct)}),{enabled:rt,id:at})}}function shouldRetry(o){return"code"in o&&typeof o.code=="number"?o.code===-1||o.code===LimitExceededRpcError.code||o.code===InternalRpcError.code:o instanceof HttpRequestError&&o.status?o.status===403||o.status===408||o.status===413||o.status===429||o.status===500||o.status===502||o.status===503||o.status===504:!0}function defineChain(o){return{formatters:void 0,fees:void 0,serializers:void 0,...o}}function withTimeout(o,{errorInstance:et=new Error("timed out"),timeout:tt,signal:nt}){return new Promise((rt,ot)=>{(async()=>{let it;try{const st=new AbortController;tt>0&&(it=setTimeout(()=>{nt?st.abort():ot(et)},tt)),rt(await o({signal:(st==null?void 0:st.signal)||null}))}catch(st){(st==null?void 0:st.name)==="AbortError"&&ot(et),ot(st)}finally{clearTimeout(it)}})()})}function createIdStore(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const idCache=createIdStore();function getHttpRpcClient(o,et={}){return{async request(tt){var dt;const{body:nt,onRequest:rt=et.onRequest,onResponse:ot=et.onResponse,timeout:it=et.timeout??1e4}=tt,st={...et.fetchOptions??{},...tt.fetchOptions??{}},{headers:at,method:ct,signal:lt}=st;try{const ht=await withTimeout(async({signal:mt})=>{const ft={...st,body:Array.isArray(nt)?stringify$2(nt.map(vt=>({jsonrpc:"2.0",id:vt.id??idCache.take(),...vt}))):stringify$2({jsonrpc:"2.0",id:nt.id??idCache.take(),...nt}),headers:{"Content-Type":"application/json",...at},method:ct||"POST",signal:lt||(it>0?mt:null)},yt=new Request(o,ft),gt=await(rt==null?void 0:rt(yt,ft))??{...ft,url:o};return await fetch(gt.url??o,gt)},{errorInstance:new TimeoutError$4({body:nt,url:o}),timeout:it,signal:!0});ot&&await ot(ht);let pt;if((dt=ht.headers.get("Content-Type"))!=null&&dt.startsWith("application/json"))pt=await ht.json();else{pt=await ht.text();try{pt=JSON.parse(pt||"{}")}catch(mt){if(ht.ok)throw mt;pt={error:pt}}}if(!ht.ok)throw new HttpRequestError({body:nt,details:stringify$2(pt.error)||ht.statusText,headers:ht.headers,status:ht.status,url:o});return pt}catch(ht){throw ht instanceof HttpRequestError||ht instanceof TimeoutError$4?ht:new HttpRequestError({body:nt,cause:ht,url:o})}}}}function assertTransactionEIP7702(o){const{authorizationList:et}=o;if(et)for(const tt of et){const{contractAddress:nt,chainId:rt}=tt;if(!isAddress(nt))throw new InvalidAddressError({address:nt});if(rt<0)throw new InvalidChainIdError({chainId:rt})}assertTransactionEIP1559(o)}function assertTransactionEIP4844(o){const{blobVersionedHashes:et}=o;if(et){if(et.length===0)throw new EmptyBlobError;for(const tt of et){const nt=size$2(tt),rt=hexToNumber$2(slice(tt,0,1));if(nt!==32)throw new InvalidVersionedHashSizeError({hash:tt,size:nt});if(rt!==versionedHashVersionKzg)throw new InvalidVersionedHashVersionError({hash:tt,version:rt})}}assertTransactionEIP1559(o)}function assertTransactionEIP1559(o){const{chainId:et,maxPriorityFeePerGas:tt,maxFeePerGas:nt,to:rt}=o;if(et<=0)throw new InvalidChainIdError({chainId:et});if(rt&&!isAddress(rt))throw new InvalidAddressError({address:rt});if(nt&&nt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:nt});if(tt&&nt&&tt>nt)throw new TipAboveFeeCapError({maxFeePerGas:nt,maxPriorityFeePerGas:tt})}function assertTransactionEIP2930(o){const{chainId:et,maxPriorityFeePerGas:tt,gasPrice:nt,maxFeePerGas:rt,to:ot}=o;if(et<=0)throw new InvalidChainIdError({chainId:et});if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(tt||rt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(nt&&nt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:nt})}function assertTransactionLegacy(o){const{chainId:et,maxPriorityFeePerGas:tt,gasPrice:nt,maxFeePerGas:rt,to:ot}=o;if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(typeof et<"u"&&et<=0)throw new InvalidChainIdError({chainId:et});if(tt||rt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(nt&&nt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:nt})}function serializeAuthorizationList(o){if(!o||o.length===0)return[];const et=[];for(const tt of o){const{contractAddress:nt,chainId:rt,nonce:ot,...it}=tt;et.push([rt?toHex(rt):"0x",nt,ot?toHex(ot):"0x",...toYParitySignatureArray({},it)])}return et}function serializeAccessList(o){if(!o||o.length===0)return[];const et=[];for(let tt=0;tt"u"||typeof pt>"u")){const vt=typeof o.blobs[0]=="string"?o.blobs:o.blobs.map(wt=>bytesToHex$4(wt)),bt=o.kzg,Et=blobsToCommitments({blobs:vt,kzg:bt});if(typeof ht>"u"&&(ht=commitmentsToVersionedHashes({commitments:Et})),typeof pt>"u"){const wt=blobsToProofs({blobs:vt,commitments:Et,kzg:bt});pt=toBlobSidecars({blobs:vt,commitments:Et,proofs:wt})}}const mt=serializeAccessList(lt),ft=[toHex(tt),rt?toHex(rt):"0x",ct?toHex(ct):"0x",at?toHex(at):"0x",nt?toHex(nt):"0x",ot??"0x",it?toHex(it):"0x",dt??"0x",mt,st?toHex(st):"0x",ht??[],...toYParitySignatureArray(o,et)],yt=[],gt=[],xt=[];if(pt)for(let vt=0;vt{if(et.v>=35n)return(et.v-35n)/2n>0?et.v:27n+(et.v===35n?0n:1n);if(tt>0)return BigInt(tt*2)+BigInt(35n+et.v-27n);const pt=27n+(et.v===27n?0n:1n);if(et.v!==pt)throw new InvalidLegacyVError({v:et.v});return pt})(),dt=trim$1(et.r),ht=trim$1(et.s);ct=[...ct,toHex(lt),dt==="0x00"?"0x":dt,ht==="0x00"?"0x":ht]}else tt>0&&(ct=[...ct,toHex(tt),"0x","0x"]);return toRlp(ct)}function toYParitySignatureArray(o,et){const tt=et??o,{v:nt,yParity:rt}=tt;if(typeof tt.r>"u")return[];if(typeof tt.s>"u")return[];if(typeof nt>"u"&&typeof rt>"u")return[];const ot=trim$1(tt.r),it=trim$1(tt.s);return[typeof rt=="number"?rt?toHex(1):"0x":nt===0n?"0x":nt===1n?toHex(1):nt===27n?"0x":toHex(1),ot==="0x00"?"0x":ot,it==="0x00"?"0x":it]}async function signMessage$1(o,{account:et=o.account,message:tt}){if(!et)throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/signMessage"});const nt=parseAccount(et);if(nt.signMessage)return nt.signMessage({message:tt});const rt=typeof tt=="string"?stringToHex(tt):tt.raw instanceof Uint8Array?toHex(tt.raw):tt.raw;return o.request({method:"personal_sign",params:[rt,nt.address]},{retryCount:0})}class HMAC extends Hash{constructor(et,tt){super(),this.finished=!1,this.destroyed=!1,hash$1(et);const nt=toBytes$2(tt);if(this.iHash=et.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const rt=this.blockLen,ot=new Uint8Array(rt);ot.set(nt.length>rt?et.create().update(nt).digest():nt);for(let it=0;itnew HMAC(o,et).update(tt).digest();hmac.create=(o,et)=>new HMAC(o,et);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$8=BigInt(1),_2n$5=BigInt(2);function isBytes$2(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function abytes(o){if(!isBytes$2(o))throw new Error("Uint8Array expected")}function abool(o,et){if(typeof et!="boolean")throw new Error(`${o} must be valid boolean, got "${et}".`)}const hexes$1=Array.from({length:256},(o,et)=>et.toString(16).padStart(2,"0"));function bytesToHex$2(o){abytes(o);let et="";for(let tt=0;tt=asciis._0&&o<=asciis._9)return o-asciis._0;if(o>=asciis._A&&o<=asciis._F)return o-(asciis._A-10);if(o>=asciis._a&&o<=asciis._f)return o-(asciis._a-10)}function hexToBytes$2(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);const et=o.length,tt=et/2;if(et%2)throw new Error("padded hex string expected, got unpadded hex of length "+et);const nt=new Uint8Array(tt);for(let rt=0,ot=0;rttypeof o=="bigint"&&_0n$6<=o;function inRange(o,et,tt){return isPosBig(o)&&isPosBig(et)&&isPosBig(tt)&&et<=o&&o_0n$6;o>>=_1n$8,et+=1);return et}function bitGet(o,et){return o>>BigInt(et)&_1n$8}function bitSet(o,et,tt){return o|(tt?_1n$8:_0n$6)<(_2n$5<new Uint8Array(o),u8fr=o=>Uint8Array.from(o);function createHmacDrbg(o,et,tt){if(typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof et!="number"||et<2)throw new Error("qByteLen must be a number");if(typeof tt!="function")throw new Error("hmacFn must be a function");let nt=u8n(o),rt=u8n(o),ot=0;const it=()=>{nt.fill(1),rt.fill(0),ot=0},st=(...dt)=>tt(rt,nt,...dt),at=(dt=u8n())=>{rt=st(u8fr([0]),dt),nt=st(),dt.length!==0&&(rt=st(u8fr([1]),dt),nt=st())},ct=()=>{if(ot++>=1e3)throw new Error("drbg: tried 1000 values");let dt=0;const ht=[];for(;dt{it(),at(dt);let pt;for(;!(pt=ht(ct()));)at();return it(),pt}}const validatorFns={bigint:o=>typeof o=="bigint",function:o=>typeof o=="function",boolean:o=>typeof o=="boolean",string:o=>typeof o=="string",stringOrUint8Array:o=>typeof o=="string"||isBytes$2(o),isSafeInteger:o=>Number.isSafeInteger(o),array:o=>Array.isArray(o),field:(o,et)=>et.Fp.isValid(o),hash:o=>typeof o=="function"&&Number.isSafeInteger(o.outputLen)};function validateObject(o,et,tt={}){const nt=(rt,ot,it)=>{const st=validatorFns[ot];if(typeof st!="function")throw new Error(`Invalid validator "${ot}", expected function`);const at=o[rt];if(!(it&&at===void 0)&&!st(at,o))throw new Error(`Invalid param ${String(rt)}=${at} (${typeof at}), expected ${ot}`)};for(const[rt,ot]of Object.entries(et))nt(rt,ot,!1);for(const[rt,ot]of Object.entries(tt))nt(rt,ot,!0);return o}const notImplemented=()=>{throw new Error("not implemented")};function memoized(o){const et=new WeakMap;return(tt,...nt)=>{const rt=et.get(tt);if(rt!==void 0)return rt;const ot=o(tt,...nt);return et.set(tt,ot),ot}}const ut=Object.freeze(Object.defineProperty({__proto__:null,aInRange,abool,abytes,bitGet,bitLen,bitMask,bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE,bytesToNumberLE,concatBytes:concatBytes$1,createHmacDrbg,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber$1,inRange,isBytes:isBytes$2,memoized,notImplemented,numberToBytesBE,numberToBytesLE,numberToHexUnpadded:numberToHexUnpadded$1,numberToVarBytesBE,utf8ToBytes:utf8ToBytes$2,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$5=BigInt(0),_1n$7=BigInt(1),_2n$4=BigInt(2),_3n$3=BigInt(3),_4n=BigInt(4),_5n$1=BigInt(5),_8n$3=BigInt(8);BigInt(9);BigInt(16);function mod$1(o,et){const tt=o%et;return tt>=_0n$5?tt:et+tt}function pow(o,et,tt){if(tt<=_0n$5||et<_0n$5)throw new Error("Expected power/modulo > 0");if(tt===_1n$7)return _0n$5;let nt=_1n$7;for(;et>_0n$5;)et&_1n$7&&(nt=nt*o%tt),o=o*o%tt,et>>=_1n$7;return nt}function pow2$1(o,et,tt){let nt=o;for(;et-- >_0n$5;)nt*=nt,nt%=tt;return nt}function invert$1(o,et){if(o===_0n$5||et<=_0n$5)throw new Error(`invert: expected positive integers, got n=${o} mod=${et}`);let tt=mod$1(o,et),nt=et,rt=_0n$5,ot=_1n$7;for(;tt!==_0n$5;){const st=nt/tt,at=nt%tt,ct=rt-ot*st;nt=tt,tt=at,rt=ot,ot=ct}if(nt!==_1n$7)throw new Error("invert: does not exist");return mod$1(rt,et)}function tonelliShanks(o){const et=(o-_1n$7)/_2n$4;let tt,nt,rt;for(tt=o-_1n$7,nt=0;tt%_2n$4===_0n$5;tt/=_2n$4,nt++);for(rt=_2n$4;rt(mod$1(o,et)&_1n$7)===_1n$7,FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(o){const et={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},tt=FIELD_FIELDS.reduce((nt,rt)=>(nt[rt]="function",nt),et);return validateObject(o,tt)}function FpPow(o,et,tt){if(tt<_0n$5)throw new Error("Expected power > 0");if(tt===_0n$5)return o.ONE;if(tt===_1n$7)return et;let nt=o.ONE,rt=et;for(;tt>_0n$5;)tt&_1n$7&&(nt=o.mul(nt,rt)),rt=o.sqr(rt),tt>>=_1n$7;return nt}function FpInvertBatch(o,et){const tt=new Array(et.length),nt=et.reduce((ot,it,st)=>o.is0(it)?ot:(tt[st]=ot,o.mul(ot,it)),o.ONE),rt=o.inv(nt);return et.reduceRight((ot,it,st)=>o.is0(it)?ot:(tt[st]=o.mul(ot,tt[st]),o.mul(ot,it)),rt),tt}function nLength(o,et){const tt=et!==void 0?et:o.toString(2).length,nt=Math.ceil(tt/8);return{nBitLength:tt,nByteLength:nt}}function Field$1(o,et,tt=!1,nt={}){if(o<=_0n$5)throw new Error(`Expected Field ORDER > 0, got ${o}`);const{nBitLength:rt,nByteLength:ot}=nLength(o,et);if(ot>2048)throw new Error("Field lengths over 2048 bytes are not supported");const it=FpSqrt(o),st=Object.freeze({ORDER:o,BITS:rt,BYTES:ot,MASK:bitMask(rt),ZERO:_0n$5,ONE:_1n$7,create:at=>mod$1(at,o),isValid:at=>{if(typeof at!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof at}`);return _0n$5<=at&&atat===_0n$5,isOdd:at=>(at&_1n$7)===_1n$7,neg:at=>mod$1(-at,o),eql:(at,ct)=>at===ct,sqr:at=>mod$1(at*at,o),add:(at,ct)=>mod$1(at+ct,o),sub:(at,ct)=>mod$1(at-ct,o),mul:(at,ct)=>mod$1(at*ct,o),pow:(at,ct)=>FpPow(st,at,ct),div:(at,ct)=>mod$1(at*invert$1(ct,o),o),sqrN:at=>at*at,addN:(at,ct)=>at+ct,subN:(at,ct)=>at-ct,mulN:(at,ct)=>at*ct,inv:at=>invert$1(at,o),sqrt:nt.sqrt||(at=>it(st,at)),invertBatch:at=>FpInvertBatch(st,at),cmov:(at,ct,lt)=>lt?ct:at,toBytes:at=>tt?numberToBytesLE(at,ot):numberToBytesBE(at,ot),fromBytes:at=>{if(at.length!==ot)throw new Error(`Fp.fromBytes: expected ${ot}, got ${at.length}`);return tt?bytesToNumberLE(at):bytesToNumberBE(at)}});return Object.freeze(st)}function getFieldBytesLength(o){if(typeof o!="bigint")throw new Error("field order must be bigint");const et=o.toString(2).length;return Math.ceil(et/8)}function getMinHashLength(o){const et=getFieldBytesLength(o);return et+Math.ceil(et/2)}function mapHashToField(o,et,tt=!1){const nt=o.length,rt=getFieldBytesLength(et),ot=getMinHashLength(et);if(nt<16||nt1024)throw new Error(`expected ${ot}-1024 bytes of input, got ${nt}`);const it=tt?bytesToNumberBE(o):bytesToNumberLE(o),st=mod$1(it,et-_1n$7)+_1n$7;return tt?numberToBytesLE(st,rt):numberToBytesBE(st,rt)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$4=BigInt(0),_1n$6=BigInt(1),pointPrecomputes$1=new WeakMap,pointWindowSizes=new WeakMap;function wNAF(o,et){const tt=(ot,it)=>{const st=it.negate();return ot?st:it},nt=ot=>{if(!Number.isSafeInteger(ot)||ot<=0||ot>et)throw new Error(`Wrong window size=${ot}, should be [1..${et}]`)},rt=ot=>{nt(ot);const it=Math.ceil(et/ot)+1,st=2**(ot-1);return{windows:it,windowSize:st}};return{constTimeNegate:tt,unsafeLadder(ot,it){let st=o.ZERO,at=ot;for(;it>_0n$4;)it&_1n$6&&(st=st.add(at)),at=at.double(),it>>=_1n$6;return st},precomputeWindow(ot,it){const{windows:st,windowSize:at}=rt(it),ct=[];let lt=ot,dt=lt;for(let ht=0;ht>=mt,gt>ct&&(gt-=pt,st+=_1n$6);const xt=yt,vt=yt+Math.abs(gt)-1,bt=ft%2!==0,Et=gt<0;gt===0?dt=dt.add(tt(bt,it[xt])):lt=lt.add(tt(Et,it[vt]))}return{p:lt,f:dt}},wNAFCached(ot,it,st){const at=pointWindowSizes.get(ot)||1;let ct=pointPrecomputes$1.get(ot);return ct||(ct=this.precomputeWindow(ot,at),at!==1&&pointPrecomputes$1.set(ot,st(ct))),this.wNAF(at,ct,it)},setWindowSize(ot,it){nt(it),pointWindowSizes.set(ot,it),pointPrecomputes$1.delete(ot)}}}function pippenger(o,et,tt,nt){if(!Array.isArray(tt)||!Array.isArray(nt)||nt.length!==tt.length)throw new Error("arrays of points and scalars must have equal length");nt.forEach((lt,dt)=>{if(!et.isValid(lt))throw new Error(`wrong scalar at index ${dt}`)}),tt.forEach((lt,dt)=>{if(!(lt instanceof o))throw new Error(`wrong point at index ${dt}`)});const rt=bitLen(BigInt(tt.length)),ot=rt>12?rt-3:rt>4?rt-2:rt?2:1,it=(1<=0;lt-=ot){st.fill(o.ZERO);for(let ht=0;ht>BigInt(lt)&BigInt(it));st[mt]=st[mt].add(tt[ht])}let dt=o.ZERO;for(let ht=st.length-1,pt=o.ZERO;ht>0;ht--)pt=pt.add(st[ht]),dt=dt.add(pt);if(ct=ct.add(dt),lt!==0)for(let ht=0;ht{const{Err:tt}=DER;if(o<0||o>256)throw new tt("tlv.encode: wrong tag");if(et.length&1)throw new tt("tlv.encode: unpadded data");const nt=et.length/2,rt=numberToHexUnpadded$1(nt);if(rt.length/2&128)throw new tt("tlv.encode: long form length too big");const ot=nt>127?numberToHexUnpadded$1(rt.length/2|128):"";return`${numberToHexUnpadded$1(o)}${ot}${rt}${et}`},decode(o,et){const{Err:tt}=DER;let nt=0;if(o<0||o>256)throw new tt("tlv.encode: wrong tag");if(et.length<2||et[nt++]!==o)throw new tt("tlv.decode: wrong tlv");const rt=et[nt++],ot=!!(rt&128);let it=0;if(!ot)it=rt;else{const at=rt&127;if(!at)throw new tt("tlv.decode(long): indefinite length not supported");if(at>4)throw new tt("tlv.decode(long): byte length is too big");const ct=et.subarray(nt,nt+at);if(ct.length!==at)throw new tt("tlv.decode: length bytes not complete");if(ct[0]===0)throw new tt("tlv.decode(long): zero leftmost byte");for(const lt of ct)it=it<<8|lt;if(nt+=at,it<128)throw new tt("tlv.decode(long): not minimal encoding")}const st=et.subarray(nt,nt+it);if(st.length!==it)throw new tt("tlv.decode: wrong value length");return{v:st,l:et.subarray(nt+it)}}},_int:{encode(o){const{Err:et}=DER;if(o<_0n$3)throw new et("integer: negative integers are not allowed");let tt=numberToHexUnpadded$1(o);if(Number.parseInt(tt[0],16)&8&&(tt="00"+tt),tt.length&1)throw new et("unexpected assertion");return tt},decode(o){const{Err:et}=DER;if(o[0]&128)throw new et("Invalid signature integer: negative");if(o[0]===0&&!(o[1]&128))throw new et("Invalid signature integer: unnecessary leading zero");return b2n(o)}},toSig(o){const{Err:et,_int:tt,_tlv:nt}=DER,rt=typeof o=="string"?h2b(o):o;abytes(rt);const{v:ot,l:it}=nt.decode(48,rt);if(it.length)throw new et("Invalid signature: left bytes after parsing");const{v:st,l:at}=nt.decode(2,ot),{v:ct,l:lt}=nt.decode(2,at);if(lt.length)throw new et("Invalid signature: left bytes after parsing");return{r:tt.decode(st),s:tt.decode(ct)}},hexFromSig(o){const{_tlv:et,_int:tt}=DER,nt=`${et.encode(2,tt.encode(o.r))}${et.encode(2,tt.encode(o.s))}`;return et.encode(48,nt)}},_0n$3=BigInt(0),_1n$5=BigInt(1);BigInt(2);const _3n$2=BigInt(3);BigInt(4);function weierstrassPoints(o){const et=validatePointOpts(o),{Fp:tt}=et,nt=Field$1(et.n,et.nBitLength),rt=et.toBytes||((ft,yt,gt)=>{const xt=yt.toAffine();return concatBytes$1(Uint8Array.from([4]),tt.toBytes(xt.x),tt.toBytes(xt.y))}),ot=et.fromBytes||(ft=>{const yt=ft.subarray(1),gt=tt.fromBytes(yt.subarray(0,tt.BYTES)),xt=tt.fromBytes(yt.subarray(tt.BYTES,2*tt.BYTES));return{x:gt,y:xt}});function it(ft){const{a:yt,b:gt}=et,xt=tt.sqr(ft),vt=tt.mul(xt,ft);return tt.add(tt.add(vt,tt.mul(ft,yt)),gt)}if(!tt.eql(tt.sqr(et.Gy),it(et.Gx)))throw new Error("bad generator point: equation left != right");function st(ft){return inRange(ft,_1n$5,et.n)}function at(ft){const{allowedPrivateKeyLengths:yt,nByteLength:gt,wrapPrivateKey:xt,n:vt}=et;if(yt&&typeof ft!="bigint"){if(isBytes$2(ft)&&(ft=bytesToHex$2(ft)),typeof ft!="string"||!yt.includes(ft.length))throw new Error("Invalid key");ft=ft.padStart(gt*2,"0")}let bt;try{bt=typeof ft=="bigint"?ft:bytesToNumberBE(ensureBytes$1("private key",ft,gt))}catch{throw new Error(`private key must be ${gt} bytes, hex or bigint, not ${typeof ft}`)}return xt&&(bt=mod$1(bt,vt)),aInRange("private key",bt,_1n$5,vt),bt}function ct(ft){if(!(ft instanceof ht))throw new Error("ProjectivePoint expected")}const lt=memoized((ft,yt)=>{const{px:gt,py:xt,pz:vt}=ft;if(tt.eql(vt,tt.ONE))return{x:gt,y:xt};const bt=ft.is0();yt==null&&(yt=bt?tt.ONE:tt.inv(vt));const Et=tt.mul(gt,yt),wt=tt.mul(xt,yt),kt=tt.mul(vt,yt);if(bt)return{x:tt.ZERO,y:tt.ZERO};if(!tt.eql(kt,tt.ONE))throw new Error("invZ was invalid");return{x:Et,y:wt}}),dt=memoized(ft=>{if(ft.is0()){if(et.allowInfinityPoint&&!tt.is0(ft.py))return;throw new Error("bad point: ZERO")}const{x:yt,y:gt}=ft.toAffine();if(!tt.isValid(yt)||!tt.isValid(gt))throw new Error("bad point: x or y not FE");const xt=tt.sqr(gt),vt=it(yt);if(!tt.eql(xt,vt))throw new Error("bad point: equation left != right");if(!ft.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class ht{constructor(yt,gt,xt){if(this.px=yt,this.py=gt,this.pz=xt,yt==null||!tt.isValid(yt))throw new Error("x required");if(gt==null||!tt.isValid(gt))throw new Error("y required");if(xt==null||!tt.isValid(xt))throw new Error("z required");Object.freeze(this)}static fromAffine(yt){const{x:gt,y:xt}=yt||{};if(!yt||!tt.isValid(gt)||!tt.isValid(xt))throw new Error("invalid affine point");if(yt instanceof ht)throw new Error("projective point not allowed");const vt=bt=>tt.eql(bt,tt.ZERO);return vt(gt)&&vt(xt)?ht.ZERO:new ht(gt,xt,tt.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(yt){const gt=tt.invertBatch(yt.map(xt=>xt.pz));return yt.map((xt,vt)=>xt.toAffine(gt[vt])).map(ht.fromAffine)}static fromHex(yt){const gt=ht.fromAffine(ot(ensureBytes$1("pointHex",yt)));return gt.assertValidity(),gt}static fromPrivateKey(yt){return ht.BASE.multiply(at(yt))}static msm(yt,gt){return pippenger(ht,nt,yt,gt)}_setWindowSize(yt){mt.setWindowSize(this,yt)}assertValidity(){dt(this)}hasEvenY(){const{y:yt}=this.toAffine();if(tt.isOdd)return!tt.isOdd(yt);throw new Error("Field doesn't support isOdd")}equals(yt){ct(yt);const{px:gt,py:xt,pz:vt}=this,{px:bt,py:Et,pz:wt}=yt,kt=tt.eql(tt.mul(gt,wt),tt.mul(bt,vt)),It=tt.eql(tt.mul(xt,wt),tt.mul(Et,vt));return kt&&It}negate(){return new ht(this.px,tt.neg(this.py),this.pz)}double(){const{a:yt,b:gt}=et,xt=tt.mul(gt,_3n$2),{px:vt,py:bt,pz:Et}=this;let wt=tt.ZERO,kt=tt.ZERO,It=tt.ZERO,Rt=tt.mul(vt,vt),Pt=tt.mul(bt,bt),jt=tt.mul(Et,Et),Ot=tt.mul(vt,bt);return Ot=tt.add(Ot,Ot),It=tt.mul(vt,Et),It=tt.add(It,It),wt=tt.mul(yt,It),kt=tt.mul(xt,jt),kt=tt.add(wt,kt),wt=tt.sub(Pt,kt),kt=tt.add(Pt,kt),kt=tt.mul(wt,kt),wt=tt.mul(Ot,wt),It=tt.mul(xt,It),jt=tt.mul(yt,jt),Ot=tt.sub(Rt,jt),Ot=tt.mul(yt,Ot),Ot=tt.add(Ot,It),It=tt.add(Rt,Rt),Rt=tt.add(It,Rt),Rt=tt.add(Rt,jt),Rt=tt.mul(Rt,Ot),kt=tt.add(kt,Rt),jt=tt.mul(bt,Et),jt=tt.add(jt,jt),Rt=tt.mul(jt,Ot),wt=tt.sub(wt,Rt),It=tt.mul(jt,Pt),It=tt.add(It,It),It=tt.add(It,It),new ht(wt,kt,It)}add(yt){ct(yt);const{px:gt,py:xt,pz:vt}=this,{px:bt,py:Et,pz:wt}=yt;let kt=tt.ZERO,It=tt.ZERO,Rt=tt.ZERO;const Pt=et.a,jt=tt.mul(et.b,_3n$2);let Ot=tt.mul(gt,bt),Bt=tt.mul(xt,Et),zt=tt.mul(vt,wt),Ft=tt.add(gt,xt),Yt=tt.add(bt,Et);Ft=tt.mul(Ft,Yt),Yt=tt.add(Ot,Bt),Ft=tt.sub(Ft,Yt),Yt=tt.add(gt,vt);let Ht=tt.add(bt,wt);return Yt=tt.mul(Yt,Ht),Ht=tt.add(Ot,zt),Yt=tt.sub(Yt,Ht),Ht=tt.add(xt,vt),kt=tt.add(Et,wt),Ht=tt.mul(Ht,kt),kt=tt.add(Bt,zt),Ht=tt.sub(Ht,kt),Rt=tt.mul(Pt,Yt),kt=tt.mul(jt,zt),Rt=tt.add(kt,Rt),kt=tt.sub(Bt,Rt),Rt=tt.add(Bt,Rt),It=tt.mul(kt,Rt),Bt=tt.add(Ot,Ot),Bt=tt.add(Bt,Ot),zt=tt.mul(Pt,zt),Yt=tt.mul(jt,Yt),Bt=tt.add(Bt,zt),zt=tt.sub(Ot,zt),zt=tt.mul(Pt,zt),Yt=tt.add(Yt,zt),Ot=tt.mul(Bt,Yt),It=tt.add(It,Ot),Ot=tt.mul(Ht,Yt),kt=tt.mul(Ft,kt),kt=tt.sub(kt,Ot),Ot=tt.mul(Ft,Bt),Rt=tt.mul(Ht,Rt),Rt=tt.add(Rt,Ot),new ht(kt,It,Rt)}subtract(yt){return this.add(yt.negate())}is0(){return this.equals(ht.ZERO)}wNAF(yt){return mt.wNAFCached(this,yt,ht.normalizeZ)}multiplyUnsafe(yt){aInRange("scalar",yt,_0n$3,et.n);const gt=ht.ZERO;if(yt===_0n$3)return gt;if(yt===_1n$5)return this;const{endo:xt}=et;if(!xt)return mt.unsafeLadder(this,yt);let{k1neg:vt,k1:bt,k2neg:Et,k2:wt}=xt.splitScalar(yt),kt=gt,It=gt,Rt=this;for(;bt>_0n$3||wt>_0n$3;)bt&_1n$5&&(kt=kt.add(Rt)),wt&_1n$5&&(It=It.add(Rt)),Rt=Rt.double(),bt>>=_1n$5,wt>>=_1n$5;return vt&&(kt=kt.negate()),Et&&(It=It.negate()),It=new ht(tt.mul(It.px,xt.beta),It.py,It.pz),kt.add(It)}multiply(yt){const{endo:gt,n:xt}=et;aInRange("scalar",yt,_1n$5,xt);let vt,bt;if(gt){const{k1neg:Et,k1:wt,k2neg:kt,k2:It}=gt.splitScalar(yt);let{p:Rt,f:Pt}=this.wNAF(wt),{p:jt,f:Ot}=this.wNAF(It);Rt=mt.constTimeNegate(Et,Rt),jt=mt.constTimeNegate(kt,jt),jt=new ht(tt.mul(jt.px,gt.beta),jt.py,jt.pz),vt=Rt.add(jt),bt=Pt.add(Ot)}else{const{p:Et,f:wt}=this.wNAF(yt);vt=Et,bt=wt}return ht.normalizeZ([vt,bt])[0]}multiplyAndAddUnsafe(yt,gt,xt){const vt=ht.BASE,bt=(wt,kt)=>kt===_0n$3||kt===_1n$5||!wt.equals(vt)?wt.multiplyUnsafe(kt):wt.multiply(kt),Et=bt(this,gt).add(bt(yt,xt));return Et.is0()?void 0:Et}toAffine(yt){return lt(this,yt)}isTorsionFree(){const{h:yt,isTorsionFree:gt}=et;if(yt===_1n$5)return!0;if(gt)return gt(ht,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:yt,clearCofactor:gt}=et;return yt===_1n$5?this:gt?gt(ht,this):this.multiplyUnsafe(et.h)}toRawBytes(yt=!0){return abool("isCompressed",yt),this.assertValidity(),rt(ht,this,yt)}toHex(yt=!0){return abool("isCompressed",yt),bytesToHex$2(this.toRawBytes(yt))}}ht.BASE=new ht(et.Gx,et.Gy,tt.ONE),ht.ZERO=new ht(tt.ZERO,tt.ONE,tt.ZERO);const pt=et.nBitLength,mt=wNAF(ht,et.endo?Math.ceil(pt/2):pt);return{CURVE:et,ProjectivePoint:ht,normPrivateKeyToScalar:at,weierstrassEquation:it,isWithinCurveOrder:st}}function validateOpts$2(o){const et=validateBasic(o);return validateObject(et,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...et})}function weierstrass$1(o){const et=validateOpts$2(o),{Fp:tt,n:nt}=et,rt=tt.BYTES+1,ot=2*tt.BYTES+1;function it(zt){return mod$1(zt,nt)}function st(zt){return invert$1(zt,nt)}const{ProjectivePoint:at,normPrivateKeyToScalar:ct,weierstrassEquation:lt,isWithinCurveOrder:dt}=weierstrassPoints({...et,toBytes(zt,Ft,Yt){const Ht=Ft.toAffine(),Ut=tt.toBytes(Ht.x),qt=concatBytes$1;return abool("isCompressed",Yt),Yt?qt(Uint8Array.from([Ft.hasEvenY()?2:3]),Ut):qt(Uint8Array.from([4]),Ut,tt.toBytes(Ht.y))},fromBytes(zt){const Ft=zt.length,Yt=zt[0],Ht=zt.subarray(1);if(Ft===rt&&(Yt===2||Yt===3)){const Ut=bytesToNumberBE(Ht);if(!inRange(Ut,_1n$5,tt.ORDER))throw new Error("Point is not on curve");const qt=lt(Ut);let Lt;try{Lt=tt.sqrt(qt)}catch(Nt){const Gt=Nt instanceof Error?": "+Nt.message:"";throw new Error("Point is not on curve"+Gt)}const Zt=(Lt&_1n$5)===_1n$5;return(Yt&1)===1!==Zt&&(Lt=tt.neg(Lt)),{x:Ut,y:Lt}}else if(Ft===ot&&Yt===4){const Ut=tt.fromBytes(Ht.subarray(0,tt.BYTES)),qt=tt.fromBytes(Ht.subarray(tt.BYTES,2*tt.BYTES));return{x:Ut,y:qt}}else throw new Error(`Point of length ${Ft} was invalid. Expected ${rt} compressed bytes or ${ot} uncompressed bytes`)}}),ht=zt=>bytesToHex$2(numberToBytesBE(zt,et.nByteLength));function pt(zt){const Ft=nt>>_1n$5;return zt>Ft}function mt(zt){return pt(zt)?it(-zt):zt}const ft=(zt,Ft,Yt)=>bytesToNumberBE(zt.slice(Ft,Yt));class yt{constructor(Ft,Yt,Ht){this.r=Ft,this.s=Yt,this.recovery=Ht,this.assertValidity()}static fromCompact(Ft){const Yt=et.nByteLength;return Ft=ensureBytes$1("compactSignature",Ft,Yt*2),new yt(ft(Ft,0,Yt),ft(Ft,Yt,2*Yt))}static fromDER(Ft){const{r:Yt,s:Ht}=DER.toSig(ensureBytes$1("DER",Ft));return new yt(Yt,Ht)}assertValidity(){aInRange("r",this.r,_1n$5,nt),aInRange("s",this.s,_1n$5,nt)}addRecoveryBit(Ft){return new yt(this.r,this.s,Ft)}recoverPublicKey(Ft){const{r:Yt,s:Ht,recovery:Ut}=this,qt=wt(ensureBytes$1("msgHash",Ft));if(Ut==null||![0,1,2,3].includes(Ut))throw new Error("recovery id invalid");const Lt=Ut===2||Ut===3?Yt+et.n:Yt;if(Lt>=tt.ORDER)throw new Error("recovery id 2 or 3 invalid");const Zt=Ut&1?"03":"02",Qt=at.fromHex(Zt+ht(Lt)),Nt=st(Lt),Gt=it(-qt*Nt),nn=it(Ht*Nt),Wt=at.BASE.multiplyAndAddUnsafe(Qt,Gt,nn);if(!Wt)throw new Error("point at infinify");return Wt.assertValidity(),Wt}hasHighS(){return pt(this.s)}normalizeS(){return this.hasHighS()?new yt(this.r,it(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return ht(this.r)+ht(this.s)}}const gt={isValidPrivateKey(zt){try{return ct(zt),!0}catch{return!1}},normPrivateKeyToScalar:ct,randomPrivateKey:()=>{const zt=getMinHashLength(et.n);return mapHashToField(et.randomBytes(zt),et.n)},precompute(zt=8,Ft=at.BASE){return Ft._setWindowSize(zt),Ft.multiply(BigInt(3)),Ft}};function xt(zt,Ft=!0){return at.fromPrivateKey(zt).toRawBytes(Ft)}function vt(zt){const Ft=isBytes$2(zt),Yt=typeof zt=="string",Ht=(Ft||Yt)&&zt.length;return Ft?Ht===rt||Ht===ot:Yt?Ht===2*rt||Ht===2*ot:zt instanceof at}function bt(zt,Ft,Yt=!0){if(vt(zt))throw new Error("first arg must be private key");if(!vt(Ft))throw new Error("second arg must be public key");return at.fromHex(Ft).multiply(ct(zt)).toRawBytes(Yt)}const Et=et.bits2int||function(zt){const Ft=bytesToNumberBE(zt),Yt=zt.length*8-et.nBitLength;return Yt>0?Ft>>BigInt(Yt):Ft},wt=et.bits2int_modN||function(zt){return it(Et(zt))},kt=bitMask(et.nBitLength);function It(zt){return aInRange(`num < 2^${et.nBitLength}`,zt,_0n$3,kt),numberToBytesBE(zt,et.nByteLength)}function Rt(zt,Ft,Yt=Pt){if(["recovered","canonical"].some(Xt=>Xt in Yt))throw new Error("sign() legacy options not supported");const{hash:Ht,randomBytes:Ut}=et;let{lowS:qt,prehash:Lt,extraEntropy:Zt}=Yt;qt==null&&(qt=!0),zt=ensureBytes$1("msgHash",zt),validateSigVerOpts(Yt),Lt&&(zt=ensureBytes$1("prehashed msgHash",Ht(zt)));const Qt=wt(zt),Nt=ct(Ft),Gt=[It(Nt),It(Qt)];if(Zt!=null&&Zt!==!1){const Xt=Zt===!0?Ut(tt.BYTES):Zt;Gt.push(ensureBytes$1("extraEntropy",Xt))}const nn=concatBytes$1(...Gt),Wt=Qt;function hn(Xt){const Jt=Et(Xt);if(!dt(Jt))return;const tn=st(Jt),_t=at.BASE.multiply(Jt).toAffine(),Dt=it(_t.x);if(Dt===_0n$3)return;const Vt=it(tn*it(Wt+Dt*Nt));if(Vt===_0n$3)return;let en=(_t.x===Dt?0:2)|Number(_t.y&_1n$5),an=Vt;return qt&&pt(Vt)&&(an=mt(Vt),en^=1),new yt(Dt,an,en)}return{seed:nn,k2sig:hn}}const Pt={lowS:et.lowS,prehash:!1},jt={lowS:et.lowS,prehash:!1};function Ot(zt,Ft,Yt=Pt){const{seed:Ht,k2sig:Ut}=Rt(zt,Ft,Yt),qt=et;return createHmacDrbg(qt.hash.outputLen,qt.nByteLength,qt.hmac)(Ht,Ut)}at.BASE._setWindowSize(8);function Bt(zt,Ft,Yt,Ht=jt){var _t;const Ut=zt;if(Ft=ensureBytes$1("msgHash",Ft),Yt=ensureBytes$1("publicKey",Yt),"strict"in Ht)throw new Error("options.strict was renamed to lowS");validateSigVerOpts(Ht);const{lowS:qt,prehash:Lt}=Ht;let Zt,Qt;try{if(typeof Ut=="string"||isBytes$2(Ut))try{Zt=yt.fromDER(Ut)}catch(Dt){if(!(Dt instanceof DER.Err))throw Dt;Zt=yt.fromCompact(Ut)}else if(typeof Ut=="object"&&typeof Ut.r=="bigint"&&typeof Ut.s=="bigint"){const{r:Dt,s:Vt}=Ut;Zt=new yt(Dt,Vt)}else throw new Error("PARSE");Qt=at.fromHex(Yt)}catch(Dt){if(Dt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(qt&&Zt.hasHighS())return!1;Lt&&(Ft=et.hash(Ft));const{r:Nt,s:Gt}=Zt,nn=wt(Ft),Wt=st(Gt),hn=it(nn*Wt),Xt=it(Nt*Wt),Jt=(_t=at.BASE.multiplyAndAddUnsafe(Qt,hn,Xt))==null?void 0:_t.toAffine();return Jt?it(Jt.x)===Nt:!1}return{CURVE:et,getPublicKey:xt,getSharedSecret:bt,sign:Ot,verify:Bt,ProjectivePoint:at,Signature:yt,utils:gt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(o){return{hash:o,hmac:(et,...tt)=>hmac(o,et,concatBytes$2(...tt)),randomBytes:randomBytes$1}}function createCurve(o,et){const tt=nt=>weierstrass$1({...o,...getHash(nt)});return Object.freeze({...tt(et),create:tt})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$4=BigInt(1),_2n$3=BigInt(2),divNearest$1=(o,et)=>(o+et/_2n$3)/et;function sqrtMod$1(o){const et=secp256k1P,tt=BigInt(3),nt=BigInt(6),rt=BigInt(11),ot=BigInt(22),it=BigInt(23),st=BigInt(44),at=BigInt(88),ct=o*o*o%et,lt=ct*ct*o%et,dt=pow2$1(lt,tt,et)*lt%et,ht=pow2$1(dt,tt,et)*lt%et,pt=pow2$1(ht,_2n$3,et)*ct%et,mt=pow2$1(pt,rt,et)*pt%et,ft=pow2$1(mt,ot,et)*mt%et,yt=pow2$1(ft,st,et)*ft%et,gt=pow2$1(yt,at,et)*yt%et,xt=pow2$1(gt,st,et)*ft%et,vt=pow2$1(xt,tt,et)*lt%et,bt=pow2$1(vt,it,et)*mt%et,Et=pow2$1(bt,nt,et)*ct%et,wt=pow2$1(Et,_2n$3,et);if(!Fp$1.eql(Fp$1.sqr(wt),o))throw new Error("Cannot find square root");return wt}const Fp$1=Field$1(secp256k1P,void 0,void 0,{sqrt:sqrtMod$1}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:o=>{const et=secp256k1N,tt=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),nt=-_1n$4*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),rt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),ot=tt,it=BigInt("0x100000000000000000000000000000000"),st=divNearest$1(ot*o,et),at=divNearest$1(-nt*o,et);let ct=mod$1(o-st*tt-at*rt,et),lt=mod$1(-st*nt-at*ot,et);const dt=ct>it,ht=lt>it;if(dt&&(ct=et-ct),ht&&(lt=et-lt),ct>it||lt>it)throw new Error("splitScalar: Endomorphism failed, k="+o);return{k1neg:dt,k1:ct,k2neg:ht,k2:lt}}}},sha256$2);BigInt(0);secp256k1.ProjectivePoint;function getAction(o,et,tt){const nt=o[et.name];if(typeof nt=="function")return nt;const rt=o[tt];return typeof rt=="function"?rt:ot=>et(o,ot)}const version$6="2.14.4",getVersion$1=()=>`@wagmi/core@${version$6}`;var __classPrivateFieldGet$1=function(o,et,tt,nt){if(tt==="a"&&!nt)throw new TypeError("Private accessor was defined without a getter");if(typeof et=="function"?o!==et||!nt:!et.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return tt==="m"?nt:tt==="a"?nt.call(o):nt?nt.value:et.get(o)},_BaseError_instances,_BaseError_walk;let BaseError$1=class As extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return getVersion$1()}constructor(et,tt={}){var ot;super(),_BaseError_instances.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const nt=tt.cause instanceof As?tt.cause.details:(ot=tt.cause)!=null&&ot.message?tt.cause.message:tt.details,rt=tt.cause instanceof As&&tt.cause.docsPath||tt.docsPath;this.message=[et||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...rt?[`Docs: ${this.docsBaseUrl}${rt}.html${tt.docsSlug?`#${tt.docsSlug}`:""}`]:[],...nt?[`Details: ${nt}`]:[],`Version: ${this.version}`].join(` +`):`The contract function "${nt}" reverted.`,{cause:ot,metaMessages:st,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=it,this.reason=at,this.signature=ct}}class ContractFunctionZeroDataError extends BaseError$3{constructor({functionName:et}){super(`The contract function "${et}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${et}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class CounterfactualDeploymentFailedError extends BaseError$3{constructor({factory:et}){super(`Deployment for counterfactual contract call failed${et?` for factory "${et}".`:""}`,{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class RawContractError extends BaseError$3{constructor({data:et,message:tt}){super(tt||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=et}}function isNullUniversalResolverError(o,et){var nt,rt,ot,it,st,at;if(!(o instanceof BaseError$3))return!1;const tt=o.walk(ct=>ct instanceof ContractFunctionRevertedError);return tt instanceof ContractFunctionRevertedError?!!(((nt=tt.data)==null?void 0:nt.errorName)==="ResolverNotFound"||((rt=tt.data)==null?void 0:rt.errorName)==="ResolverWildcardNotSupported"||((ot=tt.data)==null?void 0:ot.errorName)==="ResolverNotContract"||((it=tt.data)==null?void 0:it.errorName)==="ResolverError"||((st=tt.data)==null?void 0:st.errorName)==="HttpError"||(at=tt.reason)!=null&&at.includes("Wildcard on non-extended resolvers is not supported")||et==="reverse"&&tt.reason===panicReasons[50]):!1}function encodedLabelToLabelhash(o){if(o.length!==66||o.indexOf("[")!==0||o.indexOf("]")!==65)return null;const et=`0x${o.slice(1,65)}`;return isHex(et)?et:null}function namehash(o){let et=new Uint8Array(32).fill(0);if(!o)return bytesToHex$4(et);const tt=o.split(".");for(let nt=tt.length-1;nt>=0;nt-=1){const rt=encodedLabelToLabelhash(tt[nt]),ot=rt?toBytes$3(rt):keccak256$1(stringToBytes(tt[nt]),"bytes");et=keccak256$1(concat$3([et,ot]),"bytes")}return bytesToHex$4(et)}function encodeLabelhash(o){return`[${o.slice(2)}]`}function labelhash(o){const et=new Uint8Array(32).fill(0);return o?encodedLabelToLabelhash(o)||keccak256$1(stringToBytes(o)):bytesToHex$4(et)}function packetToBytes(o){const et=o.replace(/^\.|\.$/gm,"");if(et.length===0)return new Uint8Array(1);const tt=new Uint8Array(stringToBytes(et).byteLength+2);let nt=0;const rt=et.split(".");for(let ot=0;ot255&&(it=stringToBytes(encodeLabelhash(labelhash(rt[ot])))),tt[nt]=it.length,tt.set(it,nt+1),nt+=it.length+1}return tt.byteLength!==nt+1?tt.slice(0,nt+1):tt}const EXECUTION_REVERTED_ERROR_CODE=3;function getContractError(o,{abi:et,address:tt,args:nt,docsPath:rt,functionName:ot,sender:it}){const{code:st,data:at,message:ct,shortMessage:lt}=o instanceof RawContractError?o:o instanceof BaseError$3?o.walk(ht=>"data"in ht)||o.walk():{},dt=o instanceof AbiDecodingZeroDataError?new ContractFunctionZeroDataError({functionName:ot}):[EXECUTION_REVERTED_ERROR_CODE,InternalRpcError.code].includes(st)&&(at||ct||lt)?new ContractFunctionRevertedError({abi:et,data:typeof at=="object"?at.data:at,functionName:ot,message:lt??ct}):o;return new ContractFunctionExecutionError(dt,{abi:et,args:nt,contractAddress:tt,docsPath:rt,functionName:ot,sender:it})}const aggregate3Signature="0x82ad56cb",deploylessCallViaBytecodeBytecode="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",deploylessCallViaFactoryBytecode="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe";function getCallError(o,{docsPath:et,...tt}){const nt=(()=>{const rt=getNodeError(o,tt);return rt instanceof UnknownNodeError?o:rt})();return new CallExecutionError(nt,{docsPath:et,...tt})}function withResolvers(){let o=()=>{},et=()=>{};return{promise:new Promise((nt,rt)=>{o=nt,et=rt}),resolve:o,reject:et}}const schedulerCache=new Map;function createBatchScheduler({fn:o,id:et,shouldSplitBatch:tt,wait:nt=0,sort:rt}){const ot=async()=>{const lt=at();it();const dt=lt.map(({args:ht})=>ht);dt.length!==0&&o(dt).then(ht=>{rt&&Array.isArray(ht)&&ht.sort(rt);for(let pt=0;pt{for(let pt=0;ptschedulerCache.delete(et),st=()=>at().map(({args:lt})=>lt),at=()=>schedulerCache.get(et)||[],ct=lt=>schedulerCache.set(et,[...at(),lt]);return{flush:it,async schedule(lt){const{promise:dt,resolve:ht,reject:pt}=withResolvers();return(tt==null?void 0:tt([...st(),lt]))&&ot(),at().length>0?(ct({args:lt,resolve:ht,reject:pt}),dt):(ct({args:lt,resolve:ht,reject:pt}),setTimeout(ot,nt),dt)}}}async function call(o,et){var jt,Ot,Bt,zt;const{account:tt=o.account,batch:nt=!!((jt=o.batch)!=null&&jt.multicall),blockNumber:rt,blockTag:ot="latest",accessList:it,blobs:st,code:at,data:ct,factory:lt,factoryData:dt,gas:ht,gasPrice:pt,maxFeePerBlobGas:mt,maxFeePerGas:ft,maxPriorityFeePerGas:yt,nonce:gt,to:xt,value:vt,stateOverride:bt,...Et}=et,wt=tt?parseAccount(tt):void 0;if(at&&(lt||dt))throw new BaseError$3("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(at&&xt)throw new BaseError$3("Cannot provide both `code` & `to` as parameters.");const kt=at&&ct,It=lt&&dt&&xt&&ct,Rt=kt||It,Pt=kt?toDeploylessCallViaBytecodeData({code:at,data:ct}):It?toDeploylessCallViaFactoryData({data:ct,factory:lt,factoryData:dt,to:xt}):ct;try{assertRequest(et);const Yt=(rt?numberToHex(rt):void 0)||ot,Ht=serializeStateOverride(bt),Ut=(zt=(Bt=(Ot=o.chain)==null?void 0:Ot.formatters)==null?void 0:Bt.transactionRequest)==null?void 0:zt.format,Lt=(Ut||formatTransactionRequest)({...extract$1(Et,{format:Ut}),from:wt==null?void 0:wt.address,accessList:it,blobs:st,data:Pt,gas:ht,gasPrice:pt,maxFeePerBlobGas:mt,maxFeePerGas:ft,maxPriorityFeePerGas:yt,nonce:gt,to:Rt?void 0:xt,value:vt});if(nt&&shouldPerformMulticall({request:Lt})&&!Ht)try{return await scheduleMulticall(o,{...Lt,blockNumber:rt,blockTag:ot})}catch(Qt){if(!(Qt instanceof ClientChainNotConfiguredError)&&!(Qt instanceof ChainDoesNotSupportContract))throw Qt}const Zt=await o.request({method:"eth_call",params:Ht?[Lt,Yt,Ht]:[Lt,Yt]});return Zt==="0x"?{data:void 0}:{data:Zt}}catch(Ft){const Yt=getRevertErrorData(Ft),{offchainLookup:Ht,offchainLookupSignature:Ut}=await __vitePreload(async()=>{const{offchainLookup:qt,offchainLookupSignature:Lt}=await import("./ccip-BfnZBgwN.js");return{offchainLookup:qt,offchainLookupSignature:Lt}},[]);if(o.ccipRead!==!1&&(Yt==null?void 0:Yt.slice(0,10))===Ut&&xt)return{data:await Ht(o,{data:Yt,to:xt})};throw Rt&&(Yt==null?void 0:Yt.slice(0,10))==="0x101bb98d"?new CounterfactualDeploymentFailedError({factory:lt}):getCallError(Ft,{...et,account:wt,chain:o.chain})}}function shouldPerformMulticall({request:o}){const{data:et,to:tt,...nt}=o;return!(!et||et.startsWith(aggregate3Signature)||!tt||Object.values(nt).filter(rt=>typeof rt<"u").length>0)}async function scheduleMulticall(o,et){var ft;const{batchSize:tt=1024,wait:nt=0}=typeof((ft=o.batch)==null?void 0:ft.multicall)=="object"?o.batch.multicall:{},{blockNumber:rt,blockTag:ot="latest",data:it,multicallAddress:st,to:at}=et;let ct=st;if(!ct){if(!o.chain)throw new ClientChainNotConfiguredError;ct=getChainContractAddress({blockNumber:rt,chain:o.chain,contract:"multicall3"})}const dt=(rt?numberToHex(rt):void 0)||ot,{schedule:ht}=createBatchScheduler({id:`${o.uid}.${dt}`,wait:nt,shouldSplitBatch(yt){return yt.reduce((xt,{data:vt})=>xt+(vt.length-2),0)>tt*2},fn:async yt=>{const gt=yt.map(bt=>({allowFailure:!0,callData:bt.data,target:bt.to})),xt=encodeFunctionData({abi:multicall3Abi,args:[gt],functionName:"aggregate3"}),vt=await o.request({method:"eth_call",params:[{data:xt,to:ct},dt]});return decodeFunctionResult({abi:multicall3Abi,args:[gt],functionName:"aggregate3",data:vt||"0x"})}}),[{returnData:pt,success:mt}]=await ht({data:it,to:at});if(!mt)throw new RawContractError({data:pt});return pt==="0x"?{data:void 0}:{data:pt}}function toDeploylessCallViaBytecodeData(o){const{code:et,data:tt}=o;return encodeDeployData({abi:parseAbi(["constructor(bytes, bytes)"]),bytecode:deploylessCallViaBytecodeBytecode,args:[et,tt]})}function toDeploylessCallViaFactoryData(o){const{data:et,factory:tt,factoryData:nt,to:rt}=o;return encodeDeployData({abi:parseAbi(["constructor(address, bytes, address, bytes)"]),bytecode:deploylessCallViaFactoryBytecode,args:[rt,et,tt,nt]})}function getRevertErrorData(o){var tt;if(!(o instanceof BaseError$3))return;const et=o.walk();return typeof(et==null?void 0:et.data)=="object"?(tt=et.data)==null?void 0:tt.data:et.data}async function readContract$1(o,et){const{abi:tt,address:nt,args:rt,functionName:ot,...it}=et,st=encodeFunctionData({abi:tt,args:rt,functionName:ot});try{const{data:at}=await getAction$1(o,call,"call")({...it,data:st,to:nt});return decodeFunctionResult({abi:tt,args:rt,functionName:ot,data:at||"0x"})}catch(at){throw getContractError(at,{abi:tt,address:nt,args:rt,docsPath:"/docs/contract/readContract",functionName:ot})}}async function getEnsAddress$1(o,{blockNumber:et,blockTag:tt,coinType:nt,name:rt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!o.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:et,chain:o.chain,contract:"ensUniversalResolver"})}try{const ct=encodeFunctionData({abi:addressResolverAbi,functionName:"addr",...nt!=null?{args:[namehash(rt),BigInt(nt)]}:{args:[namehash(rt)]}}),lt={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(rt)),ct],blockNumber:et,blockTag:tt},dt=getAction$1(o,readContract$1,"readContract"),ht=ot?await dt({...lt,args:[...lt.args,ot]}):await dt(lt);if(ht[0]==="0x")return null;const pt=decodeFunctionResult({abi:addressResolverAbi,args:nt!=null?[namehash(rt),BigInt(nt)]:void 0,functionName:"addr",data:ht[0]});return pt==="0x"||trim$1(pt)==="0x00"?null:pt}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}class EnsAvatarInvalidMetadataError extends BaseError$3{constructor({data:et}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(et)}`],name:"EnsAvatarInvalidMetadataError"})}}class EnsAvatarInvalidNftUriError extends BaseError$3{constructor({reason:et}){super(`ENS NFT avatar URI is invalid. ${et}`,{name:"EnsAvatarInvalidNftUriError"})}}class EnsAvatarUriResolutionError extends BaseError$3{constructor({uri:et}){super(`Unable to resolve ENS avatar URI "${et}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class EnsAvatarUnsupportedNamespaceError extends BaseError$3{constructor({namespace:et}){super(`ENS NFT avatar namespace "${et}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const networkRegex=/(?https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?\/)?(?ipfs\/|ipns\/)?(?[\w\-.]+)(?\/.*)?/,ipfsHashRegex=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?[\w\-.]+))?(?\/.*)?$/,base64Regex=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,dataURIRegex=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function isImageUri(o){try{const et=await fetch(o,{method:"HEAD"});if(et.status===200){const tt=et.headers.get("content-type");return tt==null?void 0:tt.startsWith("image/")}return!1}catch(et){return typeof et=="object"&&typeof et.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(tt=>{const nt=new Image;nt.onload=()=>{tt(!0)},nt.onerror=()=>{tt(!1)},nt.src=o})}}function getGateway(o,et){return o?o.endsWith("/")?o.slice(0,-1):o:et}function resolveAvatarUri({uri:o,gatewayUrls:et}){const tt=base64Regex.test(o);if(tt)return{uri:o,isOnChain:!0,isEncoded:tt};const nt=getGateway(et==null?void 0:et.ipfs,"https://ipfs.io"),rt=getGateway(et==null?void 0:et.arweave,"https://arweave.net"),ot=o.match(networkRegex),{protocol:it,subpath:st,target:at,subtarget:ct=""}=(ot==null?void 0:ot.groups)||{},lt=it==="ipns:/"||st==="ipns/",dt=it==="ipfs:/"||st==="ipfs/"||ipfsHashRegex.test(o);if(o.startsWith("http")&&!lt&&!dt){let pt=o;return et!=null&&et.arweave&&(pt=o.replace(/https:\/\/arweave.net/g,et==null?void 0:et.arweave)),{uri:pt,isOnChain:!1,isEncoded:!1}}if((lt||dt)&&at)return{uri:`${nt}/${lt?"ipns":"ipfs"}/${at}${ct}`,isOnChain:!1,isEncoded:!1};if(it==="ar:/"&&at)return{uri:`${rt}/${at}${ct||""}`,isOnChain:!1,isEncoded:!1};let ht=o.replace(dataURIRegex,"");if(ht.startsWith("rt.json());return await parseAvatarUri({gatewayUrls:o,uri:getJsonImage(tt)})}catch{throw new EnsAvatarUriResolutionError({uri:et})}}async function parseAvatarUri({gatewayUrls:o,uri:et}){const{uri:tt,isOnChain:nt}=resolveAvatarUri({uri:et,gatewayUrls:o});if(nt||await isImageUri(tt))return tt;throw new EnsAvatarUriResolutionError({uri:et})}function parseNftUri(o){let et=o;et.startsWith("did:nft:")&&(et=et.replace("did:nft:","").replace(/_/g,"/"));const[tt,nt,rt]=et.split("/"),[ot,it]=tt.split(":"),[st,at]=nt.split(":");if(!ot||ot.toLowerCase()!=="eip155")throw new EnsAvatarInvalidNftUriError({reason:"Only EIP-155 supported"});if(!it)throw new EnsAvatarInvalidNftUriError({reason:"Chain ID not found"});if(!at)throw new EnsAvatarInvalidNftUriError({reason:"Contract address not found"});if(!rt)throw new EnsAvatarInvalidNftUriError({reason:"Token ID not found"});if(!st)throw new EnsAvatarInvalidNftUriError({reason:"ERC namespace not found"});return{chainID:Number.parseInt(it),namespace:st.toLowerCase(),contractAddress:at,tokenID:rt}}async function getNftTokenUri(o,{nft:et}){if(et.namespace==="erc721")return readContract$1(o,{address:et.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(et.tokenID)]});if(et.namespace==="erc1155")return readContract$1(o,{address:et.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(et.tokenID)]});throw new EnsAvatarUnsupportedNamespaceError({namespace:et.namespace})}async function parseAvatarRecord(o,{gatewayUrls:et,record:tt}){return/eip155:/i.test(tt)?parseNftAvatarUri(o,{gatewayUrls:et,record:tt}):parseAvatarUri({uri:tt,gatewayUrls:et})}async function parseNftAvatarUri(o,{gatewayUrls:et,record:tt}){const nt=parseNftUri(tt),rt=await getNftTokenUri(o,{nft:nt}),{uri:ot,isOnChain:it,isEncoded:st}=resolveAvatarUri({uri:rt,gatewayUrls:et});if(it&&(ot.includes("data:application/json;base64,")||ot.startsWith("{"))){const ct=st?atob(ot.replace("data:application/json;base64,","")):ot,lt=JSON.parse(ct);return parseAvatarUri({uri:getJsonImage(lt),gatewayUrls:et})}let at=nt.tokenID;return nt.namespace==="erc1155"&&(at=at.replace("0x","").padStart(64,"0")),getMetadataAvatarUri({gatewayUrls:et,uri:ot.replace(/(?:0x)?{id}/,at)})}async function getEnsText(o,{blockNumber:et,blockTag:tt,name:nt,key:rt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){let at=st;if(!at){if(!o.chain)throw new Error("client chain not configured. universalResolverAddress is required.");at=getChainContractAddress({blockNumber:et,chain:o.chain,contract:"ensUniversalResolver"})}try{const ct={address:at,abi:universalResolverResolveAbi,functionName:"resolve",args:[toHex(packetToBytes(nt)),encodeFunctionData({abi:textResolverAbi,functionName:"text",args:[namehash(nt),rt]})],blockNumber:et,blockTag:tt},lt=getAction$1(o,readContract$1,"readContract"),dt=ot?await lt({...ct,args:[...ct.args,ot]}):await lt(ct);if(dt[0]==="0x")return null;const ht=decodeFunctionResult({abi:textResolverAbi,functionName:"text",data:dt[0]});return ht===""?null:ht}catch(ct){if(it)throw ct;if(isNullUniversalResolverError(ct,"resolve"))return null;throw ct}}async function getEnsAvatar$1(o,{blockNumber:et,blockTag:tt,assetGatewayUrls:nt,name:rt,gatewayUrls:ot,strict:it,universalResolverAddress:st}){const at=await getAction$1(o,getEnsText,"getEnsText")({blockNumber:et,blockTag:tt,key:"avatar",name:rt,universalResolverAddress:st,gatewayUrls:ot,strict:it});if(!at)return null;try{return await parseAvatarRecord(o,{record:at,gatewayUrls:nt})}catch{return null}}async function getEnsName$1(o,{address:et,blockNumber:tt,blockTag:nt,gatewayUrls:rt,strict:ot,universalResolverAddress:it}){let st=it;if(!st){if(!o.chain)throw new Error("client chain not configured. universalResolverAddress is required.");st=getChainContractAddress({blockNumber:tt,chain:o.chain,contract:"ensUniversalResolver"})}const at=`${et.toLowerCase().substring(2)}.addr.reverse`;try{const ct={address:st,abi:universalResolverReverseAbi,functionName:"reverse",args:[toHex(packetToBytes(at))],blockNumber:tt,blockTag:nt},lt=getAction$1(o,readContract$1,"readContract"),[dt,ht]=rt?await lt({...ct,args:[...ct.args,rt]}):await lt(ct);return et.toLowerCase()!==ht.toLowerCase()?null:dt}catch(ct){if(ot)throw ct;if(isNullUniversalResolverError(ct,"reverse"))return null;throw ct}}const promiseCache$1=new Map,responseCache=new Map;function getCache(o){const et=(rt,ot)=>({clear:()=>ot.delete(rt),get:()=>ot.get(rt),set:it=>ot.set(rt,it)}),tt=et(o,promiseCache$1),nt=et(o,responseCache);return{clear:()=>{tt.clear(),nt.clear()},promise:tt,response:nt}}async function withCache(o,{cacheKey:et,cacheTime:tt=Number.POSITIVE_INFINITY}){const nt=getCache(et),rt=nt.response.get();if(rt&&tt>0&&new Date().getTime()-rt.created.getTime()`blockNumber.${o}`;async function getBlockNumber$1(o,{cacheTime:et=o.cacheTime}={}){const tt=await withCache(()=>o.request({method:"eth_blockNumber"}),{cacheKey:cacheKey(o.uid),cacheTime:et});return BigInt(tt)}function formatLog(o,{args:et,eventName:tt}={}){return{...o,blockHash:o.blockHash?o.blockHash:null,blockNumber:o.blockNumber?BigInt(o.blockNumber):null,logIndex:o.logIndex?Number(o.logIndex):null,transactionHash:o.transactionHash?o.transactionHash:null,transactionIndex:o.transactionIndex?Number(o.transactionIndex):null,...tt?{args:et,eventName:tt}:{}}}const receiptStatuses={"0x0":"reverted","0x1":"success"};function formatTransactionReceipt(o){const et={...o,blockNumber:o.blockNumber?BigInt(o.blockNumber):null,contractAddress:o.contractAddress?o.contractAddress:null,cumulativeGasUsed:o.cumulativeGasUsed?BigInt(o.cumulativeGasUsed):null,effectiveGasPrice:o.effectiveGasPrice?BigInt(o.effectiveGasPrice):null,gasUsed:o.gasUsed?BigInt(o.gasUsed):null,logs:o.logs?o.logs.map(tt=>formatLog(tt)):null,to:o.to?o.to:null,transactionIndex:o.transactionIndex?hexToNumber$2(o.transactionIndex):null,status:o.status?receiptStatuses[o.status]:null,type:o.type?transactionType[o.type]||o.type:null};return o.blobGasPrice&&(et.blobGasPrice=BigInt(o.blobGasPrice)),o.blobGasUsed&&(et.blobGasUsed=BigInt(o.blobGasUsed)),et}const defineTransactionReceipt=defineFormatter("transactionReceipt",formatTransactionReceipt);async function multicall$1(o,et){var yt;const{allowFailure:tt=!0,batchSize:nt,blockNumber:rt,blockTag:ot,multicallAddress:it,stateOverride:st}=et,at=et.contracts,ct=nt??(typeof((yt=o.batch)==null?void 0:yt.multicall)=="object"&&o.batch.multicall.batchSize||1024);let lt=it;if(!lt){if(!o.chain)throw new Error("client chain not configured. multicallAddress is required.");lt=getChainContractAddress({blockNumber:rt,chain:o.chain,contract:"multicall3"})}const dt=[[]];let ht=0,pt=0;for(let gt=0;gt0&&pt>ct&&dt[ht].length>0&&(ht++,pt=(wt.length-2)/2,dt[ht]=[]),dt[ht]=[...dt[ht],{allowFailure:!0,callData:wt,target:vt}]}catch(wt){const kt=getContractError(wt,{abi:xt,address:vt,args:bt,docsPath:"/docs/contract/multicall",functionName:Et});if(!tt)throw kt;dt[ht]=[...dt[ht],{allowFailure:!0,callData:"0x",target:vt}]}}const mt=await Promise.allSettled(dt.map(gt=>getAction$1(o,readContract$1,"readContract")({abi:multicall3Abi,address:lt,args:[gt],blockNumber:rt,blockTag:ot,functionName:"aggregate3",stateOverride:st}))),ft=[];for(let gt=0;gtlistenersCache.get(o)||[],ot=()=>{const lt=rt();listenersCache.set(o,lt.filter(dt=>dt.id!==nt))},it=()=>{const lt=cleanupCache.get(o);rt().length===1&<&<(),ot()},st=rt();if(listenersCache.set(o,[...st,{id:nt,fns:et}]),st&&st.length>0)return it;const at={};for(const lt in et)at[lt]=(...dt)=>{var pt,mt;const ht=rt();if(ht.length!==0)for(const ft of ht)(mt=(pt=ft.fns)[lt])==null||mt.call(pt,...dt)};const ct=tt(at);return typeof ct=="function"&&cleanupCache.set(o,ct),it}async function wait$1(o){return new Promise(et=>setTimeout(et,o))}function poll(o,{emitOnBegin:et,initialWaitTime:tt,interval:nt}){let rt=!0;const ot=()=>rt=!1;return(async()=>{let st;et&&(st=await o({unpoll:ot}));const at=await(tt==null?void 0:tt(st))??nt;await wait$1(at);const ct=async()=>{rt&&(await o({unpoll:ot}),await wait$1(nt),ct())};ct()})(),ot}function watchBlockNumber$1(o,{emitOnBegin:et=!1,emitMissed:tt=!1,onBlockNumber:nt,onError:rt,poll:ot,pollingInterval:it=o.pollingInterval}){const st=typeof ot<"u"?ot:!(o.transport.type==="webSocket"||o.transport.type==="fallback"&&o.transport.transports[0].config.type==="webSocket");let at;return st?(()=>{const dt=stringify$2(["watchBlockNumber",o.uid,et,tt,it]);return observe(dt,{onBlockNumber:nt,onError:rt},ht=>poll(async()=>{var pt;try{const mt=await getAction$1(o,getBlockNumber$1,"getBlockNumber")({cacheTime:0});if(at){if(mt===at)return;if(mt-at>1&&tt)for(let ft=at+1n;ftat)&&(ht.onBlockNumber(mt,at),at=mt)}catch(mt){(pt=ht.onError)==null||pt.call(ht,mt)}},{emitOnBegin:et,interval:it}))})():(()=>{const dt=stringify$2(["watchBlockNumber",o.uid,et,tt]);return observe(dt,{onBlockNumber:nt,onError:rt},ht=>{let pt=!0,mt=()=>pt=!1;return(async()=>{try{const ft=(()=>{if(o.transport.type==="fallback"){const gt=o.transport.transports.find(xt=>xt.config.type==="webSocket");return gt?gt.value:o.transport}return o.transport})(),{unsubscribe:yt}=await ft.subscribe({params:["newHeads"],onData(gt){var vt;if(!pt)return;const xt=hexToBigInt((vt=gt.result)==null?void 0:vt.number);ht.onBlockNumber(xt,at),at=xt},onError(gt){var xt;(xt=ht.onError)==null||xt.call(ht,gt)}});mt=yt,pt||mt()}catch(ft){rt==null||rt(ft)}})(),()=>mt()})})()}const promiseCache=new LruMap(8192);function withDedupe(o,{enabled:et=!0,id:tt}){if(!et||!tt)return o();if(promiseCache.get(tt))return promiseCache.get(tt);const nt=o().finally(()=>promiseCache.delete(tt));return promiseCache.set(tt,nt),nt}function withRetry(o,{delay:et=100,retryCount:tt=2,shouldRetry:nt=()=>!0}={}){return new Promise((rt,ot)=>{const it=async({count:st=0}={})=>{const at=async({error:ct})=>{const lt=typeof et=="function"?et({count:st,error:ct}):et;lt&&await wait$1(lt),it({count:st+1})};try{const ct=await o();rt(ct)}catch(ct){if(st{const{dedupe:rt=!1,retryDelay:ot=150,retryCount:it=3,uid:st}={...et,...nt},at=rt?keccak256$1(stringToHex(`${st}.${stringify$2(tt)}`)):void 0;return withDedupe(()=>withRetry(async()=>{try{return await o(tt)}catch(ct){const lt=ct;switch(lt.code){case ParseRpcError.code:throw new ParseRpcError(lt);case InvalidRequestRpcError.code:throw new InvalidRequestRpcError(lt);case MethodNotFoundRpcError.code:throw new MethodNotFoundRpcError(lt,{method:tt.method});case InvalidParamsRpcError.code:throw new InvalidParamsRpcError(lt);case InternalRpcError.code:throw new InternalRpcError(lt);case InvalidInputRpcError.code:throw new InvalidInputRpcError(lt);case ResourceNotFoundRpcError.code:throw new ResourceNotFoundRpcError(lt);case ResourceUnavailableRpcError.code:throw new ResourceUnavailableRpcError(lt);case TransactionRejectedRpcError.code:throw new TransactionRejectedRpcError(lt);case MethodNotSupportedRpcError.code:throw new MethodNotSupportedRpcError(lt,{method:tt.method});case LimitExceededRpcError.code:throw new LimitExceededRpcError(lt);case JsonRpcVersionUnsupportedError.code:throw new JsonRpcVersionUnsupportedError(lt);case UserRejectedRequestError.code:throw new UserRejectedRequestError(lt);case UnauthorizedProviderError.code:throw new UnauthorizedProviderError(lt);case UnsupportedProviderMethodError.code:throw new UnsupportedProviderMethodError(lt);case ProviderDisconnectedError.code:throw new ProviderDisconnectedError(lt);case ChainDisconnectedError.code:throw new ChainDisconnectedError(lt);case SwitchChainError.code:throw new SwitchChainError(lt);case 5e3:throw new UserRejectedRequestError(lt);default:throw ct instanceof BaseError$3?ct:new UnknownRpcError(lt)}}},{delay:({count:ct,error:lt})=>{var dt;if(lt&< instanceof HttpRequestError){const ht=(dt=lt==null?void 0:lt.headers)==null?void 0:dt.get("Retry-After");if(ht!=null&&ht.match(/\d/))return Number.parseInt(ht)*1e3}return~~(1<shouldRetry(ct)}),{enabled:rt,id:at})}}function shouldRetry(o){return"code"in o&&typeof o.code=="number"?o.code===-1||o.code===LimitExceededRpcError.code||o.code===InternalRpcError.code:o instanceof HttpRequestError&&o.status?o.status===403||o.status===408||o.status===413||o.status===429||o.status===500||o.status===502||o.status===503||o.status===504:!0}function defineChain(o){return{formatters:void 0,fees:void 0,serializers:void 0,...o}}function withTimeout(o,{errorInstance:et=new Error("timed out"),timeout:tt,signal:nt}){return new Promise((rt,ot)=>{(async()=>{let it;try{const st=new AbortController;tt>0&&(it=setTimeout(()=>{nt?st.abort():ot(et)},tt)),rt(await o({signal:(st==null?void 0:st.signal)||null}))}catch(st){(st==null?void 0:st.name)==="AbortError"&&ot(et),ot(st)}finally{clearTimeout(it)}})()})}function createIdStore(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const idCache=createIdStore();function getHttpRpcClient(o,et={}){return{async request(tt){var dt;const{body:nt,onRequest:rt=et.onRequest,onResponse:ot=et.onResponse,timeout:it=et.timeout??1e4}=tt,st={...et.fetchOptions??{},...tt.fetchOptions??{}},{headers:at,method:ct,signal:lt}=st;try{const ht=await withTimeout(async({signal:mt})=>{const ft={...st,body:Array.isArray(nt)?stringify$2(nt.map(vt=>({jsonrpc:"2.0",id:vt.id??idCache.take(),...vt}))):stringify$2({jsonrpc:"2.0",id:nt.id??idCache.take(),...nt}),headers:{"Content-Type":"application/json",...at},method:ct||"POST",signal:lt||(it>0?mt:null)},yt=new Request(o,ft),gt=await(rt==null?void 0:rt(yt,ft))??{...ft,url:o};return await fetch(gt.url??o,gt)},{errorInstance:new TimeoutError$4({body:nt,url:o}),timeout:it,signal:!0});ot&&await ot(ht);let pt;if((dt=ht.headers.get("Content-Type"))!=null&&dt.startsWith("application/json"))pt=await ht.json();else{pt=await ht.text();try{pt=JSON.parse(pt||"{}")}catch(mt){if(ht.ok)throw mt;pt={error:pt}}}if(!ht.ok)throw new HttpRequestError({body:nt,details:stringify$2(pt.error)||ht.statusText,headers:ht.headers,status:ht.status,url:o});return pt}catch(ht){throw ht instanceof HttpRequestError||ht instanceof TimeoutError$4?ht:new HttpRequestError({body:nt,cause:ht,url:o})}}}}function assertTransactionEIP7702(o){const{authorizationList:et}=o;if(et)for(const tt of et){const{contractAddress:nt,chainId:rt}=tt;if(!isAddress(nt))throw new InvalidAddressError({address:nt});if(rt<0)throw new InvalidChainIdError({chainId:rt})}assertTransactionEIP1559(o)}function assertTransactionEIP4844(o){const{blobVersionedHashes:et}=o;if(et){if(et.length===0)throw new EmptyBlobError;for(const tt of et){const nt=size$2(tt),rt=hexToNumber$2(slice(tt,0,1));if(nt!==32)throw new InvalidVersionedHashSizeError({hash:tt,size:nt});if(rt!==versionedHashVersionKzg)throw new InvalidVersionedHashVersionError({hash:tt,version:rt})}}assertTransactionEIP1559(o)}function assertTransactionEIP1559(o){const{chainId:et,maxPriorityFeePerGas:tt,maxFeePerGas:nt,to:rt}=o;if(et<=0)throw new InvalidChainIdError({chainId:et});if(rt&&!isAddress(rt))throw new InvalidAddressError({address:rt});if(nt&&nt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:nt});if(tt&&nt&&tt>nt)throw new TipAboveFeeCapError({maxFeePerGas:nt,maxPriorityFeePerGas:tt})}function assertTransactionEIP2930(o){const{chainId:et,maxPriorityFeePerGas:tt,gasPrice:nt,maxFeePerGas:rt,to:ot}=o;if(et<=0)throw new InvalidChainIdError({chainId:et});if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(tt||rt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(nt&&nt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:nt})}function assertTransactionLegacy(o){const{chainId:et,maxPriorityFeePerGas:tt,gasPrice:nt,maxFeePerGas:rt,to:ot}=o;if(ot&&!isAddress(ot))throw new InvalidAddressError({address:ot});if(typeof et<"u"&&et<=0)throw new InvalidChainIdError({chainId:et});if(tt||rt)throw new BaseError$3("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(nt&&nt>maxUint256)throw new FeeCapTooHighError({maxFeePerGas:nt})}function serializeAuthorizationList(o){if(!o||o.length===0)return[];const et=[];for(const tt of o){const{contractAddress:nt,chainId:rt,nonce:ot,...it}=tt;et.push([rt?toHex(rt):"0x",nt,ot?toHex(ot):"0x",...toYParitySignatureArray({},it)])}return et}function serializeAccessList(o){if(!o||o.length===0)return[];const et=[];for(let tt=0;tt"u"||typeof pt>"u")){const vt=typeof o.blobs[0]=="string"?o.blobs:o.blobs.map(wt=>bytesToHex$4(wt)),bt=o.kzg,Et=blobsToCommitments({blobs:vt,kzg:bt});if(typeof ht>"u"&&(ht=commitmentsToVersionedHashes({commitments:Et})),typeof pt>"u"){const wt=blobsToProofs({blobs:vt,commitments:Et,kzg:bt});pt=toBlobSidecars({blobs:vt,commitments:Et,proofs:wt})}}const mt=serializeAccessList(lt),ft=[toHex(tt),rt?toHex(rt):"0x",ct?toHex(ct):"0x",at?toHex(at):"0x",nt?toHex(nt):"0x",ot??"0x",it?toHex(it):"0x",dt??"0x",mt,st?toHex(st):"0x",ht??[],...toYParitySignatureArray(o,et)],yt=[],gt=[],xt=[];if(pt)for(let vt=0;vt{if(et.v>=35n)return(et.v-35n)/2n>0?et.v:27n+(et.v===35n?0n:1n);if(tt>0)return BigInt(tt*2)+BigInt(35n+et.v-27n);const pt=27n+(et.v===27n?0n:1n);if(et.v!==pt)throw new InvalidLegacyVError({v:et.v});return pt})(),dt=trim$1(et.r),ht=trim$1(et.s);ct=[...ct,toHex(lt),dt==="0x00"?"0x":dt,ht==="0x00"?"0x":ht]}else tt>0&&(ct=[...ct,toHex(tt),"0x","0x"]);return toRlp(ct)}function toYParitySignatureArray(o,et){const tt=et??o,{v:nt,yParity:rt}=tt;if(typeof tt.r>"u")return[];if(typeof tt.s>"u")return[];if(typeof nt>"u"&&typeof rt>"u")return[];const ot=trim$1(tt.r),it=trim$1(tt.s);return[typeof rt=="number"?rt?toHex(1):"0x":nt===0n?"0x":nt===1n?toHex(1):nt===27n?"0x":toHex(1),ot==="0x00"?"0x":ot,it==="0x00"?"0x":it]}async function signMessage$1(o,{account:et=o.account,message:tt}){if(!et)throw new AccountNotFoundError({docsPath:"/docs/actions/wallet/signMessage"});const nt=parseAccount(et);if(nt.signMessage)return nt.signMessage({message:tt});const rt=typeof tt=="string"?stringToHex(tt):tt.raw instanceof Uint8Array?toHex(tt.raw):tt.raw;return o.request({method:"personal_sign",params:[rt,nt.address]},{retryCount:0})}class HMAC extends Hash{constructor(et,tt){super(),this.finished=!1,this.destroyed=!1,hash$1(et);const nt=toBytes$2(tt);if(this.iHash=et.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const rt=this.blockLen,ot=new Uint8Array(rt);ot.set(nt.length>rt?et.create().update(nt).digest():nt);for(let it=0;itnew HMAC(o,et).update(tt).digest();hmac.create=(o,et)=>new HMAC(o,et);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$6=BigInt(0),_1n$8=BigInt(1),_2n$5=BigInt(2);function isBytes$2(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function abytes(o){if(!isBytes$2(o))throw new Error("Uint8Array expected")}function abool(o,et){if(typeof et!="boolean")throw new Error(`${o} must be valid boolean, got "${et}".`)}const hexes$1=Array.from({length:256},(o,et)=>et.toString(16).padStart(2,"0"));function bytesToHex$2(o){abytes(o);let et="";for(let tt=0;tt=asciis._0&&o<=asciis._9)return o-asciis._0;if(o>=asciis._A&&o<=asciis._F)return o-(asciis._A-10);if(o>=asciis._a&&o<=asciis._f)return o-(asciis._a-10)}function hexToBytes$2(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);const et=o.length,tt=et/2;if(et%2)throw new Error("padded hex string expected, got unpadded hex of length "+et);const nt=new Uint8Array(tt);for(let rt=0,ot=0;rttypeof o=="bigint"&&_0n$6<=o;function inRange(o,et,tt){return isPosBig(o)&&isPosBig(et)&&isPosBig(tt)&&et<=o&&o_0n$6;o>>=_1n$8,et+=1);return et}function bitGet(o,et){return o>>BigInt(et)&_1n$8}function bitSet(o,et,tt){return o|(tt?_1n$8:_0n$6)<(_2n$5<new Uint8Array(o),u8fr=o=>Uint8Array.from(o);function createHmacDrbg(o,et,tt){if(typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof et!="number"||et<2)throw new Error("qByteLen must be a number");if(typeof tt!="function")throw new Error("hmacFn must be a function");let nt=u8n(o),rt=u8n(o),ot=0;const it=()=>{nt.fill(1),rt.fill(0),ot=0},st=(...dt)=>tt(rt,nt,...dt),at=(dt=u8n())=>{rt=st(u8fr([0]),dt),nt=st(),dt.length!==0&&(rt=st(u8fr([1]),dt),nt=st())},ct=()=>{if(ot++>=1e3)throw new Error("drbg: tried 1000 values");let dt=0;const ht=[];for(;dt{it(),at(dt);let pt;for(;!(pt=ht(ct()));)at();return it(),pt}}const validatorFns={bigint:o=>typeof o=="bigint",function:o=>typeof o=="function",boolean:o=>typeof o=="boolean",string:o=>typeof o=="string",stringOrUint8Array:o=>typeof o=="string"||isBytes$2(o),isSafeInteger:o=>Number.isSafeInteger(o),array:o=>Array.isArray(o),field:(o,et)=>et.Fp.isValid(o),hash:o=>typeof o=="function"&&Number.isSafeInteger(o.outputLen)};function validateObject(o,et,tt={}){const nt=(rt,ot,it)=>{const st=validatorFns[ot];if(typeof st!="function")throw new Error(`Invalid validator "${ot}", expected function`);const at=o[rt];if(!(it&&at===void 0)&&!st(at,o))throw new Error(`Invalid param ${String(rt)}=${at} (${typeof at}), expected ${ot}`)};for(const[rt,ot]of Object.entries(et))nt(rt,ot,!1);for(const[rt,ot]of Object.entries(tt))nt(rt,ot,!0);return o}const notImplemented=()=>{throw new Error("not implemented")};function memoized(o){const et=new WeakMap;return(tt,...nt)=>{const rt=et.get(tt);if(rt!==void 0)return rt;const ot=o(tt,...nt);return et.set(tt,ot),ot}}const ut=Object.freeze(Object.defineProperty({__proto__:null,aInRange,abool,abytes,bitGet,bitLen,bitMask,bitSet,bytesToHex:bytesToHex$2,bytesToNumberBE,bytesToNumberLE,concatBytes:concatBytes$1,createHmacDrbg,ensureBytes:ensureBytes$1,equalBytes:equalBytes$1,hexToBytes:hexToBytes$2,hexToNumber:hexToNumber$1,inRange,isBytes:isBytes$2,memoized,notImplemented,numberToBytesBE,numberToBytesLE,numberToHexUnpadded:numberToHexUnpadded$1,numberToVarBytesBE,utf8ToBytes:utf8ToBytes$2,validateObject},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$5=BigInt(0),_1n$7=BigInt(1),_2n$4=BigInt(2),_3n$3=BigInt(3),_4n=BigInt(4),_5n$1=BigInt(5),_8n$3=BigInt(8);BigInt(9);BigInt(16);function mod$1(o,et){const tt=o%et;return tt>=_0n$5?tt:et+tt}function pow(o,et,tt){if(tt<=_0n$5||et<_0n$5)throw new Error("Expected power/modulo > 0");if(tt===_1n$7)return _0n$5;let nt=_1n$7;for(;et>_0n$5;)et&_1n$7&&(nt=nt*o%tt),o=o*o%tt,et>>=_1n$7;return nt}function pow2$1(o,et,tt){let nt=o;for(;et-- >_0n$5;)nt*=nt,nt%=tt;return nt}function invert$1(o,et){if(o===_0n$5||et<=_0n$5)throw new Error(`invert: expected positive integers, got n=${o} mod=${et}`);let tt=mod$1(o,et),nt=et,rt=_0n$5,ot=_1n$7;for(;tt!==_0n$5;){const st=nt/tt,at=nt%tt,ct=rt-ot*st;nt=tt,tt=at,rt=ot,ot=ct}if(nt!==_1n$7)throw new Error("invert: does not exist");return mod$1(rt,et)}function tonelliShanks(o){const et=(o-_1n$7)/_2n$4;let tt,nt,rt;for(tt=o-_1n$7,nt=0;tt%_2n$4===_0n$5;tt/=_2n$4,nt++);for(rt=_2n$4;rt(mod$1(o,et)&_1n$7)===_1n$7,FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(o){const et={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},tt=FIELD_FIELDS.reduce((nt,rt)=>(nt[rt]="function",nt),et);return validateObject(o,tt)}function FpPow(o,et,tt){if(tt<_0n$5)throw new Error("Expected power > 0");if(tt===_0n$5)return o.ONE;if(tt===_1n$7)return et;let nt=o.ONE,rt=et;for(;tt>_0n$5;)tt&_1n$7&&(nt=o.mul(nt,rt)),rt=o.sqr(rt),tt>>=_1n$7;return nt}function FpInvertBatch(o,et){const tt=new Array(et.length),nt=et.reduce((ot,it,st)=>o.is0(it)?ot:(tt[st]=ot,o.mul(ot,it)),o.ONE),rt=o.inv(nt);return et.reduceRight((ot,it,st)=>o.is0(it)?ot:(tt[st]=o.mul(ot,tt[st]),o.mul(ot,it)),rt),tt}function nLength(o,et){const tt=et!==void 0?et:o.toString(2).length,nt=Math.ceil(tt/8);return{nBitLength:tt,nByteLength:nt}}function Field$1(o,et,tt=!1,nt={}){if(o<=_0n$5)throw new Error(`Expected Field ORDER > 0, got ${o}`);const{nBitLength:rt,nByteLength:ot}=nLength(o,et);if(ot>2048)throw new Error("Field lengths over 2048 bytes are not supported");const it=FpSqrt(o),st=Object.freeze({ORDER:o,BITS:rt,BYTES:ot,MASK:bitMask(rt),ZERO:_0n$5,ONE:_1n$7,create:at=>mod$1(at,o),isValid:at=>{if(typeof at!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof at}`);return _0n$5<=at&&atat===_0n$5,isOdd:at=>(at&_1n$7)===_1n$7,neg:at=>mod$1(-at,o),eql:(at,ct)=>at===ct,sqr:at=>mod$1(at*at,o),add:(at,ct)=>mod$1(at+ct,o),sub:(at,ct)=>mod$1(at-ct,o),mul:(at,ct)=>mod$1(at*ct,o),pow:(at,ct)=>FpPow(st,at,ct),div:(at,ct)=>mod$1(at*invert$1(ct,o),o),sqrN:at=>at*at,addN:(at,ct)=>at+ct,subN:(at,ct)=>at-ct,mulN:(at,ct)=>at*ct,inv:at=>invert$1(at,o),sqrt:nt.sqrt||(at=>it(st,at)),invertBatch:at=>FpInvertBatch(st,at),cmov:(at,ct,lt)=>lt?ct:at,toBytes:at=>tt?numberToBytesLE(at,ot):numberToBytesBE(at,ot),fromBytes:at=>{if(at.length!==ot)throw new Error(`Fp.fromBytes: expected ${ot}, got ${at.length}`);return tt?bytesToNumberLE(at):bytesToNumberBE(at)}});return Object.freeze(st)}function getFieldBytesLength(o){if(typeof o!="bigint")throw new Error("field order must be bigint");const et=o.toString(2).length;return Math.ceil(et/8)}function getMinHashLength(o){const et=getFieldBytesLength(o);return et+Math.ceil(et/2)}function mapHashToField(o,et,tt=!1){const nt=o.length,rt=getFieldBytesLength(et),ot=getMinHashLength(et);if(nt<16||nt1024)throw new Error(`expected ${ot}-1024 bytes of input, got ${nt}`);const it=tt?bytesToNumberBE(o):bytesToNumberLE(o),st=mod$1(it,et-_1n$7)+_1n$7;return tt?numberToBytesLE(st,rt):numberToBytesBE(st,rt)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$4=BigInt(0),_1n$6=BigInt(1),pointPrecomputes$1=new WeakMap,pointWindowSizes=new WeakMap;function wNAF(o,et){const tt=(ot,it)=>{const st=it.negate();return ot?st:it},nt=ot=>{if(!Number.isSafeInteger(ot)||ot<=0||ot>et)throw new Error(`Wrong window size=${ot}, should be [1..${et}]`)},rt=ot=>{nt(ot);const it=Math.ceil(et/ot)+1,st=2**(ot-1);return{windows:it,windowSize:st}};return{constTimeNegate:tt,unsafeLadder(ot,it){let st=o.ZERO,at=ot;for(;it>_0n$4;)it&_1n$6&&(st=st.add(at)),at=at.double(),it>>=_1n$6;return st},precomputeWindow(ot,it){const{windows:st,windowSize:at}=rt(it),ct=[];let lt=ot,dt=lt;for(let ht=0;ht>=mt,gt>ct&&(gt-=pt,st+=_1n$6);const xt=yt,vt=yt+Math.abs(gt)-1,bt=ft%2!==0,Et=gt<0;gt===0?dt=dt.add(tt(bt,it[xt])):lt=lt.add(tt(Et,it[vt]))}return{p:lt,f:dt}},wNAFCached(ot,it,st){const at=pointWindowSizes.get(ot)||1;let ct=pointPrecomputes$1.get(ot);return ct||(ct=this.precomputeWindow(ot,at),at!==1&&pointPrecomputes$1.set(ot,st(ct))),this.wNAF(at,ct,it)},setWindowSize(ot,it){nt(it),pointWindowSizes.set(ot,it),pointPrecomputes$1.delete(ot)}}}function pippenger(o,et,tt,nt){if(!Array.isArray(tt)||!Array.isArray(nt)||nt.length!==tt.length)throw new Error("arrays of points and scalars must have equal length");nt.forEach((lt,dt)=>{if(!et.isValid(lt))throw new Error(`wrong scalar at index ${dt}`)}),tt.forEach((lt,dt)=>{if(!(lt instanceof o))throw new Error(`wrong point at index ${dt}`)});const rt=bitLen(BigInt(tt.length)),ot=rt>12?rt-3:rt>4?rt-2:rt?2:1,it=(1<=0;lt-=ot){st.fill(o.ZERO);for(let ht=0;ht>BigInt(lt)&BigInt(it));st[mt]=st[mt].add(tt[ht])}let dt=o.ZERO;for(let ht=st.length-1,pt=o.ZERO;ht>0;ht--)pt=pt.add(st[ht]),dt=dt.add(pt);if(ct=ct.add(dt),lt!==0)for(let ht=0;ht{const{Err:tt}=DER;if(o<0||o>256)throw new tt("tlv.encode: wrong tag");if(et.length&1)throw new tt("tlv.encode: unpadded data");const nt=et.length/2,rt=numberToHexUnpadded$1(nt);if(rt.length/2&128)throw new tt("tlv.encode: long form length too big");const ot=nt>127?numberToHexUnpadded$1(rt.length/2|128):"";return`${numberToHexUnpadded$1(o)}${ot}${rt}${et}`},decode(o,et){const{Err:tt}=DER;let nt=0;if(o<0||o>256)throw new tt("tlv.encode: wrong tag");if(et.length<2||et[nt++]!==o)throw new tt("tlv.decode: wrong tlv");const rt=et[nt++],ot=!!(rt&128);let it=0;if(!ot)it=rt;else{const at=rt&127;if(!at)throw new tt("tlv.decode(long): indefinite length not supported");if(at>4)throw new tt("tlv.decode(long): byte length is too big");const ct=et.subarray(nt,nt+at);if(ct.length!==at)throw new tt("tlv.decode: length bytes not complete");if(ct[0]===0)throw new tt("tlv.decode(long): zero leftmost byte");for(const lt of ct)it=it<<8|lt;if(nt+=at,it<128)throw new tt("tlv.decode(long): not minimal encoding")}const st=et.subarray(nt,nt+it);if(st.length!==it)throw new tt("tlv.decode: wrong value length");return{v:st,l:et.subarray(nt+it)}}},_int:{encode(o){const{Err:et}=DER;if(o<_0n$3)throw new et("integer: negative integers are not allowed");let tt=numberToHexUnpadded$1(o);if(Number.parseInt(tt[0],16)&8&&(tt="00"+tt),tt.length&1)throw new et("unexpected assertion");return tt},decode(o){const{Err:et}=DER;if(o[0]&128)throw new et("Invalid signature integer: negative");if(o[0]===0&&!(o[1]&128))throw new et("Invalid signature integer: unnecessary leading zero");return b2n(o)}},toSig(o){const{Err:et,_int:tt,_tlv:nt}=DER,rt=typeof o=="string"?h2b(o):o;abytes(rt);const{v:ot,l:it}=nt.decode(48,rt);if(it.length)throw new et("Invalid signature: left bytes after parsing");const{v:st,l:at}=nt.decode(2,ot),{v:ct,l:lt}=nt.decode(2,at);if(lt.length)throw new et("Invalid signature: left bytes after parsing");return{r:tt.decode(st),s:tt.decode(ct)}},hexFromSig(o){const{_tlv:et,_int:tt}=DER,nt=`${et.encode(2,tt.encode(o.r))}${et.encode(2,tt.encode(o.s))}`;return et.encode(48,nt)}},_0n$3=BigInt(0),_1n$5=BigInt(1);BigInt(2);const _3n$2=BigInt(3);BigInt(4);function weierstrassPoints(o){const et=validatePointOpts(o),{Fp:tt}=et,nt=Field$1(et.n,et.nBitLength),rt=et.toBytes||((ft,yt,gt)=>{const xt=yt.toAffine();return concatBytes$1(Uint8Array.from([4]),tt.toBytes(xt.x),tt.toBytes(xt.y))}),ot=et.fromBytes||(ft=>{const yt=ft.subarray(1),gt=tt.fromBytes(yt.subarray(0,tt.BYTES)),xt=tt.fromBytes(yt.subarray(tt.BYTES,2*tt.BYTES));return{x:gt,y:xt}});function it(ft){const{a:yt,b:gt}=et,xt=tt.sqr(ft),vt=tt.mul(xt,ft);return tt.add(tt.add(vt,tt.mul(ft,yt)),gt)}if(!tt.eql(tt.sqr(et.Gy),it(et.Gx)))throw new Error("bad generator point: equation left != right");function st(ft){return inRange(ft,_1n$5,et.n)}function at(ft){const{allowedPrivateKeyLengths:yt,nByteLength:gt,wrapPrivateKey:xt,n:vt}=et;if(yt&&typeof ft!="bigint"){if(isBytes$2(ft)&&(ft=bytesToHex$2(ft)),typeof ft!="string"||!yt.includes(ft.length))throw new Error("Invalid key");ft=ft.padStart(gt*2,"0")}let bt;try{bt=typeof ft=="bigint"?ft:bytesToNumberBE(ensureBytes$1("private key",ft,gt))}catch{throw new Error(`private key must be ${gt} bytes, hex or bigint, not ${typeof ft}`)}return xt&&(bt=mod$1(bt,vt)),aInRange("private key",bt,_1n$5,vt),bt}function ct(ft){if(!(ft instanceof ht))throw new Error("ProjectivePoint expected")}const lt=memoized((ft,yt)=>{const{px:gt,py:xt,pz:vt}=ft;if(tt.eql(vt,tt.ONE))return{x:gt,y:xt};const bt=ft.is0();yt==null&&(yt=bt?tt.ONE:tt.inv(vt));const Et=tt.mul(gt,yt),wt=tt.mul(xt,yt),kt=tt.mul(vt,yt);if(bt)return{x:tt.ZERO,y:tt.ZERO};if(!tt.eql(kt,tt.ONE))throw new Error("invZ was invalid");return{x:Et,y:wt}}),dt=memoized(ft=>{if(ft.is0()){if(et.allowInfinityPoint&&!tt.is0(ft.py))return;throw new Error("bad point: ZERO")}const{x:yt,y:gt}=ft.toAffine();if(!tt.isValid(yt)||!tt.isValid(gt))throw new Error("bad point: x or y not FE");const xt=tt.sqr(gt),vt=it(yt);if(!tt.eql(xt,vt))throw new Error("bad point: equation left != right");if(!ft.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class ht{constructor(yt,gt,xt){if(this.px=yt,this.py=gt,this.pz=xt,yt==null||!tt.isValid(yt))throw new Error("x required");if(gt==null||!tt.isValid(gt))throw new Error("y required");if(xt==null||!tt.isValid(xt))throw new Error("z required");Object.freeze(this)}static fromAffine(yt){const{x:gt,y:xt}=yt||{};if(!yt||!tt.isValid(gt)||!tt.isValid(xt))throw new Error("invalid affine point");if(yt instanceof ht)throw new Error("projective point not allowed");const vt=bt=>tt.eql(bt,tt.ZERO);return vt(gt)&&vt(xt)?ht.ZERO:new ht(gt,xt,tt.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(yt){const gt=tt.invertBatch(yt.map(xt=>xt.pz));return yt.map((xt,vt)=>xt.toAffine(gt[vt])).map(ht.fromAffine)}static fromHex(yt){const gt=ht.fromAffine(ot(ensureBytes$1("pointHex",yt)));return gt.assertValidity(),gt}static fromPrivateKey(yt){return ht.BASE.multiply(at(yt))}static msm(yt,gt){return pippenger(ht,nt,yt,gt)}_setWindowSize(yt){mt.setWindowSize(this,yt)}assertValidity(){dt(this)}hasEvenY(){const{y:yt}=this.toAffine();if(tt.isOdd)return!tt.isOdd(yt);throw new Error("Field doesn't support isOdd")}equals(yt){ct(yt);const{px:gt,py:xt,pz:vt}=this,{px:bt,py:Et,pz:wt}=yt,kt=tt.eql(tt.mul(gt,wt),tt.mul(bt,vt)),It=tt.eql(tt.mul(xt,wt),tt.mul(Et,vt));return kt&&It}negate(){return new ht(this.px,tt.neg(this.py),this.pz)}double(){const{a:yt,b:gt}=et,xt=tt.mul(gt,_3n$2),{px:vt,py:bt,pz:Et}=this;let wt=tt.ZERO,kt=tt.ZERO,It=tt.ZERO,Rt=tt.mul(vt,vt),Pt=tt.mul(bt,bt),jt=tt.mul(Et,Et),Ot=tt.mul(vt,bt);return Ot=tt.add(Ot,Ot),It=tt.mul(vt,Et),It=tt.add(It,It),wt=tt.mul(yt,It),kt=tt.mul(xt,jt),kt=tt.add(wt,kt),wt=tt.sub(Pt,kt),kt=tt.add(Pt,kt),kt=tt.mul(wt,kt),wt=tt.mul(Ot,wt),It=tt.mul(xt,It),jt=tt.mul(yt,jt),Ot=tt.sub(Rt,jt),Ot=tt.mul(yt,Ot),Ot=tt.add(Ot,It),It=tt.add(Rt,Rt),Rt=tt.add(It,Rt),Rt=tt.add(Rt,jt),Rt=tt.mul(Rt,Ot),kt=tt.add(kt,Rt),jt=tt.mul(bt,Et),jt=tt.add(jt,jt),Rt=tt.mul(jt,Ot),wt=tt.sub(wt,Rt),It=tt.mul(jt,Pt),It=tt.add(It,It),It=tt.add(It,It),new ht(wt,kt,It)}add(yt){ct(yt);const{px:gt,py:xt,pz:vt}=this,{px:bt,py:Et,pz:wt}=yt;let kt=tt.ZERO,It=tt.ZERO,Rt=tt.ZERO;const Pt=et.a,jt=tt.mul(et.b,_3n$2);let Ot=tt.mul(gt,bt),Bt=tt.mul(xt,Et),zt=tt.mul(vt,wt),Ft=tt.add(gt,xt),Yt=tt.add(bt,Et);Ft=tt.mul(Ft,Yt),Yt=tt.add(Ot,Bt),Ft=tt.sub(Ft,Yt),Yt=tt.add(gt,vt);let Ht=tt.add(bt,wt);return Yt=tt.mul(Yt,Ht),Ht=tt.add(Ot,zt),Yt=tt.sub(Yt,Ht),Ht=tt.add(xt,vt),kt=tt.add(Et,wt),Ht=tt.mul(Ht,kt),kt=tt.add(Bt,zt),Ht=tt.sub(Ht,kt),Rt=tt.mul(Pt,Yt),kt=tt.mul(jt,zt),Rt=tt.add(kt,Rt),kt=tt.sub(Bt,Rt),Rt=tt.add(Bt,Rt),It=tt.mul(kt,Rt),Bt=tt.add(Ot,Ot),Bt=tt.add(Bt,Ot),zt=tt.mul(Pt,zt),Yt=tt.mul(jt,Yt),Bt=tt.add(Bt,zt),zt=tt.sub(Ot,zt),zt=tt.mul(Pt,zt),Yt=tt.add(Yt,zt),Ot=tt.mul(Bt,Yt),It=tt.add(It,Ot),Ot=tt.mul(Ht,Yt),kt=tt.mul(Ft,kt),kt=tt.sub(kt,Ot),Ot=tt.mul(Ft,Bt),Rt=tt.mul(Ht,Rt),Rt=tt.add(Rt,Ot),new ht(kt,It,Rt)}subtract(yt){return this.add(yt.negate())}is0(){return this.equals(ht.ZERO)}wNAF(yt){return mt.wNAFCached(this,yt,ht.normalizeZ)}multiplyUnsafe(yt){aInRange("scalar",yt,_0n$3,et.n);const gt=ht.ZERO;if(yt===_0n$3)return gt;if(yt===_1n$5)return this;const{endo:xt}=et;if(!xt)return mt.unsafeLadder(this,yt);let{k1neg:vt,k1:bt,k2neg:Et,k2:wt}=xt.splitScalar(yt),kt=gt,It=gt,Rt=this;for(;bt>_0n$3||wt>_0n$3;)bt&_1n$5&&(kt=kt.add(Rt)),wt&_1n$5&&(It=It.add(Rt)),Rt=Rt.double(),bt>>=_1n$5,wt>>=_1n$5;return vt&&(kt=kt.negate()),Et&&(It=It.negate()),It=new ht(tt.mul(It.px,xt.beta),It.py,It.pz),kt.add(It)}multiply(yt){const{endo:gt,n:xt}=et;aInRange("scalar",yt,_1n$5,xt);let vt,bt;if(gt){const{k1neg:Et,k1:wt,k2neg:kt,k2:It}=gt.splitScalar(yt);let{p:Rt,f:Pt}=this.wNAF(wt),{p:jt,f:Ot}=this.wNAF(It);Rt=mt.constTimeNegate(Et,Rt),jt=mt.constTimeNegate(kt,jt),jt=new ht(tt.mul(jt.px,gt.beta),jt.py,jt.pz),vt=Rt.add(jt),bt=Pt.add(Ot)}else{const{p:Et,f:wt}=this.wNAF(yt);vt=Et,bt=wt}return ht.normalizeZ([vt,bt])[0]}multiplyAndAddUnsafe(yt,gt,xt){const vt=ht.BASE,bt=(wt,kt)=>kt===_0n$3||kt===_1n$5||!wt.equals(vt)?wt.multiplyUnsafe(kt):wt.multiply(kt),Et=bt(this,gt).add(bt(yt,xt));return Et.is0()?void 0:Et}toAffine(yt){return lt(this,yt)}isTorsionFree(){const{h:yt,isTorsionFree:gt}=et;if(yt===_1n$5)return!0;if(gt)return gt(ht,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:yt,clearCofactor:gt}=et;return yt===_1n$5?this:gt?gt(ht,this):this.multiplyUnsafe(et.h)}toRawBytes(yt=!0){return abool("isCompressed",yt),this.assertValidity(),rt(ht,this,yt)}toHex(yt=!0){return abool("isCompressed",yt),bytesToHex$2(this.toRawBytes(yt))}}ht.BASE=new ht(et.Gx,et.Gy,tt.ONE),ht.ZERO=new ht(tt.ZERO,tt.ONE,tt.ZERO);const pt=et.nBitLength,mt=wNAF(ht,et.endo?Math.ceil(pt/2):pt);return{CURVE:et,ProjectivePoint:ht,normPrivateKeyToScalar:at,weierstrassEquation:it,isWithinCurveOrder:st}}function validateOpts$2(o){const et=validateBasic(o);return validateObject(et,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...et})}function weierstrass$1(o){const et=validateOpts$2(o),{Fp:tt,n:nt}=et,rt=tt.BYTES+1,ot=2*tt.BYTES+1;function it(zt){return mod$1(zt,nt)}function st(zt){return invert$1(zt,nt)}const{ProjectivePoint:at,normPrivateKeyToScalar:ct,weierstrassEquation:lt,isWithinCurveOrder:dt}=weierstrassPoints({...et,toBytes(zt,Ft,Yt){const Ht=Ft.toAffine(),Ut=tt.toBytes(Ht.x),qt=concatBytes$1;return abool("isCompressed",Yt),Yt?qt(Uint8Array.from([Ft.hasEvenY()?2:3]),Ut):qt(Uint8Array.from([4]),Ut,tt.toBytes(Ht.y))},fromBytes(zt){const Ft=zt.length,Yt=zt[0],Ht=zt.subarray(1);if(Ft===rt&&(Yt===2||Yt===3)){const Ut=bytesToNumberBE(Ht);if(!inRange(Ut,_1n$5,tt.ORDER))throw new Error("Point is not on curve");const qt=lt(Ut);let Lt;try{Lt=tt.sqrt(qt)}catch(Nt){const Gt=Nt instanceof Error?": "+Nt.message:"";throw new Error("Point is not on curve"+Gt)}const Zt=(Lt&_1n$5)===_1n$5;return(Yt&1)===1!==Zt&&(Lt=tt.neg(Lt)),{x:Ut,y:Lt}}else if(Ft===ot&&Yt===4){const Ut=tt.fromBytes(Ht.subarray(0,tt.BYTES)),qt=tt.fromBytes(Ht.subarray(tt.BYTES,2*tt.BYTES));return{x:Ut,y:qt}}else throw new Error(`Point of length ${Ft} was invalid. Expected ${rt} compressed bytes or ${ot} uncompressed bytes`)}}),ht=zt=>bytesToHex$2(numberToBytesBE(zt,et.nByteLength));function pt(zt){const Ft=nt>>_1n$5;return zt>Ft}function mt(zt){return pt(zt)?it(-zt):zt}const ft=(zt,Ft,Yt)=>bytesToNumberBE(zt.slice(Ft,Yt));class yt{constructor(Ft,Yt,Ht){this.r=Ft,this.s=Yt,this.recovery=Ht,this.assertValidity()}static fromCompact(Ft){const Yt=et.nByteLength;return Ft=ensureBytes$1("compactSignature",Ft,Yt*2),new yt(ft(Ft,0,Yt),ft(Ft,Yt,2*Yt))}static fromDER(Ft){const{r:Yt,s:Ht}=DER.toSig(ensureBytes$1("DER",Ft));return new yt(Yt,Ht)}assertValidity(){aInRange("r",this.r,_1n$5,nt),aInRange("s",this.s,_1n$5,nt)}addRecoveryBit(Ft){return new yt(this.r,this.s,Ft)}recoverPublicKey(Ft){const{r:Yt,s:Ht,recovery:Ut}=this,qt=wt(ensureBytes$1("msgHash",Ft));if(Ut==null||![0,1,2,3].includes(Ut))throw new Error("recovery id invalid");const Lt=Ut===2||Ut===3?Yt+et.n:Yt;if(Lt>=tt.ORDER)throw new Error("recovery id 2 or 3 invalid");const Zt=Ut&1?"03":"02",Qt=at.fromHex(Zt+ht(Lt)),Nt=st(Lt),Gt=it(-qt*Nt),nn=it(Ht*Nt),Wt=at.BASE.multiplyAndAddUnsafe(Qt,Gt,nn);if(!Wt)throw new Error("point at infinify");return Wt.assertValidity(),Wt}hasHighS(){return pt(this.s)}normalizeS(){return this.hasHighS()?new yt(this.r,it(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$2(this.toDERHex())}toDERHex(){return DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$2(this.toCompactHex())}toCompactHex(){return ht(this.r)+ht(this.s)}}const gt={isValidPrivateKey(zt){try{return ct(zt),!0}catch{return!1}},normPrivateKeyToScalar:ct,randomPrivateKey:()=>{const zt=getMinHashLength(et.n);return mapHashToField(et.randomBytes(zt),et.n)},precompute(zt=8,Ft=at.BASE){return Ft._setWindowSize(zt),Ft.multiply(BigInt(3)),Ft}};function xt(zt,Ft=!0){return at.fromPrivateKey(zt).toRawBytes(Ft)}function vt(zt){const Ft=isBytes$2(zt),Yt=typeof zt=="string",Ht=(Ft||Yt)&&zt.length;return Ft?Ht===rt||Ht===ot:Yt?Ht===2*rt||Ht===2*ot:zt instanceof at}function bt(zt,Ft,Yt=!0){if(vt(zt))throw new Error("first arg must be private key");if(!vt(Ft))throw new Error("second arg must be public key");return at.fromHex(Ft).multiply(ct(zt)).toRawBytes(Yt)}const Et=et.bits2int||function(zt){const Ft=bytesToNumberBE(zt),Yt=zt.length*8-et.nBitLength;return Yt>0?Ft>>BigInt(Yt):Ft},wt=et.bits2int_modN||function(zt){return it(Et(zt))},kt=bitMask(et.nBitLength);function It(zt){return aInRange(`num < 2^${et.nBitLength}`,zt,_0n$3,kt),numberToBytesBE(zt,et.nByteLength)}function Rt(zt,Ft,Yt=Pt){if(["recovered","canonical"].some(Xt=>Xt in Yt))throw new Error("sign() legacy options not supported");const{hash:Ht,randomBytes:Ut}=et;let{lowS:qt,prehash:Lt,extraEntropy:Zt}=Yt;qt==null&&(qt=!0),zt=ensureBytes$1("msgHash",zt),validateSigVerOpts(Yt),Lt&&(zt=ensureBytes$1("prehashed msgHash",Ht(zt)));const Qt=wt(zt),Nt=ct(Ft),Gt=[It(Nt),It(Qt)];if(Zt!=null&&Zt!==!1){const Xt=Zt===!0?Ut(tt.BYTES):Zt;Gt.push(ensureBytes$1("extraEntropy",Xt))}const nn=concatBytes$1(...Gt),Wt=Qt;function hn(Xt){const Jt=Et(Xt);if(!dt(Jt))return;const tn=st(Jt),_t=at.BASE.multiply(Jt).toAffine(),Dt=it(_t.x);if(Dt===_0n$3)return;const Vt=it(tn*it(Wt+Dt*Nt));if(Vt===_0n$3)return;let en=(_t.x===Dt?0:2)|Number(_t.y&_1n$5),an=Vt;return qt&&pt(Vt)&&(an=mt(Vt),en^=1),new yt(Dt,an,en)}return{seed:nn,k2sig:hn}}const Pt={lowS:et.lowS,prehash:!1},jt={lowS:et.lowS,prehash:!1};function Ot(zt,Ft,Yt=Pt){const{seed:Ht,k2sig:Ut}=Rt(zt,Ft,Yt),qt=et;return createHmacDrbg(qt.hash.outputLen,qt.nByteLength,qt.hmac)(Ht,Ut)}at.BASE._setWindowSize(8);function Bt(zt,Ft,Yt,Ht=jt){var _t;const Ut=zt;if(Ft=ensureBytes$1("msgHash",Ft),Yt=ensureBytes$1("publicKey",Yt),"strict"in Ht)throw new Error("options.strict was renamed to lowS");validateSigVerOpts(Ht);const{lowS:qt,prehash:Lt}=Ht;let Zt,Qt;try{if(typeof Ut=="string"||isBytes$2(Ut))try{Zt=yt.fromDER(Ut)}catch(Dt){if(!(Dt instanceof DER.Err))throw Dt;Zt=yt.fromCompact(Ut)}else if(typeof Ut=="object"&&typeof Ut.r=="bigint"&&typeof Ut.s=="bigint"){const{r:Dt,s:Vt}=Ut;Zt=new yt(Dt,Vt)}else throw new Error("PARSE");Qt=at.fromHex(Yt)}catch(Dt){if(Dt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(qt&&Zt.hasHighS())return!1;Lt&&(Ft=et.hash(Ft));const{r:Nt,s:Gt}=Zt,nn=wt(Ft),Wt=st(Gt),hn=it(nn*Wt),Xt=it(Nt*Wt),Jt=(_t=at.BASE.multiplyAndAddUnsafe(Qt,hn,Xt))==null?void 0:_t.toAffine();return Jt?it(Jt.x)===Nt:!1}return{CURVE:et,getPublicKey:xt,getSharedSecret:bt,sign:Ot,verify:Bt,ProjectivePoint:at,Signature:yt,utils:gt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(o){return{hash:o,hmac:(et,...tt)=>hmac(o,et,concatBytes$2(...tt)),randomBytes:randomBytes$1}}function createCurve(o,et){const tt=nt=>weierstrass$1({...o,...getHash(nt)});return Object.freeze({...tt(et),create:tt})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$4=BigInt(1),_2n$3=BigInt(2),divNearest$1=(o,et)=>(o+et/_2n$3)/et;function sqrtMod$1(o){const et=secp256k1P,tt=BigInt(3),nt=BigInt(6),rt=BigInt(11),ot=BigInt(22),it=BigInt(23),st=BigInt(44),at=BigInt(88),ct=o*o*o%et,lt=ct*ct*o%et,dt=pow2$1(lt,tt,et)*lt%et,ht=pow2$1(dt,tt,et)*lt%et,pt=pow2$1(ht,_2n$3,et)*ct%et,mt=pow2$1(pt,rt,et)*pt%et,ft=pow2$1(mt,ot,et)*mt%et,yt=pow2$1(ft,st,et)*ft%et,gt=pow2$1(yt,at,et)*yt%et,xt=pow2$1(gt,st,et)*ft%et,vt=pow2$1(xt,tt,et)*lt%et,bt=pow2$1(vt,it,et)*mt%et,Et=pow2$1(bt,nt,et)*ct%et,wt=pow2$1(Et,_2n$3,et);if(!Fp$1.eql(Fp$1.sqr(wt),o))throw new Error("Cannot find square root");return wt}const Fp$1=Field$1(secp256k1P,void 0,void 0,{sqrt:sqrtMod$1}),secp256k1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:o=>{const et=secp256k1N,tt=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),nt=-_1n$4*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),rt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),ot=tt,it=BigInt("0x100000000000000000000000000000000"),st=divNearest$1(ot*o,et),at=divNearest$1(-nt*o,et);let ct=mod$1(o-st*tt-at*rt,et),lt=mod$1(-st*nt-at*ot,et);const dt=ct>it,ht=lt>it;if(dt&&(ct=et-ct),ht&&(lt=et-lt),ct>it||lt>it)throw new Error("splitScalar: Endomorphism failed, k="+o);return{k1neg:dt,k1:ct,k2neg:ht,k2:lt}}}},sha256$2);BigInt(0);secp256k1.ProjectivePoint;function getAction(o,et,tt){const nt=o[et.name];if(typeof nt=="function")return nt;const rt=o[tt];return typeof rt=="function"?rt:ot=>et(o,ot)}const version$6="2.14.4",getVersion$1=()=>`@wagmi/core@${version$6}`;var __classPrivateFieldGet$1=function(o,et,tt,nt){if(tt==="a"&&!nt)throw new TypeError("Private accessor was defined without a getter");if(typeof et=="function"?o!==et||!nt:!et.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return tt==="m"?nt:tt==="a"?nt.call(o):nt?nt.value:et.get(o)},_BaseError_instances,_BaseError_walk;let BaseError$1=class As extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return getVersion$1()}constructor(et,tt={}){var ot;super(),_BaseError_instances.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const nt=tt.cause instanceof As?tt.cause.details:(ot=tt.cause)!=null&&ot.message?tt.cause.message:tt.details,rt=tt.cause instanceof As&&tt.cause.docsPath||tt.docsPath;this.message=[et||"An error occurred.","",...tt.metaMessages?[...tt.metaMessages,""]:[],...rt?[`Docs: ${this.docsBaseUrl}${rt}.html${tt.docsSlug?`#${tt.docsSlug}`:""}`]:[],...nt?[`Details: ${nt}`]:[],`Version: ${this.version}`].join(` `),tt.cause&&(this.cause=tt.cause),this.details=nt,this.docsPath=rt,this.metaMessages=tt.metaMessages,this.shortMessage=et}walk(et){return __classPrivateFieldGet$1(this,_BaseError_instances,"m",_BaseError_walk).call(this,this,et)}};_BaseError_instances=new WeakSet,_BaseError_walk=function o(et,tt){return tt!=null&&tt(et)?et:et.cause?__classPrivateFieldGet$1(this,_BaseError_instances,"m",o).call(this,et.cause,tt):et};class ChainNotConfiguredError extends BaseError$1{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class ConnectorAlreadyConnectedError extends BaseError$1{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class ConnectorNotConnectedError extends BaseError$1{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class ConnectorAccountNotFoundError extends BaseError$1{constructor({address:et,connector:tt}){super(`Account "${et}" not found for connector "${tt.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class ConnectorChainMismatchError extends BaseError$1{constructor({connectionChainId:et,connectorChainId:tt}){super(`The current chain of the connector (id: ${tt}) does not match the connection's chain (id: ${et}).`,{metaMessages:[`Current Chain ID: ${tt}`,`Expected Chain ID: ${et}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class ConnectorUnavailableReconnectingError extends BaseError$1{constructor({connector:et}){super(`Connector "${et.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uuid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function connect$1(o,et){var nt;let tt;if(typeof et.connector=="function"?tt=o._internal.connectors.setup(et.connector):tt=et.connector,tt.uid===o.state.current)throw new ConnectorAlreadyConnectedError;try{o.setState(it=>({...it,status:"connecting"})),tt.emitter.emit("message",{type:"connecting"});const rt=await tt.connect({chainId:et.chainId}),ot=rt.accounts;return tt.emitter.off("connect",o._internal.events.connect),tt.emitter.on("change",o._internal.events.change),tt.emitter.on("disconnect",o._internal.events.disconnect),await((nt=o.storage)==null?void 0:nt.setItem("recentConnectorId",tt.id)),o.setState(it=>({...it,connections:new Map(it.connections).set(tt.uid,{accounts:ot,chainId:rt.chainId,connector:tt}),current:tt.uid,status:"connected"})),{accounts:ot,chainId:rt.chainId}}catch(rt){throw o.setState(ot=>({...ot,status:ot.current?"connected":"disconnected"})),rt}}const size$1=256;let index$3=size$1,buffer$1;function uid$1(o=11){if(!buffer$1||index$3+o>size$1*2){buffer$1="",index$3=0;for(let et=0;et{const xt=gt(yt);for(const bt in mt)delete xt[bt];const vt={...yt,...xt};return Object.assign(vt,{extend:ft(vt)})}}return Object.assign(mt,{extend:ft(mt)})}function createTransport({key:o,name:et,request:tt,retryCount:nt=3,retryDelay:rt=150,timeout:ot,type:it},st){const at=uid$1();return{config:{key:o,name:et,request:tt,retryCount:nt,retryDelay:rt,timeout:ot,type:it},request:buildRequest(tt,{retryCount:nt,retryDelay:rt,uid:at}),value:st}}function custom(o,et={}){const{key:tt="custom",name:nt="Custom Provider",retryDelay:rt}=et;return({retryCount:ot})=>createTransport({key:tt,name:nt,request:o.request.bind(o),retryCount:et.retryCount??ot,retryDelay:rt,type:"custom"})}class UrlRequiredError extends BaseError$3{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function http(o,et={}){const{batch:tt,fetchOptions:nt,key:rt="http",name:ot="HTTP JSON-RPC",onFetchRequest:it,onFetchResponse:st,retryDelay:at}=et;return({chain:ct,retryCount:lt,timeout:dt})=>{const{batchSize:ht=1e3,wait:pt=0}=typeof tt=="object"?tt:{},mt=et.retryCount??lt,ft=dt??et.timeout??1e4,yt=ct==null?void 0:ct.rpcUrls.default.http[0];if(!yt)throw new UrlRequiredError;const gt=getHttpRpcClient(yt,{fetchOptions:nt,onRequest:it,onResponse:st,timeout:ft});return createTransport({key:rt,name:ot,async request({method:xt,params:vt}){const bt={method:xt,params:vt},{schedule:Et}=createBatchScheduler({id:yt,wait:pt,shouldSplitBatch(Rt){return Rt.length>ht},fn:Rt=>gt.request({body:Rt}),sort:(Rt,Pt)=>Rt.id-Pt.id}),wt=async Rt=>tt?Et(Rt):[await gt.request({body:Rt})],[{error:kt,result:It}]=await wt(bt);if(kt)throw new RpcRequestError({body:bt,error:kt,url:yt});return It},retryCount:mt,retryDelay:at,timeout:ft,type:"http"},{fetchOptions:nt,url:yt})}}async function getConnectorClient(o,et={}){let tt;if(et.connector){const{connector:ct}=et;if(o.state.status==="reconnecting"&&!ct.getAccounts&&!ct.getChainId)throw new ConnectorUnavailableReconnectingError({connector:ct});const[lt,dt]=await Promise.all([ct.getAccounts(),ct.getChainId()]);tt={accounts:lt,chainId:dt,connector:ct}}else tt=o.state.connections.get(o.state.current);if(!tt)throw new ConnectorNotConnectedError;const nt=et.chainId??tt.chainId,rt=await tt.connector.getChainId();if(rt!==tt.chainId)throw new ConnectorChainMismatchError({connectionChainId:tt.chainId,connectorChainId:rt});const ot=tt.connector;if(ot.getClient)return ot.getClient({chainId:nt});const it=parseAccount(et.account??tt.accounts[0]);if(it.address=getAddress(it.address),et.account&&!tt.accounts.some(ct=>ct.toLowerCase()===it.address.toLowerCase()))throw new ConnectorAccountNotFoundError({address:it.address,connector:ot});const st=o.chains.find(ct=>ct.id===nt),at=await tt.connector.getProvider({chainId:nt});return createClient({account:it,chain:st,name:"Connector Client",transport:ct=>custom(at)({...ct,retryCount:0})})}async function disconnect(o,et={}){var rt,ot;let tt;if(et.connector)tt=et.connector;else{const{connections:it,current:st}=o.state,at=it.get(st);tt=at==null?void 0:at.connector}const nt=o.state.connections;tt&&(await tt.disconnect(),tt.emitter.off("change",o._internal.events.change),tt.emitter.off("disconnect",o._internal.events.disconnect),tt.emitter.on("connect",o._internal.events.connect),nt.delete(tt.uid)),o.setState(it=>{if(nt.size===0)return{...it,connections:new Map,current:null,status:"disconnected"};const st=nt.values().next().value;return{...it,connections:new Map(nt),current:st.connector.uid}});{const it=o.state.current;if(!it)return;const st=(rt=o.state.connections.get(it))==null?void 0:rt.connector;if(!st)return;await((ot=o.storage)==null?void 0:ot.setItem("recentConnectorId",st.id))}}function getUnit(o){return typeof o=="number"?o:o==="wei"?0:Math.abs(weiUnits[o])}function getAccount(o){const et=o.state.current,tt=o.state.connections.get(et),nt=tt==null?void 0:tt.accounts,rt=nt==null?void 0:nt[0],ot=o.chains.find(st=>st.id===(tt==null?void 0:tt.chainId)),it=o.state.status;switch(it){case"connected":return{address:rt,addresses:nt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:it};case"reconnecting":return{address:rt,addresses:nt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!!rt,isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:it};case"connecting":return{address:rt,addresses:nt,chain:ot,chainId:tt==null?void 0:tt.chainId,connector:tt==null?void 0:tt.connector,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:it};case"disconnected":return{address:void 0,addresses:void 0,chain:void 0,chainId:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:it}}}async function multicall(o,et){const{allowFailure:tt=!0,chainId:nt,contracts:rt,...ot}=et,it=o.getClient({chainId:nt});return getAction(it,multicall$1,"multicall")({allowFailure:tt,contracts:rt,...ot})}function readContract(o,et){const{chainId:tt,...nt}=et,rt=o.getClient({chainId:tt});return getAction(rt,readContract$1,"readContract")(nt)}async function readContracts(o,et){var st;const{allowFailure:tt=!0,blockNumber:nt,blockTag:rt,...ot}=et,it=et.contracts;try{const at={};for(const[ht,pt]of it.entries()){const mt=pt.chainId??o.state.chainId;at[mt]||(at[mt]=[]),(st=at[mt])==null||st.push({contract:pt,index:ht})}const ct=()=>Object.entries(at).map(([ht,pt])=>multicall(o,{...ot,allowFailure:tt,blockNumber:nt,blockTag:rt,chainId:Number.parseInt(ht),contracts:pt.map(({contract:mt})=>mt)})),lt=(await Promise.all(ct())).flat(),dt=Object.values(at).flatMap(ht=>ht.map(({index:pt})=>pt));return lt.reduce((ht,pt,mt)=>(ht&&(ht[dt[mt]]=pt),ht),[])}catch(at){if(at instanceof ContractFunctionExecutionError)throw at;const ct=()=>it.map(lt=>readContract(o,{...lt,blockNumber:nt,blockTag:rt}));return tt?(await Promise.allSettled(ct())).map(lt=>lt.status==="fulfilled"?{result:lt.value,status:"success"}:{error:lt.reason,result:void 0,status:"failure"}):await Promise.all(ct())}}async function getBalance(o,et){const{address:tt,blockNumber:nt,blockTag:rt,chainId:ot,token:it,unit:st="ether"}=et;if(it)try{return await getTokenBalance(o,{balanceAddress:tt,chainId:ot,symbolType:"string",tokenAddress:it})}catch(ht){if(ht.name==="ContractFunctionExecutionError"){const pt=await getTokenBalance(o,{balanceAddress:tt,chainId:ot,symbolType:"bytes32",tokenAddress:it}),mt=hexToString(trim$1(pt.symbol,{dir:"right"}));return{...pt,symbol:mt}}throw ht}const at=o.getClient({chainId:ot}),lt=await getAction(at,getBalance$1,"getBalance")(nt?{address:tt,blockNumber:nt}:{address:tt,blockTag:rt}),dt=o.chains.find(ht=>ht.id===ot)??at.chain;return{decimals:dt.nativeCurrency.decimals,formatted:formatUnits(lt,getUnit(st)),symbol:dt.nativeCurrency.symbol,value:lt}}async function getTokenBalance(o,et){const{balanceAddress:tt,chainId:nt,symbolType:rt,tokenAddress:ot,unit:it}=et,st={abi:[{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:rt}]}],address:ot},[at,ct,lt]=await readContracts(o,{allowFailure:!1,contracts:[{...st,functionName:"balanceOf",args:[tt],chainId:nt},{...st,functionName:"decimals",chainId:nt},{...st,functionName:"symbol",chainId:nt}]}),dt=formatUnits(at??"0",getUnit(it??ct));return{decimals:ct,formatted:dt,symbol:lt,value:at}}function getBlockNumber(o,et={}){const{chainId:tt,...nt}=et,rt=o.getClient({chainId:tt});return getAction(rt,getBlockNumber$1,"getBlockNumber")(nt)}function getChainId(o){return o.state.chainId}function deepEqual(o,et){if(o===et)return!0;if(o&&et&&typeof o=="object"&&typeof et=="object"){if(o.constructor!==et.constructor)return!1;let tt,nt;if(Array.isArray(o)&&Array.isArray(et)){if(tt=o.length,tt!==et.length)return!1;for(nt=tt;nt--!==0;)if(!deepEqual(o[nt],et[nt]))return!1;return!0}if(o.valueOf!==Object.prototype.valueOf)return o.valueOf()===et.valueOf();if(o.toString!==Object.prototype.toString)return o.toString()===et.toString();const rt=Object.keys(o);if(tt=rt.length,tt!==Object.keys(et).length)return!1;for(nt=tt;nt--!==0;)if(!Object.prototype.hasOwnProperty.call(et,rt[nt]))return!1;for(nt=tt;nt--!==0;){const ot=rt[nt];if(ot&&!deepEqual(o[ot],et[ot]))return!1}return!0}return o!==o&&et!==et}let previousChains=[];function getChains(o){const et=o.chains;return deepEqual(previousChains,et)?previousChains:(previousChains=et,et)}let previousConnections=[];function getConnections(o){const et=[...o.state.connections.values()];return o.state.status==="reconnecting"||deepEqual(previousConnections,et)?previousConnections:(previousConnections=et,et)}let previousConnectors=[];function getConnectors(o){const et=o.connectors;return deepEqual(previousConnectors,et)?previousConnectors:(previousConnectors=et,et)}function getEnsAddress(o,et){const{chainId:tt,...nt}=et,rt=o.getClient({chainId:tt});return getAction(rt,getEnsAddress$1,"getEnsAddress")(nt)}function getEnsAvatar(o,et){const{chainId:tt,...nt}=et,rt=o.getClient({chainId:tt});return getAction(rt,getEnsAvatar$1,"getEnsAvatar")(nt)}function getEnsName(o,et){const{chainId:tt,...nt}=et,rt=o.getClient({chainId:tt});return getAction(rt,getEnsName$1,"getEnsName")(nt)}let isReconnecting=!1;async function reconnect(o,et={}){var ct,lt;if(isReconnecting)return[];isReconnecting=!0,o.setState(dt=>({...dt,status:dt.current?"reconnecting":"connecting"}));const tt=[];if((ct=et.connectors)!=null&&ct.length)for(const dt of et.connectors){let ht;typeof dt=="function"?ht=o._internal.connectors.setup(dt):ht=dt,tt.push(ht)}else tt.push(...o.connectors);let nt;try{nt=await((lt=o.storage)==null?void 0:lt.getItem("recentConnectorId"))}catch{}const rt={};for(const[,dt]of o.state.connections)rt[dt.connector.id]=1;nt&&(rt[nt]=0);const ot=Object.keys(rt).length>0?[...tt].sort((dt,ht)=>(rt[dt.id]??10)-(rt[ht.id]??10)):tt;let it=!1;const st=[],at=[];for(const dt of ot){const ht=await dt.getProvider().catch(()=>{});if(!ht||at.some(ft=>ft===ht)||!await dt.isAuthorized())continue;const mt=await dt.connect({isReconnecting:!0}).catch(()=>null);mt&&(dt.emitter.off("connect",o._internal.events.connect),dt.emitter.on("change",o._internal.events.change),dt.emitter.on("disconnect",o._internal.events.disconnect),o.setState(ft=>{const yt=new Map(it?ft.connections:new Map).set(dt.uid,{accounts:mt.accounts,chainId:mt.chainId,connector:dt});return{...ft,current:it?ft.current:dt.uid,connections:yt}}),st.push({accounts:mt.accounts,chainId:mt.chainId,connector:dt}),at.push(ht),it=!0)}return(o.state.status==="reconnecting"||o.state.status==="connecting")&&(it?o.setState(dt=>({...dt,status:"connected"})):o.setState(dt=>({...dt,connections:new Map,current:null,status:"disconnected"}))),isReconnecting=!1,st}async function signMessage(o,et){const{account:tt,connector:nt,...rt}=et;let ot;return typeof tt=="object"&&tt.type==="local"?ot=o.getClient():ot=await getConnectorClient(o,{account:tt,connector:nt}),getAction(ot,signMessage$1,"signMessage")({...rt,...tt?{account:tt}:{}})}class ProviderNotFoundError extends BaseError$1{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}class SwitchChainNotSupportedError extends BaseError$1{constructor({connector:et}){super(`"${et.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function switchChain(o,et){var it;const{addEthereumChainParameter:tt,chainId:nt}=et,rt=o.state.connections.get(((it=et.connector)==null?void 0:it.uid)??o.state.current);if(rt){const st=rt.connector;if(!st.switchChain)throw new SwitchChainNotSupportedError({connector:st});return await st.switchChain({addEthereumChainParameter:tt,chainId:nt})}const ot=o.chains.find(st=>st.id===nt);if(!ot)throw new ChainNotConfiguredError;return o.setState(st=>({...st,chainId:nt})),ot}function watchAccount(o,et){const{onChange:tt}=et;return o.subscribe(()=>getAccount(o),tt,{equalityFn(nt,rt){const{connector:ot,...it}=nt,{connector:st,...at}=rt;return deepEqual(it,at)&&(ot==null?void 0:ot.id)===(st==null?void 0:st.id)&&(ot==null?void 0:ot.uid)===(st==null?void 0:st.uid)}})}function watchBlockNumber(o,et){const{syncConnectedChain:tt=o._internal.syncConnectedChain,...nt}=et;let rt;const ot=at=>{rt&&rt();const ct=o.getClient({chainId:at});return rt=getAction(ct,watchBlockNumber$1,"watchBlockNumber")(nt),rt},it=ot(et.chainId);let st;return tt&&!et.chainId&&(st=o.subscribe(({chainId:at})=>at,async at=>ot(at))),()=>{it==null||it(),st==null||st()}}function watchChainId(o,et){const{onChange:tt}=et;return o.subscribe(nt=>nt.chainId,tt)}function watchConnections(o,et){const{onChange:tt}=et;return o.subscribe(()=>getConnections(o),tt,{equalityFn:deepEqual})}function watchConnectors(o,et){const{onChange:tt}=et;return o._internal.connectors.subscribe((nt,rt)=>{tt(Object.values(nt),rt)})}function createConnector(o){return o}const supportsSimulationIdRegex=/(rabby|trustwallet)/;injected.type="injected";function injected(o={}){const{shimDisconnect:et=!0,unstable_shimAsyncInject:tt}=o;function nt(){const at=o.target;if(typeof at=="function"){const ct=at();if(ct)return ct}return typeof at=="object"?at:typeof at=="string"?{...targetMap[at]??{id:at,name:`${at[0].toUpperCase()}${at.slice(1)}`,provider:`is${at[0].toUpperCase()}${at.slice(1)}`}}:{id:"injected",name:"Injected",provider(ct){return ct==null?void 0:ct.ethereum}}}let rt,ot,it,st;return at=>({get icon(){return nt().icon},get id(){return nt().id},get name(){return nt().name},get supportsSimulation(){return supportsSimulationIdRegex.test(this.id.toLowerCase())},type:injected.type,async setup(){const ct=await this.getProvider();ct!=null&&ct.on&&o.target&&(it||(it=this.onConnect.bind(this),ct.on("connect",it)),rt||(rt=this.onAccountsChanged.bind(this),ct.on("accountsChanged",rt)))},async connect({chainId:ct,isReconnecting:lt}={}){var pt,mt,ft,yt,gt,xt;const dt=await this.getProvider();if(!dt)throw new ProviderNotFoundError;let ht=[];if(lt)ht=await this.getAccounts().catch(()=>[]);else if(et)try{ht=(yt=(ft=(mt=(pt=(await dt.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:pt.caveats)==null?void 0:mt[0])==null?void 0:ft.value)==null?void 0:yt.map(bt=>getAddress(bt)),ht.length>0&&(ht=await this.getAccounts())}catch(vt){const bt=vt;if(bt.code===UserRejectedRequestError.code)throw new UserRejectedRequestError(bt);if(bt.code===ResourceUnavailableRpcError.code)throw bt}try{!(ht!=null&&ht.length)&&!lt&&(ht=(await dt.request({method:"eth_requestAccounts"})).map(Et=>getAddress(Et))),it&&(dt.removeListener("connect",it),it=void 0),rt||(rt=this.onAccountsChanged.bind(this),dt.on("accountsChanged",rt)),ot||(ot=this.onChainChanged.bind(this),dt.on("chainChanged",ot)),st||(st=this.onDisconnect.bind(this),dt.on("disconnect",st));let vt=await this.getChainId();if(ct&&vt!==ct){const bt=await this.switchChain({chainId:ct}).catch(Et=>{if(Et.code===UserRejectedRequestError.code)throw Et;return{id:vt}});vt=(bt==null?void 0:bt.id)??vt}return et&&await((gt=at.storage)==null?void 0:gt.removeItem(`${this.id}.disconnected`)),o.target||await((xt=at.storage)==null?void 0:xt.setItem("injected.connected",!0)),{accounts:ht,chainId:vt}}catch(vt){const bt=vt;throw bt.code===UserRejectedRequestError.code?new UserRejectedRequestError(bt):bt.code===ResourceUnavailableRpcError.code?new ResourceUnavailableRpcError(bt):bt}},async disconnect(){var lt,dt;const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;ot&&(ct.removeListener("chainChanged",ot),ot=void 0),st&&(ct.removeListener("disconnect",st),st=void 0),it||(it=this.onConnect.bind(this),ct.on("connect",it));try{await withTimeout(()=>ct.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}et&&await((lt=at.storage)==null?void 0:lt.setItem(`${this.id}.disconnected`,!0)),o.target||await((dt=at.storage)==null?void 0:dt.removeItem("injected.connected"))},async getAccounts(){const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;return(await ct.request({method:"eth_accounts"})).map(dt=>getAddress(dt))},async getChainId(){const ct=await this.getProvider();if(!ct)throw new ProviderNotFoundError;const lt=await ct.request({method:"eth_chainId"});return Number(lt)},async getProvider(){if(typeof window>"u")return;let ct;const lt=nt();return typeof lt.provider=="function"?ct=lt.provider(window):typeof lt.provider=="string"?ct=findProvider(window,lt.provider):ct=lt.provider,ct&&!ct.removeListener&&("off"in ct&&typeof ct.off=="function"?ct.removeListener=ct.off:ct.removeListener=()=>{}),ct},async isAuthorized(){var ct,lt;try{if(et&&await((ct=at.storage)==null?void 0:ct.getItem(`${this.id}.disconnected`))||!o.target&&!await((lt=at.storage)==null?void 0:lt.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(tt!==void 0&&tt!==!1){const mt=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",mt),!!await this.getProvider()),ft=typeof tt=="number"?tt:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(gt=>window.addEventListener("ethereum#initialized",()=>gt(mt()),{once:!0}))]:[],new Promise(gt=>setTimeout(()=>gt(mt()),ft))]))return!0}throw new ProviderNotFoundError}return!!(await withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:ct,chainId:lt}){var mt,ft,yt,gt;const dt=await this.getProvider();if(!dt)throw new ProviderNotFoundError;const ht=at.chains.find(xt=>xt.id===lt);if(!ht)throw new SwitchChainError(new ChainNotConfiguredError);const pt=new Promise(xt=>{const vt=bt=>{"chainId"in bt&&bt.chainId===lt&&(at.emitter.off("change",vt),xt())};at.emitter.on("change",vt)});try{return await Promise.all([dt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(lt)}]}).then(async()=>{await this.getChainId()===lt&&at.emitter.emit("change",{chainId:lt})}),pt]),ht}catch(xt){const vt=xt;if(vt.code===4902||((ft=(mt=vt==null?void 0:vt.data)==null?void 0:mt.originalError)==null?void 0:ft.code)===4902)try{const{default:bt,...Et}=ht.blockExplorers??{};let wt;ct!=null&&ct.blockExplorerUrls?wt=ct.blockExplorerUrls:bt&&(wt=[bt.url,...Object.values(Et).map(Rt=>Rt.url)]);let kt;(yt=ct==null?void 0:ct.rpcUrls)!=null&&yt.length?kt=ct.rpcUrls:kt=[((gt=ht.rpcUrls.default)==null?void 0:gt.http[0])??""];const It={blockExplorerUrls:wt,chainId:numberToHex(lt),chainName:(ct==null?void 0:ct.chainName)??ht.name,iconUrls:ct==null?void 0:ct.iconUrls,nativeCurrency:(ct==null?void 0:ct.nativeCurrency)??ht.nativeCurrency,rpcUrls:kt};return await Promise.all([dt.request({method:"wallet_addEthereumChain",params:[It]}).then(async()=>{if(await this.getChainId()===lt)at.emitter.emit("change",{chainId:lt});else throw new UserRejectedRequestError(new Error("User rejected switch after adding network."))}),pt]),ht}catch(bt){throw new UserRejectedRequestError(bt)}throw vt.code===UserRejectedRequestError.code?new UserRejectedRequestError(vt):new SwitchChainError(vt)}},async onAccountsChanged(ct){var lt;if(ct.length===0)this.onDisconnect();else if(at.emitter.listenerCount("connect")){const dt=(await this.getChainId()).toString();this.onConnect({chainId:dt}),et&&await((lt=at.storage)==null?void 0:lt.removeItem(`${this.id}.disconnected`))}else at.emitter.emit("change",{accounts:ct.map(dt=>getAddress(dt))})},onChainChanged(ct){const lt=Number(ct);at.emitter.emit("change",{chainId:lt})},async onConnect(ct){const lt=await this.getAccounts();if(lt.length===0)return;const dt=Number(ct.chainId);at.emitter.emit("connect",{accounts:lt,chainId:dt});const ht=await this.getProvider();ht&&(it&&(ht.removeListener("connect",it),it=void 0),rt||(rt=this.onAccountsChanged.bind(this),ht.on("accountsChanged",rt)),ot||(ot=this.onChainChanged.bind(this),ht.on("chainChanged",ot)),st||(st=this.onDisconnect.bind(this),ht.on("disconnect",st)))},async onDisconnect(ct){const lt=await this.getProvider();ct&&ct.code===1013&<&&(await this.getAccounts()).length||(at.emitter.emit("disconnect"),lt&&(ot&&(lt.removeListener("chainChanged",ot),ot=void 0),st&&(lt.removeListener("disconnect",st),st=void 0),it||(it=this.onConnect.bind(this),lt.on("connect",it))))}})}const targetMap={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(o){return o!=null&&o.coinbaseWalletExtension?o.coinbaseWalletExtension:findProvider(o,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(o){return findProvider(o,et=>{if(!et.isMetaMask||et.isBraveWallet&&!et._events&&!et._state)return!1;const tt=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const nt of tt)if(et[nt])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(o){var et,tt;return(et=o==null?void 0:o.phantom)!=null&&et.ethereum?(tt=o.phantom)==null?void 0:tt.ethereum:findProvider(o,"isPhantom")}}};function findProvider(o,et){function tt(rt){return typeof et=="function"?et(rt):typeof et=="string"?rt[et]:!0}const nt=o.ethereum;if(nt!=null&&nt.providers)return nt.providers.find(rt=>tt(rt));if(nt&&tt(nt))return nt}function requestProviders(o){if(typeof window>"u")return;const et=tt=>o(tt.detail);return window.addEventListener("eip6963:announceProvider",et),window.dispatchEvent(new CustomEvent("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",et)}function createStore$1(){const o=new Set;let et=[];const tt=()=>requestProviders(rt=>{et.some(({info:ot})=>ot.uuid===rt.info.uuid)||(et=[...et,rt],o.forEach(ot=>ot(et,{added:[rt]})))});let nt=tt();return{_listeners(){return o},clear(){o.forEach(rt=>rt([],{removed:[...et]})),et=[]},destroy(){this.clear(),o.clear(),nt==null||nt()},findProvider({rdns:rt}){return et.find(ot=>ot.info.rdns===rt)},getProviders(){return et},reset(){this.clear(),nt==null||nt(),nt=tt()},subscribe(rt,{emitImmediately:ot}={}){return o.add(rt),ot&&rt(et,{added:et}),()=>o.delete(rt)}}}const subscribeWithSelectorImpl=o=>(et,tt,nt)=>{const rt=nt.subscribe;return nt.subscribe=(it,st,at)=>{let ct=it;if(st){const lt=(at==null?void 0:at.equalityFn)||Object.is;let dt=it(nt.getState());ct=ht=>{const pt=it(ht);if(!lt(dt,pt)){const mt=dt;st(dt=pt,mt)}},at!=null&&at.fireImmediately&&st(dt,dt)}return rt(ct)},o(et,tt,nt)},subscribeWithSelector=subscribeWithSelectorImpl;function createJSONStorage(o,et){let tt;try{tt=o()}catch{return}return{getItem:rt=>{var ot;const it=at=>at===null?null:JSON.parse(at,void 0),st=(ot=tt.getItem(rt))!=null?ot:null;return st instanceof Promise?st.then(it):it(st)},setItem:(rt,ot)=>tt.setItem(rt,JSON.stringify(ot,void 0)),removeItem:rt=>tt.removeItem(rt)}}const toThenable=o=>et=>{try{const tt=o(et);return tt instanceof Promise?tt:{then(nt){return toThenable(nt)(tt)},catch(nt){return this}}}catch(tt){return{then(nt){return this},catch(nt){return toThenable(nt)(tt)}}}},persistImpl=(o,et)=>(tt,nt,rt)=>{let ot={storage:createJSONStorage(()=>localStorage),partialize:ft=>ft,version:0,merge:(ft,yt)=>({...yt,...ft}),...et},it=!1;const st=new Set,at=new Set;let ct=ot.storage;if(!ct)return o((...ft)=>{console.warn(`[zustand persist middleware] Unable to update item '${ot.name}', the given storage is currently unavailable.`),tt(...ft)},nt,rt);const lt=()=>{const ft=ot.partialize({...nt()});return ct.setItem(ot.name,{state:ft,version:ot.version})},dt=rt.setState;rt.setState=(ft,yt)=>{dt(ft,yt),lt()};const ht=o((...ft)=>{tt(...ft),lt()},nt,rt);rt.getInitialState=()=>ht;let pt;const mt=()=>{var ft,yt;if(!ct)return;it=!1,st.forEach(xt=>{var vt;return xt((vt=nt())!=null?vt:ht)});const gt=((yt=ot.onRehydrateStorage)==null?void 0:yt.call(ot,(ft=nt())!=null?ft:ht))||void 0;return toThenable(ct.getItem.bind(ct))(ot.name).then(xt=>{if(xt)if(typeof xt.version=="number"&&xt.version!==ot.version){if(ot.migrate)return[!0,ot.migrate(xt.state,xt.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,xt.state];return[!1,void 0]}).then(xt=>{var vt;const[bt,Et]=xt;if(pt=ot.merge(Et,(vt=nt())!=null?vt:ht),tt(pt,!0),bt)return lt()}).then(()=>{gt==null||gt(pt,void 0),pt=nt(),it=!0,at.forEach(xt=>xt(pt))}).catch(xt=>{gt==null||gt(void 0,xt)})};return rt.persist={setOptions:ft=>{ot={...ot,...ft},ft.storage&&(ct=ft.storage)},clearStorage:()=>{ct==null||ct.removeItem(ot.name)},getOptions:()=>ot,rehydrate:()=>mt(),hasHydrated:()=>it,onHydrate:ft=>(st.add(ft),()=>{st.delete(ft)}),onFinishHydration:ft=>(at.add(ft),()=>{at.delete(ft)})},ot.skipHydration||mt(),pt||ht},persist=persistImpl,createStoreImpl=o=>{let et;const tt=new Set,nt=(ct,lt)=>{const dt=typeof ct=="function"?ct(et):ct;if(!Object.is(dt,et)){const ht=et;et=lt??(typeof dt!="object"||dt===null)?dt:Object.assign({},et,dt),tt.forEach(pt=>pt(et,ht))}},rt=()=>et,st={setState:nt,getState:rt,getInitialState:()=>at,subscribe:ct=>(tt.add(ct),()=>tt.delete(ct))},at=et=o(nt,rt,st);return st},createStore=o=>o?createStoreImpl(o):createStoreImpl;var eventemitter3={exports:{}};(function(o){var et=Object.prototype.hasOwnProperty,tt="~";function nt(){}Object.create&&(nt.prototype=Object.create(null),new nt().__proto__||(tt=!1));function rt(at,ct,lt){this.fn=at,this.context=ct,this.once=lt||!1}function ot(at,ct,lt,dt,ht){if(typeof lt!="function")throw new TypeError("The listener must be a function");var pt=new rt(lt,dt||at,ht),mt=tt?tt+ct:ct;return at._events[mt]?at._events[mt].fn?at._events[mt]=[at._events[mt],pt]:at._events[mt].push(pt):(at._events[mt]=pt,at._eventsCount++),at}function it(at,ct){--at._eventsCount===0?at._events=new nt:delete at._events[ct]}function st(){this._events=new nt,this._eventsCount=0}st.prototype.eventNames=function(){var ct=[],lt,dt;if(this._eventsCount===0)return ct;for(dt in lt=this._events)et.call(lt,dt)&&ct.push(tt?dt.slice(1):dt);return Object.getOwnPropertySymbols?ct.concat(Object.getOwnPropertySymbols(lt)):ct},st.prototype.listeners=function(ct){var lt=tt?tt+ct:ct,dt=this._events[lt];if(!dt)return[];if(dt.fn)return[dt.fn];for(var ht=0,pt=dt.length,mt=new Array(pt);ht{let rt=nt;return(rt==null?void 0:rt.__type)==="bigint"&&(rt=BigInt(rt.value)),(rt==null?void 0:rt.__type)==="Map"&&(rt=new Map(rt.value)),(et==null?void 0:et(tt,rt))??rt})}function getReferenceKey(o,et){return o.slice(0,et).join(".")||"."}function getCutoff(o,et){const{length:tt}=o;for(let nt=0;nt{let it=ot;return typeof it=="bigint"&&(it={__type:"bigint",value:ot.toString()}),it instanceof Map&&(it={__type:"Map",value:Array.from(ot.entries())}),(et==null?void 0:et(rt,it))??it},nt),tt??void 0)}function createStorage(o){const{deserialize:et=deserialize$1,key:tt="wagmi",serialize:nt=serialize$1,storage:rt=noopStorage}=o;function ot(it){return it instanceof Promise?it.then(st=>st).catch(()=>null):it}return{...rt,key:tt,async getItem(it,st){const at=rt.getItem(`${tt}.${it}`),ct=await ot(at);return ct?et(ct)??null:st??null},async setItem(it,st){const at=`${tt}.${it}`;st===null?await ot(rt.removeItem(at)):await ot(rt.setItem(at,nt(st)))},async removeItem(it){await ot(rt.removeItem(`${tt}.${it}`))}}}const noopStorage={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},size=256;let index$2=size,buffer;function uid(o=11){if(!buffer||index$2+o>size*2){buffer="",index$2=0;for(let et=0;etot.chains),at=createStore(()=>{const Et=[],wt=new Set;for(const kt of ot.connectors??[]){const It=ct(kt);Et.push(It),!rt&&It.rdns&&wt.add(It.rdns)}if(!rt&&it){const kt=it.getProviders();for(const It of kt)wt.has(It.info.rdns)||Et.push(ct(lt(It)))}return Et});function ct(Et){var It;const wt=createEmitter(uid()),kt={...Et({emitter:wt,chains:st.getState(),storage:tt,transports:ot.transports}),emitter:wt,uid:wt.uid};return wt.on("connect",vt),(It=kt.setup)==null||It.call(kt),kt}function lt(Et){const{info:wt}=Et,kt=Et.provider;return injected({target:{...wt,id:wt.rdns,provider:kt}})}const dt=new Map;function ht(Et={}){const wt=Et.chainId??yt.getState().chainId,kt=st.getState().find(Rt=>Rt.id===wt);if(Et.chainId&&!kt)throw new ChainNotConfiguredError;{const Rt=dt.get(yt.getState().chainId);if(Rt&&!kt)return Rt;if(!kt)throw new ChainNotConfiguredError}{const Rt=dt.get(wt);if(Rt)return Rt}let It;if(ot.client)It=ot.client({chain:kt});else{const Rt=kt.id,Pt=st.getState().map(Bt=>Bt.id),jt={},Ot=Object.entries(ot);for(const[Bt,zt]of Ot)if(!(Bt==="chains"||Bt==="client"||Bt==="connectors"||Bt==="transports"))if(typeof zt=="object")if(Rt in zt)jt[Bt]=zt[Rt];else{if(Pt.some(Yt=>Yt in zt))continue;jt[Bt]=zt}else jt[Bt]=zt;It=createClient({...jt,chain:kt,batch:jt.batch??{multicall:!0},transport:Bt=>ot.transports[Rt]({...Bt,connectors:at})})}return dt.set(wt,It),It}function pt(){return{chainId:st.getState()[0].id,connections:new Map,current:null,status:"disconnected"}}let mt;const ft="0.0.0-canary-";version$6.startsWith(ft)?mt=Number.parseInt(version$6.replace(ft,"")):mt=Number.parseInt(version$6.split(".")[0]??"0");const yt=createStore(subscribeWithSelector(tt?persist(pt,{migrate(Et,wt){if(wt===mt)return Et;const kt=pt(),It=gt(Et,kt.chainId);return{...kt,chainId:It}},name:"store",partialize(Et){return{connections:{__type:"Map",value:Array.from(Et.connections.entries()).map(([wt,kt])=>{const{id:It,name:Rt,type:Pt,uid:jt}=kt.connector;return[wt,{...kt,connector:{id:It,name:Rt,type:Pt,uid:jt}}]})},chainId:Et.chainId,current:Et.current}},merge(Et,wt){typeof Et=="object"&&Et&&"status"in Et&&delete Et.status;const kt=gt(Et,wt.chainId);return{...wt,...Et,chainId:kt}},skipHydration:rt,storage:tt,version:mt}):pt));yt.setState(pt());function gt(Et,wt){return Et&&typeof Et=="object"&&"chainId"in Et&&typeof Et.chainId=="number"&&st.getState().some(kt=>kt.id===Et.chainId)?Et.chainId:wt}nt&&yt.subscribe(({connections:Et,current:wt})=>{var kt;return wt?(kt=Et.get(wt))==null?void 0:kt.chainId:void 0},Et=>{if(st.getState().some(kt=>kt.id===Et))return yt.setState(kt=>({...kt,chainId:Et??kt.chainId}))}),it==null||it.subscribe(Et=>{const wt=new Set,kt=new Set;for(const Rt of at.getState())wt.add(Rt.id),Rt.rdns&&kt.add(Rt.rdns);const It=[];for(const Rt of Et){if(kt.has(Rt.info.rdns))continue;const Pt=ct(lt(Rt));wt.has(Pt.id)||It.push(Pt)}tt&&!yt.persist.hasHydrated()||at.setState(Rt=>[...Rt,...It],!0)});function xt(Et){yt.setState(wt=>{const kt=wt.connections.get(Et.uid);return kt?{...wt,connections:new Map(wt.connections).set(Et.uid,{accounts:Et.accounts??kt.accounts,chainId:Et.chainId??kt.chainId,connector:kt.connector})}:wt})}function vt(Et){yt.getState().status==="connecting"||yt.getState().status==="reconnecting"||yt.setState(wt=>{const kt=at.getState().find(It=>It.uid===Et.uid);return kt?(kt.emitter.listenerCount("connect")&&kt.emitter.off("connect",xt),kt.emitter.listenerCount("change")||kt.emitter.on("change",xt),kt.emitter.listenerCount("disconnect")||kt.emitter.on("disconnect",bt),{...wt,connections:new Map(wt.connections).set(Et.uid,{accounts:Et.accounts,chainId:Et.chainId,connector:kt}),current:Et.uid,status:"connected"}):wt})}function bt(Et){yt.setState(wt=>{const kt=wt.connections.get(Et.uid);if(kt){const Rt=kt.connector;Rt.emitter.listenerCount("change")&&kt.connector.emitter.off("change",xt),Rt.emitter.listenerCount("disconnect")&&kt.connector.emitter.off("disconnect",bt),Rt.emitter.listenerCount("connect")||kt.connector.emitter.on("connect",vt)}if(wt.connections.delete(Et.uid),wt.connections.size===0)return{...wt,connections:new Map,current:null,status:"disconnected"};const It=wt.connections.values().next().value;return{...wt,connections:new Map(wt.connections),current:It.connector.uid}})}return{get chains(){return st.getState()},get connectors(){return at.getState()},storage:tt,getClient:ht,get state(){return yt.getState()},setState(Et){let wt;typeof Et=="function"?wt=Et(yt.getState()):wt=Et;const kt=pt();typeof wt!="object"&&(wt=kt),Object.keys(kt).some(Rt=>!(Rt in wt))&&(wt=kt),yt.setState(wt,!0)},subscribe(Et,wt,kt){return yt.subscribe(Et,wt,kt?{...kt,fireImmediately:kt.emitImmediately}:void 0)},_internal:{mipd:it,store:yt,ssr:!!rt,syncConnectedChain:nt,transports:ot.transports,chains:{setState(Et){const wt=typeof Et=="function"?Et(st.getState()):Et;if(wt.length!==0)return st.setState(wt,!0)},subscribe(Et){return st.subscribe(Et)}},connectors:{providerDetailToConnector:lt,setup:ct,setState(Et){return at.setState(typeof Et=="function"?Et(at.getState()):Et,!0)},subscribe(Et){return at.subscribe(Et)}},events:{change:xt,connect:vt,disconnect:bt}}}}function hydrate(o,et){const{initialState:tt,reconnectOnMount:nt}=et;return tt&&!o._internal.store.persist.hasHydrated()&&o.setState({...tt,chainId:o.chains.some(rt=>rt.id===tt.chainId)?tt.chainId:o.chains[0].id,connections:nt?tt.connections:new Map,status:nt?"reconnecting":"disconnected"}),{async onMount(){o._internal.ssr&&(await o._internal.store.persist.rehydrate(),o._internal.mipd&&o._internal.connectors.setState(rt=>{var at;const ot=new Set;for(const ct of rt??[])ct.rdns&&ot.add(ct.rdns);const it=[],st=((at=o._internal.mipd)==null?void 0:at.getProviders())??[];for(const ct of st){if(ot.has(ct.info.rdns))continue;const lt=o._internal.connectors.providerDetailToConnector(ct),dt=o._internal.connectors.setup(lt);it.push(dt)}return[...rt,...it]})),nt?reconnect(o):o.storage&&o.setState(rt=>({...rt,connections:new Map}))}}}function extractRpcUrls(o){var ot,it,st;const{chain:et}=o,tt=et.rpcUrls.default.http[0];if(!o.transports)return[tt];const nt=(it=(ot=o.transports)==null?void 0:ot[et.id])==null?void 0:it.call(ot,{chain:et});return(((st=nt==null?void 0:nt.value)==null?void 0:st.transports)||[nt]).map(({value:at})=>(at==null?void 0:at.url)||tt)}function Hydrate(o){const{children:et,config:tt,initialState:nt,reconnectOnMount:rt=!0}=o,{onMount:ot}=hydrate(tt,{initialState:nt,reconnectOnMount:rt});tt._internal.ssr||ot();const it=reactExports.useRef(!0);return reactExports.useEffect(()=>{if(it.current&&tt._internal.ssr)return ot(),()=>{it.current=!1}},[]),et}const WagmiContext=reactExports.createContext(void 0);function WagmiProvider(o){const{children:et,config:tt}=o,nt={value:tt};return reactExports.createElement(Hydrate,o,reactExports.createElement(WagmiContext.Provider,nt,et))}const version$5="2.12.29",getVersion=()=>`wagmi@${version$5}`;class BaseError extends BaseError$1{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiError"})}get docsBaseUrl(){return"https://wagmi.sh/react"}get version(){return getVersion()}}class WagmiProviderNotFoundError extends BaseError{constructor(){super("`useConfig` must be used within `WagmiProvider`.",{docsPath:"/api/WagmiProvider"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiProviderNotFoundError"})}}function useConfig(o={}){const et=o.config??reactExports.useContext(WagmiContext);if(!et)throw new WagmiProviderNotFoundError;return et}function watchChains(o,et){const{onChange:tt}=et;return o._internal.chains.subscribe((nt,rt)=>{tt(nt,rt)})}var withSelector={exports:{}},withSelector_production_min={},shim={exports:{}},useSyncExternalStoreShim_production_min={};/** * @license React * use-sync-external-store-shim.production.min.js @@ -92,7 +92,7 @@ ${prettyStateOverride(pt)}`),super(et.shortMessage,{cause:et,docsPath:nt,metaMes * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var h$3=reactExports,n$2=shimExports;function p$2(o,et){return o===et&&(o!==0||1/o===1/et)||o!==o&&et!==et}var q$3=typeof Object.is=="function"?Object.is:p$2,r$3=n$2.useSyncExternalStore,t$2=h$3.useRef,u$1=h$3.useEffect,v$3=h$3.useMemo,w$3=h$3.useDebugValue;withSelector_production_min.useSyncExternalStoreWithSelector=function(o,et,tt,nt,rt){var ot=t$2(null);if(ot.current===null){var it={hasValue:!1,value:null};ot.current=it}else it=ot.current;ot=v$3(function(){function at(pt){if(!ct){if(ct=!0,lt=pt,pt=nt(pt),rt!==void 0&&it.hasValue){var mt=it.value;if(rt(mt,pt))return dt=mt}return dt=pt}if(mt=dt,q$3(lt,pt))return mt;var ft=nt(pt);return rt!==void 0&&rt(mt,ft)?mt:(lt=pt,dt=ft)}var ct=!1,lt,dt,ht=tt===void 0?null:tt;return[function(){return at(et())},ht===null?void 0:function(){return at(ht())}]},[et,tt,nt,rt]);var st=r$3(o,ot[0],ot[1]);return u$1(function(){it.hasValue=!0,it.value=st},[st]),w$3(st),st};withSelector.exports=withSelector_production_min;var withSelectorExports=withSelector.exports;const isPlainObject$4=o=>typeof o=="object"&&!Array.isArray(o);function useSyncExternalStoreWithTracked(o,et,tt=et,nt=deepEqual){const rt=reactExports.useRef([]),ot=withSelectorExports.useSyncExternalStoreWithSelector(o,et,tt,it=>it,(it,st)=>{if(isPlainObject$4(it)&&isPlainObject$4(st)&&rt.current.length){for(const at of rt.current)if(!nt(it[at],st[at]))return!1;return!0}return nt(it,st)});return reactExports.useMemo(()=>{if(isPlainObject$4(ot)){const it={...ot};let st={};for(const[at,ct]of Object.entries(it))st={...st,[at]:{configurable:!1,enumerable:!0,get:()=>(rt.current.includes(at)||rt.current.push(at),ct)}};return Object.defineProperties(it,st),it}return ot},[ot])}function useAccount(o={}){const et=useConfig(o);return useSyncExternalStoreWithTracked(tt=>watchAccount(et,{onChange:tt}),()=>getAccount(et))}function useAccountEffect(o={}){const{onConnect:et,onDisconnect:tt}=o,nt=useConfig(o);reactExports.useEffect(()=>watchAccount(nt,{onChange(rt,ot){if((ot.status==="reconnecting"||ot.status==="connecting"&&ot.address===void 0)&&rt.status==="connected"){const{address:it,addresses:st,chain:at,chainId:ct,connector:lt}=rt,dt=ot.status==="reconnecting"||ot.status===void 0;et==null||et({address:it,addresses:st,chain:at,chainId:ct,connector:lt,isReconnected:dt})}else ot.status==="connected"&&rt.status==="disconnected"&&(tt==null||tt())}}),[nt,et,tt])}var Subscribable=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(o){return this.listeners.add(o),this.onSubscribe(),()=>{this.listeners.delete(o),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},isServer=typeof window>"u"||"Deno"in globalThis;function noop$4(){}function functionalUpdate(o,et){return typeof o=="function"?o(et):o}function isValidTimeout(o){return typeof o=="number"&&o>=0&&o!==1/0}function timeUntilStale(o,et){return Math.max(o+(et||0)-Date.now(),0)}function resolveStaleTime(o,et){return typeof o=="function"?o(et):o}function resolveEnabled(o,et){return typeof o=="function"?o(et):o}function matchQuery(o,et){const{type:tt="all",exact:nt,fetchStatus:rt,predicate:ot,queryKey:it,stale:st}=o;if(it){if(nt){if(et.queryHash!==hashQueryKeyByOptions(it,et.options))return!1}else if(!partialMatchKey(et.queryKey,it))return!1}if(tt!=="all"){const at=et.isActive();if(tt==="active"&&!at||tt==="inactive"&&at)return!1}return!(typeof st=="boolean"&&et.isStale()!==st||rt&&rt!==et.state.fetchStatus||ot&&!ot(et))}function matchMutation(o,et){const{exact:tt,status:nt,predicate:rt,mutationKey:ot}=o;if(ot){if(!et.options.mutationKey)return!1;if(tt){if(hashKey(et.options.mutationKey)!==hashKey(ot))return!1}else if(!partialMatchKey(et.options.mutationKey,ot))return!1}return!(nt&&et.state.status!==nt||rt&&!rt(et))}function hashQueryKeyByOptions(o,et){return((et==null?void 0:et.queryKeyHashFn)||hashKey)(o)}function hashKey(o){return JSON.stringify(o,(et,tt)=>isPlainObject$3(tt)?Object.keys(tt).sort().reduce((nt,rt)=>(nt[rt]=tt[rt],nt),{}):tt)}function partialMatchKey(o,et){return o===et?!0:typeof o!=typeof et?!1:o&&et&&typeof o=="object"&&typeof et=="object"?!Object.keys(et).some(tt=>!partialMatchKey(o[tt],et[tt])):!1}function replaceEqualDeep(o,et){if(o===et)return o;const tt=isPlainArray(o)&&isPlainArray(et);if(tt||isPlainObject$3(o)&&isPlainObject$3(et)){const nt=tt?o:Object.keys(o),rt=nt.length,ot=tt?et:Object.keys(et),it=ot.length,st=tt?[]:{};let at=0;for(let ct=0;ct{setTimeout(et,o)})}function replaceData(o,et,tt){return typeof tt.structuralSharing=="function"?tt.structuralSharing(o,et):tt.structuralSharing!==!1?replaceEqualDeep(o,et):et}function addToEnd(o,et,tt=0){const nt=[...o,et];return tt&&nt.length>tt?nt.slice(1):nt}function addToStart(o,et,tt=0){const nt=[et,...o];return tt&&nt.length>tt?nt.slice(0,-1):nt}var skipToken=Symbol();function ensureQueryFn(o,et){return!o.queryFn&&(et!=null&&et.initialPromise)?()=>et.initialPromise:!o.queryFn||o.queryFn===skipToken?()=>Promise.reject(new Error(`Missing queryFn: '${o.queryHash}'`)):o.queryFn}var Sr,lr,$r,Ds,FocusManager=(Ds=class extends Subscribable{constructor(){super();fn(this,Sr);fn(this,lr);fn(this,$r);un(this,$r,et=>{if(!isServer&&window.addEventListener){const tt=()=>et();return window.addEventListener("visibilitychange",tt,!1),()=>{window.removeEventListener("visibilitychange",tt)}}})}onSubscribe(){Mt(this,lr)||this.setEventListener(Mt(this,$r))}onUnsubscribe(){var et;this.hasListeners()||((et=Mt(this,lr))==null||et.call(this),un(this,lr,void 0))}setEventListener(et){var tt;un(this,$r,et),(tt=Mt(this,lr))==null||tt.call(this),un(this,lr,et(nt=>{typeof nt=="boolean"?this.setFocused(nt):this.onFocus()}))}setFocused(et){Mt(this,Sr)!==et&&(un(this,Sr,et),this.onFocus())}onFocus(){const et=this.isFocused();this.listeners.forEach(tt=>{tt(et)})}isFocused(){var et;return typeof Mt(this,Sr)=="boolean"?Mt(this,Sr):((et=globalThis.document)==null?void 0:et.visibilityState)!=="hidden"}},Sr=new WeakMap,lr=new WeakMap,$r=new WeakMap,Ds),focusManager=new FocusManager,Or,ur,Mr,Fs,OnlineManager=(Fs=class extends Subscribable{constructor(){super();fn(this,Or,!0);fn(this,ur);fn(this,Mr);un(this,Mr,et=>{if(!isServer&&window.addEventListener){const tt=()=>et(!0),nt=()=>et(!1);return window.addEventListener("online",tt,!1),window.addEventListener("offline",nt,!1),()=>{window.removeEventListener("online",tt),window.removeEventListener("offline",nt)}}})}onSubscribe(){Mt(this,ur)||this.setEventListener(Mt(this,Mr))}onUnsubscribe(){var et;this.hasListeners()||((et=Mt(this,ur))==null||et.call(this),un(this,ur,void 0))}setEventListener(et){var tt;un(this,Mr,et),(tt=Mt(this,ur))==null||tt.call(this),un(this,ur,et(this.setOnline.bind(this)))}setOnline(et){Mt(this,Or)!==et&&(un(this,Or,et),this.listeners.forEach(nt=>{nt(et)}))}isOnline(){return Mt(this,Or)}},Or=new WeakMap,ur=new WeakMap,Mr=new WeakMap,Fs),onlineManager=new OnlineManager;function pendingThenable(){let o,et;const tt=new Promise((rt,ot)=>{o=rt,et=ot});tt.status="pending",tt.catch(()=>{});function nt(rt){Object.assign(tt,rt),delete tt.resolve,delete tt.reject}return tt.resolve=rt=>{nt({status:"fulfilled",value:rt}),o(rt)},tt.reject=rt=>{nt({status:"rejected",reason:rt}),et(rt)},tt}function defaultRetryDelay(o){return Math.min(1e3*2**o,3e4)}function canFetch(o){return(o??"online")==="online"?onlineManager.isOnline():!0}var CancelledError=class extends Error{constructor(o){super("CancelledError"),this.revert=o==null?void 0:o.revert,this.silent=o==null?void 0:o.silent}};function isCancelledError(o){return o instanceof CancelledError}function createRetryer(o){let et=!1,tt=0,nt=!1,rt;const ot=pendingThenable(),it=ft=>{var yt;nt||(ht(new CancelledError(ft)),(yt=o.abort)==null||yt.call(o))},st=()=>{et=!0},at=()=>{et=!1},ct=()=>focusManager.isFocused()&&(o.networkMode==="always"||onlineManager.isOnline())&&o.canRun(),lt=()=>canFetch(o.networkMode)&&o.canRun(),dt=ft=>{var yt;nt||(nt=!0,(yt=o.onSuccess)==null||yt.call(o,ft),rt==null||rt(),ot.resolve(ft))},ht=ft=>{var yt;nt||(nt=!0,(yt=o.onError)==null||yt.call(o,ft),rt==null||rt(),ot.reject(ft))},pt=()=>new Promise(ft=>{var yt;rt=gt=>{(nt||ct())&&ft(gt)},(yt=o.onPause)==null||yt.call(o)}).then(()=>{var ft;rt=void 0,nt||(ft=o.onContinue)==null||ft.call(o)}),mt=()=>{if(nt)return;let ft;const yt=tt===0?o.initialPromise:void 0;try{ft=yt??o.fn()}catch(gt){ft=Promise.reject(gt)}Promise.resolve(ft).then(dt).catch(gt=>{var wt;if(nt)return;const xt=o.retry??(isServer?0:3),vt=o.retryDelay??defaultRetryDelay,bt=typeof vt=="function"?vt(tt,gt):vt,Et=xt===!0||typeof xt=="number"&&ttct()?void 0:pt()).then(()=>{et?ht(gt):mt()})})};return{promise:ot,cancel:it,continue:()=>(rt==null||rt(),ot),cancelRetry:st,continueRetry:at,canStart:lt,start:()=>(lt()?mt():pt().then(mt),ot)}}function createNotifyManager(){let o=[],et=0,tt=st=>{st()},nt=st=>{st()},rt=st=>setTimeout(st,0);const ot=st=>{et?o.push(st):rt(()=>{tt(st)})},it=()=>{const st=o;o=[],st.length&&rt(()=>{nt(()=>{st.forEach(at=>{tt(at)})})})};return{batch:st=>{let at;et++;try{at=st()}finally{et--,et||it()}return at},batchCalls:st=>(...at)=>{ot(()=>{st(...at)})},schedule:ot,setNotifyFunction:st=>{tt=st},setBatchNotifyFunction:st=>{nt=st},setScheduler:st=>{rt=st}}}var notifyManager=createNotifyManager(),kr,Us,Removable=(Us=class{constructor(){fn(this,kr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),isValidTimeout(this.gcTime)&&un(this,kr,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(o){this.gcTime=Math.max(this.gcTime||0,o??(isServer?1/0:5*60*1e3))}clearGcTimeout(){Mt(this,kr)&&(clearTimeout(Mt(this,kr)),un(this,kr,void 0))}},kr=new WeakMap,Us),Br,Dr,Un,jn,no,Ar,Hn,tr,zs,Query=(zs=class extends Removable{constructor(et){super();fn(this,Hn);fn(this,Br);fn(this,Dr);fn(this,Un);fn(this,jn);fn(this,no);fn(this,Ar);un(this,Ar,!1),un(this,no,et.defaultOptions),this.setOptions(et.options),this.observers=[],un(this,Un,et.cache),this.queryKey=et.queryKey,this.queryHash=et.queryHash,un(this,Br,getDefaultState$1(this.options)),this.state=et.state??Mt(this,Br),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var et;return(et=Mt(this,jn))==null?void 0:et.promise}setOptions(et){this.options={...Mt(this,no),...et},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&Mt(this,Un).remove(this)}setData(et,tt){const nt=replaceData(this.state.data,et,this.options);return gn(this,Hn,tr).call(this,{data:nt,type:"success",dataUpdatedAt:tt==null?void 0:tt.updatedAt,manual:tt==null?void 0:tt.manual}),nt}setState(et,tt){gn(this,Hn,tr).call(this,{type:"setState",state:et,setStateOptions:tt})}cancel(et){var nt,rt;const tt=(nt=Mt(this,jn))==null?void 0:nt.promise;return(rt=Mt(this,jn))==null||rt.cancel(et),tt?tt.then(noop$4).catch(noop$4):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Mt(this,Br))}isActive(){return this.observers.some(et=>resolveEnabled(et.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(et=>et.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(et=0){return this.state.isInvalidated||this.state.data===void 0||!timeUntilStale(this.state.dataUpdatedAt,et)}onFocus(){var tt;const et=this.observers.find(nt=>nt.shouldFetchOnWindowFocus());et==null||et.refetch({cancelRefetch:!1}),(tt=Mt(this,jn))==null||tt.continue()}onOnline(){var tt;const et=this.observers.find(nt=>nt.shouldFetchOnReconnect());et==null||et.refetch({cancelRefetch:!1}),(tt=Mt(this,jn))==null||tt.continue()}addObserver(et){this.observers.includes(et)||(this.observers.push(et),this.clearGcTimeout(),Mt(this,Un).notify({type:"observerAdded",query:this,observer:et}))}removeObserver(et){this.observers.includes(et)&&(this.observers=this.observers.filter(tt=>tt!==et),this.observers.length||(Mt(this,jn)&&(Mt(this,Ar)?Mt(this,jn).cancel({revert:!0}):Mt(this,jn).cancelRetry()),this.scheduleGc()),Mt(this,Un).notify({type:"observerRemoved",query:this,observer:et}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||gn(this,Hn,tr).call(this,{type:"invalidate"})}fetch(et,tt){var at,ct,lt;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(tt!=null&&tt.cancelRefetch))this.cancel({silent:!0});else if(Mt(this,jn))return Mt(this,jn).continueRetry(),Mt(this,jn).promise}if(et&&this.setOptions(et),!this.options.queryFn){const dt=this.observers.find(ht=>ht.options.queryFn);dt&&this.setOptions(dt.options)}const nt=new AbortController,rt=dt=>{Object.defineProperty(dt,"signal",{enumerable:!0,get:()=>(un(this,Ar,!0),nt.signal)})},ot=()=>{const dt=ensureQueryFn(this.options,tt),ht={queryKey:this.queryKey,meta:this.meta};return rt(ht),un(this,Ar,!1),this.options.persister?this.options.persister(dt,ht,this):dt(ht)},it={fetchOptions:tt,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:ot};rt(it),(at=this.options.behavior)==null||at.onFetch(it,this),un(this,Dr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((ct=it.fetchOptions)==null?void 0:ct.meta))&&gn(this,Hn,tr).call(this,{type:"fetch",meta:(lt=it.fetchOptions)==null?void 0:lt.meta});const st=dt=>{var ht,pt,mt,ft;isCancelledError(dt)&&dt.silent||gn(this,Hn,tr).call(this,{type:"error",error:dt}),isCancelledError(dt)||((pt=(ht=Mt(this,Un).config).onError)==null||pt.call(ht,dt,this),(ft=(mt=Mt(this,Un).config).onSettled)==null||ft.call(mt,this.state.data,dt,this)),this.scheduleGc()};return un(this,jn,createRetryer({initialPromise:tt==null?void 0:tt.initialPromise,fn:it.fetchFn,abort:nt.abort.bind(nt),onSuccess:dt=>{var ht,pt,mt,ft;if(dt===void 0){st(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(dt)}catch(yt){st(yt);return}(pt=(ht=Mt(this,Un).config).onSuccess)==null||pt.call(ht,dt,this),(ft=(mt=Mt(this,Un).config).onSettled)==null||ft.call(mt,dt,this.state.error,this),this.scheduleGc()},onError:st,onFail:(dt,ht)=>{gn(this,Hn,tr).call(this,{type:"failed",failureCount:dt,error:ht})},onPause:()=>{gn(this,Hn,tr).call(this,{type:"pause"})},onContinue:()=>{gn(this,Hn,tr).call(this,{type:"continue"})},retry:it.options.retry,retryDelay:it.options.retryDelay,networkMode:it.options.networkMode,canRun:()=>!0})),Mt(this,jn).start()}},Br=new WeakMap,Dr=new WeakMap,Un=new WeakMap,jn=new WeakMap,no=new WeakMap,Ar=new WeakMap,Hn=new WeakSet,tr=function(et){const tt=nt=>{switch(et.type){case"failed":return{...nt,fetchFailureCount:et.failureCount,fetchFailureReason:et.error};case"pause":return{...nt,fetchStatus:"paused"};case"continue":return{...nt,fetchStatus:"fetching"};case"fetch":return{...nt,...fetchState(nt.data,this.options),fetchMeta:et.meta??null};case"success":return{...nt,data:et.data,dataUpdateCount:nt.dataUpdateCount+1,dataUpdatedAt:et.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!et.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const rt=et.error;return isCancelledError(rt)&&rt.revert&&Mt(this,Dr)?{...Mt(this,Dr),fetchStatus:"idle"}:{...nt,error:rt,errorUpdateCount:nt.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:nt.fetchFailureCount+1,fetchFailureReason:rt,fetchStatus:"idle",status:"error"};case"invalidate":return{...nt,isInvalidated:!0};case"setState":return{...nt,...et.state}}};this.state=tt(this.state),notifyManager.batch(()=>{this.observers.forEach(nt=>{nt.onQueryUpdate()}),Mt(this,Un).notify({query:this,type:"updated",action:et})})},zs);function fetchState(o,et){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:canFetch(et.networkMode)?"fetching":"paused",...o===void 0&&{error:null,status:"pending"}}}function getDefaultState$1(o){const et=typeof o.initialData=="function"?o.initialData():o.initialData,tt=et!==void 0,nt=tt?typeof o.initialDataUpdatedAt=="function"?o.initialDataUpdatedAt():o.initialDataUpdatedAt:0;return{data:et,dataUpdateCount:0,dataUpdatedAt:tt?nt??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:tt?"success":"pending",fetchStatus:"idle"}}var Wn,Vs,QueryCache=(Vs=class extends Subscribable{constructor(et={}){super();fn(this,Wn);this.config=et,un(this,Wn,new Map)}build(et,tt,nt){const rt=tt.queryKey,ot=tt.queryHash??hashQueryKeyByOptions(rt,tt);let it=this.get(ot);return it||(it=new Query({cache:this,queryKey:rt,queryHash:ot,options:et.defaultQueryOptions(tt),state:nt,defaultOptions:et.getQueryDefaults(rt)}),this.add(it)),it}add(et){Mt(this,Wn).has(et.queryHash)||(Mt(this,Wn).set(et.queryHash,et),this.notify({type:"added",query:et}))}remove(et){const tt=Mt(this,Wn).get(et.queryHash);tt&&(et.destroy(),tt===et&&Mt(this,Wn).delete(et.queryHash),this.notify({type:"removed",query:et}))}clear(){notifyManager.batch(()=>{this.getAll().forEach(et=>{this.remove(et)})})}get(et){return Mt(this,Wn).get(et)}getAll(){return[...Mt(this,Wn).values()]}find(et){const tt={exact:!0,...et};return this.getAll().find(nt=>matchQuery(tt,nt))}findAll(et={}){const tt=this.getAll();return Object.keys(et).length>0?tt.filter(nt=>matchQuery(et,nt)):tt}notify(et){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(et)})})}onFocus(){notifyManager.batch(()=>{this.getAll().forEach(et=>{et.onFocus()})})}onOnline(){notifyManager.batch(()=>{this.getAll().forEach(et=>{et.onOnline()})})}},Wn=new WeakMap,Vs),Gn,$n,Rr,qn,ar,Hs,Mutation=(Hs=class extends Removable{constructor(et){super();fn(this,qn);fn(this,Gn);fn(this,$n);fn(this,Rr);this.mutationId=et.mutationId,un(this,$n,et.mutationCache),un(this,Gn,[]),this.state=et.state||getDefaultState(),this.setOptions(et.options),this.scheduleGc()}setOptions(et){this.options=et,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(et){Mt(this,Gn).includes(et)||(Mt(this,Gn).push(et),this.clearGcTimeout(),Mt(this,$n).notify({type:"observerAdded",mutation:this,observer:et}))}removeObserver(et){un(this,Gn,Mt(this,Gn).filter(tt=>tt!==et)),this.scheduleGc(),Mt(this,$n).notify({type:"observerRemoved",mutation:this,observer:et})}optionalRemove(){Mt(this,Gn).length||(this.state.status==="pending"?this.scheduleGc():Mt(this,$n).remove(this))}continue(){var et;return((et=Mt(this,Rr))==null?void 0:et.continue())??this.execute(this.state.variables)}async execute(et){var rt,ot,it,st,at,ct,lt,dt,ht,pt,mt,ft,yt,gt,xt,vt,bt,Et,wt,kt;un(this,Rr,createRetryer({fn:()=>this.options.mutationFn?this.options.mutationFn(et):Promise.reject(new Error("No mutationFn found")),onFail:(It,Rt)=>{gn(this,qn,ar).call(this,{type:"failed",failureCount:It,error:Rt})},onPause:()=>{gn(this,qn,ar).call(this,{type:"pause"})},onContinue:()=>{gn(this,qn,ar).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Mt(this,$n).canRun(this)}));const tt=this.state.status==="pending",nt=!Mt(this,Rr).canStart();try{if(!tt){gn(this,qn,ar).call(this,{type:"pending",variables:et,isPaused:nt}),await((ot=(rt=Mt(this,$n).config).onMutate)==null?void 0:ot.call(rt,et,this));const Rt=await((st=(it=this.options).onMutate)==null?void 0:st.call(it,et));Rt!==this.state.context&&gn(this,qn,ar).call(this,{type:"pending",context:Rt,variables:et,isPaused:nt})}const It=await Mt(this,Rr).start();return await((ct=(at=Mt(this,$n).config).onSuccess)==null?void 0:ct.call(at,It,et,this.state.context,this)),await((dt=(lt=this.options).onSuccess)==null?void 0:dt.call(lt,It,et,this.state.context)),await((pt=(ht=Mt(this,$n).config).onSettled)==null?void 0:pt.call(ht,It,null,this.state.variables,this.state.context,this)),await((ft=(mt=this.options).onSettled)==null?void 0:ft.call(mt,It,null,et,this.state.context)),gn(this,qn,ar).call(this,{type:"success",data:It}),It}catch(It){try{throw await((gt=(yt=Mt(this,$n).config).onError)==null?void 0:gt.call(yt,It,et,this.state.context,this)),await((vt=(xt=this.options).onError)==null?void 0:vt.call(xt,It,et,this.state.context)),await((Et=(bt=Mt(this,$n).config).onSettled)==null?void 0:Et.call(bt,void 0,It,this.state.variables,this.state.context,this)),await((kt=(wt=this.options).onSettled)==null?void 0:kt.call(wt,void 0,It,et,this.state.context)),It}finally{gn(this,qn,ar).call(this,{type:"error",error:It})}}finally{Mt(this,$n).runNext(this)}}},Gn=new WeakMap,$n=new WeakMap,Rr=new WeakMap,qn=new WeakSet,ar=function(et){const tt=nt=>{switch(et.type){case"failed":return{...nt,failureCount:et.failureCount,failureReason:et.error};case"pause":return{...nt,isPaused:!0};case"continue":return{...nt,isPaused:!1};case"pending":return{...nt,context:et.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:et.isPaused,status:"pending",variables:et.variables,submittedAt:Date.now()};case"success":return{...nt,data:et.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...nt,data:void 0,error:et.error,failureCount:nt.failureCount+1,failureReason:et.error,isPaused:!1,status:"error"}}};this.state=tt(this.state),notifyManager.batch(()=>{Mt(this,Gn).forEach(nt=>{nt.onMutationUpdate(et)}),Mt(this,$n).notify({mutation:this,type:"updated",action:et})})},Hs);function getDefaultState(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Fn,ro,Ws,MutationCache=(Ws=class extends Subscribable{constructor(et={}){super();fn(this,Fn);fn(this,ro);this.config=et,un(this,Fn,new Map),un(this,ro,Date.now())}build(et,tt,nt){const rt=new Mutation({mutationCache:this,mutationId:++br(this,ro)._,options:et.defaultMutationOptions(tt),state:nt});return this.add(rt),rt}add(et){const tt=scopeFor(et),nt=Mt(this,Fn).get(tt)??[];nt.push(et),Mt(this,Fn).set(tt,nt),this.notify({type:"added",mutation:et})}remove(et){var nt;const tt=scopeFor(et);if(Mt(this,Fn).has(tt)){const rt=(nt=Mt(this,Fn).get(tt))==null?void 0:nt.filter(ot=>ot!==et);rt&&(rt.length===0?Mt(this,Fn).delete(tt):Mt(this,Fn).set(tt,rt))}this.notify({type:"removed",mutation:et})}canRun(et){var nt;const tt=(nt=Mt(this,Fn).get(scopeFor(et)))==null?void 0:nt.find(rt=>rt.state.status==="pending");return!tt||tt===et}runNext(et){var nt;const tt=(nt=Mt(this,Fn).get(scopeFor(et)))==null?void 0:nt.find(rt=>rt!==et&&rt.state.isPaused);return(tt==null?void 0:tt.continue())??Promise.resolve()}clear(){notifyManager.batch(()=>{this.getAll().forEach(et=>{this.remove(et)})})}getAll(){return[...Mt(this,Fn).values()].flat()}find(et){const tt={exact:!0,...et};return this.getAll().find(nt=>matchMutation(tt,nt))}findAll(et={}){return this.getAll().filter(tt=>matchMutation(et,tt))}notify(et){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(et)})})}resumePausedMutations(){const et=this.getAll().filter(tt=>tt.state.isPaused);return notifyManager.batch(()=>Promise.all(et.map(tt=>tt.continue().catch(noop$4))))}},Fn=new WeakMap,ro=new WeakMap,Ws);function scopeFor(o){var et;return((et=o.options.scope)==null?void 0:et.id)??String(o.mutationId)}function infiniteQueryBehavior(o){return{onFetch:(et,tt)=>{var lt,dt,ht,pt,mt;const nt=et.options,rt=(ht=(dt=(lt=et.fetchOptions)==null?void 0:lt.meta)==null?void 0:dt.fetchMore)==null?void 0:ht.direction,ot=((pt=et.state.data)==null?void 0:pt.pages)||[],it=((mt=et.state.data)==null?void 0:mt.pageParams)||[];let st={pages:[],pageParams:[]},at=0;const ct=async()=>{let ft=!1;const yt=vt=>{Object.defineProperty(vt,"signal",{enumerable:!0,get:()=>(et.signal.aborted?ft=!0:et.signal.addEventListener("abort",()=>{ft=!0}),et.signal)})},gt=ensureQueryFn(et.options,et.fetchOptions),xt=async(vt,bt,Et)=>{if(ft)return Promise.reject();if(bt==null&&vt.pages.length)return Promise.resolve(vt);const wt={queryKey:et.queryKey,pageParam:bt,direction:Et?"backward":"forward",meta:et.options.meta};yt(wt);const kt=await gt(wt),{maxPages:It}=et.options,Rt=Et?addToStart:addToEnd;return{pages:Rt(vt.pages,kt,It),pageParams:Rt(vt.pageParams,bt,It)}};if(rt&&ot.length){const vt=rt==="backward",bt=vt?getPreviousPageParam:getNextPageParam,Et={pages:ot,pageParams:it},wt=bt(nt,Et);st=await xt(Et,wt,vt)}else{const vt=o??ot.length;do{const bt=at===0?it[0]??nt.initialPageParam:getNextPageParam(nt,st);if(at>0&&bt==null)break;st=await xt(st,bt),at++}while(at{var ft,yt;return(yt=(ft=et.options).persister)==null?void 0:yt.call(ft,ct,{queryKey:et.queryKey,meta:et.options.meta,signal:et.signal},tt)}:et.fetchFn=ct}}}function getNextPageParam(o,{pages:et,pageParams:tt}){const nt=et.length-1;return et.length>0?o.getNextPageParam(et[nt],et,tt[nt],tt):void 0}function getPreviousPageParam(o,{pages:et,pageParams:tt}){var nt;return et.length>0?(nt=o.getPreviousPageParam)==null?void 0:nt.call(o,et[0],et,tt[0],tt):void 0}var Nn,dr,hr,Fr,Ur,pr,zr,Vr,Gs,QueryClient=(Gs=class{constructor(o={}){fn(this,Nn);fn(this,dr);fn(this,hr);fn(this,Fr);fn(this,Ur);fn(this,pr);fn(this,zr);fn(this,Vr);un(this,Nn,o.queryCache||new QueryCache),un(this,dr,o.mutationCache||new MutationCache),un(this,hr,o.defaultOptions||{}),un(this,Fr,new Map),un(this,Ur,new Map),un(this,pr,0)}mount(){br(this,pr)._++,Mt(this,pr)===1&&(un(this,zr,focusManager.subscribe(async o=>{o&&(await this.resumePausedMutations(),Mt(this,Nn).onFocus())})),un(this,Vr,onlineManager.subscribe(async o=>{o&&(await this.resumePausedMutations(),Mt(this,Nn).onOnline())})))}unmount(){var o,et;br(this,pr)._--,Mt(this,pr)===0&&((o=Mt(this,zr))==null||o.call(this),un(this,zr,void 0),(et=Mt(this,Vr))==null||et.call(this),un(this,Vr,void 0))}isFetching(o){return Mt(this,Nn).findAll({...o,fetchStatus:"fetching"}).length}isMutating(o){return Mt(this,dr).findAll({...o,status:"pending"}).length}getQueryData(o){var tt;const et=this.defaultQueryOptions({queryKey:o});return(tt=Mt(this,Nn).get(et.queryHash))==null?void 0:tt.state.data}ensureQueryData(o){const et=this.getQueryData(o.queryKey);if(et===void 0)return this.fetchQuery(o);{const tt=this.defaultQueryOptions(o),nt=Mt(this,Nn).build(this,tt);return o.revalidateIfStale&&nt.isStaleByTime(resolveStaleTime(tt.staleTime,nt))&&this.prefetchQuery(tt),Promise.resolve(et)}}getQueriesData(o){return Mt(this,Nn).findAll(o).map(({queryKey:et,state:tt})=>{const nt=tt.data;return[et,nt]})}setQueryData(o,et,tt){const nt=this.defaultQueryOptions({queryKey:o}),rt=Mt(this,Nn).get(nt.queryHash),ot=rt==null?void 0:rt.state.data,it=functionalUpdate(et,ot);if(it!==void 0)return Mt(this,Nn).build(this,nt).setData(it,{...tt,manual:!0})}setQueriesData(o,et,tt){return notifyManager.batch(()=>Mt(this,Nn).findAll(o).map(({queryKey:nt})=>[nt,this.setQueryData(nt,et,tt)]))}getQueryState(o){var tt;const et=this.defaultQueryOptions({queryKey:o});return(tt=Mt(this,Nn).get(et.queryHash))==null?void 0:tt.state}removeQueries(o){const et=Mt(this,Nn);notifyManager.batch(()=>{et.findAll(o).forEach(tt=>{et.remove(tt)})})}resetQueries(o,et){const tt=Mt(this,Nn),nt={type:"active",...o};return notifyManager.batch(()=>(tt.findAll(o).forEach(rt=>{rt.reset()}),this.refetchQueries(nt,et)))}cancelQueries(o={},et={}){const tt={revert:!0,...et},nt=notifyManager.batch(()=>Mt(this,Nn).findAll(o).map(rt=>rt.cancel(tt)));return Promise.all(nt).then(noop$4).catch(noop$4)}invalidateQueries(o={},et={}){return notifyManager.batch(()=>{if(Mt(this,Nn).findAll(o).forEach(nt=>{nt.invalidate()}),o.refetchType==="none")return Promise.resolve();const tt={...o,type:o.refetchType??o.type??"active"};return this.refetchQueries(tt,et)})}refetchQueries(o={},et){const tt={...et,cancelRefetch:(et==null?void 0:et.cancelRefetch)??!0},nt=notifyManager.batch(()=>Mt(this,Nn).findAll(o).filter(rt=>!rt.isDisabled()).map(rt=>{let ot=rt.fetch(void 0,tt);return tt.throwOnError||(ot=ot.catch(noop$4)),rt.state.fetchStatus==="paused"?Promise.resolve():ot}));return Promise.all(nt).then(noop$4)}fetchQuery(o){const et=this.defaultQueryOptions(o);et.retry===void 0&&(et.retry=!1);const tt=Mt(this,Nn).build(this,et);return tt.isStaleByTime(resolveStaleTime(et.staleTime,tt))?tt.fetch(et):Promise.resolve(tt.state.data)}prefetchQuery(o){return this.fetchQuery(o).then(noop$4).catch(noop$4)}fetchInfiniteQuery(o){return o.behavior=infiniteQueryBehavior(o.pages),this.fetchQuery(o)}prefetchInfiniteQuery(o){return this.fetchInfiniteQuery(o).then(noop$4).catch(noop$4)}ensureInfiniteQueryData(o){return o.behavior=infiniteQueryBehavior(o.pages),this.ensureQueryData(o)}resumePausedMutations(){return onlineManager.isOnline()?Mt(this,dr).resumePausedMutations():Promise.resolve()}getQueryCache(){return Mt(this,Nn)}getMutationCache(){return Mt(this,dr)}getDefaultOptions(){return Mt(this,hr)}setDefaultOptions(o){un(this,hr,o)}setQueryDefaults(o,et){Mt(this,Fr).set(hashKey(o),{queryKey:o,defaultOptions:et})}getQueryDefaults(o){const et=[...Mt(this,Fr).values()];let tt={};return et.forEach(nt=>{partialMatchKey(o,nt.queryKey)&&(tt={...tt,...nt.defaultOptions})}),tt}setMutationDefaults(o,et){Mt(this,Ur).set(hashKey(o),{mutationKey:o,defaultOptions:et})}getMutationDefaults(o){const et=[...Mt(this,Ur).values()];let tt={};return et.forEach(nt=>{partialMatchKey(o,nt.mutationKey)&&(tt={...tt,...nt.defaultOptions})}),tt}defaultQueryOptions(o){if(o._defaulted)return o;const et={...Mt(this,hr).queries,...this.getQueryDefaults(o.queryKey),...o,_defaulted:!0};return et.queryHash||(et.queryHash=hashQueryKeyByOptions(et.queryKey,et)),et.refetchOnReconnect===void 0&&(et.refetchOnReconnect=et.networkMode!=="always"),et.throwOnError===void 0&&(et.throwOnError=!!et.suspense),!et.networkMode&&et.persister&&(et.networkMode="offlineFirst"),et.enabled!==!0&&et.queryFn===skipToken&&(et.enabled=!1),et}defaultMutationOptions(o){return o!=null&&o._defaulted?o:{...Mt(this,hr).mutations,...(o==null?void 0:o.mutationKey)&&this.getMutationDefaults(o.mutationKey),...o,_defaulted:!0}}clear(){Mt(this,Nn).clear(),Mt(this,dr).clear()}},Nn=new WeakMap,dr=new WeakMap,hr=new WeakMap,Fr=new WeakMap,Ur=new WeakMap,pr=new WeakMap,zr=new WeakMap,Vr=new WeakMap,Gs),Mn,Sn,oo,On,_r,Hr,fr,Kn,io,Wr,Gr,Ir,Tr,mr,qr,In,to,Rs,_s,Is,Ts,Ps,Ls,Ns,Ql,qs,QueryObserver=(qs=class extends Subscribable{constructor(et,tt){super();fn(this,In);fn(this,Mn);fn(this,Sn);fn(this,oo);fn(this,On);fn(this,_r);fn(this,Hr);fn(this,fr);fn(this,Kn);fn(this,io);fn(this,Wr);fn(this,Gr);fn(this,Ir);fn(this,Tr);fn(this,mr);fn(this,qr,new Set);this.options=tt,un(this,Mn,et),un(this,Kn,null),un(this,fr,pendingThenable()),this.options.experimental_prefetchInRender||Mt(this,fr).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(tt)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Mt(this,Sn).addObserver(this),shouldFetchOnMount(Mt(this,Sn),this.options)?gn(this,In,to).call(this):this.updateResult(),gn(this,In,Ts).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return shouldFetchOn(Mt(this,Sn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return shouldFetchOn(Mt(this,Sn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,gn(this,In,Ps).call(this),gn(this,In,Ls).call(this),Mt(this,Sn).removeObserver(this)}setOptions(et,tt){const nt=this.options,rt=Mt(this,Sn);if(this.options=Mt(this,Mn).defaultQueryOptions(et),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof resolveEnabled(this.options.enabled,Mt(this,Sn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");gn(this,In,Ns).call(this),Mt(this,Sn).setOptions(this.options),nt._defaulted&&!shallowEqualObjects(this.options,nt)&&Mt(this,Mn).getQueryCache().notify({type:"observerOptionsUpdated",query:Mt(this,Sn),observer:this});const ot=this.hasListeners();ot&&shouldFetchOptionally(Mt(this,Sn),rt,this.options,nt)&&gn(this,In,to).call(this),this.updateResult(tt),ot&&(Mt(this,Sn)!==rt||resolveEnabled(this.options.enabled,Mt(this,Sn))!==resolveEnabled(nt.enabled,Mt(this,Sn))||resolveStaleTime(this.options.staleTime,Mt(this,Sn))!==resolveStaleTime(nt.staleTime,Mt(this,Sn)))&&gn(this,In,Rs).call(this);const it=gn(this,In,_s).call(this);ot&&(Mt(this,Sn)!==rt||resolveEnabled(this.options.enabled,Mt(this,Sn))!==resolveEnabled(nt.enabled,Mt(this,Sn))||it!==Mt(this,mr))&&gn(this,In,Is).call(this,it)}getOptimisticResult(et){const tt=Mt(this,Mn).getQueryCache().build(Mt(this,Mn),et),nt=this.createResult(tt,et);return shouldAssignObserverCurrentProperties(this,nt)&&(un(this,On,nt),un(this,Hr,this.options),un(this,_r,Mt(this,Sn).state)),nt}getCurrentResult(){return Mt(this,On)}trackResult(et,tt){const nt={};return Object.keys(et).forEach(rt=>{Object.defineProperty(nt,rt,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(rt),tt==null||tt(rt),et[rt])})}),nt}trackProp(et){Mt(this,qr).add(et)}getCurrentQuery(){return Mt(this,Sn)}refetch({...et}={}){return this.fetch({...et})}fetchOptimistic(et){const tt=Mt(this,Mn).defaultQueryOptions(et),nt=Mt(this,Mn).getQueryCache().build(Mt(this,Mn),tt);return nt.fetch().then(()=>this.createResult(nt,tt))}fetch(et){return gn(this,In,to).call(this,{...et,cancelRefetch:et.cancelRefetch??!0}).then(()=>(this.updateResult(),Mt(this,On)))}createResult(et,tt){var It;const nt=Mt(this,Sn),rt=this.options,ot=Mt(this,On),it=Mt(this,_r),st=Mt(this,Hr),ct=et!==nt?et.state:Mt(this,oo),{state:lt}=et;let dt={...lt},ht=!1,pt;if(tt._optimisticResults){const Rt=this.hasListeners(),Pt=!Rt&&shouldFetchOnMount(et,tt),jt=Rt&&shouldFetchOptionally(et,nt,tt,rt);(Pt||jt)&&(dt={...dt,...fetchState(lt.data,et.options)}),tt._optimisticResults==="isRestoring"&&(dt.fetchStatus="idle")}let{error:mt,errorUpdatedAt:ft,status:yt}=dt;if(tt.select&&dt.data!==void 0)if(ot&&dt.data===(it==null?void 0:it.data)&&tt.select===Mt(this,io))pt=Mt(this,Wr);else try{un(this,io,tt.select),pt=tt.select(dt.data),pt=replaceData(ot==null?void 0:ot.data,pt,tt),un(this,Wr,pt),un(this,Kn,null)}catch(Rt){un(this,Kn,Rt)}else pt=dt.data;if(tt.placeholderData!==void 0&&pt===void 0&&yt==="pending"){let Rt;if(ot!=null&&ot.isPlaceholderData&&tt.placeholderData===(st==null?void 0:st.placeholderData))Rt=ot.data;else if(Rt=typeof tt.placeholderData=="function"?tt.placeholderData((It=Mt(this,Gr))==null?void 0:It.state.data,Mt(this,Gr)):tt.placeholderData,tt.select&&Rt!==void 0)try{Rt=tt.select(Rt),un(this,Kn,null)}catch(Pt){un(this,Kn,Pt)}Rt!==void 0&&(yt="success",pt=replaceData(ot==null?void 0:ot.data,Rt,tt),ht=!0)}Mt(this,Kn)&&(mt=Mt(this,Kn),pt=Mt(this,Wr),ft=Date.now(),yt="error");const gt=dt.fetchStatus==="fetching",xt=yt==="pending",vt=yt==="error",bt=xt&>,Et=pt!==void 0,kt={status:yt,fetchStatus:dt.fetchStatus,isPending:xt,isSuccess:yt==="success",isError:vt,isInitialLoading:bt,isLoading:bt,data:pt,dataUpdatedAt:dt.dataUpdatedAt,error:mt,errorUpdatedAt:ft,failureCount:dt.fetchFailureCount,failureReason:dt.fetchFailureReason,errorUpdateCount:dt.errorUpdateCount,isFetched:dt.dataUpdateCount>0||dt.errorUpdateCount>0,isFetchedAfterMount:dt.dataUpdateCount>ct.dataUpdateCount||dt.errorUpdateCount>ct.errorUpdateCount,isFetching:gt,isRefetching:gt&&!xt,isLoadingError:vt&&!Et,isPaused:dt.fetchStatus==="paused",isPlaceholderData:ht,isRefetchError:vt&&Et,isStale:isStale(et,tt),refetch:this.refetch,promise:Mt(this,fr)};if(this.options.experimental_prefetchInRender){const Rt=Ot=>{kt.status==="error"?Ot.reject(kt.error):kt.data!==void 0&&Ot.resolve(kt.data)},Pt=()=>{const Ot=un(this,fr,kt.promise=pendingThenable());Rt(Ot)},jt=Mt(this,fr);switch(jt.status){case"pending":et.queryHash===nt.queryHash&&Rt(jt);break;case"fulfilled":(kt.status==="error"||kt.data!==jt.value)&&Pt();break;case"rejected":(kt.status!=="error"||kt.error!==jt.reason)&&Pt();break}}return kt}updateResult(et){const tt=Mt(this,On),nt=this.createResult(Mt(this,Sn),this.options);if(un(this,_r,Mt(this,Sn).state),un(this,Hr,this.options),Mt(this,_r).data!==void 0&&un(this,Gr,Mt(this,Sn)),shallowEqualObjects(nt,tt))return;un(this,On,nt);const rt={},ot=()=>{if(!tt)return!0;const{notifyOnChangeProps:it}=this.options,st=typeof it=="function"?it():it;if(st==="all"||!st&&!Mt(this,qr).size)return!0;const at=new Set(st??Mt(this,qr));return this.options.throwOnError&&at.add("error"),Object.keys(Mt(this,On)).some(ct=>{const lt=ct;return Mt(this,On)[lt]!==tt[lt]&&at.has(lt)})};(et==null?void 0:et.listeners)!==!1&&ot()&&(rt.listeners=!0),gn(this,In,Ql).call(this,{...rt,...et})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&gn(this,In,Ts).call(this)}},Mn=new WeakMap,Sn=new WeakMap,oo=new WeakMap,On=new WeakMap,_r=new WeakMap,Hr=new WeakMap,fr=new WeakMap,Kn=new WeakMap,io=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Ir=new WeakMap,Tr=new WeakMap,mr=new WeakMap,qr=new WeakMap,In=new WeakSet,to=function(et){gn(this,In,Ns).call(this);let tt=Mt(this,Sn).fetch(this.options,et);return et!=null&&et.throwOnError||(tt=tt.catch(noop$4)),tt},Rs=function(){gn(this,In,Ps).call(this);const et=resolveStaleTime(this.options.staleTime,Mt(this,Sn));if(isServer||Mt(this,On).isStale||!isValidTimeout(et))return;const nt=timeUntilStale(Mt(this,On).dataUpdatedAt,et)+1;un(this,Ir,setTimeout(()=>{Mt(this,On).isStale||this.updateResult()},nt))},_s=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Mt(this,Sn)):this.options.refetchInterval)??!1},Is=function(et){gn(this,In,Ls).call(this),un(this,mr,et),!(isServer||resolveEnabled(this.options.enabled,Mt(this,Sn))===!1||!isValidTimeout(Mt(this,mr))||Mt(this,mr)===0)&&un(this,Tr,setInterval(()=>{(this.options.refetchIntervalInBackground||focusManager.isFocused())&&gn(this,In,to).call(this)},Mt(this,mr)))},Ts=function(){gn(this,In,Rs).call(this),gn(this,In,Is).call(this,gn(this,In,_s).call(this))},Ps=function(){Mt(this,Ir)&&(clearTimeout(Mt(this,Ir)),un(this,Ir,void 0))},Ls=function(){Mt(this,Tr)&&(clearInterval(Mt(this,Tr)),un(this,Tr,void 0))},Ns=function(){const et=Mt(this,Mn).getQueryCache().build(Mt(this,Mn),this.options);if(et===Mt(this,Sn))return;const tt=Mt(this,Sn);un(this,Sn,et),un(this,oo,et.state),this.hasListeners()&&(tt==null||tt.removeObserver(this),et.addObserver(this))},Ql=function(et){notifyManager.batch(()=>{et.listeners&&this.listeners.forEach(tt=>{tt(Mt(this,On))}),Mt(this,Mn).getQueryCache().notify({query:Mt(this,Sn),type:"observerResultsUpdated"})})},qs);function shouldLoadOnMount(o,et){return resolveEnabled(et.enabled,o)!==!1&&o.state.data===void 0&&!(o.state.status==="error"&&et.retryOnMount===!1)}function shouldFetchOnMount(o,et){return shouldLoadOnMount(o,et)||o.state.data!==void 0&&shouldFetchOn(o,et,et.refetchOnMount)}function shouldFetchOn(o,et,tt){if(resolveEnabled(et.enabled,o)!==!1){const nt=typeof tt=="function"?tt(o):tt;return nt==="always"||nt!==!1&&isStale(o,et)}return!1}function shouldFetchOptionally(o,et,tt,nt){return(o!==et||resolveEnabled(nt.enabled,o)===!1)&&(!tt.suspense||o.state.status!=="error")&&isStale(o,tt)}function isStale(o,et){return resolveEnabled(et.enabled,o)!==!1&&o.isStaleByTime(resolveStaleTime(et.staleTime,o))}function shouldAssignObserverCurrentProperties(o,et){return!shallowEqualObjects(o.getCurrentResult(),et)}var gr,yr,Bn,rr,sr,Yo,js,Ks,MutationObserver$1=(Ks=class extends Subscribable{constructor(tt,nt){super();fn(this,sr);fn(this,gr);fn(this,yr);fn(this,Bn);fn(this,rr);un(this,gr,tt),this.setOptions(nt),this.bindMethods(),gn(this,sr,Yo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(tt){var rt;const nt=this.options;this.options=Mt(this,gr).defaultMutationOptions(tt),shallowEqualObjects(this.options,nt)||Mt(this,gr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Mt(this,Bn),observer:this}),nt!=null&&nt.mutationKey&&this.options.mutationKey&&hashKey(nt.mutationKey)!==hashKey(this.options.mutationKey)?this.reset():((rt=Mt(this,Bn))==null?void 0:rt.state.status)==="pending"&&Mt(this,Bn).setOptions(this.options)}onUnsubscribe(){var tt;this.hasListeners()||(tt=Mt(this,Bn))==null||tt.removeObserver(this)}onMutationUpdate(tt){gn(this,sr,Yo).call(this),gn(this,sr,js).call(this,tt)}getCurrentResult(){return Mt(this,yr)}reset(){var tt;(tt=Mt(this,Bn))==null||tt.removeObserver(this),un(this,Bn,void 0),gn(this,sr,Yo).call(this),gn(this,sr,js).call(this)}mutate(tt,nt){var rt;return un(this,rr,nt),(rt=Mt(this,Bn))==null||rt.removeObserver(this),un(this,Bn,Mt(this,gr).getMutationCache().build(Mt(this,gr),this.options)),Mt(this,Bn).addObserver(this),Mt(this,Bn).execute(tt)}},gr=new WeakMap,yr=new WeakMap,Bn=new WeakMap,rr=new WeakMap,sr=new WeakSet,Yo=function(){var nt;const tt=((nt=Mt(this,Bn))==null?void 0:nt.state)??getDefaultState();un(this,yr,{...tt,isPending:tt.status==="pending",isSuccess:tt.status==="success",isError:tt.status==="error",isIdle:tt.status==="idle",mutate:this.mutate,reset:this.reset})},js=function(tt){notifyManager.batch(()=>{var nt,rt,ot,it,st,at,ct,lt;if(Mt(this,rr)&&this.hasListeners()){const dt=Mt(this,yr).variables,ht=Mt(this,yr).context;(tt==null?void 0:tt.type)==="success"?((rt=(nt=Mt(this,rr)).onSuccess)==null||rt.call(nt,tt.data,dt,ht),(it=(ot=Mt(this,rr)).onSettled)==null||it.call(ot,tt.data,null,dt,ht)):(tt==null?void 0:tt.type)==="error"&&((at=(st=Mt(this,rr)).onError)==null||at.call(st,tt.error,dt,ht),(lt=(ct=Mt(this,rr)).onSettled)==null||lt.call(ct,void 0,tt.error,dt,ht))}this.listeners.forEach(dt=>{dt(Mt(this,yr))})})},Ks);function hashFn(o){return JSON.stringify(o,(et,tt)=>isPlainObject$2(tt)?Object.keys(tt).sort().reduce((nt,rt)=>(nt[rt]=tt[rt],nt),{}):typeof tt=="bigint"?tt.toString():tt)}function isPlainObject$2(o){if(!hasObjectPrototype(o))return!1;const et=o.constructor;if(typeof et>"u")return!0;const tt=et.prototype;return!(!hasObjectPrototype(tt)||!tt.hasOwnProperty("isPrototypeOf"))}function hasObjectPrototype(o){return Object.prototype.toString.call(o)==="[object Object]"}function filterQueryOptions(o){const{_defaulted:et,behavior:tt,gcTime:nt,initialData:rt,initialDataUpdatedAt:ot,maxPages:it,meta:st,networkMode:at,queryFn:ct,queryHash:lt,queryKey:dt,queryKeyHashFn:ht,retry:pt,retryDelay:mt,structuralSharing:ft,getPreviousPageParam:yt,getNextPageParam:gt,initialPageParam:xt,_optimisticResults:vt,enabled:bt,notifyOnChangeProps:Et,placeholderData:wt,refetchInterval:kt,refetchIntervalInBackground:It,refetchOnMount:Rt,refetchOnReconnect:Pt,refetchOnWindowFocus:jt,retryOnMount:Ot,select:Bt,staleTime:zt,suspense:Ft,throwOnError:Yt,config:Ht,connector:Ut,query:qt,...Lt}=o;return Lt}function connectMutationOptions(o){return{mutationFn(et){return connect$1(o,et)},mutationKey:["connect"]}}function disconnectMutationOptions(o){return{mutationFn(et){return disconnect(o,et)},mutationKey:["disconnect"]}}function getBalanceQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{address:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("address is required");return await getBalance(o,{...ot,address:nt})??null},queryKey:getBalanceQueryKey(et)}}function getBalanceQueryKey(o={}){return["balance",filterQueryOptions(o)]}function getBlockNumberQueryOptions(o,et={}){return{gcTime:0,async queryFn({queryKey:tt}){const{scopeKey:nt,...rt}=tt[1];return await getBlockNumber(o,rt)??null},queryKey:getBlockNumberQueryKey(et)}}function getBlockNumberQueryKey(o={}){return["blockNumber",filterQueryOptions(o)]}function getEnsAddressQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{name:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("name is required");return getEnsAddress(o,{...ot,name:nt})},queryKey:getEnsAddressQueryKey(et)}}function getEnsAddressQueryKey(o={}){return["ensAddress",filterQueryOptions(o)]}function getEnsAvatarQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{name:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("name is required");return getEnsAvatar(o,{...ot,name:nt})},queryKey:getEnsAvatarQueryKey(et)}}function getEnsAvatarQueryKey(o={}){return["ensAvatar",filterQueryOptions(o)]}function getEnsNameQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{address:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("address is required");return getEnsName(o,{...ot,address:nt})},queryKey:getEnsNameQueryKey(et)}}function getEnsNameQueryKey(o={}){return["ensName",filterQueryOptions(o)]}function signMessageMutationOptions(o){return{mutationFn(et){return signMessage(o,et)},mutationKey:["signMessage"]}}function switchChainMutationOptions(o){return{mutationFn(et){return switchChain(o,et)},mutationKey:["switchChain"]}}var QueryClientContext=reactExports.createContext(void 0),useQueryClient=o=>{const et=reactExports.useContext(QueryClientContext);if(!et)throw new Error("No QueryClient set, use QueryClientProvider to set one");return et},QueryClientProvider=({client:o,children:et})=>(reactExports.useEffect(()=>(o.mount(),()=>{o.unmount()}),[o]),jsxRuntimeExports.jsx(QueryClientContext.Provider,{value:o,children:et})),IsRestoringContext=reactExports.createContext(!1),useIsRestoring=()=>reactExports.useContext(IsRestoringContext);IsRestoringContext.Provider;function createValue(){let o=!1;return{clearReset:()=>{o=!1},reset:()=>{o=!0},isReset:()=>o}}var QueryErrorResetBoundaryContext=reactExports.createContext(createValue()),useQueryErrorResetBoundary=()=>reactExports.useContext(QueryErrorResetBoundaryContext);function shouldThrowError(o,et){return typeof o=="function"?o(...et):!!o}function noop$3(){}var ensurePreventErrorBoundaryRetry=(o,et)=>{(o.suspense||o.throwOnError||o.experimental_prefetchInRender)&&(et.isReset()||(o.retryOnMount=!1))},useClearResetErrorBoundary=o=>{reactExports.useEffect(()=>{o.clearReset()},[o])},getHasError=({result:o,errorResetBoundary:et,throwOnError:tt,query:nt})=>o.isError&&!et.isReset()&&!o.isFetching&&nt&&shouldThrowError(tt,[o.error,nt]),ensureSuspenseTimers=o=>{o.suspense&&(o.staleTime===void 0&&(o.staleTime=1e3),typeof o.gcTime=="number"&&(o.gcTime=Math.max(o.gcTime,1e3)))},willFetch=(o,et)=>o.isLoading&&o.isFetching&&!et,shouldSuspend=(o,et)=>(o==null?void 0:o.suspense)&&et.isPending,fetchOptimistic=(o,et,tt)=>et.fetchOptimistic(o).catch(()=>{tt.clearReset()});function useBaseQuery(o,et,tt){var lt,dt,ht,pt,mt;const nt=useQueryClient(),rt=useIsRestoring(),ot=useQueryErrorResetBoundary(),it=nt.defaultQueryOptions(o);(dt=(lt=nt.getDefaultOptions().queries)==null?void 0:lt._experimental_beforeQuery)==null||dt.call(lt,it),it._optimisticResults=rt?"isRestoring":"optimistic",ensureSuspenseTimers(it),ensurePreventErrorBoundaryRetry(it,ot),useClearResetErrorBoundary(ot);const st=!nt.getQueryCache().get(it.queryHash),[at]=reactExports.useState(()=>new et(nt,it)),ct=at.getOptimisticResult(it);if(reactExports.useSyncExternalStore(reactExports.useCallback(ft=>{const yt=rt?()=>{}:at.subscribe(notifyManager.batchCalls(ft));return at.updateResult(),yt},[at,rt]),()=>at.getCurrentResult(),()=>at.getCurrentResult()),reactExports.useEffect(()=>{at.setOptions(it,{listeners:!1})},[it,at]),shouldSuspend(it,ct))throw fetchOptimistic(it,at,ot);if(getHasError({result:ct,errorResetBoundary:ot,throwOnError:it.throwOnError,query:nt.getQueryCache().get(it.queryHash)}))throw ct.error;if((pt=(ht=nt.getDefaultOptions().queries)==null?void 0:ht._experimental_afterQuery)==null||pt.call(ht,it,ct),it.experimental_prefetchInRender&&!isServer&&willFetch(ct,rt)){const ft=st?fetchOptimistic(it,at,ot):(mt=nt.getQueryCache().get(it.queryHash))==null?void 0:mt.promise;ft==null||ft.catch(noop$3).finally(()=>{at.updateResult()})}return it.notifyOnChangeProps?ct:at.trackResult(ct)}function useQuery$1(o,et){return useBaseQuery(o,QueryObserver)}function useMutation(o,et){const tt=useQueryClient(),[nt]=reactExports.useState(()=>new MutationObserver$1(tt,o));reactExports.useEffect(()=>{nt.setOptions(o)},[nt,o]);const rt=reactExports.useSyncExternalStore(reactExports.useCallback(it=>nt.subscribe(notifyManager.batchCalls(it)),[nt]),()=>nt.getCurrentResult(),()=>nt.getCurrentResult()),ot=reactExports.useCallback((it,st)=>{nt.mutate(it,st).catch(noop$3)},[nt]);if(rt.error&&shouldThrowError(nt.options.throwOnError,[rt.error]))throw rt.error;return{...rt,mutate:ot,mutateAsync:rt.mutate}}function useQuery(o){const et=useQuery$1({...o,queryKeyHashFn:hashFn});return et.queryKey=o.queryKey,et}function useChainId(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchChainId(et,{onChange:tt}),()=>getChainId(et),()=>getChainId(et))}function useBalance(o={}){const{address:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getBalanceQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useWatchBlockNumber(o={}){const{enabled:et=!0,onBlockNumber:tt,config:nt,...rt}=o,ot=useConfig(o),it=useChainId({config:ot}),st=o.chainId??it;reactExports.useEffect(()=>{if(et&&tt)return watchBlockNumber(ot,{...rt,chainId:st,onBlockNumber:tt})},[st,ot,et,tt,rt.onError,rt.emitMissed,rt.emitOnBegin,rt.poll,rt.pollingInterval,rt.syncConnectedChain])}function useBlockNumber(o={}){const{query:et={},watch:tt}=o,nt=useConfig(o),rt=useQueryClient(),ot=useChainId({config:nt}),it=o.chainId??ot,st=getBlockNumberQueryOptions(nt,{...o,chainId:it});return useWatchBlockNumber({config:o.config,chainId:o.chainId,...typeof tt=="object"?tt:{},enabled:!!((et.enabled??!0)&&(typeof tt=="object"?tt.enabled:tt)),onBlockNumber(at){rt.setQueryData(st.queryKey,at)}}),useQuery({...et,...st})}function useChains$1(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchChains(et,{onChange:tt}),()=>getChains(et),()=>getChains(et))}function useConnectors$1(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchConnectors(et,{onChange:tt}),()=>getConnectors(et),()=>getConnectors(et))}function useConnect$1(o={}){const{mutation:et}=o,tt=useConfig(o),nt=connectMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return reactExports.useEffect(()=>tt.subscribe(({status:st})=>st,(st,at)=>{at==="connected"&&st==="disconnected"&&it.reset()}),[tt,it.reset]),{...it,connect:rt,connectAsync:ot,connectors:useConnectors$1({config:tt})}}function useConnections(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchConnections(et,{onChange:tt}),()=>getConnections(et),()=>getConnections(et))}function useDisconnect(o={}){const{mutation:et}=o,tt=useConfig(o),nt=disconnectMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return{...it,connectors:useConnections({config:tt}).map(st=>st.connector),disconnect:rt,disconnectAsync:ot}}function useEnsAddress(o={}){const{name:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getEnsAddressQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsAvatar(o={}){const{name:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getEnsAvatarQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsName(o={}){const{address:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getEnsNameQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useSignMessage(o={}){const{mutation:et}=o,tt=useConfig(o),nt=signMessageMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return{...it,signMessage:rt,signMessageAsync:ot}}function useSwitchChain(o={}){const{mutation:et}=o,tt=useConfig(o),nt=switchChainMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return{...it,chains:useChains$1({config:tt}),switchChain:rt,switchChainAsync:ot}}const contracts={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters={block:defineBlock({format(o){var tt;return{transactions:(tt=o.transactions)==null?void 0:tt.map(nt=>{if(typeof nt=="string")return nt;const rt=formatTransaction(nt);return rt.typeHex==="0x7e"&&(rt.isSystemTx=nt.isSystemTx,rt.mint=nt.mint?hexToBigInt(nt.mint):void 0,rt.sourceHash=nt.sourceHash,rt.type="deposit"),rt}),stateRoot:o.stateRoot}}}),transaction:defineTransaction({format(o){const et={};return o.type==="0x7e"&&(et.isSystemTx=o.isSystemTx,et.mint=o.mint?hexToBigInt(o.mint):void 0,et.sourceHash=o.sourceHash,et.type="deposit"),et}}),transactionReceipt:defineTransactionReceipt({format(o){return{l1GasPrice:o.l1GasPrice?hexToBigInt(o.l1GasPrice):null,l1GasUsed:o.l1GasUsed?hexToBigInt(o.l1GasUsed):null,l1Fee:o.l1Fee?hexToBigInt(o.l1Fee):null,l1FeeScalar:o.l1FeeScalar?Number(o.l1FeeScalar):null}}})};function serializeTransaction(o,et){return isDeposit(o)?serializeTransactionDeposit(o):serializeTransaction$1(o,et)}const serializers={transaction:serializeTransaction};function serializeTransactionDeposit(o){assertTransactionDeposit(o);const{sourceHash:et,data:tt,from:nt,gas:rt,isSystemTx:ot,mint:it,to:st,value:at}=o,ct=[et,nt,st??"0x",it?toHex(it):"0x",at?toHex(at):"0x",rt?toHex(rt):"0x",ot?"0x1":"0x",tt??"0x"];return concatHex(["0x7e",toRlp(ct)])}function isDeposit(o){return o.type==="deposit"||typeof o.sourceHash<"u"}function assertTransactionDeposit(o){const{from:et,to:tt}=o;if(et&&!isAddress(et))throw new InvalidAddressError({address:et});if(tt&&!isAddress(tt))throw new InvalidAddressError({address:tt})}const chainConfig={contracts,formatters,serializers},arbitrum=defineChain({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),mainnet=defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),sourceId=1,optimism=defineChain({...chainConfig,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...chainConfig.contracts,disputeGameFactory:{[sourceId]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[sourceId]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[sourceId]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[sourceId]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId}),polygon=defineChain({id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}});coinbaseWallet.type="coinbaseWallet";function coinbaseWallet(o={}){return o.version==="3"||o.headlessMode?version3(o):version4(o)}function version4(o){let et,tt,nt,rt,ot;return it=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:st}={}){try{const at=await this.getProvider(),ct=(await at.request({method:"eth_requestAccounts"})).map(dt=>getAddress(dt));nt||(nt=this.onAccountsChanged.bind(this),at.on("accountsChanged",nt)),rt||(rt=this.onChainChanged.bind(this),at.on("chainChanged",rt)),ot||(ot=this.onDisconnect.bind(this),at.on("disconnect",ot));let lt=await this.getChainId();if(st&<!==st){const dt=await this.switchChain({chainId:st}).catch(ht=>{if(ht.code===UserRejectedRequestError.code)throw ht;return{id:lt}});lt=(dt==null?void 0:dt.id)??lt}return{accounts:ct,chainId:lt}}catch(at){throw/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(at.message)?new UserRejectedRequestError(at):at}},async disconnect(){var at;const st=await this.getProvider();nt&&(st.removeListener("accountsChanged",nt),nt=void 0),rt&&(st.removeListener("chainChanged",rt),rt=void 0),ot&&(st.removeListener("disconnect",ot),ot=void 0),st.disconnect(),(at=st.close)==null||at.call(st)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(at=>getAddress(at))},async getChainId(){const at=await(await this.getProvider()).request({method:"eth_chainId"});return Number(at)},async getProvider(){if(!tt){const st=await(async()=>{const at=await __vitePreload(()=>import("./index-xz6stGwY.js"),__vite__mapDeps([0,1]));return typeof at.CoinbaseWalletSDK!="function"&&typeof at.default=="function"?at.default:at.CoinbaseWalletSDK})();et=new st({...o,appChainIds:it.chains.map(at=>at.id)}),tt=et.makeWeb3Provider({...o,options:o.preference??"all"})}return tt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:st,chainId:at}){var dt,ht,pt,mt;const ct=it.chains.find(ft=>ft.id===at);if(!ct)throw new SwitchChainError(new ChainNotConfiguredError);const lt=await this.getProvider();try{return await lt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(ct.id)}]}),ct}catch(ft){if(ft.code===4902)try{let yt;st!=null&&st.blockExplorerUrls?yt=st.blockExplorerUrls:yt=(dt=ct.blockExplorers)!=null&&dt.default.url?[(ht=ct.blockExplorers)==null?void 0:ht.default.url]:[];let gt;(pt=st==null?void 0:st.rpcUrls)!=null&&pt.length?gt=st.rpcUrls:gt=[((mt=ct.rpcUrls.default)==null?void 0:mt.http[0])??""];const xt={blockExplorerUrls:yt,chainId:numberToHex(at),chainName:(st==null?void 0:st.chainName)??ct.name,iconUrls:st==null?void 0:st.iconUrls,nativeCurrency:(st==null?void 0:st.nativeCurrency)??ct.nativeCurrency,rpcUrls:gt};return await lt.request({method:"wallet_addEthereumChain",params:[xt]}),ct}catch(yt){throw new UserRejectedRequestError(yt)}throw new SwitchChainError(ft)}},onAccountsChanged(st){st.length===0?this.onDisconnect():it.emitter.emit("change",{accounts:st.map(at=>getAddress(at))})},onChainChanged(st){const at=Number(st);it.emitter.emit("change",{chainId:at})},async onDisconnect(st){it.emitter.emit("disconnect");const at=await this.getProvider();nt&&(at.removeListener("accountsChanged",nt),nt=void 0),rt&&(at.removeListener("chainChanged",rt),rt=void 0),ot&&(at.removeListener("disconnect",ot),ot=void 0)}})}function version3(o){let tt,nt,rt,ot,it;return st=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:at}={}){try{const ct=await this.getProvider(),lt=(await ct.request({method:"eth_requestAccounts"})).map(ht=>getAddress(ht));rt||(rt=this.onAccountsChanged.bind(this),ct.on("accountsChanged",rt)),ot||(ot=this.onChainChanged.bind(this),ct.on("chainChanged",ot)),it||(it=this.onDisconnect.bind(this),ct.on("disconnect",it));let dt=await this.getChainId();if(at&&dt!==at){const ht=await this.switchChain({chainId:at}).catch(pt=>{if(pt.code===UserRejectedRequestError.code)throw pt;return{id:dt}});dt=(ht==null?void 0:ht.id)??dt}return{accounts:lt,chainId:dt}}catch(ct){throw/(user closed modal|accounts received is empty|user denied account)/i.test(ct.message)?new UserRejectedRequestError(ct):ct}},async disconnect(){const at=await this.getProvider();rt&&(at.removeListener("accountsChanged",rt),rt=void 0),ot&&(at.removeListener("chainChanged",ot),ot=void 0),it&&(at.removeListener("disconnect",it),it=void 0),at.disconnect(),at.close()},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(ct=>getAddress(ct))},async getChainId(){const ct=await(await this.getProvider()).request({method:"eth_chainId"});return Number(ct)},async getProvider(){var at;if(!nt){const ct=await(async()=>{const{default:mt}=await __vitePreload(async()=>{const{default:ft}=await import("./index-Cu6T4rb4.js").then(yt=>yt.i);return{default:ft}},__vite__mapDeps([2,3,1,4]));return typeof mt!="function"&&typeof mt.default=="function"?mt.default:mt})();tt=new ct({...o,reloadOnDisconnect:!1});const lt=(at=tt.walletExtension)==null?void 0:at.getChainId(),dt=st.chains.find(mt=>o.chainId?mt.id===o.chainId:mt.id===lt)||st.chains[0],ht=o.chainId||(dt==null?void 0:dt.id),pt=o.jsonRpcUrl||(dt==null?void 0:dt.rpcUrls.default.http[0]);nt=tt.makeWeb3Provider(pt,ht)}return nt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:at,chainId:ct}){var ht,pt,mt,ft;const lt=st.chains.find(yt=>yt.id===ct);if(!lt)throw new SwitchChainError(new ChainNotConfiguredError);const dt=await this.getProvider();try{return await dt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(lt.id)}]}),lt}catch(yt){if(yt.code===4902)try{let gt;at!=null&&at.blockExplorerUrls?gt=at.blockExplorerUrls:gt=(ht=lt.blockExplorers)!=null&&ht.default.url?[(pt=lt.blockExplorers)==null?void 0:pt.default.url]:[];let xt;(mt=at==null?void 0:at.rpcUrls)!=null&&mt.length?xt=at.rpcUrls:xt=[((ft=lt.rpcUrls.default)==null?void 0:ft.http[0])??""];const vt={blockExplorerUrls:gt,chainId:numberToHex(ct),chainName:(at==null?void 0:at.chainName)??lt.name,iconUrls:at==null?void 0:at.iconUrls,nativeCurrency:(at==null?void 0:at.nativeCurrency)??lt.nativeCurrency,rpcUrls:xt};return await dt.request({method:"wallet_addEthereumChain",params:[vt]}),lt}catch(gt){throw new UserRejectedRequestError(gt)}throw new SwitchChainError(yt)}},onAccountsChanged(at){at.length===0?this.onDisconnect():st.emitter.emit("change",{accounts:at.map(ct=>getAddress(ct))})},onChainChanged(at){const ct=Number(at);st.emitter.emit("change",{chainId:ct})},async onDisconnect(at){st.emitter.emit("disconnect");const ct=await this.getProvider();rt&&(ct.removeListener("accountsChanged",rt),rt=void 0),ot&&(ct.removeListener("chainChanged",ot),ot=void 0),it&&(ct.removeListener("disconnect",it),it=void 0)}})}safe.type="safe";function safe(o={}){const{shimDisconnect:et=!1}=o;let tt,nt;return rt=>({id:"safe",name:"Safe",type:safe.type,async connect(){var at;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;const it=await this.getAccounts(),st=await this.getChainId();return nt||(nt=this.onDisconnect.bind(this),ot.on("disconnect",nt)),et&&await((at=rt.storage)==null?void 0:at.removeItem("safe.disconnected")),{accounts:it,chainId:st}},async disconnect(){var it;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;nt&&(ot.removeListener("disconnect",nt),nt=void 0),et&&await((it=rt.storage)==null?void 0:it.setItem("safe.disconnected",!0))},async getAccounts(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return(await ot.request({method:"eth_accounts"})).map(getAddress)},async getProvider(){if(typeof window<"u"&&(window==null?void 0:window.parent)!==window){if(!tt){const{default:it}=await __vitePreload(async()=>{const{default:lt}=await import("./index-DlENImLn.js");return{default:lt}},[]),st=new it(o),at=await withTimeout(()=>st.safe.getInfo(),{timeout:o.unstable_getInfoTimeout??10});if(!at)throw new Error("Could not load Safe information");const ct=await(async()=>{const lt=await __vitePreload(()=>import("./index-BpmIcSNW.js").then(dt=>dt.i),__vite__mapDeps([5,4]));return typeof lt.SafeAppProvider!="function"&&typeof lt.default.SafeAppProvider=="function"?lt.default.SafeAppProvider:lt.SafeAppProvider})();tt=new ct(at,st)}return tt}},async getChainId(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return Number(ot.chainId)},async isAuthorized(){var ot;try{return et&&await((ot=rt.storage)==null?void 0:ot.getItem("safe.disconnected"))?!1:!!(await this.getAccounts()).length}catch{return!1}},onAccountsChanged(){},onChainChanged(){},onDisconnect(){rt.emitter.emit("disconnect")}})}walletConnect.type="walletConnect";function walletConnect(o){const et=o.isNewChainsStale??!0;let tt,nt;const rt="eip155";let ot,it,st,at,ct,lt;return dt=>({id:"walletConnect",name:"WalletConnect",type:walletConnect.type,async setup(){const ht=await this.getProvider().catch(()=>null);ht&&(st||(st=this.onConnect.bind(this),ht.on("connect",st)),ct||(ct=this.onSessionDelete.bind(this),ht.on("session_delete",ct)))},async connect({chainId:ht,...pt}={}){var mt,ft;try{const yt=await this.getProvider();if(!yt)throw new ProviderNotFoundError;at||(at=this.onDisplayUri,yt.on("display_uri",at));let gt=ht;if(!gt){const Et=await((mt=dt.storage)==null?void 0:mt.getItem("state"))??{};dt.chains.some(kt=>kt.id===Et.chainId)?gt=Et.chainId:gt=(ft=dt.chains[0])==null?void 0:ft.id}if(!gt)throw new Error("No chains found on connector.");const xt=await this.isChainsStale();if(yt.session&&xt&&await yt.disconnect(),!yt.session||xt){const Et=dt.chains.filter(wt=>wt.id!==gt).map(wt=>wt.id);await yt.connect({optionalChains:[gt,...Et],..."pairingTopic"in pt?{pairingTopic:pt.pairingTopic}:{}}),this.setRequestedChainsIds(dt.chains.map(wt=>wt.id))}const vt=(await yt.enable()).map(Et=>getAddress(Et)),bt=await this.getChainId();return at&&(yt.removeListener("display_uri",at),at=void 0),st&&(yt.removeListener("connect",st),st=void 0),ot||(ot=this.onAccountsChanged.bind(this),yt.on("accountsChanged",ot)),it||(it=this.onChainChanged.bind(this),yt.on("chainChanged",it)),lt||(lt=this.onDisconnect.bind(this),yt.on("disconnect",lt)),ct||(ct=this.onSessionDelete.bind(this),yt.on("session_delete",ct)),{accounts:vt,chainId:bt}}catch(yt){throw/(user rejected|connection request reset)/i.test(yt==null?void 0:yt.message)?new UserRejectedRequestError(yt):yt}},async disconnect(){const ht=await this.getProvider();try{await(ht==null?void 0:ht.disconnect())}catch(pt){if(!/No matching key/i.test(pt.message))throw pt}finally{it&&(ht==null||ht.removeListener("chainChanged",it),it=void 0),lt&&(ht==null||ht.removeListener("disconnect",lt),lt=void 0),st||(st=this.onConnect.bind(this),ht==null||ht.on("connect",st)),ot&&(ht==null||ht.removeListener("accountsChanged",ot),ot=void 0),ct&&(ht==null||ht.removeListener("session_delete",ct),ct=void 0),this.setRequestedChainsIds([])}},async getAccounts(){return(await this.getProvider()).accounts.map(pt=>getAddress(pt))},async getProvider({chainId:ht}={}){var mt;async function pt(){const ft=dt.chains.map(gt=>gt.id);if(!ft.length)return;const{EthereumProvider:yt}=await __vitePreload(async()=>{const{EthereumProvider:gt}=await import("./index.es-C5jEvyUt.js");return{EthereumProvider:gt}},__vite__mapDeps([6,4,3]));return await yt.init({...o,disableProviderPing:!0,optionalChains:ft,projectId:o.projectId,rpcMap:Object.fromEntries(dt.chains.map(gt=>{const[xt]=extractRpcUrls({chain:gt,transports:dt.transports});return[gt.id,xt]})),showQrModal:o.showQrModal??!0})}return tt||(nt||(nt=pt()),tt=await nt,tt==null||tt.events.setMaxListeners(Number.POSITIVE_INFINITY)),ht&&await((mt=this.switchChain)==null?void 0:mt.call(this,{chainId:ht})),tt},async getChainId(){return(await this.getProvider()).chainId},async isAuthorized(){try{const[ht,pt]=await Promise.all([this.getAccounts(),this.getProvider()]);return ht.length?await this.isChainsStale()&&pt.session?(await pt.disconnect().catch(()=>{}),!1):!0:!1}catch{return!1}},async switchChain({addEthereumChainParameter:ht,chainId:pt}){var yt,gt,xt;const mt=await this.getProvider();if(!mt)throw new ProviderNotFoundError;const ft=dt.chains.find(vt=>vt.id===pt);if(!ft)throw new SwitchChainError(new ChainNotConfiguredError);try{await Promise.all([new Promise(bt=>{const Et=({chainId:wt})=>{wt===pt&&(dt.emitter.off("change",Et),bt())};dt.emitter.on("change",Et)}),mt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(pt)}]})]);const vt=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...vt,pt]),ft}catch(vt){const bt=vt;if(/(user rejected)/i.test(bt.message))throw new UserRejectedRequestError(bt);try{let Et;ht!=null&&ht.blockExplorerUrls?Et=ht.blockExplorerUrls:Et=(yt=ft.blockExplorers)!=null&&yt.default.url?[(gt=ft.blockExplorers)==null?void 0:gt.default.url]:[];let wt;(xt=ht==null?void 0:ht.rpcUrls)!=null&&xt.length?wt=ht.rpcUrls:wt=[...ft.rpcUrls.default.http];const kt={blockExplorerUrls:Et,chainId:numberToHex(pt),chainName:(ht==null?void 0:ht.chainName)??ft.name,iconUrls:ht==null?void 0:ht.iconUrls,nativeCurrency:(ht==null?void 0:ht.nativeCurrency)??ft.nativeCurrency,rpcUrls:wt};await mt.request({method:"wallet_addEthereumChain",params:[kt]});const It=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...It,pt]),ft}catch(Et){throw new UserRejectedRequestError(Et)}}},onAccountsChanged(ht){ht.length===0?this.onDisconnect():dt.emitter.emit("change",{accounts:ht.map(pt=>getAddress(pt))})},onChainChanged(ht){const pt=Number(ht);dt.emitter.emit("change",{chainId:pt})},async onConnect(ht){const pt=Number(ht.chainId),mt=await this.getAccounts();dt.emitter.emit("connect",{accounts:mt,chainId:pt})},async onDisconnect(ht){this.setRequestedChainsIds([]),dt.emitter.emit("disconnect");const pt=await this.getProvider();ot&&(pt.removeListener("accountsChanged",ot),ot=void 0),it&&(pt.removeListener("chainChanged",it),it=void 0),lt&&(pt.removeListener("disconnect",lt),lt=void 0),ct&&(pt.removeListener("session_delete",ct),ct=void 0),st||(st=this.onConnect.bind(this),pt.on("connect",st))},onDisplayUri(ht){dt.emitter.emit("message",{type:"display_uri",data:ht})},onSessionDelete(){this.onDisconnect()},getNamespaceChainsIds(){var pt,mt,ft;return tt?((ft=(mt=(pt=tt.session)==null?void 0:pt.namespaces[rt])==null?void 0:mt.accounts)==null?void 0:ft.map(yt=>Number.parseInt(yt.split(":")[1]||"")))??[]:[]},async getRequestedChainsIds(){var ht;return await((ht=dt.storage)==null?void 0:ht.getItem(this.requestedChainsStorageKey))??[]},async isChainsStale(){if(!et)return!1;const ht=dt.chains.map(ft=>ft.id),pt=this.getNamespaceChainsIds();if(pt.length&&!pt.some(ft=>ht.includes(ft)))return!1;const mt=await this.getRequestedChainsIds();return!ht.every(ft=>mt.includes(ft))},async setRequestedChainsIds(ht){var pt;await((pt=dt.storage)==null?void 0:pt.setItem(this.requestedChainsStorageKey,ht))},get requestedChainsStorageKey(){return`${this.id}.requestedChains`}})}var define_process_default$3={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},__spreadArray$1=function(o,et,tt){for(var nt=0,rt=et.length,ot;nt"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(o){return o!==""&&userAgentRules.reduce(function(et,tt){var nt=tt[0],rt=tt[1];if(et)return et;var ot=rt.exec(o);return!!ot&&[nt,ot]},!1)}function parseUserAgent(o){var et=matchUserAgent(o);if(!et)return null;var tt=et[0],nt=et[1];if(tt==="searchbot")return new BotInfo;var rt=nt[1]&&nt[1].split(".").join("_").split("_").slice(0,3);rt?rt.length=0;st--)(it=o[st])&&(ot=(rt<3?it(ot):rt>3?it(et,tt,ot):it(et,tt))||ot);return rt>3&&ot&&Object.defineProperty(et,tt,ot),ot}function __param(o,et){return function(tt,nt){et(tt,nt,o)}}function __esDecorate(o,et,tt,nt,rt,ot){function it(gt){if(gt!==void 0&&typeof gt!="function")throw new TypeError("Function expected");return gt}for(var st=nt.kind,at=st==="getter"?"get":st==="setter"?"set":"value",ct=!et&&o?nt.static?o:o.prototype:null,lt=et||(ct?Object.getOwnPropertyDescriptor(ct,nt.name):{}),dt,ht=!1,pt=tt.length-1;pt>=0;pt--){var mt={};for(var ft in nt)mt[ft]=ft==="access"?{}:nt[ft];for(var ft in nt.access)mt.access[ft]=nt.access[ft];mt.addInitializer=function(gt){if(ht)throw new TypeError("Cannot add initializers after decoration has completed");ot.push(it(gt||null))};var yt=(0,tt[pt])(st==="accessor"?{get:lt.get,set:lt.set}:lt[at],mt);if(st==="accessor"){if(yt===void 0)continue;if(yt===null||typeof yt!="object")throw new TypeError("Object expected");(dt=it(yt.get))&&(lt.get=dt),(dt=it(yt.set))&&(lt.set=dt),(dt=it(yt.init))&&rt.unshift(dt)}else(dt=it(yt))&&(st==="field"?rt.unshift(dt):lt[at]=dt)}ct&&Object.defineProperty(ct,nt.name,lt),ht=!0}function __runInitializers(o,et,tt){for(var nt=arguments.length>2,rt=0;rt0&&ot[ot.length-1])&&(ct[0]===6||ct[0]===2)){tt=0;continue}if(ct[0]===3&&(!ot||ct[1]>ot[0]&&ct[1]=o.length&&(o=void 0),{value:o&&o[nt++],done:!o}}};throw new TypeError(et?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(o,et){var tt=typeof Symbol=="function"&&o[Symbol.iterator];if(!tt)return o;var nt=tt.call(o),rt,ot=[],it;try{for(;(et===void 0||et-- >0)&&!(rt=nt.next()).done;)ot.push(rt.value)}catch(st){it={error:st}}finally{try{rt&&!rt.done&&(tt=nt.return)&&tt.call(nt)}finally{if(it)throw it.error}}return ot}function __spread(){for(var o=[],et=0;et1||at(pt,ft)})},mt&&(rt[pt]=mt(rt[pt])))}function at(pt,mt){try{ct(nt[pt](mt))}catch(ft){ht(ot[0][3],ft)}}function ct(pt){pt.value instanceof __await?Promise.resolve(pt.value.v).then(lt,dt):ht(ot[0][2],pt)}function lt(pt){at("next",pt)}function dt(pt){at("throw",pt)}function ht(pt,mt){pt(mt),ot.shift(),ot.length&&at(ot[0][0],ot[0][1])}}function __asyncDelegator(o){var et,tt;return et={},nt("next"),nt("throw",function(rt){throw rt}),nt("return"),et[Symbol.iterator]=function(){return this},et;function nt(rt,ot){et[rt]=o[rt]?function(it){return(tt=!tt)?{value:__await(o[rt](it)),done:!1}:ot?ot(it):it}:ot}}function __asyncValues(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var et=o[Symbol.asyncIterator],tt;return et?et.call(o):(o=typeof __values=="function"?__values(o):o[Symbol.iterator](),tt={},nt("next"),nt("throw"),nt("return"),tt[Symbol.asyncIterator]=function(){return this},tt);function nt(ot){tt[ot]=o[ot]&&function(it){return new Promise(function(st,at){it=o[ot](it),rt(st,at,it.done,it.value)})}}function rt(ot,it,st,at){Promise.resolve(at).then(function(ct){ot({value:ct,done:st})},it)}}function __makeTemplateObject(o,et){return Object.defineProperty?Object.defineProperty(o,"raw",{value:et}):o.raw=et,o}var __setModuleDefault=Object.create?function(o,et){Object.defineProperty(o,"default",{enumerable:!0,value:et})}:function(o,et){o.default=et},ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(et){var tt=[];for(var nt in et)Object.prototype.hasOwnProperty.call(et,nt)&&(tt[tt.length]=nt);return tt},ownKeys(o)};function __importStar(o){if(o&&o.__esModule)return o;var et={};if(o!=null)for(var tt=ownKeys(o),nt=0;nt"u"||define_process_env_default$1===void 0?defaultEnvironment:"production",createDefinition=function(o){return{isEnabled:function(et){return o.some(function(tt){return!!et[tt]})}}},featureDefinitions={measureLayout:createDefinition(["layout","layoutId","drag"]),animation:createDefinition(["animate","exit","variants","whileHover","whileTap","whileFocus","whileDrag","whileInView"]),exit:createDefinition(["exit"]),drag:createDefinition(["drag","dragControls"]),focus:createDefinition(["whileFocus"]),hover:createDefinition(["whileHover","onHoverStart","onHoverEnd"]),tap:createDefinition(["whileTap","onTap","onTapStart","onTapCancel"]),pan:createDefinition(["onPan","onPanStart","onPanSessionStart","onPanEnd"]),inView:createDefinition(["whileInView","onViewportEnter","onViewportLeave"])};function loadFeatures(o){for(var et in o)o[et]!==null&&(et==="projectionNodeConstructor"?featureDefinitions.projectionNodeConstructor=o[et]:featureDefinitions[et].Component=o[et])}var invariant$1=function(){},LazyContext=reactExports.createContext({strict:!1}),featureNames=Object.keys(featureDefinitions),numFeatures=featureNames.length;function useFeatures(o,et,tt){var nt=[],rt=reactExports.useContext(LazyContext);if(!et)return null;env$1!=="production"&&tt&&rt.strict;for(var ot=0;ot"u")return et;var tt=new Map;return new Proxy(et,{get:function(nt,rt){return tt.has(rt)||tt.set(rt,et(rt)),tt.get(rt)}})}var lowercaseSVGElements=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","svg","switch","symbol","text","tspan","use","view"];function isSVGComponent(o){return typeof o!="string"||o.includes("-")?!1:!!(lowercaseSVGElements.indexOf(o)>-1||/[A-Z]/.test(o))}var scaleCorrectors={};function addScaleCorrector(o){Object.assign(scaleCorrectors,o)}var transformAxes=["","X","Y","Z"],order$1=["translate","scale","rotate","skew"],transformProps=["transformPerspective","x","y","z"];order$1.forEach(function(o){return transformAxes.forEach(function(et){return transformProps.push(o+et)})});function sortTransformProps(o,et){return transformProps.indexOf(o)-transformProps.indexOf(et)}var transformPropSet=new Set(transformProps);function isTransformProp(o){return transformPropSet.has(o)}var transformOriginProps=new Set(["originX","originY","originZ"]);function isTransformOriginProp(o){return transformOriginProps.has(o)}function isForcedMotionValue(o,et){var tt=et.layout,nt=et.layoutId;return isTransformProp(o)||isTransformOriginProp(o)||(tt||nt!==void 0)&&(!!scaleCorrectors[o]||o==="opacity")}var isMotionValue=function(o){return!!(o!==null&&typeof o=="object"&&o.getVelocity)},translateAlias={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"};function buildTransform(o,et,tt,nt){var rt=o.transform,ot=o.transformKeys,it=et.enableHardwareAcceleration,st=it===void 0?!0:it,at=et.allowTransformNone,ct=at===void 0?!0:at,lt="";ot.sort(sortTransformProps);for(var dt=!1,ht=ot.length,pt=0;pttt=>Math.max(Math.min(tt,et),o),sanitize=o=>o%1?Number(o.toFixed(5)):o,floatRegex=/(-)?([\d]*\.?[\d])+/g,colorRegex=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,singleColorRegex=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function isString(o){return typeof o=="string"}const number$3={test:o=>typeof o=="number",parse:parseFloat,transform:o=>o},alpha=Object.assign(Object.assign({},number$3),{transform:clamp$2(0,1)}),scale=Object.assign(Object.assign({},number$3),{default:1}),createUnitType=o=>({test:et=>isString(et)&&et.endsWith(o)&&et.split(" ").length===1,parse:parseFloat,transform:et=>`${et}${o}`}),degrees=createUnitType("deg"),percent=createUnitType("%"),px=createUnitType("px"),vh=createUnitType("vh"),vw=createUnitType("vw"),progressPercentage=Object.assign(Object.assign({},percent),{parse:o=>percent.parse(o)/100,transform:o=>percent.transform(o*100)}),isColorString=(o,et)=>tt=>!!(isString(tt)&&singleColorRegex.test(tt)&&tt.startsWith(o)||et&&Object.prototype.hasOwnProperty.call(tt,et)),splitColor=(o,et,tt)=>nt=>{if(!isString(nt))return nt;const[rt,ot,it,st]=nt.match(floatRegex);return{[o]:parseFloat(rt),[et]:parseFloat(ot),[tt]:parseFloat(it),alpha:st!==void 0?parseFloat(st):1}},hsla={test:isColorString("hsl","hue"),parse:splitColor("hue","saturation","lightness"),transform:({hue:o,saturation:et,lightness:tt,alpha:nt=1})=>"hsla("+Math.round(o)+", "+percent.transform(sanitize(et))+", "+percent.transform(sanitize(tt))+", "+sanitize(alpha.transform(nt))+")"},clampRgbUnit=clamp$2(0,255),rgbUnit=Object.assign(Object.assign({},number$3),{transform:o=>Math.round(clampRgbUnit(o))}),rgba={test:isColorString("rgb","red"),parse:splitColor("red","green","blue"),transform:({red:o,green:et,blue:tt,alpha:nt=1})=>"rgba("+rgbUnit.transform(o)+", "+rgbUnit.transform(et)+", "+rgbUnit.transform(tt)+", "+sanitize(alpha.transform(nt))+")"};function parseHex(o){let et="",tt="",nt="",rt="";return o.length>5?(et=o.substr(1,2),tt=o.substr(3,2),nt=o.substr(5,2),rt=o.substr(7,2)):(et=o.substr(1,1),tt=o.substr(2,1),nt=o.substr(3,1),rt=o.substr(4,1),et+=et,tt+=tt,nt+=nt,rt+=rt),{red:parseInt(et,16),green:parseInt(tt,16),blue:parseInt(nt,16),alpha:rt?parseInt(rt,16)/255:1}}const hex={test:isColorString("#"),parse:parseHex,transform:rgba.transform},color$1={test:o=>rgba.test(o)||hex.test(o)||hsla.test(o),parse:o=>rgba.test(o)?rgba.parse(o):hsla.test(o)?hsla.parse(o):hex.parse(o),transform:o=>isString(o)?o:o.hasOwnProperty("red")?rgba.transform(o):hsla.transform(o)},colorToken="${c}",numberToken="${n}";function test(o){var et,tt,nt,rt;return isNaN(o)&&isString(o)&&((tt=(et=o.match(floatRegex))===null||et===void 0?void 0:et.length)!==null&&tt!==void 0?tt:0)+((rt=(nt=o.match(colorRegex))===null||nt===void 0?void 0:nt.length)!==null&&rt!==void 0?rt:0)>0}function analyse$1(o){typeof o=="number"&&(o=`${o}`);const et=[];let tt=0;const nt=o.match(colorRegex);nt&&(tt=nt.length,o=o.replace(colorRegex,colorToken),et.push(...nt.map(color$1.parse)));const rt=o.match(floatRegex);return rt&&(o=o.replace(floatRegex,numberToken),et.push(...rt.map(number$3.parse))),{values:et,numColors:tt,tokenised:o}}function parse$4(o){return analyse$1(o).values}function createTransformer(o){const{values:et,numColors:tt,tokenised:nt}=analyse$1(o),rt=et.length;return ot=>{let it=nt;for(let st=0;sttypeof o=="number"?0:o;function getAnimatableNone$1(o){const et=parse$4(o);return createTransformer(o)(et.map(convertNumbersToZero))}const complex={test,parse:parse$4,createTransformer,getAnimatableNone:getAnimatableNone$1},maxDefaults=new Set(["brightness","contrast","saturate","opacity"]);function applyDefaultFilter(o){let[et,tt]=o.slice(0,-1).split("(");if(et==="drop-shadow")return o;const[nt]=tt.match(floatRegex)||[];if(!nt)return o;const rt=tt.replace(nt,"");let ot=maxDefaults.has(et)?1:0;return nt!==tt&&(ot*=100),et+"("+ot+rt+")"}const functionRegex=/([a-z-]*)\(.*?\)/g,filter$1=Object.assign(Object.assign({},complex),{getAnimatableNone:o=>{const et=o.match(functionRegex);return et?et.map(applyDefaultFilter).join(" "):o}});var int=__assign(__assign({},number$3),{transform:Math.round}),numberValueTypes={borderWidth:px,borderTopWidth:px,borderRightWidth:px,borderBottomWidth:px,borderLeftWidth:px,borderRadius:px,radius:px,borderTopLeftRadius:px,borderTopRightRadius:px,borderBottomRightRadius:px,borderBottomLeftRadius:px,width:px,maxWidth:px,height:px,maxHeight:px,size:px,top:px,right:px,bottom:px,left:px,padding:px,paddingTop:px,paddingRight:px,paddingBottom:px,paddingLeft:px,margin:px,marginTop:px,marginRight:px,marginBottom:px,marginLeft:px,rotate:degrees,rotateX:degrees,rotateY:degrees,rotateZ:degrees,scale,scaleX:scale,scaleY:scale,scaleZ:scale,skew:degrees,skewX:degrees,skewY:degrees,distance:px,translateX:px,translateY:px,translateZ:px,x:px,y:px,z:px,perspective:px,transformPerspective:px,opacity:alpha,originX:progressPercentage,originY:progressPercentage,originZ:px,zIndex:int,fillOpacity:alpha,strokeOpacity:alpha,numOctaves:int};function buildHTMLStyles(o,et,tt,nt){var rt,ot=o.style,it=o.vars,st=o.transform,at=o.transformKeys,ct=o.transformOrigin;at.length=0;var lt=!1,dt=!1,ht=!0;for(var pt in et){var mt=et[pt];if(isCSSVariable$1(pt)){it[pt]=mt;continue}var ft=numberValueTypes[pt],yt=getValueAsType(mt,ft);if(isTransformProp(pt)){if(lt=!0,st[pt]=yt,at.push(pt),!ht)continue;mt!==((rt=ft.default)!==null&&rt!==void 0?rt:0)&&(ht=!1)}else isTransformOriginProp(pt)?(ct[pt]=yt,dt=!0):ot[pt]=yt}lt?ot.transform=buildTransform(o,tt,ht,nt):nt?ot.transform=nt({},""):!et.transform&&ot.transform&&(ot.transform="none"),dt&&(ot.transformOrigin=buildTransformOrigin(ct))}var createHtmlRenderState=function(){return{style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{}}};function copyRawValuesOnly(o,et,tt){for(var nt in et)!isMotionValue(et[nt])&&!isForcedMotionValue(nt,tt)&&(o[nt]=et[nt])}function useInitialMotionValues(o,et,tt){var nt=o.transformTemplate;return reactExports.useMemo(function(){var rt=createHtmlRenderState();buildHTMLStyles(rt,et,{enableHardwareAcceleration:!tt},nt);var ot=rt.vars,it=rt.style;return __assign(__assign({},ot),it)},[et])}function useStyle(o,et,tt){var nt=o.style||{},rt={};return copyRawValuesOnly(rt,nt,o),Object.assign(rt,useInitialMotionValues(o,et,tt)),o.transformValues&&(rt=o.transformValues(rt)),rt}function useHTMLProps(o,et,tt){var nt={},rt=useStyle(o,et,tt);return o.drag&&o.dragListener!==!1&&(nt.draggable=!1,rt.userSelect=rt.WebkitUserSelect=rt.WebkitTouchCallout="none",rt.touchAction=o.drag===!0?"none":"pan-".concat(o.drag==="x"?"y":"x")),nt.style=rt,nt}var validMotionProps=new Set(["initial","animate","exit","style","variants","transition","transformTemplate","transformValues","custom","inherit","layout","layoutId","layoutDependency","onLayoutAnimationStart","onLayoutAnimationComplete","onLayoutMeasure","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","drag","dragControls","dragListener","dragConstraints","dragDirectionLock","dragSnapToOrigin","_dragX","_dragY","dragElastic","dragMomentum","dragPropagation","dragTransition","whileDrag","onPan","onPanStart","onPanEnd","onPanSessionStart","onTap","onTapStart","onTapCancel","onHoverStart","onHoverEnd","whileFocus","whileTap","whileHover","whileInView","onViewportEnter","onViewportLeave","viewport","layoutScroll"]);function isValidMotionProp(o){return validMotionProps.has(o)}var shouldForward=function(o){return!isValidMotionProp(o)};function loadExternalIsValidProp(o){o&&(shouldForward=function(et){return et.startsWith("on")?!isValidMotionProp(et):o(et)})}try{loadExternalIsValidProp(require("@emotion/is-prop-valid").default)}catch{}function filterProps(o,et,tt){var nt={};for(var rt in o)(shouldForward(rt)||tt===!0&&isValidMotionProp(rt)||!et&&!isValidMotionProp(rt)||o.draggable&&rt.startsWith("onDrag"))&&(nt[rt]=o[rt]);return nt}function calcOrigin$1(o,et,tt){return typeof o=="string"?o:px.transform(et+tt*o)}function calcSVGTransformOrigin(o,et,tt){var nt=calcOrigin$1(et,o.x,o.width),rt=calcOrigin$1(tt,o.y,o.height);return"".concat(nt," ").concat(rt)}var camelKeys={offset:"strokeDashoffset",array:"strokeDasharray"};function buildSVGPath(o,et,tt,nt,rt){tt===void 0&&(tt=1),nt===void 0&&(nt=0),o.pathLength=1;var ot=camelKeys;o[ot.offset]=px.transform(-nt);var it=px.transform(et),st=px.transform(tt);o[ot.array]="".concat(it," ").concat(st)}function buildSVGAttrs(o,et,tt,nt){var rt=et.attrX,ot=et.attrY,it=et.originX,st=et.originY,at=et.pathLength,ct=et.pathSpacing,lt=ct===void 0?1:ct,dt=et.pathOffset,ht=dt===void 0?0:dt,pt=__rest(et,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]);buildHTMLStyles(o,pt,tt,nt),o.attrs=o.style,o.style={};var mt=o.attrs,ft=o.style,yt=o.dimensions;mt.transform&&(yt&&(ft.transform=mt.transform),delete mt.transform),yt&&(it!==void 0||st!==void 0||ft.transform)&&(ft.transformOrigin=calcSVGTransformOrigin(yt,it!==void 0?it:.5,st!==void 0?st:.5)),rt!==void 0&&(mt.x=rt),ot!==void 0&&(mt.y=ot),at!==void 0&&buildSVGPath(mt,at,lt,ht)}var createSvgRenderState=function(){return __assign(__assign({},createHtmlRenderState()),{attrs:{}})};function useSVGProps(o,et){var tt=reactExports.useMemo(function(){var rt=createSvgRenderState();return buildSVGAttrs(rt,et,{enableHardwareAcceleration:!1},o.transformTemplate),__assign(__assign({},rt.attrs),{style:__assign({},rt.style)})},[et]);if(o.style){var nt={};copyRawValuesOnly(nt,o.style,o),tt.style=__assign(__assign({},nt),tt.style)}return tt}function createUseRender(o){o===void 0&&(o=!1);var et=function(tt,nt,rt,ot,it,st){var at=it.latestValues,ct=isSVGComponent(tt)?useSVGProps:useHTMLProps,lt=ct(nt,at,st),dt=filterProps(nt,typeof tt=="string",o),ht=__assign(__assign(__assign({},dt),lt),{ref:ot});return rt&&(ht["data-projection-id"]=rt),reactExports.createElement(tt,ht)};return et}var CAMEL_CASE_PATTERN=/([a-z])([A-Z])/g,REPLACE_TEMPLATE="$1-$2",camelToDash=function(o){return o.replace(CAMEL_CASE_PATTERN,REPLACE_TEMPLATE).toLowerCase()};function renderHTML(o,et,tt,nt){var rt=et.style,ot=et.vars;Object.assign(o.style,rt,nt&&nt.getProjectionStyles(tt));for(var it in ot)o.style.setProperty(it,ot[it])}var camelCaseAttributes=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength"]);function renderSVG(o,et,tt,nt){renderHTML(o,et,void 0,nt);for(var rt in et.attrs)o.setAttribute(camelCaseAttributes.has(rt)?rt:camelToDash(rt),et.attrs[rt])}function scrapeMotionValuesFromProps$1(o){var et=o.style,tt={};for(var nt in et)(isMotionValue(et[nt])||isForcedMotionValue(nt,o))&&(tt[nt]=et[nt]);return tt}function scrapeMotionValuesFromProps(o){var et=scrapeMotionValuesFromProps$1(o);for(var tt in o)if(isMotionValue(o[tt])){var nt=tt==="x"||tt==="y"?"attr"+tt.toUpperCase():tt;et[nt]=o[tt]}return et}function isAnimationControls(o){return typeof o=="object"&&typeof o.start=="function"}var isKeyframesTarget=function(o){return Array.isArray(o)},isCustomValue=function(o){return!!(o&&typeof o=="object"&&o.mix&&o.toValue)},resolveFinalValueInKeyframes=function(o){return isKeyframesTarget(o)?o[o.length-1]||0:o};function resolveMotionValue(o){var et=isMotionValue(o)?o.get():o;return isCustomValue(et)?et.toValue():et}function makeState(o,et,tt,nt){var rt=o.scrapeMotionValuesFromProps,ot=o.createRenderState,it=o.onMount,st={latestValues:makeLatestValues(et,tt,nt,rt),renderState:ot()};return it&&(st.mount=function(at){return it(et,at,st)}),st}var makeUseVisualState=function(o){return function(et,tt){var nt=reactExports.useContext(MotionContext),rt=reactExports.useContext(PresenceContext);return tt?makeState(o,et,nt,rt):useConstant(function(){return makeState(o,et,nt,rt)})}};function makeLatestValues(o,et,tt,nt){var rt={},ot=(tt==null?void 0:tt.initial)===!1,it=nt(o);for(var st in it)rt[st]=resolveMotionValue(it[st]);var at=o.initial,ct=o.animate,lt=checkIfControllingVariants(o),dt=checkIfVariantNode(o);et&&dt&&!lt&&o.inherit!==!1&&(at??(at=et.initial),ct??(ct=et.animate));var ht=ot||at===!1,pt=ht?ct:at;if(pt&&typeof pt!="boolean"&&!isAnimationControls(pt)){var mt=Array.isArray(pt)?pt:[pt];mt.forEach(function(ft){var yt=resolveVariantFromProps(o,ft);if(yt){var gt=yt.transitionEnd;yt.transition;var xt=__rest(yt,["transitionEnd","transition"]);for(var vt in xt){var bt=xt[vt];if(Array.isArray(bt)){var Et=ht?bt.length-1:0;bt=bt[Et]}bt!==null&&(rt[vt]=bt)}for(var vt in gt)rt[vt]=gt[vt]}})}return rt}var svgMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps,createRenderState:createSvgRenderState,onMount:function(o,et,tt){var nt=tt.renderState,rt=tt.latestValues;try{nt.dimensions=typeof et.getBBox=="function"?et.getBBox():et.getBoundingClientRect()}catch{nt.dimensions={x:0,y:0,width:0,height:0}}buildSVGAttrs(nt,rt,{enableHardwareAcceleration:!1},o.transformTemplate),renderSVG(et,nt)}})},htmlMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,createRenderState:createHtmlRenderState})};function createDomMotionConfig(o,et,tt,nt,rt){var ot=et.forwardMotionProps,it=ot===void 0?!1:ot,st=isSVGComponent(o)?svgMotionConfig:htmlMotionConfig;return __assign(__assign({},st),{preloadedFeatures:tt,useRender:createUseRender(it),createVisualElement:nt,projectionNodeConstructor:rt,Component:o})}var AnimationType;(function(o){o.Animate="animate",o.Hover="whileHover",o.Tap="whileTap",o.Drag="whileDrag",o.Focus="whileFocus",o.InView="whileInView",o.Exit="exit"})(AnimationType||(AnimationType={}));function addDomEvent(o,et,tt,nt){return nt===void 0&&(nt={passive:!0}),o.addEventListener(et,tt,nt),function(){return o.removeEventListener(et,tt)}}function useDomEvent(o,et,tt,nt){reactExports.useEffect(function(){var rt=o.current;if(tt&&rt)return addDomEvent(rt,et,tt,nt)},[o,et,tt,nt])}function useFocusGesture(o){var et=o.whileFocus,tt=o.visualElement,nt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!0)},rt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!1)};useDomEvent(tt,"focus",et?nt:void 0),useDomEvent(tt,"blur",et?rt:void 0)}function isMouseEvent(o){return typeof PointerEvent<"u"&&o instanceof PointerEvent?o.pointerType==="mouse":o instanceof MouseEvent}function isTouchEvent(o){var et=!!o.touches;return et}function filterPrimaryPointer(o){return function(et){var tt=et instanceof MouseEvent,nt=!tt||tt&&et.button===0;nt&&o(et)}}var defaultPagePoint={pageX:0,pageY:0};function pointFromTouch(o,et){et===void 0&&(et="page");var tt=o.touches[0]||o.changedTouches[0],nt=tt||defaultPagePoint;return{x:nt[et+"X"],y:nt[et+"Y"]}}function pointFromMouse(o,et){return et===void 0&&(et="page"),{x:o[et+"X"],y:o[et+"Y"]}}function extractEventInfo(o,et){return et===void 0&&(et="page"),{point:isTouchEvent(o)?pointFromTouch(o,et):pointFromMouse(o,et)}}var wrapHandler=function(o,et){et===void 0&&(et=!1);var tt=function(nt){return o(nt,extractEventInfo(nt))};return et?filterPrimaryPointer(tt):tt},supportsPointerEvents=function(){return isBrowser$3&&window.onpointerdown===null},supportsTouchEvents=function(){return isBrowser$3&&window.ontouchstart===null},supportsMouseEvents=function(){return isBrowser$3&&window.onmousedown===null},mouseEventNames={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},touchEventNames={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function getPointerEventName(o){return supportsPointerEvents()?o:supportsTouchEvents()?touchEventNames[o]:supportsMouseEvents()?mouseEventNames[o]:o}function addPointerEvent(o,et,tt,nt){return addDomEvent(o,getPointerEventName(et),wrapHandler(tt,et==="pointerdown"),nt)}function usePointerEvent(o,et,tt,nt){return useDomEvent(o,getPointerEventName(et),tt&&wrapHandler(tt,et==="pointerdown"),nt)}function createLock(o){var et=null;return function(){var tt=function(){et=null};return et===null?(et=o,tt):!1}}var globalHorizontalLock=createLock("dragHorizontal"),globalVerticalLock=createLock("dragVertical");function getGlobalLock(o){var et=!1;if(o==="y")et=globalVerticalLock();else if(o==="x")et=globalHorizontalLock();else{var tt=globalHorizontalLock(),nt=globalVerticalLock();tt&&nt?et=function(){tt(),nt()}:(tt&&tt(),nt&&nt())}return et}function isDragActive(){var o=getGlobalLock(!0);return o?(o(),!1):!0}function createHoverEvent(o,et,tt){return function(nt,rt){var ot;!isMouseEvent(nt)||isDragActive()||((ot=o.animationState)===null||ot===void 0||ot.setActive(AnimationType.Hover,et),tt==null||tt(nt,rt))}}function useHoverGesture(o){var et=o.onHoverStart,tt=o.onHoverEnd,nt=o.whileHover,rt=o.visualElement;usePointerEvent(rt,"pointerenter",et||nt?createHoverEvent(rt,!0,et):void 0,{passive:!et}),usePointerEvent(rt,"pointerleave",tt||nt?createHoverEvent(rt,!1,tt):void 0,{passive:!tt})}var isNodeOrChild=function(o,et){return et?o===et?!0:isNodeOrChild(o,et.parentElement):!1};function useUnmountEffect(o){return reactExports.useEffect(function(){return function(){return o()}},[])}const clamp$1=(o,et,tt)=>Math.min(Math.max(tt,o),et),safeMin=.001,minDuration=.01,maxDuration=10,minDamping=.05,maxDamping=1;function findSpring({duration:o=800,bounce:et=.25,velocity:tt=0,mass:nt=1}){let rt,ot,it=1-et;it=clamp$1(minDamping,maxDamping,it),o=clamp$1(minDuration,maxDuration,o/1e3),it<1?(rt=ct=>{const lt=ct*it,dt=lt*o,ht=lt-tt,pt=calcAngularFreq(ct,it),mt=Math.exp(-dt);return safeMin-ht/pt*mt},ot=ct=>{const dt=ct*it*o,ht=dt*tt+tt,pt=Math.pow(it,2)*Math.pow(ct,2)*o,mt=Math.exp(-dt),ft=calcAngularFreq(Math.pow(ct,2),it);return(-rt(ct)+safeMin>0?-1:1)*((ht-pt)*mt)/ft}):(rt=ct=>{const lt=Math.exp(-ct*o),dt=(ct-tt)*o+1;return-safeMin+lt*dt},ot=ct=>{const lt=Math.exp(-ct*o),dt=(tt-ct)*(o*o);return lt*dt});const st=5/o,at=approximateRoot(rt,ot,st);if(o=o*1e3,isNaN(at))return{stiffness:100,damping:10,duration:o};{const ct=Math.pow(at,2)*nt;return{stiffness:ct,damping:it*2*Math.sqrt(nt*ct),duration:o}}}const rootIterations=12;function approximateRoot(o,et,tt){let nt=tt;for(let rt=1;rto[tt]!==void 0)}function getSpringOptions(o){let et=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},o);if(!isSpringType(o,physicsKeys)&&isSpringType(o,durationKeys)){const tt=findSpring(o);et=Object.assign(Object.assign(Object.assign({},et),tt),{velocity:0,mass:1}),et.isResolvedFromDuration=!0}return et}function spring(o){var{from:et=0,to:tt=1,restSpeed:nt=2,restDelta:rt}=o,ot=__rest(o,["from","to","restSpeed","restDelta"]);const it={done:!1,value:et};let{stiffness:st,damping:at,mass:ct,velocity:lt,duration:dt,isResolvedFromDuration:ht}=getSpringOptions(ot),pt=zero$1,mt=zero$1;function ft(){const yt=lt?-(lt/1e3):0,gt=tt-et,xt=at/(2*Math.sqrt(st*ct)),vt=Math.sqrt(st/ct)/1e3;if(rt===void 0&&(rt=Math.min(Math.abs(tt-et)/100,.4)),xt<1){const bt=calcAngularFreq(vt,xt);pt=Et=>{const wt=Math.exp(-xt*vt*Et);return tt-wt*((yt+xt*vt*gt)/bt*Math.sin(bt*Et)+gt*Math.cos(bt*Et))},mt=Et=>{const wt=Math.exp(-xt*vt*Et);return xt*vt*wt*(Math.sin(bt*Et)*(yt+xt*vt*gt)/bt+gt*Math.cos(bt*Et))-wt*(Math.cos(bt*Et)*(yt+xt*vt*gt)-bt*gt*Math.sin(bt*Et))}}else if(xt===1)pt=bt=>tt-Math.exp(-vt*bt)*(gt+(yt+vt*gt)*bt);else{const bt=vt*Math.sqrt(xt*xt-1);pt=Et=>{const wt=Math.exp(-xt*vt*Et),kt=Math.min(bt*Et,300);return tt-wt*((yt+xt*vt*gt)*Math.sinh(kt)+bt*gt*Math.cosh(kt))/bt}}}return ft(),{next:yt=>{const gt=pt(yt);if(ht)it.done=yt>=dt;else{const xt=mt(yt)*1e3,vt=Math.abs(xt)<=nt,bt=Math.abs(tt-gt)<=rt;it.done=vt&&bt}return it.value=it.done?tt:gt,it},flipTarget:()=>{lt=-lt,[et,tt]=[tt,et],ft()}}}spring.needsInterpolation=(o,et)=>typeof o=="string"||typeof et=="string";const zero$1=o=>0,progress=(o,et,tt)=>{const nt=et-o;return nt===0?1:(tt-o)/nt},mix=(o,et,tt)=>-tt*o+tt*et+o;function hueToRgb(o,et,tt){return tt<0&&(tt+=1),tt>1&&(tt-=1),tt<1/6?o+(et-o)*6*tt:tt<1/2?et:tt<2/3?o+(et-o)*(2/3-tt)*6:o}function hslaToRgba({hue:o,saturation:et,lightness:tt,alpha:nt}){o/=360,et/=100,tt/=100;let rt=0,ot=0,it=0;if(!et)rt=ot=it=tt;else{const st=tt<.5?tt*(1+et):tt+et-tt*et,at=2*tt-st;rt=hueToRgb(at,st,o+1/3),ot=hueToRgb(at,st,o),it=hueToRgb(at,st,o-1/3)}return{red:Math.round(rt*255),green:Math.round(ot*255),blue:Math.round(it*255),alpha:nt}}const mixLinearColor=(o,et,tt)=>{const nt=o*o,rt=et*et;return Math.sqrt(Math.max(0,tt*(rt-nt)+nt))},colorTypes=[hex,rgba,hsla],getColorType=o=>colorTypes.find(et=>et.test(o)),mixColor=(o,et)=>{let tt=getColorType(o),nt=getColorType(et),rt=tt.parse(o),ot=nt.parse(et);tt===hsla&&(rt=hslaToRgba(rt),tt=rgba),nt===hsla&&(ot=hslaToRgba(ot),nt=rgba);const it=Object.assign({},rt);return st=>{for(const at in it)at!=="alpha"&&(it[at]=mixLinearColor(rt[at],ot[at],st));return it.alpha=mix(rt.alpha,ot.alpha,st),tt.transform(it)}},isNum=o=>typeof o=="number",combineFunctions=(o,et)=>tt=>et(o(tt)),pipe$1=(...o)=>o.reduce(combineFunctions);function getMixer(o,et){return isNum(o)?tt=>mix(o,et,tt):color$1.test(o)?mixColor(o,et):mixComplex(o,et)}const mixArray=(o,et)=>{const tt=[...o],nt=tt.length,rt=o.map((ot,it)=>getMixer(ot,et[it]));return ot=>{for(let it=0;it{const tt=Object.assign(Object.assign({},o),et),nt={};for(const rt in tt)o[rt]!==void 0&&et[rt]!==void 0&&(nt[rt]=getMixer(o[rt],et[rt]));return rt=>{for(const ot in nt)tt[ot]=nt[ot](rt);return tt}};function analyse(o){const et=complex.parse(o),tt=et.length;let nt=0,rt=0,ot=0;for(let it=0;it{const tt=complex.createTransformer(et),nt=analyse(o),rt=analyse(et);return nt.numHSL===rt.numHSL&&nt.numRGB===rt.numRGB&&nt.numNumbers>=rt.numNumbers?pipe$1(mixArray(nt.parsed,rt.parsed),tt):it=>`${it>0?et:o}`},mixNumber=(o,et)=>tt=>mix(o,et,tt);function detectMixerFactory(o){if(typeof o=="number")return mixNumber;if(typeof o=="string")return color$1.test(o)?mixColor:mixComplex;if(Array.isArray(o))return mixArray;if(typeof o=="object")return mixObject}function createMixers(o,et,tt){const nt=[],rt=tt||detectMixerFactory(o[0]),ot=o.length-1;for(let it=0;ittt(progress(o,et,nt))}function slowInterpolate(o,et){const tt=o.length,nt=tt-1;return rt=>{let ot=0,it=!1;if(rt<=o[0]?it=!0:rt>=o[nt]&&(ot=nt-1,it=!0),!it){let at=1;for(;atrt||at===nt);at++);ot=at-1}const st=progress(o[ot],o[ot+1],rt);return et[ot](st)}}function interpolate(o,et,{clamp:tt=!0,ease:nt,mixer:rt}={}){const ot=o.length;invariant$1(ot===et.length),invariant$1(!nt||!Array.isArray(nt)||nt.length===ot-1),o[0]>o[ot-1]&&(o=[].concat(o),et=[].concat(et),o.reverse(),et.reverse());const it=createMixers(et,nt,rt),st=ot===2?fastInterpolate(o,it):slowInterpolate(o,it);return tt?at=>st(clamp$1(o[0],o[ot-1],at)):st}const reverseEasing=o=>et=>1-o(1-et),mirrorEasing=o=>et=>et<=.5?o(2*et)/2:(2-o(2*(1-et)))/2,createExpoIn=o=>et=>Math.pow(et,o),createBackIn=o=>et=>et*et*((o+1)*et-o),createAnticipate=o=>{const et=createBackIn(o);return tt=>(tt*=2)<1?.5*et(tt):.5*(2-Math.pow(2,-10*(tt-1)))},DEFAULT_OVERSHOOT_STRENGTH=1.525,BOUNCE_FIRST_THRESHOLD=4/11,BOUNCE_SECOND_THRESHOLD=8/11,BOUNCE_THIRD_THRESHOLD=9/10,linear=o=>o,easeIn=createExpoIn(2),easeOut=reverseEasing(easeIn),easeInOut=mirrorEasing(easeIn),circIn=o=>1-Math.sin(Math.acos(o)),circOut=reverseEasing(circIn),circInOut=mirrorEasing(circOut),backIn=createBackIn(DEFAULT_OVERSHOOT_STRENGTH),backOut=reverseEasing(backIn),backInOut=mirrorEasing(backIn),anticipate=createAnticipate(DEFAULT_OVERSHOOT_STRENGTH),ca=4356/361,cb=35442/1805,cc=16061/1805,bounceOut=o=>{if(o===1||o===0)return o;const et=o*o;return oo<.5?.5*(1-bounceOut(1-o*2)):.5*bounceOut(o*2-1)+.5;function defaultEasing(o,et){return o.map(()=>et||easeInOut).splice(0,o.length-1)}function defaultOffset(o){const et=o.length;return o.map((tt,nt)=>nt!==0?nt/(et-1):0)}function convertOffsetToTimes(o,et){return o.map(tt=>tt*et)}function keyframes$1({from:o=0,to:et=1,ease:tt,offset:nt,duration:rt=300}){const ot={done:!1,value:o},it=Array.isArray(et)?et:[o,et],st=convertOffsetToTimes(nt&&nt.length===it.length?nt:defaultOffset(it),rt);function at(){return interpolate(st,it,{ease:Array.isArray(tt)?tt:defaultEasing(it,tt)})}let ct=at();return{next:lt=>(ot.value=ct(lt),ot.done=lt>=rt,ot),flipTarget:()=>{it.reverse(),ct=at()}}}function decay({velocity:o=0,from:et=0,power:tt=.8,timeConstant:nt=350,restDelta:rt=.5,modifyTarget:ot}){const it={done:!1,value:et};let st=tt*o;const at=et+st,ct=ot===void 0?at:ot(at);return ct!==at&&(st=ct-et),{next:lt=>{const dt=-st*Math.exp(-lt/nt);return it.done=!(dt>rt||dt<-rt),it.value=it.done?ct:ct+dt,it},flipTarget:()=>{}}}const types$3={keyframes:keyframes$1,spring,decay};function detectAnimationFromOptions(o){if(Array.isArray(o.to))return keyframes$1;if(types$3[o.type])return types$3[o.type];const et=new Set(Object.keys(o));return et.has("ease")||et.has("duration")&&!et.has("dampingRatio")?keyframes$1:et.has("dampingRatio")||et.has("stiffness")||et.has("mass")||et.has("damping")||et.has("restSpeed")||et.has("restDelta")?spring:keyframes$1}const defaultTimestep=1/60*1e3,getCurrentTime=typeof performance<"u"?()=>performance.now():()=>Date.now(),onNextFrame=typeof window<"u"?o=>window.requestAnimationFrame(o):o=>setTimeout(()=>o(getCurrentTime()),defaultTimestep);function createRenderStep(o){let et=[],tt=[],nt=0,rt=!1,ot=!1;const it=new WeakSet,st={schedule:(at,ct=!1,lt=!1)=>{const dt=lt&&rt,ht=dt?et:tt;return ct&&it.add(at),ht.indexOf(at)===-1&&(ht.push(at),dt&&rt&&(nt=et.length)),at},cancel:at=>{const ct=tt.indexOf(at);ct!==-1&&tt.splice(ct,1),it.delete(at)},process:at=>{if(rt){ot=!0;return}if(rt=!0,[et,tt]=[tt,et],tt.length=0,nt=et.length,nt)for(let ct=0;ct(o[et]=createRenderStep(()=>runNextFrame=!0),o),{}),sync=stepsOrder.reduce((o,et)=>{const tt=steps[et];return o[et]=(nt,rt=!1,ot=!1)=>(runNextFrame||startLoop(),tt.schedule(nt,rt,ot)),o},{}),cancelSync=stepsOrder.reduce((o,et)=>(o[et]=steps[et].cancel,o),{}),flushSync=stepsOrder.reduce((o,et)=>(o[et]=()=>steps[et].process(frame),o),{}),processStep=o=>steps[o].process(frame),processFrame=o=>{runNextFrame=!1,frame.delta=useDefaultElapsed?defaultTimestep:Math.max(Math.min(o-frame.timestamp,maxElapsed),1),frame.timestamp=o,isProcessing=!0,stepsOrder.forEach(processStep),isProcessing=!1,runNextFrame&&(useDefaultElapsed=!1,onNextFrame(processFrame))},startLoop=()=>{runNextFrame=!0,useDefaultElapsed=!0,isProcessing||onNextFrame(processFrame)},getFrameData=()=>frame;function loopElapsed(o,et,tt=0){return o-et-tt}function reverseElapsed(o,et,tt=0,nt=!0){return nt?loopElapsed(et+-o,et,tt):et-(o-et)+tt}function hasRepeatDelayElapsed(o,et,tt,nt){return nt?o>=et+tt:o<=-tt}const framesync=o=>{const et=({delta:tt})=>o(tt);return{start:()=>sync.update(et,!0),stop:()=>cancelSync.update(et)}};function animate$1(o){var et,tt,{from:nt,autoplay:rt=!0,driver:ot=framesync,elapsed:it=0,repeat:st=0,repeatType:at="loop",repeatDelay:ct=0,onPlay:lt,onStop:dt,onComplete:ht,onRepeat:pt,onUpdate:mt}=o,ft=__rest(o,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let{to:yt}=ft,gt,xt=0,vt=ft.duration,bt,Et=!1,wt=!0,kt;const It=detectAnimationFromOptions(ft);!((tt=(et=It).needsInterpolation)===null||tt===void 0)&&tt.call(et,nt,yt)&&(kt=interpolate([0,100],[nt,yt],{clamp:!1}),nt=0,yt=100);const Rt=It(Object.assign(Object.assign({},ft),{from:nt,to:yt}));function Pt(){xt++,at==="reverse"?(wt=xt%2===0,it=reverseElapsed(it,vt,ct,wt)):(it=loopElapsed(it,vt,ct),at==="mirror"&&Rt.flipTarget()),Et=!1,pt&&pt()}function jt(){gt.stop(),ht&&ht()}function Ot(zt){if(wt||(zt=-zt),it+=zt,!Et){const Ft=Rt.next(Math.max(0,it));bt=Ft.value,kt&&(bt=kt(bt)),Et=wt?Ft.done:it<=0}mt==null||mt(bt),Et&&(xt===0&&(vt??(vt=it)),xt{dt==null||dt(),gt.stop()}}}function velocityPerSecond(o,et){return et?o*(1e3/et):0}function inertia({from:o=0,velocity:et=0,min:tt,max:nt,power:rt=.8,timeConstant:ot=750,bounceStiffness:it=500,bounceDamping:st=10,restDelta:at=1,modifyTarget:ct,driver:lt,onUpdate:dt,onComplete:ht,onStop:pt}){let mt;function ft(vt){return tt!==void 0&&vtnt}function yt(vt){return tt===void 0?nt:nt===void 0||Math.abs(tt-vt){var Et;dt==null||dt(bt),(Et=vt.onUpdate)===null||Et===void 0||Et.call(vt,bt)},onComplete:ht,onStop:pt}))}function xt(vt){gt(Object.assign({type:"spring",stiffness:it,damping:st,restDelta:at},vt))}if(ft(o))xt({from:o,velocity:et,to:yt(o)});else{let vt=rt*et+o;typeof ct<"u"&&(vt=ct(vt));const bt=yt(vt),Et=bt===tt?-1:1;let wt,kt;const It=Rt=>{wt=kt,kt=Rt,et=velocityPerSecond(Rt-wt,getFrameData().delta),(Et===1&&Rt>bt||Et===-1&&Rtmt==null?void 0:mt.stop()}}const isPoint=o=>o.hasOwnProperty("x")&&o.hasOwnProperty("y"),isPoint3D=o=>isPoint(o)&&o.hasOwnProperty("z"),distance1D=(o,et)=>Math.abs(o-et);function distance(o,et){if(isNum(o)&&isNum(et))return distance1D(o,et);if(isPoint(o)&&isPoint(et)){const tt=distance1D(o.x,et.x),nt=distance1D(o.y,et.y),rt=isPoint3D(o)&&isPoint3D(et)?distance1D(o.z,et.z):0;return Math.sqrt(Math.pow(tt,2)+Math.pow(nt,2)+Math.pow(rt,2))}}const a=(o,et)=>1-3*et+3*o,b$3=(o,et)=>3*et-6*o,c$2=o=>3*o,calcBezier=(o,et,tt)=>((a(et,tt)*o+b$3(et,tt))*o+c$2(et))*o,getSlope=(o,et,tt)=>3*a(et,tt)*o*o+2*b$3(et,tt)*o+c$2(et),subdivisionPrecision=1e-7,subdivisionMaxIterations=10;function binarySubdivide(o,et,tt,nt,rt){let ot,it,st=0;do it=et+(tt-et)/2,ot=calcBezier(it,nt,rt)-o,ot>0?tt=it:et=it;while(Math.abs(ot)>subdivisionPrecision&&++st=newtonMinSlope?newtonRaphsonIterate(it,dt,o,tt):ht===0?dt:binarySubdivide(it,st,st+kSampleStepSize,o,tt)}return it=>it===0||it===1?it:calcBezier(ot(it),et,nt)}function useTapGesture(o){var et=o.onTap,tt=o.onTapStart,nt=o.onTapCancel,rt=o.whileTap,ot=o.visualElement,it=et||tt||nt||rt,st=reactExports.useRef(!1),at=reactExports.useRef(null),ct={passive:!(tt||et||nt||mt)};function lt(){var ft;(ft=at.current)===null||ft===void 0||ft.call(at),at.current=null}function dt(){var ft;return lt(),st.current=!1,(ft=ot.animationState)===null||ft===void 0||ft.setActive(AnimationType.Tap,!1),!isDragActive()}function ht(ft,yt){dt()&&(isNodeOrChild(ot.getInstance(),ft.target)?et==null||et(ft,yt):nt==null||nt(ft,yt))}function pt(ft,yt){dt()&&(nt==null||nt(ft,yt))}function mt(ft,yt){var gt;lt(),!st.current&&(st.current=!0,at.current=pipe$1(addPointerEvent(window,"pointerup",ht,ct),addPointerEvent(window,"pointercancel",pt,ct)),(gt=ot.animationState)===null||gt===void 0||gt.setActive(AnimationType.Tap,!0),tt==null||tt(ft,yt))}usePointerEvent(ot,"pointerdown",it?mt:void 0,ct),useUnmountEffect(lt)}var warned=new Set;function warnOnce$1(o,et,tt){warned.has(et)||(console.warn(et),warned.add(et))}var observerCallbacks=new WeakMap,observers$1=new WeakMap,fireObserverCallback=function(o){var et;(et=observerCallbacks.get(o.target))===null||et===void 0||et(o)},fireAllObserverCallbacks=function(o){o.forEach(fireObserverCallback)};function initIntersectionObserver(o){var et=o.root,tt=__rest(o,["root"]),nt=et||document;observers$1.has(nt)||observers$1.set(nt,{});var rt=observers$1.get(nt),ot=JSON.stringify(tt);return rt[ot]||(rt[ot]=new IntersectionObserver(fireAllObserverCallbacks,__assign({root:et},tt))),rt[ot]}function observeIntersection(o,et,tt){var nt=initIntersectionObserver(et);return observerCallbacks.set(o,tt),nt.observe(o),function(){observerCallbacks.delete(o),nt.unobserve(o)}}function useViewport(o){var et=o.visualElement,tt=o.whileInView,nt=o.onViewportEnter,rt=o.onViewportLeave,ot=o.viewport,it=ot===void 0?{}:ot,st=reactExports.useRef({hasEnteredView:!1,isInView:!1}),at=!!(tt||nt||rt);it.once&&st.current.hasEnteredView&&(at=!1);var ct=typeof IntersectionObserver>"u"?useMissingIntersectionObserver:useIntersectionObserver;ct(at,st.current,et,it)}var thresholdNames={some:0,all:1};function useIntersectionObserver(o,et,tt,nt){var rt=nt.root,ot=nt.margin,it=nt.amount,st=it===void 0?"some":it,at=nt.once;reactExports.useEffect(function(){if(o){var ct={root:rt==null?void 0:rt.current,rootMargin:ot,threshold:typeof st=="number"?st:thresholdNames[st]},lt=function(dt){var ht,pt=dt.isIntersecting;if(et.isInView!==pt&&(et.isInView=pt,!(at&&!pt&&et.hasEnteredView))){pt&&(et.hasEnteredView=!0),(ht=tt.animationState)===null||ht===void 0||ht.setActive(AnimationType.InView,pt);var mt=tt.getProps(),ft=pt?mt.onViewportEnter:mt.onViewportLeave;ft==null||ft(dt)}};return observeIntersection(tt.getInstance(),ct,lt)}},[o,rt,ot,st])}function useMissingIntersectionObserver(o,et,tt,nt){var rt=nt.fallback,ot=rt===void 0?!0:rt;reactExports.useEffect(function(){!o||!ot||(env$1!=="production"&&warnOnce$1(!1,"IntersectionObserver not available on this device. whileInView animations will trigger on mount."),requestAnimationFrame(function(){var it;et.hasEnteredView=!0;var st=tt.getProps().onViewportEnter;st==null||st(null),(it=tt.animationState)===null||it===void 0||it.setActive(AnimationType.InView,!0)}))},[o])}var makeRenderlessComponent=function(o){return function(et){return o(et),null}},gestureAnimations={inView:makeRenderlessComponent(useViewport),tap:makeRenderlessComponent(useTapGesture),focus:makeRenderlessComponent(useFocusGesture),hover:makeRenderlessComponent(useHoverGesture)},counter=0,incrementId=function(){return counter++},useId$1=function(){return useConstant(incrementId)};function usePresence$1(){var o=reactExports.useContext(PresenceContext);if(o===null)return[!0,null];var et=o.isPresent,tt=o.onExitComplete,nt=o.register,rt=useId$1();reactExports.useEffect(function(){return nt(rt)},[]);var ot=function(){return tt==null?void 0:tt(rt)};return!et&&tt?[!1,ot]:[!0]}function shallowCompare(o,et){if(!Array.isArray(et))return!1;var tt=et.length;if(tt!==o.length)return!1;for(var nt=0;nt-1&&o.splice(tt,1)}var SubscriptionManager$1=function(){function o(){this.subscriptions=[]}return o.prototype.add=function(et){var tt=this;return addUniqueItem(this.subscriptions,et),function(){return removeItem(tt.subscriptions,et)}},o.prototype.notify=function(et,tt,nt){var rt=this.subscriptions.length;if(rt)if(rt===1)this.subscriptions[0](et,tt,nt);else for(var ot=0;otxt&&jt,Yt=Array.isArray(Pt)?Pt:[Pt],Ht=Yt.reduce(ot,{});Ot===!1&&(Ht={});var Ut=Rt.prevResolvedValues,qt=Ut===void 0?{}:Ut,Lt=__assign(__assign({},qt),Ht),Zt=function(nn){Ft=!0,yt.delete(nn),Rt.needsAnimating[nn]=!0};for(var Qt in Lt){var Nt=Ht[Qt],Gt=qt[Qt];gt.hasOwnProperty(Qt)||(Nt!==Gt?isKeyframesTarget(Nt)&&isKeyframesTarget(Gt)?!shallowCompare(Nt,Gt)||zt?Zt(Qt):Rt.protectedKeys[Qt]=!0:Nt!==void 0?Zt(Qt):yt.add(Qt):Nt!==void 0&&yt.has(Qt)?Zt(Qt):Rt.protectedKeys[Qt]=!0)}Rt.prevProp=Pt,Rt.prevResolvedValues=Ht,Rt.isActive&&(gt=__assign(__assign({},gt),Ht)),rt&&o.blockInitialAnimation&&(Ft=!1),Ft&&!Bt&&ft.push.apply(ft,__spreadArray([],__read(Yt.map(function(nn){return{animation:nn,options:__assign({type:It},lt)}})),!1))},bt=0;bt=3;if(!(!pt&&!mt)){var ft=ht.point,yt=getFrameData().timestamp;rt.history.push(__assign(__assign({},ft),{timestamp:yt}));var gt=rt.handlers,xt=gt.onStart,vt=gt.onMove;pt||(xt&&xt(rt.lastMoveEvent,ht),rt.startEvent=rt.lastMoveEvent),vt&&vt(rt.lastMoveEvent,ht)}}},this.handlePointerMove=function(ht,pt){if(rt.lastMoveEvent=ht,rt.lastMoveEventInfo=transformPoint(pt,rt.transformPagePoint),isMouseEvent(ht)&&ht.buttons===0){rt.handlePointerUp(ht,pt);return}sync.update(rt.updatePoint,!0)},this.handlePointerUp=function(ht,pt){rt.end();var mt=rt.handlers,ft=mt.onEnd,yt=mt.onSessionEnd,gt=getPanInfo(transformPoint(pt,rt.transformPagePoint),rt.history);rt.startEvent&&ft&&ft(ht,gt),yt&&yt(ht,gt)},!(isTouchEvent(et)&&et.touches.length>1)){this.handlers=tt,this.transformPagePoint=it;var st=extractEventInfo(et),at=transformPoint(st,this.transformPagePoint),ct=at.point,lt=getFrameData().timestamp;this.history=[__assign(__assign({},ct),{timestamp:lt})];var dt=tt.onSessionStart;dt&&dt(et,getPanInfo(at,this.history)),this.removeListeners=pipe$1(addPointerEvent(window,"pointermove",this.handlePointerMove),addPointerEvent(window,"pointerup",this.handlePointerUp),addPointerEvent(window,"pointercancel",this.handlePointerUp))}}return o.prototype.updateHandlers=function(et){this.handlers=et},o.prototype.end=function(){this.removeListeners&&this.removeListeners(),cancelSync.update(this.updatePoint)},o}();function transformPoint(o,et){return et?{point:et(o.point)}:o}function subtractPoint(o,et){return{x:o.x-et.x,y:o.y-et.y}}function getPanInfo(o,et){var tt=o.point;return{point:tt,delta:subtractPoint(tt,lastDevicePoint(et)),offset:subtractPoint(tt,startDevicePoint(et)),velocity:getVelocity(et,.1)}}function startDevicePoint(o){return o[0]}function lastDevicePoint(o){return o[o.length-1]}function getVelocity(o,et){if(o.length<2)return{x:0,y:0};for(var tt=o.length-1,nt=null,rt=lastDevicePoint(o);tt>=0&&(nt=o[tt],!(rt.timestamp-nt.timestamp>secondsToMilliseconds(et)));)tt--;if(!nt)return{x:0,y:0};var ot=(rt.timestamp-nt.timestamp)/1e3;if(ot===0)return{x:0,y:0};var it={x:(rt.x-nt.x)/ot,y:(rt.y-nt.y)/ot};return it.x===1/0&&(it.x=0),it.y===1/0&&(it.y=0),it}function calcLength(o){return o.max-o.min}function isNear(o,et,tt){return et===void 0&&(et=0),tt===void 0&&(tt=.01),distance(o,et)rt&&(o=tt?mix(rt,o,tt.max):Math.min(o,rt)),o}function calcRelativeAxisConstraints(o,et,tt){return{min:et!==void 0?o.min+et:void 0,max:tt!==void 0?o.max+tt-(o.max-o.min):void 0}}function calcRelativeConstraints(o,et){var tt=et.top,nt=et.left,rt=et.bottom,ot=et.right;return{x:calcRelativeAxisConstraints(o.x,nt,ot),y:calcRelativeAxisConstraints(o.y,tt,rt)}}function calcViewportAxisConstraints(o,et){var tt,nt=et.min-o.min,rt=et.max-o.max;return et.max-et.minnt?tt=progress(et.min,et.max-nt,o.min):nt>rt&&(tt=progress(o.min,o.max-rt,et.min)),clamp$1(0,1,tt)}function rebaseAxisConstraints(o,et){var tt={};return et.min!==void 0&&(tt.min=et.min-o.min),et.max!==void 0&&(tt.max=et.max-o.min),tt}var defaultElastic=.35;function resolveDragElastic(o){return o===void 0&&(o=defaultElastic),o===!1?o=0:o===!0&&(o=defaultElastic),{x:resolveAxisElastic(o,"left","right"),y:resolveAxisElastic(o,"top","bottom")}}function resolveAxisElastic(o,et,tt){return{min:resolvePointElastic(o,et),max:resolvePointElastic(o,tt)}}function resolvePointElastic(o,et){var tt;return typeof o=="number"?o:(tt=o[et])!==null&&tt!==void 0?tt:0}var createAxisDelta=function(){return{translate:0,scale:1,origin:0,originPoint:0}},createDelta=function(){return{x:createAxisDelta(),y:createAxisDelta()}},createAxis=function(){return{min:0,max:0}},createBox=function(){return{x:createAxis(),y:createAxis()}};function eachAxis(o){return[o("x"),o("y")]}function convertBoundingBoxToBox(o){var et=o.top,tt=o.left,nt=o.right,rt=o.bottom;return{x:{min:tt,max:nt},y:{min:et,max:rt}}}function convertBoxToBoundingBox(o){var et=o.x,tt=o.y;return{top:tt.min,right:et.max,bottom:tt.max,left:et.min}}function transformBoxPoints(o,et){if(!et)return o;var tt=et({x:o.left,y:o.top}),nt=et({x:o.right,y:o.bottom});return{top:tt.y,left:tt.x,bottom:nt.y,right:nt.x}}function isIdentityScale(o){return o===void 0||o===1}function hasScale(o){var et=o.scale,tt=o.scaleX,nt=o.scaleY;return!isIdentityScale(et)||!isIdentityScale(tt)||!isIdentityScale(nt)}function hasTransform(o){return hasScale(o)||hasTranslate(o.x)||hasTranslate(o.y)||o.z||o.rotate||o.rotateX||o.rotateY}function hasTranslate(o){return o&&o!=="0%"}function scalePoint(o,et,tt){var nt=o-tt,rt=et*nt;return tt+rt}function applyPointDelta(o,et,tt,nt,rt){return rt!==void 0&&(o=scalePoint(o,rt,nt)),scalePoint(o,tt,nt)+et}function applyAxisDelta(o,et,tt,nt,rt){et===void 0&&(et=0),tt===void 0&&(tt=1),o.min=applyPointDelta(o.min,et,tt,nt,rt),o.max=applyPointDelta(o.max,et,tt,nt,rt)}function applyBoxDelta(o,et){var tt=et.x,nt=et.y;applyAxisDelta(o.x,tt.translate,tt.scale,tt.originPoint),applyAxisDelta(o.y,nt.translate,nt.scale,nt.originPoint)}function applyTreeDeltas(o,et,tt,nt){var rt,ot;nt===void 0&&(nt=!1);var it=tt.length;if(it){et.x=et.y=1;for(var st,at,ct=0;ctet?tt="y":Math.abs(o.x)>et&&(tt="x"),tt}function useDrag(o){var et=o.dragControls,tt=o.visualElement,nt=useConstant(function(){return new VisualElementDragControls(tt)});reactExports.useEffect(function(){return et&&et.subscribe(nt)},[nt,et]),reactExports.useEffect(function(){return nt.addListeners()},[nt])}function usePanGesture(o){var et=o.onPan,tt=o.onPanStart,nt=o.onPanEnd,rt=o.onPanSessionStart,ot=o.visualElement,it=et||tt||nt||rt,st=reactExports.useRef(null),at=reactExports.useContext(MotionConfigContext).transformPagePoint,ct={onSessionStart:rt,onStart:tt,onMove:et,onEnd:function(dt,ht){st.current=null,nt&&nt(dt,ht)}};reactExports.useEffect(function(){st.current!==null&&st.current.updateHandlers(ct)});function lt(dt){st.current=new PanSession(dt,ct,{transformPagePoint:at})}usePointerEvent(ot,"pointerdown",it&<),useUnmountEffect(function(){return st.current&&st.current.end()})}var drag={pan:makeRenderlessComponent(usePanGesture),drag:makeRenderlessComponent(useDrag)},names$1=["LayoutMeasure","BeforeLayoutMeasure","LayoutUpdate","ViewportBoxUpdate","Update","Render","AnimationComplete","LayoutAnimationComplete","AnimationStart","LayoutAnimationStart","SetAxisTarget","Unmount"];function createLifecycles(){var o=names$1.map(function(){return new SubscriptionManager$1}),et={},tt={clearAllListeners:function(){return o.forEach(function(nt){return nt.clear()})},updatePropListeners:function(nt){names$1.forEach(function(rt){var ot,it="on"+rt,st=nt[it];(ot=et[rt])===null||ot===void 0||ot.call(et),st&&(et[rt]=tt[it](st))})}};return o.forEach(function(nt,rt){tt["on"+names$1[rt]]=function(ot){return nt.add(ot)},tt["notify"+names$1[rt]]=function(){for(var ot=[],it=0;it=0?window.pageYOffset:null,ct=convertChangedValueTypes(et,o,st);return ot.length&&ot.forEach(function(lt){var dt=__read(lt,2),ht=dt[0],pt=dt[1];o.getValue(ht).set(pt)}),o.syncRender(),at!==null&&window.scrollTo({top:at}),{target:ct,transitionEnd:nt}}else return{target:et,transitionEnd:nt}};function unitConversion(o,et,tt,nt){return hasPositionalKey(et)?checkAndConvertChangedValueTypes(o,et,tt,nt):{target:et,transitionEnd:nt}}var parseDomVariant=function(o,et,tt,nt){var rt=resolveCSSVariables(o,et,nt);return et=rt.target,nt=rt.transitionEnd,unitConversion(o,et,tt,nt)};function getComputedStyle$1(o){return window.getComputedStyle(o)}var htmlConfig={treeType:"dom",readValueFromInstance:function(o,et){if(isTransformProp(et)){var tt=getDefaultValueType(et);return tt&&tt.default||0}else{var nt=getComputedStyle$1(o);return(isCSSVariable$1(et)?nt.getPropertyValue(et):nt[et])||0}},sortNodePosition:function(o,et){return o.compareDocumentPosition(et)&2?1:-1},getBaseTarget:function(o,et){var tt;return(tt=o.style)===null||tt===void 0?void 0:tt[et]},measureViewportBox:function(o,et){var tt=et.transformPagePoint;return measureViewportBox(o,tt)},resetTransform:function(o,et,tt){var nt=tt.transformTemplate;et.style.transform=nt?nt({},""):"none",o.scheduleRender()},restoreTransform:function(o,et){o.style.transform=et.style.transform},removeValueFromRenderState:function(o,et){var tt=et.vars,nt=et.style;delete tt[o],delete nt[o]},makeTargetAnimatable:function(o,et,tt,nt){var rt=tt.transformValues;nt===void 0&&(nt=!0);var ot=et.transition,it=et.transitionEnd,st=__rest(et,["transition","transitionEnd"]),at=getOrigin(st,ot||{},o);if(rt&&(it&&(it=rt(it)),st&&(st=rt(st)),at&&(at=rt(at))),nt){checkTargetForNewValues(o,st,at);var ct=parseDomVariant(o,st,at,it);it=ct.transitionEnd,st=ct.target}return __assign({transition:ot,transitionEnd:it},st)},scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,build:function(o,et,tt,nt,rt){o.isVisible!==void 0&&(et.style.visibility=o.isVisible?"visible":"hidden"),buildHTMLStyles(et,tt,nt,rt.transformTemplate)},render:renderHTML},htmlVisualElement=visualElement(htmlConfig),svgVisualElement=visualElement(__assign(__assign({},htmlConfig),{getBaseTarget:function(o,et){return o[et]},readValueFromInstance:function(o,et){var tt;return isTransformProp(et)?((tt=getDefaultValueType(et))===null||tt===void 0?void 0:tt.default)||0:(et=camelCaseAttributes.has(et)?et:camelToDash(et),o.getAttribute(et))},scrapeMotionValuesFromProps,build:function(o,et,tt,nt,rt){buildSVGAttrs(et,tt,nt,rt.transformTemplate)},render:renderSVG})),createDomVisualElement=function(o,et){return isSVGComponent(o)?svgVisualElement(et,{enableHardwareAcceleration:!1}):htmlVisualElement(et,{enableHardwareAcceleration:!0})};function pixelsToPercent(o,et){return et.max===et.min?0:o/(et.max-et.min)*100}var correctBorderRadius={correct:function(o,et){if(!et.target)return o;if(typeof o=="string")if(px.test(o))o=parseFloat(o);else return o;var tt=pixelsToPercent(o,et.target.x),nt=pixelsToPercent(o,et.target.y);return"".concat(tt,"% ").concat(nt,"%")}},varToken="_$css",correctBoxShadow={correct:function(o,et){var tt=et.treeScale,nt=et.projectionDelta,rt=o,ot=o.includes("var("),it=[];ot&&(o=o.replace(cssVariableRegex,function(ft){return it.push(ft),varToken}));var st=complex.parse(o);if(st.length>5)return rt;var at=complex.createTransformer(o),ct=typeof st[0]!="number"?1:0,lt=nt.x.scale*tt.x,dt=nt.y.scale*tt.y;st[0+ct]/=lt,st[1+ct]/=dt;var ht=mix(lt,dt,.5);typeof st[2+ct]=="number"&&(st[2+ct]/=ht),typeof st[3+ct]=="number"&&(st[3+ct]/=ht);var pt=at(st);if(ot){var mt=0;pt=pt.replace(varToken,function(){var ft=it[mt];return mt++,ft})}return pt}},MeasureLayoutWithContext=function(o){__extends(et,o);function et(){return o!==null&&o.apply(this,arguments)||this}return et.prototype.componentDidMount=function(){var tt=this,nt=this.props,rt=nt.visualElement,ot=nt.layoutGroup,it=nt.switchLayoutGroup,st=nt.layoutId,at=rt.projection;addScaleCorrector(defaultScaleCorrectors),at&&(ot!=null&&ot.group&&ot.group.add(at),it!=null&&it.register&&st&&it.register(at),at.root.didUpdate(),at.addEventListener("animationComplete",function(){tt.safeToRemove()}),at.setOptions(__assign(__assign({},at.options),{onExitComplete:function(){return tt.safeToRemove()}}))),globalProjectionState.hasEverUpdated=!0},et.prototype.getSnapshotBeforeUpdate=function(tt){var nt=this,rt=this.props,ot=rt.layoutDependency,it=rt.visualElement,st=rt.drag,at=rt.isPresent,ct=it.projection;return ct&&(ct.isPresent=at,st||tt.layoutDependency!==ot||ot===void 0?ct.willUpdate():this.safeToRemove(),tt.isPresent!==at&&(at?ct.promote():ct.relegate()||sync.postRender(function(){var lt;!((lt=ct.getStack())===null||lt===void 0)&<.members.length||nt.safeToRemove()}))),null},et.prototype.componentDidUpdate=function(){var tt=this.props.visualElement.projection;tt&&(tt.root.didUpdate(),!tt.currentAnimation&&tt.isLead()&&this.safeToRemove())},et.prototype.componentWillUnmount=function(){var tt=this.props,nt=tt.visualElement,rt=tt.layoutGroup,ot=tt.switchLayoutGroup,it=nt.projection;it&&(it.scheduleCheckAfterUnmount(),rt!=null&&rt.group&&rt.group.remove(it),ot!=null&&ot.deregister&&ot.deregister(it))},et.prototype.safeToRemove=function(){var tt=this.props.safeToRemove;tt==null||tt()},et.prototype.render=function(){return null},et}(React.Component);function MeasureLayout(o){var et=__read(usePresence$1(),2),tt=et[0],nt=et[1],rt=reactExports.useContext(LayoutGroupContext);return React.createElement(MeasureLayoutWithContext,__assign({},o,{layoutGroup:rt,switchLayoutGroup:reactExports.useContext(SwitchLayoutGroupContext),isPresent:tt,safeToRemove:nt}))}var defaultScaleCorrectors={borderRadius:__assign(__assign({},correctBorderRadius),{applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]}),borderTopLeftRadius:correctBorderRadius,borderTopRightRadius:correctBorderRadius,borderBottomLeftRadius:correctBorderRadius,borderBottomRightRadius:correctBorderRadius,boxShadow:correctBoxShadow},layoutFeatures={measureLayout:MeasureLayout};function animate(o,et,tt){tt===void 0&&(tt={});var nt=isMotionValue(o)?o:motionValue(o);return startAnimation("",nt,et,tt),{stop:function(){return nt.stop()},isAnimating:function(){return nt.isAnimating()}}}var borders=["TopLeft","TopRight","BottomLeft","BottomRight"],numBorders=borders.length,asNumber=function(o){return typeof o=="string"?parseFloat(o):o},isPx=function(o){return typeof o=="number"||px.test(o)};function mixValues(o,et,tt,nt,rt,ot){var it,st,at,ct;rt?(o.opacity=mix(0,(it=tt.opacity)!==null&&it!==void 0?it:1,easeCrossfadeIn(nt)),o.opacityExit=mix((st=et.opacity)!==null&&st!==void 0?st:1,0,easeCrossfadeOut(nt))):ot&&(o.opacity=mix((at=et.opacity)!==null&&at!==void 0?at:1,(ct=tt.opacity)!==null&&ct!==void 0?ct:1,nt));for(var lt=0;ltet?1:tt(progress(o,et,nt))}}function copyAxisInto(o,et){o.min=et.min,o.max=et.max}function copyBoxInto(o,et){copyAxisInto(o.x,et.x),copyAxisInto(o.y,et.y)}function removePointDelta(o,et,tt,nt,rt){return o-=et,o=scalePoint(o,1/tt,nt),rt!==void 0&&(o=scalePoint(o,1/rt,nt)),o}function removeAxisDelta(o,et,tt,nt,rt,ot,it){if(et===void 0&&(et=0),tt===void 0&&(tt=1),nt===void 0&&(nt=.5),ot===void 0&&(ot=o),it===void 0&&(it=o),percent.test(et)){et=parseFloat(et);var st=mix(it.min,it.max,et/100);et=st-it.min}if(typeof et=="number"){var at=mix(ot.min,ot.max,nt);o===ot&&(at-=et),o.min=removePointDelta(o.min,et,tt,at,rt),o.max=removePointDelta(o.max,et,tt,at,rt)}}function removeAxisTransforms(o,et,tt,nt,rt){var ot=__read(tt,3),it=ot[0],st=ot[1],at=ot[2];removeAxisDelta(o,et[it],et[st],et[at],et.scale,nt,rt)}var xKeys=["x","scaleX","originX"],yKeys=["y","scaleY","originY"];function removeBoxTransforms(o,et,tt,nt){removeAxisTransforms(o.x,et,xKeys,tt==null?void 0:tt.x,nt==null?void 0:nt.x),removeAxisTransforms(o.y,et,yKeys,tt==null?void 0:tt.y,nt==null?void 0:nt.y)}function isAxisDeltaZero(o){return o.translate===0&&o.scale===1}function isDeltaZero(o){return isAxisDeltaZero(o.x)&&isAxisDeltaZero(o.y)}function boxEquals(o,et){return o.x.min===et.x.min&&o.x.max===et.x.max&&o.y.min===et.y.min&&o.y.max===et.y.max}var NodeStack=function(){function o(){this.members=[]}return o.prototype.add=function(et){addUniqueItem(this.members,et),et.scheduleRender()},o.prototype.remove=function(et){if(removeItem(this.members,et),et===this.prevLead&&(this.prevLead=void 0),et===this.lead){var tt=this.members[this.members.length-1];tt&&this.promote(tt)}},o.prototype.relegate=function(et){var tt=this.members.findIndex(function(it){return et===it});if(tt===0)return!1;for(var nt,rt=tt;rt>=0;rt--){var ot=this.members[rt];if(ot.isPresent!==!1){nt=ot;break}}return nt?(this.promote(nt),!0):!1},o.prototype.promote=function(et,tt){var nt,rt=this.lead;if(et!==rt&&(this.prevLead=rt,this.lead=et,et.show(),rt)){rt.instance&&rt.scheduleRender(),et.scheduleRender(),et.resumeFrom=rt,tt&&(et.resumeFrom.preserveOpacity=!0),rt.snapshot&&(et.snapshot=rt.snapshot,et.snapshot.latestValues=rt.animationValues||rt.latestValues,et.snapshot.isShared=!0),!((nt=et.root)===null||nt===void 0)&&nt.isUpdating&&(et.isLayoutDirty=!0);var ot=et.options.crossfade;ot===!1&&rt.hide()}},o.prototype.exitAnimationComplete=function(){this.members.forEach(function(et){var tt,nt,rt,ot,it;(nt=(tt=et.options).onExitComplete)===null||nt===void 0||nt.call(tt),(it=(rt=et.resumingFrom)===null||rt===void 0?void 0:(ot=rt.options).onExitComplete)===null||it===void 0||it.call(ot)})},o.prototype.scheduleRender=function(){this.members.forEach(function(et){et.instance&&et.scheduleRender(!1)})},o.prototype.removeLeadSnapshot=function(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)},o}(),identityProjection="translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";function buildProjectionTransform(o,et,tt){var nt=o.x.translate/et.x,rt=o.y.translate/et.y,ot="translate3d(".concat(nt,"px, ").concat(rt,"px, 0) ");if(ot+="scale(".concat(1/et.x,", ").concat(1/et.y,") "),tt){var it=tt.rotate,st=tt.rotateX,at=tt.rotateY;it&&(ot+="rotate(".concat(it,"deg) ")),st&&(ot+="rotateX(".concat(st,"deg) ")),at&&(ot+="rotateY(".concat(at,"deg) "))}var ct=o.x.scale*et.x,lt=o.y.scale*et.y;return ot+="scale(".concat(ct,", ").concat(lt,")"),ot===identityProjection?"none":ot}var compareByDepth=function(o,et){return o.depth-et.depth},FlatTree=function(){function o(){this.children=[],this.isDirty=!1}return o.prototype.add=function(et){addUniqueItem(this.children,et),this.isDirty=!0},o.prototype.remove=function(et){removeItem(this.children,et),this.isDirty=!0},o.prototype.forEach=function(et){this.isDirty&&this.children.sort(compareByDepth),this.isDirty=!1,this.children.forEach(et)},o}(),animationTarget=1e3;function createProjectionNode(o){var et=o.attachResizeListener,tt=o.defaultParent,nt=o.measureScroll,rt=o.checkIsScrollRoot,ot=o.resetTransform;return function(){function it(st,at,ct){var lt=this;at===void 0&&(at={}),ct===void 0&&(ct=tt==null?void 0:tt()),this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.potentialNodes=new Map,this.checkUpdateFailed=function(){lt.isUpdating&&(lt.isUpdating=!1,lt.clearAllSnapshots())},this.updateProjection=function(){lt.nodes.forEach(resolveTargetDelta),lt.nodes.forEach(calcProjection)},this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.id=st,this.latestValues=at,this.root=ct?ct.root||ct:this,this.path=ct?__spreadArray(__spreadArray([],__read(ct.path),!1),[ct],!1):[],this.parent=ct,this.depth=ct?ct.depth+1:0,st&&this.root.registerPotentialNode(st,this);for(var dt=0;dt=0;nt--)if(o.path[nt].instance){tt=o.path[nt];break}var rt=tt&&tt!==o.root?tt.instance:document,ot=rt.querySelector('[data-projection-id="'.concat(et,'"]'));ot&&o.mount(ot,!0)}function roundAxis(o){o.min=Math.round(o.min),o.max=Math.round(o.max)}function roundBox(o){roundAxis(o.x),roundAxis(o.y)}var DocumentProjectionNode=createProjectionNode({attachResizeListener:function(o,et){return addDomEvent(o,"resize",et)},measureScroll:function(){return{x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}},checkIsScrollRoot:function(){return!0}}),rootProjectionNode={current:void 0},HTMLProjectionNode=createProjectionNode({measureScroll:function(o){return{x:o.scrollLeft,y:o.scrollTop}},defaultParent:function(){if(!rootProjectionNode.current){var o=new DocumentProjectionNode(0,{});o.mount(window),o.setOptions({layoutScroll:!0}),rootProjectionNode.current=o}return rootProjectionNode.current},resetTransform:function(o,et){o.style.transform=et??"none"},checkIsScrollRoot:function(o){return window.getComputedStyle(o).position==="fixed"}}),featureBundle=__assign(__assign(__assign(__assign({},animations),gestureAnimations),drag),layoutFeatures),motion=createMotionProxy(function(o,et){return createDomMotionConfig(o,et,featureBundle,createDomVisualElement,HTMLProjectionNode)});function useIsMounted$1(){var o=reactExports.useRef(!1);return useIsomorphicLayoutEffect$3(function(){return o.current=!0,function(){o.current=!1}},[]),o}function useForceUpdate(){var o=useIsMounted$1(),et=__read(reactExports.useState(0),2),tt=et[0],nt=et[1],rt=reactExports.useCallback(function(){o.current&&nt(tt+1)},[tt]),ot=reactExports.useCallback(function(){return sync.postRender(rt)},[rt]);return[ot,tt]}var PresenceChild=function(o){var et=o.children,tt=o.initial,nt=o.isPresent,rt=o.onExitComplete,ot=o.custom,it=o.presenceAffectsLayout,st=useConstant(newChildrenMap),at=useId$1(),ct=reactExports.useMemo(function(){return{id:at,initial:tt,isPresent:nt,custom:ot,onExitComplete:function(lt){var dt,ht;st.set(lt,!0);try{for(var pt=__values(st.values()),mt=pt.next();!mt.done;mt=pt.next()){var ft=mt.value;if(!ft)return}}catch(yt){dt={error:yt}}finally{try{mt&&!mt.done&&(ht=pt.return)&&ht.call(pt)}finally{if(dt)throw dt.error}}rt==null||rt()},register:function(lt){return st.set(lt,!1),function(){return st.delete(lt)}}}},it?void 0:[nt]);return reactExports.useMemo(function(){st.forEach(function(lt,dt){return st.set(dt,!1)})},[nt]),reactExports.useEffect(function(){!nt&&!st.size&&(rt==null||rt())},[nt]),reactExports.createElement(PresenceContext.Provider,{value:ct},et)};function newChildrenMap(){return new Map}var getChildKey=function(o){return o.key||""};function updateChildLookup(o,et){o.forEach(function(tt){var nt=getChildKey(tt);et.set(nt,tt)})}function onlyElements(o){var et=[];return reactExports.Children.forEach(o,function(tt){reactExports.isValidElement(tt)&&et.push(tt)}),et}var AnimatePresence=function(o){var et=o.children,tt=o.custom,nt=o.initial,rt=nt===void 0?!0:nt,ot=o.onExitComplete,it=o.exitBeforeEnter,st=o.presenceAffectsLayout,at=st===void 0?!0:st,ct=__read(useForceUpdate(),1),lt=ct[0],dt=reactExports.useContext(LayoutGroupContext).forceRender;dt&&(lt=dt);var ht=useIsMounted$1(),pt=onlyElements(et),mt=pt,ft=new Set,yt=reactExports.useRef(mt),gt=reactExports.useRef(new Map).current,xt=reactExports.useRef(!0);if(useIsomorphicLayoutEffect$3(function(){xt.current=!1,updateChildLookup(pt,gt),yt.current=mt}),useUnmountEffect(function(){xt.current=!0,gt.clear(),ft.clear()}),xt.current)return reactExports.createElement(reactExports.Fragment,null,mt.map(function(It){return reactExports.createElement(PresenceChild,{key:getChildKey(It),isPresent:!0,initial:rt?void 0:!1,presenceAffectsLayout:at},It)}));mt=__spreadArray([],__read(mt),!1);for(var vt=yt.current.map(getChildKey),bt=pt.map(getChildKey),Et=vt.length,wt=0;wt1&&console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour."),reactExports.createElement(reactExports.Fragment,null,ft.size?mt:mt.map(function(It){return reactExports.cloneElement(It)}))};function MotionConfig(o){var et=o.children,tt=o.isValidProp,nt=__rest(o,["children","isValidProp"]);tt&&loadExternalIsValidProp(tt),nt=__assign(__assign({},reactExports.useContext(MotionConfigContext)),nt),nt.isStatic=useConstant(function(){return nt.isStatic});var rt=reactExports.useMemo(function(){return nt},[JSON.stringify(nt.transition),nt.transformPagePoint,nt.reducedMotion]);return reactExports.createElement(MotionConfigContext.Provider,{value:rt},et)}var reactIs$2={exports:{}},reactIs_production_min$1={};/** + */var h$3=reactExports,n$2=shimExports;function p$2(o,et){return o===et&&(o!==0||1/o===1/et)||o!==o&&et!==et}var q$3=typeof Object.is=="function"?Object.is:p$2,r$3=n$2.useSyncExternalStore,t$2=h$3.useRef,u$1=h$3.useEffect,v$3=h$3.useMemo,w$3=h$3.useDebugValue;withSelector_production_min.useSyncExternalStoreWithSelector=function(o,et,tt,nt,rt){var ot=t$2(null);if(ot.current===null){var it={hasValue:!1,value:null};ot.current=it}else it=ot.current;ot=v$3(function(){function at(pt){if(!ct){if(ct=!0,lt=pt,pt=nt(pt),rt!==void 0&&it.hasValue){var mt=it.value;if(rt(mt,pt))return dt=mt}return dt=pt}if(mt=dt,q$3(lt,pt))return mt;var ft=nt(pt);return rt!==void 0&&rt(mt,ft)?mt:(lt=pt,dt=ft)}var ct=!1,lt,dt,ht=tt===void 0?null:tt;return[function(){return at(et())},ht===null?void 0:function(){return at(ht())}]},[et,tt,nt,rt]);var st=r$3(o,ot[0],ot[1]);return u$1(function(){it.hasValue=!0,it.value=st},[st]),w$3(st),st};withSelector.exports=withSelector_production_min;var withSelectorExports=withSelector.exports;const isPlainObject$4=o=>typeof o=="object"&&!Array.isArray(o);function useSyncExternalStoreWithTracked(o,et,tt=et,nt=deepEqual){const rt=reactExports.useRef([]),ot=withSelectorExports.useSyncExternalStoreWithSelector(o,et,tt,it=>it,(it,st)=>{if(isPlainObject$4(it)&&isPlainObject$4(st)&&rt.current.length){for(const at of rt.current)if(!nt(it[at],st[at]))return!1;return!0}return nt(it,st)});return reactExports.useMemo(()=>{if(isPlainObject$4(ot)){const it={...ot};let st={};for(const[at,ct]of Object.entries(it))st={...st,[at]:{configurable:!1,enumerable:!0,get:()=>(rt.current.includes(at)||rt.current.push(at),ct)}};return Object.defineProperties(it,st),it}return ot},[ot])}function useAccount(o={}){const et=useConfig(o);return useSyncExternalStoreWithTracked(tt=>watchAccount(et,{onChange:tt}),()=>getAccount(et))}function useAccountEffect(o={}){const{onConnect:et,onDisconnect:tt}=o,nt=useConfig(o);reactExports.useEffect(()=>watchAccount(nt,{onChange(rt,ot){if((ot.status==="reconnecting"||ot.status==="connecting"&&ot.address===void 0)&&rt.status==="connected"){const{address:it,addresses:st,chain:at,chainId:ct,connector:lt}=rt,dt=ot.status==="reconnecting"||ot.status===void 0;et==null||et({address:it,addresses:st,chain:at,chainId:ct,connector:lt,isReconnected:dt})}else ot.status==="connected"&&rt.status==="disconnected"&&(tt==null||tt())}}),[nt,et,tt])}var Subscribable=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(o){return this.listeners.add(o),this.onSubscribe(),()=>{this.listeners.delete(o),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},isServer=typeof window>"u"||"Deno"in globalThis;function noop$4(){}function functionalUpdate(o,et){return typeof o=="function"?o(et):o}function isValidTimeout(o){return typeof o=="number"&&o>=0&&o!==1/0}function timeUntilStale(o,et){return Math.max(o+(et||0)-Date.now(),0)}function resolveStaleTime(o,et){return typeof o=="function"?o(et):o}function resolveEnabled(o,et){return typeof o=="function"?o(et):o}function matchQuery(o,et){const{type:tt="all",exact:nt,fetchStatus:rt,predicate:ot,queryKey:it,stale:st}=o;if(it){if(nt){if(et.queryHash!==hashQueryKeyByOptions(it,et.options))return!1}else if(!partialMatchKey(et.queryKey,it))return!1}if(tt!=="all"){const at=et.isActive();if(tt==="active"&&!at||tt==="inactive"&&at)return!1}return!(typeof st=="boolean"&&et.isStale()!==st||rt&&rt!==et.state.fetchStatus||ot&&!ot(et))}function matchMutation(o,et){const{exact:tt,status:nt,predicate:rt,mutationKey:ot}=o;if(ot){if(!et.options.mutationKey)return!1;if(tt){if(hashKey(et.options.mutationKey)!==hashKey(ot))return!1}else if(!partialMatchKey(et.options.mutationKey,ot))return!1}return!(nt&&et.state.status!==nt||rt&&!rt(et))}function hashQueryKeyByOptions(o,et){return((et==null?void 0:et.queryKeyHashFn)||hashKey)(o)}function hashKey(o){return JSON.stringify(o,(et,tt)=>isPlainObject$3(tt)?Object.keys(tt).sort().reduce((nt,rt)=>(nt[rt]=tt[rt],nt),{}):tt)}function partialMatchKey(o,et){return o===et?!0:typeof o!=typeof et?!1:o&&et&&typeof o=="object"&&typeof et=="object"?!Object.keys(et).some(tt=>!partialMatchKey(o[tt],et[tt])):!1}function replaceEqualDeep(o,et){if(o===et)return o;const tt=isPlainArray(o)&&isPlainArray(et);if(tt||isPlainObject$3(o)&&isPlainObject$3(et)){const nt=tt?o:Object.keys(o),rt=nt.length,ot=tt?et:Object.keys(et),it=ot.length,st=tt?[]:{};let at=0;for(let ct=0;ct{setTimeout(et,o)})}function replaceData(o,et,tt){return typeof tt.structuralSharing=="function"?tt.structuralSharing(o,et):tt.structuralSharing!==!1?replaceEqualDeep(o,et):et}function addToEnd(o,et,tt=0){const nt=[...o,et];return tt&&nt.length>tt?nt.slice(1):nt}function addToStart(o,et,tt=0){const nt=[et,...o];return tt&&nt.length>tt?nt.slice(0,-1):nt}var skipToken=Symbol();function ensureQueryFn(o,et){return!o.queryFn&&(et!=null&&et.initialPromise)?()=>et.initialPromise:!o.queryFn||o.queryFn===skipToken?()=>Promise.reject(new Error(`Missing queryFn: '${o.queryHash}'`)):o.queryFn}var Sr,lr,$r,Ds,FocusManager=(Ds=class extends Subscribable{constructor(){super();fn(this,Sr);fn(this,lr);fn(this,$r);un(this,$r,et=>{if(!isServer&&window.addEventListener){const tt=()=>et();return window.addEventListener("visibilitychange",tt,!1),()=>{window.removeEventListener("visibilitychange",tt)}}})}onSubscribe(){Mt(this,lr)||this.setEventListener(Mt(this,$r))}onUnsubscribe(){var et;this.hasListeners()||((et=Mt(this,lr))==null||et.call(this),un(this,lr,void 0))}setEventListener(et){var tt;un(this,$r,et),(tt=Mt(this,lr))==null||tt.call(this),un(this,lr,et(nt=>{typeof nt=="boolean"?this.setFocused(nt):this.onFocus()}))}setFocused(et){Mt(this,Sr)!==et&&(un(this,Sr,et),this.onFocus())}onFocus(){const et=this.isFocused();this.listeners.forEach(tt=>{tt(et)})}isFocused(){var et;return typeof Mt(this,Sr)=="boolean"?Mt(this,Sr):((et=globalThis.document)==null?void 0:et.visibilityState)!=="hidden"}},Sr=new WeakMap,lr=new WeakMap,$r=new WeakMap,Ds),focusManager=new FocusManager,Or,ur,Mr,Fs,OnlineManager=(Fs=class extends Subscribable{constructor(){super();fn(this,Or,!0);fn(this,ur);fn(this,Mr);un(this,Mr,et=>{if(!isServer&&window.addEventListener){const tt=()=>et(!0),nt=()=>et(!1);return window.addEventListener("online",tt,!1),window.addEventListener("offline",nt,!1),()=>{window.removeEventListener("online",tt),window.removeEventListener("offline",nt)}}})}onSubscribe(){Mt(this,ur)||this.setEventListener(Mt(this,Mr))}onUnsubscribe(){var et;this.hasListeners()||((et=Mt(this,ur))==null||et.call(this),un(this,ur,void 0))}setEventListener(et){var tt;un(this,Mr,et),(tt=Mt(this,ur))==null||tt.call(this),un(this,ur,et(this.setOnline.bind(this)))}setOnline(et){Mt(this,Or)!==et&&(un(this,Or,et),this.listeners.forEach(nt=>{nt(et)}))}isOnline(){return Mt(this,Or)}},Or=new WeakMap,ur=new WeakMap,Mr=new WeakMap,Fs),onlineManager=new OnlineManager;function pendingThenable(){let o,et;const tt=new Promise((rt,ot)=>{o=rt,et=ot});tt.status="pending",tt.catch(()=>{});function nt(rt){Object.assign(tt,rt),delete tt.resolve,delete tt.reject}return tt.resolve=rt=>{nt({status:"fulfilled",value:rt}),o(rt)},tt.reject=rt=>{nt({status:"rejected",reason:rt}),et(rt)},tt}function defaultRetryDelay(o){return Math.min(1e3*2**o,3e4)}function canFetch(o){return(o??"online")==="online"?onlineManager.isOnline():!0}var CancelledError=class extends Error{constructor(o){super("CancelledError"),this.revert=o==null?void 0:o.revert,this.silent=o==null?void 0:o.silent}};function isCancelledError(o){return o instanceof CancelledError}function createRetryer(o){let et=!1,tt=0,nt=!1,rt;const ot=pendingThenable(),it=ft=>{var yt;nt||(ht(new CancelledError(ft)),(yt=o.abort)==null||yt.call(o))},st=()=>{et=!0},at=()=>{et=!1},ct=()=>focusManager.isFocused()&&(o.networkMode==="always"||onlineManager.isOnline())&&o.canRun(),lt=()=>canFetch(o.networkMode)&&o.canRun(),dt=ft=>{var yt;nt||(nt=!0,(yt=o.onSuccess)==null||yt.call(o,ft),rt==null||rt(),ot.resolve(ft))},ht=ft=>{var yt;nt||(nt=!0,(yt=o.onError)==null||yt.call(o,ft),rt==null||rt(),ot.reject(ft))},pt=()=>new Promise(ft=>{var yt;rt=gt=>{(nt||ct())&&ft(gt)},(yt=o.onPause)==null||yt.call(o)}).then(()=>{var ft;rt=void 0,nt||(ft=o.onContinue)==null||ft.call(o)}),mt=()=>{if(nt)return;let ft;const yt=tt===0?o.initialPromise:void 0;try{ft=yt??o.fn()}catch(gt){ft=Promise.reject(gt)}Promise.resolve(ft).then(dt).catch(gt=>{var wt;if(nt)return;const xt=o.retry??(isServer?0:3),vt=o.retryDelay??defaultRetryDelay,bt=typeof vt=="function"?vt(tt,gt):vt,Et=xt===!0||typeof xt=="number"&&ttct()?void 0:pt()).then(()=>{et?ht(gt):mt()})})};return{promise:ot,cancel:it,continue:()=>(rt==null||rt(),ot),cancelRetry:st,continueRetry:at,canStart:lt,start:()=>(lt()?mt():pt().then(mt),ot)}}function createNotifyManager(){let o=[],et=0,tt=st=>{st()},nt=st=>{st()},rt=st=>setTimeout(st,0);const ot=st=>{et?o.push(st):rt(()=>{tt(st)})},it=()=>{const st=o;o=[],st.length&&rt(()=>{nt(()=>{st.forEach(at=>{tt(at)})})})};return{batch:st=>{let at;et++;try{at=st()}finally{et--,et||it()}return at},batchCalls:st=>(...at)=>{ot(()=>{st(...at)})},schedule:ot,setNotifyFunction:st=>{tt=st},setBatchNotifyFunction:st=>{nt=st},setScheduler:st=>{rt=st}}}var notifyManager=createNotifyManager(),kr,Us,Removable=(Us=class{constructor(){fn(this,kr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),isValidTimeout(this.gcTime)&&un(this,kr,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(o){this.gcTime=Math.max(this.gcTime||0,o??(isServer?1/0:5*60*1e3))}clearGcTimeout(){Mt(this,kr)&&(clearTimeout(Mt(this,kr)),un(this,kr,void 0))}},kr=new WeakMap,Us),Br,Dr,Un,jn,no,Ar,Hn,tr,zs,Query=(zs=class extends Removable{constructor(et){super();fn(this,Hn);fn(this,Br);fn(this,Dr);fn(this,Un);fn(this,jn);fn(this,no);fn(this,Ar);un(this,Ar,!1),un(this,no,et.defaultOptions),this.setOptions(et.options),this.observers=[],un(this,Un,et.cache),this.queryKey=et.queryKey,this.queryHash=et.queryHash,un(this,Br,getDefaultState$1(this.options)),this.state=et.state??Mt(this,Br),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var et;return(et=Mt(this,jn))==null?void 0:et.promise}setOptions(et){this.options={...Mt(this,no),...et},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&Mt(this,Un).remove(this)}setData(et,tt){const nt=replaceData(this.state.data,et,this.options);return gn(this,Hn,tr).call(this,{data:nt,type:"success",dataUpdatedAt:tt==null?void 0:tt.updatedAt,manual:tt==null?void 0:tt.manual}),nt}setState(et,tt){gn(this,Hn,tr).call(this,{type:"setState",state:et,setStateOptions:tt})}cancel(et){var nt,rt;const tt=(nt=Mt(this,jn))==null?void 0:nt.promise;return(rt=Mt(this,jn))==null||rt.cancel(et),tt?tt.then(noop$4).catch(noop$4):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Mt(this,Br))}isActive(){return this.observers.some(et=>resolveEnabled(et.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(et=>et.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(et=0){return this.state.isInvalidated||this.state.data===void 0||!timeUntilStale(this.state.dataUpdatedAt,et)}onFocus(){var tt;const et=this.observers.find(nt=>nt.shouldFetchOnWindowFocus());et==null||et.refetch({cancelRefetch:!1}),(tt=Mt(this,jn))==null||tt.continue()}onOnline(){var tt;const et=this.observers.find(nt=>nt.shouldFetchOnReconnect());et==null||et.refetch({cancelRefetch:!1}),(tt=Mt(this,jn))==null||tt.continue()}addObserver(et){this.observers.includes(et)||(this.observers.push(et),this.clearGcTimeout(),Mt(this,Un).notify({type:"observerAdded",query:this,observer:et}))}removeObserver(et){this.observers.includes(et)&&(this.observers=this.observers.filter(tt=>tt!==et),this.observers.length||(Mt(this,jn)&&(Mt(this,Ar)?Mt(this,jn).cancel({revert:!0}):Mt(this,jn).cancelRetry()),this.scheduleGc()),Mt(this,Un).notify({type:"observerRemoved",query:this,observer:et}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||gn(this,Hn,tr).call(this,{type:"invalidate"})}fetch(et,tt){var at,ct,lt;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(tt!=null&&tt.cancelRefetch))this.cancel({silent:!0});else if(Mt(this,jn))return Mt(this,jn).continueRetry(),Mt(this,jn).promise}if(et&&this.setOptions(et),!this.options.queryFn){const dt=this.observers.find(ht=>ht.options.queryFn);dt&&this.setOptions(dt.options)}const nt=new AbortController,rt=dt=>{Object.defineProperty(dt,"signal",{enumerable:!0,get:()=>(un(this,Ar,!0),nt.signal)})},ot=()=>{const dt=ensureQueryFn(this.options,tt),ht={queryKey:this.queryKey,meta:this.meta};return rt(ht),un(this,Ar,!1),this.options.persister?this.options.persister(dt,ht,this):dt(ht)},it={fetchOptions:tt,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:ot};rt(it),(at=this.options.behavior)==null||at.onFetch(it,this),un(this,Dr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((ct=it.fetchOptions)==null?void 0:ct.meta))&&gn(this,Hn,tr).call(this,{type:"fetch",meta:(lt=it.fetchOptions)==null?void 0:lt.meta});const st=dt=>{var ht,pt,mt,ft;isCancelledError(dt)&&dt.silent||gn(this,Hn,tr).call(this,{type:"error",error:dt}),isCancelledError(dt)||((pt=(ht=Mt(this,Un).config).onError)==null||pt.call(ht,dt,this),(ft=(mt=Mt(this,Un).config).onSettled)==null||ft.call(mt,this.state.data,dt,this)),this.scheduleGc()};return un(this,jn,createRetryer({initialPromise:tt==null?void 0:tt.initialPromise,fn:it.fetchFn,abort:nt.abort.bind(nt),onSuccess:dt=>{var ht,pt,mt,ft;if(dt===void 0){st(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(dt)}catch(yt){st(yt);return}(pt=(ht=Mt(this,Un).config).onSuccess)==null||pt.call(ht,dt,this),(ft=(mt=Mt(this,Un).config).onSettled)==null||ft.call(mt,dt,this.state.error,this),this.scheduleGc()},onError:st,onFail:(dt,ht)=>{gn(this,Hn,tr).call(this,{type:"failed",failureCount:dt,error:ht})},onPause:()=>{gn(this,Hn,tr).call(this,{type:"pause"})},onContinue:()=>{gn(this,Hn,tr).call(this,{type:"continue"})},retry:it.options.retry,retryDelay:it.options.retryDelay,networkMode:it.options.networkMode,canRun:()=>!0})),Mt(this,jn).start()}},Br=new WeakMap,Dr=new WeakMap,Un=new WeakMap,jn=new WeakMap,no=new WeakMap,Ar=new WeakMap,Hn=new WeakSet,tr=function(et){const tt=nt=>{switch(et.type){case"failed":return{...nt,fetchFailureCount:et.failureCount,fetchFailureReason:et.error};case"pause":return{...nt,fetchStatus:"paused"};case"continue":return{...nt,fetchStatus:"fetching"};case"fetch":return{...nt,...fetchState(nt.data,this.options),fetchMeta:et.meta??null};case"success":return{...nt,data:et.data,dataUpdateCount:nt.dataUpdateCount+1,dataUpdatedAt:et.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!et.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const rt=et.error;return isCancelledError(rt)&&rt.revert&&Mt(this,Dr)?{...Mt(this,Dr),fetchStatus:"idle"}:{...nt,error:rt,errorUpdateCount:nt.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:nt.fetchFailureCount+1,fetchFailureReason:rt,fetchStatus:"idle",status:"error"};case"invalidate":return{...nt,isInvalidated:!0};case"setState":return{...nt,...et.state}}};this.state=tt(this.state),notifyManager.batch(()=>{this.observers.forEach(nt=>{nt.onQueryUpdate()}),Mt(this,Un).notify({query:this,type:"updated",action:et})})},zs);function fetchState(o,et){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:canFetch(et.networkMode)?"fetching":"paused",...o===void 0&&{error:null,status:"pending"}}}function getDefaultState$1(o){const et=typeof o.initialData=="function"?o.initialData():o.initialData,tt=et!==void 0,nt=tt?typeof o.initialDataUpdatedAt=="function"?o.initialDataUpdatedAt():o.initialDataUpdatedAt:0;return{data:et,dataUpdateCount:0,dataUpdatedAt:tt?nt??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:tt?"success":"pending",fetchStatus:"idle"}}var Wn,Vs,QueryCache=(Vs=class extends Subscribable{constructor(et={}){super();fn(this,Wn);this.config=et,un(this,Wn,new Map)}build(et,tt,nt){const rt=tt.queryKey,ot=tt.queryHash??hashQueryKeyByOptions(rt,tt);let it=this.get(ot);return it||(it=new Query({cache:this,queryKey:rt,queryHash:ot,options:et.defaultQueryOptions(tt),state:nt,defaultOptions:et.getQueryDefaults(rt)}),this.add(it)),it}add(et){Mt(this,Wn).has(et.queryHash)||(Mt(this,Wn).set(et.queryHash,et),this.notify({type:"added",query:et}))}remove(et){const tt=Mt(this,Wn).get(et.queryHash);tt&&(et.destroy(),tt===et&&Mt(this,Wn).delete(et.queryHash),this.notify({type:"removed",query:et}))}clear(){notifyManager.batch(()=>{this.getAll().forEach(et=>{this.remove(et)})})}get(et){return Mt(this,Wn).get(et)}getAll(){return[...Mt(this,Wn).values()]}find(et){const tt={exact:!0,...et};return this.getAll().find(nt=>matchQuery(tt,nt))}findAll(et={}){const tt=this.getAll();return Object.keys(et).length>0?tt.filter(nt=>matchQuery(et,nt)):tt}notify(et){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(et)})})}onFocus(){notifyManager.batch(()=>{this.getAll().forEach(et=>{et.onFocus()})})}onOnline(){notifyManager.batch(()=>{this.getAll().forEach(et=>{et.onOnline()})})}},Wn=new WeakMap,Vs),Gn,$n,Rr,qn,ar,Hs,Mutation=(Hs=class extends Removable{constructor(et){super();fn(this,qn);fn(this,Gn);fn(this,$n);fn(this,Rr);this.mutationId=et.mutationId,un(this,$n,et.mutationCache),un(this,Gn,[]),this.state=et.state||getDefaultState(),this.setOptions(et.options),this.scheduleGc()}setOptions(et){this.options=et,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(et){Mt(this,Gn).includes(et)||(Mt(this,Gn).push(et),this.clearGcTimeout(),Mt(this,$n).notify({type:"observerAdded",mutation:this,observer:et}))}removeObserver(et){un(this,Gn,Mt(this,Gn).filter(tt=>tt!==et)),this.scheduleGc(),Mt(this,$n).notify({type:"observerRemoved",mutation:this,observer:et})}optionalRemove(){Mt(this,Gn).length||(this.state.status==="pending"?this.scheduleGc():Mt(this,$n).remove(this))}continue(){var et;return((et=Mt(this,Rr))==null?void 0:et.continue())??this.execute(this.state.variables)}async execute(et){var rt,ot,it,st,at,ct,lt,dt,ht,pt,mt,ft,yt,gt,xt,vt,bt,Et,wt,kt;un(this,Rr,createRetryer({fn:()=>this.options.mutationFn?this.options.mutationFn(et):Promise.reject(new Error("No mutationFn found")),onFail:(It,Rt)=>{gn(this,qn,ar).call(this,{type:"failed",failureCount:It,error:Rt})},onPause:()=>{gn(this,qn,ar).call(this,{type:"pause"})},onContinue:()=>{gn(this,qn,ar).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Mt(this,$n).canRun(this)}));const tt=this.state.status==="pending",nt=!Mt(this,Rr).canStart();try{if(!tt){gn(this,qn,ar).call(this,{type:"pending",variables:et,isPaused:nt}),await((ot=(rt=Mt(this,$n).config).onMutate)==null?void 0:ot.call(rt,et,this));const Rt=await((st=(it=this.options).onMutate)==null?void 0:st.call(it,et));Rt!==this.state.context&&gn(this,qn,ar).call(this,{type:"pending",context:Rt,variables:et,isPaused:nt})}const It=await Mt(this,Rr).start();return await((ct=(at=Mt(this,$n).config).onSuccess)==null?void 0:ct.call(at,It,et,this.state.context,this)),await((dt=(lt=this.options).onSuccess)==null?void 0:dt.call(lt,It,et,this.state.context)),await((pt=(ht=Mt(this,$n).config).onSettled)==null?void 0:pt.call(ht,It,null,this.state.variables,this.state.context,this)),await((ft=(mt=this.options).onSettled)==null?void 0:ft.call(mt,It,null,et,this.state.context)),gn(this,qn,ar).call(this,{type:"success",data:It}),It}catch(It){try{throw await((gt=(yt=Mt(this,$n).config).onError)==null?void 0:gt.call(yt,It,et,this.state.context,this)),await((vt=(xt=this.options).onError)==null?void 0:vt.call(xt,It,et,this.state.context)),await((Et=(bt=Mt(this,$n).config).onSettled)==null?void 0:Et.call(bt,void 0,It,this.state.variables,this.state.context,this)),await((kt=(wt=this.options).onSettled)==null?void 0:kt.call(wt,void 0,It,et,this.state.context)),It}finally{gn(this,qn,ar).call(this,{type:"error",error:It})}}finally{Mt(this,$n).runNext(this)}}},Gn=new WeakMap,$n=new WeakMap,Rr=new WeakMap,qn=new WeakSet,ar=function(et){const tt=nt=>{switch(et.type){case"failed":return{...nt,failureCount:et.failureCount,failureReason:et.error};case"pause":return{...nt,isPaused:!0};case"continue":return{...nt,isPaused:!1};case"pending":return{...nt,context:et.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:et.isPaused,status:"pending",variables:et.variables,submittedAt:Date.now()};case"success":return{...nt,data:et.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...nt,data:void 0,error:et.error,failureCount:nt.failureCount+1,failureReason:et.error,isPaused:!1,status:"error"}}};this.state=tt(this.state),notifyManager.batch(()=>{Mt(this,Gn).forEach(nt=>{nt.onMutationUpdate(et)}),Mt(this,$n).notify({mutation:this,type:"updated",action:et})})},Hs);function getDefaultState(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Fn,ro,Ws,MutationCache=(Ws=class extends Subscribable{constructor(et={}){super();fn(this,Fn);fn(this,ro);this.config=et,un(this,Fn,new Map),un(this,ro,Date.now())}build(et,tt,nt){const rt=new Mutation({mutationCache:this,mutationId:++br(this,ro)._,options:et.defaultMutationOptions(tt),state:nt});return this.add(rt),rt}add(et){const tt=scopeFor(et),nt=Mt(this,Fn).get(tt)??[];nt.push(et),Mt(this,Fn).set(tt,nt),this.notify({type:"added",mutation:et})}remove(et){var nt;const tt=scopeFor(et);if(Mt(this,Fn).has(tt)){const rt=(nt=Mt(this,Fn).get(tt))==null?void 0:nt.filter(ot=>ot!==et);rt&&(rt.length===0?Mt(this,Fn).delete(tt):Mt(this,Fn).set(tt,rt))}this.notify({type:"removed",mutation:et})}canRun(et){var nt;const tt=(nt=Mt(this,Fn).get(scopeFor(et)))==null?void 0:nt.find(rt=>rt.state.status==="pending");return!tt||tt===et}runNext(et){var nt;const tt=(nt=Mt(this,Fn).get(scopeFor(et)))==null?void 0:nt.find(rt=>rt!==et&&rt.state.isPaused);return(tt==null?void 0:tt.continue())??Promise.resolve()}clear(){notifyManager.batch(()=>{this.getAll().forEach(et=>{this.remove(et)})})}getAll(){return[...Mt(this,Fn).values()].flat()}find(et){const tt={exact:!0,...et};return this.getAll().find(nt=>matchMutation(tt,nt))}findAll(et={}){return this.getAll().filter(tt=>matchMutation(et,tt))}notify(et){notifyManager.batch(()=>{this.listeners.forEach(tt=>{tt(et)})})}resumePausedMutations(){const et=this.getAll().filter(tt=>tt.state.isPaused);return notifyManager.batch(()=>Promise.all(et.map(tt=>tt.continue().catch(noop$4))))}},Fn=new WeakMap,ro=new WeakMap,Ws);function scopeFor(o){var et;return((et=o.options.scope)==null?void 0:et.id)??String(o.mutationId)}function infiniteQueryBehavior(o){return{onFetch:(et,tt)=>{var lt,dt,ht,pt,mt;const nt=et.options,rt=(ht=(dt=(lt=et.fetchOptions)==null?void 0:lt.meta)==null?void 0:dt.fetchMore)==null?void 0:ht.direction,ot=((pt=et.state.data)==null?void 0:pt.pages)||[],it=((mt=et.state.data)==null?void 0:mt.pageParams)||[];let st={pages:[],pageParams:[]},at=0;const ct=async()=>{let ft=!1;const yt=vt=>{Object.defineProperty(vt,"signal",{enumerable:!0,get:()=>(et.signal.aborted?ft=!0:et.signal.addEventListener("abort",()=>{ft=!0}),et.signal)})},gt=ensureQueryFn(et.options,et.fetchOptions),xt=async(vt,bt,Et)=>{if(ft)return Promise.reject();if(bt==null&&vt.pages.length)return Promise.resolve(vt);const wt={queryKey:et.queryKey,pageParam:bt,direction:Et?"backward":"forward",meta:et.options.meta};yt(wt);const kt=await gt(wt),{maxPages:It}=et.options,Rt=Et?addToStart:addToEnd;return{pages:Rt(vt.pages,kt,It),pageParams:Rt(vt.pageParams,bt,It)}};if(rt&&ot.length){const vt=rt==="backward",bt=vt?getPreviousPageParam:getNextPageParam,Et={pages:ot,pageParams:it},wt=bt(nt,Et);st=await xt(Et,wt,vt)}else{const vt=o??ot.length;do{const bt=at===0?it[0]??nt.initialPageParam:getNextPageParam(nt,st);if(at>0&&bt==null)break;st=await xt(st,bt),at++}while(at{var ft,yt;return(yt=(ft=et.options).persister)==null?void 0:yt.call(ft,ct,{queryKey:et.queryKey,meta:et.options.meta,signal:et.signal},tt)}:et.fetchFn=ct}}}function getNextPageParam(o,{pages:et,pageParams:tt}){const nt=et.length-1;return et.length>0?o.getNextPageParam(et[nt],et,tt[nt],tt):void 0}function getPreviousPageParam(o,{pages:et,pageParams:tt}){var nt;return et.length>0?(nt=o.getPreviousPageParam)==null?void 0:nt.call(o,et[0],et,tt[0],tt):void 0}var Nn,dr,hr,Fr,Ur,pr,zr,Vr,Gs,QueryClient=(Gs=class{constructor(o={}){fn(this,Nn);fn(this,dr);fn(this,hr);fn(this,Fr);fn(this,Ur);fn(this,pr);fn(this,zr);fn(this,Vr);un(this,Nn,o.queryCache||new QueryCache),un(this,dr,o.mutationCache||new MutationCache),un(this,hr,o.defaultOptions||{}),un(this,Fr,new Map),un(this,Ur,new Map),un(this,pr,0)}mount(){br(this,pr)._++,Mt(this,pr)===1&&(un(this,zr,focusManager.subscribe(async o=>{o&&(await this.resumePausedMutations(),Mt(this,Nn).onFocus())})),un(this,Vr,onlineManager.subscribe(async o=>{o&&(await this.resumePausedMutations(),Mt(this,Nn).onOnline())})))}unmount(){var o,et;br(this,pr)._--,Mt(this,pr)===0&&((o=Mt(this,zr))==null||o.call(this),un(this,zr,void 0),(et=Mt(this,Vr))==null||et.call(this),un(this,Vr,void 0))}isFetching(o){return Mt(this,Nn).findAll({...o,fetchStatus:"fetching"}).length}isMutating(o){return Mt(this,dr).findAll({...o,status:"pending"}).length}getQueryData(o){var tt;const et=this.defaultQueryOptions({queryKey:o});return(tt=Mt(this,Nn).get(et.queryHash))==null?void 0:tt.state.data}ensureQueryData(o){const et=this.getQueryData(o.queryKey);if(et===void 0)return this.fetchQuery(o);{const tt=this.defaultQueryOptions(o),nt=Mt(this,Nn).build(this,tt);return o.revalidateIfStale&&nt.isStaleByTime(resolveStaleTime(tt.staleTime,nt))&&this.prefetchQuery(tt),Promise.resolve(et)}}getQueriesData(o){return Mt(this,Nn).findAll(o).map(({queryKey:et,state:tt})=>{const nt=tt.data;return[et,nt]})}setQueryData(o,et,tt){const nt=this.defaultQueryOptions({queryKey:o}),rt=Mt(this,Nn).get(nt.queryHash),ot=rt==null?void 0:rt.state.data,it=functionalUpdate(et,ot);if(it!==void 0)return Mt(this,Nn).build(this,nt).setData(it,{...tt,manual:!0})}setQueriesData(o,et,tt){return notifyManager.batch(()=>Mt(this,Nn).findAll(o).map(({queryKey:nt})=>[nt,this.setQueryData(nt,et,tt)]))}getQueryState(o){var tt;const et=this.defaultQueryOptions({queryKey:o});return(tt=Mt(this,Nn).get(et.queryHash))==null?void 0:tt.state}removeQueries(o){const et=Mt(this,Nn);notifyManager.batch(()=>{et.findAll(o).forEach(tt=>{et.remove(tt)})})}resetQueries(o,et){const tt=Mt(this,Nn),nt={type:"active",...o};return notifyManager.batch(()=>(tt.findAll(o).forEach(rt=>{rt.reset()}),this.refetchQueries(nt,et)))}cancelQueries(o={},et={}){const tt={revert:!0,...et},nt=notifyManager.batch(()=>Mt(this,Nn).findAll(o).map(rt=>rt.cancel(tt)));return Promise.all(nt).then(noop$4).catch(noop$4)}invalidateQueries(o={},et={}){return notifyManager.batch(()=>{if(Mt(this,Nn).findAll(o).forEach(nt=>{nt.invalidate()}),o.refetchType==="none")return Promise.resolve();const tt={...o,type:o.refetchType??o.type??"active"};return this.refetchQueries(tt,et)})}refetchQueries(o={},et){const tt={...et,cancelRefetch:(et==null?void 0:et.cancelRefetch)??!0},nt=notifyManager.batch(()=>Mt(this,Nn).findAll(o).filter(rt=>!rt.isDisabled()).map(rt=>{let ot=rt.fetch(void 0,tt);return tt.throwOnError||(ot=ot.catch(noop$4)),rt.state.fetchStatus==="paused"?Promise.resolve():ot}));return Promise.all(nt).then(noop$4)}fetchQuery(o){const et=this.defaultQueryOptions(o);et.retry===void 0&&(et.retry=!1);const tt=Mt(this,Nn).build(this,et);return tt.isStaleByTime(resolveStaleTime(et.staleTime,tt))?tt.fetch(et):Promise.resolve(tt.state.data)}prefetchQuery(o){return this.fetchQuery(o).then(noop$4).catch(noop$4)}fetchInfiniteQuery(o){return o.behavior=infiniteQueryBehavior(o.pages),this.fetchQuery(o)}prefetchInfiniteQuery(o){return this.fetchInfiniteQuery(o).then(noop$4).catch(noop$4)}ensureInfiniteQueryData(o){return o.behavior=infiniteQueryBehavior(o.pages),this.ensureQueryData(o)}resumePausedMutations(){return onlineManager.isOnline()?Mt(this,dr).resumePausedMutations():Promise.resolve()}getQueryCache(){return Mt(this,Nn)}getMutationCache(){return Mt(this,dr)}getDefaultOptions(){return Mt(this,hr)}setDefaultOptions(o){un(this,hr,o)}setQueryDefaults(o,et){Mt(this,Fr).set(hashKey(o),{queryKey:o,defaultOptions:et})}getQueryDefaults(o){const et=[...Mt(this,Fr).values()];let tt={};return et.forEach(nt=>{partialMatchKey(o,nt.queryKey)&&(tt={...tt,...nt.defaultOptions})}),tt}setMutationDefaults(o,et){Mt(this,Ur).set(hashKey(o),{mutationKey:o,defaultOptions:et})}getMutationDefaults(o){const et=[...Mt(this,Ur).values()];let tt={};return et.forEach(nt=>{partialMatchKey(o,nt.mutationKey)&&(tt={...tt,...nt.defaultOptions})}),tt}defaultQueryOptions(o){if(o._defaulted)return o;const et={...Mt(this,hr).queries,...this.getQueryDefaults(o.queryKey),...o,_defaulted:!0};return et.queryHash||(et.queryHash=hashQueryKeyByOptions(et.queryKey,et)),et.refetchOnReconnect===void 0&&(et.refetchOnReconnect=et.networkMode!=="always"),et.throwOnError===void 0&&(et.throwOnError=!!et.suspense),!et.networkMode&&et.persister&&(et.networkMode="offlineFirst"),et.enabled!==!0&&et.queryFn===skipToken&&(et.enabled=!1),et}defaultMutationOptions(o){return o!=null&&o._defaulted?o:{...Mt(this,hr).mutations,...(o==null?void 0:o.mutationKey)&&this.getMutationDefaults(o.mutationKey),...o,_defaulted:!0}}clear(){Mt(this,Nn).clear(),Mt(this,dr).clear()}},Nn=new WeakMap,dr=new WeakMap,hr=new WeakMap,Fr=new WeakMap,Ur=new WeakMap,pr=new WeakMap,zr=new WeakMap,Vr=new WeakMap,Gs),Mn,Sn,oo,On,_r,Hr,fr,Kn,io,Wr,Gr,Ir,Tr,mr,qr,In,to,Rs,_s,Is,Ts,Ps,Ls,Ns,Ql,qs,QueryObserver=(qs=class extends Subscribable{constructor(et,tt){super();fn(this,In);fn(this,Mn);fn(this,Sn);fn(this,oo);fn(this,On);fn(this,_r);fn(this,Hr);fn(this,fr);fn(this,Kn);fn(this,io);fn(this,Wr);fn(this,Gr);fn(this,Ir);fn(this,Tr);fn(this,mr);fn(this,qr,new Set);this.options=tt,un(this,Mn,et),un(this,Kn,null),un(this,fr,pendingThenable()),this.options.experimental_prefetchInRender||Mt(this,fr).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(tt)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Mt(this,Sn).addObserver(this),shouldFetchOnMount(Mt(this,Sn),this.options)?gn(this,In,to).call(this):this.updateResult(),gn(this,In,Ts).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return shouldFetchOn(Mt(this,Sn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return shouldFetchOn(Mt(this,Sn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,gn(this,In,Ps).call(this),gn(this,In,Ls).call(this),Mt(this,Sn).removeObserver(this)}setOptions(et,tt){const nt=this.options,rt=Mt(this,Sn);if(this.options=Mt(this,Mn).defaultQueryOptions(et),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof resolveEnabled(this.options.enabled,Mt(this,Sn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");gn(this,In,Ns).call(this),Mt(this,Sn).setOptions(this.options),nt._defaulted&&!shallowEqualObjects(this.options,nt)&&Mt(this,Mn).getQueryCache().notify({type:"observerOptionsUpdated",query:Mt(this,Sn),observer:this});const ot=this.hasListeners();ot&&shouldFetchOptionally(Mt(this,Sn),rt,this.options,nt)&&gn(this,In,to).call(this),this.updateResult(tt),ot&&(Mt(this,Sn)!==rt||resolveEnabled(this.options.enabled,Mt(this,Sn))!==resolveEnabled(nt.enabled,Mt(this,Sn))||resolveStaleTime(this.options.staleTime,Mt(this,Sn))!==resolveStaleTime(nt.staleTime,Mt(this,Sn)))&&gn(this,In,Rs).call(this);const it=gn(this,In,_s).call(this);ot&&(Mt(this,Sn)!==rt||resolveEnabled(this.options.enabled,Mt(this,Sn))!==resolveEnabled(nt.enabled,Mt(this,Sn))||it!==Mt(this,mr))&&gn(this,In,Is).call(this,it)}getOptimisticResult(et){const tt=Mt(this,Mn).getQueryCache().build(Mt(this,Mn),et),nt=this.createResult(tt,et);return shouldAssignObserverCurrentProperties(this,nt)&&(un(this,On,nt),un(this,Hr,this.options),un(this,_r,Mt(this,Sn).state)),nt}getCurrentResult(){return Mt(this,On)}trackResult(et,tt){const nt={};return Object.keys(et).forEach(rt=>{Object.defineProperty(nt,rt,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(rt),tt==null||tt(rt),et[rt])})}),nt}trackProp(et){Mt(this,qr).add(et)}getCurrentQuery(){return Mt(this,Sn)}refetch({...et}={}){return this.fetch({...et})}fetchOptimistic(et){const tt=Mt(this,Mn).defaultQueryOptions(et),nt=Mt(this,Mn).getQueryCache().build(Mt(this,Mn),tt);return nt.fetch().then(()=>this.createResult(nt,tt))}fetch(et){return gn(this,In,to).call(this,{...et,cancelRefetch:et.cancelRefetch??!0}).then(()=>(this.updateResult(),Mt(this,On)))}createResult(et,tt){var It;const nt=Mt(this,Sn),rt=this.options,ot=Mt(this,On),it=Mt(this,_r),st=Mt(this,Hr),ct=et!==nt?et.state:Mt(this,oo),{state:lt}=et;let dt={...lt},ht=!1,pt;if(tt._optimisticResults){const Rt=this.hasListeners(),Pt=!Rt&&shouldFetchOnMount(et,tt),jt=Rt&&shouldFetchOptionally(et,nt,tt,rt);(Pt||jt)&&(dt={...dt,...fetchState(lt.data,et.options)}),tt._optimisticResults==="isRestoring"&&(dt.fetchStatus="idle")}let{error:mt,errorUpdatedAt:ft,status:yt}=dt;if(tt.select&&dt.data!==void 0)if(ot&&dt.data===(it==null?void 0:it.data)&&tt.select===Mt(this,io))pt=Mt(this,Wr);else try{un(this,io,tt.select),pt=tt.select(dt.data),pt=replaceData(ot==null?void 0:ot.data,pt,tt),un(this,Wr,pt),un(this,Kn,null)}catch(Rt){un(this,Kn,Rt)}else pt=dt.data;if(tt.placeholderData!==void 0&&pt===void 0&&yt==="pending"){let Rt;if(ot!=null&&ot.isPlaceholderData&&tt.placeholderData===(st==null?void 0:st.placeholderData))Rt=ot.data;else if(Rt=typeof tt.placeholderData=="function"?tt.placeholderData((It=Mt(this,Gr))==null?void 0:It.state.data,Mt(this,Gr)):tt.placeholderData,tt.select&&Rt!==void 0)try{Rt=tt.select(Rt),un(this,Kn,null)}catch(Pt){un(this,Kn,Pt)}Rt!==void 0&&(yt="success",pt=replaceData(ot==null?void 0:ot.data,Rt,tt),ht=!0)}Mt(this,Kn)&&(mt=Mt(this,Kn),pt=Mt(this,Wr),ft=Date.now(),yt="error");const gt=dt.fetchStatus==="fetching",xt=yt==="pending",vt=yt==="error",bt=xt&>,Et=pt!==void 0,kt={status:yt,fetchStatus:dt.fetchStatus,isPending:xt,isSuccess:yt==="success",isError:vt,isInitialLoading:bt,isLoading:bt,data:pt,dataUpdatedAt:dt.dataUpdatedAt,error:mt,errorUpdatedAt:ft,failureCount:dt.fetchFailureCount,failureReason:dt.fetchFailureReason,errorUpdateCount:dt.errorUpdateCount,isFetched:dt.dataUpdateCount>0||dt.errorUpdateCount>0,isFetchedAfterMount:dt.dataUpdateCount>ct.dataUpdateCount||dt.errorUpdateCount>ct.errorUpdateCount,isFetching:gt,isRefetching:gt&&!xt,isLoadingError:vt&&!Et,isPaused:dt.fetchStatus==="paused",isPlaceholderData:ht,isRefetchError:vt&&Et,isStale:isStale(et,tt),refetch:this.refetch,promise:Mt(this,fr)};if(this.options.experimental_prefetchInRender){const Rt=Ot=>{kt.status==="error"?Ot.reject(kt.error):kt.data!==void 0&&Ot.resolve(kt.data)},Pt=()=>{const Ot=un(this,fr,kt.promise=pendingThenable());Rt(Ot)},jt=Mt(this,fr);switch(jt.status){case"pending":et.queryHash===nt.queryHash&&Rt(jt);break;case"fulfilled":(kt.status==="error"||kt.data!==jt.value)&&Pt();break;case"rejected":(kt.status!=="error"||kt.error!==jt.reason)&&Pt();break}}return kt}updateResult(et){const tt=Mt(this,On),nt=this.createResult(Mt(this,Sn),this.options);if(un(this,_r,Mt(this,Sn).state),un(this,Hr,this.options),Mt(this,_r).data!==void 0&&un(this,Gr,Mt(this,Sn)),shallowEqualObjects(nt,tt))return;un(this,On,nt);const rt={},ot=()=>{if(!tt)return!0;const{notifyOnChangeProps:it}=this.options,st=typeof it=="function"?it():it;if(st==="all"||!st&&!Mt(this,qr).size)return!0;const at=new Set(st??Mt(this,qr));return this.options.throwOnError&&at.add("error"),Object.keys(Mt(this,On)).some(ct=>{const lt=ct;return Mt(this,On)[lt]!==tt[lt]&&at.has(lt)})};(et==null?void 0:et.listeners)!==!1&&ot()&&(rt.listeners=!0),gn(this,In,Ql).call(this,{...rt,...et})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&gn(this,In,Ts).call(this)}},Mn=new WeakMap,Sn=new WeakMap,oo=new WeakMap,On=new WeakMap,_r=new WeakMap,Hr=new WeakMap,fr=new WeakMap,Kn=new WeakMap,io=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Ir=new WeakMap,Tr=new WeakMap,mr=new WeakMap,qr=new WeakMap,In=new WeakSet,to=function(et){gn(this,In,Ns).call(this);let tt=Mt(this,Sn).fetch(this.options,et);return et!=null&&et.throwOnError||(tt=tt.catch(noop$4)),tt},Rs=function(){gn(this,In,Ps).call(this);const et=resolveStaleTime(this.options.staleTime,Mt(this,Sn));if(isServer||Mt(this,On).isStale||!isValidTimeout(et))return;const nt=timeUntilStale(Mt(this,On).dataUpdatedAt,et)+1;un(this,Ir,setTimeout(()=>{Mt(this,On).isStale||this.updateResult()},nt))},_s=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Mt(this,Sn)):this.options.refetchInterval)??!1},Is=function(et){gn(this,In,Ls).call(this),un(this,mr,et),!(isServer||resolveEnabled(this.options.enabled,Mt(this,Sn))===!1||!isValidTimeout(Mt(this,mr))||Mt(this,mr)===0)&&un(this,Tr,setInterval(()=>{(this.options.refetchIntervalInBackground||focusManager.isFocused())&&gn(this,In,to).call(this)},Mt(this,mr)))},Ts=function(){gn(this,In,Rs).call(this),gn(this,In,Is).call(this,gn(this,In,_s).call(this))},Ps=function(){Mt(this,Ir)&&(clearTimeout(Mt(this,Ir)),un(this,Ir,void 0))},Ls=function(){Mt(this,Tr)&&(clearInterval(Mt(this,Tr)),un(this,Tr,void 0))},Ns=function(){const et=Mt(this,Mn).getQueryCache().build(Mt(this,Mn),this.options);if(et===Mt(this,Sn))return;const tt=Mt(this,Sn);un(this,Sn,et),un(this,oo,et.state),this.hasListeners()&&(tt==null||tt.removeObserver(this),et.addObserver(this))},Ql=function(et){notifyManager.batch(()=>{et.listeners&&this.listeners.forEach(tt=>{tt(Mt(this,On))}),Mt(this,Mn).getQueryCache().notify({query:Mt(this,Sn),type:"observerResultsUpdated"})})},qs);function shouldLoadOnMount(o,et){return resolveEnabled(et.enabled,o)!==!1&&o.state.data===void 0&&!(o.state.status==="error"&&et.retryOnMount===!1)}function shouldFetchOnMount(o,et){return shouldLoadOnMount(o,et)||o.state.data!==void 0&&shouldFetchOn(o,et,et.refetchOnMount)}function shouldFetchOn(o,et,tt){if(resolveEnabled(et.enabled,o)!==!1){const nt=typeof tt=="function"?tt(o):tt;return nt==="always"||nt!==!1&&isStale(o,et)}return!1}function shouldFetchOptionally(o,et,tt,nt){return(o!==et||resolveEnabled(nt.enabled,o)===!1)&&(!tt.suspense||o.state.status!=="error")&&isStale(o,tt)}function isStale(o,et){return resolveEnabled(et.enabled,o)!==!1&&o.isStaleByTime(resolveStaleTime(et.staleTime,o))}function shouldAssignObserverCurrentProperties(o,et){return!shallowEqualObjects(o.getCurrentResult(),et)}var gr,yr,Bn,rr,sr,Yo,js,Ks,MutationObserver$1=(Ks=class extends Subscribable{constructor(tt,nt){super();fn(this,sr);fn(this,gr);fn(this,yr);fn(this,Bn);fn(this,rr);un(this,gr,tt),this.setOptions(nt),this.bindMethods(),gn(this,sr,Yo).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(tt){var rt;const nt=this.options;this.options=Mt(this,gr).defaultMutationOptions(tt),shallowEqualObjects(this.options,nt)||Mt(this,gr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Mt(this,Bn),observer:this}),nt!=null&&nt.mutationKey&&this.options.mutationKey&&hashKey(nt.mutationKey)!==hashKey(this.options.mutationKey)?this.reset():((rt=Mt(this,Bn))==null?void 0:rt.state.status)==="pending"&&Mt(this,Bn).setOptions(this.options)}onUnsubscribe(){var tt;this.hasListeners()||(tt=Mt(this,Bn))==null||tt.removeObserver(this)}onMutationUpdate(tt){gn(this,sr,Yo).call(this),gn(this,sr,js).call(this,tt)}getCurrentResult(){return Mt(this,yr)}reset(){var tt;(tt=Mt(this,Bn))==null||tt.removeObserver(this),un(this,Bn,void 0),gn(this,sr,Yo).call(this),gn(this,sr,js).call(this)}mutate(tt,nt){var rt;return un(this,rr,nt),(rt=Mt(this,Bn))==null||rt.removeObserver(this),un(this,Bn,Mt(this,gr).getMutationCache().build(Mt(this,gr),this.options)),Mt(this,Bn).addObserver(this),Mt(this,Bn).execute(tt)}},gr=new WeakMap,yr=new WeakMap,Bn=new WeakMap,rr=new WeakMap,sr=new WeakSet,Yo=function(){var nt;const tt=((nt=Mt(this,Bn))==null?void 0:nt.state)??getDefaultState();un(this,yr,{...tt,isPending:tt.status==="pending",isSuccess:tt.status==="success",isError:tt.status==="error",isIdle:tt.status==="idle",mutate:this.mutate,reset:this.reset})},js=function(tt){notifyManager.batch(()=>{var nt,rt,ot,it,st,at,ct,lt;if(Mt(this,rr)&&this.hasListeners()){const dt=Mt(this,yr).variables,ht=Mt(this,yr).context;(tt==null?void 0:tt.type)==="success"?((rt=(nt=Mt(this,rr)).onSuccess)==null||rt.call(nt,tt.data,dt,ht),(it=(ot=Mt(this,rr)).onSettled)==null||it.call(ot,tt.data,null,dt,ht)):(tt==null?void 0:tt.type)==="error"&&((at=(st=Mt(this,rr)).onError)==null||at.call(st,tt.error,dt,ht),(lt=(ct=Mt(this,rr)).onSettled)==null||lt.call(ct,void 0,tt.error,dt,ht))}this.listeners.forEach(dt=>{dt(Mt(this,yr))})})},Ks);function hashFn(o){return JSON.stringify(o,(et,tt)=>isPlainObject$2(tt)?Object.keys(tt).sort().reduce((nt,rt)=>(nt[rt]=tt[rt],nt),{}):typeof tt=="bigint"?tt.toString():tt)}function isPlainObject$2(o){if(!hasObjectPrototype(o))return!1;const et=o.constructor;if(typeof et>"u")return!0;const tt=et.prototype;return!(!hasObjectPrototype(tt)||!tt.hasOwnProperty("isPrototypeOf"))}function hasObjectPrototype(o){return Object.prototype.toString.call(o)==="[object Object]"}function filterQueryOptions(o){const{_defaulted:et,behavior:tt,gcTime:nt,initialData:rt,initialDataUpdatedAt:ot,maxPages:it,meta:st,networkMode:at,queryFn:ct,queryHash:lt,queryKey:dt,queryKeyHashFn:ht,retry:pt,retryDelay:mt,structuralSharing:ft,getPreviousPageParam:yt,getNextPageParam:gt,initialPageParam:xt,_optimisticResults:vt,enabled:bt,notifyOnChangeProps:Et,placeholderData:wt,refetchInterval:kt,refetchIntervalInBackground:It,refetchOnMount:Rt,refetchOnReconnect:Pt,refetchOnWindowFocus:jt,retryOnMount:Ot,select:Bt,staleTime:zt,suspense:Ft,throwOnError:Yt,config:Ht,connector:Ut,query:qt,...Lt}=o;return Lt}function connectMutationOptions(o){return{mutationFn(et){return connect$1(o,et)},mutationKey:["connect"]}}function disconnectMutationOptions(o){return{mutationFn(et){return disconnect(o,et)},mutationKey:["disconnect"]}}function getBalanceQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{address:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("address is required");return await getBalance(o,{...ot,address:nt})??null},queryKey:getBalanceQueryKey(et)}}function getBalanceQueryKey(o={}){return["balance",filterQueryOptions(o)]}function getBlockNumberQueryOptions(o,et={}){return{gcTime:0,async queryFn({queryKey:tt}){const{scopeKey:nt,...rt}=tt[1];return await getBlockNumber(o,rt)??null},queryKey:getBlockNumberQueryKey(et)}}function getBlockNumberQueryKey(o={}){return["blockNumber",filterQueryOptions(o)]}function getEnsAddressQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{name:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("name is required");return getEnsAddress(o,{...ot,name:nt})},queryKey:getEnsAddressQueryKey(et)}}function getEnsAddressQueryKey(o={}){return["ensAddress",filterQueryOptions(o)]}function getEnsAvatarQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{name:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("name is required");return getEnsAvatar(o,{...ot,name:nt})},queryKey:getEnsAvatarQueryKey(et)}}function getEnsAvatarQueryKey(o={}){return["ensAvatar",filterQueryOptions(o)]}function getEnsNameQueryOptions(o,et={}){return{async queryFn({queryKey:tt}){const{address:nt,scopeKey:rt,...ot}=tt[1];if(!nt)throw new Error("address is required");return getEnsName(o,{...ot,address:nt})},queryKey:getEnsNameQueryKey(et)}}function getEnsNameQueryKey(o={}){return["ensName",filterQueryOptions(o)]}function signMessageMutationOptions(o){return{mutationFn(et){return signMessage(o,et)},mutationKey:["signMessage"]}}function switchChainMutationOptions(o){return{mutationFn(et){return switchChain(o,et)},mutationKey:["switchChain"]}}var QueryClientContext=reactExports.createContext(void 0),useQueryClient=o=>{const et=reactExports.useContext(QueryClientContext);if(!et)throw new Error("No QueryClient set, use QueryClientProvider to set one");return et},QueryClientProvider=({client:o,children:et})=>(reactExports.useEffect(()=>(o.mount(),()=>{o.unmount()}),[o]),jsxRuntimeExports.jsx(QueryClientContext.Provider,{value:o,children:et})),IsRestoringContext=reactExports.createContext(!1),useIsRestoring=()=>reactExports.useContext(IsRestoringContext);IsRestoringContext.Provider;function createValue(){let o=!1;return{clearReset:()=>{o=!1},reset:()=>{o=!0},isReset:()=>o}}var QueryErrorResetBoundaryContext=reactExports.createContext(createValue()),useQueryErrorResetBoundary=()=>reactExports.useContext(QueryErrorResetBoundaryContext);function shouldThrowError(o,et){return typeof o=="function"?o(...et):!!o}function noop$3(){}var ensurePreventErrorBoundaryRetry=(o,et)=>{(o.suspense||o.throwOnError||o.experimental_prefetchInRender)&&(et.isReset()||(o.retryOnMount=!1))},useClearResetErrorBoundary=o=>{reactExports.useEffect(()=>{o.clearReset()},[o])},getHasError=({result:o,errorResetBoundary:et,throwOnError:tt,query:nt})=>o.isError&&!et.isReset()&&!o.isFetching&&nt&&shouldThrowError(tt,[o.error,nt]),ensureSuspenseTimers=o=>{o.suspense&&(o.staleTime===void 0&&(o.staleTime=1e3),typeof o.gcTime=="number"&&(o.gcTime=Math.max(o.gcTime,1e3)))},willFetch=(o,et)=>o.isLoading&&o.isFetching&&!et,shouldSuspend=(o,et)=>(o==null?void 0:o.suspense)&&et.isPending,fetchOptimistic=(o,et,tt)=>et.fetchOptimistic(o).catch(()=>{tt.clearReset()});function useBaseQuery(o,et,tt){var lt,dt,ht,pt,mt;const nt=useQueryClient(),rt=useIsRestoring(),ot=useQueryErrorResetBoundary(),it=nt.defaultQueryOptions(o);(dt=(lt=nt.getDefaultOptions().queries)==null?void 0:lt._experimental_beforeQuery)==null||dt.call(lt,it),it._optimisticResults=rt?"isRestoring":"optimistic",ensureSuspenseTimers(it),ensurePreventErrorBoundaryRetry(it,ot),useClearResetErrorBoundary(ot);const st=!nt.getQueryCache().get(it.queryHash),[at]=reactExports.useState(()=>new et(nt,it)),ct=at.getOptimisticResult(it);if(reactExports.useSyncExternalStore(reactExports.useCallback(ft=>{const yt=rt?()=>{}:at.subscribe(notifyManager.batchCalls(ft));return at.updateResult(),yt},[at,rt]),()=>at.getCurrentResult(),()=>at.getCurrentResult()),reactExports.useEffect(()=>{at.setOptions(it,{listeners:!1})},[it,at]),shouldSuspend(it,ct))throw fetchOptimistic(it,at,ot);if(getHasError({result:ct,errorResetBoundary:ot,throwOnError:it.throwOnError,query:nt.getQueryCache().get(it.queryHash)}))throw ct.error;if((pt=(ht=nt.getDefaultOptions().queries)==null?void 0:ht._experimental_afterQuery)==null||pt.call(ht,it,ct),it.experimental_prefetchInRender&&!isServer&&willFetch(ct,rt)){const ft=st?fetchOptimistic(it,at,ot):(mt=nt.getQueryCache().get(it.queryHash))==null?void 0:mt.promise;ft==null||ft.catch(noop$3).finally(()=>{at.updateResult()})}return it.notifyOnChangeProps?ct:at.trackResult(ct)}function useQuery$1(o,et){return useBaseQuery(o,QueryObserver)}function useMutation(o,et){const tt=useQueryClient(),[nt]=reactExports.useState(()=>new MutationObserver$1(tt,o));reactExports.useEffect(()=>{nt.setOptions(o)},[nt,o]);const rt=reactExports.useSyncExternalStore(reactExports.useCallback(it=>nt.subscribe(notifyManager.batchCalls(it)),[nt]),()=>nt.getCurrentResult(),()=>nt.getCurrentResult()),ot=reactExports.useCallback((it,st)=>{nt.mutate(it,st).catch(noop$3)},[nt]);if(rt.error&&shouldThrowError(nt.options.throwOnError,[rt.error]))throw rt.error;return{...rt,mutate:ot,mutateAsync:rt.mutate}}function useQuery(o){const et=useQuery$1({...o,queryKeyHashFn:hashFn});return et.queryKey=o.queryKey,et}function useChainId(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchChainId(et,{onChange:tt}),()=>getChainId(et),()=>getChainId(et))}function useBalance(o={}){const{address:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getBalanceQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useWatchBlockNumber(o={}){const{enabled:et=!0,onBlockNumber:tt,config:nt,...rt}=o,ot=useConfig(o),it=useChainId({config:ot}),st=o.chainId??it;reactExports.useEffect(()=>{if(et&&tt)return watchBlockNumber(ot,{...rt,chainId:st,onBlockNumber:tt})},[st,ot,et,tt,rt.onError,rt.emitMissed,rt.emitOnBegin,rt.poll,rt.pollingInterval,rt.syncConnectedChain])}function useBlockNumber(o={}){const{query:et={},watch:tt}=o,nt=useConfig(o),rt=useQueryClient(),ot=useChainId({config:nt}),it=o.chainId??ot,st=getBlockNumberQueryOptions(nt,{...o,chainId:it});return useWatchBlockNumber({config:o.config,chainId:o.chainId,...typeof tt=="object"?tt:{},enabled:!!((et.enabled??!0)&&(typeof tt=="object"?tt.enabled:tt)),onBlockNumber(at){rt.setQueryData(st.queryKey,at)}}),useQuery({...et,...st})}function useChains$1(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchChains(et,{onChange:tt}),()=>getChains(et),()=>getChains(et))}function useConnectors$1(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchConnectors(et,{onChange:tt}),()=>getConnectors(et),()=>getConnectors(et))}function useConnect$1(o={}){const{mutation:et}=o,tt=useConfig(o),nt=connectMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return reactExports.useEffect(()=>tt.subscribe(({status:st})=>st,(st,at)=>{at==="connected"&&st==="disconnected"&&it.reset()}),[tt,it.reset]),{...it,connect:rt,connectAsync:ot,connectors:useConnectors$1({config:tt})}}function useConnections(o={}){const et=useConfig(o);return reactExports.useSyncExternalStore(tt=>watchConnections(et,{onChange:tt}),()=>getConnections(et),()=>getConnections(et))}function useDisconnect(o={}){const{mutation:et}=o,tt=useConfig(o),nt=disconnectMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return{...it,connectors:useConnections({config:tt}).map(st=>st.connector),disconnect:rt,disconnectAsync:ot}}function useEnsAddress(o={}){const{name:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getEnsAddressQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsAvatar(o={}){const{name:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getEnsAvatarQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useEnsName(o={}){const{address:et,query:tt={}}=o,nt=useConfig(o),rt=useChainId({config:nt}),ot=getEnsNameQueryOptions(nt,{...o,chainId:o.chainId??rt}),it=!!(et&&(tt.enabled??!0));return useQuery({...tt,...ot,enabled:it})}function useSignMessage(o={}){const{mutation:et}=o,tt=useConfig(o),nt=signMessageMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return{...it,signMessage:rt,signMessageAsync:ot}}function useSwitchChain(o={}){const{mutation:et}=o,tt=useConfig(o),nt=switchChainMutationOptions(tt),{mutate:rt,mutateAsync:ot,...it}=useMutation({...et,...nt});return{...it,chains:useChains$1({config:tt}),switchChain:rt,switchChainAsync:ot}}const contracts={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters={block:defineBlock({format(o){var tt;return{transactions:(tt=o.transactions)==null?void 0:tt.map(nt=>{if(typeof nt=="string")return nt;const rt=formatTransaction(nt);return rt.typeHex==="0x7e"&&(rt.isSystemTx=nt.isSystemTx,rt.mint=nt.mint?hexToBigInt(nt.mint):void 0,rt.sourceHash=nt.sourceHash,rt.type="deposit"),rt}),stateRoot:o.stateRoot}}}),transaction:defineTransaction({format(o){const et={};return o.type==="0x7e"&&(et.isSystemTx=o.isSystemTx,et.mint=o.mint?hexToBigInt(o.mint):void 0,et.sourceHash=o.sourceHash,et.type="deposit"),et}}),transactionReceipt:defineTransactionReceipt({format(o){return{l1GasPrice:o.l1GasPrice?hexToBigInt(o.l1GasPrice):null,l1GasUsed:o.l1GasUsed?hexToBigInt(o.l1GasUsed):null,l1Fee:o.l1Fee?hexToBigInt(o.l1Fee):null,l1FeeScalar:o.l1FeeScalar?Number(o.l1FeeScalar):null}}})};function serializeTransaction(o,et){return isDeposit(o)?serializeTransactionDeposit(o):serializeTransaction$1(o,et)}const serializers={transaction:serializeTransaction};function serializeTransactionDeposit(o){assertTransactionDeposit(o);const{sourceHash:et,data:tt,from:nt,gas:rt,isSystemTx:ot,mint:it,to:st,value:at}=o,ct=[et,nt,st??"0x",it?toHex(it):"0x",at?toHex(at):"0x",rt?toHex(rt):"0x",ot?"0x1":"0x",tt??"0x"];return concatHex(["0x7e",toRlp(ct)])}function isDeposit(o){return o.type==="deposit"||typeof o.sourceHash<"u"}function assertTransactionDeposit(o){const{from:et,to:tt}=o;if(et&&!isAddress(et))throw new InvalidAddressError({address:et});if(tt&&!isAddress(tt))throw new InvalidAddressError({address:tt})}const chainConfig={contracts,formatters,serializers},arbitrum=defineChain({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),mainnet=defineChain({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),sourceId=1,optimism=defineChain({...chainConfig,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...chainConfig.contracts,disputeGameFactory:{[sourceId]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[sourceId]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[sourceId]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[sourceId]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId}),polygon=defineChain({id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}});coinbaseWallet.type="coinbaseWallet";function coinbaseWallet(o={}){return o.version==="3"||o.headlessMode?version3(o):version4(o)}function version4(o){let et,tt,nt,rt,ot;return it=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:st}={}){try{const at=await this.getProvider(),ct=(await at.request({method:"eth_requestAccounts"})).map(dt=>getAddress(dt));nt||(nt=this.onAccountsChanged.bind(this),at.on("accountsChanged",nt)),rt||(rt=this.onChainChanged.bind(this),at.on("chainChanged",rt)),ot||(ot=this.onDisconnect.bind(this),at.on("disconnect",ot));let lt=await this.getChainId();if(st&<!==st){const dt=await this.switchChain({chainId:st}).catch(ht=>{if(ht.code===UserRejectedRequestError.code)throw ht;return{id:lt}});lt=(dt==null?void 0:dt.id)??lt}return{accounts:ct,chainId:lt}}catch(at){throw/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(at.message)?new UserRejectedRequestError(at):at}},async disconnect(){var at;const st=await this.getProvider();nt&&(st.removeListener("accountsChanged",nt),nt=void 0),rt&&(st.removeListener("chainChanged",rt),rt=void 0),ot&&(st.removeListener("disconnect",ot),ot=void 0),st.disconnect(),(at=st.close)==null||at.call(st)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(at=>getAddress(at))},async getChainId(){const at=await(await this.getProvider()).request({method:"eth_chainId"});return Number(at)},async getProvider(){if(!tt){const st=await(async()=>{const at=await __vitePreload(()=>import("./index-BhnqxX7Q.js"),__vite__mapDeps([0,1]));return typeof at.CoinbaseWalletSDK!="function"&&typeof at.default=="function"?at.default:at.CoinbaseWalletSDK})();et=new st({...o,appChainIds:it.chains.map(at=>at.id)}),tt=et.makeWeb3Provider({...o,options:o.preference??"all"})}return tt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:st,chainId:at}){var dt,ht,pt,mt;const ct=it.chains.find(ft=>ft.id===at);if(!ct)throw new SwitchChainError(new ChainNotConfiguredError);const lt=await this.getProvider();try{return await lt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(ct.id)}]}),ct}catch(ft){if(ft.code===4902)try{let yt;st!=null&&st.blockExplorerUrls?yt=st.blockExplorerUrls:yt=(dt=ct.blockExplorers)!=null&&dt.default.url?[(ht=ct.blockExplorers)==null?void 0:ht.default.url]:[];let gt;(pt=st==null?void 0:st.rpcUrls)!=null&&pt.length?gt=st.rpcUrls:gt=[((mt=ct.rpcUrls.default)==null?void 0:mt.http[0])??""];const xt={blockExplorerUrls:yt,chainId:numberToHex(at),chainName:(st==null?void 0:st.chainName)??ct.name,iconUrls:st==null?void 0:st.iconUrls,nativeCurrency:(st==null?void 0:st.nativeCurrency)??ct.nativeCurrency,rpcUrls:gt};return await lt.request({method:"wallet_addEthereumChain",params:[xt]}),ct}catch(yt){throw new UserRejectedRequestError(yt)}throw new SwitchChainError(ft)}},onAccountsChanged(st){st.length===0?this.onDisconnect():it.emitter.emit("change",{accounts:st.map(at=>getAddress(at))})},onChainChanged(st){const at=Number(st);it.emitter.emit("change",{chainId:at})},async onDisconnect(st){it.emitter.emit("disconnect");const at=await this.getProvider();nt&&(at.removeListener("accountsChanged",nt),nt=void 0),rt&&(at.removeListener("chainChanged",rt),rt=void 0),ot&&(at.removeListener("disconnect",ot),ot=void 0)}})}function version3(o){let tt,nt,rt,ot,it;return st=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",supportsSimulation:!0,type:coinbaseWallet.type,async connect({chainId:at}={}){try{const ct=await this.getProvider(),lt=(await ct.request({method:"eth_requestAccounts"})).map(ht=>getAddress(ht));rt||(rt=this.onAccountsChanged.bind(this),ct.on("accountsChanged",rt)),ot||(ot=this.onChainChanged.bind(this),ct.on("chainChanged",ot)),it||(it=this.onDisconnect.bind(this),ct.on("disconnect",it));let dt=await this.getChainId();if(at&&dt!==at){const ht=await this.switchChain({chainId:at}).catch(pt=>{if(pt.code===UserRejectedRequestError.code)throw pt;return{id:dt}});dt=(ht==null?void 0:ht.id)??dt}return{accounts:lt,chainId:dt}}catch(ct){throw/(user closed modal|accounts received is empty|user denied account)/i.test(ct.message)?new UserRejectedRequestError(ct):ct}},async disconnect(){const at=await this.getProvider();rt&&(at.removeListener("accountsChanged",rt),rt=void 0),ot&&(at.removeListener("chainChanged",ot),ot=void 0),it&&(at.removeListener("disconnect",it),it=void 0),at.disconnect(),at.close()},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(ct=>getAddress(ct))},async getChainId(){const ct=await(await this.getProvider()).request({method:"eth_chainId"});return Number(ct)},async getProvider(){var at;if(!nt){const ct=await(async()=>{const{default:mt}=await __vitePreload(async()=>{const{default:ft}=await import("./index-BE2r4h4L.js").then(yt=>yt.i);return{default:ft}},__vite__mapDeps([2,3,1,4]));return typeof mt!="function"&&typeof mt.default=="function"?mt.default:mt})();tt=new ct({...o,reloadOnDisconnect:!1});const lt=(at=tt.walletExtension)==null?void 0:at.getChainId(),dt=st.chains.find(mt=>o.chainId?mt.id===o.chainId:mt.id===lt)||st.chains[0],ht=o.chainId||(dt==null?void 0:dt.id),pt=o.jsonRpcUrl||(dt==null?void 0:dt.rpcUrls.default.http[0]);nt=tt.makeWeb3Provider(pt,ht)}return nt},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:at,chainId:ct}){var ht,pt,mt,ft;const lt=st.chains.find(yt=>yt.id===ct);if(!lt)throw new SwitchChainError(new ChainNotConfiguredError);const dt=await this.getProvider();try{return await dt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(lt.id)}]}),lt}catch(yt){if(yt.code===4902)try{let gt;at!=null&&at.blockExplorerUrls?gt=at.blockExplorerUrls:gt=(ht=lt.blockExplorers)!=null&&ht.default.url?[(pt=lt.blockExplorers)==null?void 0:pt.default.url]:[];let xt;(mt=at==null?void 0:at.rpcUrls)!=null&&mt.length?xt=at.rpcUrls:xt=[((ft=lt.rpcUrls.default)==null?void 0:ft.http[0])??""];const vt={blockExplorerUrls:gt,chainId:numberToHex(ct),chainName:(at==null?void 0:at.chainName)??lt.name,iconUrls:at==null?void 0:at.iconUrls,nativeCurrency:(at==null?void 0:at.nativeCurrency)??lt.nativeCurrency,rpcUrls:xt};return await dt.request({method:"wallet_addEthereumChain",params:[vt]}),lt}catch(gt){throw new UserRejectedRequestError(gt)}throw new SwitchChainError(yt)}},onAccountsChanged(at){at.length===0?this.onDisconnect():st.emitter.emit("change",{accounts:at.map(ct=>getAddress(ct))})},onChainChanged(at){const ct=Number(at);st.emitter.emit("change",{chainId:ct})},async onDisconnect(at){st.emitter.emit("disconnect");const ct=await this.getProvider();rt&&(ct.removeListener("accountsChanged",rt),rt=void 0),ot&&(ct.removeListener("chainChanged",ot),ot=void 0),it&&(ct.removeListener("disconnect",it),it=void 0)}})}safe.type="safe";function safe(o={}){const{shimDisconnect:et=!1}=o;let tt,nt;return rt=>({id:"safe",name:"Safe",type:safe.type,async connect(){var at;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;const it=await this.getAccounts(),st=await this.getChainId();return nt||(nt=this.onDisconnect.bind(this),ot.on("disconnect",nt)),et&&await((at=rt.storage)==null?void 0:at.removeItem("safe.disconnected")),{accounts:it,chainId:st}},async disconnect(){var it;const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;nt&&(ot.removeListener("disconnect",nt),nt=void 0),et&&await((it=rt.storage)==null?void 0:it.setItem("safe.disconnected",!0))},async getAccounts(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return(await ot.request({method:"eth_accounts"})).map(getAddress)},async getProvider(){if(typeof window<"u"&&(window==null?void 0:window.parent)!==window){if(!tt){const{default:it}=await __vitePreload(async()=>{const{default:lt}=await import("./index-Ctx71FWU.js");return{default:lt}},[]),st=new it(o),at=await withTimeout(()=>st.safe.getInfo(),{timeout:o.unstable_getInfoTimeout??10});if(!at)throw new Error("Could not load Safe information");const ct=await(async()=>{const lt=await __vitePreload(()=>import("./index-DskNhwDJ.js").then(dt=>dt.i),__vite__mapDeps([5,4]));return typeof lt.SafeAppProvider!="function"&&typeof lt.default.SafeAppProvider=="function"?lt.default.SafeAppProvider:lt.SafeAppProvider})();tt=new ct(at,st)}return tt}},async getChainId(){const ot=await this.getProvider();if(!ot)throw new ProviderNotFoundError;return Number(ot.chainId)},async isAuthorized(){var ot;try{return et&&await((ot=rt.storage)==null?void 0:ot.getItem("safe.disconnected"))?!1:!!(await this.getAccounts()).length}catch{return!1}},onAccountsChanged(){},onChainChanged(){},onDisconnect(){rt.emitter.emit("disconnect")}})}walletConnect.type="walletConnect";function walletConnect(o){const et=o.isNewChainsStale??!0;let tt,nt;const rt="eip155";let ot,it,st,at,ct,lt;return dt=>({id:"walletConnect",name:"WalletConnect",type:walletConnect.type,async setup(){const ht=await this.getProvider().catch(()=>null);ht&&(st||(st=this.onConnect.bind(this),ht.on("connect",st)),ct||(ct=this.onSessionDelete.bind(this),ht.on("session_delete",ct)))},async connect({chainId:ht,...pt}={}){var mt,ft;try{const yt=await this.getProvider();if(!yt)throw new ProviderNotFoundError;at||(at=this.onDisplayUri,yt.on("display_uri",at));let gt=ht;if(!gt){const Et=await((mt=dt.storage)==null?void 0:mt.getItem("state"))??{};dt.chains.some(kt=>kt.id===Et.chainId)?gt=Et.chainId:gt=(ft=dt.chains[0])==null?void 0:ft.id}if(!gt)throw new Error("No chains found on connector.");const xt=await this.isChainsStale();if(yt.session&&xt&&await yt.disconnect(),!yt.session||xt){const Et=dt.chains.filter(wt=>wt.id!==gt).map(wt=>wt.id);await yt.connect({optionalChains:[gt,...Et],..."pairingTopic"in pt?{pairingTopic:pt.pairingTopic}:{}}),this.setRequestedChainsIds(dt.chains.map(wt=>wt.id))}const vt=(await yt.enable()).map(Et=>getAddress(Et)),bt=await this.getChainId();return at&&(yt.removeListener("display_uri",at),at=void 0),st&&(yt.removeListener("connect",st),st=void 0),ot||(ot=this.onAccountsChanged.bind(this),yt.on("accountsChanged",ot)),it||(it=this.onChainChanged.bind(this),yt.on("chainChanged",it)),lt||(lt=this.onDisconnect.bind(this),yt.on("disconnect",lt)),ct||(ct=this.onSessionDelete.bind(this),yt.on("session_delete",ct)),{accounts:vt,chainId:bt}}catch(yt){throw/(user rejected|connection request reset)/i.test(yt==null?void 0:yt.message)?new UserRejectedRequestError(yt):yt}},async disconnect(){const ht=await this.getProvider();try{await(ht==null?void 0:ht.disconnect())}catch(pt){if(!/No matching key/i.test(pt.message))throw pt}finally{it&&(ht==null||ht.removeListener("chainChanged",it),it=void 0),lt&&(ht==null||ht.removeListener("disconnect",lt),lt=void 0),st||(st=this.onConnect.bind(this),ht==null||ht.on("connect",st)),ot&&(ht==null||ht.removeListener("accountsChanged",ot),ot=void 0),ct&&(ht==null||ht.removeListener("session_delete",ct),ct=void 0),this.setRequestedChainsIds([])}},async getAccounts(){return(await this.getProvider()).accounts.map(pt=>getAddress(pt))},async getProvider({chainId:ht}={}){var mt;async function pt(){const ft=dt.chains.map(gt=>gt.id);if(!ft.length)return;const{EthereumProvider:yt}=await __vitePreload(async()=>{const{EthereumProvider:gt}=await import("./index.es-BwINMB1n.js");return{EthereumProvider:gt}},__vite__mapDeps([6,4,3]));return await yt.init({...o,disableProviderPing:!0,optionalChains:ft,projectId:o.projectId,rpcMap:Object.fromEntries(dt.chains.map(gt=>{const[xt]=extractRpcUrls({chain:gt,transports:dt.transports});return[gt.id,xt]})),showQrModal:o.showQrModal??!0})}return tt||(nt||(nt=pt()),tt=await nt,tt==null||tt.events.setMaxListeners(Number.POSITIVE_INFINITY)),ht&&await((mt=this.switchChain)==null?void 0:mt.call(this,{chainId:ht})),tt},async getChainId(){return(await this.getProvider()).chainId},async isAuthorized(){try{const[ht,pt]=await Promise.all([this.getAccounts(),this.getProvider()]);return ht.length?await this.isChainsStale()&&pt.session?(await pt.disconnect().catch(()=>{}),!1):!0:!1}catch{return!1}},async switchChain({addEthereumChainParameter:ht,chainId:pt}){var yt,gt,xt;const mt=await this.getProvider();if(!mt)throw new ProviderNotFoundError;const ft=dt.chains.find(vt=>vt.id===pt);if(!ft)throw new SwitchChainError(new ChainNotConfiguredError);try{await Promise.all([new Promise(bt=>{const Et=({chainId:wt})=>{wt===pt&&(dt.emitter.off("change",Et),bt())};dt.emitter.on("change",Et)}),mt.request({method:"wallet_switchEthereumChain",params:[{chainId:numberToHex(pt)}]})]);const vt=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...vt,pt]),ft}catch(vt){const bt=vt;if(/(user rejected)/i.test(bt.message))throw new UserRejectedRequestError(bt);try{let Et;ht!=null&&ht.blockExplorerUrls?Et=ht.blockExplorerUrls:Et=(yt=ft.blockExplorers)!=null&&yt.default.url?[(gt=ft.blockExplorers)==null?void 0:gt.default.url]:[];let wt;(xt=ht==null?void 0:ht.rpcUrls)!=null&&xt.length?wt=ht.rpcUrls:wt=[...ft.rpcUrls.default.http];const kt={blockExplorerUrls:Et,chainId:numberToHex(pt),chainName:(ht==null?void 0:ht.chainName)??ft.name,iconUrls:ht==null?void 0:ht.iconUrls,nativeCurrency:(ht==null?void 0:ht.nativeCurrency)??ft.nativeCurrency,rpcUrls:wt};await mt.request({method:"wallet_addEthereumChain",params:[kt]});const It=await this.getRequestedChainsIds();return this.setRequestedChainsIds([...It,pt]),ft}catch(Et){throw new UserRejectedRequestError(Et)}}},onAccountsChanged(ht){ht.length===0?this.onDisconnect():dt.emitter.emit("change",{accounts:ht.map(pt=>getAddress(pt))})},onChainChanged(ht){const pt=Number(ht);dt.emitter.emit("change",{chainId:pt})},async onConnect(ht){const pt=Number(ht.chainId),mt=await this.getAccounts();dt.emitter.emit("connect",{accounts:mt,chainId:pt})},async onDisconnect(ht){this.setRequestedChainsIds([]),dt.emitter.emit("disconnect");const pt=await this.getProvider();ot&&(pt.removeListener("accountsChanged",ot),ot=void 0),it&&(pt.removeListener("chainChanged",it),it=void 0),lt&&(pt.removeListener("disconnect",lt),lt=void 0),ct&&(pt.removeListener("session_delete",ct),ct=void 0),st||(st=this.onConnect.bind(this),pt.on("connect",st))},onDisplayUri(ht){dt.emitter.emit("message",{type:"display_uri",data:ht})},onSessionDelete(){this.onDisconnect()},getNamespaceChainsIds(){var pt,mt,ft;return tt?((ft=(mt=(pt=tt.session)==null?void 0:pt.namespaces[rt])==null?void 0:mt.accounts)==null?void 0:ft.map(yt=>Number.parseInt(yt.split(":")[1]||"")))??[]:[]},async getRequestedChainsIds(){var ht;return await((ht=dt.storage)==null?void 0:ht.getItem(this.requestedChainsStorageKey))??[]},async isChainsStale(){if(!et)return!1;const ht=dt.chains.map(ft=>ft.id),pt=this.getNamespaceChainsIds();if(pt.length&&!pt.some(ft=>ht.includes(ft)))return!1;const mt=await this.getRequestedChainsIds();return!ht.every(ft=>mt.includes(ft))},async setRequestedChainsIds(ht){var pt;await((pt=dt.storage)==null?void 0:pt.setItem(this.requestedChainsStorageKey,ht))},get requestedChainsStorageKey(){return`${this.id}.requestedChains`}})}var define_process_default$3={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},__spreadArray$1=function(o,et,tt){for(var nt=0,rt=et.length,ot;nt"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(o){return o!==""&&userAgentRules.reduce(function(et,tt){var nt=tt[0],rt=tt[1];if(et)return et;var ot=rt.exec(o);return!!ot&&[nt,ot]},!1)}function parseUserAgent(o){var et=matchUserAgent(o);if(!et)return null;var tt=et[0],nt=et[1];if(tt==="searchbot")return new BotInfo;var rt=nt[1]&&nt[1].split(".").join("_").split("_").slice(0,3);rt?rt.length=0;st--)(it=o[st])&&(ot=(rt<3?it(ot):rt>3?it(et,tt,ot):it(et,tt))||ot);return rt>3&&ot&&Object.defineProperty(et,tt,ot),ot}function __param(o,et){return function(tt,nt){et(tt,nt,o)}}function __esDecorate(o,et,tt,nt,rt,ot){function it(gt){if(gt!==void 0&&typeof gt!="function")throw new TypeError("Function expected");return gt}for(var st=nt.kind,at=st==="getter"?"get":st==="setter"?"set":"value",ct=!et&&o?nt.static?o:o.prototype:null,lt=et||(ct?Object.getOwnPropertyDescriptor(ct,nt.name):{}),dt,ht=!1,pt=tt.length-1;pt>=0;pt--){var mt={};for(var ft in nt)mt[ft]=ft==="access"?{}:nt[ft];for(var ft in nt.access)mt.access[ft]=nt.access[ft];mt.addInitializer=function(gt){if(ht)throw new TypeError("Cannot add initializers after decoration has completed");ot.push(it(gt||null))};var yt=(0,tt[pt])(st==="accessor"?{get:lt.get,set:lt.set}:lt[at],mt);if(st==="accessor"){if(yt===void 0)continue;if(yt===null||typeof yt!="object")throw new TypeError("Object expected");(dt=it(yt.get))&&(lt.get=dt),(dt=it(yt.set))&&(lt.set=dt),(dt=it(yt.init))&&rt.unshift(dt)}else(dt=it(yt))&&(st==="field"?rt.unshift(dt):lt[at]=dt)}ct&&Object.defineProperty(ct,nt.name,lt),ht=!0}function __runInitializers(o,et,tt){for(var nt=arguments.length>2,rt=0;rt0&&ot[ot.length-1])&&(ct[0]===6||ct[0]===2)){tt=0;continue}if(ct[0]===3&&(!ot||ct[1]>ot[0]&&ct[1]=o.length&&(o=void 0),{value:o&&o[nt++],done:!o}}};throw new TypeError(et?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(o,et){var tt=typeof Symbol=="function"&&o[Symbol.iterator];if(!tt)return o;var nt=tt.call(o),rt,ot=[],it;try{for(;(et===void 0||et-- >0)&&!(rt=nt.next()).done;)ot.push(rt.value)}catch(st){it={error:st}}finally{try{rt&&!rt.done&&(tt=nt.return)&&tt.call(nt)}finally{if(it)throw it.error}}return ot}function __spread(){for(var o=[],et=0;et1||at(pt,ft)})},mt&&(rt[pt]=mt(rt[pt])))}function at(pt,mt){try{ct(nt[pt](mt))}catch(ft){ht(ot[0][3],ft)}}function ct(pt){pt.value instanceof __await?Promise.resolve(pt.value.v).then(lt,dt):ht(ot[0][2],pt)}function lt(pt){at("next",pt)}function dt(pt){at("throw",pt)}function ht(pt,mt){pt(mt),ot.shift(),ot.length&&at(ot[0][0],ot[0][1])}}function __asyncDelegator(o){var et,tt;return et={},nt("next"),nt("throw",function(rt){throw rt}),nt("return"),et[Symbol.iterator]=function(){return this},et;function nt(rt,ot){et[rt]=o[rt]?function(it){return(tt=!tt)?{value:__await(o[rt](it)),done:!1}:ot?ot(it):it}:ot}}function __asyncValues(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var et=o[Symbol.asyncIterator],tt;return et?et.call(o):(o=typeof __values=="function"?__values(o):o[Symbol.iterator](),tt={},nt("next"),nt("throw"),nt("return"),tt[Symbol.asyncIterator]=function(){return this},tt);function nt(ot){tt[ot]=o[ot]&&function(it){return new Promise(function(st,at){it=o[ot](it),rt(st,at,it.done,it.value)})}}function rt(ot,it,st,at){Promise.resolve(at).then(function(ct){ot({value:ct,done:st})},it)}}function __makeTemplateObject(o,et){return Object.defineProperty?Object.defineProperty(o,"raw",{value:et}):o.raw=et,o}var __setModuleDefault=Object.create?function(o,et){Object.defineProperty(o,"default",{enumerable:!0,value:et})}:function(o,et){o.default=et},ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(et){var tt=[];for(var nt in et)Object.prototype.hasOwnProperty.call(et,nt)&&(tt[tt.length]=nt);return tt},ownKeys(o)};function __importStar(o){if(o&&o.__esModule)return o;var et={};if(o!=null)for(var tt=ownKeys(o),nt=0;nt"u"||define_process_env_default$1===void 0?defaultEnvironment:"production",createDefinition=function(o){return{isEnabled:function(et){return o.some(function(tt){return!!et[tt]})}}},featureDefinitions={measureLayout:createDefinition(["layout","layoutId","drag"]),animation:createDefinition(["animate","exit","variants","whileHover","whileTap","whileFocus","whileDrag","whileInView"]),exit:createDefinition(["exit"]),drag:createDefinition(["drag","dragControls"]),focus:createDefinition(["whileFocus"]),hover:createDefinition(["whileHover","onHoverStart","onHoverEnd"]),tap:createDefinition(["whileTap","onTap","onTapStart","onTapCancel"]),pan:createDefinition(["onPan","onPanStart","onPanSessionStart","onPanEnd"]),inView:createDefinition(["whileInView","onViewportEnter","onViewportLeave"])};function loadFeatures(o){for(var et in o)o[et]!==null&&(et==="projectionNodeConstructor"?featureDefinitions.projectionNodeConstructor=o[et]:featureDefinitions[et].Component=o[et])}var invariant$1=function(){},LazyContext=reactExports.createContext({strict:!1}),featureNames=Object.keys(featureDefinitions),numFeatures=featureNames.length;function useFeatures(o,et,tt){var nt=[],rt=reactExports.useContext(LazyContext);if(!et)return null;env$1!=="production"&&tt&&rt.strict;for(var ot=0;ot"u")return et;var tt=new Map;return new Proxy(et,{get:function(nt,rt){return tt.has(rt)||tt.set(rt,et(rt)),tt.get(rt)}})}var lowercaseSVGElements=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","svg","switch","symbol","text","tspan","use","view"];function isSVGComponent(o){return typeof o!="string"||o.includes("-")?!1:!!(lowercaseSVGElements.indexOf(o)>-1||/[A-Z]/.test(o))}var scaleCorrectors={};function addScaleCorrector(o){Object.assign(scaleCorrectors,o)}var transformAxes=["","X","Y","Z"],order$1=["translate","scale","rotate","skew"],transformProps=["transformPerspective","x","y","z"];order$1.forEach(function(o){return transformAxes.forEach(function(et){return transformProps.push(o+et)})});function sortTransformProps(o,et){return transformProps.indexOf(o)-transformProps.indexOf(et)}var transformPropSet=new Set(transformProps);function isTransformProp(o){return transformPropSet.has(o)}var transformOriginProps=new Set(["originX","originY","originZ"]);function isTransformOriginProp(o){return transformOriginProps.has(o)}function isForcedMotionValue(o,et){var tt=et.layout,nt=et.layoutId;return isTransformProp(o)||isTransformOriginProp(o)||(tt||nt!==void 0)&&(!!scaleCorrectors[o]||o==="opacity")}var isMotionValue=function(o){return!!(o!==null&&typeof o=="object"&&o.getVelocity)},translateAlias={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"};function buildTransform(o,et,tt,nt){var rt=o.transform,ot=o.transformKeys,it=et.enableHardwareAcceleration,st=it===void 0?!0:it,at=et.allowTransformNone,ct=at===void 0?!0:at,lt="";ot.sort(sortTransformProps);for(var dt=!1,ht=ot.length,pt=0;pttt=>Math.max(Math.min(tt,et),o),sanitize=o=>o%1?Number(o.toFixed(5)):o,floatRegex=/(-)?([\d]*\.?[\d])+/g,colorRegex=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,singleColorRegex=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function isString(o){return typeof o=="string"}const number$3={test:o=>typeof o=="number",parse:parseFloat,transform:o=>o},alpha=Object.assign(Object.assign({},number$3),{transform:clamp$2(0,1)}),scale=Object.assign(Object.assign({},number$3),{default:1}),createUnitType=o=>({test:et=>isString(et)&&et.endsWith(o)&&et.split(" ").length===1,parse:parseFloat,transform:et=>`${et}${o}`}),degrees=createUnitType("deg"),percent=createUnitType("%"),px=createUnitType("px"),vh=createUnitType("vh"),vw=createUnitType("vw"),progressPercentage=Object.assign(Object.assign({},percent),{parse:o=>percent.parse(o)/100,transform:o=>percent.transform(o*100)}),isColorString=(o,et)=>tt=>!!(isString(tt)&&singleColorRegex.test(tt)&&tt.startsWith(o)||et&&Object.prototype.hasOwnProperty.call(tt,et)),splitColor=(o,et,tt)=>nt=>{if(!isString(nt))return nt;const[rt,ot,it,st]=nt.match(floatRegex);return{[o]:parseFloat(rt),[et]:parseFloat(ot),[tt]:parseFloat(it),alpha:st!==void 0?parseFloat(st):1}},hsla={test:isColorString("hsl","hue"),parse:splitColor("hue","saturation","lightness"),transform:({hue:o,saturation:et,lightness:tt,alpha:nt=1})=>"hsla("+Math.round(o)+", "+percent.transform(sanitize(et))+", "+percent.transform(sanitize(tt))+", "+sanitize(alpha.transform(nt))+")"},clampRgbUnit=clamp$2(0,255),rgbUnit=Object.assign(Object.assign({},number$3),{transform:o=>Math.round(clampRgbUnit(o))}),rgba={test:isColorString("rgb","red"),parse:splitColor("red","green","blue"),transform:({red:o,green:et,blue:tt,alpha:nt=1})=>"rgba("+rgbUnit.transform(o)+", "+rgbUnit.transform(et)+", "+rgbUnit.transform(tt)+", "+sanitize(alpha.transform(nt))+")"};function parseHex(o){let et="",tt="",nt="",rt="";return o.length>5?(et=o.substr(1,2),tt=o.substr(3,2),nt=o.substr(5,2),rt=o.substr(7,2)):(et=o.substr(1,1),tt=o.substr(2,1),nt=o.substr(3,1),rt=o.substr(4,1),et+=et,tt+=tt,nt+=nt,rt+=rt),{red:parseInt(et,16),green:parseInt(tt,16),blue:parseInt(nt,16),alpha:rt?parseInt(rt,16)/255:1}}const hex={test:isColorString("#"),parse:parseHex,transform:rgba.transform},color$1={test:o=>rgba.test(o)||hex.test(o)||hsla.test(o),parse:o=>rgba.test(o)?rgba.parse(o):hsla.test(o)?hsla.parse(o):hex.parse(o),transform:o=>isString(o)?o:o.hasOwnProperty("red")?rgba.transform(o):hsla.transform(o)},colorToken="${c}",numberToken="${n}";function test(o){var et,tt,nt,rt;return isNaN(o)&&isString(o)&&((tt=(et=o.match(floatRegex))===null||et===void 0?void 0:et.length)!==null&&tt!==void 0?tt:0)+((rt=(nt=o.match(colorRegex))===null||nt===void 0?void 0:nt.length)!==null&&rt!==void 0?rt:0)>0}function analyse$1(o){typeof o=="number"&&(o=`${o}`);const et=[];let tt=0;const nt=o.match(colorRegex);nt&&(tt=nt.length,o=o.replace(colorRegex,colorToken),et.push(...nt.map(color$1.parse)));const rt=o.match(floatRegex);return rt&&(o=o.replace(floatRegex,numberToken),et.push(...rt.map(number$3.parse))),{values:et,numColors:tt,tokenised:o}}function parse$4(o){return analyse$1(o).values}function createTransformer(o){const{values:et,numColors:tt,tokenised:nt}=analyse$1(o),rt=et.length;return ot=>{let it=nt;for(let st=0;sttypeof o=="number"?0:o;function getAnimatableNone$1(o){const et=parse$4(o);return createTransformer(o)(et.map(convertNumbersToZero))}const complex={test,parse:parse$4,createTransformer,getAnimatableNone:getAnimatableNone$1},maxDefaults=new Set(["brightness","contrast","saturate","opacity"]);function applyDefaultFilter(o){let[et,tt]=o.slice(0,-1).split("(");if(et==="drop-shadow")return o;const[nt]=tt.match(floatRegex)||[];if(!nt)return o;const rt=tt.replace(nt,"");let ot=maxDefaults.has(et)?1:0;return nt!==tt&&(ot*=100),et+"("+ot+rt+")"}const functionRegex=/([a-z-]*)\(.*?\)/g,filter$1=Object.assign(Object.assign({},complex),{getAnimatableNone:o=>{const et=o.match(functionRegex);return et?et.map(applyDefaultFilter).join(" "):o}});var int=__assign(__assign({},number$3),{transform:Math.round}),numberValueTypes={borderWidth:px,borderTopWidth:px,borderRightWidth:px,borderBottomWidth:px,borderLeftWidth:px,borderRadius:px,radius:px,borderTopLeftRadius:px,borderTopRightRadius:px,borderBottomRightRadius:px,borderBottomLeftRadius:px,width:px,maxWidth:px,height:px,maxHeight:px,size:px,top:px,right:px,bottom:px,left:px,padding:px,paddingTop:px,paddingRight:px,paddingBottom:px,paddingLeft:px,margin:px,marginTop:px,marginRight:px,marginBottom:px,marginLeft:px,rotate:degrees,rotateX:degrees,rotateY:degrees,rotateZ:degrees,scale,scaleX:scale,scaleY:scale,scaleZ:scale,skew:degrees,skewX:degrees,skewY:degrees,distance:px,translateX:px,translateY:px,translateZ:px,x:px,y:px,z:px,perspective:px,transformPerspective:px,opacity:alpha,originX:progressPercentage,originY:progressPercentage,originZ:px,zIndex:int,fillOpacity:alpha,strokeOpacity:alpha,numOctaves:int};function buildHTMLStyles(o,et,tt,nt){var rt,ot=o.style,it=o.vars,st=o.transform,at=o.transformKeys,ct=o.transformOrigin;at.length=0;var lt=!1,dt=!1,ht=!0;for(var pt in et){var mt=et[pt];if(isCSSVariable$1(pt)){it[pt]=mt;continue}var ft=numberValueTypes[pt],yt=getValueAsType(mt,ft);if(isTransformProp(pt)){if(lt=!0,st[pt]=yt,at.push(pt),!ht)continue;mt!==((rt=ft.default)!==null&&rt!==void 0?rt:0)&&(ht=!1)}else isTransformOriginProp(pt)?(ct[pt]=yt,dt=!0):ot[pt]=yt}lt?ot.transform=buildTransform(o,tt,ht,nt):nt?ot.transform=nt({},""):!et.transform&&ot.transform&&(ot.transform="none"),dt&&(ot.transformOrigin=buildTransformOrigin(ct))}var createHtmlRenderState=function(){return{style:{},transform:{},transformKeys:[],transformOrigin:{},vars:{}}};function copyRawValuesOnly(o,et,tt){for(var nt in et)!isMotionValue(et[nt])&&!isForcedMotionValue(nt,tt)&&(o[nt]=et[nt])}function useInitialMotionValues(o,et,tt){var nt=o.transformTemplate;return reactExports.useMemo(function(){var rt=createHtmlRenderState();buildHTMLStyles(rt,et,{enableHardwareAcceleration:!tt},nt);var ot=rt.vars,it=rt.style;return __assign(__assign({},ot),it)},[et])}function useStyle(o,et,tt){var nt=o.style||{},rt={};return copyRawValuesOnly(rt,nt,o),Object.assign(rt,useInitialMotionValues(o,et,tt)),o.transformValues&&(rt=o.transformValues(rt)),rt}function useHTMLProps(o,et,tt){var nt={},rt=useStyle(o,et,tt);return o.drag&&o.dragListener!==!1&&(nt.draggable=!1,rt.userSelect=rt.WebkitUserSelect=rt.WebkitTouchCallout="none",rt.touchAction=o.drag===!0?"none":"pan-".concat(o.drag==="x"?"y":"x")),nt.style=rt,nt}var validMotionProps=new Set(["initial","animate","exit","style","variants","transition","transformTemplate","transformValues","custom","inherit","layout","layoutId","layoutDependency","onLayoutAnimationStart","onLayoutAnimationComplete","onLayoutMeasure","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","drag","dragControls","dragListener","dragConstraints","dragDirectionLock","dragSnapToOrigin","_dragX","_dragY","dragElastic","dragMomentum","dragPropagation","dragTransition","whileDrag","onPan","onPanStart","onPanEnd","onPanSessionStart","onTap","onTapStart","onTapCancel","onHoverStart","onHoverEnd","whileFocus","whileTap","whileHover","whileInView","onViewportEnter","onViewportLeave","viewport","layoutScroll"]);function isValidMotionProp(o){return validMotionProps.has(o)}var shouldForward=function(o){return!isValidMotionProp(o)};function loadExternalIsValidProp(o){o&&(shouldForward=function(et){return et.startsWith("on")?!isValidMotionProp(et):o(et)})}try{loadExternalIsValidProp(require("@emotion/is-prop-valid").default)}catch{}function filterProps(o,et,tt){var nt={};for(var rt in o)(shouldForward(rt)||tt===!0&&isValidMotionProp(rt)||!et&&!isValidMotionProp(rt)||o.draggable&&rt.startsWith("onDrag"))&&(nt[rt]=o[rt]);return nt}function calcOrigin$1(o,et,tt){return typeof o=="string"?o:px.transform(et+tt*o)}function calcSVGTransformOrigin(o,et,tt){var nt=calcOrigin$1(et,o.x,o.width),rt=calcOrigin$1(tt,o.y,o.height);return"".concat(nt," ").concat(rt)}var camelKeys={offset:"strokeDashoffset",array:"strokeDasharray"};function buildSVGPath(o,et,tt,nt,rt){tt===void 0&&(tt=1),nt===void 0&&(nt=0),o.pathLength=1;var ot=camelKeys;o[ot.offset]=px.transform(-nt);var it=px.transform(et),st=px.transform(tt);o[ot.array]="".concat(it," ").concat(st)}function buildSVGAttrs(o,et,tt,nt){var rt=et.attrX,ot=et.attrY,it=et.originX,st=et.originY,at=et.pathLength,ct=et.pathSpacing,lt=ct===void 0?1:ct,dt=et.pathOffset,ht=dt===void 0?0:dt,pt=__rest(et,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]);buildHTMLStyles(o,pt,tt,nt),o.attrs=o.style,o.style={};var mt=o.attrs,ft=o.style,yt=o.dimensions;mt.transform&&(yt&&(ft.transform=mt.transform),delete mt.transform),yt&&(it!==void 0||st!==void 0||ft.transform)&&(ft.transformOrigin=calcSVGTransformOrigin(yt,it!==void 0?it:.5,st!==void 0?st:.5)),rt!==void 0&&(mt.x=rt),ot!==void 0&&(mt.y=ot),at!==void 0&&buildSVGPath(mt,at,lt,ht)}var createSvgRenderState=function(){return __assign(__assign({},createHtmlRenderState()),{attrs:{}})};function useSVGProps(o,et){var tt=reactExports.useMemo(function(){var rt=createSvgRenderState();return buildSVGAttrs(rt,et,{enableHardwareAcceleration:!1},o.transformTemplate),__assign(__assign({},rt.attrs),{style:__assign({},rt.style)})},[et]);if(o.style){var nt={};copyRawValuesOnly(nt,o.style,o),tt.style=__assign(__assign({},nt),tt.style)}return tt}function createUseRender(o){o===void 0&&(o=!1);var et=function(tt,nt,rt,ot,it,st){var at=it.latestValues,ct=isSVGComponent(tt)?useSVGProps:useHTMLProps,lt=ct(nt,at,st),dt=filterProps(nt,typeof tt=="string",o),ht=__assign(__assign(__assign({},dt),lt),{ref:ot});return rt&&(ht["data-projection-id"]=rt),reactExports.createElement(tt,ht)};return et}var CAMEL_CASE_PATTERN=/([a-z])([A-Z])/g,REPLACE_TEMPLATE="$1-$2",camelToDash=function(o){return o.replace(CAMEL_CASE_PATTERN,REPLACE_TEMPLATE).toLowerCase()};function renderHTML(o,et,tt,nt){var rt=et.style,ot=et.vars;Object.assign(o.style,rt,nt&&nt.getProjectionStyles(tt));for(var it in ot)o.style.setProperty(it,ot[it])}var camelCaseAttributes=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength"]);function renderSVG(o,et,tt,nt){renderHTML(o,et,void 0,nt);for(var rt in et.attrs)o.setAttribute(camelCaseAttributes.has(rt)?rt:camelToDash(rt),et.attrs[rt])}function scrapeMotionValuesFromProps$1(o){var et=o.style,tt={};for(var nt in et)(isMotionValue(et[nt])||isForcedMotionValue(nt,o))&&(tt[nt]=et[nt]);return tt}function scrapeMotionValuesFromProps(o){var et=scrapeMotionValuesFromProps$1(o);for(var tt in o)if(isMotionValue(o[tt])){var nt=tt==="x"||tt==="y"?"attr"+tt.toUpperCase():tt;et[nt]=o[tt]}return et}function isAnimationControls(o){return typeof o=="object"&&typeof o.start=="function"}var isKeyframesTarget=function(o){return Array.isArray(o)},isCustomValue=function(o){return!!(o&&typeof o=="object"&&o.mix&&o.toValue)},resolveFinalValueInKeyframes=function(o){return isKeyframesTarget(o)?o[o.length-1]||0:o};function resolveMotionValue(o){var et=isMotionValue(o)?o.get():o;return isCustomValue(et)?et.toValue():et}function makeState(o,et,tt,nt){var rt=o.scrapeMotionValuesFromProps,ot=o.createRenderState,it=o.onMount,st={latestValues:makeLatestValues(et,tt,nt,rt),renderState:ot()};return it&&(st.mount=function(at){return it(et,at,st)}),st}var makeUseVisualState=function(o){return function(et,tt){var nt=reactExports.useContext(MotionContext),rt=reactExports.useContext(PresenceContext);return tt?makeState(o,et,nt,rt):useConstant(function(){return makeState(o,et,nt,rt)})}};function makeLatestValues(o,et,tt,nt){var rt={},ot=(tt==null?void 0:tt.initial)===!1,it=nt(o);for(var st in it)rt[st]=resolveMotionValue(it[st]);var at=o.initial,ct=o.animate,lt=checkIfControllingVariants(o),dt=checkIfVariantNode(o);et&&dt&&!lt&&o.inherit!==!1&&(at??(at=et.initial),ct??(ct=et.animate));var ht=ot||at===!1,pt=ht?ct:at;if(pt&&typeof pt!="boolean"&&!isAnimationControls(pt)){var mt=Array.isArray(pt)?pt:[pt];mt.forEach(function(ft){var yt=resolveVariantFromProps(o,ft);if(yt){var gt=yt.transitionEnd;yt.transition;var xt=__rest(yt,["transitionEnd","transition"]);for(var vt in xt){var bt=xt[vt];if(Array.isArray(bt)){var Et=ht?bt.length-1:0;bt=bt[Et]}bt!==null&&(rt[vt]=bt)}for(var vt in gt)rt[vt]=gt[vt]}})}return rt}var svgMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps,createRenderState:createSvgRenderState,onMount:function(o,et,tt){var nt=tt.renderState,rt=tt.latestValues;try{nt.dimensions=typeof et.getBBox=="function"?et.getBBox():et.getBoundingClientRect()}catch{nt.dimensions={x:0,y:0,width:0,height:0}}buildSVGAttrs(nt,rt,{enableHardwareAcceleration:!1},o.transformTemplate),renderSVG(et,nt)}})},htmlMotionConfig={useVisualState:makeUseVisualState({scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,createRenderState:createHtmlRenderState})};function createDomMotionConfig(o,et,tt,nt,rt){var ot=et.forwardMotionProps,it=ot===void 0?!1:ot,st=isSVGComponent(o)?svgMotionConfig:htmlMotionConfig;return __assign(__assign({},st),{preloadedFeatures:tt,useRender:createUseRender(it),createVisualElement:nt,projectionNodeConstructor:rt,Component:o})}var AnimationType;(function(o){o.Animate="animate",o.Hover="whileHover",o.Tap="whileTap",o.Drag="whileDrag",o.Focus="whileFocus",o.InView="whileInView",o.Exit="exit"})(AnimationType||(AnimationType={}));function addDomEvent(o,et,tt,nt){return nt===void 0&&(nt={passive:!0}),o.addEventListener(et,tt,nt),function(){return o.removeEventListener(et,tt)}}function useDomEvent(o,et,tt,nt){reactExports.useEffect(function(){var rt=o.current;if(tt&&rt)return addDomEvent(rt,et,tt,nt)},[o,et,tt,nt])}function useFocusGesture(o){var et=o.whileFocus,tt=o.visualElement,nt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!0)},rt=function(){var ot;(ot=tt.animationState)===null||ot===void 0||ot.setActive(AnimationType.Focus,!1)};useDomEvent(tt,"focus",et?nt:void 0),useDomEvent(tt,"blur",et?rt:void 0)}function isMouseEvent(o){return typeof PointerEvent<"u"&&o instanceof PointerEvent?o.pointerType==="mouse":o instanceof MouseEvent}function isTouchEvent(o){var et=!!o.touches;return et}function filterPrimaryPointer(o){return function(et){var tt=et instanceof MouseEvent,nt=!tt||tt&&et.button===0;nt&&o(et)}}var defaultPagePoint={pageX:0,pageY:0};function pointFromTouch(o,et){et===void 0&&(et="page");var tt=o.touches[0]||o.changedTouches[0],nt=tt||defaultPagePoint;return{x:nt[et+"X"],y:nt[et+"Y"]}}function pointFromMouse(o,et){return et===void 0&&(et="page"),{x:o[et+"X"],y:o[et+"Y"]}}function extractEventInfo(o,et){return et===void 0&&(et="page"),{point:isTouchEvent(o)?pointFromTouch(o,et):pointFromMouse(o,et)}}var wrapHandler=function(o,et){et===void 0&&(et=!1);var tt=function(nt){return o(nt,extractEventInfo(nt))};return et?filterPrimaryPointer(tt):tt},supportsPointerEvents=function(){return isBrowser$3&&window.onpointerdown===null},supportsTouchEvents=function(){return isBrowser$3&&window.ontouchstart===null},supportsMouseEvents=function(){return isBrowser$3&&window.onmousedown===null},mouseEventNames={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},touchEventNames={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function getPointerEventName(o){return supportsPointerEvents()?o:supportsTouchEvents()?touchEventNames[o]:supportsMouseEvents()?mouseEventNames[o]:o}function addPointerEvent(o,et,tt,nt){return addDomEvent(o,getPointerEventName(et),wrapHandler(tt,et==="pointerdown"),nt)}function usePointerEvent(o,et,tt,nt){return useDomEvent(o,getPointerEventName(et),tt&&wrapHandler(tt,et==="pointerdown"),nt)}function createLock(o){var et=null;return function(){var tt=function(){et=null};return et===null?(et=o,tt):!1}}var globalHorizontalLock=createLock("dragHorizontal"),globalVerticalLock=createLock("dragVertical");function getGlobalLock(o){var et=!1;if(o==="y")et=globalVerticalLock();else if(o==="x")et=globalHorizontalLock();else{var tt=globalHorizontalLock(),nt=globalVerticalLock();tt&&nt?et=function(){tt(),nt()}:(tt&&tt(),nt&&nt())}return et}function isDragActive(){var o=getGlobalLock(!0);return o?(o(),!1):!0}function createHoverEvent(o,et,tt){return function(nt,rt){var ot;!isMouseEvent(nt)||isDragActive()||((ot=o.animationState)===null||ot===void 0||ot.setActive(AnimationType.Hover,et),tt==null||tt(nt,rt))}}function useHoverGesture(o){var et=o.onHoverStart,tt=o.onHoverEnd,nt=o.whileHover,rt=o.visualElement;usePointerEvent(rt,"pointerenter",et||nt?createHoverEvent(rt,!0,et):void 0,{passive:!et}),usePointerEvent(rt,"pointerleave",tt||nt?createHoverEvent(rt,!1,tt):void 0,{passive:!tt})}var isNodeOrChild=function(o,et){return et?o===et?!0:isNodeOrChild(o,et.parentElement):!1};function useUnmountEffect(o){return reactExports.useEffect(function(){return function(){return o()}},[])}const clamp$1=(o,et,tt)=>Math.min(Math.max(tt,o),et),safeMin=.001,minDuration=.01,maxDuration=10,minDamping=.05,maxDamping=1;function findSpring({duration:o=800,bounce:et=.25,velocity:tt=0,mass:nt=1}){let rt,ot,it=1-et;it=clamp$1(minDamping,maxDamping,it),o=clamp$1(minDuration,maxDuration,o/1e3),it<1?(rt=ct=>{const lt=ct*it,dt=lt*o,ht=lt-tt,pt=calcAngularFreq(ct,it),mt=Math.exp(-dt);return safeMin-ht/pt*mt},ot=ct=>{const dt=ct*it*o,ht=dt*tt+tt,pt=Math.pow(it,2)*Math.pow(ct,2)*o,mt=Math.exp(-dt),ft=calcAngularFreq(Math.pow(ct,2),it);return(-rt(ct)+safeMin>0?-1:1)*((ht-pt)*mt)/ft}):(rt=ct=>{const lt=Math.exp(-ct*o),dt=(ct-tt)*o+1;return-safeMin+lt*dt},ot=ct=>{const lt=Math.exp(-ct*o),dt=(tt-ct)*(o*o);return lt*dt});const st=5/o,at=approximateRoot(rt,ot,st);if(o=o*1e3,isNaN(at))return{stiffness:100,damping:10,duration:o};{const ct=Math.pow(at,2)*nt;return{stiffness:ct,damping:it*2*Math.sqrt(nt*ct),duration:o}}}const rootIterations=12;function approximateRoot(o,et,tt){let nt=tt;for(let rt=1;rto[tt]!==void 0)}function getSpringOptions(o){let et=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},o);if(!isSpringType(o,physicsKeys)&&isSpringType(o,durationKeys)){const tt=findSpring(o);et=Object.assign(Object.assign(Object.assign({},et),tt),{velocity:0,mass:1}),et.isResolvedFromDuration=!0}return et}function spring(o){var{from:et=0,to:tt=1,restSpeed:nt=2,restDelta:rt}=o,ot=__rest(o,["from","to","restSpeed","restDelta"]);const it={done:!1,value:et};let{stiffness:st,damping:at,mass:ct,velocity:lt,duration:dt,isResolvedFromDuration:ht}=getSpringOptions(ot),pt=zero$1,mt=zero$1;function ft(){const yt=lt?-(lt/1e3):0,gt=tt-et,xt=at/(2*Math.sqrt(st*ct)),vt=Math.sqrt(st/ct)/1e3;if(rt===void 0&&(rt=Math.min(Math.abs(tt-et)/100,.4)),xt<1){const bt=calcAngularFreq(vt,xt);pt=Et=>{const wt=Math.exp(-xt*vt*Et);return tt-wt*((yt+xt*vt*gt)/bt*Math.sin(bt*Et)+gt*Math.cos(bt*Et))},mt=Et=>{const wt=Math.exp(-xt*vt*Et);return xt*vt*wt*(Math.sin(bt*Et)*(yt+xt*vt*gt)/bt+gt*Math.cos(bt*Et))-wt*(Math.cos(bt*Et)*(yt+xt*vt*gt)-bt*gt*Math.sin(bt*Et))}}else if(xt===1)pt=bt=>tt-Math.exp(-vt*bt)*(gt+(yt+vt*gt)*bt);else{const bt=vt*Math.sqrt(xt*xt-1);pt=Et=>{const wt=Math.exp(-xt*vt*Et),kt=Math.min(bt*Et,300);return tt-wt*((yt+xt*vt*gt)*Math.sinh(kt)+bt*gt*Math.cosh(kt))/bt}}}return ft(),{next:yt=>{const gt=pt(yt);if(ht)it.done=yt>=dt;else{const xt=mt(yt)*1e3,vt=Math.abs(xt)<=nt,bt=Math.abs(tt-gt)<=rt;it.done=vt&&bt}return it.value=it.done?tt:gt,it},flipTarget:()=>{lt=-lt,[et,tt]=[tt,et],ft()}}}spring.needsInterpolation=(o,et)=>typeof o=="string"||typeof et=="string";const zero$1=o=>0,progress=(o,et,tt)=>{const nt=et-o;return nt===0?1:(tt-o)/nt},mix=(o,et,tt)=>-tt*o+tt*et+o;function hueToRgb(o,et,tt){return tt<0&&(tt+=1),tt>1&&(tt-=1),tt<1/6?o+(et-o)*6*tt:tt<1/2?et:tt<2/3?o+(et-o)*(2/3-tt)*6:o}function hslaToRgba({hue:o,saturation:et,lightness:tt,alpha:nt}){o/=360,et/=100,tt/=100;let rt=0,ot=0,it=0;if(!et)rt=ot=it=tt;else{const st=tt<.5?tt*(1+et):tt+et-tt*et,at=2*tt-st;rt=hueToRgb(at,st,o+1/3),ot=hueToRgb(at,st,o),it=hueToRgb(at,st,o-1/3)}return{red:Math.round(rt*255),green:Math.round(ot*255),blue:Math.round(it*255),alpha:nt}}const mixLinearColor=(o,et,tt)=>{const nt=o*o,rt=et*et;return Math.sqrt(Math.max(0,tt*(rt-nt)+nt))},colorTypes=[hex,rgba,hsla],getColorType=o=>colorTypes.find(et=>et.test(o)),mixColor=(o,et)=>{let tt=getColorType(o),nt=getColorType(et),rt=tt.parse(o),ot=nt.parse(et);tt===hsla&&(rt=hslaToRgba(rt),tt=rgba),nt===hsla&&(ot=hslaToRgba(ot),nt=rgba);const it=Object.assign({},rt);return st=>{for(const at in it)at!=="alpha"&&(it[at]=mixLinearColor(rt[at],ot[at],st));return it.alpha=mix(rt.alpha,ot.alpha,st),tt.transform(it)}},isNum=o=>typeof o=="number",combineFunctions=(o,et)=>tt=>et(o(tt)),pipe$1=(...o)=>o.reduce(combineFunctions);function getMixer(o,et){return isNum(o)?tt=>mix(o,et,tt):color$1.test(o)?mixColor(o,et):mixComplex(o,et)}const mixArray=(o,et)=>{const tt=[...o],nt=tt.length,rt=o.map((ot,it)=>getMixer(ot,et[it]));return ot=>{for(let it=0;it{const tt=Object.assign(Object.assign({},o),et),nt={};for(const rt in tt)o[rt]!==void 0&&et[rt]!==void 0&&(nt[rt]=getMixer(o[rt],et[rt]));return rt=>{for(const ot in nt)tt[ot]=nt[ot](rt);return tt}};function analyse(o){const et=complex.parse(o),tt=et.length;let nt=0,rt=0,ot=0;for(let it=0;it{const tt=complex.createTransformer(et),nt=analyse(o),rt=analyse(et);return nt.numHSL===rt.numHSL&&nt.numRGB===rt.numRGB&&nt.numNumbers>=rt.numNumbers?pipe$1(mixArray(nt.parsed,rt.parsed),tt):it=>`${it>0?et:o}`},mixNumber=(o,et)=>tt=>mix(o,et,tt);function detectMixerFactory(o){if(typeof o=="number")return mixNumber;if(typeof o=="string")return color$1.test(o)?mixColor:mixComplex;if(Array.isArray(o))return mixArray;if(typeof o=="object")return mixObject}function createMixers(o,et,tt){const nt=[],rt=tt||detectMixerFactory(o[0]),ot=o.length-1;for(let it=0;ittt(progress(o,et,nt))}function slowInterpolate(o,et){const tt=o.length,nt=tt-1;return rt=>{let ot=0,it=!1;if(rt<=o[0]?it=!0:rt>=o[nt]&&(ot=nt-1,it=!0),!it){let at=1;for(;atrt||at===nt);at++);ot=at-1}const st=progress(o[ot],o[ot+1],rt);return et[ot](st)}}function interpolate(o,et,{clamp:tt=!0,ease:nt,mixer:rt}={}){const ot=o.length;invariant$1(ot===et.length),invariant$1(!nt||!Array.isArray(nt)||nt.length===ot-1),o[0]>o[ot-1]&&(o=[].concat(o),et=[].concat(et),o.reverse(),et.reverse());const it=createMixers(et,nt,rt),st=ot===2?fastInterpolate(o,it):slowInterpolate(o,it);return tt?at=>st(clamp$1(o[0],o[ot-1],at)):st}const reverseEasing=o=>et=>1-o(1-et),mirrorEasing=o=>et=>et<=.5?o(2*et)/2:(2-o(2*(1-et)))/2,createExpoIn=o=>et=>Math.pow(et,o),createBackIn=o=>et=>et*et*((o+1)*et-o),createAnticipate=o=>{const et=createBackIn(o);return tt=>(tt*=2)<1?.5*et(tt):.5*(2-Math.pow(2,-10*(tt-1)))},DEFAULT_OVERSHOOT_STRENGTH=1.525,BOUNCE_FIRST_THRESHOLD=4/11,BOUNCE_SECOND_THRESHOLD=8/11,BOUNCE_THIRD_THRESHOLD=9/10,linear=o=>o,easeIn=createExpoIn(2),easeOut=reverseEasing(easeIn),easeInOut=mirrorEasing(easeIn),circIn=o=>1-Math.sin(Math.acos(o)),circOut=reverseEasing(circIn),circInOut=mirrorEasing(circOut),backIn=createBackIn(DEFAULT_OVERSHOOT_STRENGTH),backOut=reverseEasing(backIn),backInOut=mirrorEasing(backIn),anticipate=createAnticipate(DEFAULT_OVERSHOOT_STRENGTH),ca=4356/361,cb=35442/1805,cc=16061/1805,bounceOut=o=>{if(o===1||o===0)return o;const et=o*o;return oo<.5?.5*(1-bounceOut(1-o*2)):.5*bounceOut(o*2-1)+.5;function defaultEasing(o,et){return o.map(()=>et||easeInOut).splice(0,o.length-1)}function defaultOffset(o){const et=o.length;return o.map((tt,nt)=>nt!==0?nt/(et-1):0)}function convertOffsetToTimes(o,et){return o.map(tt=>tt*et)}function keyframes$1({from:o=0,to:et=1,ease:tt,offset:nt,duration:rt=300}){const ot={done:!1,value:o},it=Array.isArray(et)?et:[o,et],st=convertOffsetToTimes(nt&&nt.length===it.length?nt:defaultOffset(it),rt);function at(){return interpolate(st,it,{ease:Array.isArray(tt)?tt:defaultEasing(it,tt)})}let ct=at();return{next:lt=>(ot.value=ct(lt),ot.done=lt>=rt,ot),flipTarget:()=>{it.reverse(),ct=at()}}}function decay({velocity:o=0,from:et=0,power:tt=.8,timeConstant:nt=350,restDelta:rt=.5,modifyTarget:ot}){const it={done:!1,value:et};let st=tt*o;const at=et+st,ct=ot===void 0?at:ot(at);return ct!==at&&(st=ct-et),{next:lt=>{const dt=-st*Math.exp(-lt/nt);return it.done=!(dt>rt||dt<-rt),it.value=it.done?ct:ct+dt,it},flipTarget:()=>{}}}const types$3={keyframes:keyframes$1,spring,decay};function detectAnimationFromOptions(o){if(Array.isArray(o.to))return keyframes$1;if(types$3[o.type])return types$3[o.type];const et=new Set(Object.keys(o));return et.has("ease")||et.has("duration")&&!et.has("dampingRatio")?keyframes$1:et.has("dampingRatio")||et.has("stiffness")||et.has("mass")||et.has("damping")||et.has("restSpeed")||et.has("restDelta")?spring:keyframes$1}const defaultTimestep=1/60*1e3,getCurrentTime=typeof performance<"u"?()=>performance.now():()=>Date.now(),onNextFrame=typeof window<"u"?o=>window.requestAnimationFrame(o):o=>setTimeout(()=>o(getCurrentTime()),defaultTimestep);function createRenderStep(o){let et=[],tt=[],nt=0,rt=!1,ot=!1;const it=new WeakSet,st={schedule:(at,ct=!1,lt=!1)=>{const dt=lt&&rt,ht=dt?et:tt;return ct&&it.add(at),ht.indexOf(at)===-1&&(ht.push(at),dt&&rt&&(nt=et.length)),at},cancel:at=>{const ct=tt.indexOf(at);ct!==-1&&tt.splice(ct,1),it.delete(at)},process:at=>{if(rt){ot=!0;return}if(rt=!0,[et,tt]=[tt,et],tt.length=0,nt=et.length,nt)for(let ct=0;ct(o[et]=createRenderStep(()=>runNextFrame=!0),o),{}),sync=stepsOrder.reduce((o,et)=>{const tt=steps[et];return o[et]=(nt,rt=!1,ot=!1)=>(runNextFrame||startLoop(),tt.schedule(nt,rt,ot)),o},{}),cancelSync=stepsOrder.reduce((o,et)=>(o[et]=steps[et].cancel,o),{}),flushSync=stepsOrder.reduce((o,et)=>(o[et]=()=>steps[et].process(frame),o),{}),processStep=o=>steps[o].process(frame),processFrame=o=>{runNextFrame=!1,frame.delta=useDefaultElapsed?defaultTimestep:Math.max(Math.min(o-frame.timestamp,maxElapsed),1),frame.timestamp=o,isProcessing=!0,stepsOrder.forEach(processStep),isProcessing=!1,runNextFrame&&(useDefaultElapsed=!1,onNextFrame(processFrame))},startLoop=()=>{runNextFrame=!0,useDefaultElapsed=!0,isProcessing||onNextFrame(processFrame)},getFrameData=()=>frame;function loopElapsed(o,et,tt=0){return o-et-tt}function reverseElapsed(o,et,tt=0,nt=!0){return nt?loopElapsed(et+-o,et,tt):et-(o-et)+tt}function hasRepeatDelayElapsed(o,et,tt,nt){return nt?o>=et+tt:o<=-tt}const framesync=o=>{const et=({delta:tt})=>o(tt);return{start:()=>sync.update(et,!0),stop:()=>cancelSync.update(et)}};function animate$1(o){var et,tt,{from:nt,autoplay:rt=!0,driver:ot=framesync,elapsed:it=0,repeat:st=0,repeatType:at="loop",repeatDelay:ct=0,onPlay:lt,onStop:dt,onComplete:ht,onRepeat:pt,onUpdate:mt}=o,ft=__rest(o,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let{to:yt}=ft,gt,xt=0,vt=ft.duration,bt,Et=!1,wt=!0,kt;const It=detectAnimationFromOptions(ft);!((tt=(et=It).needsInterpolation)===null||tt===void 0)&&tt.call(et,nt,yt)&&(kt=interpolate([0,100],[nt,yt],{clamp:!1}),nt=0,yt=100);const Rt=It(Object.assign(Object.assign({},ft),{from:nt,to:yt}));function Pt(){xt++,at==="reverse"?(wt=xt%2===0,it=reverseElapsed(it,vt,ct,wt)):(it=loopElapsed(it,vt,ct),at==="mirror"&&Rt.flipTarget()),Et=!1,pt&&pt()}function jt(){gt.stop(),ht&&ht()}function Ot(zt){if(wt||(zt=-zt),it+=zt,!Et){const Ft=Rt.next(Math.max(0,it));bt=Ft.value,kt&&(bt=kt(bt)),Et=wt?Ft.done:it<=0}mt==null||mt(bt),Et&&(xt===0&&(vt??(vt=it)),xt{dt==null||dt(),gt.stop()}}}function velocityPerSecond(o,et){return et?o*(1e3/et):0}function inertia({from:o=0,velocity:et=0,min:tt,max:nt,power:rt=.8,timeConstant:ot=750,bounceStiffness:it=500,bounceDamping:st=10,restDelta:at=1,modifyTarget:ct,driver:lt,onUpdate:dt,onComplete:ht,onStop:pt}){let mt;function ft(vt){return tt!==void 0&&vtnt}function yt(vt){return tt===void 0?nt:nt===void 0||Math.abs(tt-vt){var Et;dt==null||dt(bt),(Et=vt.onUpdate)===null||Et===void 0||Et.call(vt,bt)},onComplete:ht,onStop:pt}))}function xt(vt){gt(Object.assign({type:"spring",stiffness:it,damping:st,restDelta:at},vt))}if(ft(o))xt({from:o,velocity:et,to:yt(o)});else{let vt=rt*et+o;typeof ct<"u"&&(vt=ct(vt));const bt=yt(vt),Et=bt===tt?-1:1;let wt,kt;const It=Rt=>{wt=kt,kt=Rt,et=velocityPerSecond(Rt-wt,getFrameData().delta),(Et===1&&Rt>bt||Et===-1&&Rtmt==null?void 0:mt.stop()}}const isPoint=o=>o.hasOwnProperty("x")&&o.hasOwnProperty("y"),isPoint3D=o=>isPoint(o)&&o.hasOwnProperty("z"),distance1D=(o,et)=>Math.abs(o-et);function distance(o,et){if(isNum(o)&&isNum(et))return distance1D(o,et);if(isPoint(o)&&isPoint(et)){const tt=distance1D(o.x,et.x),nt=distance1D(o.y,et.y),rt=isPoint3D(o)&&isPoint3D(et)?distance1D(o.z,et.z):0;return Math.sqrt(Math.pow(tt,2)+Math.pow(nt,2)+Math.pow(rt,2))}}const a=(o,et)=>1-3*et+3*o,b$3=(o,et)=>3*et-6*o,c$2=o=>3*o,calcBezier=(o,et,tt)=>((a(et,tt)*o+b$3(et,tt))*o+c$2(et))*o,getSlope=(o,et,tt)=>3*a(et,tt)*o*o+2*b$3(et,tt)*o+c$2(et),subdivisionPrecision=1e-7,subdivisionMaxIterations=10;function binarySubdivide(o,et,tt,nt,rt){let ot,it,st=0;do it=et+(tt-et)/2,ot=calcBezier(it,nt,rt)-o,ot>0?tt=it:et=it;while(Math.abs(ot)>subdivisionPrecision&&++st=newtonMinSlope?newtonRaphsonIterate(it,dt,o,tt):ht===0?dt:binarySubdivide(it,st,st+kSampleStepSize,o,tt)}return it=>it===0||it===1?it:calcBezier(ot(it),et,nt)}function useTapGesture(o){var et=o.onTap,tt=o.onTapStart,nt=o.onTapCancel,rt=o.whileTap,ot=o.visualElement,it=et||tt||nt||rt,st=reactExports.useRef(!1),at=reactExports.useRef(null),ct={passive:!(tt||et||nt||mt)};function lt(){var ft;(ft=at.current)===null||ft===void 0||ft.call(at),at.current=null}function dt(){var ft;return lt(),st.current=!1,(ft=ot.animationState)===null||ft===void 0||ft.setActive(AnimationType.Tap,!1),!isDragActive()}function ht(ft,yt){dt()&&(isNodeOrChild(ot.getInstance(),ft.target)?et==null||et(ft,yt):nt==null||nt(ft,yt))}function pt(ft,yt){dt()&&(nt==null||nt(ft,yt))}function mt(ft,yt){var gt;lt(),!st.current&&(st.current=!0,at.current=pipe$1(addPointerEvent(window,"pointerup",ht,ct),addPointerEvent(window,"pointercancel",pt,ct)),(gt=ot.animationState)===null||gt===void 0||gt.setActive(AnimationType.Tap,!0),tt==null||tt(ft,yt))}usePointerEvent(ot,"pointerdown",it?mt:void 0,ct),useUnmountEffect(lt)}var warned=new Set;function warnOnce$1(o,et,tt){warned.has(et)||(console.warn(et),warned.add(et))}var observerCallbacks=new WeakMap,observers$1=new WeakMap,fireObserverCallback=function(o){var et;(et=observerCallbacks.get(o.target))===null||et===void 0||et(o)},fireAllObserverCallbacks=function(o){o.forEach(fireObserverCallback)};function initIntersectionObserver(o){var et=o.root,tt=__rest(o,["root"]),nt=et||document;observers$1.has(nt)||observers$1.set(nt,{});var rt=observers$1.get(nt),ot=JSON.stringify(tt);return rt[ot]||(rt[ot]=new IntersectionObserver(fireAllObserverCallbacks,__assign({root:et},tt))),rt[ot]}function observeIntersection(o,et,tt){var nt=initIntersectionObserver(et);return observerCallbacks.set(o,tt),nt.observe(o),function(){observerCallbacks.delete(o),nt.unobserve(o)}}function useViewport(o){var et=o.visualElement,tt=o.whileInView,nt=o.onViewportEnter,rt=o.onViewportLeave,ot=o.viewport,it=ot===void 0?{}:ot,st=reactExports.useRef({hasEnteredView:!1,isInView:!1}),at=!!(tt||nt||rt);it.once&&st.current.hasEnteredView&&(at=!1);var ct=typeof IntersectionObserver>"u"?useMissingIntersectionObserver:useIntersectionObserver;ct(at,st.current,et,it)}var thresholdNames={some:0,all:1};function useIntersectionObserver(o,et,tt,nt){var rt=nt.root,ot=nt.margin,it=nt.amount,st=it===void 0?"some":it,at=nt.once;reactExports.useEffect(function(){if(o){var ct={root:rt==null?void 0:rt.current,rootMargin:ot,threshold:typeof st=="number"?st:thresholdNames[st]},lt=function(dt){var ht,pt=dt.isIntersecting;if(et.isInView!==pt&&(et.isInView=pt,!(at&&!pt&&et.hasEnteredView))){pt&&(et.hasEnteredView=!0),(ht=tt.animationState)===null||ht===void 0||ht.setActive(AnimationType.InView,pt);var mt=tt.getProps(),ft=pt?mt.onViewportEnter:mt.onViewportLeave;ft==null||ft(dt)}};return observeIntersection(tt.getInstance(),ct,lt)}},[o,rt,ot,st])}function useMissingIntersectionObserver(o,et,tt,nt){var rt=nt.fallback,ot=rt===void 0?!0:rt;reactExports.useEffect(function(){!o||!ot||(env$1!=="production"&&warnOnce$1(!1,"IntersectionObserver not available on this device. whileInView animations will trigger on mount."),requestAnimationFrame(function(){var it;et.hasEnteredView=!0;var st=tt.getProps().onViewportEnter;st==null||st(null),(it=tt.animationState)===null||it===void 0||it.setActive(AnimationType.InView,!0)}))},[o])}var makeRenderlessComponent=function(o){return function(et){return o(et),null}},gestureAnimations={inView:makeRenderlessComponent(useViewport),tap:makeRenderlessComponent(useTapGesture),focus:makeRenderlessComponent(useFocusGesture),hover:makeRenderlessComponent(useHoverGesture)},counter=0,incrementId=function(){return counter++},useId$1=function(){return useConstant(incrementId)};function usePresence$1(){var o=reactExports.useContext(PresenceContext);if(o===null)return[!0,null];var et=o.isPresent,tt=o.onExitComplete,nt=o.register,rt=useId$1();reactExports.useEffect(function(){return nt(rt)},[]);var ot=function(){return tt==null?void 0:tt(rt)};return!et&&tt?[!1,ot]:[!0]}function shallowCompare(o,et){if(!Array.isArray(et))return!1;var tt=et.length;if(tt!==o.length)return!1;for(var nt=0;nt-1&&o.splice(tt,1)}var SubscriptionManager$1=function(){function o(){this.subscriptions=[]}return o.prototype.add=function(et){var tt=this;return addUniqueItem(this.subscriptions,et),function(){return removeItem(tt.subscriptions,et)}},o.prototype.notify=function(et,tt,nt){var rt=this.subscriptions.length;if(rt)if(rt===1)this.subscriptions[0](et,tt,nt);else for(var ot=0;otxt&&jt,Yt=Array.isArray(Pt)?Pt:[Pt],Ht=Yt.reduce(ot,{});Ot===!1&&(Ht={});var Ut=Rt.prevResolvedValues,qt=Ut===void 0?{}:Ut,Lt=__assign(__assign({},qt),Ht),Zt=function(nn){Ft=!0,yt.delete(nn),Rt.needsAnimating[nn]=!0};for(var Qt in Lt){var Nt=Ht[Qt],Gt=qt[Qt];gt.hasOwnProperty(Qt)||(Nt!==Gt?isKeyframesTarget(Nt)&&isKeyframesTarget(Gt)?!shallowCompare(Nt,Gt)||zt?Zt(Qt):Rt.protectedKeys[Qt]=!0:Nt!==void 0?Zt(Qt):yt.add(Qt):Nt!==void 0&&yt.has(Qt)?Zt(Qt):Rt.protectedKeys[Qt]=!0)}Rt.prevProp=Pt,Rt.prevResolvedValues=Ht,Rt.isActive&&(gt=__assign(__assign({},gt),Ht)),rt&&o.blockInitialAnimation&&(Ft=!1),Ft&&!Bt&&ft.push.apply(ft,__spreadArray([],__read(Yt.map(function(nn){return{animation:nn,options:__assign({type:It},lt)}})),!1))},bt=0;bt=3;if(!(!pt&&!mt)){var ft=ht.point,yt=getFrameData().timestamp;rt.history.push(__assign(__assign({},ft),{timestamp:yt}));var gt=rt.handlers,xt=gt.onStart,vt=gt.onMove;pt||(xt&&xt(rt.lastMoveEvent,ht),rt.startEvent=rt.lastMoveEvent),vt&&vt(rt.lastMoveEvent,ht)}}},this.handlePointerMove=function(ht,pt){if(rt.lastMoveEvent=ht,rt.lastMoveEventInfo=transformPoint(pt,rt.transformPagePoint),isMouseEvent(ht)&&ht.buttons===0){rt.handlePointerUp(ht,pt);return}sync.update(rt.updatePoint,!0)},this.handlePointerUp=function(ht,pt){rt.end();var mt=rt.handlers,ft=mt.onEnd,yt=mt.onSessionEnd,gt=getPanInfo(transformPoint(pt,rt.transformPagePoint),rt.history);rt.startEvent&&ft&&ft(ht,gt),yt&&yt(ht,gt)},!(isTouchEvent(et)&&et.touches.length>1)){this.handlers=tt,this.transformPagePoint=it;var st=extractEventInfo(et),at=transformPoint(st,this.transformPagePoint),ct=at.point,lt=getFrameData().timestamp;this.history=[__assign(__assign({},ct),{timestamp:lt})];var dt=tt.onSessionStart;dt&&dt(et,getPanInfo(at,this.history)),this.removeListeners=pipe$1(addPointerEvent(window,"pointermove",this.handlePointerMove),addPointerEvent(window,"pointerup",this.handlePointerUp),addPointerEvent(window,"pointercancel",this.handlePointerUp))}}return o.prototype.updateHandlers=function(et){this.handlers=et},o.prototype.end=function(){this.removeListeners&&this.removeListeners(),cancelSync.update(this.updatePoint)},o}();function transformPoint(o,et){return et?{point:et(o.point)}:o}function subtractPoint(o,et){return{x:o.x-et.x,y:o.y-et.y}}function getPanInfo(o,et){var tt=o.point;return{point:tt,delta:subtractPoint(tt,lastDevicePoint(et)),offset:subtractPoint(tt,startDevicePoint(et)),velocity:getVelocity(et,.1)}}function startDevicePoint(o){return o[0]}function lastDevicePoint(o){return o[o.length-1]}function getVelocity(o,et){if(o.length<2)return{x:0,y:0};for(var tt=o.length-1,nt=null,rt=lastDevicePoint(o);tt>=0&&(nt=o[tt],!(rt.timestamp-nt.timestamp>secondsToMilliseconds(et)));)tt--;if(!nt)return{x:0,y:0};var ot=(rt.timestamp-nt.timestamp)/1e3;if(ot===0)return{x:0,y:0};var it={x:(rt.x-nt.x)/ot,y:(rt.y-nt.y)/ot};return it.x===1/0&&(it.x=0),it.y===1/0&&(it.y=0),it}function calcLength(o){return o.max-o.min}function isNear(o,et,tt){return et===void 0&&(et=0),tt===void 0&&(tt=.01),distance(o,et)rt&&(o=tt?mix(rt,o,tt.max):Math.min(o,rt)),o}function calcRelativeAxisConstraints(o,et,tt){return{min:et!==void 0?o.min+et:void 0,max:tt!==void 0?o.max+tt-(o.max-o.min):void 0}}function calcRelativeConstraints(o,et){var tt=et.top,nt=et.left,rt=et.bottom,ot=et.right;return{x:calcRelativeAxisConstraints(o.x,nt,ot),y:calcRelativeAxisConstraints(o.y,tt,rt)}}function calcViewportAxisConstraints(o,et){var tt,nt=et.min-o.min,rt=et.max-o.max;return et.max-et.minnt?tt=progress(et.min,et.max-nt,o.min):nt>rt&&(tt=progress(o.min,o.max-rt,et.min)),clamp$1(0,1,tt)}function rebaseAxisConstraints(o,et){var tt={};return et.min!==void 0&&(tt.min=et.min-o.min),et.max!==void 0&&(tt.max=et.max-o.min),tt}var defaultElastic=.35;function resolveDragElastic(o){return o===void 0&&(o=defaultElastic),o===!1?o=0:o===!0&&(o=defaultElastic),{x:resolveAxisElastic(o,"left","right"),y:resolveAxisElastic(o,"top","bottom")}}function resolveAxisElastic(o,et,tt){return{min:resolvePointElastic(o,et),max:resolvePointElastic(o,tt)}}function resolvePointElastic(o,et){var tt;return typeof o=="number"?o:(tt=o[et])!==null&&tt!==void 0?tt:0}var createAxisDelta=function(){return{translate:0,scale:1,origin:0,originPoint:0}},createDelta=function(){return{x:createAxisDelta(),y:createAxisDelta()}},createAxis=function(){return{min:0,max:0}},createBox=function(){return{x:createAxis(),y:createAxis()}};function eachAxis(o){return[o("x"),o("y")]}function convertBoundingBoxToBox(o){var et=o.top,tt=o.left,nt=o.right,rt=o.bottom;return{x:{min:tt,max:nt},y:{min:et,max:rt}}}function convertBoxToBoundingBox(o){var et=o.x,tt=o.y;return{top:tt.min,right:et.max,bottom:tt.max,left:et.min}}function transformBoxPoints(o,et){if(!et)return o;var tt=et({x:o.left,y:o.top}),nt=et({x:o.right,y:o.bottom});return{top:tt.y,left:tt.x,bottom:nt.y,right:nt.x}}function isIdentityScale(o){return o===void 0||o===1}function hasScale(o){var et=o.scale,tt=o.scaleX,nt=o.scaleY;return!isIdentityScale(et)||!isIdentityScale(tt)||!isIdentityScale(nt)}function hasTransform(o){return hasScale(o)||hasTranslate(o.x)||hasTranslate(o.y)||o.z||o.rotate||o.rotateX||o.rotateY}function hasTranslate(o){return o&&o!=="0%"}function scalePoint(o,et,tt){var nt=o-tt,rt=et*nt;return tt+rt}function applyPointDelta(o,et,tt,nt,rt){return rt!==void 0&&(o=scalePoint(o,rt,nt)),scalePoint(o,tt,nt)+et}function applyAxisDelta(o,et,tt,nt,rt){et===void 0&&(et=0),tt===void 0&&(tt=1),o.min=applyPointDelta(o.min,et,tt,nt,rt),o.max=applyPointDelta(o.max,et,tt,nt,rt)}function applyBoxDelta(o,et){var tt=et.x,nt=et.y;applyAxisDelta(o.x,tt.translate,tt.scale,tt.originPoint),applyAxisDelta(o.y,nt.translate,nt.scale,nt.originPoint)}function applyTreeDeltas(o,et,tt,nt){var rt,ot;nt===void 0&&(nt=!1);var it=tt.length;if(it){et.x=et.y=1;for(var st,at,ct=0;ctet?tt="y":Math.abs(o.x)>et&&(tt="x"),tt}function useDrag(o){var et=o.dragControls,tt=o.visualElement,nt=useConstant(function(){return new VisualElementDragControls(tt)});reactExports.useEffect(function(){return et&&et.subscribe(nt)},[nt,et]),reactExports.useEffect(function(){return nt.addListeners()},[nt])}function usePanGesture(o){var et=o.onPan,tt=o.onPanStart,nt=o.onPanEnd,rt=o.onPanSessionStart,ot=o.visualElement,it=et||tt||nt||rt,st=reactExports.useRef(null),at=reactExports.useContext(MotionConfigContext).transformPagePoint,ct={onSessionStart:rt,onStart:tt,onMove:et,onEnd:function(dt,ht){st.current=null,nt&&nt(dt,ht)}};reactExports.useEffect(function(){st.current!==null&&st.current.updateHandlers(ct)});function lt(dt){st.current=new PanSession(dt,ct,{transformPagePoint:at})}usePointerEvent(ot,"pointerdown",it&<),useUnmountEffect(function(){return st.current&&st.current.end()})}var drag={pan:makeRenderlessComponent(usePanGesture),drag:makeRenderlessComponent(useDrag)},names$1=["LayoutMeasure","BeforeLayoutMeasure","LayoutUpdate","ViewportBoxUpdate","Update","Render","AnimationComplete","LayoutAnimationComplete","AnimationStart","LayoutAnimationStart","SetAxisTarget","Unmount"];function createLifecycles(){var o=names$1.map(function(){return new SubscriptionManager$1}),et={},tt={clearAllListeners:function(){return o.forEach(function(nt){return nt.clear()})},updatePropListeners:function(nt){names$1.forEach(function(rt){var ot,it="on"+rt,st=nt[it];(ot=et[rt])===null||ot===void 0||ot.call(et),st&&(et[rt]=tt[it](st))})}};return o.forEach(function(nt,rt){tt["on"+names$1[rt]]=function(ot){return nt.add(ot)},tt["notify"+names$1[rt]]=function(){for(var ot=[],it=0;it=0?window.pageYOffset:null,ct=convertChangedValueTypes(et,o,st);return ot.length&&ot.forEach(function(lt){var dt=__read(lt,2),ht=dt[0],pt=dt[1];o.getValue(ht).set(pt)}),o.syncRender(),at!==null&&window.scrollTo({top:at}),{target:ct,transitionEnd:nt}}else return{target:et,transitionEnd:nt}};function unitConversion(o,et,tt,nt){return hasPositionalKey(et)?checkAndConvertChangedValueTypes(o,et,tt,nt):{target:et,transitionEnd:nt}}var parseDomVariant=function(o,et,tt,nt){var rt=resolveCSSVariables(o,et,nt);return et=rt.target,nt=rt.transitionEnd,unitConversion(o,et,tt,nt)};function getComputedStyle$1(o){return window.getComputedStyle(o)}var htmlConfig={treeType:"dom",readValueFromInstance:function(o,et){if(isTransformProp(et)){var tt=getDefaultValueType(et);return tt&&tt.default||0}else{var nt=getComputedStyle$1(o);return(isCSSVariable$1(et)?nt.getPropertyValue(et):nt[et])||0}},sortNodePosition:function(o,et){return o.compareDocumentPosition(et)&2?1:-1},getBaseTarget:function(o,et){var tt;return(tt=o.style)===null||tt===void 0?void 0:tt[et]},measureViewportBox:function(o,et){var tt=et.transformPagePoint;return measureViewportBox(o,tt)},resetTransform:function(o,et,tt){var nt=tt.transformTemplate;et.style.transform=nt?nt({},""):"none",o.scheduleRender()},restoreTransform:function(o,et){o.style.transform=et.style.transform},removeValueFromRenderState:function(o,et){var tt=et.vars,nt=et.style;delete tt[o],delete nt[o]},makeTargetAnimatable:function(o,et,tt,nt){var rt=tt.transformValues;nt===void 0&&(nt=!0);var ot=et.transition,it=et.transitionEnd,st=__rest(et,["transition","transitionEnd"]),at=getOrigin(st,ot||{},o);if(rt&&(it&&(it=rt(it)),st&&(st=rt(st)),at&&(at=rt(at))),nt){checkTargetForNewValues(o,st,at);var ct=parseDomVariant(o,st,at,it);it=ct.transitionEnd,st=ct.target}return __assign({transition:ot,transitionEnd:it},st)},scrapeMotionValuesFromProps:scrapeMotionValuesFromProps$1,build:function(o,et,tt,nt,rt){o.isVisible!==void 0&&(et.style.visibility=o.isVisible?"visible":"hidden"),buildHTMLStyles(et,tt,nt,rt.transformTemplate)},render:renderHTML},htmlVisualElement=visualElement(htmlConfig),svgVisualElement=visualElement(__assign(__assign({},htmlConfig),{getBaseTarget:function(o,et){return o[et]},readValueFromInstance:function(o,et){var tt;return isTransformProp(et)?((tt=getDefaultValueType(et))===null||tt===void 0?void 0:tt.default)||0:(et=camelCaseAttributes.has(et)?et:camelToDash(et),o.getAttribute(et))},scrapeMotionValuesFromProps,build:function(o,et,tt,nt,rt){buildSVGAttrs(et,tt,nt,rt.transformTemplate)},render:renderSVG})),createDomVisualElement=function(o,et){return isSVGComponent(o)?svgVisualElement(et,{enableHardwareAcceleration:!1}):htmlVisualElement(et,{enableHardwareAcceleration:!0})};function pixelsToPercent(o,et){return et.max===et.min?0:o/(et.max-et.min)*100}var correctBorderRadius={correct:function(o,et){if(!et.target)return o;if(typeof o=="string")if(px.test(o))o=parseFloat(o);else return o;var tt=pixelsToPercent(o,et.target.x),nt=pixelsToPercent(o,et.target.y);return"".concat(tt,"% ").concat(nt,"%")}},varToken="_$css",correctBoxShadow={correct:function(o,et){var tt=et.treeScale,nt=et.projectionDelta,rt=o,ot=o.includes("var("),it=[];ot&&(o=o.replace(cssVariableRegex,function(ft){return it.push(ft),varToken}));var st=complex.parse(o);if(st.length>5)return rt;var at=complex.createTransformer(o),ct=typeof st[0]!="number"?1:0,lt=nt.x.scale*tt.x,dt=nt.y.scale*tt.y;st[0+ct]/=lt,st[1+ct]/=dt;var ht=mix(lt,dt,.5);typeof st[2+ct]=="number"&&(st[2+ct]/=ht),typeof st[3+ct]=="number"&&(st[3+ct]/=ht);var pt=at(st);if(ot){var mt=0;pt=pt.replace(varToken,function(){var ft=it[mt];return mt++,ft})}return pt}},MeasureLayoutWithContext=function(o){__extends(et,o);function et(){return o!==null&&o.apply(this,arguments)||this}return et.prototype.componentDidMount=function(){var tt=this,nt=this.props,rt=nt.visualElement,ot=nt.layoutGroup,it=nt.switchLayoutGroup,st=nt.layoutId,at=rt.projection;addScaleCorrector(defaultScaleCorrectors),at&&(ot!=null&&ot.group&&ot.group.add(at),it!=null&&it.register&&st&&it.register(at),at.root.didUpdate(),at.addEventListener("animationComplete",function(){tt.safeToRemove()}),at.setOptions(__assign(__assign({},at.options),{onExitComplete:function(){return tt.safeToRemove()}}))),globalProjectionState.hasEverUpdated=!0},et.prototype.getSnapshotBeforeUpdate=function(tt){var nt=this,rt=this.props,ot=rt.layoutDependency,it=rt.visualElement,st=rt.drag,at=rt.isPresent,ct=it.projection;return ct&&(ct.isPresent=at,st||tt.layoutDependency!==ot||ot===void 0?ct.willUpdate():this.safeToRemove(),tt.isPresent!==at&&(at?ct.promote():ct.relegate()||sync.postRender(function(){var lt;!((lt=ct.getStack())===null||lt===void 0)&<.members.length||nt.safeToRemove()}))),null},et.prototype.componentDidUpdate=function(){var tt=this.props.visualElement.projection;tt&&(tt.root.didUpdate(),!tt.currentAnimation&&tt.isLead()&&this.safeToRemove())},et.prototype.componentWillUnmount=function(){var tt=this.props,nt=tt.visualElement,rt=tt.layoutGroup,ot=tt.switchLayoutGroup,it=nt.projection;it&&(it.scheduleCheckAfterUnmount(),rt!=null&&rt.group&&rt.group.remove(it),ot!=null&&ot.deregister&&ot.deregister(it))},et.prototype.safeToRemove=function(){var tt=this.props.safeToRemove;tt==null||tt()},et.prototype.render=function(){return null},et}(React.Component);function MeasureLayout(o){var et=__read(usePresence$1(),2),tt=et[0],nt=et[1],rt=reactExports.useContext(LayoutGroupContext);return React.createElement(MeasureLayoutWithContext,__assign({},o,{layoutGroup:rt,switchLayoutGroup:reactExports.useContext(SwitchLayoutGroupContext),isPresent:tt,safeToRemove:nt}))}var defaultScaleCorrectors={borderRadius:__assign(__assign({},correctBorderRadius),{applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]}),borderTopLeftRadius:correctBorderRadius,borderTopRightRadius:correctBorderRadius,borderBottomLeftRadius:correctBorderRadius,borderBottomRightRadius:correctBorderRadius,boxShadow:correctBoxShadow},layoutFeatures={measureLayout:MeasureLayout};function animate(o,et,tt){tt===void 0&&(tt={});var nt=isMotionValue(o)?o:motionValue(o);return startAnimation("",nt,et,tt),{stop:function(){return nt.stop()},isAnimating:function(){return nt.isAnimating()}}}var borders=["TopLeft","TopRight","BottomLeft","BottomRight"],numBorders=borders.length,asNumber=function(o){return typeof o=="string"?parseFloat(o):o},isPx=function(o){return typeof o=="number"||px.test(o)};function mixValues(o,et,tt,nt,rt,ot){var it,st,at,ct;rt?(o.opacity=mix(0,(it=tt.opacity)!==null&&it!==void 0?it:1,easeCrossfadeIn(nt)),o.opacityExit=mix((st=et.opacity)!==null&&st!==void 0?st:1,0,easeCrossfadeOut(nt))):ot&&(o.opacity=mix((at=et.opacity)!==null&&at!==void 0?at:1,(ct=tt.opacity)!==null&&ct!==void 0?ct:1,nt));for(var lt=0;ltet?1:tt(progress(o,et,nt))}}function copyAxisInto(o,et){o.min=et.min,o.max=et.max}function copyBoxInto(o,et){copyAxisInto(o.x,et.x),copyAxisInto(o.y,et.y)}function removePointDelta(o,et,tt,nt,rt){return o-=et,o=scalePoint(o,1/tt,nt),rt!==void 0&&(o=scalePoint(o,1/rt,nt)),o}function removeAxisDelta(o,et,tt,nt,rt,ot,it){if(et===void 0&&(et=0),tt===void 0&&(tt=1),nt===void 0&&(nt=.5),ot===void 0&&(ot=o),it===void 0&&(it=o),percent.test(et)){et=parseFloat(et);var st=mix(it.min,it.max,et/100);et=st-it.min}if(typeof et=="number"){var at=mix(ot.min,ot.max,nt);o===ot&&(at-=et),o.min=removePointDelta(o.min,et,tt,at,rt),o.max=removePointDelta(o.max,et,tt,at,rt)}}function removeAxisTransforms(o,et,tt,nt,rt){var ot=__read(tt,3),it=ot[0],st=ot[1],at=ot[2];removeAxisDelta(o,et[it],et[st],et[at],et.scale,nt,rt)}var xKeys=["x","scaleX","originX"],yKeys=["y","scaleY","originY"];function removeBoxTransforms(o,et,tt,nt){removeAxisTransforms(o.x,et,xKeys,tt==null?void 0:tt.x,nt==null?void 0:nt.x),removeAxisTransforms(o.y,et,yKeys,tt==null?void 0:tt.y,nt==null?void 0:nt.y)}function isAxisDeltaZero(o){return o.translate===0&&o.scale===1}function isDeltaZero(o){return isAxisDeltaZero(o.x)&&isAxisDeltaZero(o.y)}function boxEquals(o,et){return o.x.min===et.x.min&&o.x.max===et.x.max&&o.y.min===et.y.min&&o.y.max===et.y.max}var NodeStack=function(){function o(){this.members=[]}return o.prototype.add=function(et){addUniqueItem(this.members,et),et.scheduleRender()},o.prototype.remove=function(et){if(removeItem(this.members,et),et===this.prevLead&&(this.prevLead=void 0),et===this.lead){var tt=this.members[this.members.length-1];tt&&this.promote(tt)}},o.prototype.relegate=function(et){var tt=this.members.findIndex(function(it){return et===it});if(tt===0)return!1;for(var nt,rt=tt;rt>=0;rt--){var ot=this.members[rt];if(ot.isPresent!==!1){nt=ot;break}}return nt?(this.promote(nt),!0):!1},o.prototype.promote=function(et,tt){var nt,rt=this.lead;if(et!==rt&&(this.prevLead=rt,this.lead=et,et.show(),rt)){rt.instance&&rt.scheduleRender(),et.scheduleRender(),et.resumeFrom=rt,tt&&(et.resumeFrom.preserveOpacity=!0),rt.snapshot&&(et.snapshot=rt.snapshot,et.snapshot.latestValues=rt.animationValues||rt.latestValues,et.snapshot.isShared=!0),!((nt=et.root)===null||nt===void 0)&&nt.isUpdating&&(et.isLayoutDirty=!0);var ot=et.options.crossfade;ot===!1&&rt.hide()}},o.prototype.exitAnimationComplete=function(){this.members.forEach(function(et){var tt,nt,rt,ot,it;(nt=(tt=et.options).onExitComplete)===null||nt===void 0||nt.call(tt),(it=(rt=et.resumingFrom)===null||rt===void 0?void 0:(ot=rt.options).onExitComplete)===null||it===void 0||it.call(ot)})},o.prototype.scheduleRender=function(){this.members.forEach(function(et){et.instance&&et.scheduleRender(!1)})},o.prototype.removeLeadSnapshot=function(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)},o}(),identityProjection="translate3d(0px, 0px, 0) scale(1, 1) scale(1, 1)";function buildProjectionTransform(o,et,tt){var nt=o.x.translate/et.x,rt=o.y.translate/et.y,ot="translate3d(".concat(nt,"px, ").concat(rt,"px, 0) ");if(ot+="scale(".concat(1/et.x,", ").concat(1/et.y,") "),tt){var it=tt.rotate,st=tt.rotateX,at=tt.rotateY;it&&(ot+="rotate(".concat(it,"deg) ")),st&&(ot+="rotateX(".concat(st,"deg) ")),at&&(ot+="rotateY(".concat(at,"deg) "))}var ct=o.x.scale*et.x,lt=o.y.scale*et.y;return ot+="scale(".concat(ct,", ").concat(lt,")"),ot===identityProjection?"none":ot}var compareByDepth=function(o,et){return o.depth-et.depth},FlatTree=function(){function o(){this.children=[],this.isDirty=!1}return o.prototype.add=function(et){addUniqueItem(this.children,et),this.isDirty=!0},o.prototype.remove=function(et){removeItem(this.children,et),this.isDirty=!0},o.prototype.forEach=function(et){this.isDirty&&this.children.sort(compareByDepth),this.isDirty=!1,this.children.forEach(et)},o}(),animationTarget=1e3;function createProjectionNode(o){var et=o.attachResizeListener,tt=o.defaultParent,nt=o.measureScroll,rt=o.checkIsScrollRoot,ot=o.resetTransform;return function(){function it(st,at,ct){var lt=this;at===void 0&&(at={}),ct===void 0&&(ct=tt==null?void 0:tt()),this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.potentialNodes=new Map,this.checkUpdateFailed=function(){lt.isUpdating&&(lt.isUpdating=!1,lt.clearAllSnapshots())},this.updateProjection=function(){lt.nodes.forEach(resolveTargetDelta),lt.nodes.forEach(calcProjection)},this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.id=st,this.latestValues=at,this.root=ct?ct.root||ct:this,this.path=ct?__spreadArray(__spreadArray([],__read(ct.path),!1),[ct],!1):[],this.parent=ct,this.depth=ct?ct.depth+1:0,st&&this.root.registerPotentialNode(st,this);for(var dt=0;dt=0;nt--)if(o.path[nt].instance){tt=o.path[nt];break}var rt=tt&&tt!==o.root?tt.instance:document,ot=rt.querySelector('[data-projection-id="'.concat(et,'"]'));ot&&o.mount(ot,!0)}function roundAxis(o){o.min=Math.round(o.min),o.max=Math.round(o.max)}function roundBox(o){roundAxis(o.x),roundAxis(o.y)}var DocumentProjectionNode=createProjectionNode({attachResizeListener:function(o,et){return addDomEvent(o,"resize",et)},measureScroll:function(){return{x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}},checkIsScrollRoot:function(){return!0}}),rootProjectionNode={current:void 0},HTMLProjectionNode=createProjectionNode({measureScroll:function(o){return{x:o.scrollLeft,y:o.scrollTop}},defaultParent:function(){if(!rootProjectionNode.current){var o=new DocumentProjectionNode(0,{});o.mount(window),o.setOptions({layoutScroll:!0}),rootProjectionNode.current=o}return rootProjectionNode.current},resetTransform:function(o,et){o.style.transform=et??"none"},checkIsScrollRoot:function(o){return window.getComputedStyle(o).position==="fixed"}}),featureBundle=__assign(__assign(__assign(__assign({},animations),gestureAnimations),drag),layoutFeatures),motion=createMotionProxy(function(o,et){return createDomMotionConfig(o,et,featureBundle,createDomVisualElement,HTMLProjectionNode)});function useIsMounted$1(){var o=reactExports.useRef(!1);return useIsomorphicLayoutEffect$3(function(){return o.current=!0,function(){o.current=!1}},[]),o}function useForceUpdate(){var o=useIsMounted$1(),et=__read(reactExports.useState(0),2),tt=et[0],nt=et[1],rt=reactExports.useCallback(function(){o.current&&nt(tt+1)},[tt]),ot=reactExports.useCallback(function(){return sync.postRender(rt)},[rt]);return[ot,tt]}var PresenceChild=function(o){var et=o.children,tt=o.initial,nt=o.isPresent,rt=o.onExitComplete,ot=o.custom,it=o.presenceAffectsLayout,st=useConstant(newChildrenMap),at=useId$1(),ct=reactExports.useMemo(function(){return{id:at,initial:tt,isPresent:nt,custom:ot,onExitComplete:function(lt){var dt,ht;st.set(lt,!0);try{for(var pt=__values(st.values()),mt=pt.next();!mt.done;mt=pt.next()){var ft=mt.value;if(!ft)return}}catch(yt){dt={error:yt}}finally{try{mt&&!mt.done&&(ht=pt.return)&&ht.call(pt)}finally{if(dt)throw dt.error}}rt==null||rt()},register:function(lt){return st.set(lt,!1),function(){return st.delete(lt)}}}},it?void 0:[nt]);return reactExports.useMemo(function(){st.forEach(function(lt,dt){return st.set(dt,!1)})},[nt]),reactExports.useEffect(function(){!nt&&!st.size&&(rt==null||rt())},[nt]),reactExports.createElement(PresenceContext.Provider,{value:ct},et)};function newChildrenMap(){return new Map}var getChildKey=function(o){return o.key||""};function updateChildLookup(o,et){o.forEach(function(tt){var nt=getChildKey(tt);et.set(nt,tt)})}function onlyElements(o){var et=[];return reactExports.Children.forEach(o,function(tt){reactExports.isValidElement(tt)&&et.push(tt)}),et}var AnimatePresence=function(o){var et=o.children,tt=o.custom,nt=o.initial,rt=nt===void 0?!0:nt,ot=o.onExitComplete,it=o.exitBeforeEnter,st=o.presenceAffectsLayout,at=st===void 0?!0:st,ct=__read(useForceUpdate(),1),lt=ct[0],dt=reactExports.useContext(LayoutGroupContext).forceRender;dt&&(lt=dt);var ht=useIsMounted$1(),pt=onlyElements(et),mt=pt,ft=new Set,yt=reactExports.useRef(mt),gt=reactExports.useRef(new Map).current,xt=reactExports.useRef(!0);if(useIsomorphicLayoutEffect$3(function(){xt.current=!1,updateChildLookup(pt,gt),yt.current=mt}),useUnmountEffect(function(){xt.current=!0,gt.clear(),ft.clear()}),xt.current)return reactExports.createElement(reactExports.Fragment,null,mt.map(function(It){return reactExports.createElement(PresenceChild,{key:getChildKey(It),isPresent:!0,initial:rt?void 0:!1,presenceAffectsLayout:at},It)}));mt=__spreadArray([],__read(mt),!1);for(var vt=yt.current.map(getChildKey),bt=pt.map(getChildKey),Et=vt.length,wt=0;wt1&&console.warn("You're attempting to animate multiple children within AnimatePresence, but its exitBeforeEnter prop is set to true. This will lead to odd visual behaviour."),reactExports.createElement(reactExports.Fragment,null,ft.size?mt:mt.map(function(It){return reactExports.cloneElement(It)}))};function MotionConfig(o){var et=o.children,tt=o.isValidProp,nt=__rest(o,["children","isValidProp"]);tt&&loadExternalIsValidProp(tt),nt=__assign(__assign({},reactExports.useContext(MotionConfigContext)),nt),nt.isStatic=useConstant(function(){return nt.isStatic});var rt=reactExports.useMemo(function(){return nt},[JSON.stringify(nt.transition),nt.transformPagePoint,nt.reducedMotion]);return reactExports.createElement(MotionConfigContext.Provider,{value:rt},et)}var reactIs$2={exports:{}},reactIs_production_min$1={};/** * @license React * react-is.production.min.js * @@ -3870,10 +3870,10 @@ Vui lòng thử lại.`,injectionScreen_notconnected_h1:"Đăng nhập vào {{ C * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function _extends(){return _extends=Object.assign?Object.assign.bind():function(o){for(var et=1;et=0)&&(tt[rt]=o[rt]);return tt}function isModifiedEvent(o){return!!(o.metaKey||o.altKey||o.ctrlKey||o.shiftKey)}function shouldProcessLinkClick(o,et){return o.button===0&&(!et||et==="_self")&&!isModifiedEvent(o)}const _excluded=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],REACT_ROUTER_VERSION="6";try{window.__reactRouterVersion=REACT_ROUTER_VERSION}catch{}const START_TRANSITION="startTransition",startTransitionImpl=React$1[START_TRANSITION];function BrowserRouter(o){let{basename:et,children:tt,future:nt,window:rt}=o,ot=reactExports.useRef();ot.current==null&&(ot.current=createBrowserHistory({window:rt,v5Compat:!0}));let it=ot.current,[st,at]=reactExports.useState({action:it.action,location:it.location}),{v7_startTransition:ct}=nt||{},lt=reactExports.useCallback(dt=>{ct&&startTransitionImpl?startTransitionImpl(()=>at(dt)):at(dt)},[at,ct]);return reactExports.useLayoutEffect(()=>it.listen(lt),[it,lt]),reactExports.useEffect(()=>logV6DeprecationWarnings(nt),[nt]),reactExports.createElement(Router,{basename:et,children:tt,location:st.location,navigationType:st.action,navigator:it,future:nt})}const isBrowser$1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ABSOLUTE_URL_REGEX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Link=reactExports.forwardRef(function(et,tt){let{onClick:nt,relative:rt,reloadDocument:ot,replace:it,state:st,target:at,to:ct,preventScrollReset:lt,viewTransition:dt}=et,ht=_objectWithoutPropertiesLoose(et,_excluded),{basename:pt}=reactExports.useContext(NavigationContext),mt,ft=!1;if(typeof ct=="string"&&ABSOLUTE_URL_REGEX.test(ct)&&(mt=ct,isBrowser$1))try{let vt=new URL(window.location.href),bt=ct.startsWith("//")?new URL(vt.protocol+ct):new URL(ct),Et=stripBasename(bt.pathname,pt);bt.origin===vt.origin&&Et!=null?ct=Et+bt.search+bt.hash:ft=!0}catch{}let yt=useHref(ct,{relative:rt}),gt=useLinkClickHandler(ct,{replace:it,state:st,target:at,preventScrollReset:lt,relative:rt,viewTransition:dt});function xt(vt){nt&&nt(vt),vt.defaultPrevented||gt(vt)}return reactExports.createElement("a",_extends({},ht,{href:mt||yt,onClick:ft||ot?nt:xt,ref:tt,target:at}))});var DataRouterHook;(function(o){o.UseScrollRestoration="useScrollRestoration",o.UseSubmit="useSubmit",o.UseSubmitFetcher="useSubmitFetcher",o.UseFetcher="useFetcher",o.useViewTransitionState="useViewTransitionState"})(DataRouterHook||(DataRouterHook={}));var DataRouterStateHook;(function(o){o.UseFetcher="useFetcher",o.UseFetchers="useFetchers",o.UseScrollRestoration="useScrollRestoration"})(DataRouterStateHook||(DataRouterStateHook={}));function useLinkClickHandler(o,et){let{target:tt,replace:nt,state:rt,preventScrollReset:ot,relative:it,viewTransition:st}=et===void 0?{}:et,at=useNavigate(),ct=useLocation(),lt=useResolvedPath(o,{relative:it});return reactExports.useCallback(dt=>{if(shouldProcessLinkClick(dt,tt)){dt.preventDefault();let ht=nt!==void 0?nt:createPath(ct)===createPath(lt);at(o,{replace:ht,state:rt,preventScrollReset:ot,relative:it,viewTransition:st})}},[ct,at,lt,nt,rt,tt,o,ot,it,st])}function setRef(o,et){typeof o=="function"?o(et):o!=null&&(o.current=et)}function composeRefs(...o){return et=>o.forEach(tt=>setRef(tt,et))}function useComposedRefs(...o){return reactExports.useCallback(composeRefs(...o),o)}var Slot=reactExports.forwardRef((o,et)=>{const{children:tt,...nt}=o,rt=reactExports.Children.toArray(tt),ot=rt.find(isSlottable);if(ot){const it=ot.props.children,st=rt.map(at=>at===ot?reactExports.Children.count(it)>1?reactExports.Children.only(null):reactExports.isValidElement(it)?it.props.children:null:at);return jsxRuntimeExports.jsx(SlotClone,{...nt,ref:et,children:reactExports.isValidElement(it)?reactExports.cloneElement(it,void 0,st):null})}return jsxRuntimeExports.jsx(SlotClone,{...nt,ref:et,children:tt})});Slot.displayName="Slot";var SlotClone=reactExports.forwardRef((o,et)=>{const{children:tt,...nt}=o;if(reactExports.isValidElement(tt)){const rt=getElementRef$1(tt);return reactExports.cloneElement(tt,{...mergeProps(nt,tt.props),ref:et?composeRefs(et,rt):rt})}return reactExports.Children.count(tt)>1?reactExports.Children.only(null):null});SlotClone.displayName="SlotClone";var Slottable=({children:o})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:o});function isSlottable(o){return reactExports.isValidElement(o)&&o.type===Slottable}function mergeProps(o,et){const tt={...et};for(const nt in et){const rt=o[nt],ot=et[nt];/^on[A-Z]/.test(nt)?rt&&ot?tt[nt]=(...st)=>{ot(...st),rt(...st)}:rt&&(tt[nt]=rt):nt==="style"?tt[nt]={...rt,...ot}:nt==="className"&&(tt[nt]=[rt,ot].filter(Boolean).join(" "))}return{...o,...tt}}function getElementRef$1(o){var nt,rt;let et=(nt=Object.getOwnPropertyDescriptor(o.props,"ref"))==null?void 0:nt.get,tt=et&&"isReactWarning"in et&&et.isReactWarning;return tt?o.ref:(et=(rt=Object.getOwnPropertyDescriptor(o,"ref"))==null?void 0:rt.get,tt=et&&"isReactWarning"in et&&et.isReactWarning,tt?o.props.ref:o.props.ref||o.ref)}function r$1(o){var et,tt,nt="";if(typeof o=="string"||typeof o=="number")nt+=o;else if(typeof o=="object")if(Array.isArray(o))for(et=0;ettypeof o=="boolean"?"".concat(o):o===0?"0":o,cx=clsx$1,cva=(o,et)=>tt=>{var nt;if((et==null?void 0:et.variants)==null)return cx(o,tt==null?void 0:tt.class,tt==null?void 0:tt.className);const{variants:rt,defaultVariants:ot}=et,it=Object.keys(rt).map(ct=>{const lt=tt==null?void 0:tt[ct],dt=ot==null?void 0:ot[ct];if(lt===null)return null;const ht=falsyToString(lt)||falsyToString(dt);return rt[ct][ht]}),st=tt&&Object.entries(tt).reduce((ct,lt)=>{let[dt,ht]=lt;return ht===void 0||(ct[dt]=ht),ct},{}),at=et==null||(nt=et.compoundVariants)===null||nt===void 0?void 0:nt.reduce((ct,lt)=>{let{class:dt,className:ht,...pt}=lt;return Object.entries(pt).every(mt=>{let[ft,yt]=mt;return Array.isArray(yt)?yt.includes({...ot,...st}[ft]):{...ot,...st}[ft]===yt})?[...ct,dt,ht]:ct},[]);return cx(o,it,at,tt==null?void 0:tt.class,tt==null?void 0:tt.className)};function r(o){var et,tt,nt="";if(typeof o=="string"||typeof o=="number")nt+=o;else if(typeof o=="object")if(Array.isArray(o)){var rt=o.length;for(et=0;et{const et=createClassMap(o),{conflictingClassGroups:tt,conflictingClassGroupModifiers:nt}=o;return{getClassGroupId:it=>{const st=it.split(CLASS_PART_SEPARATOR);return st[0]===""&&st.length!==1&&st.shift(),getGroupRecursive(st,et)||getGroupIdForArbitraryProperty(it)},getConflictingClassGroupIds:(it,st)=>{const at=tt[it]||[];return st&&nt[it]?[...at,...nt[it]]:at}}},getGroupRecursive=(o,et)=>{var it;if(o.length===0)return et.classGroupId;const tt=o[0],nt=et.nextPart.get(tt),rt=nt?getGroupRecursive(o.slice(1),nt):void 0;if(rt)return rt;if(et.validators.length===0)return;const ot=o.join(CLASS_PART_SEPARATOR);return(it=et.validators.find(({validator:st})=>st(ot)))==null?void 0:it.classGroupId},arbitraryPropertyRegex=/^\[(.+)\]$/,getGroupIdForArbitraryProperty=o=>{if(arbitraryPropertyRegex.test(o)){const et=arbitraryPropertyRegex.exec(o)[1],tt=et==null?void 0:et.substring(0,et.indexOf(":"));if(tt)return"arbitrary.."+tt}},createClassMap=o=>{const{theme:et,prefix:tt}=o,nt={nextPart:new Map,validators:[]};return getPrefixedClassGroupEntries(Object.entries(o.classGroups),tt).forEach(([ot,it])=>{processClassesRecursively(it,nt,ot,et)}),nt},processClassesRecursively=(o,et,tt,nt)=>{o.forEach(rt=>{if(typeof rt=="string"){const ot=rt===""?et:getPart(et,rt);ot.classGroupId=tt;return}if(typeof rt=="function"){if(isThemeGetter(rt)){processClassesRecursively(rt(nt),et,tt,nt);return}et.validators.push({validator:rt,classGroupId:tt});return}Object.entries(rt).forEach(([ot,it])=>{processClassesRecursively(it,getPart(et,ot),tt,nt)})})},getPart=(o,et)=>{let tt=o;return et.split(CLASS_PART_SEPARATOR).forEach(nt=>{tt.nextPart.has(nt)||tt.nextPart.set(nt,{nextPart:new Map,validators:[]}),tt=tt.nextPart.get(nt)}),tt},isThemeGetter=o=>o.isThemeGetter,getPrefixedClassGroupEntries=(o,et)=>et?o.map(([tt,nt])=>{const rt=nt.map(ot=>typeof ot=="string"?et+ot:typeof ot=="object"?Object.fromEntries(Object.entries(ot).map(([it,st])=>[et+it,st])):ot);return[tt,rt]}):o,createLruCache=o=>{if(o<1)return{get:()=>{},set:()=>{}};let et=0,tt=new Map,nt=new Map;const rt=(ot,it)=>{tt.set(ot,it),et++,et>o&&(et=0,nt=tt,tt=new Map)};return{get(ot){let it=tt.get(ot);if(it!==void 0)return it;if((it=nt.get(ot))!==void 0)return rt(ot,it),it},set(ot,it){tt.has(ot)?tt.set(ot,it):rt(ot,it)}}},IMPORTANT_MODIFIER="!",createParseClassName=o=>{const{separator:et,experimentalParseClassName:tt}=o,nt=et.length===1,rt=et[0],ot=et.length,it=st=>{const at=[];let ct=0,lt=0,dt;for(let yt=0;ytlt?dt-lt:void 0;return{modifiers:at,hasImportantModifier:pt,baseClassName:mt,maybePostfixModifierPosition:ft}};return tt?st=>tt({className:st,parseClassName:it}):it},sortModifiers=o=>{if(o.length<=1)return o;const et=[];let tt=[];return o.forEach(nt=>{nt[0]==="["?(et.push(...tt.sort(),nt),tt=[]):tt.push(nt)}),et.push(...tt.sort()),et},createConfigUtils=o=>({cache:createLruCache(o.cacheSize),parseClassName:createParseClassName(o),...createClassGroupUtils(o)}),SPLIT_CLASSES_REGEX=/\s+/,mergeClassList=(o,et)=>{const{parseClassName:tt,getClassGroupId:nt,getConflictingClassGroupIds:rt}=et,ot=[],it=o.trim().split(SPLIT_CLASSES_REGEX);let st="";for(let at=it.length-1;at>=0;at-=1){const ct=it[at],{modifiers:lt,hasImportantModifier:dt,baseClassName:ht,maybePostfixModifierPosition:pt}=tt(ct);let mt=!!pt,ft=nt(mt?ht.substring(0,pt):ht);if(!ft){if(!mt){st=ct+(st.length>0?" "+st:st);continue}if(ft=nt(ht),!ft){st=ct+(st.length>0?" "+st:st);continue}mt=!1}const yt=sortModifiers(lt).join(":"),gt=dt?yt+IMPORTANT_MODIFIER:yt,xt=gt+ft;if(ot.includes(xt))continue;ot.push(xt);const vt=rt(ft,mt);for(let bt=0;bt0?" "+st:st)}return st};function twJoin(){let o=0,et,tt,nt="";for(;o{if(typeof o=="string")return o;let et,tt="";for(let nt=0;ntdt(lt),o());return tt=createConfigUtils(ct),nt=tt.cache.get,rt=tt.cache.set,ot=st,st(at)}function st(at){const ct=nt(at);if(ct)return ct;const lt=mergeClassList(at,tt);return rt(at,lt),lt}return function(){return ot(twJoin.apply(null,arguments))}}const fromTheme=o=>{const et=tt=>tt[o]||[];return et.isThemeGetter=!0,et},arbitraryValueRegex=/^\[(?:([a-z-]+):)?(.+)\]$/i,fractionRegex=/^\d+\/\d+$/,stringLengths=new Set(["px","full","screen"]),tshirtUnitRegex=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lengthUnitRegex=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,colorFunctionRegex=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,shadowRegex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,imageRegex=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,isLength=o=>isNumber(o)||stringLengths.has(o)||fractionRegex.test(o),isArbitraryLength=o=>getIsArbitraryValue(o,"length",isLengthOnly),isNumber=o=>!!o&&!Number.isNaN(Number(o)),isArbitraryNumber=o=>getIsArbitraryValue(o,"number",isNumber),isInteger$1=o=>!!o&&Number.isInteger(Number(o)),isPercent=o=>o.endsWith("%")&&isNumber(o.slice(0,-1)),isArbitraryValue=o=>arbitraryValueRegex.test(o),isTshirtSize=o=>tshirtUnitRegex.test(o),sizeLabels=new Set(["length","size","percentage"]),isArbitrarySize=o=>getIsArbitraryValue(o,sizeLabels,isNever),isArbitraryPosition=o=>getIsArbitraryValue(o,"position",isNever),imageLabels=new Set(["image","url"]),isArbitraryImage=o=>getIsArbitraryValue(o,imageLabels,isImage),isArbitraryShadow=o=>getIsArbitraryValue(o,"",isShadow),isAny=()=>!0,getIsArbitraryValue=(o,et,tt)=>{const nt=arbitraryValueRegex.exec(o);return nt?nt[1]?typeof et=="string"?nt[1]===et:et.has(nt[1]):tt(nt[2]):!1},isLengthOnly=o=>lengthUnitRegex.test(o)&&!colorFunctionRegex.test(o),isNever=()=>!1,isShadow=o=>shadowRegex.test(o),isImage=o=>imageRegex.test(o),getDefaultConfig=()=>{const o=fromTheme("colors"),et=fromTheme("spacing"),tt=fromTheme("blur"),nt=fromTheme("brightness"),rt=fromTheme("borderColor"),ot=fromTheme("borderRadius"),it=fromTheme("borderSpacing"),st=fromTheme("borderWidth"),at=fromTheme("contrast"),ct=fromTheme("grayscale"),lt=fromTheme("hueRotate"),dt=fromTheme("invert"),ht=fromTheme("gap"),pt=fromTheme("gradientColorStops"),mt=fromTheme("gradientColorStopPositions"),ft=fromTheme("inset"),yt=fromTheme("margin"),gt=fromTheme("opacity"),xt=fromTheme("padding"),vt=fromTheme("saturate"),bt=fromTheme("scale"),Et=fromTheme("sepia"),wt=fromTheme("skew"),kt=fromTheme("space"),It=fromTheme("translate"),Rt=()=>["auto","contain","none"],Pt=()=>["auto","hidden","clip","visible","scroll"],jt=()=>["auto",isArbitraryValue,et],Ot=()=>[isArbitraryValue,et],Bt=()=>["",isLength,isArbitraryLength],zt=()=>["auto",isNumber,isArbitraryValue],Ft=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Yt=()=>["solid","dashed","dotted","double","none"],Ht=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ut=()=>["start","end","center","between","around","evenly","stretch"],qt=()=>["","0",isArbitraryValue],Lt=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Zt=()=>[isNumber,isArbitraryValue];return{cacheSize:500,separator:":",theme:{colors:[isAny],spacing:[isLength,isArbitraryLength],blur:["none","",isTshirtSize,isArbitraryValue],brightness:Zt(),borderColor:[o],borderRadius:["none","","full",isTshirtSize,isArbitraryValue],borderSpacing:Ot(),borderWidth:Bt(),contrast:Zt(),grayscale:qt(),hueRotate:Zt(),invert:qt(),gap:Ot(),gradientColorStops:[o],gradientColorStopPositions:[isPercent,isArbitraryLength],inset:jt(),margin:jt(),opacity:Zt(),padding:Ot(),saturate:Zt(),scale:Zt(),sepia:qt(),skew:Zt(),space:Ot(),translate:Ot()},classGroups:{aspect:[{aspect:["auto","square","video",isArbitraryValue]}],container:["container"],columns:[{columns:[isTshirtSize]}],"break-after":[{"break-after":Lt()}],"break-before":[{"break-before":Lt()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Ft(),isArbitraryValue]}],overflow:[{overflow:Pt()}],"overflow-x":[{"overflow-x":Pt()}],"overflow-y":[{"overflow-y":Pt()}],overscroll:[{overscroll:Rt()}],"overscroll-x":[{"overscroll-x":Rt()}],"overscroll-y":[{"overscroll-y":Rt()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[ft]}],"inset-x":[{"inset-x":[ft]}],"inset-y":[{"inset-y":[ft]}],start:[{start:[ft]}],end:[{end:[ft]}],top:[{top:[ft]}],right:[{right:[ft]}],bottom:[{bottom:[ft]}],left:[{left:[ft]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",isInteger$1,isArbitraryValue]}],basis:[{basis:jt()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",isArbitraryValue]}],grow:[{grow:qt()}],shrink:[{shrink:qt()}],order:[{order:["first","last","none",isInteger$1,isArbitraryValue]}],"grid-cols":[{"grid-cols":[isAny]}],"col-start-end":[{col:["auto",{span:["full",isInteger$1,isArbitraryValue]},isArbitraryValue]}],"col-start":[{"col-start":zt()}],"col-end":[{"col-end":zt()}],"grid-rows":[{"grid-rows":[isAny]}],"row-start-end":[{row:["auto",{span:[isInteger$1,isArbitraryValue]},isArbitraryValue]}],"row-start":[{"row-start":zt()}],"row-end":[{"row-end":zt()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",isArbitraryValue]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",isArbitraryValue]}],gap:[{gap:[ht]}],"gap-x":[{"gap-x":[ht]}],"gap-y":[{"gap-y":[ht]}],"justify-content":[{justify:["normal",...Ut()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Ut(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Ut(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[xt]}],px:[{px:[xt]}],py:[{py:[xt]}],ps:[{ps:[xt]}],pe:[{pe:[xt]}],pt:[{pt:[xt]}],pr:[{pr:[xt]}],pb:[{pb:[xt]}],pl:[{pl:[xt]}],m:[{m:[yt]}],mx:[{mx:[yt]}],my:[{my:[yt]}],ms:[{ms:[yt]}],me:[{me:[yt]}],mt:[{mt:[yt]}],mr:[{mr:[yt]}],mb:[{mb:[yt]}],ml:[{ml:[yt]}],"space-x":[{"space-x":[kt]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[kt]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",isArbitraryValue,et]}],"min-w":[{"min-w":[isArbitraryValue,et,"min","max","fit"]}],"max-w":[{"max-w":[isArbitraryValue,et,"none","full","min","max","fit","prose",{screen:[isTshirtSize]},isTshirtSize]}],h:[{h:[isArbitraryValue,et,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[isArbitraryValue,et,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[isArbitraryValue,et,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[isArbitraryValue,et,"auto","min","max","fit"]}],"font-size":[{text:["base",isTshirtSize,isArbitraryLength]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",isArbitraryNumber]}],"font-family":[{font:[isAny]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",isArbitraryValue]}],"line-clamp":[{"line-clamp":["none",isNumber,isArbitraryNumber]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",isLength,isArbitraryValue]}],"list-image":[{"list-image":["none",isArbitraryValue]}],"list-style-type":[{list:["none","disc","decimal",isArbitraryValue]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[o]}],"placeholder-opacity":[{"placeholder-opacity":[gt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[o]}],"text-opacity":[{"text-opacity":[gt]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Yt(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",isLength,isArbitraryLength]}],"underline-offset":[{"underline-offset":["auto",isLength,isArbitraryValue]}],"text-decoration-color":[{decoration:[o]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Ot()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",isArbitraryValue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",isArbitraryValue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[gt]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Ft(),isArbitraryPosition]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",isArbitrarySize]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},isArbitraryImage]}],"bg-color":[{bg:[o]}],"gradient-from-pos":[{from:[mt]}],"gradient-via-pos":[{via:[mt]}],"gradient-to-pos":[{to:[mt]}],"gradient-from":[{from:[pt]}],"gradient-via":[{via:[pt]}],"gradient-to":[{to:[pt]}],rounded:[{rounded:[ot]}],"rounded-s":[{"rounded-s":[ot]}],"rounded-e":[{"rounded-e":[ot]}],"rounded-t":[{"rounded-t":[ot]}],"rounded-r":[{"rounded-r":[ot]}],"rounded-b":[{"rounded-b":[ot]}],"rounded-l":[{"rounded-l":[ot]}],"rounded-ss":[{"rounded-ss":[ot]}],"rounded-se":[{"rounded-se":[ot]}],"rounded-ee":[{"rounded-ee":[ot]}],"rounded-es":[{"rounded-es":[ot]}],"rounded-tl":[{"rounded-tl":[ot]}],"rounded-tr":[{"rounded-tr":[ot]}],"rounded-br":[{"rounded-br":[ot]}],"rounded-bl":[{"rounded-bl":[ot]}],"border-w":[{border:[st]}],"border-w-x":[{"border-x":[st]}],"border-w-y":[{"border-y":[st]}],"border-w-s":[{"border-s":[st]}],"border-w-e":[{"border-e":[st]}],"border-w-t":[{"border-t":[st]}],"border-w-r":[{"border-r":[st]}],"border-w-b":[{"border-b":[st]}],"border-w-l":[{"border-l":[st]}],"border-opacity":[{"border-opacity":[gt]}],"border-style":[{border:[...Yt(),"hidden"]}],"divide-x":[{"divide-x":[st]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[st]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[gt]}],"divide-style":[{divide:Yt()}],"border-color":[{border:[rt]}],"border-color-x":[{"border-x":[rt]}],"border-color-y":[{"border-y":[rt]}],"border-color-s":[{"border-s":[rt]}],"border-color-e":[{"border-e":[rt]}],"border-color-t":[{"border-t":[rt]}],"border-color-r":[{"border-r":[rt]}],"border-color-b":[{"border-b":[rt]}],"border-color-l":[{"border-l":[rt]}],"divide-color":[{divide:[rt]}],"outline-style":[{outline:["",...Yt()]}],"outline-offset":[{"outline-offset":[isLength,isArbitraryValue]}],"outline-w":[{outline:[isLength,isArbitraryLength]}],"outline-color":[{outline:[o]}],"ring-w":[{ring:Bt()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[o]}],"ring-opacity":[{"ring-opacity":[gt]}],"ring-offset-w":[{"ring-offset":[isLength,isArbitraryLength]}],"ring-offset-color":[{"ring-offset":[o]}],shadow:[{shadow:["","inner","none",isTshirtSize,isArbitraryShadow]}],"shadow-color":[{shadow:[isAny]}],opacity:[{opacity:[gt]}],"mix-blend":[{"mix-blend":[...Ht(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Ht()}],filter:[{filter:["","none"]}],blur:[{blur:[tt]}],brightness:[{brightness:[nt]}],contrast:[{contrast:[at]}],"drop-shadow":[{"drop-shadow":["","none",isTshirtSize,isArbitraryValue]}],grayscale:[{grayscale:[ct]}],"hue-rotate":[{"hue-rotate":[lt]}],invert:[{invert:[dt]}],saturate:[{saturate:[vt]}],sepia:[{sepia:[Et]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[tt]}],"backdrop-brightness":[{"backdrop-brightness":[nt]}],"backdrop-contrast":[{"backdrop-contrast":[at]}],"backdrop-grayscale":[{"backdrop-grayscale":[ct]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[lt]}],"backdrop-invert":[{"backdrop-invert":[dt]}],"backdrop-opacity":[{"backdrop-opacity":[gt]}],"backdrop-saturate":[{"backdrop-saturate":[vt]}],"backdrop-sepia":[{"backdrop-sepia":[Et]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[it]}],"border-spacing-x":[{"border-spacing-x":[it]}],"border-spacing-y":[{"border-spacing-y":[it]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",isArbitraryValue]}],duration:[{duration:Zt()}],ease:[{ease:["linear","in","out","in-out",isArbitraryValue]}],delay:[{delay:Zt()}],animate:[{animate:["none","spin","ping","pulse","bounce",isArbitraryValue]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[bt]}],"scale-x":[{"scale-x":[bt]}],"scale-y":[{"scale-y":[bt]}],rotate:[{rotate:[isInteger$1,isArbitraryValue]}],"translate-x":[{"translate-x":[It]}],"translate-y":[{"translate-y":[It]}],"skew-x":[{"skew-x":[wt]}],"skew-y":[{"skew-y":[wt]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",isArbitraryValue]}],accent:[{accent:["auto",o]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",isArbitraryValue]}],"caret-color":[{caret:[o]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Ot()}],"scroll-mx":[{"scroll-mx":Ot()}],"scroll-my":[{"scroll-my":Ot()}],"scroll-ms":[{"scroll-ms":Ot()}],"scroll-me":[{"scroll-me":Ot()}],"scroll-mt":[{"scroll-mt":Ot()}],"scroll-mr":[{"scroll-mr":Ot()}],"scroll-mb":[{"scroll-mb":Ot()}],"scroll-ml":[{"scroll-ml":Ot()}],"scroll-p":[{"scroll-p":Ot()}],"scroll-px":[{"scroll-px":Ot()}],"scroll-py":[{"scroll-py":Ot()}],"scroll-ps":[{"scroll-ps":Ot()}],"scroll-pe":[{"scroll-pe":Ot()}],"scroll-pt":[{"scroll-pt":Ot()}],"scroll-pr":[{"scroll-pr":Ot()}],"scroll-pb":[{"scroll-pb":Ot()}],"scroll-pl":[{"scroll-pl":Ot()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",isArbitraryValue]}],fill:[{fill:[o,"none"]}],"stroke-w":[{stroke:[isLength,isArbitraryLength,isArbitraryNumber]}],stroke:[{stroke:[o,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},twMerge=createTailwindMerge(getDefaultConfig);function cn(...o){return twMerge(clsx(o))}const buttonVariants=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Button=reactExports.forwardRef(({className:o,variant:et,size:tt,asChild:nt=!1,...rt},ot)=>{const it=nt?Slot:"button";return jsxRuntimeExports.jsx(it,{className:cn("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50","min-h-[44px] px-4 py-2 md:min-h-[36px] md:px-3 md:py-1.5",buttonVariants({variant:et,size:tt,className:o})),ref:ot,...rt})});Button.displayName="Button";function alloc$2(o=0){return new Uint8Array(o)}function allocUnsafe(o=0){return new Uint8Array(o)}const N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),MSB$2=128,REST$2=127;function encodingLength$3(o){if(oNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function encodeUint8Array(o,et,tt=0){switch(encodingLength$3(o)){case 8:et[tt++]=o&255|MSB$2,o/=128;case 7:et[tt++]=o&255|MSB$2,o/=128;case 6:et[tt++]=o&255|MSB$2,o/=128;case 5:et[tt++]=o&255|MSB$2,o/=128;case 4:et[tt++]=o&255|MSB$2,o>>>=7;case 3:et[tt++]=o&255|MSB$2,o>>>=7;case 2:et[tt++]=o&255|MSB$2,o>>>=7;case 1:{et[tt++]=o&255,o>>>=7;break}default:throw new Error("unreachable")}return et}function encodeUint8ArrayList(o,et,tt=0){switch(encodingLength$3(o)){case 8:et.set(tt++,o&255|MSB$2),o/=128;case 7:et.set(tt++,o&255|MSB$2),o/=128;case 6:et.set(tt++,o&255|MSB$2),o/=128;case 5:et.set(tt++,o&255|MSB$2),o/=128;case 4:et.set(tt++,o&255|MSB$2),o>>>=7;case 3:et.set(tt++,o&255|MSB$2),o>>>=7;case 2:et.set(tt++,o&255|MSB$2),o>>>=7;case 1:{et.set(tt++,o&255),o>>>=7;break}default:throw new Error("unreachable")}return et}function decodeUint8Array(o,et){let tt=o[et],nt=0;if(nt+=tt&REST$2,tt>>31>0){const tt=~this.lo+1>>>0;let nt=~this.hi>>>0;return tt===0&&(nt=nt+1>>>0),-(tt+nt*4294967296)}return this.lo+this.hi*4294967296}toBigInt(et=!1){if(et)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){const tt=~this.lo+1>>>0;let nt=~this.hi>>>0;return tt===0&&(nt=nt+1>>>0),-(BigInt(tt)+(BigInt(nt)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(et=!1){return this.toBigInt(et).toString()}zzEncode(){const et=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^et)>>>0,this.lo=(this.lo<<1^et)>>>0,this}zzDecode(){const et=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^et)>>>0,this.hi=(this.hi>>>1^et)>>>0,this}length(){const et=this.lo,tt=(this.lo>>>28|this.hi<<4)>>>0,nt=this.hi>>>24;return nt===0?tt===0?et<16384?et<128?1:2:et<2097152?3:4:tt<16384?tt<128?5:6:tt<2097152?7:8:nt<128?9:10}static fromBigInt(et){if(et===0n)return zero;if(etMIN_SAFE_NUMBER_INTEGER)return this.fromNumber(Number(et));const tt=et<0n;tt&&(et=-et);let nt=et>>32n,rt=et-(nt<<32n);return tt&&(nt=~nt|0n,rt=~rt|0n,++rt>TWO_32&&(rt=0n,++nt>TWO_32&&(nt=0n))),new Er(Number(rt),Number(nt))}static fromNumber(et){if(et===0)return zero;const tt=et<0;tt&&(et=-et);let nt=et>>>0,rt=(et-nt)/4294967296>>>0;return tt&&(rt=~rt>>>0,nt=~nt>>>0,++nt>4294967295&&(nt=0,++rt>4294967295&&(rt=0))),new Er(nt,rt)}static from(et){return typeof et=="number"?Er.fromNumber(et):typeof et=="bigint"?Er.fromBigInt(et):typeof et=="string"?Er.fromBigInt(BigInt(et)):et.low!=null||et.high!=null?new Er(et.low>>>0,et.high>>>0):zero}};const zero=new LongBits$2(0,0);zero.toBigInt=function(){return 0n};zero.zzEncode=zero.zzDecode=function(){return this};zero.length=function(){return 1};const TWO_32=4294967296n;function length$1(o){let et=0,tt=0;for(let nt=0;nt191&&st<224?ot[it++]=(st&31)<<6|o[et++]&63:st>239&&st<365?(st=((st&7)<<18|(o[et++]&63)<<12|(o[et++]&63)<<6|o[et++]&63)-65536,ot[it++]=55296+(st>>10),ot[it++]=56320+(st&1023)):ot[it++]=(st&15)<<12|(o[et++]&63)<<6|o[et++]&63,it>8191&&((rt??(rt=[])).push(String.fromCharCode.apply(String,ot)),it=0);return rt!=null?(it>0&&rt.push(String.fromCharCode.apply(String,ot.slice(0,it))),rt.join("")):String.fromCharCode.apply(String,ot.slice(0,it))}function write$2(o,et,tt){const nt=tt;let rt,ot;for(let it=0;it>6|192,et[tt++]=rt&63|128):(rt&64512)===55296&&((ot=o.charCodeAt(it+1))&64512)===56320?(rt=65536+((rt&1023)<<10)+(ot&1023),++it,et[tt++]=rt>>18|240,et[tt++]=rt>>12&63|128,et[tt++]=rt>>6&63|128,et[tt++]=rt&63|128):(et[tt++]=rt>>12|224,et[tt++]=rt>>6&63|128,et[tt++]=rt&63|128);return tt-nt}function indexOutOfRange$1(o,et){return RangeError(`index out of range: ${o.pos} + ${et??1} > ${o.len}`)}function readFixed32End(o,et){return(o[et-4]|o[et-3]<<8|o[et-2]<<16|o[et-1]<<24)>>>0}class Uint8ArrayReader{constructor(et){Ct(this,"buf");Ct(this,"pos");Ct(this,"len");Ct(this,"_slice",Uint8Array.prototype.subarray);this.buf=et,this.pos=0,this.len=et.length}uint32(){let et=4294967295;if(et=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(et=(et|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(et=(et|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(et=(et|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(et=(et|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return et;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange$1(this,10);return et}int32(){return this.uint32()|0}sint32(){const et=this.uint32();return et>>>1^-(et&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);const et=readFloatLE(this.buf,this.pos);return this.pos+=4,et}double(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,4);const et=readDoubleLE(this.buf,this.pos);return this.pos+=8,et}bytes(){const et=this.uint32(),tt=this.pos,nt=this.pos+et;if(nt>this.len)throw indexOutOfRange$1(this,et);return this.pos+=et,tt===nt?new Uint8Array(0):this.buf.subarray(tt,nt)}string(){const et=this.bytes();return read$2(et,0,et.length)}skip(et){if(typeof et=="number"){if(this.pos+et>this.len)throw indexOutOfRange$1(this,et);this.pos+=et}else do if(this.pos>=this.len)throw indexOutOfRange$1(this);while(this.buf[this.pos++]&128);return this}skipType(et){switch(et){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(et=this.uint32()&7)!==4;)this.skipType(et);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${et} at offset ${this.pos}`)}return this}readLongVarint(){const et=new LongBits$2(0,0);let tt=0;if(this.len-this.pos>4){for(;tt<4;++tt)if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et;if(et.lo=(et.lo|(this.buf[this.pos]&127)<<28)>>>0,et.hi=(et.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return et;tt=0}else{for(;tt<3;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}return et.lo=(et.lo|(this.buf[this.pos++]&127)<>>0,et}if(this.len-this.pos>4){for(;tt<5;++tt)if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}else for(;tt<5;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,8);const et=readFixed32End(this.buf,this.pos+=4),tt=readFixed32End(this.buf,this.pos+=4);return new LongBits$2(et,tt)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const et=decodeUint8Array(this.buf,this.pos);return this.pos+=encodingLength$3(et),et}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function createReader(o){return new Uint8ArrayReader(o instanceof Uint8Array?o:o.subarray())}function decodeMessage(o,et,tt){const nt=createReader(o);return et.decode(nt,void 0,tt)}function equals$2(o,et){if(o===et)return!0;if(o.byteLength!==et.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),nt=0;nt>>0,bt=new Uint8Array(vt);gt!==xt;){for(var Et=mt[gt],wt=0,kt=vt-1;(Et!==0||wt>>0,bt[kt]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=wt,gt++}for(var It=vt-yt;It!==vt&&bt[It]===0;)It++;for(var Rt=at.repeat(ft);It>>0,vt=new Uint8Array(xt);mt[ft];){var bt=tt[mt.charCodeAt(ft)];if(bt===255)return;for(var Et=0,wt=xt-1;(bt!==0||Et>>0,vt[wt]=bt%256>>>0,bt=bt/256>>>0;if(bt!==0)throw new Error("Non-zero carry");gt=Et,ft++}if(mt[ft]!==" "){for(var kt=xt-gt;kt!==xt&&vt[kt]===0;)kt++;for(var It=new Uint8Array(yt+(xt-kt)),Rt=yt;kt!==xt;)It[Rt++]=vt[kt++];return It}}}function pt(mt){var ft=ht(mt);if(ft)return ft;throw new Error(`Non-${et} character`)}return{encode:dt,decodeUnsafe:ht,decode:pt}}var src$1=base$1,_brrp__multiformats_scope_baseX=src$1;let Encoder$2=class{constructor(et,tt,nt){Ct(this,"name");Ct(this,"prefix");Ct(this,"baseEncode");this.name=et,this.prefix=tt,this.baseEncode=nt}encode(et){if(et instanceof Uint8Array)return`${this.prefix}${this.baseEncode(et)}`;throw Error("Unknown type, must be binary type")}},Decoder$2=class{constructor(et,tt,nt){Ct(this,"name");Ct(this,"prefix");Ct(this,"baseDecode");Ct(this,"prefixCodePoint");this.name=et,this.prefix=tt;const rt=tt.codePointAt(0);if(rt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=rt,this.baseDecode=nt}decode(et){if(typeof et=="string"){if(et.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(et)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(et.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(et){return or$2(this,et)}};class ComposedDecoder{constructor(et){Ct(this,"decoders");this.decoders=et}or(et){return or$2(this,et)}decode(et){const tt=et[0],nt=this.decoders[tt];if(nt!=null)return nt.decode(et);throw RangeError(`Unable to decode multibase string ${JSON.stringify(et)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function or$2(o,et){return new ComposedDecoder({...o.decoders??{[o.prefix]:o},...et.decoders??{[et.prefix]:et}})}class Codec{constructor(et,tt,nt,rt){Ct(this,"name");Ct(this,"prefix");Ct(this,"baseEncode");Ct(this,"baseDecode");Ct(this,"encoder");Ct(this,"decoder");this.name=et,this.prefix=tt,this.baseEncode=nt,this.baseDecode=rt,this.encoder=new Encoder$2(et,tt,nt),this.decoder=new Decoder$2(et,tt,rt)}encode(et){return this.encoder.encode(et)}decode(et){return this.decoder.decode(et)}}function from$2({name:o,prefix:et,encode:tt,decode:nt}){return new Codec(o,et,tt,nt)}function baseX({name:o,prefix:et,alphabet:tt}){const{encode:nt,decode:rt}=_brrp__multiformats_scope_baseX(tt,o);return from$2({prefix:et,name:o,encode:nt,decode:ot=>coerce(rt(ot))})}function decode$a(o,et,tt,nt){const rt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$9(o,et,tt){const nt=et[et.length-1]==="=",rt=(1<tt;)it-=tt,ot+=et[rt&st>>it];if(it!==0&&(ot+=et[rt&st<(o[tt]=et,o),[]),alphabetCharsToBytes=alphabet.reduce((o,et,tt)=>{const nt=et.codePointAt(0);if(nt==null)throw new Error(`Invalid character: ${et}`);return o[nt]=tt,o},[]);function encode$8(o){return o.reduce((et,tt)=>(et+=alphabetBytesToChars[tt],et),"")}function decode$9(o){const et=[];for(const tt of o){const nt=tt.codePointAt(0);if(nt==null)throw new Error(`Invalid character: ${tt}`);const rt=alphabetCharsToBytes[nt];if(rt==null)throw new Error(`Non-base256emoji character: ${tt}`);et.push(rt)}return new Uint8Array(et)}const base256emoji=from$2({prefix:"🚀",name:"base256emoji",encode:encode$8,decode:decode$9}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"})),base32$2=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$3=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$2,base32hex,base32hexpad,base32hexpadupper,base32hexupper,base32pad,base32padupper,base32upper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base58btc=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr=baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58=Object.freeze(Object.defineProperty({__proto__:null,base58btc,base58flickr},Symbol.toStringTag,{value:"Module"})),base64$2=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$3=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$2,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),identity$1=from$2({prefix:"\0",name:"identity",encode:o=>toString$9(o),decode:o=>fromString$1(o)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$1},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;var encode_1=encode$7,MSB$1=128,REST$1=127,MSBALL=~REST$1,INT=Math.pow(2,31);function encode$7(o,et,tt){et=et||[],tt=tt||0;for(var nt=tt;o>=INT;)et[tt++]=o&255|MSB$1,o/=128;for(;o&MSBALL;)et[tt++]=o&255|MSB$1,o>>>=7;return et[tt]=o|0,encode$7.bytes=tt-nt+1,et}var decode$8=read$1,MSB$1$1=128,REST$1$1=127;function read$1(o,nt){var tt=0,nt=nt||0,rt=0,ot=nt,it,st=o.length;do{if(ot>=st)throw read$1.bytes=0,new RangeError("Could not decode varint");it=o[ot++],tt+=rt<28?(it&REST$1$1)<=MSB$1$1);return read$1.bytes=ot-nt,tt}var N1=Math.pow(2,7),N2=Math.pow(2,14),N3=Math.pow(2,21),N4=Math.pow(2,28),N5=Math.pow(2,35),N6=Math.pow(2,42),N7=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length=function(o){return ocreate$3(this.code,nt))}else throw Error("Unknown type, must be binary type")}}function sha(o){return async et=>new Uint8Array(await crypto.subtle.digest(o,et))}const sha256=from$1({name:"sha2-256",code:18,encode:sha("SHA-256")});function format(o,et){const{bytes:tt,version:nt}=o;switch(nt){case 0:return toStringV0(tt,baseCache(o),et??base58btc.encoder);default:return toStringV1(tt,baseCache(o),et??base32$2.encoder)}}const cache$1=new WeakMap;function baseCache(o){const et=cache$1.get(o);if(et==null){const tt=new Map;return cache$1.set(o,tt),tt}return et}var Qs;class CID{constructor(et,tt,nt,rt){Ct(this,"code");Ct(this,"version");Ct(this,"multihash");Ct(this,"bytes");Ct(this,"/");Ct(this,Qs,"CID");this.code=tt,this.version=et,this.multihash=nt,this.bytes=rt,this["/"]=rt}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{const{code:et,multihash:tt}=this;if(et!==DAG_PB_CODE)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(tt.code!==SHA_256_CODE)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return CID.createV0(tt)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{const{code:et,digest:tt}=this.multihash,nt=create$3(et,tt);return CID.createV1(this.code,nt)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(et){return CID.equals(this,et)}static equals(et,tt){const nt=tt;return nt!=null&&et.code===nt.code&&et.version===nt.version&&equals$1(et.multihash,nt.multihash)}toString(et){return format(this,et)}toJSON(){return{"/":format(this)}}link(){return this}[(Qs=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(et){if(et==null)return null;const tt=et;if(tt instanceof CID)return tt;if(tt["/"]!=null&&tt["/"]===tt.bytes||tt.asCID===tt){const{version:nt,code:rt,multihash:ot,bytes:it}=tt;return new CID(nt,rt,ot,it??encodeCID(nt,rt,ot.bytes))}else if(tt[cidSymbol]===!0){const{version:nt,multihash:rt,code:ot}=tt,it=decode$6(rt);return CID.create(nt,ot,it)}else return null}static create(et,tt,nt){if(typeof tt!="number")throw new Error("String codecs are no longer supported");if(!(nt.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(et){case 0:{if(tt!==DAG_PB_CODE)throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);return new CID(et,tt,nt,nt.bytes)}case 1:{const rt=encodeCID(et,tt,nt.bytes);return new CID(et,tt,nt,rt)}default:throw new Error("Invalid version")}}static createV0(et){return CID.create(0,DAG_PB_CODE,et)}static createV1(et,tt){return CID.create(1,et,tt)}static decode(et){const[tt,nt]=CID.decodeFirst(et);if(nt.length!==0)throw new Error("Incorrect length");return tt}static decodeFirst(et){const tt=CID.inspectBytes(et),nt=tt.size-tt.multihashSize,rt=coerce(et.subarray(nt,nt+tt.multihashSize));if(rt.byteLength!==tt.multihashSize)throw new Error("Incorrect length");const ot=rt.subarray(tt.multihashSize-tt.digestSize),it=new Digest(tt.multihashCode,tt.digestSize,ot,rt);return[tt.version===0?CID.createV0(it):CID.createV1(tt.codec,it),et.subarray(tt.size)]}static inspectBytes(et){let tt=0;const nt=()=>{const[dt,ht]=decode$7(et.subarray(tt));return tt+=ht,dt};let rt=nt(),ot=DAG_PB_CODE;if(rt===18?(rt=0,tt=0):ot=nt(),rt!==0&&rt!==1)throw new RangeError(`Invalid CID version ${rt}`);const it=tt,st=nt(),at=nt(),ct=tt+at,lt=ct-it;return{version:rt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(et,tt){const[nt,rt]=parseCIDtoBytes(et,tt),ot=CID.decode(rt);if(ot.version===0&&et[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache(ot).set(nt,et),ot}}function parseCIDtoBytes(o,et){switch(o[0]){case"Q":{const tt=et??base58btc;return[base58btc.prefix,tt.decode(`${base58btc.prefix}${o}`)]}case base58btc.prefix:{const tt=et??base58btc;return[base58btc.prefix,tt.decode(o)]}case base32$2.prefix:{const tt=et??base32$2;return[base32$2.prefix,tt.decode(o)]}case base36.prefix:{const tt=et??base36;return[base36.prefix,tt.decode(o)]}default:{if(et==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[o[0],et.decode(o)]}}}function toStringV0(o,et,tt){const{prefix:nt}=tt;if(nt!==base58btc.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const rt=et.get(nt);if(rt==null){const ot=tt.encode(o).slice(1);return et.set(nt,ot),ot}else return rt}function toStringV1(o,et,tt){const{prefix:nt}=tt,rt=et.get(nt);if(rt==null){const ot=tt.encode(o);return et.set(nt,ot),ot}else return rt}const DAG_PB_CODE=112,SHA_256_CODE=18;function encodeCID(o,et,tt){const nt=encodingLength$2(o),rt=nt+encodingLength$2(et),ot=new Uint8Array(rt+tt.byteLength);return encodeTo(o,ot,0),encodeTo(et,ot,nt),ot.set(tt,rt),ot}const cidSymbol=Symbol.for("@ipld/js-cid/CID"),bases={...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$3,...base36$1,...base58,...base64$3,...base256emoji$1};function createCodec$1(o,et,tt,nt){return{name:o,prefix:et,encoder:{name:o,prefix:et,encode:tt},decoder:{decode:nt}}}const string$4=createCodec$1("utf8","u",o=>"u"+new TextDecoder("utf8").decode(o),o=>new TextEncoder().encode(o.substring(1))),ascii=createCodec$1("ascii","a",o=>{let et="a";for(let tt=0;tt{o=o.substring(1);const et=allocUnsafe(o.length);for(let tt=0;tt4096)return allocUnsafe(it);rt+it>8192&&(nt=allocUnsafe(8192),rt=0);const st=nt.subarray(rt,rt+=it);return rt&7&&(rt=(rt|7)+1),st}}let Op$1=class{constructor(et,tt,nt){Ct(this,"fn");Ct(this,"len");Ct(this,"next");Ct(this,"val");this.fn=et,this.len=tt,this.next=void 0,this.val=nt}};function noop$2(){}let State$1=class{constructor(et){Ct(this,"head");Ct(this,"tail");Ct(this,"len");Ct(this,"next");this.head=et.head,this.tail=et.tail,this.len=et.len,this.next=et.states}};const bufferPool=pool$1();function alloc$1(o){return globalThis.Buffer!=null?allocUnsafe(o):bufferPool(o)}class Uint8ArrayWriter{constructor(){Ct(this,"len");Ct(this,"head");Ct(this,"tail");Ct(this,"states");this.len=0,this.head=new Op$1(noop$2,0,0),this.tail=this.head,this.states=null}_push(et,tt,nt){return this.tail=this.tail.next=new Op$1(et,tt,nt),this.len+=tt,this}uint32(et){return this.len+=(this.tail=this.tail.next=new VarintOp$1((et=et>>>0)<128?1:et<16384?2:et<2097152?3:et<268435456?4:5,et)).len,this}int32(et){return et<0?this._push(writeVarint64$1,10,LongBits$2.fromNumber(et)):this.uint32(et)}sint32(et){return this.uint32((et<<1^et>>31)>>>0)}uint64(et){const tt=LongBits$2.fromBigInt(et);return this._push(writeVarint64$1,tt.length(),tt)}uint64Number(et){return this._push(encodeUint8Array,encodingLength$3(et),et)}uint64String(et){return this.uint64(BigInt(et))}int64(et){return this.uint64(et)}int64Number(et){return this.uint64Number(et)}int64String(et){return this.uint64String(et)}sint64(et){const tt=LongBits$2.fromBigInt(et).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64Number(et){const tt=LongBits$2.fromNumber(et).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64String(et){return this.sint64(BigInt(et))}bool(et){return this._push(writeByte$1,1,et?1:0)}fixed32(et){return this._push(writeFixed32$1,4,et>>>0)}sfixed32(et){return this.fixed32(et)}fixed64(et){const tt=LongBits$2.fromBigInt(et);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.hi)}fixed64Number(et){const tt=LongBits$2.fromNumber(et);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.hi)}fixed64String(et){return this.fixed64(BigInt(et))}sfixed64(et){return this.fixed64(et)}sfixed64Number(et){return this.fixed64Number(et)}sfixed64String(et){return this.fixed64String(et)}float(et){return this._push(writeFloatLE,4,et)}double(et){return this._push(writeDoubleLE,8,et)}bytes(et){const tt=et.length>>>0;return tt===0?this._push(writeByte$1,1,0):this.uint32(tt)._push(writeBytes$1,tt,et)}string(et){const tt=length$1(et);return tt!==0?this.uint32(tt)._push(write$2,tt,et):this._push(writeByte$1,1,0)}fork(){return this.states=new State$1(this),this.head=this.tail=new Op$1(noop$2,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op$1(noop$2,0,0),this.len=0),this}ldelim(){const et=this.head,tt=this.tail,nt=this.len;return this.reset().uint32(nt),nt!==0&&(this.tail.next=et.next,this.tail=tt,this.len+=nt),this}finish(){let et=this.head.next;const tt=alloc$1(this.len);let nt=0;for(;et!=null;)et.fn(et.val,tt,nt),nt+=et.len,et=et.next;return tt}}function writeByte$1(o,et,tt){et[tt]=o&255}function writeVarint32$1(o,et,tt){for(;o>127;)et[tt++]=o&127|128,o>>>=7;et[tt]=o}let VarintOp$1=class extends Op$1{constructor(tt,nt){super(writeVarint32$1,tt,nt);Ct(this,"next");this.next=void 0}};function writeVarint64$1(o,et,tt){for(;o.hi!==0;)et[tt++]=o.lo&127|128,o.lo=(o.lo>>>7|o.hi<<25)>>>0,o.hi>>>=7;for(;o.lo>127;)et[tt++]=o.lo&127|128,o.lo=o.lo>>>7;et[tt++]=o.lo}function writeFixed32$1(o,et,tt){et[tt]=o&255,et[tt+1]=o>>>8&255,et[tt+2]=o>>>16&255,et[tt+3]=o>>>24}function writeBytes$1(o,et,tt){et.set(o,tt)}globalThis.Buffer!=null&&(Uint8ArrayWriter.prototype.bytes=function(o){const et=o.length>>>0;return this.uint32(et),et>0&&this._push(writeBytesBuffer,et,o),this},Uint8ArrayWriter.prototype.string=function(o){const et=globalThis.Buffer.byteLength(o);return this.uint32(et),et>0&&this._push(writeStringBuffer$1,et,o),this});function writeBytesBuffer(o,et,tt){et.set(o,tt)}function writeStringBuffer$1(o,et,tt){o.length<40?write$2(o,et,tt):et.utf8Write!=null?et.utf8Write(o,tt):et.set(fromString(o),tt)}function createWriter(){return new Uint8ArrayWriter}function encodeMessage(o,et){const tt=createWriter();return et.encode(o,tt,{lengthDelimited:!1}),tt.finish()}var CODEC_TYPES;(function(o){o[o.VARINT=0]="VARINT",o[o.BIT64=1]="BIT64",o[o.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",o[o.START_GROUP=3]="START_GROUP",o[o.END_GROUP=4]="END_GROUP",o[o.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec(o,et,tt,nt){return{name:o,type:et,encode:tt,decode:nt}}function enumeration(o){function et(rt){if(o[rt.toString()]==null)throw new Error("Invalid enum value");return o[rt]}const tt=function(ot,it){const st=et(ot);it.int32(st)},nt=function(ot){const it=ot.int32();return et(it)};return createCodec("enum",CODEC_TYPES.VARINT,tt,nt)}function message$1(o,et){return createCodec("message",CODEC_TYPES.LENGTH_DELIMITED,o,et)}class MaxLengthError extends Error{constructor(){super(...arguments);Ct(this,"code","ERR_MAX_LENGTH");Ct(this,"name","MaxLengthError")}}class MaxSizeError extends Error{constructor(){super(...arguments);Ct(this,"code","ERR_MAX_SIZE");Ct(this,"name","MaxSizeError")}}var RateLimitProof$4;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$4||(RateLimitProof$4={}));var WakuMessage$4;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$4.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$4.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$4||(WakuMessage$4={}));var FilterRequest;(function(o){(function(tt){let nt;tt.codec=()=>(nt==null&&(nt=message$1((rt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),rt.contentTopic!=null&&rt.contentTopic!==""&&(ot.uint32(10),ot.string(rt.contentTopic)),it.lengthDelimited!==!1&&ot.ldelim()},(rt,ot,it={})=>{const st={contentTopic:""},at=ot==null?rt.len:rt.pos+ot;for(;rt.pos>>3){case 1:{st.contentTopic=rt.string();break}default:{rt.skipType(ct&7);break}}}return st})),nt),tt.encode=rt=>encodeMessage(rt,tt.codec()),tt.decode=(rt,ot)=>decodeMessage(rt,tt.codec(),ot)})(o.ContentFilter||(o.ContentFilter={}));let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.subscribe!=null&&tt.subscribe!==!1&&(nt.uint32(8),nt.bool(tt.subscribe)),tt.topic!=null&&tt.topic!==""&&(nt.uint32(18),nt.string(tt.topic)),tt.contentFilters!=null)for(const ot of tt.contentFilters)nt.uint32(26),o.ContentFilter.codec().encode(ot,nt);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={subscribe:!1,topic:"",contentFilters:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.subscribe=tt.bool();break}case 2:{ot.topic=tt.string();break}case 3:{if(((st=rt.limits)==null?void 0:st.contentFilters)!=null&&ot.contentFilters.length===rt.limits.contentFilters)throw new MaxLengthError('Decode error - map field "contentFilters" had too many elements');ot.contentFilters.push(o.ContentFilter.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.contentFilters$}));break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(FilterRequest||(FilterRequest={}));var MessagePush$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.messages!=null)for(const ot of tt.messages)nt.uint32(10),WakuMessage$3.codec().encode(ot,nt);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={messages:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{if(((st=rt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===rt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessage$3.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.messages$}));break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(MessagePush$1||(MessagePush$1={}));var FilterRpc;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.request!=null&&(nt.uint32(18),FilterRequest.codec().encode(tt.request,nt)),tt.push!=null&&(nt.uint32(26),MessagePush$1.codec().encode(tt.push,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=FilterRequest.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.request});break}case 3:{ot.push=MessagePush$1.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.push});break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(FilterRpc||(FilterRpc={}));var RateLimitProof$3;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$3||(RateLimitProof$3={}));var WakuMessage$3;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$3.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$3.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$3||(WakuMessage$3={}));var TopicOnlyMessage;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 2:{ot.contentTopic=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(TopicOnlyMessage||(TopicOnlyMessage={}));var FilterSubscribeRequest;(function(o){let et;(function(rt){rt.SUBSCRIBER_PING="SUBSCRIBER_PING",rt.SUBSCRIBE="SUBSCRIBE",rt.UNSUBSCRIBE="UNSUBSCRIBE",rt.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"})(et=o.FilterSubscribeType||(o.FilterSubscribeType={}));let tt;(function(rt){rt[rt.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",rt[rt.SUBSCRIBE=1]="SUBSCRIBE",rt[rt.UNSUBSCRIBE=2]="UNSUBSCRIBE",rt[rt.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"})(tt||(tt={})),function(rt){rt.codec=()=>enumeration(tt)}(et=o.FilterSubscribeType||(o.FilterSubscribeType={}));let nt;o.codec=()=>(nt==null&&(nt=message$1((rt,ot,it={})=>{if(it.lengthDelimited!==!1&&ot.fork(),rt.requestId!=null&&rt.requestId!==""&&(ot.uint32(10),ot.string(rt.requestId)),rt.filterSubscribeType!=null&&tt[rt.filterSubscribeType]!==0&&(ot.uint32(16),o.FilterSubscribeType.codec().encode(rt.filterSubscribeType,ot)),rt.pubsubTopic!=null&&(ot.uint32(82),ot.string(rt.pubsubTopic)),rt.contentTopics!=null)for(const st of rt.contentTopics)ot.uint32(90),ot.string(st);it.lengthDelimited!==!1&&ot.ldelim()},(rt,ot,it={})=>{var ct;const st={requestId:"",filterSubscribeType:et.SUBSCRIBER_PING,contentTopics:[]},at=ot==null?rt.len:rt.pos+ot;for(;rt.pos>>3){case 1:{st.requestId=rt.string();break}case 2:{st.filterSubscribeType=o.FilterSubscribeType.codec().decode(rt);break}case 10:{st.pubsubTopic=rt.string();break}case 11:{if(((ct=it.limits)==null?void 0:ct.contentTopics)!=null&&st.contentTopics.length===it.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');st.contentTopics.push(rt.string());break}default:{rt.skipType(lt&7);break}}}return st})),nt),o.encode=rt=>encodeMessage(rt,o.codec()),o.decode=(rt,ot)=>decodeMessage(rt,o.codec(),ot)})(FilterSubscribeRequest||(FilterSubscribeRequest={}));var FilterSubscribeResponse$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.statusCode!=null&&tt.statusCode!==0&&(nt.uint32(80),nt.uint32(tt.statusCode)),tt.statusDesc!=null&&(nt.uint32(90),nt.string(tt.statusDesc)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={requestId:"",statusCode:0},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(FilterSubscribeResponse$1||(FilterSubscribeResponse$1={}));var MessagePush;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.wakuMessage!=null&&(nt.uint32(10),WakuMessage$2.codec().encode(tt.wakuMessage,nt)),tt.pubsubTopic!=null&&(nt.uint32(18),nt.string(tt.pubsubTopic)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.wakuMessage=WakuMessage$2.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.wakuMessage});break}case 2:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(MessagePush||(MessagePush={}));var RateLimitProof$2;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$2||(RateLimitProof$2={}));var WakuMessage$2;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$2.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$2.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$2||(WakuMessage$2={}));var PushRequest;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.pubsubTopic!=null&&tt.pubsubTopic!==""&&(nt.uint32(10),nt.string(tt.pubsubTopic)),tt.message!=null&&(nt.uint32(18),WakuMessage$1.codec().encode(tt.message,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={pubsubTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.pubsubTopic=tt.string();break}case 2:{ot.message=WakuMessage$1.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.message});break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PushRequest||(PushRequest={}));var PushResponse;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.isSuccess!=null&&tt.isSuccess!==!1&&(nt.uint32(8),nt.bool(tt.isSuccess)),tt.info!=null&&(nt.uint32(18),nt.string(tt.info)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={isSuccess:!1},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.isSuccess=tt.bool();break}case 2:{ot.info=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PushResponse||(PushResponse={}));var PushRpc$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.request!=null&&(nt.uint32(18),PushRequest.codec().encode(tt.request,nt)),tt.response!=null&&(nt.uint32(26),PushResponse.codec().encode(tt.response,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=PushRequest.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.request});break}case 3:{ot.response=PushResponse.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PushRpc$1||(PushRpc$1={}));var RateLimitProof$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$1||(RateLimitProof$1={}));var WakuMessage$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$1.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$1.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$1||(WakuMessage$1={}));var WakuMessageKeyValue;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.messageHash!=null&&(nt.uint32(10),nt.bytes(tt.messageHash)),tt.message!=null&&(nt.uint32(18),WakuMessage.codec().encode(tt.message,nt)),tt.pubsubTopic!=null&&(nt.uint32(26),nt.string(tt.pubsubTopic)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.messageHash=tt.bytes();break}case 2:{ot.message=WakuMessage.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.message});break}case 3:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessageKeyValue||(WakuMessageKeyValue={}));var StoreQueryRequest$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.includeData!=null&&tt.includeData!==!1&&(nt.uint32(16),nt.bool(tt.includeData)),tt.pubsubTopic!=null&&(nt.uint32(82),nt.string(tt.pubsubTopic)),tt.contentTopics!=null)for(const ot of tt.contentTopics)nt.uint32(90),nt.string(ot);if(tt.timeStart!=null&&(nt.uint32(96),nt.sint64(tt.timeStart)),tt.timeEnd!=null&&(nt.uint32(104),nt.sint64(tt.timeEnd)),tt.messageHashes!=null)for(const ot of tt.messageHashes)nt.uint32(162),nt.bytes(ot);tt.paginationCursor!=null&&(nt.uint32(410),nt.bytes(tt.paginationCursor)),tt.paginationForward!=null&&tt.paginationForward!==!1&&(nt.uint32(416),nt.bool(tt.paginationForward)),tt.paginationLimit!=null&&(nt.uint32(424),nt.uint64(tt.paginationLimit)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:"",includeData:!1,contentTopics:[],messageHashes:[],paginationForward:!1},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.includeData=tt.bool();break}case 10:{ot.pubsubTopic=tt.string();break}case 11:{if(((st=rt.limits)==null?void 0:st.contentTopics)!=null&&ot.contentTopics.length===rt.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');ot.contentTopics.push(tt.string());break}case 12:{ot.timeStart=tt.sint64();break}case 13:{ot.timeEnd=tt.sint64();break}case 20:{if(((at=rt.limits)==null?void 0:at.messageHashes)!=null&&ot.messageHashes.length===rt.limits.messageHashes)throw new MaxLengthError('Decode error - map field "messageHashes" had too many elements');ot.messageHashes.push(tt.bytes());break}case 51:{ot.paginationCursor=tt.bytes();break}case 52:{ot.paginationForward=tt.bool();break}case 53:{ot.paginationLimit=tt.uint64();break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(StoreQueryRequest$1||(StoreQueryRequest$1={}));var StoreQueryResponse$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.statusCode!=null&&(nt.uint32(80),nt.uint32(tt.statusCode)),tt.statusDesc!=null&&(nt.uint32(90),nt.string(tt.statusDesc)),tt.messages!=null)for(const ot of tt.messages)nt.uint32(162),WakuMessageKeyValue.codec().encode(ot,nt);tt.paginationCursor!=null&&(nt.uint32(410),nt.bytes(tt.paginationCursor)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:"",messages:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}case 20:{if(((st=rt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===rt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessageKeyValue.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.messages$}));break}case 51:{ot.paginationCursor=tt.bytes();break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(StoreQueryResponse$1||(StoreQueryResponse$1={}));var RateLimitProof;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof||(RateLimitProof={}));var WakuMessage;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage||(WakuMessage={}));var PeerInfo;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.enr!=null&&(nt.uint32(10),nt.bytes(tt.enr)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.enr=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerInfo||(PeerInfo={}));var PeerExchangeQuery;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.numPeers!=null&&(nt.uint32(8),nt.uint64(tt.numPeers)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.numPeers=tt.uint64();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerExchangeQuery||(PeerExchangeQuery={}));var PeerExchangeResponse;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.peerInfos!=null)for(const ot of tt.peerInfos)nt.uint32(10),PeerInfo.codec().encode(ot,nt);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={peerInfos:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{if(((st=rt.limits)==null?void 0:st.peerInfos)!=null&&ot.peerInfos.length===rt.limits.peerInfos)throw new MaxLengthError('Decode error - map field "peerInfos" had too many elements');ot.peerInfos.push(PeerInfo.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.peerInfos$}));break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerExchangeResponse||(PeerExchangeResponse={}));var PeerExchangeRPC$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.query!=null&&(nt.uint32(10),PeerExchangeQuery.codec().encode(tt.query,nt)),tt.response!=null&&(nt.uint32(18),PeerExchangeResponse.codec().encode(tt.response,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.query=PeerExchangeQuery.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.query});break}case 2:{ot.response=PeerExchangeResponse.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerExchangeRPC$1||(PeerExchangeRPC$1={}));var WakuMetadataRequest;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.clusterId!=null&&(nt.uint32(8),nt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)nt.uint32(16),nt.uint32(ot);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={shards:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=rt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===rt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMetadataRequest||(WakuMetadataRequest={}));var WakuMetadataResponse;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.clusterId!=null&&(nt.uint32(8),nt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)nt.uint32(16),nt.uint32(ot);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={shards:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=rt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===rt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMetadataResponse||(WakuMetadataResponse={}));function isDefined(o){return!!o}function groupByContentTopic(o){const et=new Map;return o.forEach(tt=>{let nt=et.get(tt.contentTopic);nt||(et.set(tt.contentTopic,[]),nt=et.get(tt.contentTopic)),nt.push(tt)}),et}const FRAME_RATE=60;async function toAsyncIterator(o,et,tt){const nt=FRAME_RATE,rt=[];let ot;ot=await o.subscribeWithUnsubscribe(et,lt=>{rt.push(lt)});const it=Number.isInteger(tt==null?void 0:tt.timeoutMs),st=0,at=Date.now();async function*ct(){for(;;){if(it&&Date.now()-at>=st)return;await wait(nt);const lt=rt.shift();if(!ot&&rt.length===0)return lt;!lt&&ot||(yield lt)}}return{iterator:ct(),async stop(){ot&&(await ot(),ot=void 0)}}}function wait(o){return new Promise(et=>{setTimeout(et,o)})}const MB=1024**2,SIZE_CAP_IN_MB=1;async function isMessageSizeUnderCap(o,et){const tt=await o.toWire(et);return tt?isWireSizeUnderCap(tt):!1}const isWireSizeUnderCap=o=>o.length/MB<=SIZE_CAP_IN_MB;var Protocols;(function(o){o.Relay="relay",o.Store="store",o.LightPush="lightpush",o.Filter="filter"})(Protocols||(Protocols={}));var ProtocolError$1;(function(o){o.GENERIC_FAIL="Generic error",o.ENCODE_FAILED="Failed to encode",o.DECODE_FAILED="Failed to decode",o.EMPTY_PAYLOAD="Payload is empty",o.SIZE_TOO_BIG="Size is too big",o.TOPIC_NOT_CONFIGURED="Topic not configured",o.TOPIC_DECODER_MISMATCH="Topic decoder mismatch",o.INVALID_DECODER_TOPICS="Invalid decoder topics",o.NO_PEER_AVAILABLE="No peer available",o.NO_STREAM_AVAILABLE="No stream available",o.NO_RESPONSE="No response received",o.REMOTE_PEER_REJECTED="Remote peer rejected",o.REQUEST_TIMEOUT="Request timeout",o.RLN_IDENTITY_MISSING="Identity credentials are not set",o.RLN_MEMBERSHIP_INDEX="Membership index is not set",o.RLN_LIMIT_MISSING="User message limit is not set",o.RLN_PROOF_GENERATION="Proof generation failed"})(ProtocolError$1||(ProtocolError$1={}));var Tags;(function(o){o.BOOTSTRAP="bootstrap",o.PEER_EXCHANGE="peer-exchange",o.LOCAL="local-peer-cache"})(Tags||(Tags={}));var EPeersByDiscoveryEvents;(function(o){o.PEER_DISCOVERY_BOOTSTRAP="peer:discovery:bootstrap",o.PEER_DISCOVERY_PEER_EXCHANGE="peer:discovery:peer-exchange",o.PEER_CONNECT_BOOTSTRAP="peer:connected:bootstrap",o.PEER_CONNECT_PEER_EXCHANGE="peer:connected:peer-exchange"})(EPeersByDiscoveryEvents||(EPeersByDiscoveryEvents={}));var EConnectionStateEvents;(function(o){o.CONNECTION_STATUS="waku:connection"})(EConnectionStateEvents||(EConnectionStateEvents={}));const DNS_DISCOVERY_TAG="@waku/bootstrap",DEFAULT_CLUSTER_ID=1,DefaultShardInfo={clusterId:DEFAULT_CLUSTER_ID,shards:[0,1,2,3,4,5,6,7,8]},DefaultNetworkConfig=DefaultShardInfo;var HealthStatus;(function(o){o.Unhealthy="Unhealthy",o.MinimallyHealthy="MinimallyHealthy",o.SufficientlyHealthy="SufficientlyHealthy"})(HealthStatus||(HealthStatus={}));function toString$8(o,et="utf8"){const tt=BASES[et];if(tt==null)throw new Error(`Unsupported encoding "${et}"`);return tt.encoder.encode(o).substring(1)}function hexToBytes$1(o){if(typeof o=="string"){const et=o.replace(/^0x/i,"");return fromString(et.toLowerCase(),"base16")}return o}function numberToBytes(o){const et=new ArrayBuffer(8),tt=new DataView(et);return typeof o=="number"?tt.setFloat64(0,o,!1):tt.setBigInt64(0,o,!1),new Uint8Array(et)}const bytesToHex$1=o=>toString$8(o,"base16"),bytesToUtf8=o=>toString$8(o,"utf8"),utf8ToBytes$1=o=>fromString(o,"utf8");function concat$2(o,et){const tt=o.reduce((ot,it)=>ot+it.length,0),nt=new Uint8Array(tt);let rt=0;for(const ot of o)nt.set(ot,rt),rt+=ot.length;return nt}function isStaticSharding(o){return"clusterId"in o&&"shards"in o&&!("contentTopics"in o)}function isAutoSharding(o){return"contentTopics"in o}function derivePubsubTopicsFromNetworkConfig(o){if(isStaticSharding(o)){if(o.shards.length===0)throw new Error("Invalid shards configuration: please provide at least one shard");return shardInfoToPubsubTopics(o)}else if(isAutoSharding(o)){if(o.contentTopics.length===0)throw new Error("Invalid content topics configuration: please provide at least one content topic");return o.contentTopics.map(et=>contentTopicToPubsubTopic(et,o.clusterId))}else throw new Error("Unknown shard config. Please use ShardInfo or ContentTopicInfo")}const singleShardInfoToPubsubTopic=o=>{if(o.shard===void 0)throw new Error("Invalid shard");return`/waku/2/rs/${o.clusterId??DEFAULT_CLUSTER_ID}/${o.shard}`},shardInfoToPubsubTopics=o=>{if("contentTopics"in o&&o.contentTopics)return Array.from(new Set(o.contentTopics.map(et=>contentTopicToPubsubTopic(et,o.clusterId))));if("shards"in o){if(o.shards===void 0)throw new Error("Invalid shard");return Array.from(new Set(o.shards.map(et=>`/waku/2/rs/${o.clusterId??DEFAULT_CLUSTER_ID}/${et}`)))}else{if("application"in o&&"version"in o)return[contentTopicToPubsubTopic(`/${o.application}/${o.version}/default/default`,o.clusterId)];throw new Error("Missing required configuration in shard parameters")}},pubsubTopicToSingleShardInfo=o=>{const et=o.split("/");if(et.length!=6||et[1]!=="waku"||et[2]!=="2"||et[3]!=="rs")throw new Error("Invalid pubsub topic");const tt=parseInt(et[4]),nt=parseInt(et[5]);if(isNaN(tt)||isNaN(nt))throw new Error("Invalid clusterId or shard");return{clusterId:tt,shard:nt}},pubsubTopicsToShardInfo=o=>{const et=new Set,tt=new Set;for(const ot of o){const{clusterId:it,shard:st}=pubsubTopicToSingleShardInfo(ot);et.add(`${it}:${st}`),tt.add(it)}if(et.size===0)throw new Error("No valid pubsub topics provided");if(tt.size>1)throw new Error("Pubsub topics from multiple cluster IDs are not supported");const nt=tt.values().next().value,rt=Array.from(et).map(ot=>parseInt(ot.split(":")[1]));return{clusterId:nt,shards:rt}};function ensurePubsubTopicIsConfigured(o,et){if(!et.includes(o))throw new Error(`Pubsub topic ${o} has not been configured on this instance. Configured topics are: ${et}. Please update your configuration by passing in the topic during Waku node instantiation.`)}function ensureValidContentTopic(o){const et=o.split("/");if(et.length<5||et.length>6)throw Error("Content topic format is invalid");let tt=0;if(et.length==6){if(tt=parseInt(et[1]),isNaN(tt))throw new Error("Invalid generation field in content topic");if(tt>0)throw new Error("Generation greater than 0 is not supported")}const nt=et.splice(-4);if(nt[0].length==0)throw new Error("Application field cannot be empty");if(nt[1].length==0)throw new Error("Version field cannot be empty");if(nt[2].length==0)throw new Error("Topic name field cannot be empty");if(nt[3].length==0)throw new Error("Encoding field cannot be empty");return{generation:tt,application:nt[0],version:nt[1],topicName:nt[2],encoding:nt[3]}}function contentTopicToShardIndex(o,et=8){const{application:tt,version:nt}=ensureValidContentTopic(o),rt=sha256$2(concat$2([utf8ToBytes$1(tt),utf8ToBytes$1(nt)])),ot=new DataView(rt.buffer.slice(-8));return Number(ot.getBigUint64(0,!1)%BigInt(et))}function contentTopicToPubsubTopic(o,et=DEFAULT_CLUSTER_ID,tt=8){if(!o)throw Error("Content topic must be specified");const nt=contentTopicToShardIndex(o,tt);return`/waku/2/rs/${et}/${nt}`}function determinePubsubTopic(o,et){return typeof et=="string"?et:(et==null?void 0:et.shard)!==void 0?singleShardInfoToPubsubTopic(et):contentTopicToPubsubTopic(o,(et==null?void 0:et.clusterId)??DEFAULT_CLUSTER_ID)}const decodeRelayShard=o=>{if(o=new Uint8Array(o),o.length<3)throw new Error("Insufficient data");const et=new DataView(o.buffer),tt=et.getUint16(0),nt=[];if(o.length===130)for(let rt=0;rt<1024;rt++){const ot=Math.floor(rt/8)+2,it=7-rt%8;et.getUint8(ot)&1<=o.length)throw new Error("Unexpected end of data");nt.push(et.getUint16(it))}}return{clusterId:tt,shards:nt}},encodeRelayShard=o=>{const{clusterId:et,shards:tt}=o,nt=tt.length>=64?130:3+2*tt.length,rt=new ArrayBuffer(nt),ot=new DataView(rt);if(ot.setUint16(0,et),tt.length>=64)for(const it of tt){const st=Math.floor(it/8)+2,at=7-it%8;ot.setUint8(st,ot.getUint8(st)|1<tt.toString().includes("ws")||tt.toString().includes("wss"));if(!et)throw new Error("No ws multiaddr found in the given addresses");return et}var browser={exports:{}},ms$1,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms$1;hasRequiredMs=1;var o=1e3,et=o*60,tt=et*60,nt=tt*24,rt=nt*7,ot=nt*365.25;ms$1=function(lt,dt){dt=dt||{};var ht=typeof lt;if(ht==="string"&<.length>0)return it(lt);if(ht==="number"&&isFinite(lt))return dt.long?at(lt):st(lt);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(lt))};function it(lt){if(lt=String(lt),!(lt.length>100)){var dt=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(lt);if(dt){var ht=parseFloat(dt[1]),pt=(dt[2]||"ms").toLowerCase();switch(pt){case"years":case"year":case"yrs":case"yr":case"y":return ht*ot;case"weeks":case"week":case"w":return ht*rt;case"days":case"day":case"d":return ht*nt;case"hours":case"hour":case"hrs":case"hr":case"h":return ht*tt;case"minutes":case"minute":case"mins":case"min":case"m":return ht*et;case"seconds":case"second":case"secs":case"sec":case"s":return ht*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return ht;default:return}}}}function st(lt){var dt=Math.abs(lt);return dt>=nt?Math.round(lt/nt)+"d":dt>=tt?Math.round(lt/tt)+"h":dt>=et?Math.round(lt/et)+"m":dt>=o?Math.round(lt/o)+"s":lt+"ms"}function at(lt){var dt=Math.abs(lt);return dt>=nt?ct(lt,dt,nt,"day"):dt>=tt?ct(lt,dt,tt,"hour"):dt>=et?ct(lt,dt,et,"minute"):dt>=o?ct(lt,dt,o,"second"):lt+" ms"}function ct(lt,dt,ht,pt){var mt=dt>=ht*1.5;return Math.round(lt/ht)+" "+pt+(mt?"s":"")}return ms$1}function setup$1(o){tt.debug=tt,tt.default=tt,tt.coerce=at,tt.disable=ot,tt.enable=rt,tt.enabled=it,tt.humanize=requireMs(),tt.destroy=ct,Object.keys(o).forEach(lt=>{tt[lt]=o[lt]}),tt.names=[],tt.skips=[],tt.formatters={};function et(lt){let dt=0;for(let ht=0;ht{if(wt==="%%")return"%";bt++;const It=tt.formatters[kt];if(typeof It=="function"){const Rt=yt[bt];wt=It.call(gt,Rt),yt.splice(bt,1),bt--}return wt}),tt.formatArgs.call(gt,yt),(gt.log||tt.log).apply(gt,yt)}return ft.namespace=lt,ft.useColors=tt.useColors(),ft.color=tt.selectColor(lt),ft.extend=nt,ft.destroy=tt.destroy,Object.defineProperty(ft,"enabled",{enumerable:!0,configurable:!1,get:()=>ht!==null?ht:(pt!==tt.namespaces&&(pt=tt.namespaces,mt=tt.enabled(lt)),mt),set:yt=>{ht=yt}}),typeof tt.init=="function"&&tt.init(ft),ft}function nt(lt,dt){const ht=tt(this.namespace+(typeof dt>"u"?":":dt)+lt);return ht.log=this.log,ht}function rt(lt){tt.save(lt),tt.namespaces=lt,tt.names=[],tt.skips=[];let dt;const ht=(typeof lt=="string"?lt:"").split(/[\s,]+/),pt=ht.length;for(dt=0;dt"-"+dt)].join(",");return tt.enable(""),lt}function it(lt){if(lt[lt.length-1]==="*")return!0;let dt,ht;for(dt=0,ht=tt.skips.length;dt{let lt=!1;return()=>{lt||(lt=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),et.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function rt(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let lt;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(lt=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(lt[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function ot(lt){if(lt[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+lt[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;const dt="color: "+this.color;lt.splice(1,0,dt,"color: inherit");let ht=0,pt=0;lt[0].replace(/%[a-zA-Z%]/g,mt=>{mt!=="%%"&&(ht++,mt==="%c"&&(pt=ht))}),lt.splice(pt,0,dt)}et.log=console.debug||console.log||(()=>{});function it(lt){try{lt?et.storage.setItem("debug",lt):et.storage.removeItem("debug")}catch{}}function st(){let lt;try{lt=et.storage.getItem("debug")}catch{}return!lt&&typeof tt<"u"&&"env"in tt&&(lt=nt.DEBUG),lt}function at(){try{return localStorage}catch{}}o.exports=common$1(et);const{formatters:ct}=o.exports;ct.j=function(lt){try{return JSON.stringify(lt)}catch(dt){return"[UnexpectedJSONParseError]: "+dt.message}}})(browser,browser.exports);var browserExports=browser.exports;const debug=getDefaultExportFromCjs(browserExports),APP_NAME="waku";let Logger$1=class Zo{constructor(et){Ct(this,"_info");Ct(this,"_warn");Ct(this,"_error");this._info=debug(Zo.createDebugNamespace("info",et)),this._warn=debug(Zo.createDebugNamespace("warn",et)),this._error=debug(Zo.createDebugNamespace("error",et))}static createDebugNamespace(et,tt){return tt?`${APP_NAME}:${et}:${tt}`:`${APP_NAME}:${et}`}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(et,...tt){const nt=this[et];nt(...tt)}};const log$o=new Logger$1("message:version-0"),OneMillion=BigInt(1e6),Version=0;class DecodedMessage{constructor(et,tt){Ct(this,"pubsubTopic");Ct(this,"proto");this.pubsubTopic=et,this.proto=tt}get ephemeral(){return!!this.proto.ephemeral}get payload(){return this.proto.payload}get contentTopic(){return this.proto.contentTopic}get _rawTimestamp(){return this.proto.timestamp}get timestamp(){try{if(this.proto.timestamp){const et=this.proto.timestamp/OneMillion;return new Date(Number(et))}return}catch{return}}get meta(){return this.proto.meta}get version(){return this.proto.version??0}get rateLimitProof(){return this.proto.rateLimitProof}}let Encoder$1=class{constructor(et,tt=!1,nt,rt){Ct(this,"contentTopic");Ct(this,"ephemeral");Ct(this,"pubsubTopic");Ct(this,"metaSetter");if(this.contentTopic=et,this.ephemeral=tt,this.pubsubTopic=nt,this.metaSetter=rt,!et||et==="")throw new Error("Content topic must be specified")}async toWire(et){return WakuMessage$4.encode(await this.toProtoObj(et))}async toProtoObj(et){const tt=et.timestamp??new Date,nt={payload:et.payload,version:Version,contentTopic:this.contentTopic,timestamp:BigInt(tt.valueOf())*OneMillion,meta:void 0,rateLimitProof:et.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const rt=this.metaSetter(nt);return{...nt,meta:rt}}return nt}};function createEncoder({pubsubTopic:o,pubsubTopicShardInfo:et,contentTopic:tt,ephemeral:nt,metaSetter:rt}){return new Encoder$1(tt,nt,determinePubsubTopic(tt,o??et),rt)}let Decoder$1=class{constructor(et,tt){Ct(this,"pubsubTopic");Ct(this,"contentTopic");if(this.pubsubTopic=et,this.contentTopic=tt,!tt||tt==="")throw new Error("Content topic must be specified")}fromWireToProtoObj(et){const tt=WakuMessage$4.decode(et);return Promise.resolve({payload:tt.payload,contentTopic:tt.contentTopic,version:tt.version??void 0,timestamp:tt.timestamp??void 0,meta:tt.meta??void 0,rateLimitProof:tt.rateLimitProof??void 0,ephemeral:tt.ephemeral??!1})}async fromProtoObj(et,tt){return tt.version??Version!==0?(log$o.error("Failed to decode due to incorrect version, expected:",Version,", actual:",tt.version),Promise.resolve(void 0)):new DecodedMessage(et,tt)}};function createDecoder(o,et){return new Decoder$1(determinePubsubTopic(o,et),o)}function isAsyncIterable$8(o){return o[Symbol.asyncIterator]!=null}function all$2(o){if(isAsyncIterable$8(o))return(async()=>{const tt=[];for await(const nt of o)tt.push(nt);return tt})();const et=[];for(const tt of o)et.push(tt);return et}function asUint8Array(o){return o}function concat$1(o,et){et==null&&(et=o.reduce((rt,ot)=>rt+ot.length,0));const tt=allocUnsafe(et);let nt=0;for(const rt of o)tt.set(rt,nt),nt+=rt.length;return tt}function equals(o,et){if(o===et)return!0;if(o.byteLength!==et.byteLength)return!1;for(let tt=0;tt0&&this.appendAll(et)}*[(Ys=symbol$1,Symbol.iterator)](){yield*this.bufs}get byteLength(){return this.length}append(...et){this.appendAll(et)}appendAll(et){let tt=0;for(const nt of et)if(nt instanceof Uint8Array)tt+=nt.byteLength,this.bufs.push(nt);else if(isUint8ArrayList(nt))tt+=nt.byteLength,this.bufs.push(...nt.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}prepend(...et){this.prependAll(et)}prependAll(et){let tt=0;for(const nt of et.reverse())if(nt instanceof Uint8Array)tt+=nt.byteLength,this.bufs.unshift(nt);else if(isUint8ArrayList(nt))tt+=nt.byteLength,this.bufs.unshift(...nt.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}get(et){const tt=findBufAndOffset(this.bufs,et);return tt.buf[tt.index]}set(et,tt){const nt=findBufAndOffset(this.bufs,et);nt.buf[nt.index]=tt}write(et,tt=0){if(et instanceof Uint8Array)for(let nt=0;nt0;)if(et>=this.bufs[0].byteLength)et-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(et),this.length-=et;break}}}slice(et,tt){const{bufs:nt,length:rt}=this._subList(et,tt);return concat$1(nt,rt)}subarray(et,tt){const{bufs:nt,length:rt}=this._subList(et,tt);return nt.length===1?nt[0]:concat$1(nt,rt)}sublist(et,tt){const{bufs:nt,length:rt}=this._subList(et,tt),ot=new Uint8ArrayList;return ot.length=rt,ot.bufs=[...nt],ot}_subList(et,tt){if(et=et??0,tt=tt??this.length,et<0&&(et=this.length+et),tt<0&&(tt=this.length+tt),et<0||tt>this.length)throw new RangeError("index is out of bounds");if(et===tt)return{bufs:[],length:0};if(et===0&&tt===this.length)return{bufs:this.bufs,length:this.length};const nt=[];let rt=0;for(let ot=0;ot=at)continue;const ct=et>=st&&etst&&tt<=at;if(ct&<){if(et===st&&tt===at){nt.push(it);break}const dt=et-st;nt.push(it.subarray(dt,dt+(tt-et)));break}if(ct){if(et===0){nt.push(it);continue}nt.push(it.subarray(et-st));continue}if(lt){if(tt===at){nt.push(it);break}nt.push(it.subarray(0,tt-st));break}nt.push(it)}return{bufs:nt,length:tt-et}}indexOf(et,tt=0){if(!isUint8ArrayList(et)&&!(et instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const nt=et instanceof Uint8Array?et:et.subarray();if(tt=Number(tt??0),isNaN(tt)&&(tt=0),tt<0&&(tt=this.length+tt),tt<0&&(tt=0),et.length===0)return tt>this.length?this.length:tt;const rt=nt.byteLength;if(rt===0)throw new TypeError("search must be at least 1 byte long");const ot=256,it=new Int32Array(ot);for(let dt=0;dt=0;ht--){const pt=this.get(dt+ht);if(nt[ht]!==pt){lt=Math.max(1,ht-st[pt]);break}}if(lt===0)return dt}return-1}getInt8(et){const tt=this.subarray(et,et+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getInt8(0)}setInt8(et,tt){const nt=allocUnsafe(1);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setInt8(0,tt),this.write(nt,et)}getInt16(et,tt){const nt=this.subarray(et,et+2);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getInt16(0,tt)}setInt16(et,tt,nt){const rt=alloc$2(2);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setInt16(0,tt,nt),this.write(rt,et)}getInt32(et,tt){const nt=this.subarray(et,et+4);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getInt32(0,tt)}setInt32(et,tt,nt){const rt=alloc$2(4);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setInt32(0,tt,nt),this.write(rt,et)}getBigInt64(et,tt){const nt=this.subarray(et,et+8);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getBigInt64(0,tt)}setBigInt64(et,tt,nt){const rt=alloc$2(8);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setBigInt64(0,tt,nt),this.write(rt,et)}getUint8(et){const tt=this.subarray(et,et+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getUint8(0)}setUint8(et,tt){const nt=allocUnsafe(1);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setUint8(0,tt),this.write(nt,et)}getUint16(et,tt){const nt=this.subarray(et,et+2);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getUint16(0,tt)}setUint16(et,tt,nt){const rt=alloc$2(2);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setUint16(0,tt,nt),this.write(rt,et)}getUint32(et,tt){const nt=this.subarray(et,et+4);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getUint32(0,tt)}setUint32(et,tt,nt){const rt=alloc$2(4);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setUint32(0,tt,nt),this.write(rt,et)}getBigUint64(et,tt){const nt=this.subarray(et,et+8);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getBigUint64(0,tt)}setBigUint64(et,tt,nt){const rt=alloc$2(8);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setBigUint64(0,tt,nt),this.write(rt,et)}getFloat32(et,tt){const nt=this.subarray(et,et+4);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getFloat32(0,tt)}setFloat32(et,tt,nt){const rt=alloc$2(4);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setFloat32(0,tt,nt),this.write(rt,et)}getFloat64(et,tt){const nt=this.subarray(et,et+8);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getFloat64(0,tt)}setFloat64(et,tt,nt){const rt=alloc$2(8);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setFloat64(0,tt,nt),this.write(rt,et)}equals(et){if(et==null||!(et instanceof Uint8ArrayList)||et.bufs.length!==this.bufs.length)return!1;for(let tt=0;ttrt+ot.byteLength,0)),nt.length=tt,nt}}function isAsyncIterable$7(o){return o[Symbol.asyncIterator]!=null}const defaultEncoder=o=>{const et=encodingLength$3(o),tt=allocUnsafe(et);return encode$a(o,tt),defaultEncoder.bytes=et,tt};defaultEncoder.bytes=0;function encode$5(o,et){et=et??{};const tt=et.lengthEncoder??defaultEncoder;function*nt(rt){const ot=tt(rt.byteLength);ot instanceof Uint8Array?yield ot:yield*ot,rt instanceof Uint8Array?yield rt:yield*rt}return isAsyncIterable$7(o)?async function*(){for await(const rt of o)yield*nt(rt)}():function*(){for(const rt of o)yield*nt(rt)}()}encode$5.single=(o,et)=>{et=et??{};const tt=et.lengthEncoder??defaultEncoder;return new Uint8ArrayList(tt(o.byteLength),o)};let InvalidMessageLengthError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","InvalidMessageLengthError");Ct(this,"code","ERR_INVALID_MSG_LENGTH")}},InvalidDataLengthError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","InvalidDataLengthError");Ct(this,"code","ERR_MSG_DATA_TOO_LONG")}},InvalidDataLengthLengthError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","InvalidDataLengthLengthError");Ct(this,"code","ERR_MSG_LENGTH_TOO_LONG")}},UnexpectedEOFError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","UnexpectedEOFError");Ct(this,"code","ERR_UNEXPECTED_EOF")}};const MAX_LENGTH_LENGTH=8,MAX_DATA_LENGTH=1024*1024*4;var ReadMode;(function(o){o[o.LENGTH=0]="LENGTH",o[o.DATA=1]="DATA"})(ReadMode||(ReadMode={}));const defaultDecoder=o=>{const et=decode$b(o);return defaultDecoder.bytes=encodingLength$3(et),et};defaultDecoder.bytes=0;function decode$5(o,et){const tt=new Uint8ArrayList;let nt=ReadMode.LENGTH,rt=-1;const ot=(et==null?void 0:et.lengthDecoder)??defaultDecoder,it=(et==null?void 0:et.maxLengthLength)??MAX_LENGTH_LENGTH,st=(et==null?void 0:et.maxDataLength)??MAX_DATA_LENGTH;function*at(){for(;tt.byteLength>0;){if(nt===ReadMode.LENGTH)try{if(rt=ot(tt),rt<0)throw new InvalidMessageLengthError$1("Invalid message length");if(rt>st)throw new InvalidDataLengthError$1("Message length too long");const ct=ot.bytes;tt.consume(ct),(et==null?void 0:et.onLength)!=null&&et.onLength(rt),nt=ReadMode.DATA}catch(ct){if(ct instanceof RangeError){if(tt.byteLength>it)throw new InvalidDataLengthLengthError$1("Message length length too long");break}throw ct}if(nt===ReadMode.DATA){if(tt.byteLength0)throw new UnexpectedEOFError$1("Unexpected end of input")}():function*(){for(const ct of o)tt.append(ct),yield*at();if(tt.byteLength>0)throw new UnexpectedEOFError$1("Unexpected end of input")}()}decode$5.fromReader=(o,et)=>{let tt=1;const nt=async function*(){for(;;)try{const{done:ot,value:it}=await o.next(tt);if(ot===!0)return;it!=null&&(yield it)}catch(ot){if(ot.code==="ERR_UNDER_READ")return{done:!0,value:null};throw ot}finally{tt=1}}();return decode$5(nt,{...et??{},onLength:ot=>{tt=ot}})};function pDefer(){const o={};return o.promise=new Promise((et,tt)=>{o.resolve=et,o.reject=tt}),o}class FixedFIFO{constructor(et){Ct(this,"buffer");Ct(this,"mask");Ct(this,"top");Ct(this,"btm");Ct(this,"next");if(!(et>0)||et-1&et)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(et),this.mask=et-1,this.top=0,this.btm=0,this.next=null}push(et){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=et,this.top=this.top+1&this.mask,!0)}shift(){const et=this.buffer[this.btm];if(et!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,et}isEmpty(){return this.buffer[this.btm]===void 0}}class FIFO{constructor(et={}){Ct(this,"size");Ct(this,"hwm");Ct(this,"head");Ct(this,"tail");this.hwm=et.splitLimit??16,this.head=new FixedFIFO(this.hwm),this.tail=this.head,this.size=0}calculateSize(et){return(et==null?void 0:et.byteLength)!=null?et.byteLength:1}push(et){if((et==null?void 0:et.value)!=null&&(this.size+=this.calculateSize(et.value)),!this.head.push(et)){const tt=this.head;this.head=tt.next=new FixedFIFO(2*this.head.buffer.length),this.head.push(et)}}shift(){let et=this.tail.shift();if(et===void 0&&this.tail.next!=null){const tt=this.tail.next;this.tail.next=null,this.tail=tt,et=this.tail.shift()}return(et==null?void 0:et.value)!=null&&(this.size-=this.calculateSize(et.value)),et}isEmpty(){return this.head.isEmpty()}}let AbortError$a=class extends Error{constructor(tt,nt){super(tt??"The operation was aborted");Ct(this,"type");Ct(this,"code");this.type="aborted",this.code=nt??"ABORT_ERR"}};function pushable(o={}){return _pushable(tt=>{const nt=tt.shift();if(nt==null)return{done:!0};if(nt.error!=null)throw nt.error;return{done:nt.done===!0,value:nt.value}},o)}function _pushable(o,et){et=et??{};let tt=et.onEnd,nt=new FIFO,rt,ot,it,st=pDefer();const at=async()=>{try{return nt.isEmpty()?it?{done:!0}:await new Promise((yt,gt)=>{ot=xt=>{ot=null,nt.push(xt);try{yt(o(nt))}catch(vt){gt(vt)}return rt}}):o(nt)}finally{nt.isEmpty()&&queueMicrotask(()=>{st.resolve(),st=pDefer()})}},ct=yt=>ot!=null?ot(yt):(nt.push(yt),rt),lt=yt=>(nt=new FIFO,ot!=null?ot({error:yt}):(nt.push({error:yt}),rt)),dt=yt=>{if(it)return rt;if((et==null?void 0:et.objectMode)!==!0&&(yt==null?void 0:yt.byteLength)==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return ct({done:!1,value:yt})},ht=yt=>it?rt:(it=!0,yt!=null?lt(yt):ct({done:!0})),pt=()=>(nt=new FIFO,ht(),{done:!0}),mt=yt=>(ht(yt),{done:!0});if(rt={[Symbol.asyncIterator](){return this},next:at,return:pt,throw:mt,push:dt,end:ht,get readableLength(){return nt.size},onEmpty:async yt=>{const gt=yt==null?void 0:yt.signal;if(gt==null||gt.throwIfAborted(),nt.isEmpty())return;let xt,vt;gt!=null&&(xt=new Promise((bt,Et)=>{vt=()=>{Et(new AbortError$a)},gt.addEventListener("abort",vt)}));try{await Promise.race([st.promise,xt])}finally{vt!=null&>!=null&&(gt==null||gt.removeEventListener("abort",vt))}}},tt==null)return rt;const ft=rt;return rt={[Symbol.asyncIterator](){return this},next(){return ft.next()},throw(yt){return ft.throw(yt),tt!=null&&(tt(yt),tt=void 0),{done:!0}},return(){return ft.return(),tt!=null&&(tt(),tt=void 0),{done:!0}},push:dt,end(yt){return ft.end(yt),tt!=null&&(tt(yt),tt=void 0),rt},get readableLength(){return ft.readableLength},onEmpty:yt=>ft.onEmpty(yt)},rt}function isAsyncIterable$6(o){return o[Symbol.asyncIterator]!=null}function merge$2(...o){const et=[];for(const tt of o)isAsyncIterable$6(tt)||et.push(tt);return et.length===o.length?function*(){for(const tt of et)yield*tt}():async function*(){const tt=pushable({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(o.map(async nt=>{for await(const rt of nt)tt.push(rt)})),tt.end()}catch(nt){tt.end(nt)}}),yield*tt}()}function pipe(o,...et){if(o==null)throw new Error("Empty pipeline");if(isDuplex(o)){const nt=o;o=()=>nt.source}else if(isIterable(o)||isAsyncIterable$5(o)){const nt=o;o=()=>nt}const tt=[o,...et];if(tt.length>1&&isDuplex(tt[tt.length-1])&&(tt[tt.length-1]=tt[tt.length-1].sink),tt.length>2)for(let nt=1;nt{let et;for(;o.length>0;)et=o.shift()(et);return et},isAsyncIterable$5=o=>(o==null?void 0:o[Symbol.asyncIterator])!=null,isIterable=o=>(o==null?void 0:o[Symbol.iterator])!=null,isDuplex=o=>o==null?!1:o.sink!=null&&o.source!=null,duplexPipelineFn=o=>et=>{const tt=o.sink(et);if((tt==null?void 0:tt.then)!=null){const nt=pushable({objectMode:!0});tt.then(()=>{nt.end()},it=>{nt.end(it)});let rt;const ot=o.source;if(isAsyncIterable$5(ot))rt=async function*(){yield*ot,nt.end()};else if(isIterable(ot))rt=function*(){yield*ot,nt.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return merge$2(nt,rt())}return o.source};async function sortPeersByLatency(o,et){return et.length===0?[]:(await Promise.all(et.map(async rt=>{try{const ot=(await o.get(rt.id)).metadata.get("ping");if(!ot)return{peer:rt,ping:1/0};const it=Number(bytesToUtf8(ot));return{peer:rt,ping:it}}catch{return{peer:rt,ping:1/0}}}))).filter(rt=>rt!==null).sort((rt,ot)=>rt.ping-ot.ping).map(rt=>rt.peer)}async function getPeersForProtocol(o,et){const tt=[];return await o.forEach(nt=>{for(let rt=0;rtit.tags.has(Tags.BOOTSTRAP)).slice(0,tt);et>0&&et!it.tags.has(Tags.BOOTSTRAP));if(et===0)return[...nt,...rt];const ot=[...nt];for(;ot.length0;){const it=Math.floor(Math.random()*rt.length),st=rt.splice(it,1)[0];ot.push(st)}return ot}function selectOpenConnection(o){return o.filter(et=>et.status==="open").sort((et,tt)=>tt.timeline.open-et.timeline.open).at(0)}const STREAM_LOCK_KEY="consumed";class StreamManager{constructor(et,tt,nt){Ct(this,"multicodec");Ct(this,"getConnections");Ct(this,"addEventListener");Ct(this,"log");Ct(this,"ongoingCreation",new Set);Ct(this,"streamPool",new Map);Ct(this,"handlePeerUpdateStreamPool",et=>{const{peer:tt}=et.detail;!tt.protocols.includes(this.multicodec)||this.getOpenStreamForCodec(tt.id)||this.scheduleNewStream(tt)});this.multicodec=et,this.getConnections=tt,this.addEventListener=nt,this.log=new Logger$1(`stream-manager:${et}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool)}async getStream(et){const tt=et.id.toString(),nt=this.streamPool.get(tt);nt&&(this.streamPool.delete(tt),await nt);let rt=this.getOpenStreamForCodec(et.id);return rt?(this.log.info(`Found existing stream peerId=${et.id.toString()} multicodec=${this.multicodec}`),this.lockStream(et.id.toString(),rt),rt):(rt=await this.createStream(et),this.lockStream(et.id.toString(),rt),rt)}async createStream(et,tt=0){const nt=this.getConnections(et.id),rt=selectOpenConnection(nt);if(!rt)throw new Error(`Failed to get a connection to the peer peerId=${et.id.toString()} multicodec=${this.multicodec}`);let ot,it;for(let st=0;stit.protocol===this.multicodec);if(!(!rt||["done","closed","closing"].includes(rt.writeStatus||"")||this.isStreamLocked(rt)))return rt}lockStream(et,tt){this.log.info(`Locking stream for peerId:${et} streamId:${tt.id}`),tt.metadata[STREAM_LOCK_KEY]=!0}isStreamLocked(et){return!!et.metadata[STREAM_LOCK_KEY]}}class BaseProtocol{constructor(et,tt,nt,rt){Ct(this,"multicodec");Ct(this,"components");Ct(this,"log");Ct(this,"pubsubTopics");Ct(this,"addLibp2pEventListener");Ct(this,"removeLibp2pEventListener");Ct(this,"streamManager");this.multicodec=et,this.components=tt,this.log=nt,this.pubsubTopics=rt,this.addLibp2pEventListener=tt.events.addEventListener.bind(tt.events),this.removeLibp2pEventListener=tt.events.removeEventListener.bind(tt.events),this.streamManager=new StreamManager(et,tt.connectionManager.getConnections.bind(tt.connectionManager),this.addLibp2pEventListener)}async getStream(et){return this.streamManager.getStream(et)}async allPeers(){return getPeersForProtocol(this.components.peerStore,[this.multicodec])}async connectedPeers(){return(await this.allPeers()).filter(tt=>this.components.connectionManager.getConnections(tt.id).length>0)}async getPeers({numPeers:et,maxBootstrapPeers:tt}={maxBootstrapPeers:0,numPeers:0}){const nt=await this.connectedPeers(),rt=filterPeersByDiscovery(nt,et,tt),ot=await sortPeersByLatency(this.components.peerStore,rt);return ot.length===0&&this.log.warn("No peers found. Ensure you have a connection to the network."),ot.length{log$n.error("Failed to register ",FilterCodecs.PUSH,ot)})}async subscribe(tt,nt,rt){const ot=await this.getStream(nt),it=FilterSubscribeRpc.createSubscribeRequest(tt,rt);let st;try{st=await pipe([it.encode()],encode$5,ot,decode$5,async dt=>await all$2(dt))}catch(dt){return log$n.error("Failed to send subscribe request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:nt.id}}}const{statusCode:at,requestId:ct,statusDesc:lt}=FilterSubscribeResponse.decode(st[0].slice());return at<200||at>=300?(log$n.error(`Filter subscribe request ${ct} failed with status code ${at}: ${lt}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:nt.id},success:null}):{failure:null,success:nt.id}}async unsubscribe(tt,nt,rt){let ot;try{ot=await this.getStream(nt)}catch(st){return log$n.error(`Failed to get a stream for remote peer${nt.id.toString()}`,st),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:nt.id}}}const it=FilterSubscribeRpc.createUnsubscribeRequest(tt,rt);try{await pipe([it.encode()],encode$5,ot.sink)}catch(st){return log$n.error("Failed to send unsubscribe request",st),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:nt.id}}}return{success:nt.id,failure:null}}async unsubscribeAll(tt,nt){const rt=await this.getStream(nt),ot=FilterSubscribeRpc.createUnsubscribeAllRequest(tt),it=await pipe([ot.encode()],encode$5,rt,decode$5,async lt=>await all$2(lt));if(!it||!it.length)return{failure:{error:ProtocolError$1.NO_RESPONSE,peerId:nt.id},success:null};const{statusCode:st,requestId:at,statusDesc:ct}=FilterSubscribeResponse.decode(it[0].slice());return st<200||st>=300?(log$n.error(`Filter unsubscribe all request ${at} failed with status code ${st}: ${ct}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:nt.id},success:null}):{failure:null,success:nt.id}}async ping(tt){let nt;try{nt=await this.getStream(tt)}catch(ct){return log$n.error(`Failed to get a stream for remote peer${tt.id.toString()}`,ct),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:tt.id}}}const rt=FilterSubscribeRpc.createSubscriberPingRequest();let ot;try{ot=await pipe([rt.encode()],encode$5,nt,decode$5,async ct=>await all$2(ct))}catch(ct){return log$n.error("Failed to send ping request",ct),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:tt.id}}}if(!ot||!ot.length)return{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:tt.id}};const{statusCode:it,requestId:st,statusDesc:at}=FilterSubscribeResponse.decode(ot[0].slice());return it<200||it>=300?(log$n.error(`Filter ping request ${st} failed with status code ${it}: ${at}`),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:tt.id}}):{success:tt.id,failure:null}}onRequest(tt){const{connection:nt,stream:rt}=tt,{remotePeer:ot}=nt;log$n.info(`Received message from ${ot.toString()}`);try{pipe(rt,decode$5,async it=>{for await(const st of it){const at=FilterPushRpc.decode(st.slice()),{pubsubTopic:ct,wakuMessage:lt}=at;if(!lt){log$n.error("Received empty message");return}if(!ct){log$n.error("Pubsub topic missing from push message");return}await this.handleIncomingMessage(ct,lt,nt.remotePeer.toString())}}).then(()=>{log$n.info("Receiving pipe closed.")},async it=>{log$n.error(`Error with receiving pipe on peer:${nt.remotePeer.toString()} -- stream:${rt.id} -- protocol:${rt.protocol}: `,it)})}catch(it){log$n.error("Error decoding message",it)}}}class PushRpc{constructor(et){Ct(this,"proto");this.proto=et}static createRequest(et,tt){return new PushRpc({requestId:v4$2(),request:{message:et,pubsubTopic:tt},response:void 0})}static decode(et){const tt=PushRpc$1.decode(et);return new PushRpc(tt)}encode(){return PushRpc$1.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const RLN_GENERATION_PREFIX_ERROR="could not generate rln-v2 proof",isRLNResponseError=o=>o?o.includes(RLN_GENERATION_PREFIX_ERROR):!1,matchRLNErrorMessage=o=>{const et={[ProtocolError$1.RLN_IDENTITY_MISSING]:ProtocolError$1.RLN_IDENTITY_MISSING,[ProtocolError$1.RLN_MEMBERSHIP_INDEX]:ProtocolError$1.RLN_MEMBERSHIP_INDEX,[ProtocolError$1.RLN_LIMIT_MISSING]:ProtocolError$1.RLN_LIMIT_MISSING},tt=o.toLowerCase();for(const nt in et)if(tt.includes(nt.toLowerCase()))return et[nt];return ProtocolError$1.RLN_PROOF_GENERATION},log$m=new Logger$1("light-push"),LightPushCodec="/vac/waku/lightpush/2.0.0-beta1";class LightPushCore extends BaseProtocol{constructor(tt,nt){super(LightPushCodec,nt.components,log$m,tt);Ct(this,"pubsubTopics");this.pubsubTopics=tt}async preparePushMessage(tt,nt){try{if(!nt.payload||nt.payload.length===0)return log$m.error("Failed to send waku light push: payload is empty"),{query:null,error:ProtocolError$1.EMPTY_PAYLOAD};if(!await isMessageSizeUnderCap(tt,nt))return log$m.error("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:ProtocolError$1.SIZE_TOO_BIG};const rt=await tt.toProtoObj(nt);return rt?{query:PushRpc.createRequest(rt,tt.pubsubTopic),error:null}:(log$m.error("Failed to encode to protoMessage, aborting push"),{query:null,error:ProtocolError$1.ENCODE_FAILED})}catch(rt){return log$m.error("Failed to prepare push message",rt),{query:null,error:ProtocolError$1.GENERIC_FAIL}}}async send(tt,nt,rt){const{query:ot,error:it}=await this.preparePushMessage(tt,nt);if(it||!ot)return{success:null,failure:{error:it,peerId:rt.id}};let st;try{st=await this.getStream(rt)}catch(dt){return log$m.error("Failed to get stream",dt),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:rt.id}}}let at;try{at=await pipe([ot.encode()],encode$5,st,decode$5,async dt=>await all$2(dt))}catch(dt){return log$m.error("Failed to send waku light push request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:rt.id}}}const ct=new Uint8ArrayList;at.forEach(dt=>{ct.append(dt)});let lt;try{lt=PushRpc.decode(ct).response}catch(dt){return log$m.error("Failed to decode push reply",dt),{success:null,failure:{error:ProtocolError$1.DECODE_FAILED,peerId:rt.id}}}if(!lt)return log$m.error("Remote peer fault: No response in PushRPC"),{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:rt.id}};if(isRLNResponseError(lt.info)){const dt=matchRLNErrorMessage(lt.info);return log$m.error("Remote peer rejected the message: ",dt),{success:null,failure:{error:dt,peerId:rt.id}}}return lt.isSuccess?{success:rt.id,failure:null}:(log$m.error("Remote peer rejected the message: ",lt.info),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:rt.id}})}}const EmptyMessage={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};function toProtoMessage(o){return{...EmptyMessage,...o}}const DEFAULT_PAGE_SIZE=20,MAX_PAGE_SIZE=100,ONE_MILLION=1e6;class StoreQueryRequest{constructor(et){Ct(this,"proto");this.proto=et}static create(et){const tt=new StoreQueryRequest({...et,requestId:v4$2(),timeStart:et.timeStart?BigInt(et.timeStart.getTime()*ONE_MILLION):void 0,timeEnd:et.timeEnd?BigInt(et.timeEnd.getTime()*ONE_MILLION):void 0,messageHashes:et.messageHashes||[],paginationLimit:et.paginationLimit?BigInt(et.paginationLimit):void 0});if(et.pubsubTopic&&!et.contentTopics||!et.pubsubTopic&&et.contentTopics)throw new Error("Both pubsubTopic and contentTopics must be set or unset");if(et.messageHashes&&(et.pubsubTopic||et.contentTopics||et.timeStart||et.timeEnd))throw new Error("Message hash lookup queries cannot include content filter criteria");return tt}static decode(et){const tt=StoreQueryRequest$1.decode(et);return new StoreQueryRequest(tt)}encode(){return StoreQueryRequest$1.encode(this.proto)}}class StoreQueryResponse{constructor(et){Ct(this,"proto");this.proto=et}static decode(et){const tt=StoreQueryResponse$1.decode(et);return new StoreQueryResponse(tt)}encode(){return StoreQueryResponse$1.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get messages(){return this.proto.messages}get paginationCursor(){return this.proto.paginationCursor}}const log$l=new Logger$1("store"),StoreCodec="/vac/waku/store-query/3.0.0";class StoreCore extends BaseProtocol{constructor(tt,nt){super(StoreCodec,nt.components,log$l,tt);Ct(this,"pubsubTopics");this.pubsubTopics=tt}async*queryPerPage(tt,nt,rt){if(tt.contentTopics.toString()!==Array.from(nt.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let ot=tt.paginationCursor;for(;;){const it=StoreQueryRequest.create({...tt,paginationCursor:ot});let st;try{st=await this.getStream(rt)}catch(ht){log$l.error("Failed to get stream",ht);break}const at=await pipe([it.encode()],encode$5,st,decode$5,async ht=>await all$2(ht)),ct=new Uint8ArrayList;at.forEach(ht=>{ct.append(ht)});const lt=StoreQueryResponse.decode(ct);if(!lt.statusCode||lt.statusCode>=300){const ht=`Store query failed with status code: ${lt.statusCode}, description: ${lt.statusDesc}`;throw log$l.error(ht),new Error(ht)}if(!lt.messages||!lt.messages.length){log$l.warn("Stopping pagination due to empty messages in response");break}if(log$l.info(`${lt.messages.length} messages retrieved from store`),yield lt.messages.map(ht=>{if(!ht.message)return Promise.resolve(void 0);const pt=ht.message.contentTopic;if(pt){const mt=nt.get(pt);if(mt)return mt.fromProtoObj(ht.pubsubTopic||"",toProtoMessage(ht.message))}return Promise.resolve(void 0)}),tt.paginationForward?ot=lt.messages[lt.messages.length-1].messageHash:ot=lt.messages[0].messageHash,lt.messages.length>MAX_PAGE_SIZE&<.messages.length<(tt.paginationLimit||DEFAULT_PAGE_SIZE))break}}}const peerDiscoverySymbol$2=Symbol.for("@libp2p/peer-discovery"),peerIdSymbol$3=Symbol.for("@libp2p/peer-id");function isPeerId$2(o){return!!(o!=null&&o[peerIdSymbol$3])}var ss;let AbortError$9=(ss=class extends Error{constructor(et="The operation was aborted"){super(et),this.name="AbortError"}},Ct(ss,"name","AbortError"),ss);class UnexpectedPeerError extends Error{constructor(et="Unexpected Peer"){super(et),this.name="UnexpectedPeerError"}}Ct(UnexpectedPeerError,"name","UnexpectedPeerError");var as;let InvalidMessageError$3=(as=class extends Error{constructor(et="Invalid message"){super(et),this.name="InvalidMessageError"}},Ct(as,"name","InvalidMessageError"),as);class ProtocolError extends Error{constructor(et="Protocol error"){super(et),this.name="ProtocolError"}}Ct(ProtocolError,"name","ProtocolError");var cs;let TimeoutError$3=(cs=class extends Error{constructor(et="Timed out"){super(et),this.name="TimeoutError"}},Ct(cs,"name","TimeoutError"),cs);function setMaxListeners$9(){}const setMaxListeners$8=(o,...et)=>{try{[...et]}catch{}};var Qn,Zs;let TypedEventEmitter$3=(Zs=class extends EventTarget{constructor(){super();fn(this,Qn,new Map);setMaxListeners$8(1/0,this)}listenerCount(tt){const nt=Mt(this,Qn).get(tt);return nt==null?0:nt.length}addEventListener(tt,nt,rt){super.addEventListener(tt,nt,rt);let ot=Mt(this,Qn).get(tt);ot==null&&(ot=[],Mt(this,Qn).set(tt,ot)),ot.push({callback:nt,once:(rt!==!0&&rt!==!1&&(rt==null?void 0:rt.once))??!1})}removeEventListener(tt,nt,rt){super.removeEventListener(tt.toString(),nt??null,rt);let ot=Mt(this,Qn).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==nt),Mt(this,Qn).set(tt,ot))}dispatchEvent(tt){const nt=super.dispatchEvent(tt);let rt=Mt(this,Qn).get(tt.type);return rt==null||(rt=rt.filter(({once:ot})=>!ot),Mt(this,Qn).set(tt.type,rt)),nt}safeDispatchEvent(tt,nt={}){return this.dispatchEvent(new CustomEvent(tt,nt))}},Qn=new WeakMap,Zs);const serviceCapabilities$5=Symbol.for("@libp2p/service-capabilities"),RelayPingContentTopic="/relay-ping/1/ping/null",log$k=new Logger$1("keep-alive");class KeepAliveManager{constructor({options:et,relay:tt,libp2p:nt}){Ct(this,"relay");Ct(this,"libp2p");Ct(this,"options");Ct(this,"pingKeepAliveTimers",new Map);Ct(this,"relayKeepAliveTimers",new Map);this.options=et,this.relay=tt,this.libp2p=nt}start(et){this.stop(et);const{pingKeepAlive:tt,relayKeepAlive:nt}=this.options,rt=et.toString();if(tt!==0){const it=setInterval(()=>{(async()=>{let st;try{try{st=await this.libp2p.services.ping.ping(et),log$k.info(`Ping succeeded (${rt})`,st)}catch{log$k.error(`Ping failed for peer (${rt}). + */function _extends(){return _extends=Object.assign?Object.assign.bind():function(o){for(var et=1;et=0)&&(tt[rt]=o[rt]);return tt}function isModifiedEvent(o){return!!(o.metaKey||o.altKey||o.ctrlKey||o.shiftKey)}function shouldProcessLinkClick(o,et){return o.button===0&&(!et||et==="_self")&&!isModifiedEvent(o)}const _excluded=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],REACT_ROUTER_VERSION="6";try{window.__reactRouterVersion=REACT_ROUTER_VERSION}catch{}const START_TRANSITION="startTransition",startTransitionImpl=React$1[START_TRANSITION];function BrowserRouter(o){let{basename:et,children:tt,future:nt,window:rt}=o,ot=reactExports.useRef();ot.current==null&&(ot.current=createBrowserHistory({window:rt,v5Compat:!0}));let it=ot.current,[st,at]=reactExports.useState({action:it.action,location:it.location}),{v7_startTransition:ct}=nt||{},lt=reactExports.useCallback(dt=>{ct&&startTransitionImpl?startTransitionImpl(()=>at(dt)):at(dt)},[at,ct]);return reactExports.useLayoutEffect(()=>it.listen(lt),[it,lt]),reactExports.useEffect(()=>logV6DeprecationWarnings(nt),[nt]),reactExports.createElement(Router,{basename:et,children:tt,location:st.location,navigationType:st.action,navigator:it,future:nt})}const isBrowser$1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ABSOLUTE_URL_REGEX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Link=reactExports.forwardRef(function(et,tt){let{onClick:nt,relative:rt,reloadDocument:ot,replace:it,state:st,target:at,to:ct,preventScrollReset:lt,viewTransition:dt}=et,ht=_objectWithoutPropertiesLoose(et,_excluded),{basename:pt}=reactExports.useContext(NavigationContext),mt,ft=!1;if(typeof ct=="string"&&ABSOLUTE_URL_REGEX.test(ct)&&(mt=ct,isBrowser$1))try{let vt=new URL(window.location.href),bt=ct.startsWith("//")?new URL(vt.protocol+ct):new URL(ct),Et=stripBasename(bt.pathname,pt);bt.origin===vt.origin&&Et!=null?ct=Et+bt.search+bt.hash:ft=!0}catch{}let yt=useHref(ct,{relative:rt}),gt=useLinkClickHandler(ct,{replace:it,state:st,target:at,preventScrollReset:lt,relative:rt,viewTransition:dt});function xt(vt){nt&&nt(vt),vt.defaultPrevented||gt(vt)}return reactExports.createElement("a",_extends({},ht,{href:mt||yt,onClick:ft||ot?nt:xt,ref:tt,target:at}))});var DataRouterHook;(function(o){o.UseScrollRestoration="useScrollRestoration",o.UseSubmit="useSubmit",o.UseSubmitFetcher="useSubmitFetcher",o.UseFetcher="useFetcher",o.useViewTransitionState="useViewTransitionState"})(DataRouterHook||(DataRouterHook={}));var DataRouterStateHook;(function(o){o.UseFetcher="useFetcher",o.UseFetchers="useFetchers",o.UseScrollRestoration="useScrollRestoration"})(DataRouterStateHook||(DataRouterStateHook={}));function useLinkClickHandler(o,et){let{target:tt,replace:nt,state:rt,preventScrollReset:ot,relative:it,viewTransition:st}=et===void 0?{}:et,at=useNavigate(),ct=useLocation(),lt=useResolvedPath(o,{relative:it});return reactExports.useCallback(dt=>{if(shouldProcessLinkClick(dt,tt)){dt.preventDefault();let ht=nt!==void 0?nt:createPath(ct)===createPath(lt);at(o,{replace:ht,state:rt,preventScrollReset:ot,relative:it,viewTransition:st})}},[ct,at,lt,nt,rt,tt,o,ot,it,st])}function setRef(o,et){typeof o=="function"?o(et):o!=null&&(o.current=et)}function composeRefs(...o){return et=>o.forEach(tt=>setRef(tt,et))}function useComposedRefs(...o){return reactExports.useCallback(composeRefs(...o),o)}var Slot=reactExports.forwardRef((o,et)=>{const{children:tt,...nt}=o,rt=reactExports.Children.toArray(tt),ot=rt.find(isSlottable);if(ot){const it=ot.props.children,st=rt.map(at=>at===ot?reactExports.Children.count(it)>1?reactExports.Children.only(null):reactExports.isValidElement(it)?it.props.children:null:at);return jsxRuntimeExports.jsx(SlotClone,{...nt,ref:et,children:reactExports.isValidElement(it)?reactExports.cloneElement(it,void 0,st):null})}return jsxRuntimeExports.jsx(SlotClone,{...nt,ref:et,children:tt})});Slot.displayName="Slot";var SlotClone=reactExports.forwardRef((o,et)=>{const{children:tt,...nt}=o;if(reactExports.isValidElement(tt)){const rt=getElementRef$1(tt);return reactExports.cloneElement(tt,{...mergeProps(nt,tt.props),ref:et?composeRefs(et,rt):rt})}return reactExports.Children.count(tt)>1?reactExports.Children.only(null):null});SlotClone.displayName="SlotClone";var Slottable=({children:o})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:o});function isSlottable(o){return reactExports.isValidElement(o)&&o.type===Slottable}function mergeProps(o,et){const tt={...et};for(const nt in et){const rt=o[nt],ot=et[nt];/^on[A-Z]/.test(nt)?rt&&ot?tt[nt]=(...st)=>{ot(...st),rt(...st)}:rt&&(tt[nt]=rt):nt==="style"?tt[nt]={...rt,...ot}:nt==="className"&&(tt[nt]=[rt,ot].filter(Boolean).join(" "))}return{...o,...tt}}function getElementRef$1(o){var nt,rt;let et=(nt=Object.getOwnPropertyDescriptor(o.props,"ref"))==null?void 0:nt.get,tt=et&&"isReactWarning"in et&&et.isReactWarning;return tt?o.ref:(et=(rt=Object.getOwnPropertyDescriptor(o,"ref"))==null?void 0:rt.get,tt=et&&"isReactWarning"in et&&et.isReactWarning,tt?o.props.ref:o.props.ref||o.ref)}function r$1(o){var et,tt,nt="";if(typeof o=="string"||typeof o=="number")nt+=o;else if(typeof o=="object")if(Array.isArray(o))for(et=0;ettypeof o=="boolean"?"".concat(o):o===0?"0":o,cx=clsx$1,cva=(o,et)=>tt=>{var nt;if((et==null?void 0:et.variants)==null)return cx(o,tt==null?void 0:tt.class,tt==null?void 0:tt.className);const{variants:rt,defaultVariants:ot}=et,it=Object.keys(rt).map(ct=>{const lt=tt==null?void 0:tt[ct],dt=ot==null?void 0:ot[ct];if(lt===null)return null;const ht=falsyToString(lt)||falsyToString(dt);return rt[ct][ht]}),st=tt&&Object.entries(tt).reduce((ct,lt)=>{let[dt,ht]=lt;return ht===void 0||(ct[dt]=ht),ct},{}),at=et==null||(nt=et.compoundVariants)===null||nt===void 0?void 0:nt.reduce((ct,lt)=>{let{class:dt,className:ht,...pt}=lt;return Object.entries(pt).every(mt=>{let[ft,yt]=mt;return Array.isArray(yt)?yt.includes({...ot,...st}[ft]):{...ot,...st}[ft]===yt})?[...ct,dt,ht]:ct},[]);return cx(o,it,at,tt==null?void 0:tt.class,tt==null?void 0:tt.className)};function r(o){var et,tt,nt="";if(typeof o=="string"||typeof o=="number")nt+=o;else if(typeof o=="object")if(Array.isArray(o)){var rt=o.length;for(et=0;et{const et=createClassMap(o),{conflictingClassGroups:tt,conflictingClassGroupModifiers:nt}=o;return{getClassGroupId:it=>{const st=it.split(CLASS_PART_SEPARATOR);return st[0]===""&&st.length!==1&&st.shift(),getGroupRecursive(st,et)||getGroupIdForArbitraryProperty(it)},getConflictingClassGroupIds:(it,st)=>{const at=tt[it]||[];return st&&nt[it]?[...at,...nt[it]]:at}}},getGroupRecursive=(o,et)=>{var it;if(o.length===0)return et.classGroupId;const tt=o[0],nt=et.nextPart.get(tt),rt=nt?getGroupRecursive(o.slice(1),nt):void 0;if(rt)return rt;if(et.validators.length===0)return;const ot=o.join(CLASS_PART_SEPARATOR);return(it=et.validators.find(({validator:st})=>st(ot)))==null?void 0:it.classGroupId},arbitraryPropertyRegex=/^\[(.+)\]$/,getGroupIdForArbitraryProperty=o=>{if(arbitraryPropertyRegex.test(o)){const et=arbitraryPropertyRegex.exec(o)[1],tt=et==null?void 0:et.substring(0,et.indexOf(":"));if(tt)return"arbitrary.."+tt}},createClassMap=o=>{const{theme:et,prefix:tt}=o,nt={nextPart:new Map,validators:[]};return getPrefixedClassGroupEntries(Object.entries(o.classGroups),tt).forEach(([ot,it])=>{processClassesRecursively(it,nt,ot,et)}),nt},processClassesRecursively=(o,et,tt,nt)=>{o.forEach(rt=>{if(typeof rt=="string"){const ot=rt===""?et:getPart(et,rt);ot.classGroupId=tt;return}if(typeof rt=="function"){if(isThemeGetter(rt)){processClassesRecursively(rt(nt),et,tt,nt);return}et.validators.push({validator:rt,classGroupId:tt});return}Object.entries(rt).forEach(([ot,it])=>{processClassesRecursively(it,getPart(et,ot),tt,nt)})})},getPart=(o,et)=>{let tt=o;return et.split(CLASS_PART_SEPARATOR).forEach(nt=>{tt.nextPart.has(nt)||tt.nextPart.set(nt,{nextPart:new Map,validators:[]}),tt=tt.nextPart.get(nt)}),tt},isThemeGetter=o=>o.isThemeGetter,getPrefixedClassGroupEntries=(o,et)=>et?o.map(([tt,nt])=>{const rt=nt.map(ot=>typeof ot=="string"?et+ot:typeof ot=="object"?Object.fromEntries(Object.entries(ot).map(([it,st])=>[et+it,st])):ot);return[tt,rt]}):o,createLruCache=o=>{if(o<1)return{get:()=>{},set:()=>{}};let et=0,tt=new Map,nt=new Map;const rt=(ot,it)=>{tt.set(ot,it),et++,et>o&&(et=0,nt=tt,tt=new Map)};return{get(ot){let it=tt.get(ot);if(it!==void 0)return it;if((it=nt.get(ot))!==void 0)return rt(ot,it),it},set(ot,it){tt.has(ot)?tt.set(ot,it):rt(ot,it)}}},IMPORTANT_MODIFIER="!",createParseClassName=o=>{const{separator:et,experimentalParseClassName:tt}=o,nt=et.length===1,rt=et[0],ot=et.length,it=st=>{const at=[];let ct=0,lt=0,dt;for(let yt=0;ytlt?dt-lt:void 0;return{modifiers:at,hasImportantModifier:pt,baseClassName:mt,maybePostfixModifierPosition:ft}};return tt?st=>tt({className:st,parseClassName:it}):it},sortModifiers=o=>{if(o.length<=1)return o;const et=[];let tt=[];return o.forEach(nt=>{nt[0]==="["?(et.push(...tt.sort(),nt),tt=[]):tt.push(nt)}),et.push(...tt.sort()),et},createConfigUtils=o=>({cache:createLruCache(o.cacheSize),parseClassName:createParseClassName(o),...createClassGroupUtils(o)}),SPLIT_CLASSES_REGEX=/\s+/,mergeClassList=(o,et)=>{const{parseClassName:tt,getClassGroupId:nt,getConflictingClassGroupIds:rt}=et,ot=[],it=o.trim().split(SPLIT_CLASSES_REGEX);let st="";for(let at=it.length-1;at>=0;at-=1){const ct=it[at],{modifiers:lt,hasImportantModifier:dt,baseClassName:ht,maybePostfixModifierPosition:pt}=tt(ct);let mt=!!pt,ft=nt(mt?ht.substring(0,pt):ht);if(!ft){if(!mt){st=ct+(st.length>0?" "+st:st);continue}if(ft=nt(ht),!ft){st=ct+(st.length>0?" "+st:st);continue}mt=!1}const yt=sortModifiers(lt).join(":"),gt=dt?yt+IMPORTANT_MODIFIER:yt,xt=gt+ft;if(ot.includes(xt))continue;ot.push(xt);const vt=rt(ft,mt);for(let bt=0;bt0?" "+st:st)}return st};function twJoin(){let o=0,et,tt,nt="";for(;o{if(typeof o=="string")return o;let et,tt="";for(let nt=0;ntdt(lt),o());return tt=createConfigUtils(ct),nt=tt.cache.get,rt=tt.cache.set,ot=st,st(at)}function st(at){const ct=nt(at);if(ct)return ct;const lt=mergeClassList(at,tt);return rt(at,lt),lt}return function(){return ot(twJoin.apply(null,arguments))}}const fromTheme=o=>{const et=tt=>tt[o]||[];return et.isThemeGetter=!0,et},arbitraryValueRegex=/^\[(?:([a-z-]+):)?(.+)\]$/i,fractionRegex=/^\d+\/\d+$/,stringLengths=new Set(["px","full","screen"]),tshirtUnitRegex=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lengthUnitRegex=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,colorFunctionRegex=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,shadowRegex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,imageRegex=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,isLength=o=>isNumber(o)||stringLengths.has(o)||fractionRegex.test(o),isArbitraryLength=o=>getIsArbitraryValue(o,"length",isLengthOnly),isNumber=o=>!!o&&!Number.isNaN(Number(o)),isArbitraryNumber=o=>getIsArbitraryValue(o,"number",isNumber),isInteger$1=o=>!!o&&Number.isInteger(Number(o)),isPercent=o=>o.endsWith("%")&&isNumber(o.slice(0,-1)),isArbitraryValue=o=>arbitraryValueRegex.test(o),isTshirtSize=o=>tshirtUnitRegex.test(o),sizeLabels=new Set(["length","size","percentage"]),isArbitrarySize=o=>getIsArbitraryValue(o,sizeLabels,isNever),isArbitraryPosition=o=>getIsArbitraryValue(o,"position",isNever),imageLabels=new Set(["image","url"]),isArbitraryImage=o=>getIsArbitraryValue(o,imageLabels,isImage),isArbitraryShadow=o=>getIsArbitraryValue(o,"",isShadow),isAny=()=>!0,getIsArbitraryValue=(o,et,tt)=>{const nt=arbitraryValueRegex.exec(o);return nt?nt[1]?typeof et=="string"?nt[1]===et:et.has(nt[1]):tt(nt[2]):!1},isLengthOnly=o=>lengthUnitRegex.test(o)&&!colorFunctionRegex.test(o),isNever=()=>!1,isShadow=o=>shadowRegex.test(o),isImage=o=>imageRegex.test(o),getDefaultConfig=()=>{const o=fromTheme("colors"),et=fromTheme("spacing"),tt=fromTheme("blur"),nt=fromTheme("brightness"),rt=fromTheme("borderColor"),ot=fromTheme("borderRadius"),it=fromTheme("borderSpacing"),st=fromTheme("borderWidth"),at=fromTheme("contrast"),ct=fromTheme("grayscale"),lt=fromTheme("hueRotate"),dt=fromTheme("invert"),ht=fromTheme("gap"),pt=fromTheme("gradientColorStops"),mt=fromTheme("gradientColorStopPositions"),ft=fromTheme("inset"),yt=fromTheme("margin"),gt=fromTheme("opacity"),xt=fromTheme("padding"),vt=fromTheme("saturate"),bt=fromTheme("scale"),Et=fromTheme("sepia"),wt=fromTheme("skew"),kt=fromTheme("space"),It=fromTheme("translate"),Rt=()=>["auto","contain","none"],Pt=()=>["auto","hidden","clip","visible","scroll"],jt=()=>["auto",isArbitraryValue,et],Ot=()=>[isArbitraryValue,et],Bt=()=>["",isLength,isArbitraryLength],zt=()=>["auto",isNumber,isArbitraryValue],Ft=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Yt=()=>["solid","dashed","dotted","double","none"],Ht=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ut=()=>["start","end","center","between","around","evenly","stretch"],qt=()=>["","0",isArbitraryValue],Lt=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Zt=()=>[isNumber,isArbitraryValue];return{cacheSize:500,separator:":",theme:{colors:[isAny],spacing:[isLength,isArbitraryLength],blur:["none","",isTshirtSize,isArbitraryValue],brightness:Zt(),borderColor:[o],borderRadius:["none","","full",isTshirtSize,isArbitraryValue],borderSpacing:Ot(),borderWidth:Bt(),contrast:Zt(),grayscale:qt(),hueRotate:Zt(),invert:qt(),gap:Ot(),gradientColorStops:[o],gradientColorStopPositions:[isPercent,isArbitraryLength],inset:jt(),margin:jt(),opacity:Zt(),padding:Ot(),saturate:Zt(),scale:Zt(),sepia:qt(),skew:Zt(),space:Ot(),translate:Ot()},classGroups:{aspect:[{aspect:["auto","square","video",isArbitraryValue]}],container:["container"],columns:[{columns:[isTshirtSize]}],"break-after":[{"break-after":Lt()}],"break-before":[{"break-before":Lt()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Ft(),isArbitraryValue]}],overflow:[{overflow:Pt()}],"overflow-x":[{"overflow-x":Pt()}],"overflow-y":[{"overflow-y":Pt()}],overscroll:[{overscroll:Rt()}],"overscroll-x":[{"overscroll-x":Rt()}],"overscroll-y":[{"overscroll-y":Rt()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[ft]}],"inset-x":[{"inset-x":[ft]}],"inset-y":[{"inset-y":[ft]}],start:[{start:[ft]}],end:[{end:[ft]}],top:[{top:[ft]}],right:[{right:[ft]}],bottom:[{bottom:[ft]}],left:[{left:[ft]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",isInteger$1,isArbitraryValue]}],basis:[{basis:jt()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",isArbitraryValue]}],grow:[{grow:qt()}],shrink:[{shrink:qt()}],order:[{order:["first","last","none",isInteger$1,isArbitraryValue]}],"grid-cols":[{"grid-cols":[isAny]}],"col-start-end":[{col:["auto",{span:["full",isInteger$1,isArbitraryValue]},isArbitraryValue]}],"col-start":[{"col-start":zt()}],"col-end":[{"col-end":zt()}],"grid-rows":[{"grid-rows":[isAny]}],"row-start-end":[{row:["auto",{span:[isInteger$1,isArbitraryValue]},isArbitraryValue]}],"row-start":[{"row-start":zt()}],"row-end":[{"row-end":zt()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",isArbitraryValue]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",isArbitraryValue]}],gap:[{gap:[ht]}],"gap-x":[{"gap-x":[ht]}],"gap-y":[{"gap-y":[ht]}],"justify-content":[{justify:["normal",...Ut()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Ut(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Ut(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[xt]}],px:[{px:[xt]}],py:[{py:[xt]}],ps:[{ps:[xt]}],pe:[{pe:[xt]}],pt:[{pt:[xt]}],pr:[{pr:[xt]}],pb:[{pb:[xt]}],pl:[{pl:[xt]}],m:[{m:[yt]}],mx:[{mx:[yt]}],my:[{my:[yt]}],ms:[{ms:[yt]}],me:[{me:[yt]}],mt:[{mt:[yt]}],mr:[{mr:[yt]}],mb:[{mb:[yt]}],ml:[{ml:[yt]}],"space-x":[{"space-x":[kt]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[kt]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",isArbitraryValue,et]}],"min-w":[{"min-w":[isArbitraryValue,et,"min","max","fit"]}],"max-w":[{"max-w":[isArbitraryValue,et,"none","full","min","max","fit","prose",{screen:[isTshirtSize]},isTshirtSize]}],h:[{h:[isArbitraryValue,et,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[isArbitraryValue,et,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[isArbitraryValue,et,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[isArbitraryValue,et,"auto","min","max","fit"]}],"font-size":[{text:["base",isTshirtSize,isArbitraryLength]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",isArbitraryNumber]}],"font-family":[{font:[isAny]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",isArbitraryValue]}],"line-clamp":[{"line-clamp":["none",isNumber,isArbitraryNumber]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",isLength,isArbitraryValue]}],"list-image":[{"list-image":["none",isArbitraryValue]}],"list-style-type":[{list:["none","disc","decimal",isArbitraryValue]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[o]}],"placeholder-opacity":[{"placeholder-opacity":[gt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[o]}],"text-opacity":[{"text-opacity":[gt]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Yt(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",isLength,isArbitraryLength]}],"underline-offset":[{"underline-offset":["auto",isLength,isArbitraryValue]}],"text-decoration-color":[{decoration:[o]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Ot()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",isArbitraryValue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",isArbitraryValue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[gt]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Ft(),isArbitraryPosition]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",isArbitrarySize]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},isArbitraryImage]}],"bg-color":[{bg:[o]}],"gradient-from-pos":[{from:[mt]}],"gradient-via-pos":[{via:[mt]}],"gradient-to-pos":[{to:[mt]}],"gradient-from":[{from:[pt]}],"gradient-via":[{via:[pt]}],"gradient-to":[{to:[pt]}],rounded:[{rounded:[ot]}],"rounded-s":[{"rounded-s":[ot]}],"rounded-e":[{"rounded-e":[ot]}],"rounded-t":[{"rounded-t":[ot]}],"rounded-r":[{"rounded-r":[ot]}],"rounded-b":[{"rounded-b":[ot]}],"rounded-l":[{"rounded-l":[ot]}],"rounded-ss":[{"rounded-ss":[ot]}],"rounded-se":[{"rounded-se":[ot]}],"rounded-ee":[{"rounded-ee":[ot]}],"rounded-es":[{"rounded-es":[ot]}],"rounded-tl":[{"rounded-tl":[ot]}],"rounded-tr":[{"rounded-tr":[ot]}],"rounded-br":[{"rounded-br":[ot]}],"rounded-bl":[{"rounded-bl":[ot]}],"border-w":[{border:[st]}],"border-w-x":[{"border-x":[st]}],"border-w-y":[{"border-y":[st]}],"border-w-s":[{"border-s":[st]}],"border-w-e":[{"border-e":[st]}],"border-w-t":[{"border-t":[st]}],"border-w-r":[{"border-r":[st]}],"border-w-b":[{"border-b":[st]}],"border-w-l":[{"border-l":[st]}],"border-opacity":[{"border-opacity":[gt]}],"border-style":[{border:[...Yt(),"hidden"]}],"divide-x":[{"divide-x":[st]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[st]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[gt]}],"divide-style":[{divide:Yt()}],"border-color":[{border:[rt]}],"border-color-x":[{"border-x":[rt]}],"border-color-y":[{"border-y":[rt]}],"border-color-s":[{"border-s":[rt]}],"border-color-e":[{"border-e":[rt]}],"border-color-t":[{"border-t":[rt]}],"border-color-r":[{"border-r":[rt]}],"border-color-b":[{"border-b":[rt]}],"border-color-l":[{"border-l":[rt]}],"divide-color":[{divide:[rt]}],"outline-style":[{outline:["",...Yt()]}],"outline-offset":[{"outline-offset":[isLength,isArbitraryValue]}],"outline-w":[{outline:[isLength,isArbitraryLength]}],"outline-color":[{outline:[o]}],"ring-w":[{ring:Bt()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[o]}],"ring-opacity":[{"ring-opacity":[gt]}],"ring-offset-w":[{"ring-offset":[isLength,isArbitraryLength]}],"ring-offset-color":[{"ring-offset":[o]}],shadow:[{shadow:["","inner","none",isTshirtSize,isArbitraryShadow]}],"shadow-color":[{shadow:[isAny]}],opacity:[{opacity:[gt]}],"mix-blend":[{"mix-blend":[...Ht(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Ht()}],filter:[{filter:["","none"]}],blur:[{blur:[tt]}],brightness:[{brightness:[nt]}],contrast:[{contrast:[at]}],"drop-shadow":[{"drop-shadow":["","none",isTshirtSize,isArbitraryValue]}],grayscale:[{grayscale:[ct]}],"hue-rotate":[{"hue-rotate":[lt]}],invert:[{invert:[dt]}],saturate:[{saturate:[vt]}],sepia:[{sepia:[Et]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[tt]}],"backdrop-brightness":[{"backdrop-brightness":[nt]}],"backdrop-contrast":[{"backdrop-contrast":[at]}],"backdrop-grayscale":[{"backdrop-grayscale":[ct]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[lt]}],"backdrop-invert":[{"backdrop-invert":[dt]}],"backdrop-opacity":[{"backdrop-opacity":[gt]}],"backdrop-saturate":[{"backdrop-saturate":[vt]}],"backdrop-sepia":[{"backdrop-sepia":[Et]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[it]}],"border-spacing-x":[{"border-spacing-x":[it]}],"border-spacing-y":[{"border-spacing-y":[it]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",isArbitraryValue]}],duration:[{duration:Zt()}],ease:[{ease:["linear","in","out","in-out",isArbitraryValue]}],delay:[{delay:Zt()}],animate:[{animate:["none","spin","ping","pulse","bounce",isArbitraryValue]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[bt]}],"scale-x":[{"scale-x":[bt]}],"scale-y":[{"scale-y":[bt]}],rotate:[{rotate:[isInteger$1,isArbitraryValue]}],"translate-x":[{"translate-x":[It]}],"translate-y":[{"translate-y":[It]}],"skew-x":[{"skew-x":[wt]}],"skew-y":[{"skew-y":[wt]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",isArbitraryValue]}],accent:[{accent:["auto",o]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",isArbitraryValue]}],"caret-color":[{caret:[o]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Ot()}],"scroll-mx":[{"scroll-mx":Ot()}],"scroll-my":[{"scroll-my":Ot()}],"scroll-ms":[{"scroll-ms":Ot()}],"scroll-me":[{"scroll-me":Ot()}],"scroll-mt":[{"scroll-mt":Ot()}],"scroll-mr":[{"scroll-mr":Ot()}],"scroll-mb":[{"scroll-mb":Ot()}],"scroll-ml":[{"scroll-ml":Ot()}],"scroll-p":[{"scroll-p":Ot()}],"scroll-px":[{"scroll-px":Ot()}],"scroll-py":[{"scroll-py":Ot()}],"scroll-ps":[{"scroll-ps":Ot()}],"scroll-pe":[{"scroll-pe":Ot()}],"scroll-pt":[{"scroll-pt":Ot()}],"scroll-pr":[{"scroll-pr":Ot()}],"scroll-pb":[{"scroll-pb":Ot()}],"scroll-pl":[{"scroll-pl":Ot()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",isArbitraryValue]}],fill:[{fill:[o,"none"]}],"stroke-w":[{stroke:[isLength,isArbitraryLength,isArbitraryNumber]}],stroke:[{stroke:[o,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},twMerge=createTailwindMerge(getDefaultConfig);function cn(...o){return twMerge(clsx(o))}const buttonVariants=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Button=reactExports.forwardRef(({className:o,variant:et,size:tt,asChild:nt=!1,...rt},ot)=>{const it=nt?Slot:"button";return jsxRuntimeExports.jsx(it,{className:cn("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50","min-h-[44px] px-4 py-2 md:min-h-[36px] md:px-3 md:py-1.5",buttonVariants({variant:et,size:tt,className:o})),ref:ot,...rt})});Button.displayName="Button";function alloc$2(o=0){return new Uint8Array(o)}function allocUnsafe(o=0){return new Uint8Array(o)}const N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),MSB$2=128,REST$2=127;function encodingLength$3(o){if(oNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function encodeUint8Array(o,et,tt=0){switch(encodingLength$3(o)){case 8:et[tt++]=o&255|MSB$2,o/=128;case 7:et[tt++]=o&255|MSB$2,o/=128;case 6:et[tt++]=o&255|MSB$2,o/=128;case 5:et[tt++]=o&255|MSB$2,o/=128;case 4:et[tt++]=o&255|MSB$2,o>>>=7;case 3:et[tt++]=o&255|MSB$2,o>>>=7;case 2:et[tt++]=o&255|MSB$2,o>>>=7;case 1:{et[tt++]=o&255,o>>>=7;break}default:throw new Error("unreachable")}return et}function encodeUint8ArrayList(o,et,tt=0){switch(encodingLength$3(o)){case 8:et.set(tt++,o&255|MSB$2),o/=128;case 7:et.set(tt++,o&255|MSB$2),o/=128;case 6:et.set(tt++,o&255|MSB$2),o/=128;case 5:et.set(tt++,o&255|MSB$2),o/=128;case 4:et.set(tt++,o&255|MSB$2),o>>>=7;case 3:et.set(tt++,o&255|MSB$2),o>>>=7;case 2:et.set(tt++,o&255|MSB$2),o>>>=7;case 1:{et.set(tt++,o&255),o>>>=7;break}default:throw new Error("unreachable")}return et}function decodeUint8Array(o,et){let tt=o[et],nt=0;if(nt+=tt&REST$2,tt>>31>0){const tt=~this.lo+1>>>0;let nt=~this.hi>>>0;return tt===0&&(nt=nt+1>>>0),-(tt+nt*4294967296)}return this.lo+this.hi*4294967296}toBigInt(et=!1){if(et)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){const tt=~this.lo+1>>>0;let nt=~this.hi>>>0;return tt===0&&(nt=nt+1>>>0),-(BigInt(tt)+(BigInt(nt)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(et=!1){return this.toBigInt(et).toString()}zzEncode(){const et=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^et)>>>0,this.lo=(this.lo<<1^et)>>>0,this}zzDecode(){const et=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^et)>>>0,this.hi=(this.hi>>>1^et)>>>0,this}length(){const et=this.lo,tt=(this.lo>>>28|this.hi<<4)>>>0,nt=this.hi>>>24;return nt===0?tt===0?et<16384?et<128?1:2:et<2097152?3:4:tt<16384?tt<128?5:6:tt<2097152?7:8:nt<128?9:10}static fromBigInt(et){if(et===0n)return zero;if(etMIN_SAFE_NUMBER_INTEGER)return this.fromNumber(Number(et));const tt=et<0n;tt&&(et=-et);let nt=et>>32n,rt=et-(nt<<32n);return tt&&(nt=~nt|0n,rt=~rt|0n,++rt>TWO_32&&(rt=0n,++nt>TWO_32&&(nt=0n))),new Er(Number(rt),Number(nt))}static fromNumber(et){if(et===0)return zero;const tt=et<0;tt&&(et=-et);let nt=et>>>0,rt=(et-nt)/4294967296>>>0;return tt&&(rt=~rt>>>0,nt=~nt>>>0,++nt>4294967295&&(nt=0,++rt>4294967295&&(rt=0))),new Er(nt,rt)}static from(et){return typeof et=="number"?Er.fromNumber(et):typeof et=="bigint"?Er.fromBigInt(et):typeof et=="string"?Er.fromBigInt(BigInt(et)):et.low!=null||et.high!=null?new Er(et.low>>>0,et.high>>>0):zero}};const zero=new LongBits$2(0,0);zero.toBigInt=function(){return 0n};zero.zzEncode=zero.zzDecode=function(){return this};zero.length=function(){return 1};const TWO_32=4294967296n;function length$1(o){let et=0,tt=0;for(let nt=0;nt191&&st<224?ot[it++]=(st&31)<<6|o[et++]&63:st>239&&st<365?(st=((st&7)<<18|(o[et++]&63)<<12|(o[et++]&63)<<6|o[et++]&63)-65536,ot[it++]=55296+(st>>10),ot[it++]=56320+(st&1023)):ot[it++]=(st&15)<<12|(o[et++]&63)<<6|o[et++]&63,it>8191&&((rt??(rt=[])).push(String.fromCharCode.apply(String,ot)),it=0);return rt!=null?(it>0&&rt.push(String.fromCharCode.apply(String,ot.slice(0,it))),rt.join("")):String.fromCharCode.apply(String,ot.slice(0,it))}function write$2(o,et,tt){const nt=tt;let rt,ot;for(let it=0;it>6|192,et[tt++]=rt&63|128):(rt&64512)===55296&&((ot=o.charCodeAt(it+1))&64512)===56320?(rt=65536+((rt&1023)<<10)+(ot&1023),++it,et[tt++]=rt>>18|240,et[tt++]=rt>>12&63|128,et[tt++]=rt>>6&63|128,et[tt++]=rt&63|128):(et[tt++]=rt>>12|224,et[tt++]=rt>>6&63|128,et[tt++]=rt&63|128);return tt-nt}function indexOutOfRange$1(o,et){return RangeError(`index out of range: ${o.pos} + ${et??1} > ${o.len}`)}function readFixed32End(o,et){return(o[et-4]|o[et-3]<<8|o[et-2]<<16|o[et-1]<<24)>>>0}class Uint8ArrayReader{constructor(et){Ct(this,"buf");Ct(this,"pos");Ct(this,"len");Ct(this,"_slice",Uint8Array.prototype.subarray);this.buf=et,this.pos=0,this.len=et.length}uint32(){let et=4294967295;if(et=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(et=(et|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(et=(et|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(et=(et|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(et=(et|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return et;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange$1(this,10);return et}int32(){return this.uint32()|0}sint32(){const et=this.uint32();return et>>>1^-(et&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);return readFixed32End(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw indexOutOfRange$1(this,4);const et=readFloatLE(this.buf,this.pos);return this.pos+=4,et}double(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,4);const et=readDoubleLE(this.buf,this.pos);return this.pos+=8,et}bytes(){const et=this.uint32(),tt=this.pos,nt=this.pos+et;if(nt>this.len)throw indexOutOfRange$1(this,et);return this.pos+=et,tt===nt?new Uint8Array(0):this.buf.subarray(tt,nt)}string(){const et=this.bytes();return read$2(et,0,et.length)}skip(et){if(typeof et=="number"){if(this.pos+et>this.len)throw indexOutOfRange$1(this,et);this.pos+=et}else do if(this.pos>=this.len)throw indexOutOfRange$1(this);while(this.buf[this.pos++]&128);return this}skipType(et){switch(et){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(et=this.uint32()&7)!==4;)this.skipType(et);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${et} at offset ${this.pos}`)}return this}readLongVarint(){const et=new LongBits$2(0,0);let tt=0;if(this.len-this.pos>4){for(;tt<4;++tt)if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et;if(et.lo=(et.lo|(this.buf[this.pos]&127)<<28)>>>0,et.hi=(et.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return et;tt=0}else{for(;tt<3;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(et.lo=(et.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}return et.lo=(et.lo|(this.buf[this.pos++]&127)<>>0,et}if(this.len-this.pos>4){for(;tt<5;++tt)if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}else for(;tt<5;++tt){if(this.pos>=this.len)throw indexOutOfRange$1(this);if(et.hi=(et.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return et}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange$1(this,8);const et=readFixed32End(this.buf,this.pos+=4),tt=readFixed32End(this.buf,this.pos+=4);return new LongBits$2(et,tt)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const et=decodeUint8Array(this.buf,this.pos);return this.pos+=encodingLength$3(et),et}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function createReader(o){return new Uint8ArrayReader(o instanceof Uint8Array?o:o.subarray())}function decodeMessage(o,et,tt){const nt=createReader(o);return et.decode(nt,void 0,tt)}function equals$2(o,et){if(o===et)return!0;if(o.byteLength!==et.byteLength)return!1;for(let tt=0;tt=255)throw new TypeError("Alphabet too long");for(var tt=new Uint8Array(256),nt=0;nt>>0,bt=new Uint8Array(vt);gt!==xt;){for(var Et=mt[gt],wt=0,kt=vt-1;(Et!==0||wt>>0,bt[kt]=Et%st>>>0,Et=Et/st>>>0;if(Et!==0)throw new Error("Non-zero carry");yt=wt,gt++}for(var It=vt-yt;It!==vt&&bt[It]===0;)It++;for(var Rt=at.repeat(ft);It>>0,vt=new Uint8Array(xt);mt[ft];){var bt=tt[mt.charCodeAt(ft)];if(bt===255)return;for(var Et=0,wt=xt-1;(bt!==0||Et>>0,vt[wt]=bt%256>>>0,bt=bt/256>>>0;if(bt!==0)throw new Error("Non-zero carry");gt=Et,ft++}if(mt[ft]!==" "){for(var kt=xt-gt;kt!==xt&&vt[kt]===0;)kt++;for(var It=new Uint8Array(yt+(xt-kt)),Rt=yt;kt!==xt;)It[Rt++]=vt[kt++];return It}}}function pt(mt){var ft=ht(mt);if(ft)return ft;throw new Error(`Non-${et} character`)}return{encode:dt,decodeUnsafe:ht,decode:pt}}var src$1=base$1,_brrp__multiformats_scope_baseX=src$1;let Encoder$2=class{constructor(et,tt,nt){Ct(this,"name");Ct(this,"prefix");Ct(this,"baseEncode");this.name=et,this.prefix=tt,this.baseEncode=nt}encode(et){if(et instanceof Uint8Array)return`${this.prefix}${this.baseEncode(et)}`;throw Error("Unknown type, must be binary type")}},Decoder$2=class{constructor(et,tt,nt){Ct(this,"name");Ct(this,"prefix");Ct(this,"baseDecode");Ct(this,"prefixCodePoint");this.name=et,this.prefix=tt;const rt=tt.codePointAt(0);if(rt===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=rt,this.baseDecode=nt}decode(et){if(typeof et=="string"){if(et.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(et)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(et.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(et){return or$2(this,et)}};class ComposedDecoder{constructor(et){Ct(this,"decoders");this.decoders=et}or(et){return or$2(this,et)}decode(et){const tt=et[0],nt=this.decoders[tt];if(nt!=null)return nt.decode(et);throw RangeError(`Unable to decode multibase string ${JSON.stringify(et)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function or$2(o,et){return new ComposedDecoder({...o.decoders??{[o.prefix]:o},...et.decoders??{[et.prefix]:et}})}class Codec{constructor(et,tt,nt,rt){Ct(this,"name");Ct(this,"prefix");Ct(this,"baseEncode");Ct(this,"baseDecode");Ct(this,"encoder");Ct(this,"decoder");this.name=et,this.prefix=tt,this.baseEncode=nt,this.baseDecode=rt,this.encoder=new Encoder$2(et,tt,nt),this.decoder=new Decoder$2(et,tt,rt)}encode(et){return this.encoder.encode(et)}decode(et){return this.decoder.decode(et)}}function from$2({name:o,prefix:et,encode:tt,decode:nt}){return new Codec(o,et,tt,nt)}function baseX({name:o,prefix:et,alphabet:tt}){const{encode:nt,decode:rt}=_brrp__multiformats_scope_baseX(tt,o);return from$2({prefix:et,name:o,encode:nt,decode:ot=>coerce(rt(ot))})}function decode$a(o,et,tt,nt){const rt={};for(let lt=0;lt=8&&(st-=8,it[ct++]=255&at>>st)}if(st>=tt||255&at<<8-st)throw new SyntaxError("Unexpected end of data");return it}function encode$9(o,et,tt){const nt=et[et.length-1]==="=",rt=(1<tt;)it-=tt,ot+=et[rt&st>>it];if(it!==0&&(ot+=et[rt&st<(o[tt]=et,o),[]),alphabetCharsToBytes=alphabet.reduce((o,et,tt)=>{const nt=et.codePointAt(0);if(nt==null)throw new Error(`Invalid character: ${et}`);return o[nt]=tt,o},[]);function encode$8(o){return o.reduce((et,tt)=>(et+=alphabetBytesToChars[tt],et),"")}function decode$9(o){const et=[];for(const tt of o){const nt=tt.codePointAt(0);if(nt==null)throw new Error(`Invalid character: ${tt}`);const rt=alphabetCharsToBytes[nt];if(rt==null)throw new Error(`Non-base256emoji character: ${tt}`);et.push(rt)}return new Uint8Array(et)}const base256emoji=from$2({prefix:"🚀",name:"base256emoji",encode:encode$8,decode:decode$9}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"})),base32$2=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$3=Object.freeze(Object.defineProperty({__proto__:null,base32:base32$2,base32hex,base32hexpad,base32hexpadupper,base32hexupper,base32pad,base32padupper,base32upper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base58btc=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr=baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),base58=Object.freeze(Object.defineProperty({__proto__:null,base58btc,base58flickr},Symbol.toStringTag,{value:"Module"})),base64$2=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$3=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$2,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),identity$1=from$2({prefix:"\0",name:"identity",encode:o=>toString$9(o),decode:o=>fromString$1(o)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$1},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;var encode_1=encode$7,MSB$1=128,REST$1=127,MSBALL=~REST$1,INT=Math.pow(2,31);function encode$7(o,et,tt){et=et||[],tt=tt||0;for(var nt=tt;o>=INT;)et[tt++]=o&255|MSB$1,o/=128;for(;o&MSBALL;)et[tt++]=o&255|MSB$1,o>>>=7;return et[tt]=o|0,encode$7.bytes=tt-nt+1,et}var decode$8=read$1,MSB$1$1=128,REST$1$1=127;function read$1(o,nt){var tt=0,nt=nt||0,rt=0,ot=nt,it,st=o.length;do{if(ot>=st)throw read$1.bytes=0,new RangeError("Could not decode varint");it=o[ot++],tt+=rt<28?(it&REST$1$1)<=MSB$1$1);return read$1.bytes=ot-nt,tt}var N1=Math.pow(2,7),N2=Math.pow(2,14),N3=Math.pow(2,21),N4=Math.pow(2,28),N5=Math.pow(2,35),N6=Math.pow(2,42),N7=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length=function(o){return ocreate$3(this.code,nt))}else throw Error("Unknown type, must be binary type")}}function sha(o){return async et=>new Uint8Array(await crypto.subtle.digest(o,et))}const sha256=from$1({name:"sha2-256",code:18,encode:sha("SHA-256")});function format(o,et){const{bytes:tt,version:nt}=o;switch(nt){case 0:return toStringV0(tt,baseCache(o),et??base58btc.encoder);default:return toStringV1(tt,baseCache(o),et??base32$2.encoder)}}const cache$1=new WeakMap;function baseCache(o){const et=cache$1.get(o);if(et==null){const tt=new Map;return cache$1.set(o,tt),tt}return et}var Qs;class CID{constructor(et,tt,nt,rt){Ct(this,"code");Ct(this,"version");Ct(this,"multihash");Ct(this,"bytes");Ct(this,"/");Ct(this,Qs,"CID");this.code=tt,this.version=et,this.multihash=nt,this.bytes=rt,this["/"]=rt}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{const{code:et,multihash:tt}=this;if(et!==DAG_PB_CODE)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(tt.code!==SHA_256_CODE)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return CID.createV0(tt)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{const{code:et,digest:tt}=this.multihash,nt=create$3(et,tt);return CID.createV1(this.code,nt)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(et){return CID.equals(this,et)}static equals(et,tt){const nt=tt;return nt!=null&&et.code===nt.code&&et.version===nt.version&&equals$1(et.multihash,nt.multihash)}toString(et){return format(this,et)}toJSON(){return{"/":format(this)}}link(){return this}[(Qs=Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"))](){return`CID(${this.toString()})`}static asCID(et){if(et==null)return null;const tt=et;if(tt instanceof CID)return tt;if(tt["/"]!=null&&tt["/"]===tt.bytes||tt.asCID===tt){const{version:nt,code:rt,multihash:ot,bytes:it}=tt;return new CID(nt,rt,ot,it??encodeCID(nt,rt,ot.bytes))}else if(tt[cidSymbol]===!0){const{version:nt,multihash:rt,code:ot}=tt,it=decode$6(rt);return CID.create(nt,ot,it)}else return null}static create(et,tt,nt){if(typeof tt!="number")throw new Error("String codecs are no longer supported");if(!(nt.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(et){case 0:{if(tt!==DAG_PB_CODE)throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);return new CID(et,tt,nt,nt.bytes)}case 1:{const rt=encodeCID(et,tt,nt.bytes);return new CID(et,tt,nt,rt)}default:throw new Error("Invalid version")}}static createV0(et){return CID.create(0,DAG_PB_CODE,et)}static createV1(et,tt){return CID.create(1,et,tt)}static decode(et){const[tt,nt]=CID.decodeFirst(et);if(nt.length!==0)throw new Error("Incorrect length");return tt}static decodeFirst(et){const tt=CID.inspectBytes(et),nt=tt.size-tt.multihashSize,rt=coerce(et.subarray(nt,nt+tt.multihashSize));if(rt.byteLength!==tt.multihashSize)throw new Error("Incorrect length");const ot=rt.subarray(tt.multihashSize-tt.digestSize),it=new Digest(tt.multihashCode,tt.digestSize,ot,rt);return[tt.version===0?CID.createV0(it):CID.createV1(tt.codec,it),et.subarray(tt.size)]}static inspectBytes(et){let tt=0;const nt=()=>{const[dt,ht]=decode$7(et.subarray(tt));return tt+=ht,dt};let rt=nt(),ot=DAG_PB_CODE;if(rt===18?(rt=0,tt=0):ot=nt(),rt!==0&&rt!==1)throw new RangeError(`Invalid CID version ${rt}`);const it=tt,st=nt(),at=nt(),ct=tt+at,lt=ct-it;return{version:rt,codec:ot,multihashCode:st,digestSize:at,multihashSize:lt,size:ct}}static parse(et,tt){const[nt,rt]=parseCIDtoBytes(et,tt),ot=CID.decode(rt);if(ot.version===0&&et[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return baseCache(ot).set(nt,et),ot}}function parseCIDtoBytes(o,et){switch(o[0]){case"Q":{const tt=et??base58btc;return[base58btc.prefix,tt.decode(`${base58btc.prefix}${o}`)]}case base58btc.prefix:{const tt=et??base58btc;return[base58btc.prefix,tt.decode(o)]}case base32$2.prefix:{const tt=et??base32$2;return[base32$2.prefix,tt.decode(o)]}case base36.prefix:{const tt=et??base36;return[base36.prefix,tt.decode(o)]}default:{if(et==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[o[0],et.decode(o)]}}}function toStringV0(o,et,tt){const{prefix:nt}=tt;if(nt!==base58btc.prefix)throw Error(`Cannot string encode V0 in ${tt.name} encoding`);const rt=et.get(nt);if(rt==null){const ot=tt.encode(o).slice(1);return et.set(nt,ot),ot}else return rt}function toStringV1(o,et,tt){const{prefix:nt}=tt,rt=et.get(nt);if(rt==null){const ot=tt.encode(o);return et.set(nt,ot),ot}else return rt}const DAG_PB_CODE=112,SHA_256_CODE=18;function encodeCID(o,et,tt){const nt=encodingLength$2(o),rt=nt+encodingLength$2(et),ot=new Uint8Array(rt+tt.byteLength);return encodeTo(o,ot,0),encodeTo(et,ot,nt),ot.set(tt,rt),ot}const cidSymbol=Symbol.for("@ipld/js-cid/CID"),bases={...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$3,...base36$1,...base58,...base64$3,...base256emoji$1};function createCodec$1(o,et,tt,nt){return{name:o,prefix:et,encoder:{name:o,prefix:et,encode:tt},decoder:{decode:nt}}}const string$4=createCodec$1("utf8","u",o=>"u"+new TextDecoder("utf8").decode(o),o=>new TextEncoder().encode(o.substring(1))),ascii=createCodec$1("ascii","a",o=>{let et="a";for(let tt=0;tt{o=o.substring(1);const et=allocUnsafe(o.length);for(let tt=0;tt4096)return allocUnsafe(it);rt+it>8192&&(nt=allocUnsafe(8192),rt=0);const st=nt.subarray(rt,rt+=it);return rt&7&&(rt=(rt|7)+1),st}}let Op$1=class{constructor(et,tt,nt){Ct(this,"fn");Ct(this,"len");Ct(this,"next");Ct(this,"val");this.fn=et,this.len=tt,this.next=void 0,this.val=nt}};function noop$2(){}let State$1=class{constructor(et){Ct(this,"head");Ct(this,"tail");Ct(this,"len");Ct(this,"next");this.head=et.head,this.tail=et.tail,this.len=et.len,this.next=et.states}};const bufferPool=pool$1();function alloc$1(o){return globalThis.Buffer!=null?allocUnsafe(o):bufferPool(o)}class Uint8ArrayWriter{constructor(){Ct(this,"len");Ct(this,"head");Ct(this,"tail");Ct(this,"states");this.len=0,this.head=new Op$1(noop$2,0,0),this.tail=this.head,this.states=null}_push(et,tt,nt){return this.tail=this.tail.next=new Op$1(et,tt,nt),this.len+=tt,this}uint32(et){return this.len+=(this.tail=this.tail.next=new VarintOp$1((et=et>>>0)<128?1:et<16384?2:et<2097152?3:et<268435456?4:5,et)).len,this}int32(et){return et<0?this._push(writeVarint64$1,10,LongBits$2.fromNumber(et)):this.uint32(et)}sint32(et){return this.uint32((et<<1^et>>31)>>>0)}uint64(et){const tt=LongBits$2.fromBigInt(et);return this._push(writeVarint64$1,tt.length(),tt)}uint64Number(et){return this._push(encodeUint8Array,encodingLength$3(et),et)}uint64String(et){return this.uint64(BigInt(et))}int64(et){return this.uint64(et)}int64Number(et){return this.uint64Number(et)}int64String(et){return this.uint64String(et)}sint64(et){const tt=LongBits$2.fromBigInt(et).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64Number(et){const tt=LongBits$2.fromNumber(et).zzEncode();return this._push(writeVarint64$1,tt.length(),tt)}sint64String(et){return this.sint64(BigInt(et))}bool(et){return this._push(writeByte$1,1,et?1:0)}fixed32(et){return this._push(writeFixed32$1,4,et>>>0)}sfixed32(et){return this.fixed32(et)}fixed64(et){const tt=LongBits$2.fromBigInt(et);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.hi)}fixed64Number(et){const tt=LongBits$2.fromNumber(et);return this._push(writeFixed32$1,4,tt.lo)._push(writeFixed32$1,4,tt.hi)}fixed64String(et){return this.fixed64(BigInt(et))}sfixed64(et){return this.fixed64(et)}sfixed64Number(et){return this.fixed64Number(et)}sfixed64String(et){return this.fixed64String(et)}float(et){return this._push(writeFloatLE,4,et)}double(et){return this._push(writeDoubleLE,8,et)}bytes(et){const tt=et.length>>>0;return tt===0?this._push(writeByte$1,1,0):this.uint32(tt)._push(writeBytes$1,tt,et)}string(et){const tt=length$1(et);return tt!==0?this.uint32(tt)._push(write$2,tt,et):this._push(writeByte$1,1,0)}fork(){return this.states=new State$1(this),this.head=this.tail=new Op$1(noop$2,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op$1(noop$2,0,0),this.len=0),this}ldelim(){const et=this.head,tt=this.tail,nt=this.len;return this.reset().uint32(nt),nt!==0&&(this.tail.next=et.next,this.tail=tt,this.len+=nt),this}finish(){let et=this.head.next;const tt=alloc$1(this.len);let nt=0;for(;et!=null;)et.fn(et.val,tt,nt),nt+=et.len,et=et.next;return tt}}function writeByte$1(o,et,tt){et[tt]=o&255}function writeVarint32$1(o,et,tt){for(;o>127;)et[tt++]=o&127|128,o>>>=7;et[tt]=o}let VarintOp$1=class extends Op$1{constructor(tt,nt){super(writeVarint32$1,tt,nt);Ct(this,"next");this.next=void 0}};function writeVarint64$1(o,et,tt){for(;o.hi!==0;)et[tt++]=o.lo&127|128,o.lo=(o.lo>>>7|o.hi<<25)>>>0,o.hi>>>=7;for(;o.lo>127;)et[tt++]=o.lo&127|128,o.lo=o.lo>>>7;et[tt++]=o.lo}function writeFixed32$1(o,et,tt){et[tt]=o&255,et[tt+1]=o>>>8&255,et[tt+2]=o>>>16&255,et[tt+3]=o>>>24}function writeBytes$1(o,et,tt){et.set(o,tt)}globalThis.Buffer!=null&&(Uint8ArrayWriter.prototype.bytes=function(o){const et=o.length>>>0;return this.uint32(et),et>0&&this._push(writeBytesBuffer,et,o),this},Uint8ArrayWriter.prototype.string=function(o){const et=globalThis.Buffer.byteLength(o);return this.uint32(et),et>0&&this._push(writeStringBuffer$1,et,o),this});function writeBytesBuffer(o,et,tt){et.set(o,tt)}function writeStringBuffer$1(o,et,tt){o.length<40?write$2(o,et,tt):et.utf8Write!=null?et.utf8Write(o,tt):et.set(fromString(o),tt)}function createWriter(){return new Uint8ArrayWriter}function encodeMessage(o,et){const tt=createWriter();return et.encode(o,tt,{lengthDelimited:!1}),tt.finish()}var CODEC_TYPES;(function(o){o[o.VARINT=0]="VARINT",o[o.BIT64=1]="BIT64",o[o.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",o[o.START_GROUP=3]="START_GROUP",o[o.END_GROUP=4]="END_GROUP",o[o.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec(o,et,tt,nt){return{name:o,type:et,encode:tt,decode:nt}}function enumeration(o){function et(rt){if(o[rt.toString()]==null)throw new Error("Invalid enum value");return o[rt]}const tt=function(ot,it){const st=et(ot);it.int32(st)},nt=function(ot){const it=ot.int32();return et(it)};return createCodec("enum",CODEC_TYPES.VARINT,tt,nt)}function message$1(o,et){return createCodec("message",CODEC_TYPES.LENGTH_DELIMITED,o,et)}class MaxLengthError extends Error{constructor(){super(...arguments);Ct(this,"code","ERR_MAX_LENGTH");Ct(this,"name","MaxLengthError")}}class MaxSizeError extends Error{constructor(){super(...arguments);Ct(this,"code","ERR_MAX_SIZE");Ct(this,"name","MaxSizeError")}}var RateLimitProof$4;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$4||(RateLimitProof$4={}));var WakuMessage$4;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$4.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$4.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$4||(WakuMessage$4={}));var FilterRequest;(function(o){(function(tt){let nt;tt.codec=()=>(nt==null&&(nt=message$1((rt,ot,it={})=>{it.lengthDelimited!==!1&&ot.fork(),rt.contentTopic!=null&&rt.contentTopic!==""&&(ot.uint32(10),ot.string(rt.contentTopic)),it.lengthDelimited!==!1&&ot.ldelim()},(rt,ot,it={})=>{const st={contentTopic:""},at=ot==null?rt.len:rt.pos+ot;for(;rt.pos>>3){case 1:{st.contentTopic=rt.string();break}default:{rt.skipType(ct&7);break}}}return st})),nt),tt.encode=rt=>encodeMessage(rt,tt.codec()),tt.decode=(rt,ot)=>decodeMessage(rt,tt.codec(),ot)})(o.ContentFilter||(o.ContentFilter={}));let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.subscribe!=null&&tt.subscribe!==!1&&(nt.uint32(8),nt.bool(tt.subscribe)),tt.topic!=null&&tt.topic!==""&&(nt.uint32(18),nt.string(tt.topic)),tt.contentFilters!=null)for(const ot of tt.contentFilters)nt.uint32(26),o.ContentFilter.codec().encode(ot,nt);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={subscribe:!1,topic:"",contentFilters:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.subscribe=tt.bool();break}case 2:{ot.topic=tt.string();break}case 3:{if(((st=rt.limits)==null?void 0:st.contentFilters)!=null&&ot.contentFilters.length===rt.limits.contentFilters)throw new MaxLengthError('Decode error - map field "contentFilters" had too many elements');ot.contentFilters.push(o.ContentFilter.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.contentFilters$}));break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(FilterRequest||(FilterRequest={}));var MessagePush$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.messages!=null)for(const ot of tt.messages)nt.uint32(10),WakuMessage$3.codec().encode(ot,nt);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={messages:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{if(((st=rt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===rt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessage$3.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.messages$}));break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(MessagePush$1||(MessagePush$1={}));var FilterRpc;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.request!=null&&(nt.uint32(18),FilterRequest.codec().encode(tt.request,nt)),tt.push!=null&&(nt.uint32(26),MessagePush$1.codec().encode(tt.push,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=FilterRequest.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.request});break}case 3:{ot.push=MessagePush$1.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.push});break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(FilterRpc||(FilterRpc={}));var RateLimitProof$3;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$3||(RateLimitProof$3={}));var WakuMessage$3;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$3.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$3.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$3||(WakuMessage$3={}));var TopicOnlyMessage;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 2:{ot.contentTopic=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(TopicOnlyMessage||(TopicOnlyMessage={}));var FilterSubscribeRequest;(function(o){let et;(function(rt){rt.SUBSCRIBER_PING="SUBSCRIBER_PING",rt.SUBSCRIBE="SUBSCRIBE",rt.UNSUBSCRIBE="UNSUBSCRIBE",rt.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"})(et=o.FilterSubscribeType||(o.FilterSubscribeType={}));let tt;(function(rt){rt[rt.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",rt[rt.SUBSCRIBE=1]="SUBSCRIBE",rt[rt.UNSUBSCRIBE=2]="UNSUBSCRIBE",rt[rt.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"})(tt||(tt={})),function(rt){rt.codec=()=>enumeration(tt)}(et=o.FilterSubscribeType||(o.FilterSubscribeType={}));let nt;o.codec=()=>(nt==null&&(nt=message$1((rt,ot,it={})=>{if(it.lengthDelimited!==!1&&ot.fork(),rt.requestId!=null&&rt.requestId!==""&&(ot.uint32(10),ot.string(rt.requestId)),rt.filterSubscribeType!=null&&tt[rt.filterSubscribeType]!==0&&(ot.uint32(16),o.FilterSubscribeType.codec().encode(rt.filterSubscribeType,ot)),rt.pubsubTopic!=null&&(ot.uint32(82),ot.string(rt.pubsubTopic)),rt.contentTopics!=null)for(const st of rt.contentTopics)ot.uint32(90),ot.string(st);it.lengthDelimited!==!1&&ot.ldelim()},(rt,ot,it={})=>{var ct;const st={requestId:"",filterSubscribeType:et.SUBSCRIBER_PING,contentTopics:[]},at=ot==null?rt.len:rt.pos+ot;for(;rt.pos>>3){case 1:{st.requestId=rt.string();break}case 2:{st.filterSubscribeType=o.FilterSubscribeType.codec().decode(rt);break}case 10:{st.pubsubTopic=rt.string();break}case 11:{if(((ct=it.limits)==null?void 0:ct.contentTopics)!=null&&st.contentTopics.length===it.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');st.contentTopics.push(rt.string());break}default:{rt.skipType(lt&7);break}}}return st})),nt),o.encode=rt=>encodeMessage(rt,o.codec()),o.decode=(rt,ot)=>decodeMessage(rt,o.codec(),ot)})(FilterSubscribeRequest||(FilterSubscribeRequest={}));var FilterSubscribeResponse$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.statusCode!=null&&tt.statusCode!==0&&(nt.uint32(80),nt.uint32(tt.statusCode)),tt.statusDesc!=null&&(nt.uint32(90),nt.string(tt.statusDesc)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={requestId:"",statusCode:0},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(FilterSubscribeResponse$1||(FilterSubscribeResponse$1={}));var MessagePush;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.wakuMessage!=null&&(nt.uint32(10),WakuMessage$2.codec().encode(tt.wakuMessage,nt)),tt.pubsubTopic!=null&&(nt.uint32(18),nt.string(tt.pubsubTopic)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.wakuMessage=WakuMessage$2.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.wakuMessage});break}case 2:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(MessagePush||(MessagePush={}));var RateLimitProof$2;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$2||(RateLimitProof$2={}));var WakuMessage$2;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$2.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$2.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$2||(WakuMessage$2={}));var PushRequest;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.pubsubTopic!=null&&tt.pubsubTopic!==""&&(nt.uint32(10),nt.string(tt.pubsubTopic)),tt.message!=null&&(nt.uint32(18),WakuMessage$1.codec().encode(tt.message,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={pubsubTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.pubsubTopic=tt.string();break}case 2:{ot.message=WakuMessage$1.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.message});break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PushRequest||(PushRequest={}));var PushResponse;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.isSuccess!=null&&tt.isSuccess!==!1&&(nt.uint32(8),nt.bool(tt.isSuccess)),tt.info!=null&&(nt.uint32(18),nt.string(tt.info)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={isSuccess:!1},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.isSuccess=tt.bool();break}case 2:{ot.info=tt.string();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PushResponse||(PushResponse={}));var PushRpc$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.request!=null&&(nt.uint32(18),PushRequest.codec().encode(tt.request,nt)),tt.response!=null&&(nt.uint32(26),PushResponse.codec().encode(tt.response,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.request=PushRequest.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.request});break}case 3:{ot.response=PushResponse.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PushRpc$1||(PushRpc$1={}));var RateLimitProof$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof$1||(RateLimitProof$1={}));var WakuMessage$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof$1.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof$1.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage$1||(WakuMessage$1={}));var WakuMessageKeyValue;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.messageHash!=null&&(nt.uint32(10),nt.bytes(tt.messageHash)),tt.message!=null&&(nt.uint32(18),WakuMessage.codec().encode(tt.message,nt)),tt.pubsubTopic!=null&&(nt.uint32(26),nt.string(tt.pubsubTopic)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.messageHash=tt.bytes();break}case 2:{ot.message=WakuMessage.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.message});break}case 3:{ot.pubsubTopic=tt.string();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessageKeyValue||(WakuMessageKeyValue={}));var StoreQueryRequest$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.includeData!=null&&tt.includeData!==!1&&(nt.uint32(16),nt.bool(tt.includeData)),tt.pubsubTopic!=null&&(nt.uint32(82),nt.string(tt.pubsubTopic)),tt.contentTopics!=null)for(const ot of tt.contentTopics)nt.uint32(90),nt.string(ot);if(tt.timeStart!=null&&(nt.uint32(96),nt.sint64(tt.timeStart)),tt.timeEnd!=null&&(nt.uint32(104),nt.sint64(tt.timeEnd)),tt.messageHashes!=null)for(const ot of tt.messageHashes)nt.uint32(162),nt.bytes(ot);tt.paginationCursor!=null&&(nt.uint32(410),nt.bytes(tt.paginationCursor)),tt.paginationForward!=null&&tt.paginationForward!==!1&&(nt.uint32(416),nt.bool(tt.paginationForward)),tt.paginationLimit!=null&&(nt.uint32(424),nt.uint64(tt.paginationLimit)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:"",includeData:!1,contentTopics:[],messageHashes:[],paginationForward:!1},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 2:{ot.includeData=tt.bool();break}case 10:{ot.pubsubTopic=tt.string();break}case 11:{if(((st=rt.limits)==null?void 0:st.contentTopics)!=null&&ot.contentTopics.length===rt.limits.contentTopics)throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');ot.contentTopics.push(tt.string());break}case 12:{ot.timeStart=tt.sint64();break}case 13:{ot.timeEnd=tt.sint64();break}case 20:{if(((at=rt.limits)==null?void 0:at.messageHashes)!=null&&ot.messageHashes.length===rt.limits.messageHashes)throw new MaxLengthError('Decode error - map field "messageHashes" had too many elements');ot.messageHashes.push(tt.bytes());break}case 51:{ot.paginationCursor=tt.bytes();break}case 52:{ot.paginationForward=tt.bool();break}case 53:{ot.paginationLimit=tt.uint64();break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(StoreQueryRequest$1||(StoreQueryRequest$1={}));var StoreQueryResponse$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.requestId!=null&&tt.requestId!==""&&(nt.uint32(10),nt.string(tt.requestId)),tt.statusCode!=null&&(nt.uint32(80),nt.uint32(tt.statusCode)),tt.statusDesc!=null&&(nt.uint32(90),nt.string(tt.statusDesc)),tt.messages!=null)for(const ot of tt.messages)nt.uint32(162),WakuMessageKeyValue.codec().encode(ot,nt);tt.paginationCursor!=null&&(nt.uint32(410),nt.bytes(tt.paginationCursor)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={requestId:"",messages:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.requestId=tt.string();break}case 10:{ot.statusCode=tt.uint32();break}case 11:{ot.statusDesc=tt.string();break}case 20:{if(((st=rt.limits)==null?void 0:st.messages)!=null&&ot.messages.length===rt.limits.messages)throw new MaxLengthError('Decode error - map field "messages" had too many elements');ot.messages.push(WakuMessageKeyValue.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.messages$}));break}case 51:{ot.paginationCursor=tt.bytes();break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(StoreQueryResponse$1||(StoreQueryResponse$1={}));var RateLimitProof;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.proof!=null&&tt.proof.byteLength>0&&(nt.uint32(10),nt.bytes(tt.proof)),tt.merkleRoot!=null&&tt.merkleRoot.byteLength>0&&(nt.uint32(18),nt.bytes(tt.merkleRoot)),tt.epoch!=null&&tt.epoch.byteLength>0&&(nt.uint32(26),nt.bytes(tt.epoch)),tt.shareX!=null&&tt.shareX.byteLength>0&&(nt.uint32(34),nt.bytes(tt.shareX)),tt.shareY!=null&&tt.shareY.byteLength>0&&(nt.uint32(42),nt.bytes(tt.shareY)),tt.nullifier!=null&&tt.nullifier.byteLength>0&&(nt.uint32(50),nt.bytes(tt.nullifier)),tt.rlnIdentifier!=null&&tt.rlnIdentifier.byteLength>0&&(nt.uint32(58),nt.bytes(tt.rlnIdentifier)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={proof:alloc$2(0),merkleRoot:alloc$2(0),epoch:alloc$2(0),shareX:alloc$2(0),shareY:alloc$2(0),nullifier:alloc$2(0),rlnIdentifier:alloc$2(0)},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.proof=tt.bytes();break}case 2:{ot.merkleRoot=tt.bytes();break}case 3:{ot.epoch=tt.bytes();break}case 4:{ot.shareX=tt.bytes();break}case 5:{ot.shareY=tt.bytes();break}case 6:{ot.nullifier=tt.bytes();break}case 7:{ot.rlnIdentifier=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(RateLimitProof||(RateLimitProof={}));var WakuMessage;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.payload!=null&&tt.payload.byteLength>0&&(nt.uint32(10),nt.bytes(tt.payload)),tt.contentTopic!=null&&tt.contentTopic!==""&&(nt.uint32(18),nt.string(tt.contentTopic)),tt.version!=null&&(nt.uint32(24),nt.uint32(tt.version)),tt.timestamp!=null&&(nt.uint32(80),nt.sint64(tt.timestamp)),tt.meta!=null&&(nt.uint32(90),nt.bytes(tt.meta)),tt.rateLimitProof!=null&&(nt.uint32(170),RateLimitProof.codec().encode(tt.rateLimitProof,nt)),tt.ephemeral!=null&&(nt.uint32(248),nt.bool(tt.ephemeral)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={payload:alloc$2(0),contentTopic:""},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.payload=tt.bytes();break}case 2:{ot.contentTopic=tt.string();break}case 3:{ot.version=tt.uint32();break}case 10:{ot.timestamp=tt.sint64();break}case 11:{ot.meta=tt.bytes();break}case 21:{ot.rateLimitProof=RateLimitProof.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.rateLimitProof});break}case 31:{ot.ephemeral=tt.bool();break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMessage||(WakuMessage={}));var PeerInfo;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.enr!=null&&(nt.uint32(10),nt.bytes(tt.enr)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.enr=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerInfo||(PeerInfo={}));var PeerExchangeQuery;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.numPeers!=null&&(nt.uint32(8),nt.uint64(tt.numPeers)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.numPeers=tt.uint64();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerExchangeQuery||(PeerExchangeQuery={}));var PeerExchangeResponse;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.peerInfos!=null)for(const ot of tt.peerInfos)nt.uint32(10),PeerInfo.codec().encode(ot,nt);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={peerInfos:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{if(((st=rt.limits)==null?void 0:st.peerInfos)!=null&&ot.peerInfos.length===rt.limits.peerInfos)throw new MaxLengthError('Decode error - map field "peerInfos" had too many elements');ot.peerInfos.push(PeerInfo.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.peerInfos$}));break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerExchangeResponse||(PeerExchangeResponse={}));var PeerExchangeRPC$1;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.query!=null&&(nt.uint32(10),PeerExchangeQuery.codec().encode(tt.query,nt)),tt.response!=null&&(nt.uint32(18),PeerExchangeResponse.codec().encode(tt.response,nt)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st,at;const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.query=PeerExchangeQuery.codec().decode(tt,tt.uint32(),{limits:(st=rt.limits)==null?void 0:st.query});break}case 2:{ot.response=PeerExchangeResponse.codec().decode(tt,tt.uint32(),{limits:(at=rt.limits)==null?void 0:at.response});break}default:{tt.skipType(ct&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PeerExchangeRPC$1||(PeerExchangeRPC$1={}));var WakuMetadataRequest;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.clusterId!=null&&(nt.uint32(8),nt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)nt.uint32(16),nt.uint32(ot);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={shards:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=rt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===rt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMetadataRequest||(WakuMetadataRequest={}));var WakuMetadataResponse;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{if(rt.lengthDelimited!==!1&&nt.fork(),tt.clusterId!=null&&(nt.uint32(8),nt.uint32(tt.clusterId)),tt.shards!=null)for(const ot of tt.shards)nt.uint32(16),nt.uint32(ot);rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{var st;const ot={shards:[]},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.clusterId=tt.uint32();break}case 2:{if(((st=rt.limits)==null?void 0:st.shards)!=null&&ot.shards.length===rt.limits.shards)throw new MaxLengthError('Decode error - map field "shards" had too many elements');ot.shards.push(tt.uint32());break}default:{tt.skipType(at&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(WakuMetadataResponse||(WakuMetadataResponse={}));function isDefined(o){return!!o}function groupByContentTopic(o){const et=new Map;return o.forEach(tt=>{let nt=et.get(tt.contentTopic);nt||(et.set(tt.contentTopic,[]),nt=et.get(tt.contentTopic)),nt.push(tt)}),et}const FRAME_RATE=60;async function toAsyncIterator(o,et,tt){const nt=FRAME_RATE,rt=[];let ot;ot=await o.subscribeWithUnsubscribe(et,lt=>{rt.push(lt)});const it=Number.isInteger(tt==null?void 0:tt.timeoutMs),st=0,at=Date.now();async function*ct(){for(;;){if(it&&Date.now()-at>=st)return;await wait(nt);const lt=rt.shift();if(!ot&&rt.length===0)return lt;!lt&&ot||(yield lt)}}return{iterator:ct(),async stop(){ot&&(await ot(),ot=void 0)}}}function wait(o){return new Promise(et=>{setTimeout(et,o)})}const MB=1024**2,SIZE_CAP_IN_MB=1;async function isMessageSizeUnderCap(o,et){const tt=await o.toWire(et);return tt?isWireSizeUnderCap(tt):!1}const isWireSizeUnderCap=o=>o.length/MB<=SIZE_CAP_IN_MB;var Protocols;(function(o){o.Relay="relay",o.Store="store",o.LightPush="lightpush",o.Filter="filter"})(Protocols||(Protocols={}));var ProtocolError$1;(function(o){o.GENERIC_FAIL="Generic error",o.ENCODE_FAILED="Failed to encode",o.DECODE_FAILED="Failed to decode",o.EMPTY_PAYLOAD="Payload is empty",o.SIZE_TOO_BIG="Size is too big",o.TOPIC_NOT_CONFIGURED="Topic not configured",o.TOPIC_DECODER_MISMATCH="Topic decoder mismatch",o.INVALID_DECODER_TOPICS="Invalid decoder topics",o.NO_PEER_AVAILABLE="No peer available",o.NO_STREAM_AVAILABLE="No stream available",o.NO_RESPONSE="No response received",o.REMOTE_PEER_REJECTED="Remote peer rejected",o.REQUEST_TIMEOUT="Request timeout",o.RLN_IDENTITY_MISSING="Identity credentials are not set",o.RLN_MEMBERSHIP_INDEX="Membership index is not set",o.RLN_LIMIT_MISSING="User message limit is not set",o.RLN_PROOF_GENERATION="Proof generation failed"})(ProtocolError$1||(ProtocolError$1={}));var Tags;(function(o){o.BOOTSTRAP="bootstrap",o.PEER_EXCHANGE="peer-exchange",o.LOCAL="local-peer-cache"})(Tags||(Tags={}));var EPeersByDiscoveryEvents;(function(o){o.PEER_DISCOVERY_BOOTSTRAP="peer:discovery:bootstrap",o.PEER_DISCOVERY_PEER_EXCHANGE="peer:discovery:peer-exchange",o.PEER_CONNECT_BOOTSTRAP="peer:connected:bootstrap",o.PEER_CONNECT_PEER_EXCHANGE="peer:connected:peer-exchange"})(EPeersByDiscoveryEvents||(EPeersByDiscoveryEvents={}));var EConnectionStateEvents;(function(o){o.CONNECTION_STATUS="waku:connection"})(EConnectionStateEvents||(EConnectionStateEvents={}));const DNS_DISCOVERY_TAG="@waku/bootstrap",DEFAULT_CLUSTER_ID=1,DefaultShardInfo={clusterId:DEFAULT_CLUSTER_ID,shards:[0,1,2,3,4,5,6,7,8]},DefaultNetworkConfig=DefaultShardInfo;var HealthStatus;(function(o){o.Unhealthy="Unhealthy",o.MinimallyHealthy="MinimallyHealthy",o.SufficientlyHealthy="SufficientlyHealthy"})(HealthStatus||(HealthStatus={}));function toString$8(o,et="utf8"){const tt=BASES[et];if(tt==null)throw new Error(`Unsupported encoding "${et}"`);return tt.encoder.encode(o).substring(1)}function hexToBytes$1(o){if(typeof o=="string"){const et=o.replace(/^0x/i,"");return fromString(et.toLowerCase(),"base16")}return o}function numberToBytes(o){const et=new ArrayBuffer(8),tt=new DataView(et);return typeof o=="number"?tt.setFloat64(0,o,!1):tt.setBigInt64(0,o,!1),new Uint8Array(et)}const bytesToHex$1=o=>toString$8(o,"base16"),bytesToUtf8=o=>toString$8(o,"utf8"),utf8ToBytes$1=o=>fromString(o,"utf8");function concat$2(o,et){const tt=o.reduce((ot,it)=>ot+it.length,0),nt=new Uint8Array(tt);let rt=0;for(const ot of o)nt.set(ot,rt),rt+=ot.length;return nt}function isStaticSharding(o){return"clusterId"in o&&"shards"in o&&!("contentTopics"in o)}function isAutoSharding(o){return"contentTopics"in o}function derivePubsubTopicsFromNetworkConfig(o){if(isStaticSharding(o)){if(o.shards.length===0)throw new Error("Invalid shards configuration: please provide at least one shard");return shardInfoToPubsubTopics(o)}else if(isAutoSharding(o)){if(o.contentTopics.length===0)throw new Error("Invalid content topics configuration: please provide at least one content topic");return o.contentTopics.map(et=>contentTopicToPubsubTopic(et,o.clusterId))}else throw new Error("Unknown shard config. Please use ShardInfo or ContentTopicInfo")}const singleShardInfoToPubsubTopic=o=>{if(o.shard===void 0)throw new Error("Invalid shard");return`/waku/2/rs/${o.clusterId??DEFAULT_CLUSTER_ID}/${o.shard}`},shardInfoToPubsubTopics=o=>{if("contentTopics"in o&&o.contentTopics)return Array.from(new Set(o.contentTopics.map(et=>contentTopicToPubsubTopic(et,o.clusterId))));if("shards"in o){if(o.shards===void 0)throw new Error("Invalid shard");return Array.from(new Set(o.shards.map(et=>`/waku/2/rs/${o.clusterId??DEFAULT_CLUSTER_ID}/${et}`)))}else{if("application"in o&&"version"in o)return[contentTopicToPubsubTopic(`/${o.application}/${o.version}/default/default`,o.clusterId)];throw new Error("Missing required configuration in shard parameters")}},pubsubTopicToSingleShardInfo=o=>{const et=o.split("/");if(et.length!=6||et[1]!=="waku"||et[2]!=="2"||et[3]!=="rs")throw new Error("Invalid pubsub topic");const tt=parseInt(et[4]),nt=parseInt(et[5]);if(isNaN(tt)||isNaN(nt))throw new Error("Invalid clusterId or shard");return{clusterId:tt,shard:nt}},pubsubTopicsToShardInfo=o=>{const et=new Set,tt=new Set;for(const ot of o){const{clusterId:it,shard:st}=pubsubTopicToSingleShardInfo(ot);et.add(`${it}:${st}`),tt.add(it)}if(et.size===0)throw new Error("No valid pubsub topics provided");if(tt.size>1)throw new Error("Pubsub topics from multiple cluster IDs are not supported");const nt=tt.values().next().value,rt=Array.from(et).map(ot=>parseInt(ot.split(":")[1]));return{clusterId:nt,shards:rt}};function ensurePubsubTopicIsConfigured(o,et){if(!et.includes(o))throw new Error(`Pubsub topic ${o} has not been configured on this instance. Configured topics are: ${et}. Please update your configuration by passing in the topic during Waku node instantiation.`)}function ensureValidContentTopic(o){const et=o.split("/");if(et.length<5||et.length>6)throw Error("Content topic format is invalid");let tt=0;if(et.length==6){if(tt=parseInt(et[1]),isNaN(tt))throw new Error("Invalid generation field in content topic");if(tt>0)throw new Error("Generation greater than 0 is not supported")}const nt=et.splice(-4);if(nt[0].length==0)throw new Error("Application field cannot be empty");if(nt[1].length==0)throw new Error("Version field cannot be empty");if(nt[2].length==0)throw new Error("Topic name field cannot be empty");if(nt[3].length==0)throw new Error("Encoding field cannot be empty");return{generation:tt,application:nt[0],version:nt[1],topicName:nt[2],encoding:nt[3]}}function contentTopicToShardIndex(o,et=8){const{application:tt,version:nt}=ensureValidContentTopic(o),rt=sha256$2(concat$2([utf8ToBytes$1(tt),utf8ToBytes$1(nt)])),ot=new DataView(rt.buffer.slice(-8));return Number(ot.getBigUint64(0,!1)%BigInt(et))}function contentTopicToPubsubTopic(o,et=DEFAULT_CLUSTER_ID,tt=8){if(!o)throw Error("Content topic must be specified");const nt=contentTopicToShardIndex(o,tt);return`/waku/2/rs/${et}/${nt}`}function determinePubsubTopic(o,et){return typeof et=="string"?et:(et==null?void 0:et.shard)!==void 0?singleShardInfoToPubsubTopic(et):contentTopicToPubsubTopic(o,(et==null?void 0:et.clusterId)??DEFAULT_CLUSTER_ID)}const decodeRelayShard=o=>{if(o=new Uint8Array(o),o.length<3)throw new Error("Insufficient data");const et=new DataView(o.buffer),tt=et.getUint16(0),nt=[];if(o.length===130)for(let rt=0;rt<1024;rt++){const ot=Math.floor(rt/8)+2,it=7-rt%8;et.getUint8(ot)&1<=o.length)throw new Error("Unexpected end of data");nt.push(et.getUint16(it))}}return{clusterId:tt,shards:nt}},encodeRelayShard=o=>{const{clusterId:et,shards:tt}=o,nt=tt.length>=64?130:3+2*tt.length,rt=new ArrayBuffer(nt),ot=new DataView(rt);if(ot.setUint16(0,et),tt.length>=64)for(const it of tt){const st=Math.floor(it/8)+2,at=7-it%8;ot.setUint8(st,ot.getUint8(st)|1<tt.toString().includes("ws")||tt.toString().includes("wss"));if(!et)throw new Error("No ws multiaddr found in the given addresses");return et}var browser={exports:{}},ms$1,hasRequiredMs;function requireMs(){if(hasRequiredMs)return ms$1;hasRequiredMs=1;var o=1e3,et=o*60,tt=et*60,nt=tt*24,rt=nt*7,ot=nt*365.25;ms$1=function(lt,dt){dt=dt||{};var ht=typeof lt;if(ht==="string"&<.length>0)return it(lt);if(ht==="number"&&isFinite(lt))return dt.long?at(lt):st(lt);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(lt))};function it(lt){if(lt=String(lt),!(lt.length>100)){var dt=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(lt);if(dt){var ht=parseFloat(dt[1]),pt=(dt[2]||"ms").toLowerCase();switch(pt){case"years":case"year":case"yrs":case"yr":case"y":return ht*ot;case"weeks":case"week":case"w":return ht*rt;case"days":case"day":case"d":return ht*nt;case"hours":case"hour":case"hrs":case"hr":case"h":return ht*tt;case"minutes":case"minute":case"mins":case"min":case"m":return ht*et;case"seconds":case"second":case"secs":case"sec":case"s":return ht*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return ht;default:return}}}}function st(lt){var dt=Math.abs(lt);return dt>=nt?Math.round(lt/nt)+"d":dt>=tt?Math.round(lt/tt)+"h":dt>=et?Math.round(lt/et)+"m":dt>=o?Math.round(lt/o)+"s":lt+"ms"}function at(lt){var dt=Math.abs(lt);return dt>=nt?ct(lt,dt,nt,"day"):dt>=tt?ct(lt,dt,tt,"hour"):dt>=et?ct(lt,dt,et,"minute"):dt>=o?ct(lt,dt,o,"second"):lt+" ms"}function ct(lt,dt,ht,pt){var mt=dt>=ht*1.5;return Math.round(lt/ht)+" "+pt+(mt?"s":"")}return ms$1}function setup$1(o){tt.debug=tt,tt.default=tt,tt.coerce=at,tt.disable=ot,tt.enable=rt,tt.enabled=it,tt.humanize=requireMs(),tt.destroy=ct,Object.keys(o).forEach(lt=>{tt[lt]=o[lt]}),tt.names=[],tt.skips=[],tt.formatters={};function et(lt){let dt=0;for(let ht=0;ht{if(wt==="%%")return"%";bt++;const It=tt.formatters[kt];if(typeof It=="function"){const Rt=yt[bt];wt=It.call(gt,Rt),yt.splice(bt,1),bt--}return wt}),tt.formatArgs.call(gt,yt),(gt.log||tt.log).apply(gt,yt)}return ft.namespace=lt,ft.useColors=tt.useColors(),ft.color=tt.selectColor(lt),ft.extend=nt,ft.destroy=tt.destroy,Object.defineProperty(ft,"enabled",{enumerable:!0,configurable:!1,get:()=>ht!==null?ht:(pt!==tt.namespaces&&(pt=tt.namespaces,mt=tt.enabled(lt)),mt),set:yt=>{ht=yt}}),typeof tt.init=="function"&&tt.init(ft),ft}function nt(lt,dt){const ht=tt(this.namespace+(typeof dt>"u"?":":dt)+lt);return ht.log=this.log,ht}function rt(lt){tt.save(lt),tt.namespaces=lt,tt.names=[],tt.skips=[];let dt;const ht=(typeof lt=="string"?lt:"").split(/[\s,]+/),pt=ht.length;for(dt=0;dt"-"+dt)].join(",");return tt.enable(""),lt}function it(lt){if(lt[lt.length-1]==="*")return!0;let dt,ht;for(dt=0,ht=tt.skips.length;dt{let lt=!1;return()=>{lt||(lt=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),et.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function rt(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let lt;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(lt=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(lt[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function ot(lt){if(lt[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+lt[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;const dt="color: "+this.color;lt.splice(1,0,dt,"color: inherit");let ht=0,pt=0;lt[0].replace(/%[a-zA-Z%]/g,mt=>{mt!=="%%"&&(ht++,mt==="%c"&&(pt=ht))}),lt.splice(pt,0,dt)}et.log=console.debug||console.log||(()=>{});function it(lt){try{lt?et.storage.setItem("debug",lt):et.storage.removeItem("debug")}catch{}}function st(){let lt;try{lt=et.storage.getItem("debug")}catch{}return!lt&&typeof tt<"u"&&"env"in tt&&(lt=nt.DEBUG),lt}function at(){try{return localStorage}catch{}}o.exports=common$1(et);const{formatters:ct}=o.exports;ct.j=function(lt){try{return JSON.stringify(lt)}catch(dt){return"[UnexpectedJSONParseError]: "+dt.message}}})(browser,browser.exports);var browserExports=browser.exports;const debug=getDefaultExportFromCjs(browserExports),APP_NAME="waku";let Logger$1=class Zo{constructor(et){Ct(this,"_info");Ct(this,"_warn");Ct(this,"_error");this._info=debug(Zo.createDebugNamespace("info",et)),this._warn=debug(Zo.createDebugNamespace("warn",et)),this._error=debug(Zo.createDebugNamespace("error",et))}static createDebugNamespace(et,tt){return tt?`${APP_NAME}:${et}:${tt}`:`${APP_NAME}:${et}`}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(et,...tt){const nt=this[et];nt(...tt)}};const log$o=new Logger$1("message:version-0"),OneMillion=BigInt(1e6),Version=0;class DecodedMessage{constructor(et,tt){Ct(this,"pubsubTopic");Ct(this,"proto");this.pubsubTopic=et,this.proto=tt}get ephemeral(){return!!this.proto.ephemeral}get payload(){return this.proto.payload}get contentTopic(){return this.proto.contentTopic}get _rawTimestamp(){return this.proto.timestamp}get timestamp(){try{if(this.proto.timestamp){const et=this.proto.timestamp/OneMillion;return new Date(Number(et))}return}catch{return}}get meta(){return this.proto.meta}get version(){return this.proto.version??0}get rateLimitProof(){return this.proto.rateLimitProof}}let Encoder$1=class{constructor(et,tt=!1,nt,rt){Ct(this,"contentTopic");Ct(this,"ephemeral");Ct(this,"pubsubTopic");Ct(this,"metaSetter");if(this.contentTopic=et,this.ephemeral=tt,this.pubsubTopic=nt,this.metaSetter=rt,!et||et==="")throw new Error("Content topic must be specified")}async toWire(et){return WakuMessage$4.encode(await this.toProtoObj(et))}async toProtoObj(et){const tt=et.timestamp??new Date,nt={payload:et.payload,version:Version,contentTopic:this.contentTopic,timestamp:BigInt(tt.valueOf())*OneMillion,meta:void 0,rateLimitProof:et.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const rt=this.metaSetter(nt);return{...nt,meta:rt}}return nt}};function createEncoder({pubsubTopic:o,pubsubTopicShardInfo:et,contentTopic:tt,ephemeral:nt,metaSetter:rt}){return new Encoder$1(tt,nt,determinePubsubTopic(tt,o??et),rt)}let Decoder$1=class{constructor(et,tt){Ct(this,"pubsubTopic");Ct(this,"contentTopic");if(this.pubsubTopic=et,this.contentTopic=tt,!tt||tt==="")throw new Error("Content topic must be specified")}fromWireToProtoObj(et){const tt=WakuMessage$4.decode(et);return Promise.resolve({payload:tt.payload,contentTopic:tt.contentTopic,version:tt.version??void 0,timestamp:tt.timestamp??void 0,meta:tt.meta??void 0,rateLimitProof:tt.rateLimitProof??void 0,ephemeral:tt.ephemeral??!1})}async fromProtoObj(et,tt){return tt.version??Version!==0?(log$o.error("Failed to decode due to incorrect version, expected:",Version,", actual:",tt.version),Promise.resolve(void 0)):new DecodedMessage(et,tt)}};function createDecoder(o,et){return new Decoder$1(determinePubsubTopic(o,et),o)}function isAsyncIterable$8(o){return o[Symbol.asyncIterator]!=null}function all$2(o){if(isAsyncIterable$8(o))return(async()=>{const tt=[];for await(const nt of o)tt.push(nt);return tt})();const et=[];for(const tt of o)et.push(tt);return et}function asUint8Array(o){return o}function concat$1(o,et){et==null&&(et=o.reduce((rt,ot)=>rt+ot.length,0));const tt=allocUnsafe(et);let nt=0;for(const rt of o)tt.set(rt,nt),nt+=rt.length;return tt}function equals(o,et){if(o===et)return!0;if(o.byteLength!==et.byteLength)return!1;for(let tt=0;tt0&&this.appendAll(et)}*[(Ys=symbol$1,Symbol.iterator)](){yield*this.bufs}get byteLength(){return this.length}append(...et){this.appendAll(et)}appendAll(et){let tt=0;for(const nt of et)if(nt instanceof Uint8Array)tt+=nt.byteLength,this.bufs.push(nt);else if(isUint8ArrayList(nt))tt+=nt.byteLength,this.bufs.push(...nt.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}prepend(...et){this.prependAll(et)}prependAll(et){let tt=0;for(const nt of et.reverse())if(nt instanceof Uint8Array)tt+=nt.byteLength,this.bufs.unshift(nt);else if(isUint8ArrayList(nt))tt+=nt.byteLength,this.bufs.unshift(...nt.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=tt}get(et){const tt=findBufAndOffset(this.bufs,et);return tt.buf[tt.index]}set(et,tt){const nt=findBufAndOffset(this.bufs,et);nt.buf[nt.index]=tt}write(et,tt=0){if(et instanceof Uint8Array)for(let nt=0;nt0;)if(et>=this.bufs[0].byteLength)et-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(et),this.length-=et;break}}}slice(et,tt){const{bufs:nt,length:rt}=this._subList(et,tt);return concat$1(nt,rt)}subarray(et,tt){const{bufs:nt,length:rt}=this._subList(et,tt);return nt.length===1?nt[0]:concat$1(nt,rt)}sublist(et,tt){const{bufs:nt,length:rt}=this._subList(et,tt),ot=new Uint8ArrayList;return ot.length=rt,ot.bufs=[...nt],ot}_subList(et,tt){if(et=et??0,tt=tt??this.length,et<0&&(et=this.length+et),tt<0&&(tt=this.length+tt),et<0||tt>this.length)throw new RangeError("index is out of bounds");if(et===tt)return{bufs:[],length:0};if(et===0&&tt===this.length)return{bufs:this.bufs,length:this.length};const nt=[];let rt=0;for(let ot=0;ot=at)continue;const ct=et>=st&&etst&&tt<=at;if(ct&<){if(et===st&&tt===at){nt.push(it);break}const dt=et-st;nt.push(it.subarray(dt,dt+(tt-et)));break}if(ct){if(et===0){nt.push(it);continue}nt.push(it.subarray(et-st));continue}if(lt){if(tt===at){nt.push(it);break}nt.push(it.subarray(0,tt-st));break}nt.push(it)}return{bufs:nt,length:tt-et}}indexOf(et,tt=0){if(!isUint8ArrayList(et)&&!(et instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const nt=et instanceof Uint8Array?et:et.subarray();if(tt=Number(tt??0),isNaN(tt)&&(tt=0),tt<0&&(tt=this.length+tt),tt<0&&(tt=0),et.length===0)return tt>this.length?this.length:tt;const rt=nt.byteLength;if(rt===0)throw new TypeError("search must be at least 1 byte long");const ot=256,it=new Int32Array(ot);for(let dt=0;dt=0;ht--){const pt=this.get(dt+ht);if(nt[ht]!==pt){lt=Math.max(1,ht-st[pt]);break}}if(lt===0)return dt}return-1}getInt8(et){const tt=this.subarray(et,et+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getInt8(0)}setInt8(et,tt){const nt=allocUnsafe(1);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setInt8(0,tt),this.write(nt,et)}getInt16(et,tt){const nt=this.subarray(et,et+2);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getInt16(0,tt)}setInt16(et,tt,nt){const rt=alloc$2(2);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setInt16(0,tt,nt),this.write(rt,et)}getInt32(et,tt){const nt=this.subarray(et,et+4);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getInt32(0,tt)}setInt32(et,tt,nt){const rt=alloc$2(4);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setInt32(0,tt,nt),this.write(rt,et)}getBigInt64(et,tt){const nt=this.subarray(et,et+8);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getBigInt64(0,tt)}setBigInt64(et,tt,nt){const rt=alloc$2(8);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setBigInt64(0,tt,nt),this.write(rt,et)}getUint8(et){const tt=this.subarray(et,et+1);return new DataView(tt.buffer,tt.byteOffset,tt.byteLength).getUint8(0)}setUint8(et,tt){const nt=allocUnsafe(1);new DataView(nt.buffer,nt.byteOffset,nt.byteLength).setUint8(0,tt),this.write(nt,et)}getUint16(et,tt){const nt=this.subarray(et,et+2);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getUint16(0,tt)}setUint16(et,tt,nt){const rt=alloc$2(2);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setUint16(0,tt,nt),this.write(rt,et)}getUint32(et,tt){const nt=this.subarray(et,et+4);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getUint32(0,tt)}setUint32(et,tt,nt){const rt=alloc$2(4);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setUint32(0,tt,nt),this.write(rt,et)}getBigUint64(et,tt){const nt=this.subarray(et,et+8);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getBigUint64(0,tt)}setBigUint64(et,tt,nt){const rt=alloc$2(8);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setBigUint64(0,tt,nt),this.write(rt,et)}getFloat32(et,tt){const nt=this.subarray(et,et+4);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getFloat32(0,tt)}setFloat32(et,tt,nt){const rt=alloc$2(4);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setFloat32(0,tt,nt),this.write(rt,et)}getFloat64(et,tt){const nt=this.subarray(et,et+8);return new DataView(nt.buffer,nt.byteOffset,nt.byteLength).getFloat64(0,tt)}setFloat64(et,tt,nt){const rt=alloc$2(8);new DataView(rt.buffer,rt.byteOffset,rt.byteLength).setFloat64(0,tt,nt),this.write(rt,et)}equals(et){if(et==null||!(et instanceof Uint8ArrayList)||et.bufs.length!==this.bufs.length)return!1;for(let tt=0;ttrt+ot.byteLength,0)),nt.length=tt,nt}}function isAsyncIterable$7(o){return o[Symbol.asyncIterator]!=null}const defaultEncoder=o=>{const et=encodingLength$3(o),tt=allocUnsafe(et);return encode$a(o,tt),defaultEncoder.bytes=et,tt};defaultEncoder.bytes=0;function encode$5(o,et){et=et??{};const tt=et.lengthEncoder??defaultEncoder;function*nt(rt){const ot=tt(rt.byteLength);ot instanceof Uint8Array?yield ot:yield*ot,rt instanceof Uint8Array?yield rt:yield*rt}return isAsyncIterable$7(o)?async function*(){for await(const rt of o)yield*nt(rt)}():function*(){for(const rt of o)yield*nt(rt)}()}encode$5.single=(o,et)=>{et=et??{};const tt=et.lengthEncoder??defaultEncoder;return new Uint8ArrayList(tt(o.byteLength),o)};let InvalidMessageLengthError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","InvalidMessageLengthError");Ct(this,"code","ERR_INVALID_MSG_LENGTH")}},InvalidDataLengthError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","InvalidDataLengthError");Ct(this,"code","ERR_MSG_DATA_TOO_LONG")}},InvalidDataLengthLengthError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","InvalidDataLengthLengthError");Ct(this,"code","ERR_MSG_LENGTH_TOO_LONG")}},UnexpectedEOFError$1=class extends Error{constructor(){super(...arguments);Ct(this,"name","UnexpectedEOFError");Ct(this,"code","ERR_UNEXPECTED_EOF")}};const MAX_LENGTH_LENGTH=8,MAX_DATA_LENGTH=1024*1024*4;var ReadMode;(function(o){o[o.LENGTH=0]="LENGTH",o[o.DATA=1]="DATA"})(ReadMode||(ReadMode={}));const defaultDecoder=o=>{const et=decode$b(o);return defaultDecoder.bytes=encodingLength$3(et),et};defaultDecoder.bytes=0;function decode$5(o,et){const tt=new Uint8ArrayList;let nt=ReadMode.LENGTH,rt=-1;const ot=(et==null?void 0:et.lengthDecoder)??defaultDecoder,it=(et==null?void 0:et.maxLengthLength)??MAX_LENGTH_LENGTH,st=(et==null?void 0:et.maxDataLength)??MAX_DATA_LENGTH;function*at(){for(;tt.byteLength>0;){if(nt===ReadMode.LENGTH)try{if(rt=ot(tt),rt<0)throw new InvalidMessageLengthError$1("Invalid message length");if(rt>st)throw new InvalidDataLengthError$1("Message length too long");const ct=ot.bytes;tt.consume(ct),(et==null?void 0:et.onLength)!=null&&et.onLength(rt),nt=ReadMode.DATA}catch(ct){if(ct instanceof RangeError){if(tt.byteLength>it)throw new InvalidDataLengthLengthError$1("Message length length too long");break}throw ct}if(nt===ReadMode.DATA){if(tt.byteLength0)throw new UnexpectedEOFError$1("Unexpected end of input")}():function*(){for(const ct of o)tt.append(ct),yield*at();if(tt.byteLength>0)throw new UnexpectedEOFError$1("Unexpected end of input")}()}decode$5.fromReader=(o,et)=>{let tt=1;const nt=async function*(){for(;;)try{const{done:ot,value:it}=await o.next(tt);if(ot===!0)return;it!=null&&(yield it)}catch(ot){if(ot.code==="ERR_UNDER_READ")return{done:!0,value:null};throw ot}finally{tt=1}}();return decode$5(nt,{...et??{},onLength:ot=>{tt=ot}})};function pDefer(){const o={};return o.promise=new Promise((et,tt)=>{o.resolve=et,o.reject=tt}),o}class FixedFIFO{constructor(et){Ct(this,"buffer");Ct(this,"mask");Ct(this,"top");Ct(this,"btm");Ct(this,"next");if(!(et>0)||et-1&et)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(et),this.mask=et-1,this.top=0,this.btm=0,this.next=null}push(et){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=et,this.top=this.top+1&this.mask,!0)}shift(){const et=this.buffer[this.btm];if(et!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,et}isEmpty(){return this.buffer[this.btm]===void 0}}class FIFO{constructor(et={}){Ct(this,"size");Ct(this,"hwm");Ct(this,"head");Ct(this,"tail");this.hwm=et.splitLimit??16,this.head=new FixedFIFO(this.hwm),this.tail=this.head,this.size=0}calculateSize(et){return(et==null?void 0:et.byteLength)!=null?et.byteLength:1}push(et){if((et==null?void 0:et.value)!=null&&(this.size+=this.calculateSize(et.value)),!this.head.push(et)){const tt=this.head;this.head=tt.next=new FixedFIFO(2*this.head.buffer.length),this.head.push(et)}}shift(){let et=this.tail.shift();if(et===void 0&&this.tail.next!=null){const tt=this.tail.next;this.tail.next=null,this.tail=tt,et=this.tail.shift()}return(et==null?void 0:et.value)!=null&&(this.size-=this.calculateSize(et.value)),et}isEmpty(){return this.head.isEmpty()}}let AbortError$a=class extends Error{constructor(tt,nt){super(tt??"The operation was aborted");Ct(this,"type");Ct(this,"code");this.type="aborted",this.code=nt??"ABORT_ERR"}};function pushable(o={}){return _pushable(tt=>{const nt=tt.shift();if(nt==null)return{done:!0};if(nt.error!=null)throw nt.error;return{done:nt.done===!0,value:nt.value}},o)}function _pushable(o,et){et=et??{};let tt=et.onEnd,nt=new FIFO,rt,ot,it,st=pDefer();const at=async()=>{try{return nt.isEmpty()?it?{done:!0}:await new Promise((yt,gt)=>{ot=xt=>{ot=null,nt.push(xt);try{yt(o(nt))}catch(vt){gt(vt)}return rt}}):o(nt)}finally{nt.isEmpty()&&queueMicrotask(()=>{st.resolve(),st=pDefer()})}},ct=yt=>ot!=null?ot(yt):(nt.push(yt),rt),lt=yt=>(nt=new FIFO,ot!=null?ot({error:yt}):(nt.push({error:yt}),rt)),dt=yt=>{if(it)return rt;if((et==null?void 0:et.objectMode)!==!0&&(yt==null?void 0:yt.byteLength)==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return ct({done:!1,value:yt})},ht=yt=>it?rt:(it=!0,yt!=null?lt(yt):ct({done:!0})),pt=()=>(nt=new FIFO,ht(),{done:!0}),mt=yt=>(ht(yt),{done:!0});if(rt={[Symbol.asyncIterator](){return this},next:at,return:pt,throw:mt,push:dt,end:ht,get readableLength(){return nt.size},onEmpty:async yt=>{const gt=yt==null?void 0:yt.signal;if(gt==null||gt.throwIfAborted(),nt.isEmpty())return;let xt,vt;gt!=null&&(xt=new Promise((bt,Et)=>{vt=()=>{Et(new AbortError$a)},gt.addEventListener("abort",vt)}));try{await Promise.race([st.promise,xt])}finally{vt!=null&>!=null&&(gt==null||gt.removeEventListener("abort",vt))}}},tt==null)return rt;const ft=rt;return rt={[Symbol.asyncIterator](){return this},next(){return ft.next()},throw(yt){return ft.throw(yt),tt!=null&&(tt(yt),tt=void 0),{done:!0}},return(){return ft.return(),tt!=null&&(tt(),tt=void 0),{done:!0}},push:dt,end(yt){return ft.end(yt),tt!=null&&(tt(yt),tt=void 0),rt},get readableLength(){return ft.readableLength},onEmpty:yt=>ft.onEmpty(yt)},rt}function isAsyncIterable$6(o){return o[Symbol.asyncIterator]!=null}function merge$2(...o){const et=[];for(const tt of o)isAsyncIterable$6(tt)||et.push(tt);return et.length===o.length?function*(){for(const tt of et)yield*tt}():async function*(){const tt=pushable({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(o.map(async nt=>{for await(const rt of nt)tt.push(rt)})),tt.end()}catch(nt){tt.end(nt)}}),yield*tt}()}function pipe(o,...et){if(o==null)throw new Error("Empty pipeline");if(isDuplex(o)){const nt=o;o=()=>nt.source}else if(isIterable(o)||isAsyncIterable$5(o)){const nt=o;o=()=>nt}const tt=[o,...et];if(tt.length>1&&isDuplex(tt[tt.length-1])&&(tt[tt.length-1]=tt[tt.length-1].sink),tt.length>2)for(let nt=1;nt{let et;for(;o.length>0;)et=o.shift()(et);return et},isAsyncIterable$5=o=>(o==null?void 0:o[Symbol.asyncIterator])!=null,isIterable=o=>(o==null?void 0:o[Symbol.iterator])!=null,isDuplex=o=>o==null?!1:o.sink!=null&&o.source!=null,duplexPipelineFn=o=>et=>{const tt=o.sink(et);if((tt==null?void 0:tt.then)!=null){const nt=pushable({objectMode:!0});tt.then(()=>{nt.end()},it=>{nt.end(it)});let rt;const ot=o.source;if(isAsyncIterable$5(ot))rt=async function*(){yield*ot,nt.end()};else if(isIterable(ot))rt=function*(){yield*ot,nt.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return merge$2(nt,rt())}return o.source};async function sortPeersByLatency(o,et){return et.length===0?[]:(await Promise.all(et.map(async rt=>{try{const ot=(await o.get(rt.id)).metadata.get("ping");if(!ot)return{peer:rt,ping:1/0};const it=Number(bytesToUtf8(ot));return{peer:rt,ping:it}}catch{return{peer:rt,ping:1/0}}}))).filter(rt=>rt!==null).sort((rt,ot)=>rt.ping-ot.ping).map(rt=>rt.peer)}async function getPeersForProtocol(o,et){const tt=[];return await o.forEach(nt=>{for(let rt=0;rtit.tags.has(Tags.BOOTSTRAP)).slice(0,tt);et>0&&et!it.tags.has(Tags.BOOTSTRAP));if(et===0)return[...nt,...rt];const ot=[...nt];for(;ot.length0;){const it=Math.floor(Math.random()*rt.length),st=rt.splice(it,1)[0];ot.push(st)}return ot}function selectOpenConnection(o){return o.filter(et=>et.status==="open").sort((et,tt)=>tt.timeline.open-et.timeline.open).at(0)}const STREAM_LOCK_KEY="consumed";class StreamManager{constructor(et,tt,nt){Ct(this,"multicodec");Ct(this,"getConnections");Ct(this,"addEventListener");Ct(this,"log");Ct(this,"ongoingCreation",new Set);Ct(this,"streamPool",new Map);Ct(this,"handlePeerUpdateStreamPool",et=>{const{peer:tt}=et.detail;!tt.protocols.includes(this.multicodec)||this.getOpenStreamForCodec(tt.id)||this.scheduleNewStream(tt)});this.multicodec=et,this.getConnections=tt,this.addEventListener=nt,this.log=new Logger$1(`stream-manager:${et}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool)}async getStream(et){const tt=et.id.toString(),nt=this.streamPool.get(tt);nt&&(this.streamPool.delete(tt),await nt);let rt=this.getOpenStreamForCodec(et.id);return rt?(this.log.info(`Found existing stream peerId=${et.id.toString()} multicodec=${this.multicodec}`),this.lockStream(et.id.toString(),rt),rt):(rt=await this.createStream(et),this.lockStream(et.id.toString(),rt),rt)}async createStream(et,tt=0){const nt=this.getConnections(et.id),rt=selectOpenConnection(nt);if(!rt)throw new Error(`Failed to get a connection to the peer peerId=${et.id.toString()} multicodec=${this.multicodec}`);let ot,it;for(let st=0;stit.protocol===this.multicodec);if(!(!rt||["done","closed","closing"].includes(rt.writeStatus||"")||this.isStreamLocked(rt)))return rt}lockStream(et,tt){this.log.info(`Locking stream for peerId:${et} streamId:${tt.id}`),tt.metadata[STREAM_LOCK_KEY]=!0}isStreamLocked(et){return!!et.metadata[STREAM_LOCK_KEY]}}class BaseProtocol{constructor(et,tt,nt,rt){Ct(this,"multicodec");Ct(this,"components");Ct(this,"log");Ct(this,"pubsubTopics");Ct(this,"addLibp2pEventListener");Ct(this,"removeLibp2pEventListener");Ct(this,"streamManager");this.multicodec=et,this.components=tt,this.log=nt,this.pubsubTopics=rt,this.addLibp2pEventListener=tt.events.addEventListener.bind(tt.events),this.removeLibp2pEventListener=tt.events.removeEventListener.bind(tt.events),this.streamManager=new StreamManager(et,tt.connectionManager.getConnections.bind(tt.connectionManager),this.addLibp2pEventListener)}async getStream(et){return this.streamManager.getStream(et)}async allPeers(){return getPeersForProtocol(this.components.peerStore,[this.multicodec])}async connectedPeers(){return(await this.allPeers()).filter(tt=>this.components.connectionManager.getConnections(tt.id).length>0)}async getPeers({numPeers:et,maxBootstrapPeers:tt,peerIdStr:nt}={maxBootstrapPeers:0,numPeers:0}){if(nt){const st=(await this.connectedPeers()).find(at=>at.id.toString()===nt);return st?[st]:(this.log.warn(`Passed node to use for ${this.multicodec} not found: ${nt}. Attempting to use random peers.`),this.getPeers({numPeers:et,maxBootstrapPeers:tt}))}const rt=await this.connectedPeers(),ot=filterPeersByDiscovery(rt,et,tt),it=await sortPeersByLatency(this.components.peerStore,ot);return it.length===0&&this.log.warn("No peers found. Ensure you have a connection to the network."),it.length{log$n.error("Failed to register ",FilterCodecs.PUSH,ot)})}async subscribe(tt,nt,rt){const ot=await this.getStream(nt),it=FilterSubscribeRpc.createSubscribeRequest(tt,rt);let st;try{st=await pipe([it.encode()],encode$5,ot,decode$5,async dt=>await all$2(dt))}catch(dt){return log$n.error("Failed to send subscribe request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:nt.id}}}const{statusCode:at,requestId:ct,statusDesc:lt}=FilterSubscribeResponse.decode(st[0].slice());return at<200||at>=300?(log$n.error(`Filter subscribe request ${ct} failed with status code ${at}: ${lt}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:nt.id},success:null}):{failure:null,success:nt.id}}async unsubscribe(tt,nt,rt){let ot;try{ot=await this.getStream(nt)}catch(st){return log$n.error(`Failed to get a stream for remote peer${nt.id.toString()}`,st),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:nt.id}}}const it=FilterSubscribeRpc.createUnsubscribeRequest(tt,rt);try{await pipe([it.encode()],encode$5,ot.sink)}catch(st){return log$n.error("Failed to send unsubscribe request",st),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:nt.id}}}return{success:nt.id,failure:null}}async unsubscribeAll(tt,nt){const rt=await this.getStream(nt),ot=FilterSubscribeRpc.createUnsubscribeAllRequest(tt),it=await pipe([ot.encode()],encode$5,rt,decode$5,async lt=>await all$2(lt));if(!it||!it.length)return{failure:{error:ProtocolError$1.NO_RESPONSE,peerId:nt.id},success:null};const{statusCode:st,requestId:at,statusDesc:ct}=FilterSubscribeResponse.decode(it[0].slice());return st<200||st>=300?(log$n.error(`Filter unsubscribe all request ${at} failed with status code ${st}: ${ct}`),{failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:nt.id},success:null}):{failure:null,success:nt.id}}async ping(tt){let nt;try{nt=await this.getStream(tt)}catch(ct){return log$n.error(`Failed to get a stream for remote peer${tt.id.toString()}`,ct),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:tt.id}}}const rt=FilterSubscribeRpc.createSubscriberPingRequest();let ot;try{ot=await pipe([rt.encode()],encode$5,nt,decode$5,async ct=>await all$2(ct))}catch(ct){return log$n.error("Failed to send ping request",ct),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:tt.id}}}if(!ot||!ot.length)return{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:tt.id}};const{statusCode:it,requestId:st,statusDesc:at}=FilterSubscribeResponse.decode(ot[0].slice());return it<200||it>=300?(log$n.error(`Filter ping request ${st} failed with status code ${it}: ${at}`),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:tt.id}}):{success:tt.id,failure:null}}onRequest(tt){const{connection:nt,stream:rt}=tt,{remotePeer:ot}=nt;log$n.info(`Received message from ${ot.toString()}`);try{pipe(rt,decode$5,async it=>{for await(const st of it){const at=FilterPushRpc.decode(st.slice()),{pubsubTopic:ct,wakuMessage:lt}=at;if(!lt){log$n.error("Received empty message");return}if(!ct){log$n.error("Pubsub topic missing from push message");return}await this.handleIncomingMessage(ct,lt,nt.remotePeer.toString())}}).then(()=>{log$n.info("Receiving pipe closed.")},async it=>{log$n.error(`Error with receiving pipe on peer:${nt.remotePeer.toString()} -- stream:${rt.id} -- protocol:${rt.protocol}: `,it)})}catch(it){log$n.error("Error decoding message",it)}}}class PushRpc{constructor(et){Ct(this,"proto");this.proto=et}static createRequest(et,tt){return new PushRpc({requestId:v4$2(),request:{message:et,pubsubTopic:tt},response:void 0})}static decode(et){const tt=PushRpc$1.decode(et);return new PushRpc(tt)}encode(){return PushRpc$1.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const RLN_GENERATION_PREFIX_ERROR="could not generate rln-v2 proof",isRLNResponseError=o=>o?o.includes(RLN_GENERATION_PREFIX_ERROR):!1,matchRLNErrorMessage=o=>{const et={[ProtocolError$1.RLN_IDENTITY_MISSING]:ProtocolError$1.RLN_IDENTITY_MISSING,[ProtocolError$1.RLN_MEMBERSHIP_INDEX]:ProtocolError$1.RLN_MEMBERSHIP_INDEX,[ProtocolError$1.RLN_LIMIT_MISSING]:ProtocolError$1.RLN_LIMIT_MISSING},tt=o.toLowerCase();for(const nt in et)if(tt.includes(nt.toLowerCase()))return et[nt];return ProtocolError$1.RLN_PROOF_GENERATION},log$m=new Logger$1("light-push"),LightPushCodec="/vac/waku/lightpush/2.0.0-beta1";class LightPushCore extends BaseProtocol{constructor(tt,nt){super(LightPushCodec,nt.components,log$m,tt);Ct(this,"pubsubTopics");this.pubsubTopics=tt}async preparePushMessage(tt,nt){try{if(!nt.payload||nt.payload.length===0)return log$m.error("Failed to send waku light push: payload is empty"),{query:null,error:ProtocolError$1.EMPTY_PAYLOAD};if(!await isMessageSizeUnderCap(tt,nt))return log$m.error("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:ProtocolError$1.SIZE_TOO_BIG};const rt=await tt.toProtoObj(nt);return rt?{query:PushRpc.createRequest(rt,tt.pubsubTopic),error:null}:(log$m.error("Failed to encode to protoMessage, aborting push"),{query:null,error:ProtocolError$1.ENCODE_FAILED})}catch(rt){return log$m.error("Failed to prepare push message",rt),{query:null,error:ProtocolError$1.GENERIC_FAIL}}}async send(tt,nt,rt){const{query:ot,error:it}=await this.preparePushMessage(tt,nt);if(it||!ot)return{success:null,failure:{error:it,peerId:rt.id}};let st;try{st=await this.getStream(rt)}catch(dt){return log$m.error("Failed to get stream",dt),{success:null,failure:{error:ProtocolError$1.NO_STREAM_AVAILABLE,peerId:rt.id}}}let at;try{at=await pipe([ot.encode()],encode$5,st,decode$5,async dt=>await all$2(dt))}catch(dt){return log$m.error("Failed to send waku light push request",dt),{success:null,failure:{error:ProtocolError$1.GENERIC_FAIL,peerId:rt.id}}}const ct=new Uint8ArrayList;at.forEach(dt=>{ct.append(dt)});let lt;try{lt=PushRpc.decode(ct).response}catch(dt){return log$m.error("Failed to decode push reply",dt),{success:null,failure:{error:ProtocolError$1.DECODE_FAILED,peerId:rt.id}}}if(!lt)return log$m.error("Remote peer fault: No response in PushRPC"),{success:null,failure:{error:ProtocolError$1.NO_RESPONSE,peerId:rt.id}};if(isRLNResponseError(lt.info)){const dt=matchRLNErrorMessage(lt.info);return log$m.error("Remote peer rejected the message: ",dt),{success:null,failure:{error:dt,peerId:rt.id}}}return lt.isSuccess?{success:rt.id,failure:null}:(log$m.error("Remote peer rejected the message: ",lt.info),{success:null,failure:{error:ProtocolError$1.REMOTE_PEER_REJECTED,peerId:rt.id}})}}const EmptyMessage={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};function toProtoMessage(o){return{...EmptyMessage,...o}}const DEFAULT_PAGE_SIZE=20,MAX_PAGE_SIZE=100,ONE_MILLION=1e6;class StoreQueryRequest{constructor(et){Ct(this,"proto");this.proto=et}static create(et){const tt=new StoreQueryRequest({...et,requestId:v4$2(),timeStart:et.timeStart?BigInt(et.timeStart.getTime()*ONE_MILLION):void 0,timeEnd:et.timeEnd?BigInt(et.timeEnd.getTime()*ONE_MILLION):void 0,messageHashes:et.messageHashes||[],paginationLimit:et.paginationLimit?BigInt(et.paginationLimit):void 0});if(et.pubsubTopic&&!et.contentTopics||!et.pubsubTopic&&et.contentTopics)throw new Error("Both pubsubTopic and contentTopics must be set or unset");if(et.messageHashes&&(et.pubsubTopic||et.contentTopics||et.timeStart||et.timeEnd))throw new Error("Message hash lookup queries cannot include content filter criteria");return tt}static decode(et){const tt=StoreQueryRequest$1.decode(et);return new StoreQueryRequest(tt)}encode(){return StoreQueryRequest$1.encode(this.proto)}}class StoreQueryResponse{constructor(et){Ct(this,"proto");this.proto=et}static decode(et){const tt=StoreQueryResponse$1.decode(et);return new StoreQueryResponse(tt)}encode(){return StoreQueryResponse$1.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get messages(){return this.proto.messages}get paginationCursor(){return this.proto.paginationCursor}}const log$l=new Logger$1("store"),StoreCodec="/vac/waku/store-query/3.0.0";class StoreCore extends BaseProtocol{constructor(tt,nt){super(StoreCodec,nt.components,log$l,tt);Ct(this,"pubsubTopics");this.pubsubTopics=tt}async*queryPerPage(tt,nt,rt){if(tt.contentTopics.toString()!==Array.from(nt.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let ot=tt.paginationCursor;for(;;){const it=StoreQueryRequest.create({...tt,paginationCursor:ot});let st;try{st=await this.getStream(rt)}catch(ht){log$l.error("Failed to get stream",ht);break}const at=await pipe([it.encode()],encode$5,st,decode$5,async ht=>await all$2(ht)),ct=new Uint8ArrayList;at.forEach(ht=>{ct.append(ht)});const lt=StoreQueryResponse.decode(ct);if(!lt.statusCode||lt.statusCode>=300){const ht=`Store query failed with status code: ${lt.statusCode}, description: ${lt.statusDesc}`;throw log$l.error(ht),new Error(ht)}if(!lt.messages||!lt.messages.length){log$l.warn("Stopping pagination due to empty messages in response");break}if(log$l.info(`${lt.messages.length} messages retrieved from store`),yield lt.messages.map(ht=>{if(!ht.message)return Promise.resolve(void 0);const pt=ht.message.contentTopic;if(pt){const mt=nt.get(pt);if(mt)return mt.fromProtoObj(ht.pubsubTopic||"",toProtoMessage(ht.message))}return Promise.resolve(void 0)}),tt.paginationForward?ot=lt.messages[lt.messages.length-1].messageHash:ot=lt.messages[0].messageHash,lt.messages.length>MAX_PAGE_SIZE&<.messages.length<(tt.paginationLimit||DEFAULT_PAGE_SIZE))break}}}const peerDiscoverySymbol$2=Symbol.for("@libp2p/peer-discovery"),peerIdSymbol$3=Symbol.for("@libp2p/peer-id");function isPeerId$2(o){return!!(o!=null&&o[peerIdSymbol$3])}var ss;let AbortError$9=(ss=class extends Error{constructor(et="The operation was aborted"){super(et),this.name="AbortError"}},Ct(ss,"name","AbortError"),ss);class UnexpectedPeerError extends Error{constructor(et="Unexpected Peer"){super(et),this.name="UnexpectedPeerError"}}Ct(UnexpectedPeerError,"name","UnexpectedPeerError");var as;let InvalidMessageError$3=(as=class extends Error{constructor(et="Invalid message"){super(et),this.name="InvalidMessageError"}},Ct(as,"name","InvalidMessageError"),as);class ProtocolError extends Error{constructor(et="Protocol error"){super(et),this.name="ProtocolError"}}Ct(ProtocolError,"name","ProtocolError");var cs;let TimeoutError$3=(cs=class extends Error{constructor(et="Timed out"){super(et),this.name="TimeoutError"}},Ct(cs,"name","TimeoutError"),cs);function setMaxListeners$9(){}const setMaxListeners$8=(o,...et)=>{try{[...et]}catch{}};var Qn,Zs;let TypedEventEmitter$3=(Zs=class extends EventTarget{constructor(){super();fn(this,Qn,new Map);setMaxListeners$8(1/0,this)}listenerCount(tt){const nt=Mt(this,Qn).get(tt);return nt==null?0:nt.length}addEventListener(tt,nt,rt){super.addEventListener(tt,nt,rt);let ot=Mt(this,Qn).get(tt);ot==null&&(ot=[],Mt(this,Qn).set(tt,ot)),ot.push({callback:nt,once:(rt!==!0&&rt!==!1&&(rt==null?void 0:rt.once))??!1})}removeEventListener(tt,nt,rt){super.removeEventListener(tt.toString(),nt??null,rt);let ot=Mt(this,Qn).get(tt);ot!=null&&(ot=ot.filter(({callback:it})=>it!==nt),Mt(this,Qn).set(tt,ot))}dispatchEvent(tt){const nt=super.dispatchEvent(tt);let rt=Mt(this,Qn).get(tt.type);return rt==null||(rt=rt.filter(({once:ot})=>!ot),Mt(this,Qn).set(tt.type,rt)),nt}safeDispatchEvent(tt,nt={}){return this.dispatchEvent(new CustomEvent(tt,nt))}},Qn=new WeakMap,Zs);const serviceCapabilities$5=Symbol.for("@libp2p/service-capabilities"),RelayPingContentTopic="/relay-ping/1/ping/null",log$k=new Logger$1("keep-alive");class KeepAliveManager{constructor({options:et,relay:tt,libp2p:nt}){Ct(this,"relay");Ct(this,"libp2p");Ct(this,"options");Ct(this,"pingKeepAliveTimers",new Map);Ct(this,"relayKeepAliveTimers",new Map);this.options=et,this.relay=tt,this.libp2p=nt}start(et){this.stop(et);const{pingKeepAlive:tt,relayKeepAlive:nt}=this.options,rt=et.toString();if(tt!==0){const it=setInterval(()=>{(async()=>{let st;try{try{st=await this.libp2p.services.ping.ping(et),log$k.info(`Ping succeeded (${rt})`,st)}catch{log$k.error(`Ping failed for peer (${rt}). Next ping will be attempted in ${tt} seconds. `);return}try{await this.libp2p.peerStore.merge(et,{metadata:{ping:utf8ToBytes$1(st.toString())}})}catch(at){log$k.error("Failed to update ping",at)}}catch(at){log$k.error(`Ping failed (${rt})`,at)}})()},tt*1e3);this.pingKeepAliveTimers.set(rt,it)}const ot=this.relay;if(ot&&nt!==0){const it=this.scheduleRelayPings(ot,nt,et.toString());this.relayKeepAliveTimers.set(et,it)}}stop(et){var nt;const tt=et.toString();this.pingKeepAliveTimers.has(tt)&&(clearInterval(this.pingKeepAliveTimers.get(tt)),this.pingKeepAliveTimers.delete(tt)),this.relayKeepAliveTimers.has(et)&&((nt=this.relayKeepAliveTimers.get(et))==null||nt.map(clearInterval),this.relayKeepAliveTimers.delete(et))}stopAll(){for(const et of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(et);this.pingKeepAliveTimers.clear(),this.relayKeepAliveTimers.clear()}connectionsExist(){return this.pingKeepAliveTimers.size>0||this.relayKeepAliveTimers.size>0}scheduleRelayPings(et,tt,nt){const rt=[];for(const ot of et.pubsubTopics){if(!et.getMeshPeers(ot).includes(nt))continue;const st=createEncoder({pubsubTopicShardInfo:pubsubTopicToSingleShardInfo(ot),contentTopic:RelayPingContentTopic,ephemeral:!0}),at=setInterval(()=>{log$k.info("Sending Waku Relay ping message"),et.send(st,{payload:new Uint8Array([1])}).catch(ct=>log$k.error("Failed to send relay ping",ct))},tt*1e3);rt.push(at)}return rt}}const log$j=new Logger$1("connection-manager"),DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED=1,DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER=3,DEFAULT_MAX_PARALLEL_DIALS=3,Pr=class Pr extends TypedEventEmitter$3{constructor(tt,nt,rt,ot,it){super();Ct(this,"configuredPubsubTopics");Ct(this,"keepAliveManager");Ct(this,"options");Ct(this,"libp2p");Ct(this,"dialAttemptsForPeer",new Map);Ct(this,"dialErrorsForPeer",new Map);Ct(this,"currentActiveParallelDialCount",0);Ct(this,"pendingPeerDialQueue",[]);Ct(this,"isP2PNetworkConnected",!1);Ct(this,"onEventHandlers",{"peer:discovery":tt=>{(async()=>{const{id:nt}=tt.detail;await this.dispatchDiscoveryEvent(nt);try{await this.attemptDial(nt)}catch(rt){log$j.error(`Error dialing peer ${nt.toString()} : ${rt}`)}})()},"peer:connect":tt=>{(async()=>{log$j.info(`Connected to peer ${tt.detail.toString()}`);const nt=tt.detail;this.keepAliveManager.start(nt),(await this.getTagNamesForPeer(nt)).includes(Tags.BOOTSTRAP)?this.libp2p.getConnections().filter(it=>it.tags.includes(Tags.BOOTSTRAP)).length>this.options.maxBootstrapPeersAllowed?await this.dropConnection(nt):this.dispatchEvent(new CustomEvent(EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP,{detail:nt})):this.dispatchEvent(new CustomEvent(EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE,{detail:nt})),this.setP2PNetworkConnected()})()},"peer:disconnect":tt=>{(async()=>(this.keepAliveManager.stop(tt.detail),this.setP2PNetworkDisconnected()))()},"browser:network":()=>{this.dispatchWakuConnectionEvent()}});this.configuredPubsubTopics=rt,this.libp2p=tt,this.configuredPubsubTopics=rt,this.options={maxDialAttemptsForPeer:DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,maxBootstrapPeersAllowed:DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,maxParallelDials:DEFAULT_MAX_PARALLEL_DIALS,...it},this.keepAliveManager=new KeepAliveManager({relay:ot,libp2p:tt,options:nt}),this.startEventListeners().then(()=>log$j.info("Connection Manager is now running")).catch(st=>log$j.error("Unexpected error while running service",st)),this.dialPeerStorePeers().catch(st=>log$j.error("Unexpected error while dialing peer store peers",st))}isConnected(){var tt;return globalThis!=null&&globalThis.navigator&&!((tt=globalThis==null?void 0:globalThis.navigator)!=null&&tt.onLine)?!1:this.isP2PNetworkConnected}static create(tt,nt,rt,ot,it,st){let at=Pr.instances.get(tt);return at||(at=new Pr(nt,rt,ot,it,st),Pr.instances.set(tt,at)),at}stop(){this.keepAliveManager.stopAll(),this.libp2p.removeEventListener("peer:connect",this.onEventHandlers["peer:connect"]),this.libp2p.removeEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"]),this.libp2p.removeEventListener("peer:discovery",this.onEventHandlers["peer:discovery"]),this.stopNetworkStatusListener()}async dropConnection(tt){try{this.keepAliveManager.stop(tt),await this.libp2p.hangUp(tt),log$j.info(`Dropped connection with peer ${tt.toString()}`)}catch(nt){log$j.error(`Error dropping connection with peer ${tt.toString()} - ${nt}`)}}async getPeersByDiscovery(){const tt=await this.libp2p.peerStore.all(),nt=this.libp2p.getConnections().map(lt=>lt.remotePeer),rt=[],ot=[],it=[],st=[],at=[],ct=[];for(const lt of tt){const dt=await this.getTagNamesForPeer(lt.id);dt.includes(Tags.BOOTSTRAP)?rt.push(lt):dt.includes(Tags.PEER_EXCHANGE)?ot.push(lt):dt.includes(Tags.LOCAL)&&it.push(lt)}for(const lt of nt){const dt=await this.libp2p.peerStore.get(lt),ht=await this.getTagNamesForPeer(lt);ht.includes(Tags.BOOTSTRAP)?st.push(dt):ht.includes(Tags.PEER_EXCHANGE)?at.push(dt):ht.includes(Tags.LOCAL)&&ct.push(dt)}return{DISCOVERED:{[Tags.BOOTSTRAP]:rt,[Tags.PEER_EXCHANGE]:ot,[Tags.LOCAL]:it},CONNECTED:{[Tags.BOOTSTRAP]:st,[Tags.PEER_EXCHANGE]:at,[Tags.LOCAL]:ct}}}async dialPeerStorePeers(){const tt=await this.libp2p.peerStore.all(),nt=[];for(const rt of tt)this.libp2p.getConnections().find(ot=>ot.remotePeer===rt.id)||nt.push(this.attemptDial(rt.id));try{await Promise.all(nt)}catch(rt){log$j.error("Unexpected error while dialing peer store peers",rt)}}async startEventListeners(){this.startPeerDiscoveryListener(),this.startPeerConnectionListener(),this.startPeerDisconnectionListener(),this.startNetworkStatusListener()}async dialPeer(tt){this.currentActiveParallelDialCount+=1;let nt=0;for(;nt{ot.tags=Array.from(new Set([...ot.tags,...rt]))}),this.dialAttemptsForPeer.set(tt.toString(),-1),this.keepAliveManager.start(tt);break}catch(rt){rt instanceof AggregateError?log$j.error(`Error dialing peer ${tt.toString()} - ${rt.errors}`):log$j.error(`Error dialing peer ${tt.toString()} - ${rt.message}`),this.dialErrorsForPeer.set(tt.toString(),rt),nt++,this.dialAttemptsForPeer.set(tt.toString(),nt)}if(this.currentActiveParallelDialCount--,this.processDialQueue(),nt===this.options.maxDialAttemptsForPeer)try{const rt=this.dialErrorsForPeer.get(tt.toString());if(rt){let ot;rt instanceof AggregateError?rt.errors?rt.errors.length===0?log$j.warn("Errors array is empty for AggregateError"):ot=JSON.stringify(rt.errors[0]):log$j.warn("No errors array found for AggregateError"):ot=rt.message,log$j.info(`Deleting undialable peer ${tt.toString()} from peer store. Reason: ${ot}`)}this.dialErrorsForPeer.delete(tt.toString()),await this.libp2p.peerStore.delete(tt),await this.attemptDnsDiscovery()}catch(rt){throw new Error(`Error deleting undialable peer ${tt.toString()} from peer store - ${rt}`)}}async attemptDnsDiscovery(){if(this.libp2p.getConnections().length>0||(await this.libp2p.peerStore.all()).length>0)return;log$j.info("Attempting to trigger DNS discovery.");const tt=Object.values(this.libp2p.components.components).find(nt=>nt&&nt.toString?nt.toString().includes(DNS_DISCOVERY_TAG):!1);tt&&await tt.findPeers()}processDialQueue(){if(this.pendingPeerDialQueue.length>0&&this.currentActiveParallelDialCount{log$j.error(nt)})}}startPeerDiscoveryListener(){this.libp2p.addEventListener("peer:discovery",this.onEventHandlers["peer:discovery"])}startPeerConnectionListener(){this.libp2p.addEventListener("peer:connect",this.onEventHandlers["peer:connect"])}startPeerDisconnectionListener(){this.libp2p.addEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"])}async attemptDial(tt){if(await this.shouldDialPeer(tt)){if(this.currentActiveParallelDialCount>=this.options.maxParallelDials){this.pendingPeerDialQueue.push(tt);return}await this.dialPeer(tt)}}async shouldDialPeer(tt){if(this.libp2p.getConnections(tt).length>0)return log$j.warn(`Already connected to peer ${tt.toString()}. Not dialing.`),!1;if(!await this.isPeerTopicConfigured(tt)){const st=await this.getPeerShardInfo(tt,this.libp2p.peerStore);return log$j.warn(`Discovered peer ${tt.toString()} with ShardInfo ${st} is not part of any of the configured pubsub topics (${this.configuredPubsubTopics}). - Not dialing.`),!1}return await this.isPeerDialableBasedOnBootstrapStatus(tt)?this.dialAttemptsForPeer.has(tt.toString())?(log$j.warn(`Peer ${tt.toString()} has already been attempted dial before, or already has a dial attempt in progress, skipping dial`),!1):!0:(log$j.warn(`Peer ${tt.toString()} is not dialable based on bootstrap status. Not dialing.`),!1)}async isPeerDialableBasedOnBootstrapStatus(tt){return(await this.getTagNamesForPeer(tt)).some(it=>it===Tags.BOOTSTRAP)?this.libp2p.getConnections().filter(it=>it.tags.find(st=>st===Tags.BOOTSTRAP)).lengththis.configuredPubsubTopics.includes(it)):!0}async getPeerShardInfo(tt,nt){const ot=(await nt.get(tt)).metadata.get("shardInfo");if(ot)return decodeRelayShard(ot)}startNetworkStatusListener(){try{globalThis.addEventListener("online",this.onEventHandlers["browser:network"]),globalThis.addEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to start network listener: ${tt}`)}}stopNetworkStatusListener(){try{globalThis.removeEventListener("online",this.onEventHandlers["browser:network"]),globalThis.removeEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to stop network listener: ${tt}`)}}setP2PNetworkConnected(){this.isP2PNetworkConnected||(this.isP2PNetworkConnected=!0,this.dispatchWakuConnectionEvent())}setP2PNetworkDisconnected(){this.isP2PNetworkConnected&&this.libp2p.getConnections().length===0&&(this.isP2PNetworkConnected=!1,this.dispatchWakuConnectionEvent())}dispatchWakuConnectionEvent(){this.dispatchEvent(new CustomEvent(EConnectionStateEvents.CONNECTION_STATUS,{detail:this.isConnected()}))}};Ct(Pr,"instances",new Map);let ConnectionManager=Pr;const wr=class wr{constructor(){Ct(this,"health");this.health={overallStatus:HealthStatus.Unhealthy,protocolStatuses:new Map}}static getInstance(){return wr.instance||(wr.instance=new wr),wr.instance}getHealthStatus(){return this.health.overallStatus}getProtocolStatus(et){return this.health.protocolStatuses.get(et)}updateProtocolHealth(et,tt){const nt=this.getNameFromMulticodec(et);let rt=HealthStatus.Unhealthy;tt==1?rt=HealthStatus.MinimallyHealthy:tt>=2&&(rt=HealthStatus.SufficientlyHealthy),this.health.protocolStatuses.set(nt,{name:nt,status:rt,lastUpdate:new Date}),this.updateOverallHealth()}getNameFromMulticodec(et){let tt;if(et.includes("filter"))tt=Protocols.Filter;else if(et.includes("lightpush"))tt=Protocols.LightPush;else if(et.includes("store"))tt=Protocols.Store;else throw new Error(`Unknown protocol: ${et}`);return tt}updateOverallHealth(){const tt=[Protocols.LightPush,Protocols.Filter].map(nt=>{var rt;return(rt=this.getProtocolStatus(nt))==null?void 0:rt.status});tt.some(nt=>nt===HealthStatus.Unhealthy)?this.health.overallStatus=HealthStatus.Unhealthy:tt.some(nt=>nt===HealthStatus.MinimallyHealthy)?this.health.overallStatus=HealthStatus.MinimallyHealthy:this.health.overallStatus=HealthStatus.SufficientlyHealthy}};Ct(wr,"instance");let HealthManager=wr;const getHealthManager=()=>HealthManager.getInstance(),log$i=new Logger$1("metadata"),MetadataCodec="/vac/waku/metadata/1.0.0";class Metadata extends BaseProtocol{constructor(tt,nt){super(MetadataCodec,nt.components,log$i,tt);Ct(this,"pubsubTopics");Ct(this,"libp2pComponents");Ct(this,"handshakesConfirmed",new Map);this.pubsubTopics=tt,this.libp2pComponents=nt,nt.registrar.handle(MetadataCodec,rt=>{this.onRequest(rt)})}async query(tt){const nt=WakuMetadataRequest.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),rt=await this.libp2pComponents.peerStore.get(tt);if(!rt)return{shardInfo:null,error:ProtocolError$1.NO_PEER_AVAILABLE};let ot;try{ot=await this.getStream(rt)}catch(ct){return log$i.error("Failed to get stream",ct),{shardInfo:null,error:ProtocolError$1.NO_STREAM_AVAILABLE}}const it=await pipe([nt],encode$5,ot,decode$5,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);return st?{shardInfo:null,error:st}:(await this.savePeerShardInfo(tt,at),{shardInfo:at,error:null})}async confirmOrAttemptHandshake(tt){const nt=this.handshakesConfirmed.get(tt.toString());return nt?{shardInfo:nt,error:null}:await this.query(tt)}async onRequest(tt){try{const{stream:nt,connection:rt}=tt,ot=WakuMetadataResponse.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),it=await pipe([ot],encode$5,nt,decode$5,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);if(st)return;await this.savePeerShardInfo(rt.remotePeer,at)}catch(nt){log$i.error("Error handling metadata request",nt)}}decodeMetadataResponse(tt){const nt=new Uint8ArrayList;tt.forEach(ot=>{nt.append(ot)});const rt=WakuMetadataResponse.decode(nt);return rt?{shardInfo:rt,error:null}:(log$i.error("Error decoding metadata response"),{shardInfo:null,error:ProtocolError$1.DECODE_FAILED})}async savePeerShardInfo(tt,nt){await this.libp2pComponents.peerStore.merge(tt,{metadata:{shardInfo:encodeRelayShard(nt)}}),this.handshakesConfirmed.set(tt.toString(),nt)}}function wakuMetadata(o){return et=>new Metadata(o,et)}class Parser{constructor(){Ct(this,"index",0);Ct(this,"input","")}new(et){return this.index=0,this.input=et,this}readAtomically(et){const tt=this.index,nt=et();return nt===void 0&&(this.index=tt),nt}parseWith(et){const tt=et();if(this.index===this.input.length)return tt}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(et){return this.readAtomically(()=>{const tt=this.readChar();if(tt===et)return tt})}readSeparator(et,tt,nt){return this.readAtomically(()=>{if(!(tt>0&&this.readGivenChar(et)===void 0))return nt()})}readNumber(et,tt,nt,rt){return this.readAtomically(()=>{let ot=0,it=0;const st=this.peekChar();if(st===void 0)return;const at=st==="0",ct=2**(8*rt)-1;for(;;){const lt=this.readAtomically(()=>{const dt=this.readChar();if(dt===void 0)return;const ht=Number.parseInt(dt,et);if(!Number.isNaN(ht))return ht});if(lt===void 0)break;if(ot*=et,ot+=lt,ot>ct||(it+=1,tt!==void 0&&it>tt))return}if(it!==0)return!nt&&at&&it>1?void 0:ot})}readIPv4Addr(){return this.readAtomically(()=>{const et=new Uint8Array(4);for(let tt=0;ttthis.readNumber(10,3,!1,1));if(nt===void 0)return;et[tt]=nt}return et})}readIPv6Addr(){const et=tt=>{for(let nt=0;ntthis.readIPv4Addr());if(it!==void 0)return tt[rt]=it[0],tt[rt+1]=it[1],tt[rt+2]=it[2],tt[rt+3]=it[3],[rt+4,!0]}const ot=this.readSeparator(":",nt,()=>this.readNumber(16,4,!0,2));if(ot===void 0)return[rt,!1];tt[rt]=ot>>8,tt[rt+1]=ot&255}return[tt.length,!1]};return this.readAtomically(()=>{const tt=new Uint8Array(16),[nt,rt]=et(tt);if(nt===16)return tt;if(rt||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;const ot=new Uint8Array(14),it=16-(nt+2),[st]=et(ot.subarray(0,it));return tt.set(ot.subarray(0,st),16-st),tt})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}}const MAX_IPV6_LENGTH=45,MAX_IPV4_LENGTH=15,parser=new Parser;function parseIPv4(o){if(!(o.length>MAX_IPV4_LENGTH))return parser.new(o).parseWith(()=>parser.readIPv4Addr())}function parseIPv6(o){if(o.includes("%")&&(o=o.split("%")[0]),!(o.length>MAX_IPV6_LENGTH))return parser.new(o).parseWith(()=>parser.readIPv6Addr())}function parseIP(o){if(o.includes("%")&&(o=o.split("%")[0]),!(o.length>MAX_IPV6_LENGTH))return parser.new(o).parseWith(()=>parser.readIPAddr())}function isIPv4(o){return!!parseIPv4(o)}function isIPv6(o){return!!parseIPv6(o)}function isIP(o){return!!parseIP(o)}const isV4=isIPv4,isV6=isIPv6,toBytes$1=function(o){let et=0;if(o=o.toString().trim(),isV4(o)){const tt=new Uint8Array(et+4);return o.split(/\./g).forEach(nt=>{tt[et++]=parseInt(nt,10)&255}),tt}if(isV6(o)){const tt=o.split(":",8);let nt;for(nt=0;nt0;nt--)ot.push("0");tt.splice.apply(tt,ot)}const rt=new Uint8Array(et+16);for(nt=0;nt>8&255,rt[et++]=ot&255}return rt}throw new Error("invalid ip address")},toString$7=function(o,et=0,tt){et=~~et,tt=tt??o.length-et;const nt=new DataView(o.buffer);if(tt===4){const rt=[];for(let ot=0;ot{const et=createProtocol(...o);codes[et.code]=et,names[et.name]=et});function createProtocol(o,et,tt,nt,rt){return{code:o,size:et,name:tt,resolvable:!!nt,path:!!rt}}function getProtocol(o){if(typeof o=="number"){if(codes[o]!=null)return codes[o];throw new Error(`no protocol with code: ${o}`)}else if(typeof o=="string"){if(names[o]!=null)return names[o];throw new Error(`no protocol with name: ${o}`)}throw new Error(`invalid protocol id type: ${typeof o}`)}getProtocol("ip4");getProtocol("ip6");getProtocol("ipcidr");function convertToString(o,et){switch(getProtocol(o).code){case 4:case 41:return bytes2ip(et);case 42:return bytes2str(et);case 6:case 273:case 33:case 132:return bytes2port(et).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bytes2str(et);case 421:return bytes2mh(et);case 444:return bytes2onion(et);case 445:return bytes2onion(et);case 466:return bytes2mb(et);case 481:return globalThis.encodeURIComponent(bytes2str(et));default:return toString$8(et,"base16")}}function convertToBytes(o,et){switch(getProtocol(o).code){case 4:return ip2bytes(et);case 41:return ip2bytes(et);case 42:return str2bytes(et);case 6:case 273:case 33:case 132:return port2bytes(parseInt(et,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return str2bytes(et);case 421:return mh2bytes(et);case 444:return onion2bytes(et);case 445:return onion32bytes(et);case 466:return mb2bytes(et);case 481:return str2bytes(globalThis.decodeURIComponent(et));default:return fromString(et,"base16")}}const decoders=Object.values(bases).map(o=>o.decoder),anybaseDecoder=function(){let o=decoders[0].or(decoders[1]);return decoders.slice(2).forEach(et=>o=o.or(et)),o}();function ip2bytes(o){if(!isIP(o))throw new Error("invalid ip address");return toBytes$1(o)}function bytes2ip(o){const et=toString$7(o,0,o.length);if(et==null)throw new Error("ipBuff is required");if(!isIP(et))throw new Error("invalid ip address");return et}function port2bytes(o){const et=new ArrayBuffer(2);return new DataView(et).setUint16(0,o),new Uint8Array(et)}function bytes2port(o){return new DataView(o.buffer).getUint16(o.byteOffset)}function str2bytes(o){const et=fromString(o),tt=Uint8Array.from(encode$a(et.length));return concat$1([tt,et],tt.length+et.length)}function bytes2str(o){const et=decode$b(o);if(o=o.slice(encodingLength$3(et)),o.length!==et)throw new Error("inconsistent lengths");return toString$8(o)}function mh2bytes(o){let et;o[0]==="Q"||o[0]==="1"?et=decode$6(base58btc.decode(`z${o}`)).bytes:et=CID.parse(o).multihash.bytes;const tt=Uint8Array.from(encode$a(et.length));return concat$1([tt,et],tt.length+et.length)}function mb2bytes(o){const et=anybaseDecoder.decode(o),tt=Uint8Array.from(encode$a(et.length));return concat$1([tt,et],tt.length+et.length)}function bytes2mb(o){const et=decode$b(o),tt=o.slice(encodingLength$3(et));if(tt.length!==et)throw new Error("inconsistent lengths");return"u"+toString$8(tt,"base64url")}function bytes2mh(o){const et=decode$b(o),tt=o.slice(encodingLength$3(et));if(tt.length!==et)throw new Error("inconsistent lengths");return toString$8(tt,"base58btc")}function onion2bytes(o){const et=o.split(":");if(et.length!==2)throw new Error(`failed to parse onion addr: ["'${et.join('", "')}'"]' does not contain a port number`);if(et[0].length!==16)throw new Error(`failed to parse onion addr: ${et[0]} not a Tor onion address.`);const tt=base32$2.decode("b"+et[0]),nt=parseInt(et[1],10);if(nt<1||nt>65536)throw new Error("Port number is not in range(1, 65536)");const rt=port2bytes(nt);return concat$1([tt,rt],tt.length+rt.length)}function onion32bytes(o){const et=o.split(":");if(et.length!==2)throw new Error(`failed to parse onion addr: ["'${et.join('", "')}'"]' does not contain a port number`);if(et[0].length!==56)throw new Error(`failed to parse onion addr: ${et[0]} not a Tor onion3 address.`);const tt=base32$2.decode(`b${et[0]}`),nt=parseInt(et[1],10);if(nt<1||nt>65536)throw new Error("Port number is not in range(1, 65536)");const rt=port2bytes(nt);return concat$1([tt,rt],tt.length+rt.length)}function bytes2onion(o){const et=o.slice(0,o.length-2),tt=o.slice(o.length-2),nt=toString$8(et,"base32"),rt=bytes2port(tt);return`${nt}:${rt}`}function stringToMultiaddrParts(o){o=cleanPath(o);const et=[],tt=[];let nt=null;const rt=o.split("/").slice(1);if(rt.length===1&&rt[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let ot=0;ot=rt.length)throw ParseError("invalid address: "+o);if(st.path===!0){nt=cleanPath(rt.slice(ot).join("/")),et.push([st.code,convertToBytes(st.code,nt)]),tt.push([st.code,nt]);break}const at=convertToBytes(st.code,rt[ot]);et.push([st.code,at]),tt.push([st.code,convertToString(st.code,at)])}return{string:stringTuplesToString(tt),bytes:tuplesToBytes(et),tuples:et,stringTuples:tt,path:nt}}function bytesToMultiaddrParts(o){const et=[],tt=[];let nt=null,rt=0;for(;rto.length)throw ParseError("Invalid address Uint8Array: "+toString$8(o,"base16"));et.push([ot,ct]);const lt=convertToString(ot,ct);if(tt.push([ot,lt]),st.path===!0){nt=lt;break}}return{bytes:Uint8Array.from(o),string:stringTuplesToString(tt),tuples:et,stringTuples:tt,path:nt}}function stringTuplesToString(o){const et=[];return o.map(tt=>{const nt=getProtocol(tt[0]);return et.push(nt.name),tt.length>1&&tt[1]!=null&&et.push(tt[1]),null}),cleanPath(et.join("/"))}function tuplesToBytes(o){return concat$1(o.map(et=>{const tt=getProtocol(et[0]);let nt=Uint8Array.from(encode$a(tt.code));return et.length>1&&et[1]!=null&&(nt=concat$1([nt,et[1]])),nt}))}function sizeForAddr(o,et){if(o.size>0)return o.size/8;if(o.size===0)return 0;{const tt=decode$b(et instanceof Uint8Array?et:Uint8Array.from(et));return tt+encodingLength$3(tt)}}function cleanPath(o){return"/"+o.trim().split("/").filter(et=>et).join("/")}function ParseError(o){return new Error("Error parsing address: "+o)}const inspect$1=Symbol.for("nodejs.util.inspect.custom"),symbol=Symbol.for("@multiformats/js-multiaddr/multiaddr"),DNS_CODES=[getProtocol("dns").code,getProtocol("dns4").code,getProtocol("dns6").code,getProtocol("dnsaddr").code];class NoAvailableResolverError extends Error{constructor(et="No available resolver"){super(et),this.name="NoAvailableResolverError"}}var Xs,Kr,xr,so,ao;const Lr=class Lr{constructor(et){Ct(this,"bytes");fn(this,Kr);fn(this,xr);fn(this,so);fn(this,ao);Ct(this,Xs,!0);et==null&&(et="");let tt;if(et instanceof Uint8Array)tt=bytesToMultiaddrParts(et);else if(typeof et=="string"){if(et.length>0&&et.charAt(0)!=="/")throw new Error(`multiaddr "${et}" must start with a "/"`);tt=stringToMultiaddrParts(et)}else if(isMultiaddr(et))tt=bytesToMultiaddrParts(et.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=tt.bytes,un(this,Kr,tt.string),un(this,xr,tt.tuples),un(this,so,tt.stringTuples),un(this,ao,tt.path)}toString(){return Mt(this,Kr)}toJSON(){return this.toString()}toOptions(){let et,tt,nt,rt,ot="";const it=getProtocol("tcp"),st=getProtocol("udp"),at=getProtocol("ip4"),ct=getProtocol("ip6"),lt=getProtocol("dns6"),dt=getProtocol("ip6zone");for(const[pt,mt]of this.stringTuples())pt===dt.code&&(ot=`%${mt??""}`),DNS_CODES.includes(pt)&&(tt=it.name,rt=443,nt=`${mt??""}${ot}`,et=pt===lt.code?6:4),(pt===it.code||pt===st.code)&&(tt=getProtocol(pt).name,rt=parseInt(mt??"")),(pt===at.code||pt===ct.code)&&(tt=getProtocol(pt).name,nt=`${mt??""}${ot}`,et=pt===ct.code?6:4);if(et==null||tt==null||nt==null||rt==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:et,host:nt,transport:tt,port:rt}}protos(){return Mt(this,xr).map(([et])=>Object.assign({},getProtocol(et)))}protoCodes(){return Mt(this,xr).map(([et])=>et)}protoNames(){return Mt(this,xr).map(([et])=>getProtocol(et).name)}tuples(){return Mt(this,xr)}stringTuples(){return Mt(this,so)}encapsulate(et){return et=new Lr(et),new Lr(this.toString()+et.toString())}decapsulate(et){const tt=et.toString(),nt=this.toString(),rt=nt.lastIndexOf(tt);if(rt<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${et.toString()}`);return new Lr(nt.slice(0,rt))}decapsulateCode(et){const tt=this.tuples();for(let nt=tt.length-1;nt>=0;nt--)if(tt[nt][0]===et)return new Lr(tuplesToBytes(tt.slice(0,nt)));return this}getPeerId(){try{let et=[];this.stringTuples().forEach(([nt,rt])=>{nt===names.p2p.code&&et.push([nt,rt]),nt===names["p2p-circuit"].code&&(et=[])});const tt=et.pop();if((tt==null?void 0:tt[1])!=null){const nt=tt[1];return nt[0]==="Q"||nt[0]==="1"?toString$8(base58btc.decode(`z${nt}`),"base58btc"):toString$8(CID.parse(nt).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return Mt(this,ao)}equals(et){return equals(this.bytes,et.bytes)}async resolve(et){const tt=this.protos().find(ot=>ot.resolvable);if(tt==null)return[this];const nt=resolvers$1.get(tt.name);if(nt==null)throw new NoAvailableResolverError(`no available resolver for ${tt.name}`);return(await nt(this,et)).map(ot=>multiaddr(ot))}nodeAddress(){const et=this.toOptions();if(et.transport!=="tcp"&&et.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${et.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:et.family,address:et.host,port:et.port}}isThinWaistAddress(et){const tt=(et??this).protos();return!(tt.length!==2||tt[0].code!==4&&tt[0].code!==41||tt[1].code!==6&&tt[1].code!==273)}[(Xs=symbol,inspect$1)](){return`Multiaddr(${Mt(this,Kr)})`}};Kr=new WeakMap,xr=new WeakMap,so=new WeakMap,ao=new WeakMap;let Multiaddr=Lr;const resolvers$1=new Map;function isMultiaddr(o){return!!(o!=null&&o[symbol])}function multiaddr(o){return new Multiaddr(o)}const E_CANCELED=new Error("request for lock canceled");var __awaiter$2=function(o,et,tt,nt){function rt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(nt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(nt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):rt(lt.value).then(st,at)}ct((nt=nt.apply(o,et||[])).next())})};class Semaphore{constructor(et,tt=E_CANCELED){this._value=et,this._cancelError=tt,this._queue=[],this._weightedWaiters=[]}acquire(et=1,tt=0){if(et<=0)throw new Error(`invalid weight ${et}: must be positive`);return new Promise((nt,rt)=>{const ot={resolve:nt,reject:rt,weight:et,priority:tt},it=findIndexFromEnd(this._queue,st=>tt<=st.priority);it===-1&&et<=this._value?this._dispatchItem(ot):this._queue.splice(it+1,0,ot)})}runExclusive(et){return __awaiter$2(this,arguments,void 0,function*(tt,nt=1,rt=0){const[ot,it]=yield this.acquire(nt,rt);try{return yield tt(ot)}finally{it()}})}waitForUnlock(et=1,tt=0){if(et<=0)throw new Error(`invalid weight ${et}: must be positive`);return this._couldLockImmediately(et,tt)?Promise.resolve():new Promise(nt=>{this._weightedWaiters[et-1]||(this._weightedWaiters[et-1]=[]),insertSorted(this._weightedWaiters[et-1],{resolve:nt,priority:tt})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(et){this._value=et,this._dispatchQueue()}release(et=1){if(et<=0)throw new Error(`invalid weight ${et}: must be positive`);this._value+=et,this._dispatchQueue()}cancel(){this._queue.forEach(et=>et.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(et){const tt=this._value;this._value-=et.weight,et.resolve([tt,this._newReleaser(et.weight)])}_newReleaser(et){let tt=!1;return()=>{tt||(tt=!0,this.release(et))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let et=this._value;et>0;et--){const tt=this._weightedWaiters[et-1];tt&&(tt.forEach(nt=>nt.resolve()),this._weightedWaiters[et-1]=[])}else{const et=this._queue[0].priority;for(let tt=this._value;tt>0;tt--){const nt=this._weightedWaiters[tt-1];if(!nt)continue;const rt=nt.findIndex(ot=>ot.priority<=et);(rt===-1?nt:nt.splice(0,rt)).forEach(ot=>ot.resolve())}}}_couldLockImmediately(et,tt){return(this._queue.length===0||this._queue[0].priorityet.priority<=nt.priority);o.splice(tt+1,0,et)}function findIndexFromEnd(o,et){for(let tt=o.length-1;tt>=0;tt--)if(et(o[tt]))return tt;return-1}var __awaiter$1=function(o,et,tt,nt){function rt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(nt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(nt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):rt(lt.value).then(st,at)}ct((nt=nt.apply(o,et||[])).next())})};class Mutex{constructor(et){this._semaphore=new Semaphore(1,et)}acquire(){return __awaiter$1(this,arguments,void 0,function*(et=0){const[,tt]=yield this._semaphore.acquire(1,et);return tt})}runExclusive(et,tt=0){return this._semaphore.runExclusive(()=>et(),1,tt)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(et=0){return this._semaphore.waitForUnlock(1,et)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class PeerManager{constructor(et,tt,nt){Ct(this,"connectionManager");Ct(this,"core");Ct(this,"log");Ct(this,"peers",new Map);Ct(this,"healthManager");Ct(this,"readMutex",new Mutex);Ct(this,"writeMutex",new Mutex);Ct(this,"writeLockHolder",null);this.connectionManager=et,this.core=tt,this.log=nt,this.healthManager=getHealthManager(),this.healthManager.updateProtocolHealth(this.core.multicodec,0)}getWriteLockHolder(){return this.writeLockHolder}getPeers(){return Array.from(this.peers.values())}async addPeer(et){return this.writeMutex.runExclusive(async()=>{this.writeLockHolder=`addPeer: ${et.id.toString()}`,await this.connectionManager.attemptDial(et.id),this.peers.set(et.id.toString(),et),this.log.info(`Added and dialed peer: ${et.id.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async removePeer(et){return this.writeMutex.runExclusive(()=>{this.writeLockHolder=`removePeer: ${et.toString()}`,this.peers.delete(et.toString()),this.log.info(`Removed peer: ${et.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async getPeerCount(){return this.readMutex.runExclusive(()=>this.peers.size)}async hasPeers(){return this.readMutex.runExclusive(()=>this.peers.size>0)}async removeExcessPeers(et){this.log.info(`Removing ${et} excess peer(s)`);const tt=Array.from(this.peers.values()).slice(0,et);for(const nt of tt)await this.removePeer(nt.id)}async findAndAddPeers(et){const tt=await this.findPeers(et);return tt.length===0?(this.log.warn("No additional peers found"),[]):this.addMultiplePeers(tt)}async findPeers(et){const tt=await this.core.getPeers();return this.readMutex.runExclusive(async()=>tt.filter(rt=>!this.peers.has(rt.id.toString())).slice(0,et))}async addMultiplePeers(et){const tt=[];for(const nt of et)await this.addPeer(nt),tt.push(nt);return tt}}const DEFAULT_NUM_PEERS_TO_USE=2,DEFAULT_MAINTAIN_PEERS_INTERVAL=3e4;class BaseProtocolSDK{constructor(et,tt,nt){Ct(this,"core");Ct(this,"connectionManager");Ct(this,"peerManager");Ct(this,"numPeersToUse");Ct(this,"maintainPeersIntervalId",null);Ct(this,"log");this.core=et,this.connectionManager=tt,this.log=new Logger$1(`sdk:${et.multicodec}`),this.numPeersToUse=(nt==null?void 0:nt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE;const rt=(nt==null?void 0:nt.maintainPeersInterval)??DEFAULT_MAINTAIN_PEERS_INTERVAL;this.peerManager=new PeerManager(tt,et,this.log),this.log.info(`Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${rt}ms`),this.startMaintainPeersInterval(rt)}get connectedPeers(){return this.peerManager.getPeers().slice(0,this.numPeersToUse)}async renewPeer(et){this.log.info(`Attempting to renew peer ${et}`);const tt=await this.peerManager.findPeers(1);if(tt.length===0){this.log.error("Failed to find a new peer to replace the disconnected one");return}return await this.peerManager.removePeer(et),await this.peerManager.addPeer(tt[0]),this.log.info(`Successfully renewed peer. New peer: ${tt[0].id}`),tt[0]}stopMaintainPeersInterval(){this.maintainPeersIntervalId?(clearInterval(this.maintainPeersIntervalId),this.maintainPeersIntervalId=null,this.log.info("Maintain peers interval stopped")):this.log.info("Maintain peers interval was not running")}async hasPeers(et={}){const{forceUseAllPeers:tt=!1,maxAttempts:nt=3}=et;this.log.info(`Checking for peers. forceUseAllPeers: ${tt}, maxAttempts: ${nt}`);for(let rt=0;rt0)return this.log.info(`At least one peer connected (${this.connectedPeers.length}), not forcing use of all peers`),!0;if(this.connectedPeers.length>=this.numPeersToUse)return this.log.info(`Required number of peers (${this.numPeersToUse}) reached`),!0;this.log.warn(`Found only ${this.connectedPeers.length}/${this.numPeersToUse} required peers. Retrying...`)}return this.log.error(`Failed to find required number of peers (${this.numPeersToUse}) after ${nt} attempts`),!1}async startMaintainPeersInterval(et){this.log.info(`Starting maintain peers interval with ${et}ms interval`);try{this.maintainPeersIntervalId=setInterval(()=>{this.log.info("Running scheduled peer maintenance"),this.maintainPeers().catch(tt=>{this.log.error("Error during scheduled peer maintenance:",tt)})},et),this.log.info("Maintain peers interval started successfully")}catch(tt){throw this.log.error("Error starting maintain peers interval:",tt),tt}}async maintainPeers(){try{const et=await this.peerManager.getPeerCount(),tt=this.numPeersToUse-et;if(this.log.info(`Current peer count: ${et}, target: ${this.numPeersToUse}`),tt===0){this.log.info("Peer count is at target, no maintenance required");return}tt>0?(this.log.info(`Attempting to add ${tt} peer(s)`),await this.peerManager.findAndAddPeers(tt)):(this.log.info(`Attempting to remove ${Math.abs(tt)} excess peer(s)`),await this.peerManager.removeExcessPeers(Math.abs(tt)));const nt=await this.peerManager.getPeerCount();this.log.info(`Peer maintenance completed. Initial count: ${et}, Final count: ${nt}`)}catch(et){this.log.error("Error during peer maintenance",{error:et})}}}const DEFAULT_KEEP_ALIVE=6e4,DEFAULT_LIGHT_PUSH_FILTER_CHECK=!1,DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL=1e4,DEFAULT_SUBSCRIBE_OPTIONS={keepAlive:DEFAULT_KEEP_ALIVE,enableLightPushFilterCheck:DEFAULT_LIGHT_PUSH_FILTER_CHECK};function messageHash(o,et){const tt=utf8ToBytes$1(o),nt=utf8ToBytes$1(et.contentTopic),rt=tryConvertTimestampToBytes(et.timestamp),ot=concat$2([tt,et.payload,nt,et.meta,rt].filter(isDefined));return sha256$2(ot)}function tryConvertTimestampToBytes(o){if(!o)return;let et;return typeof o=="bigint"?et=o:et=BigInt(o.valueOf())*1000000n,numberToBytes(et)}function messageHashStr(o,et){const tt=messageHash(o,et);return bytesToHex$1(tt)}const log$h=new Logger$1("sdk:receiver:reliability_monitor"),DEFAULT_MAX_PINGS=3,MESSAGE_VERIFICATION_DELAY=5e3;class ReceiverReliabilityMonitor{constructor(et,tt,nt,rt,ot,it,st){Ct(this,"pubsubTopic");Ct(this,"getPeers");Ct(this,"renewPeer");Ct(this,"getContentTopics");Ct(this,"protocolSubscribe");Ct(this,"addLibp2pEventListener");Ct(this,"sendLightPushMessage");Ct(this,"receivedMessagesFormPeer",new Set);Ct(this,"receivedMessages",new Set);Ct(this,"scheduledVerification",new Map);Ct(this,"verifiedPeers",new Set);Ct(this,"peerFailures",new Map);Ct(this,"maxPingFailures",DEFAULT_MAX_PINGS);Ct(this,"peerRenewalLocks",new Set);this.pubsubTopic=et,this.getPeers=tt,this.renewPeer=nt,this.getContentTopics=rt,this.protocolSubscribe=ot,this.addLibp2pEventListener=it,this.sendLightPushMessage=st,this.addLibp2pEventListener("peer:disconnect",at=>{const ct=at.detail;this.getPeers().some(lt=>lt.id.equals(ct))&&this.renewAndSubscribePeer(ct)})}setMaxPingFailures(et){et!==void 0&&(this.maxPingFailures=et)}async handlePingResult(et,tt){if(tt!=null&&tt.success){this.peerFailures.delete(et.toString());return}const nt=(this.peerFailures.get(et.toString())||0)+1;if(this.peerFailures.set(et.toString(),nt),nt>=this.maxPingFailures)try{log$h.info(`Attempting to renew ${et.toString()} due to ping failures.`),await this.renewAndSubscribePeer(et),this.peerFailures.delete(et.toString())}catch(rt){log$h.error(`Failed to renew peer ${et.toString()}: ${rt}.`)}}notifyMessageReceived(et,tt){const nt=this.buildMessageHash(tt);return this.verifiedPeers.add(et),this.receivedMessagesFormPeer.add(`${et}-${nt}`),log$h.info(`notifyMessage received debug: ephemeral:${tt.ephemeral} ${bytesToUtf8(tt.payload)}`),log$h.info(`notifyMessage received: peer:${et} message:${nt}`),this.receivedMessages.has(nt)?!0:(this.receivedMessages.add(nt),!1)}notifyMessageSent(et,tt){const nt=et.toString(),rt=this.buildMessageHash(tt);if(log$h.info(`notifyMessage sent debug: ${bytesToUtf8(tt.payload)}`),this.scheduledVerification.has(nt)){log$h.warn(`notifyMessage sent: attempting to schedule verification for pending peer:${nt} message:${rt}`);return}const ot=setTimeout(async()=>{const it=this.verifiedPeers.has(nt),st=this.receivedMessagesFormPeer.has(`${nt}-${rt}`);if(it||st){log$h.info(`notifyMessage sent setTimeout: verified that peer pushes filter messages, peer:${nt} message:${rt}`);return}log$h.warn(`notifyMessage sent setTimeout: peer didn't return probe message, attempting renewAndSubscribe, peer:${nt} message:${rt}`),this.scheduledVerification.delete(nt),await this.renewAndSubscribePeer(et)},MESSAGE_VERIFICATION_DELAY);this.scheduledVerification.set(nt,ot)}shouldVerifyPeer(et){const tt=et.toString(),nt=this.verifiedPeers.has(tt),rt=this.scheduledVerification.has(tt);return!(nt||rt)}buildMessageHash(et){return messageHashStr(this.pubsubTopic,et)}async renewAndSubscribePeer(et){const tt=et.toString();try{if(this.peerRenewalLocks.has(tt)){log$h.info(`Peer ${tt} is already being renewed.`);return}this.peerRenewalLocks.add(tt);const nt=await this.renewPeer(et);if(!nt){log$h.warn(`Failed to renew peer ${tt}: No new peer found.`);return}return await this.protocolSubscribe(this.pubsubTopic,nt,this.getContentTopics()),await this.sendLightPushMessage(nt),this.peerFailures.delete(tt),nt}catch(nt){log$h.error(`Failed to renew peer ${tt}: ${nt}.`);return}finally{this.peerRenewalLocks.delete(tt)}}}const Nr=class Nr{static createReceiverMonitor(et,tt,nt,rt,ot,it,st){if(Nr.receiverMonitors.has(et))return Nr.receiverMonitors.get(et);const at=new ReceiverReliabilityMonitor(et,tt,nt,rt,ot,it,st);return Nr.receiverMonitors.set(et,at),at}constructor(){}static stop(et){this.receiverMonitors.delete(et)}static stopAll(){for(const[et,tt]of this.receiverMonitors)tt.setMaxPingFailures(void 0),this.receiverMonitors.delete(et)}};Ct(Nr,"receiverMonitors",new Map);let ReliabilityMonitorManager=Nr;const log$g=new Logger$1("sdk:filter:subscription_manager");class SubscriptionManager{constructor(et,tt,nt,rt,ot,it,st){Ct(this,"pubsubTopic");Ct(this,"protocol");Ct(this,"connectionManager");Ct(this,"getPeers");Ct(this,"renewPeer");Ct(this,"libp2p");Ct(this,"lightPush");Ct(this,"reliabilityMonitor");Ct(this,"keepAliveTimeout",DEFAULT_KEEP_ALIVE);Ct(this,"keepAliveInterval",null);Ct(this,"enableLightPushFilterCheck",DEFAULT_LIGHT_PUSH_FILTER_CHECK);Ct(this,"subscriptionCallbacks");this.pubsubTopic=et,this.protocol=tt,this.connectionManager=nt,this.getPeers=rt,this.renewPeer=ot,this.libp2p=it,this.lightPush=st,this.pubsubTopic=et,this.subscriptionCallbacks=new Map,this.reliabilityMonitor=ReliabilityMonitorManager.createReceiverMonitor(this.pubsubTopic,this.getPeers.bind(this),this.renewPeer.bind(this),()=>Array.from(this.subscriptionCallbacks.keys()),this.protocol.subscribe.bind(this.protocol),this.protocol.addLibp2pEventListener.bind(this.protocol),this.sendLightPushCheckMessage.bind(this))}async subscribe(et,tt,nt=DEFAULT_SUBSCRIBE_OPTIONS){this.reliabilityMonitor.setMaxPingFailures(nt.pingsBeforePeerRenewed),this.keepAliveTimeout=nt.keepAlive||DEFAULT_KEEP_ALIVE,this.enableLightPushFilterCheck=(nt==null?void 0:nt.enableLightPushFilterCheck)||DEFAULT_LIGHT_PUSH_FILTER_CHECK;const rt=Array.isArray(et)?et:[et];for(const lt of rt)if(lt.pubsubTopic!==this.pubsubTopic)return{failures:[{error:ProtocolError$1.TOPIC_DECODER_MISMATCH}],successes:[]};this.enableLightPushFilterCheck&&rt.push(createDecoder(this.buildLightPushContentTopic(),this.pubsubTopic));const ot=groupByContentTopic(rt),it=Array.from(ot.keys()),st=this.getPeers().map(async lt=>this.subscribeWithPeerVerification(lt,it)),at=await Promise.allSettled(st),ct=this.handleResult(at,"subscribe");return ot.forEach((lt,dt)=>{const ht={decoders:lt,callback:tt};dt!==this.buildLightPushContentTopic()&&this.subscriptionCallbacks.set(dt,ht)}),this.startSubscriptionsMaintenance(this.keepAliveTimeout),ct}async unsubscribe(et){const tt=this.getPeers().map(async ot=>{const it=await this.protocol.unsubscribe(this.pubsubTopic,ot,et);return et.forEach(st=>{this.subscriptionCallbacks.delete(st)}),it}),nt=await Promise.allSettled(tt),rt=this.handleResult(nt,"unsubscribe");return this.subscriptionCallbacks.size===0&&this.stopSubscriptionsMaintenance(),rt}async ping(et){log$g.info("Sending keep-alive ping");const nt=(et?[et]:this.getPeers().map(ot=>ot.id)).map(ot=>this.pingSpecificPeer(ot)),rt=await Promise.allSettled(nt);return this.handleResult(rt,"ping")}async unsubscribeAll(){const et=this.getPeers().map(async rt=>this.protocol.unsubscribeAll(this.pubsubTopic,rt)),tt=await Promise.allSettled(et);this.subscriptionCallbacks.clear();const nt=this.handleResult(tt,"unsubscribeAll");return this.stopSubscriptionsMaintenance(),nt}async processIncomingMessage(et,tt){if(this.reliabilityMonitor.notifyMessageReceived(tt,et)){log$g.info("Message already received, skipping");return}const{contentTopic:rt}=et,ot=this.subscriptionCallbacks.get(rt);if(!ot){log$g.error("No subscription callback available for ",rt);return}log$g.info("Processing message with content topic ",rt," on pubsub topic ",this.pubsubTopic),await pushMessage(ot,this.pubsubTopic,et)}async subscribeWithPeerVerification(et,tt){const nt=await this.protocol.subscribe(this.pubsubTopic,et,tt);return await this.sendLightPushCheckMessage(et),nt}handleResult(et,tt){const nt={failures:[],successes:[]};for(const rt of et)if(rt.status==="rejected")log$g.error(`Failed to resolve ${tt} promise successfully: `,rt.reason),nt.failures.push({error:ProtocolError$1.GENERIC_FAIL});else{const ot=rt.value;ot.failure?nt.failures.push(ot.failure):nt.successes.push(ot.success)}return nt}async pingSpecificPeer(et){var rt,ot;const tt=this.getPeers().find(it=>it.id.equals(et));if(!tt)return{success:null,failure:{peerId:et,error:ProtocolError$1.NO_PEER_AVAILABLE}};let nt;try{nt=await this.protocol.ping(tt)}catch{nt={success:null,failure:{peerId:et,error:ProtocolError$1.GENERIC_FAIL}}}return log$g.info(`Received result from filter ping peerId:${et.toString()} success:${(rt=nt.success)==null?void 0:rt.toString()} failure:${(ot=nt.failure)==null?void 0:ot.error}`),await this.reliabilityMonitor.handlePingResult(et,nt),nt}startSubscriptionsMaintenance(et){log$g.info("Starting subscriptions maintenance"),this.startKeepAlivePings(et),this.startConnectionListener()}stopSubscriptionsMaintenance(){log$g.info("Stopping subscriptions maintenance"),this.stopKeepAlivePings(),this.stopConnectionListener()}startConnectionListener(){this.connectionManager.addEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}stopConnectionListener(){this.connectionManager.removeEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}async connectionListener({detail:et}){if(!et){this.stopKeepAlivePings();return}try{await this.ping()}catch(tt){log$g.error(`networkStateListener failed to recover: ${tt}`)}this.startKeepAlivePings(this.keepAliveTimeout)}startKeepAlivePings(et){if(this.keepAliveInterval){log$g.info("Recurring pings already set up.");return}this.keepAliveInterval=setInterval(()=>{this.ping()},et)}stopKeepAlivePings(){if(!this.keepAliveInterval){log$g.info("Already stopped recurring pings.");return}log$g.info("Stopping recurring pings."),clearInterval(this.keepAliveInterval),this.keepAliveInterval=null}async sendLightPushCheckMessage(et){if(this.lightPush&&this.libp2p&&this.reliabilityMonitor.shouldVerifyPeer(et.id)){const tt=createEncoder({contentTopic:this.buildLightPushContentTopic(),pubsubTopic:this.pubsubTopic,ephemeral:!0}),nt={payload:new Uint8Array(1)},rt=await tt.toProtoObj(nt);setTimeout(async()=>{const ot=await this.lightPush.protocol.send(tt,nt,et);if(this.reliabilityMonitor.notifyMessageSent(et.id,rt),ot.failure){log$g.error(`failed to send lightPush ping message to peer:${et.id.toString()} ${ot.failure.error}`);return}},DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL)}}buildLightPushContentTopic(){return`/js-waku-subscription-ping/1/${this.libp2p.peerId.toString()}/utf8`}}async function pushMessage(o,et,tt){const{decoders:nt,callback:rt}=o,{contentTopic:ot}=tt;if(!ot){log$g.warn("Message has no content topic, skipping");return}try{const it=nt.map(at=>at.fromProtoObj(et,tt).then(ct=>ct||Promise.reject("Decoding failed"))),st=await Promise.any(it);await rt(st)}catch(it){log$g.error("Error decoding message",it)}}const log$f=new Logger$1("sdk:filter");class Filter extends BaseProtocolSDK{constructor(tt,nt,rt,ot){super(new FilterCore(async(it,st,at)=>{const ct=this.getActiveSubscription(it);if(!ct){log$f.error(`No subscription locally registered for topic ${it}`);return}await ct.processIncomingMessage(st,at)},tt.configuredPubsubTopics,nt),tt,{numPeersToUse:ot==null?void 0:ot.numPeersToUse});Ct(this,"libp2p");Ct(this,"lightPush");Ct(this,"protocol");Ct(this,"activeSubscriptions",new Map);this.libp2p=nt,this.lightPush=rt,this.protocol=this.core,this.activeSubscriptions=new Map}async subscribe(tt,nt,rt,ot=DEFAULT_SUBSCRIBE_OPTIONS){const it=this.getUniquePubsubTopics(tt);if(it.length!==1)return{subscription:null,error:ProtocolError$1.INVALID_DECODER_TOPICS,results:null};const st=it[0],{subscription:at,error:ct}=await this.createSubscription(st,rt);if(ct)return{subscription:null,error:ct,results:null};const{failures:lt,successes:dt}=await at.subscribe(tt,nt,ot);return{subscription:at,error:null,results:{failures:lt,successes:dt}}}async createSubscription(tt,nt){var st;nt={autoRetry:!0,...nt};const rt=typeof tt=="string"?tt:(st=shardInfoToPubsubTopics(tt))==null?void 0:st[0];return ensurePubsubTopicIsConfigured(rt,this.protocol.pubsubTopics),await this.hasPeers(nt)?(log$f.info(`Creating filter subscription with ${this.connectedPeers.length} peers: `,this.connectedPeers.map(at=>at.id.toString())),{error:null,subscription:this.getActiveSubscription(rt)??this.setActiveSubscription(rt,new SubscriptionManager(rt,this.protocol,this.connectionManager,()=>this.connectedPeers,this.renewPeer.bind(this),this.libp2p,this.lightPush))}):{error:ProtocolError$1.NO_PEER_AVAILABLE,subscription:null}}async subscribeWithUnsubscribe(tt,nt,rt=DEFAULT_SUBSCRIBE_OPTIONS){const ot=this.getUniquePubsubTopics(tt);if(ot.length===0)throw Error("Failed to subscribe: no pubsubTopic found on decoders provided.");if(ot.length>1)throw Error("Failed to subscribe: all decoders should have the same pubsub topic. Use createSubscription to be more agile.");const{subscription:it,error:st}=await this.createSubscription(ot[0]);if(st)throw Error(`Failed to create subscription: ${st}`);await it.subscribe(tt,nt,rt);const at=Array.from(groupByContentTopic(Array.isArray(tt)?tt:[tt]).keys());return async()=>{await it.unsubscribe(at)}}toSubscriptionIterator(tt){return toAsyncIterator(this,tt)}getActiveSubscription(tt){return this.activeSubscriptions.get(tt)}setActiveSubscription(tt,nt){return this.activeSubscriptions.set(tt,nt),nt}getUniquePubsubTopics(tt){return Array.isArray(tt)?tt.length===0?[]:[...new Set(tt.map(rt=>rt.pubsubTopic))]:[tt.pubsubTopic]}}function wakuFilter(o,et,tt){return nt=>new Filter(o,nt,et,tt)}const log$e=new Logger$1("sdk:light-push"),DEFAULT_MAX_ATTEMPTS=3,DEFAULT_SEND_OPTIONS={autoRetry:!1,maxAttempts:DEFAULT_MAX_ATTEMPTS};class LightPush{constructor(et,tt,nt){Ct(this,"libp2p");Ct(this,"numPeersToUse",DEFAULT_NUM_PEERS_TO_USE);Ct(this,"protocol");this.libp2p=tt,this.numPeersToUse=(nt==null?void 0:nt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE,this.protocol=new LightPushCore(et.configuredPubsubTopics,tt)}async send(et,tt,nt=DEFAULT_SEND_OPTIONS){const rt=[],ot=[],{pubsubTopic:it}=et;try{ensurePubsubTopicIsConfigured(it,this.protocol.pubsubTopics)}catch{return log$e.error("Failed to send waku light push: pubsub topic not configured"),{successes:rt,failures:[{error:ProtocolError$1.TOPIC_NOT_CONFIGURED}]}}const st=await this.getConnectedPeers();if(st.length===0)return{successes:rt,failures:[{error:ProtocolError$1.NO_PEER_AVAILABLE}]};const at=await Promise.allSettled(st.map(ct=>this.protocol.send(et,tt,ct)));for(const ct of at){if(ct.status!=="fulfilled"){log$e.error("Failed unexpectedly while sending:",ct.reason),ot.push({error:ProtocolError$1.GENERIC_FAIL});continue}const{failure:lt,success:dt}=ct.value;if(dt){rt.push(dt);continue}lt&&(ot.push(lt),nt!=null&&nt.autoRetry&&this.attemptRetries(ht=>this.protocol.send(et,tt,ht),nt.maxAttempts))}return getHealthManager().updateProtocolHealth(this.protocol.multicodec,rt.length),{successes:rt,failures:ot}}async attemptRetries(et,tt){var rt;tt=tt||DEFAULT_MAX_ATTEMPTS;const nt=await this.getConnectedPeers();if(nt.length===0){log$e.warn("Cannot retry with no connected peers.");return}for(let ot=0;ot{try{return await this.libp2p.peerStore.get(nt)}catch{return null}}))).filter(nt=>!!nt).filter(nt=>nt.protocols.includes(LightPushCodec)).slice(0,this.numPeersToUse)}}function wakuLightPush(o,et={}){return tt=>new LightPush(o,tt,et)}const DEFAULT_NUM_PEERS=1,log$d=new Logger$1("waku:store:sdk");class Store extends BaseProtocolSDK{constructor(tt,nt){super(new StoreCore(tt.configuredPubsubTopics,nt),tt,{numPeersToUse:DEFAULT_NUM_PEERS});Ct(this,"protocol");this.protocol=this.core}async*queryGenerator(tt,nt){const{pubsubTopic:rt,contentTopics:ot,decodersAsMap:it}=this.validateDecodersAndPubsubTopic(tt),st={pubsubTopic:rt,contentTopics:ot,includeData:!0,paginationForward:!0,...nt},at=(await this.protocol.getPeers({numPeers:this.numPeersToUse,maxBootstrapPeers:1}))[0];if(!at)throw log$d.error("No peers available to query"),new Error("No peers available to query");log$d.info(`Querying store with options: ${JSON.stringify(nt)}`);const ct=this.protocol.queryPerPage(st,it,at);for await(const lt of ct)yield lt}async queryWithOrderedCallback(tt,nt,rt){log$d.info("Querying store with ordered callback");for await(const ot of this.queryGenerator(tt,rt))if(await this.processMessages(ot,nt))break}async queryWithPromiseCallback(tt,nt,rt){log$d.info("Querying store with promise callback");let ot=!1;for await(const it of this.queryGenerator(tt,rt)){const st=it.map(async at=>{ot||(ot=!!await nt(at))});if(await Promise.all(st),ot)break}}async processMessages(tt,nt){let rt=!1;const it=(await Promise.all(tt)).filter(isDefined);return await Promise.all(it.map(async st=>{st&&!rt&&(rt=!!await nt(st))})),rt}createCursor(tt){return messageHash(tt.pubsubTopic,tt)}validateDecodersAndPubsubTopic(tt){if(tt.length===0)throw log$d.error("No decoders provided"),new Error("No decoders provided");const nt=Array.from(new Set(tt.map(st=>st.pubsubTopic)));if(nt.length>1)throw log$d.error("API does not support querying multiple pubsub topics at once"),new Error("API does not support querying multiple pubsub topics at once");const rt=nt[0];ensurePubsubTopicIsConfigured(rt,this.protocol.pubsubTopics);const ot=new Map;tt.forEach(st=>{if(ot.has(st.contentTopic))throw log$d.error("API does not support different decoder per content topic"),new Error("API does not support different decoder per content topic");ot.set(st.contentTopic,st)});const it=tt.filter(st=>st.pubsubTopic===rt).map(st=>st.contentTopic);if(it.length===0)throw log$d.error(`No decoders found for topic ${rt}`),new Error("No decoders found for topic "+rt);return{pubsubTopic:rt,contentTopics:it,decodersAsMap:ot}}}function wakuStore(o){return et=>new Store(o,et)}const log$c=new Logger$1("wait-for-remote-peer");async function waitForRemotePeer(o,et,tt){et=et!=null&&et.length?et:getEnabledProtocols(o);const nt=o.libp2p.getConnections();if(!o.isStarted())throw Error("Waku node is not started");for(const ot of et)switch(ot){case Protocols.Relay:if(!o.relay)throw Error("Cannot wait for Relay peer: protocol not mounted");break;case Protocols.LightPush:if(!o.lightPush)throw Error("Cannot wait for LightPush peer: protocol not mounted");break;case Protocols.Store:if(!o.store)throw Error("Cannot wait for Store peer: protocol not mounted");break;case Protocols.Filter:if(!o.filter)throw Error("Cannot wait for Filter peer: protocol not mounted");break}const rt=[waitForProtocols(o,et)];nt.length>0&&!et.includes(Protocols.Relay)&&rt.push(waitForMetadata(o,et)),tt?await rejectOnTimeout(Promise.any(rt),tt,"Timed out waiting for a remote peer."):await Promise.any(rt)}async function waitForProtocols(o,et){const tt=[];return o.relay&&et.includes(Protocols.Relay)&&tt.push(o.relay.waitForPeers()),o.store&&et.includes(Protocols.Store)&&tt.push(waitForConnectedPeer(StoreCodec,o.libp2p)),o.lightPush&&et.includes(Protocols.LightPush)&&tt.push(waitForConnectedPeer(LightPushCodec,o.libp2p)),o.filter&&et.includes(Protocols.Filter)&&tt.push(waitForConnectedPeer(FilterCodecs.SUBSCRIBE,o.libp2p)),Promise.all(tt)}async function waitForConnectedPeer(o,et){log$c.info(`Waiting for ${o} peer.`),await new Promise(tt=>{const nt=async rt=>{var ot,it;if((it=(ot=rt.detail)==null?void 0:ot.protocols)!=null&&it.includes(o)){const st=et.services.metadata;if(!st){et.removeEventListener("peer:identify",nt),tt();return}try{await st.confirmOrAttemptHandshake(rt.detail.peerId),et.removeEventListener("peer:identify",nt),tt()}catch(at){at.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error waiting for metadata: ${at}`)}}};et.addEventListener("peer:identify",nt)})}async function waitForMetadata(o,et){const tt=o.libp2p.getPeers(),nt=o.libp2p.services.metadata,rt=mapProtocolsToCodecs(et);if(!tt.length||!nt){log$c.info(`Skipping waitForMetadata due to missing connections:${tt.length} or metadataService:${!!nt}`);return}for(const ot of tt)try{const it=await o.libp2p.peerStore.get(ot);if(it.protocols.some(at=>rt.has(at))&&!(await nt.confirmOrAttemptHandshake(ot)).error&&(it.protocols.forEach(lt=>{rt.has(lt)&&rt.set(lt,!0)}),Array.from(rt.values()).every(lt=>lt)))return}catch(it){it.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error while iterating through peers: ${it}`);continue}}const awaitTimeout=(o,et)=>new Promise((tt,nt)=>setTimeout(()=>nt(Error(et)),o));async function rejectOnTimeout(o,et,tt){await Promise.race([o,awaitTimeout(et,tt)])}function getEnabledProtocols(o){const et=[];return o.relay&&et.push(Protocols.Relay),o.filter&&et.push(Protocols.Filter),o.store&&et.push(Protocols.Store),o.lightPush&&et.push(Protocols.LightPush),et}function mapProtocolsToCodecs(o){const et=new Map,tt={[Protocols.Filter]:FilterCodecs.SUBSCRIBE,[Protocols.LightPush]:LightPushCodec,[Protocols.Store]:StoreCodec};for(const nt of o)tt[nt]&&et.set(tt[nt],!1);return et}const DefaultPingKeepAliveValueSecs=5*60,DefaultRelayKeepAliveValueSecs=5*60,DefaultUserAgent="js-waku",DefaultPingMaxInboundStreams=10,log$b=new Logger$1("waku");class WakuNode{constructor(et,tt,nt,rt,ot){Ct(this,"pubsubTopics");Ct(this,"libp2p");Ct(this,"relay");Ct(this,"store");Ct(this,"filter");Ct(this,"lightPush");Ct(this,"connectionManager");Ct(this,"health");this.pubsubTopics=et,this.relay=ot,this.libp2p=nt,rt={filter:!1,lightpush:!1,store:!1,...rt};const it=tt.pingKeepAlive||DefaultPingKeepAliveValueSecs,st=this.relay?tt.relayKeepAlive||DefaultRelayKeepAliveValueSecs:0,at=this.libp2p.peerId.toString();if(this.connectionManager=ConnectionManager.create(at,nt,{pingKeepAlive:it,relayKeepAlive:st},this.pubsubTopics,this.relay),this.health=getHealthManager(),rt.store){const ct=wakuStore(this.connectionManager);this.store=ct(nt)}if(rt.lightpush){const ct=wakuLightPush(this.connectionManager,tt);this.lightPush=ct(nt)}if(rt.filter){const ct=wakuFilter(this.connectionManager,this.lightPush,tt);this.filter=ct(nt)}log$b.info("Waku node created",at,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}get peerId(){return this.libp2p.peerId}get protocols(){return this.libp2p.getProtocols()}async dial(et,tt){const nt=tt??[],rt=this.mapToPeerIdOrMultiaddr(et);typeof tt>"u"&&(this.relay&&nt.push(Protocols.Relay),this.store&&nt.push(Protocols.Store),this.filter&&nt.push(Protocols.Filter),this.lightPush&&nt.push(Protocols.LightPush));const ot=[];return nt.includes(Protocols.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach(it=>ot.push(it)):log$b.error("Relay codec not included in dial codec: protocol not mounted locally")),nt.includes(Protocols.Store)&&(this.store?ot.push(this.store.protocol.multicodec):log$b.error("Store codec not included in dial codec: protocol not mounted locally")),nt.includes(Protocols.LightPush)&&(this.lightPush?ot.push(this.lightPush.protocol.multicodec):log$b.error("Light Push codec not included in dial codec: protocol not mounted locally")),nt.includes(Protocols.Filter)&&(this.filter?ot.push(this.filter.protocol.multicodec):log$b.error("Filter codec not included in dial codec: protocol not mounted locally")),log$b.info(`Dialing to ${rt.toString()} with protocols ${nt}`),this.libp2p.dialProtocol(rt,ot)}async start(){await this.libp2p.start()}async stop(){ReliabilityMonitorManager.stopAll(),this.connectionManager.stop(),await this.libp2p.stop()}async waitForPeers(et,tt){return waitForRemotePeer(this,et,tt)}isStarted(){return this.libp2p.status=="started"}isConnected(){return this.connectionManager.isConnected()}mapToPeerIdOrMultiaddr(et){return isPeerId$2(et)?et:multiaddr(et)}}var ls;let InvalidParametersError$3=(ls=class extends Error{constructor(et="Invalid parameters"){super(et),this.name="InvalidParametersError"}},Ct(ls,"name","InvalidParametersError"),ls);class InvalidPublicKeyError extends Error{constructor(et="Invalid public key"){super(et),this.name="InvalidPublicKeyError"}}Ct(InvalidPublicKeyError,"name","InvalidPublicKeyError");var us;let UnsupportedKeyTypeError$1=(us=class extends Error{constructor(et="Unsupported key type"){super(et),this.name="UnsupportedKeyTypeError"}},Ct(us,"name","UnsupportedKeyTypeError"),us);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$2=BigInt(2),_8n$2=BigInt(8),VERIFY_DEFAULT={zip215:!0};function validateOpts$1(o){const et=validateBasic(o);return validateObject(o,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...et})}function twistedEdwards(o){const et=validateOpts$1(o),{Fp:tt,n:nt,prehash:rt,hash:ot,randomBytes:it,nByteLength:st,h:at}=et,ct=_2n$2<{try{return{isValid:!0,value:tt.sqrt(Yt*tt.inv(Ht))}}catch{return{isValid:!1,value:_0n$2}}}),pt=et.adjustScalarBytes||(Yt=>Yt),mt=et.domain||((Yt,Ht,Ut)=>{if(abool("phflag",Ut),Ht.length||Ut)throw new Error("Contexts/pre-hash are not supported");return Yt});function ft(Yt,Ht){aInRange("coordinate "+Yt,Ht,_0n$2,ct)}function yt(Yt){if(!(Yt instanceof vt))throw new Error("ExtendedPoint expected")}const gt=memoized((Yt,Ht)=>{const{ex:Ut,ey:qt,ez:Lt}=Yt,Zt=Yt.is0();Ht==null&&(Ht=Zt?_8n$2:tt.inv(Lt));const Qt=lt(Ut*Ht),Nt=lt(qt*Ht),Gt=lt(Lt*Ht);if(Zt)return{x:_0n$2,y:_1n$3};if(Gt!==_1n$3)throw new Error("invZ was invalid");return{x:Qt,y:Nt}}),xt=memoized(Yt=>{const{a:Ht,d:Ut}=et;if(Yt.is0())throw new Error("bad point: ZERO");const{ex:qt,ey:Lt,ez:Zt,et:Qt}=Yt,Nt=lt(qt*qt),Gt=lt(Lt*Lt),nn=lt(Zt*Zt),Wt=lt(nn*nn),hn=lt(Nt*Ht),Xt=lt(nn*lt(hn+Gt)),Jt=lt(Wt+lt(Ut*lt(Nt*Gt)));if(Xt!==Jt)throw new Error("bad point: equation left != right (1)");const tn=lt(qt*Lt),_t=lt(Zt*Qt);if(tn!==_t)throw new Error("bad point: equation left != right (2)");return!0});class vt{constructor(Ht,Ut,qt,Lt){this.ex=Ht,this.ey=Ut,this.ez=qt,this.et=Lt,ft("x",Ht),ft("y",Ut),ft("z",qt),ft("t",Lt),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(Ht){if(Ht instanceof vt)throw new Error("extended point not allowed");const{x:Ut,y:qt}=Ht||{};return ft("x",Ut),ft("y",qt),new vt(Ut,qt,_1n$3,lt(Ut*qt))}static normalizeZ(Ht){const Ut=tt.invertBatch(Ht.map(qt=>qt.ez));return Ht.map((qt,Lt)=>qt.toAffine(Ut[Lt])).map(vt.fromAffine)}static msm(Ht,Ut){return pippenger(vt,dt,Ht,Ut)}_setWindowSize(Ht){wt.setWindowSize(this,Ht)}assertValidity(){xt(this)}equals(Ht){yt(Ht);const{ex:Ut,ey:qt,ez:Lt}=this,{ex:Zt,ey:Qt,ez:Nt}=Ht,Gt=lt(Ut*Nt),nn=lt(Zt*Lt),Wt=lt(qt*Nt),hn=lt(Qt*Lt);return Gt===nn&&Wt===hn}is0(){return this.equals(vt.ZERO)}negate(){return new vt(lt(-this.ex),this.ey,this.ez,lt(-this.et))}double(){const{a:Ht}=et,{ex:Ut,ey:qt,ez:Lt}=this,Zt=lt(Ut*Ut),Qt=lt(qt*qt),Nt=lt(_2n$2*lt(Lt*Lt)),Gt=lt(Ht*Zt),nn=Ut+qt,Wt=lt(lt(nn*nn)-Zt-Qt),hn=Gt+Qt,Xt=hn-Nt,Jt=Gt-Qt,tn=lt(Wt*Xt),_t=lt(hn*Jt),Dt=lt(Wt*Jt),Vt=lt(Xt*hn);return new vt(tn,_t,Vt,Dt)}add(Ht){yt(Ht);const{a:Ut,d:qt}=et,{ex:Lt,ey:Zt,ez:Qt,et:Nt}=this,{ex:Gt,ey:nn,ez:Wt,et:hn}=Ht;if(Ut===BigInt(-1)){const mn=lt((Zt-Lt)*(nn+Gt)),wn=lt((Zt+Lt)*(nn-Gt)),Tn=lt(wn-mn);if(Tn===_0n$2)return this.double();const Pn=lt(Qt*_2n$2*hn),yn=lt(Nt*_2n$2*Wt),En=yn+Pn,on=wn+mn,Tt=yn-Pn,St=lt(En*Tn),At=lt(on*Tt),$t=lt(En*Tt),Kt=lt(Tn*on);return new vt(St,At,Kt,$t)}const Xt=lt(Lt*Gt),Jt=lt(Zt*nn),tn=lt(Nt*qt*hn),_t=lt(Qt*Wt),Dt=lt((Lt+Zt)*(Gt+nn)-Xt-Jt),Vt=_t-tn,en=_t+tn,an=lt(Jt-Ut*Xt),dn=lt(Dt*Vt),ln=lt(en*an),pn=lt(Dt*an),kn=lt(Vt*en);return new vt(dn,ln,kn,pn)}subtract(Ht){return this.add(Ht.negate())}wNAF(Ht){return wt.wNAFCached(this,Ht,vt.normalizeZ)}multiply(Ht){const Ut=Ht;aInRange("scalar",Ut,_1n$3,nt);const{p:qt,f:Lt}=this.wNAF(Ut);return vt.normalizeZ([qt,Lt])[0]}multiplyUnsafe(Ht){const Ut=Ht;return aInRange("scalar",Ut,_0n$2,nt),Ut===_0n$2?Et:this.equals(Et)||Ut===_1n$3?this:this.equals(bt)?this.wNAF(Ut).p:wt.unsafeLadder(this,Ut)}isSmallOrder(){return this.multiplyUnsafe(at).is0()}isTorsionFree(){return wt.unsafeLadder(this,nt).is0()}toAffine(Ht){return gt(this,Ht)}clearCofactor(){const{h:Ht}=et;return Ht===_1n$3?this:this.multiplyUnsafe(Ht)}static fromHex(Ht,Ut=!1){const{d:qt,a:Lt}=et,Zt=tt.BYTES;Ht=ensureBytes$1("pointHex",Ht,Zt),abool("zip215",Ut);const Qt=Ht.slice(),Nt=Ht[Zt-1];Qt[Zt-1]=Nt&-129;const Gt=bytesToNumberLE(Qt),nn=Ut?ct:tt.ORDER;aInRange("pointHex.y",Gt,_0n$2,nn);const Wt=lt(Gt*Gt),hn=lt(Wt-_1n$3),Xt=lt(qt*Wt-Lt);let{isValid:Jt,value:tn}=ht(hn,Xt);if(!Jt)throw new Error("Point.fromHex: invalid y coordinate");const _t=(tn&_1n$3)===_1n$3,Dt=(Nt&128)!==0;if(!Ut&&tn===_0n$2&&Dt)throw new Error("Point.fromHex: x=0 and x_0=1");return Dt!==_t&&(tn=lt(-tn)),vt.fromAffine({x:tn,y:Gt})}static fromPrivateKey(Ht){return Rt(Ht).point}toRawBytes(){const{x:Ht,y:Ut}=this.toAffine(),qt=numberToBytesLE(Ut,tt.BYTES);return qt[qt.length-1]|=Ht&_1n$3?128:0,qt}toHex(){return bytesToHex$2(this.toRawBytes())}}vt.BASE=new vt(et.Gx,et.Gy,_1n$3,lt(et.Gx*et.Gy)),vt.ZERO=new vt(_0n$2,_1n$3,_1n$3,_0n$2);const{BASE:bt,ZERO:Et}=vt,wt=wNAF(vt,st*8);function kt(Yt){return mod$1(Yt,nt)}function It(Yt){return kt(bytesToNumberLE(Yt))}function Rt(Yt){const Ht=st;Yt=ensureBytes$1("private key",Yt,Ht);const Ut=ensureBytes$1("hashed private key",ot(Yt),2*Ht),qt=pt(Ut.slice(0,Ht)),Lt=Ut.slice(Ht,2*Ht),Zt=It(qt),Qt=bt.multiply(Zt),Nt=Qt.toRawBytes();return{head:qt,prefix:Lt,scalar:Zt,point:Qt,pointBytes:Nt}}function Pt(Yt){return Rt(Yt).pointBytes}function jt(Yt=new Uint8Array,...Ht){const Ut=concatBytes$1(...Ht);return It(ot(mt(Ut,ensureBytes$1("context",Yt),!!rt)))}function Ot(Yt,Ht,Ut={}){Yt=ensureBytes$1("message",Yt),rt&&(Yt=rt(Yt));const{prefix:qt,scalar:Lt,pointBytes:Zt}=Rt(Ht),Qt=jt(Ut.context,qt,Yt),Nt=bt.multiply(Qt).toRawBytes(),Gt=jt(Ut.context,Nt,Zt,Yt),nn=kt(Qt+Gt*Lt);aInRange("signature.s",nn,_0n$2,nt);const Wt=concatBytes$1(Nt,numberToBytesLE(nn,tt.BYTES));return ensureBytes$1("result",Wt,st*2)}const Bt=VERIFY_DEFAULT;function zt(Yt,Ht,Ut,qt=Bt){const{context:Lt,zip215:Zt}=qt,Qt=tt.BYTES;Yt=ensureBytes$1("signature",Yt,2*Qt),Ht=ensureBytes$1("message",Ht),Zt!==void 0&&abool("zip215",Zt),rt&&(Ht=rt(Ht));const Nt=bytesToNumberLE(Yt.slice(Qt,2*Qt));let Gt,nn,Wt;try{Gt=vt.fromHex(Ut,Zt),nn=vt.fromHex(Yt.slice(0,Qt),Zt),Wt=bt.multiplyUnsafe(Nt)}catch{return!1}if(!Zt&&Gt.isSmallOrder())return!1;const hn=jt(Lt,nn.toRawBytes(),Gt.toRawBytes(),Ht);return nn.add(Gt.multiplyUnsafe(hn)).subtract(Wt).clearCofactor().equals(vt.ZERO)}return bt._setWindowSize(8),{CURVE:et,getPublicKey:Pt,sign:Ot,verify:zt,ExtendedPoint:vt,utils:{getExtendedPublicKey:Rt,randomPrivateKey:()=>it(tt.BYTES),precompute(Yt=8,Ht=vt.BASE){return Ht._setWindowSize(Yt),Ht.multiply(BigInt(3)),Ht}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function validateOpts(o){return validateObject(o,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...o})}function montgomery(o){const et=validateOpts(o),{P:tt}=et,nt=xt=>mod$1(xt,tt),rt=et.montgomeryBits,ot=Math.ceil(rt/8),it=et.nByteLength,st=et.adjustScalarBytes||(xt=>xt),at=et.powPminus2||(xt=>pow(xt,tt-BigInt(2),tt));function ct(xt,vt,bt){const Et=nt(xt*(vt-bt));return vt=nt(vt-Et),bt=nt(bt+Et),[vt,bt]}const lt=(et.a-BigInt(2))/BigInt(4);function dt(xt,vt){aInRange("u",xt,_0n$1,tt),aInRange("scalar",vt,_0n$1,tt);const bt=vt,Et=xt;let wt=_1n$2,kt=_0n$1,It=xt,Rt=_1n$2,Pt=_0n$1,jt;for(let Bt=BigInt(rt-1);Bt>=_0n$1;Bt--){const zt=bt>>Bt&_1n$2;Pt^=zt,jt=ct(Pt,wt,It),wt=jt[0],It=jt[1],jt=ct(Pt,kt,Rt),kt=jt[0],Rt=jt[1],Pt=zt;const Ft=wt+kt,Yt=nt(Ft*Ft),Ht=wt-kt,Ut=nt(Ht*Ht),qt=Yt-Ut,Lt=It+Rt,Zt=It-Rt,Qt=nt(Zt*Ft),Nt=nt(Lt*Ht),Gt=Qt+Nt,nn=Qt-Nt;It=nt(Gt*Gt),Rt=nt(Et*nt(nn*nn)),wt=nt(Yt*Ut),kt=nt(qt*(Yt+nt(lt*qt)))}jt=ct(Pt,wt,It),wt=jt[0],It=jt[1],jt=ct(Pt,kt,Rt),kt=jt[0],Rt=jt[1];const Ot=at(kt);return nt(wt*Ot)}function ht(xt){return numberToBytesLE(nt(xt),ot)}function pt(xt){const vt=ensureBytes$1("u coordinate",xt,ot);return it===32&&(vt[31]&=127),bytesToNumberLE(vt)}function mt(xt){const vt=ensureBytes$1("scalar",xt),bt=vt.length;if(bt!==ot&&bt!==it)throw new Error(`Expected ${ot} or ${it} bytes, got ${bt}`);return bytesToNumberLE(st(vt))}function ft(xt,vt){const bt=pt(vt),Et=mt(xt),wt=dt(bt,Et);if(wt===_0n$1)throw new Error("Invalid private or public key received");return ht(wt)}const yt=ht(et.Gu);function gt(xt){return ft(xt,yt)}return{scalarMult:ft,scalarMultBase:gt,getSharedSecret:(xt,vt)=>ft(xt,vt),getPublicKey:xt=>gt(xt),utils:{randomPrivateKey:()=>et.randomBytes(et.nByteLength)},GuBytes:yt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n$1=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_5n=BigInt(5),_8n$1=BigInt(8);function ed25519_pow_2_252_3(o){const et=BigInt(10),tt=BigInt(20),nt=BigInt(40),rt=BigInt(80),ot=ED25519_P,st=o*o%ot*o%ot,at=pow2$1(st,_2n$1,ot)*st%ot,ct=pow2$1(at,_1n$1,ot)*o%ot,lt=pow2$1(ct,_5n,ot)*ct%ot,dt=pow2$1(lt,et,ot)*lt%ot,ht=pow2$1(dt,tt,ot)*dt%ot,pt=pow2$1(ht,nt,ot)*ht%ot,mt=pow2$1(pt,rt,ot)*pt%ot,ft=pow2$1(mt,rt,ot)*pt%ot,yt=pow2$1(ft,et,ot)*lt%ot;return{pow_p_5_8:pow2$1(yt,_2n$1,ot)*o%ot,b2:st}}function adjustScalarBytes(o){return o[0]&=248,o[31]&=127,o[31]|=64,o}function uvRatio(o,et){const tt=ED25519_P,nt=mod$1(et*et*et,tt),rt=mod$1(nt*nt*et,tt),ot=ed25519_pow_2_252_3(o*rt).pow_p_5_8;let it=mod$1(o*nt*ot,tt);const st=mod$1(et*it*it,tt),at=it,ct=mod$1(it*ED25519_SQRT_M1,tt),lt=st===o,dt=st===mod$1(-o,tt),ht=st===mod$1(-o*ED25519_SQRT_M1,tt);return lt&&(it=at),(dt||ht)&&(it=ct),isNegativeLE(it,tt)&&(it=mod$1(-it,tt)),{isValid:lt||dt,value:it}}const Fp=Field$1(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_8n$1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512,randomBytes:randomBytes$1,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults),x25519=montgomery({P:ED25519_P,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:o=>{const et=ED25519_P,{pow_p_5_8:tt,b2:nt}=ed25519_pow_2_252_3(o);return mod$1(pow2$1(tt,_3n$1,et)*nt,et)},adjustScalarBytes,randomBytes:randomBytes$1}),PUBLIC_KEY_BYTE_LENGTH=32,PRIVATE_KEY_BYTE_LENGTH=64,KEYS_BYTE_LENGTH=32;function generateKey(){const o=ed25519.utils.randomPrivateKey(),et=ed25519.getPublicKey(o);return{privateKey:concatKeys(o,et),publicKey:et}}function hashAndSign(o,et){const tt=o.subarray(0,KEYS_BYTE_LENGTH);return ed25519.sign(et instanceof Uint8Array?et:et.subarray(),tt)}function hashAndVerify$2(o,et,tt){return ed25519.verify(et,tt instanceof Uint8Array?tt:tt.subarray(),o)}function concatKeys(o,et){const tt=new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);for(let nt=0;ntenumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.Type!=null&&(nt.uint32(8),KeyType.codec().encode(tt.Type,nt)),tt.Data!=null&&(nt.uint32(18),nt.bytes(tt.Data)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PublicKey||(PublicKey={}));var PrivateKey;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.Type!=null&&(nt.uint32(8),KeyType.codec().encode(tt.Type,nt)),tt.Data!=null&&(nt.uint32(18),nt.bytes(tt.Data)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PrivateKey||(PrivateKey={}));/*! + Not dialing.`),!1}return await this.isPeerDialableBasedOnBootstrapStatus(tt)?this.dialAttemptsForPeer.has(tt.toString())?(log$j.warn(`Peer ${tt.toString()} has already been attempted dial before, or already has a dial attempt in progress, skipping dial`),!1):!0:(log$j.warn(`Peer ${tt.toString()} is not dialable based on bootstrap status. Not dialing.`),!1)}async isPeerDialableBasedOnBootstrapStatus(tt){return(await this.getTagNamesForPeer(tt)).some(it=>it===Tags.BOOTSTRAP)?this.libp2p.getConnections().filter(it=>it.tags.find(st=>st===Tags.BOOTSTRAP)).lengththis.configuredPubsubTopics.includes(it)):!0}async getPeerShardInfo(tt,nt){const ot=(await nt.get(tt)).metadata.get("shardInfo");if(ot)return decodeRelayShard(ot)}startNetworkStatusListener(){try{globalThis.addEventListener("online",this.onEventHandlers["browser:network"]),globalThis.addEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to start network listener: ${tt}`)}}stopNetworkStatusListener(){try{globalThis.removeEventListener("online",this.onEventHandlers["browser:network"]),globalThis.removeEventListener("offline",this.onEventHandlers["browser:network"])}catch(tt){log$j.error(`Failed to stop network listener: ${tt}`)}}setP2PNetworkConnected(){this.isP2PNetworkConnected||(this.isP2PNetworkConnected=!0,this.dispatchWakuConnectionEvent())}setP2PNetworkDisconnected(){this.isP2PNetworkConnected&&this.libp2p.getConnections().length===0&&(this.isP2PNetworkConnected=!1,this.dispatchWakuConnectionEvent())}dispatchWakuConnectionEvent(){this.dispatchEvent(new CustomEvent(EConnectionStateEvents.CONNECTION_STATUS,{detail:this.isConnected()}))}};Ct(Pr,"instances",new Map);let ConnectionManager=Pr;const wr=class wr{constructor(){Ct(this,"health");this.health={overallStatus:HealthStatus.Unhealthy,protocolStatuses:new Map}}static getInstance(){return wr.instance||(wr.instance=new wr),wr.instance}getHealthStatus(){return this.health.overallStatus}getProtocolStatus(et){return this.health.protocolStatuses.get(et)}updateProtocolHealth(et,tt){const nt=this.getNameFromMulticodec(et);let rt=HealthStatus.Unhealthy;tt==1?rt=HealthStatus.MinimallyHealthy:tt>=2&&(rt=HealthStatus.SufficientlyHealthy),this.health.protocolStatuses.set(nt,{name:nt,status:rt,lastUpdate:new Date}),this.updateOverallHealth()}getNameFromMulticodec(et){let tt;if(et.includes("filter"))tt=Protocols.Filter;else if(et.includes("lightpush"))tt=Protocols.LightPush;else if(et.includes("store"))tt=Protocols.Store;else throw new Error(`Unknown protocol: ${et}`);return tt}updateOverallHealth(){const tt=[Protocols.LightPush,Protocols.Filter].map(nt=>{var rt;return(rt=this.getProtocolStatus(nt))==null?void 0:rt.status});tt.some(nt=>nt===HealthStatus.Unhealthy)?this.health.overallStatus=HealthStatus.Unhealthy:tt.some(nt=>nt===HealthStatus.MinimallyHealthy)?this.health.overallStatus=HealthStatus.MinimallyHealthy:this.health.overallStatus=HealthStatus.SufficientlyHealthy}};Ct(wr,"instance");let HealthManager=wr;const getHealthManager=()=>HealthManager.getInstance(),log$i=new Logger$1("metadata"),MetadataCodec="/vac/waku/metadata/1.0.0";class Metadata extends BaseProtocol{constructor(tt,nt){super(MetadataCodec,nt.components,log$i,tt);Ct(this,"pubsubTopics");Ct(this,"libp2pComponents");Ct(this,"handshakesConfirmed",new Map);this.pubsubTopics=tt,this.libp2pComponents=nt,nt.registrar.handle(MetadataCodec,rt=>{this.onRequest(rt)})}async query(tt){const nt=WakuMetadataRequest.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),rt=await this.libp2pComponents.peerStore.get(tt);if(!rt)return{shardInfo:null,error:ProtocolError$1.NO_PEER_AVAILABLE};let ot;try{ot=await this.getStream(rt)}catch(ct){return log$i.error("Failed to get stream",ct),{shardInfo:null,error:ProtocolError$1.NO_STREAM_AVAILABLE}}const it=await pipe([nt],encode$5,ot,decode$5,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);return st?{shardInfo:null,error:st}:(await this.savePeerShardInfo(tt,at),{shardInfo:at,error:null})}async confirmOrAttemptHandshake(tt){const nt=this.handshakesConfirmed.get(tt.toString());return nt?{shardInfo:nt,error:null}:await this.query(tt)}async onRequest(tt){try{const{stream:nt,connection:rt}=tt,ot=WakuMetadataResponse.encode(pubsubTopicsToShardInfo(this.pubsubTopics)),it=await pipe([ot],encode$5,nt,decode$5,async ct=>await all$2(ct)),{error:st,shardInfo:at}=this.decodeMetadataResponse(it);if(st)return;await this.savePeerShardInfo(rt.remotePeer,at)}catch(nt){log$i.error("Error handling metadata request",nt)}}decodeMetadataResponse(tt){const nt=new Uint8ArrayList;tt.forEach(ot=>{nt.append(ot)});const rt=WakuMetadataResponse.decode(nt);return rt?{shardInfo:rt,error:null}:(log$i.error("Error decoding metadata response"),{shardInfo:null,error:ProtocolError$1.DECODE_FAILED})}async savePeerShardInfo(tt,nt){await this.libp2pComponents.peerStore.merge(tt,{metadata:{shardInfo:encodeRelayShard(nt)}}),this.handshakesConfirmed.set(tt.toString(),nt)}}function wakuMetadata(o){return et=>new Metadata(o,et)}class Parser{constructor(){Ct(this,"index",0);Ct(this,"input","")}new(et){return this.index=0,this.input=et,this}readAtomically(et){const tt=this.index,nt=et();return nt===void 0&&(this.index=tt),nt}parseWith(et){const tt=et();if(this.index===this.input.length)return tt}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(et){return this.readAtomically(()=>{const tt=this.readChar();if(tt===et)return tt})}readSeparator(et,tt,nt){return this.readAtomically(()=>{if(!(tt>0&&this.readGivenChar(et)===void 0))return nt()})}readNumber(et,tt,nt,rt){return this.readAtomically(()=>{let ot=0,it=0;const st=this.peekChar();if(st===void 0)return;const at=st==="0",ct=2**(8*rt)-1;for(;;){const lt=this.readAtomically(()=>{const dt=this.readChar();if(dt===void 0)return;const ht=Number.parseInt(dt,et);if(!Number.isNaN(ht))return ht});if(lt===void 0)break;if(ot*=et,ot+=lt,ot>ct||(it+=1,tt!==void 0&&it>tt))return}if(it!==0)return!nt&&at&&it>1?void 0:ot})}readIPv4Addr(){return this.readAtomically(()=>{const et=new Uint8Array(4);for(let tt=0;ttthis.readNumber(10,3,!1,1));if(nt===void 0)return;et[tt]=nt}return et})}readIPv6Addr(){const et=tt=>{for(let nt=0;ntthis.readIPv4Addr());if(it!==void 0)return tt[rt]=it[0],tt[rt+1]=it[1],tt[rt+2]=it[2],tt[rt+3]=it[3],[rt+4,!0]}const ot=this.readSeparator(":",nt,()=>this.readNumber(16,4,!0,2));if(ot===void 0)return[rt,!1];tt[rt]=ot>>8,tt[rt+1]=ot&255}return[tt.length,!1]};return this.readAtomically(()=>{const tt=new Uint8Array(16),[nt,rt]=et(tt);if(nt===16)return tt;if(rt||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;const ot=new Uint8Array(14),it=16-(nt+2),[st]=et(ot.subarray(0,it));return tt.set(ot.subarray(0,st),16-st),tt})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}}const MAX_IPV6_LENGTH=45,MAX_IPV4_LENGTH=15,parser=new Parser;function parseIPv4(o){if(!(o.length>MAX_IPV4_LENGTH))return parser.new(o).parseWith(()=>parser.readIPv4Addr())}function parseIPv6(o){if(o.includes("%")&&(o=o.split("%")[0]),!(o.length>MAX_IPV6_LENGTH))return parser.new(o).parseWith(()=>parser.readIPv6Addr())}function parseIP(o){if(o.includes("%")&&(o=o.split("%")[0]),!(o.length>MAX_IPV6_LENGTH))return parser.new(o).parseWith(()=>parser.readIPAddr())}function isIPv4(o){return!!parseIPv4(o)}function isIPv6(o){return!!parseIPv6(o)}function isIP(o){return!!parseIP(o)}const isV4=isIPv4,isV6=isIPv6,toBytes$1=function(o){let et=0;if(o=o.toString().trim(),isV4(o)){const tt=new Uint8Array(et+4);return o.split(/\./g).forEach(nt=>{tt[et++]=parseInt(nt,10)&255}),tt}if(isV6(o)){const tt=o.split(":",8);let nt;for(nt=0;nt0;nt--)ot.push("0");tt.splice.apply(tt,ot)}const rt=new Uint8Array(et+16);for(nt=0;nt>8&255,rt[et++]=ot&255}return rt}throw new Error("invalid ip address")},toString$7=function(o,et=0,tt){et=~~et,tt=tt??o.length-et;const nt=new DataView(o.buffer);if(tt===4){const rt=[];for(let ot=0;ot{const et=createProtocol(...o);codes[et.code]=et,names[et.name]=et});function createProtocol(o,et,tt,nt,rt){return{code:o,size:et,name:tt,resolvable:!!nt,path:!!rt}}function getProtocol(o){if(typeof o=="number"){if(codes[o]!=null)return codes[o];throw new Error(`no protocol with code: ${o}`)}else if(typeof o=="string"){if(names[o]!=null)return names[o];throw new Error(`no protocol with name: ${o}`)}throw new Error(`invalid protocol id type: ${typeof o}`)}getProtocol("ip4");getProtocol("ip6");getProtocol("ipcidr");function convertToString(o,et){switch(getProtocol(o).code){case 4:case 41:return bytes2ip(et);case 42:return bytes2str(et);case 6:case 273:case 33:case 132:return bytes2port(et).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bytes2str(et);case 421:return bytes2mh(et);case 444:return bytes2onion(et);case 445:return bytes2onion(et);case 466:return bytes2mb(et);case 481:return globalThis.encodeURIComponent(bytes2str(et));default:return toString$8(et,"base16")}}function convertToBytes(o,et){switch(getProtocol(o).code){case 4:return ip2bytes(et);case 41:return ip2bytes(et);case 42:return str2bytes(et);case 6:case 273:case 33:case 132:return port2bytes(parseInt(et,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return str2bytes(et);case 421:return mh2bytes(et);case 444:return onion2bytes(et);case 445:return onion32bytes(et);case 466:return mb2bytes(et);case 481:return str2bytes(globalThis.decodeURIComponent(et));default:return fromString(et,"base16")}}const decoders=Object.values(bases).map(o=>o.decoder),anybaseDecoder=function(){let o=decoders[0].or(decoders[1]);return decoders.slice(2).forEach(et=>o=o.or(et)),o}();function ip2bytes(o){if(!isIP(o))throw new Error("invalid ip address");return toBytes$1(o)}function bytes2ip(o){const et=toString$7(o,0,o.length);if(et==null)throw new Error("ipBuff is required");if(!isIP(et))throw new Error("invalid ip address");return et}function port2bytes(o){const et=new ArrayBuffer(2);return new DataView(et).setUint16(0,o),new Uint8Array(et)}function bytes2port(o){return new DataView(o.buffer).getUint16(o.byteOffset)}function str2bytes(o){const et=fromString(o),tt=Uint8Array.from(encode$a(et.length));return concat$1([tt,et],tt.length+et.length)}function bytes2str(o){const et=decode$b(o);if(o=o.slice(encodingLength$3(et)),o.length!==et)throw new Error("inconsistent lengths");return toString$8(o)}function mh2bytes(o){let et;o[0]==="Q"||o[0]==="1"?et=decode$6(base58btc.decode(`z${o}`)).bytes:et=CID.parse(o).multihash.bytes;const tt=Uint8Array.from(encode$a(et.length));return concat$1([tt,et],tt.length+et.length)}function mb2bytes(o){const et=anybaseDecoder.decode(o),tt=Uint8Array.from(encode$a(et.length));return concat$1([tt,et],tt.length+et.length)}function bytes2mb(o){const et=decode$b(o),tt=o.slice(encodingLength$3(et));if(tt.length!==et)throw new Error("inconsistent lengths");return"u"+toString$8(tt,"base64url")}function bytes2mh(o){const et=decode$b(o),tt=o.slice(encodingLength$3(et));if(tt.length!==et)throw new Error("inconsistent lengths");return toString$8(tt,"base58btc")}function onion2bytes(o){const et=o.split(":");if(et.length!==2)throw new Error(`failed to parse onion addr: ["'${et.join('", "')}'"]' does not contain a port number`);if(et[0].length!==16)throw new Error(`failed to parse onion addr: ${et[0]} not a Tor onion address.`);const tt=base32$2.decode("b"+et[0]),nt=parseInt(et[1],10);if(nt<1||nt>65536)throw new Error("Port number is not in range(1, 65536)");const rt=port2bytes(nt);return concat$1([tt,rt],tt.length+rt.length)}function onion32bytes(o){const et=o.split(":");if(et.length!==2)throw new Error(`failed to parse onion addr: ["'${et.join('", "')}'"]' does not contain a port number`);if(et[0].length!==56)throw new Error(`failed to parse onion addr: ${et[0]} not a Tor onion3 address.`);const tt=base32$2.decode(`b${et[0]}`),nt=parseInt(et[1],10);if(nt<1||nt>65536)throw new Error("Port number is not in range(1, 65536)");const rt=port2bytes(nt);return concat$1([tt,rt],tt.length+rt.length)}function bytes2onion(o){const et=o.slice(0,o.length-2),tt=o.slice(o.length-2),nt=toString$8(et,"base32"),rt=bytes2port(tt);return`${nt}:${rt}`}function stringToMultiaddrParts(o){o=cleanPath(o);const et=[],tt=[];let nt=null;const rt=o.split("/").slice(1);if(rt.length===1&&rt[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let ot=0;ot=rt.length)throw ParseError("invalid address: "+o);if(st.path===!0){nt=cleanPath(rt.slice(ot).join("/")),et.push([st.code,convertToBytes(st.code,nt)]),tt.push([st.code,nt]);break}const at=convertToBytes(st.code,rt[ot]);et.push([st.code,at]),tt.push([st.code,convertToString(st.code,at)])}return{string:stringTuplesToString(tt),bytes:tuplesToBytes(et),tuples:et,stringTuples:tt,path:nt}}function bytesToMultiaddrParts(o){const et=[],tt=[];let nt=null,rt=0;for(;rto.length)throw ParseError("Invalid address Uint8Array: "+toString$8(o,"base16"));et.push([ot,ct]);const lt=convertToString(ot,ct);if(tt.push([ot,lt]),st.path===!0){nt=lt;break}}return{bytes:Uint8Array.from(o),string:stringTuplesToString(tt),tuples:et,stringTuples:tt,path:nt}}function stringTuplesToString(o){const et=[];return o.map(tt=>{const nt=getProtocol(tt[0]);return et.push(nt.name),tt.length>1&&tt[1]!=null&&et.push(tt[1]),null}),cleanPath(et.join("/"))}function tuplesToBytes(o){return concat$1(o.map(et=>{const tt=getProtocol(et[0]);let nt=Uint8Array.from(encode$a(tt.code));return et.length>1&&et[1]!=null&&(nt=concat$1([nt,et[1]])),nt}))}function sizeForAddr(o,et){if(o.size>0)return o.size/8;if(o.size===0)return 0;{const tt=decode$b(et instanceof Uint8Array?et:Uint8Array.from(et));return tt+encodingLength$3(tt)}}function cleanPath(o){return"/"+o.trim().split("/").filter(et=>et).join("/")}function ParseError(o){return new Error("Error parsing address: "+o)}const inspect$1=Symbol.for("nodejs.util.inspect.custom"),symbol=Symbol.for("@multiformats/js-multiaddr/multiaddr"),DNS_CODES=[getProtocol("dns").code,getProtocol("dns4").code,getProtocol("dns6").code,getProtocol("dnsaddr").code];class NoAvailableResolverError extends Error{constructor(et="No available resolver"){super(et),this.name="NoAvailableResolverError"}}var Xs,Kr,xr,so,ao;const Lr=class Lr{constructor(et){Ct(this,"bytes");fn(this,Kr);fn(this,xr);fn(this,so);fn(this,ao);Ct(this,Xs,!0);et==null&&(et="");let tt;if(et instanceof Uint8Array)tt=bytesToMultiaddrParts(et);else if(typeof et=="string"){if(et.length>0&&et.charAt(0)!=="/")throw new Error(`multiaddr "${et}" must start with a "/"`);tt=stringToMultiaddrParts(et)}else if(isMultiaddr(et))tt=bytesToMultiaddrParts(et.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=tt.bytes,un(this,Kr,tt.string),un(this,xr,tt.tuples),un(this,so,tt.stringTuples),un(this,ao,tt.path)}toString(){return Mt(this,Kr)}toJSON(){return this.toString()}toOptions(){let et,tt,nt,rt,ot="";const it=getProtocol("tcp"),st=getProtocol("udp"),at=getProtocol("ip4"),ct=getProtocol("ip6"),lt=getProtocol("dns6"),dt=getProtocol("ip6zone");for(const[pt,mt]of this.stringTuples())pt===dt.code&&(ot=`%${mt??""}`),DNS_CODES.includes(pt)&&(tt=it.name,rt=443,nt=`${mt??""}${ot}`,et=pt===lt.code?6:4),(pt===it.code||pt===st.code)&&(tt=getProtocol(pt).name,rt=parseInt(mt??"")),(pt===at.code||pt===ct.code)&&(tt=getProtocol(pt).name,nt=`${mt??""}${ot}`,et=pt===ct.code?6:4);if(et==null||tt==null||nt==null||rt==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:et,host:nt,transport:tt,port:rt}}protos(){return Mt(this,xr).map(([et])=>Object.assign({},getProtocol(et)))}protoCodes(){return Mt(this,xr).map(([et])=>et)}protoNames(){return Mt(this,xr).map(([et])=>getProtocol(et).name)}tuples(){return Mt(this,xr)}stringTuples(){return Mt(this,so)}encapsulate(et){return et=new Lr(et),new Lr(this.toString()+et.toString())}decapsulate(et){const tt=et.toString(),nt=this.toString(),rt=nt.lastIndexOf(tt);if(rt<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${et.toString()}`);return new Lr(nt.slice(0,rt))}decapsulateCode(et){const tt=this.tuples();for(let nt=tt.length-1;nt>=0;nt--)if(tt[nt][0]===et)return new Lr(tuplesToBytes(tt.slice(0,nt)));return this}getPeerId(){try{let et=[];this.stringTuples().forEach(([nt,rt])=>{nt===names.p2p.code&&et.push([nt,rt]),nt===names["p2p-circuit"].code&&(et=[])});const tt=et.pop();if((tt==null?void 0:tt[1])!=null){const nt=tt[1];return nt[0]==="Q"||nt[0]==="1"?toString$8(base58btc.decode(`z${nt}`),"base58btc"):toString$8(CID.parse(nt).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return Mt(this,ao)}equals(et){return equals(this.bytes,et.bytes)}async resolve(et){const tt=this.protos().find(ot=>ot.resolvable);if(tt==null)return[this];const nt=resolvers$1.get(tt.name);if(nt==null)throw new NoAvailableResolverError(`no available resolver for ${tt.name}`);return(await nt(this,et)).map(ot=>multiaddr(ot))}nodeAddress(){const et=this.toOptions();if(et.transport!=="tcp"&&et.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${et.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:et.family,address:et.host,port:et.port}}isThinWaistAddress(et){const tt=(et??this).protos();return!(tt.length!==2||tt[0].code!==4&&tt[0].code!==41||tt[1].code!==6&&tt[1].code!==273)}[(Xs=symbol,inspect$1)](){return`Multiaddr(${Mt(this,Kr)})`}};Kr=new WeakMap,xr=new WeakMap,so=new WeakMap,ao=new WeakMap;let Multiaddr=Lr;const resolvers$1=new Map;function isMultiaddr(o){return!!(o!=null&&o[symbol])}function multiaddr(o){return new Multiaddr(o)}const E_CANCELED=new Error("request for lock canceled");var __awaiter$2=function(o,et,tt,nt){function rt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(nt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(nt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):rt(lt.value).then(st,at)}ct((nt=nt.apply(o,et||[])).next())})};class Semaphore{constructor(et,tt=E_CANCELED){this._value=et,this._cancelError=tt,this._queue=[],this._weightedWaiters=[]}acquire(et=1,tt=0){if(et<=0)throw new Error(`invalid weight ${et}: must be positive`);return new Promise((nt,rt)=>{const ot={resolve:nt,reject:rt,weight:et,priority:tt},it=findIndexFromEnd(this._queue,st=>tt<=st.priority);it===-1&&et<=this._value?this._dispatchItem(ot):this._queue.splice(it+1,0,ot)})}runExclusive(et){return __awaiter$2(this,arguments,void 0,function*(tt,nt=1,rt=0){const[ot,it]=yield this.acquire(nt,rt);try{return yield tt(ot)}finally{it()}})}waitForUnlock(et=1,tt=0){if(et<=0)throw new Error(`invalid weight ${et}: must be positive`);return this._couldLockImmediately(et,tt)?Promise.resolve():new Promise(nt=>{this._weightedWaiters[et-1]||(this._weightedWaiters[et-1]=[]),insertSorted(this._weightedWaiters[et-1],{resolve:nt,priority:tt})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(et){this._value=et,this._dispatchQueue()}release(et=1){if(et<=0)throw new Error(`invalid weight ${et}: must be positive`);this._value+=et,this._dispatchQueue()}cancel(){this._queue.forEach(et=>et.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(et){const tt=this._value;this._value-=et.weight,et.resolve([tt,this._newReleaser(et.weight)])}_newReleaser(et){let tt=!1;return()=>{tt||(tt=!0,this.release(et))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let et=this._value;et>0;et--){const tt=this._weightedWaiters[et-1];tt&&(tt.forEach(nt=>nt.resolve()),this._weightedWaiters[et-1]=[])}else{const et=this._queue[0].priority;for(let tt=this._value;tt>0;tt--){const nt=this._weightedWaiters[tt-1];if(!nt)continue;const rt=nt.findIndex(ot=>ot.priority<=et);(rt===-1?nt:nt.splice(0,rt)).forEach(ot=>ot.resolve())}}}_couldLockImmediately(et,tt){return(this._queue.length===0||this._queue[0].priorityet.priority<=nt.priority);o.splice(tt+1,0,et)}function findIndexFromEnd(o,et){for(let tt=o.length-1;tt>=0;tt--)if(et(o[tt]))return tt;return-1}var __awaiter$1=function(o,et,tt,nt){function rt(ot){return ot instanceof tt?ot:new tt(function(it){it(ot)})}return new(tt||(tt=Promise))(function(ot,it){function st(lt){try{ct(nt.next(lt))}catch(dt){it(dt)}}function at(lt){try{ct(nt.throw(lt))}catch(dt){it(dt)}}function ct(lt){lt.done?ot(lt.value):rt(lt.value).then(st,at)}ct((nt=nt.apply(o,et||[])).next())})};class Mutex{constructor(et){this._semaphore=new Semaphore(1,et)}acquire(){return __awaiter$1(this,arguments,void 0,function*(et=0){const[,tt]=yield this._semaphore.acquire(1,et);return tt})}runExclusive(et,tt=0){return this._semaphore.runExclusive(()=>et(),1,tt)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(et=0){return this._semaphore.waitForUnlock(1,et)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class PeerManager{constructor(et,tt,nt){Ct(this,"connectionManager");Ct(this,"core");Ct(this,"log");Ct(this,"peers",new Map);Ct(this,"healthManager");Ct(this,"readMutex",new Mutex);Ct(this,"writeMutex",new Mutex);Ct(this,"writeLockHolder",null);this.connectionManager=et,this.core=tt,this.log=nt,this.healthManager=getHealthManager(),this.healthManager.updateProtocolHealth(this.core.multicodec,0)}getWriteLockHolder(){return this.writeLockHolder}getPeers(){return Array.from(this.peers.values())}async addPeer(et){return this.writeMutex.runExclusive(async()=>{this.writeLockHolder=`addPeer: ${et.id.toString()}`,await this.connectionManager.attemptDial(et.id),this.peers.set(et.id.toString(),et),this.log.info(`Added and dialed peer: ${et.id.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async removePeer(et){return this.writeMutex.runExclusive(()=>{this.writeLockHolder=`removePeer: ${et.toString()}`,this.peers.delete(et.toString()),this.log.info(`Removed peer: ${et.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null})}async getPeerCount(){return this.readMutex.runExclusive(()=>this.peers.size)}async hasPeers(){return this.readMutex.runExclusive(()=>this.peers.size>0)}async removeExcessPeers(et){this.log.info(`Removing ${et} excess peer(s)`);const tt=Array.from(this.peers.values()).slice(0,et);for(const nt of tt)await this.removePeer(nt.id)}async findAndAddPeers(et){const tt=await this.findPeers(et);return tt.length===0?(this.log.warn("No additional peers found"),[]):this.addMultiplePeers(tt)}async findPeers(et){const tt=await this.core.getPeers();return this.readMutex.runExclusive(async()=>tt.filter(rt=>!this.peers.has(rt.id.toString())).slice(0,et))}async addMultiplePeers(et){const tt=[];for(const nt of et)await this.addPeer(nt),tt.push(nt);return tt}}const DEFAULT_NUM_PEERS_TO_USE=2,DEFAULT_MAINTAIN_PEERS_INTERVAL=3e4;class BaseProtocolSDK{constructor(et,tt,nt){Ct(this,"core");Ct(this,"connectionManager");Ct(this,"peerManager");Ct(this,"numPeersToUse");Ct(this,"maintainPeersIntervalId",null);Ct(this,"log");this.core=et,this.connectionManager=tt,this.log=new Logger$1(`sdk:${et.multicodec}`),this.numPeersToUse=(nt==null?void 0:nt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE;const rt=(nt==null?void 0:nt.maintainPeersInterval)??DEFAULT_MAINTAIN_PEERS_INTERVAL;this.peerManager=new PeerManager(tt,et,this.log),this.log.info(`Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${rt}ms`),this.startMaintainPeersInterval(rt)}get connectedPeers(){return this.peerManager.getPeers().slice(0,this.numPeersToUse)}async renewPeer(et){this.log.info(`Attempting to renew peer ${et}`);const tt=await this.peerManager.findPeers(1);if(tt.length===0){this.log.error("Failed to find a new peer to replace the disconnected one");return}return await this.peerManager.removePeer(et),await this.peerManager.addPeer(tt[0]),this.log.info(`Successfully renewed peer. New peer: ${tt[0].id}`),tt[0]}stopMaintainPeersInterval(){this.maintainPeersIntervalId?(clearInterval(this.maintainPeersIntervalId),this.maintainPeersIntervalId=null,this.log.info("Maintain peers interval stopped")):this.log.info("Maintain peers interval was not running")}async hasPeers(et={}){const{forceUseAllPeers:tt=!1,maxAttempts:nt=3}=et;this.log.info(`Checking for peers. forceUseAllPeers: ${tt}, maxAttempts: ${nt}`);for(let rt=0;rt0)return this.log.info(`At least one peer connected (${this.connectedPeers.length}), not forcing use of all peers`),!0;if(this.connectedPeers.length>=this.numPeersToUse)return this.log.info(`Required number of peers (${this.numPeersToUse}) reached`),!0;this.log.warn(`Found only ${this.connectedPeers.length}/${this.numPeersToUse} required peers. Retrying...`)}return this.log.error(`Failed to find required number of peers (${this.numPeersToUse}) after ${nt} attempts`),!1}async startMaintainPeersInterval(et){this.log.info(`Starting maintain peers interval with ${et}ms interval`);try{this.maintainPeersIntervalId=setInterval(()=>{this.log.info("Running scheduled peer maintenance"),this.maintainPeers().catch(tt=>{this.log.error("Error during scheduled peer maintenance:",tt)})},et),this.log.info("Maintain peers interval started successfully")}catch(tt){throw this.log.error("Error starting maintain peers interval:",tt),tt}}async maintainPeers(){try{const et=await this.peerManager.getPeerCount(),tt=this.numPeersToUse-et;if(this.log.info(`Current peer count: ${et}, target: ${this.numPeersToUse}`),tt===0){this.log.info("Peer count is at target, no maintenance required");return}tt>0?(this.log.info(`Attempting to add ${tt} peer(s)`),await this.peerManager.findAndAddPeers(tt)):(this.log.info(`Attempting to remove ${Math.abs(tt)} excess peer(s)`),await this.peerManager.removeExcessPeers(Math.abs(tt)));const nt=await this.peerManager.getPeerCount();this.log.info(`Peer maintenance completed. Initial count: ${et}, Final count: ${nt}`)}catch(et){this.log.error("Error during peer maintenance",{error:et})}}}const DEFAULT_KEEP_ALIVE=6e4,DEFAULT_LIGHT_PUSH_FILTER_CHECK=!1,DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL=1e4,DEFAULT_SUBSCRIBE_OPTIONS={keepAlive:DEFAULT_KEEP_ALIVE,enableLightPushFilterCheck:DEFAULT_LIGHT_PUSH_FILTER_CHECK};function messageHash(o,et){const tt=utf8ToBytes$1(o),nt=utf8ToBytes$1(et.contentTopic),rt=tryConvertTimestampToBytes(et.timestamp),ot=concat$2([tt,et.payload,nt,et.meta,rt].filter(isDefined));return sha256$2(ot)}function tryConvertTimestampToBytes(o){if(!o)return;let et;return typeof o=="bigint"?et=o:et=BigInt(o.valueOf())*1000000n,numberToBytes(et)}function messageHashStr(o,et){const tt=messageHash(o,et);return bytesToHex$1(tt)}const log$h=new Logger$1("sdk:receiver:reliability_monitor"),DEFAULT_MAX_PINGS=3,MESSAGE_VERIFICATION_DELAY=5e3;class ReceiverReliabilityMonitor{constructor(et,tt,nt,rt,ot,it,st){Ct(this,"pubsubTopic");Ct(this,"getPeers");Ct(this,"renewPeer");Ct(this,"getContentTopics");Ct(this,"protocolSubscribe");Ct(this,"addLibp2pEventListener");Ct(this,"sendLightPushMessage");Ct(this,"receivedMessagesFormPeer",new Set);Ct(this,"receivedMessages",new Set);Ct(this,"scheduledVerification",new Map);Ct(this,"verifiedPeers",new Set);Ct(this,"peerFailures",new Map);Ct(this,"maxPingFailures",DEFAULT_MAX_PINGS);Ct(this,"peerRenewalLocks",new Set);this.pubsubTopic=et,this.getPeers=tt,this.renewPeer=nt,this.getContentTopics=rt,this.protocolSubscribe=ot,this.addLibp2pEventListener=it,this.sendLightPushMessage=st,this.addLibp2pEventListener("peer:disconnect",at=>{const ct=at.detail;this.getPeers().some(lt=>lt.id.equals(ct))&&this.renewAndSubscribePeer(ct)})}setMaxPingFailures(et){et!==void 0&&(this.maxPingFailures=et)}async handlePingResult(et,tt){if(tt!=null&&tt.success){this.peerFailures.delete(et.toString());return}const nt=(this.peerFailures.get(et.toString())||0)+1;if(this.peerFailures.set(et.toString(),nt),nt>=this.maxPingFailures)try{log$h.info(`Attempting to renew ${et.toString()} due to ping failures.`),await this.renewAndSubscribePeer(et),this.peerFailures.delete(et.toString())}catch(rt){log$h.error(`Failed to renew peer ${et.toString()}: ${rt}.`)}}notifyMessageReceived(et,tt){const nt=this.buildMessageHash(tt);return this.verifiedPeers.add(et),this.receivedMessagesFormPeer.add(`${et}-${nt}`),log$h.info(`notifyMessage received debug: ephemeral:${tt.ephemeral} ${bytesToUtf8(tt.payload)}`),log$h.info(`notifyMessage received: peer:${et} message:${nt}`),this.receivedMessages.has(nt)?!0:(this.receivedMessages.add(nt),!1)}notifyMessageSent(et,tt){const nt=et.toString(),rt=this.buildMessageHash(tt);if(log$h.info(`notifyMessage sent debug: ${bytesToUtf8(tt.payload)}`),this.scheduledVerification.has(nt)){log$h.warn(`notifyMessage sent: attempting to schedule verification for pending peer:${nt} message:${rt}`);return}const ot=setTimeout(async()=>{const it=this.verifiedPeers.has(nt),st=this.receivedMessagesFormPeer.has(`${nt}-${rt}`);if(it||st){log$h.info(`notifyMessage sent setTimeout: verified that peer pushes filter messages, peer:${nt} message:${rt}`);return}log$h.warn(`notifyMessage sent setTimeout: peer didn't return probe message, attempting renewAndSubscribe, peer:${nt} message:${rt}`),this.scheduledVerification.delete(nt),await this.renewAndSubscribePeer(et)},MESSAGE_VERIFICATION_DELAY);this.scheduledVerification.set(nt,ot)}shouldVerifyPeer(et){const tt=et.toString(),nt=this.verifiedPeers.has(tt),rt=this.scheduledVerification.has(tt);return!(nt||rt)}buildMessageHash(et){return messageHashStr(this.pubsubTopic,et)}async renewAndSubscribePeer(et){const tt=et.toString();try{if(this.peerRenewalLocks.has(tt)){log$h.info(`Peer ${tt} is already being renewed.`);return}this.peerRenewalLocks.add(tt);const nt=await this.renewPeer(et);if(!nt){log$h.warn(`Failed to renew peer ${tt}: No new peer found.`);return}return await this.protocolSubscribe(this.pubsubTopic,nt,this.getContentTopics()),await this.sendLightPushMessage(nt),this.peerFailures.delete(tt),nt}catch(nt){log$h.error(`Failed to renew peer ${tt}: ${nt}.`);return}finally{this.peerRenewalLocks.delete(tt)}}}const Nr=class Nr{static createReceiverMonitor(et,tt,nt,rt,ot,it,st){if(Nr.receiverMonitors.has(et))return Nr.receiverMonitors.get(et);const at=new ReceiverReliabilityMonitor(et,tt,nt,rt,ot,it,st);return Nr.receiverMonitors.set(et,at),at}constructor(){}static stop(et){this.receiverMonitors.delete(et)}static stopAll(){for(const[et,tt]of this.receiverMonitors)tt.setMaxPingFailures(void 0),this.receiverMonitors.delete(et)}};Ct(Nr,"receiverMonitors",new Map);let ReliabilityMonitorManager=Nr;const log$g=new Logger$1("sdk:filter:subscription_manager");class SubscriptionManager{constructor(et,tt,nt,rt,ot,it,st){Ct(this,"pubsubTopic");Ct(this,"protocol");Ct(this,"connectionManager");Ct(this,"getPeers");Ct(this,"renewPeer");Ct(this,"libp2p");Ct(this,"lightPush");Ct(this,"reliabilityMonitor");Ct(this,"keepAliveTimeout",DEFAULT_KEEP_ALIVE);Ct(this,"keepAliveInterval",null);Ct(this,"enableLightPushFilterCheck",DEFAULT_LIGHT_PUSH_FILTER_CHECK);Ct(this,"subscriptionCallbacks");this.pubsubTopic=et,this.protocol=tt,this.connectionManager=nt,this.getPeers=rt,this.renewPeer=ot,this.libp2p=it,this.lightPush=st,this.pubsubTopic=et,this.subscriptionCallbacks=new Map,this.reliabilityMonitor=ReliabilityMonitorManager.createReceiverMonitor(this.pubsubTopic,this.getPeers.bind(this),this.renewPeer.bind(this),()=>Array.from(this.subscriptionCallbacks.keys()),this.protocol.subscribe.bind(this.protocol),this.protocol.addLibp2pEventListener.bind(this.protocol),this.sendLightPushCheckMessage.bind(this))}async subscribe(et,tt,nt=DEFAULT_SUBSCRIBE_OPTIONS){this.reliabilityMonitor.setMaxPingFailures(nt.pingsBeforePeerRenewed),this.keepAliveTimeout=nt.keepAlive||DEFAULT_KEEP_ALIVE,this.enableLightPushFilterCheck=(nt==null?void 0:nt.enableLightPushFilterCheck)||DEFAULT_LIGHT_PUSH_FILTER_CHECK;const rt=Array.isArray(et)?et:[et];for(const lt of rt)if(lt.pubsubTopic!==this.pubsubTopic)return{failures:[{error:ProtocolError$1.TOPIC_DECODER_MISMATCH}],successes:[]};this.enableLightPushFilterCheck&&rt.push(createDecoder(this.buildLightPushContentTopic(),this.pubsubTopic));const ot=groupByContentTopic(rt),it=Array.from(ot.keys()),st=this.getPeers().map(async lt=>this.subscribeWithPeerVerification(lt,it)),at=await Promise.allSettled(st),ct=this.handleResult(at,"subscribe");return ot.forEach((lt,dt)=>{const ht={decoders:lt,callback:tt};dt!==this.buildLightPushContentTopic()&&this.subscriptionCallbacks.set(dt,ht)}),this.startSubscriptionsMaintenance(this.keepAliveTimeout),ct}async unsubscribe(et){const tt=this.getPeers().map(async ot=>{const it=await this.protocol.unsubscribe(this.pubsubTopic,ot,et);return et.forEach(st=>{this.subscriptionCallbacks.delete(st)}),it}),nt=await Promise.allSettled(tt),rt=this.handleResult(nt,"unsubscribe");return this.subscriptionCallbacks.size===0&&this.stopSubscriptionsMaintenance(),rt}async ping(et){log$g.info("Sending keep-alive ping");const nt=(et?[et]:this.getPeers().map(ot=>ot.id)).map(ot=>this.pingSpecificPeer(ot)),rt=await Promise.allSettled(nt);return this.handleResult(rt,"ping")}async unsubscribeAll(){const et=this.getPeers().map(async rt=>this.protocol.unsubscribeAll(this.pubsubTopic,rt)),tt=await Promise.allSettled(et);this.subscriptionCallbacks.clear();const nt=this.handleResult(tt,"unsubscribeAll");return this.stopSubscriptionsMaintenance(),nt}async processIncomingMessage(et,tt){if(this.reliabilityMonitor.notifyMessageReceived(tt,et)){log$g.info("Message already received, skipping");return}const{contentTopic:rt}=et,ot=this.subscriptionCallbacks.get(rt);if(!ot){log$g.error("No subscription callback available for ",rt);return}log$g.info("Processing message with content topic ",rt," on pubsub topic ",this.pubsubTopic),await pushMessage(ot,this.pubsubTopic,et)}async subscribeWithPeerVerification(et,tt){const nt=await this.protocol.subscribe(this.pubsubTopic,et,tt);return await this.sendLightPushCheckMessage(et),nt}handleResult(et,tt){const nt={failures:[],successes:[]};for(const rt of et)if(rt.status==="rejected")log$g.error(`Failed to resolve ${tt} promise successfully: `,rt.reason),nt.failures.push({error:ProtocolError$1.GENERIC_FAIL});else{const ot=rt.value;ot.failure?nt.failures.push(ot.failure):nt.successes.push(ot.success)}return nt}async pingSpecificPeer(et){var rt,ot;const tt=this.getPeers().find(it=>it.id.equals(et));if(!tt)return{success:null,failure:{peerId:et,error:ProtocolError$1.NO_PEER_AVAILABLE}};let nt;try{nt=await this.protocol.ping(tt)}catch{nt={success:null,failure:{peerId:et,error:ProtocolError$1.GENERIC_FAIL}}}return log$g.info(`Received result from filter ping peerId:${et.toString()} success:${(rt=nt.success)==null?void 0:rt.toString()} failure:${(ot=nt.failure)==null?void 0:ot.error}`),await this.reliabilityMonitor.handlePingResult(et,nt),nt}startSubscriptionsMaintenance(et){log$g.info("Starting subscriptions maintenance"),this.startKeepAlivePings(et),this.startConnectionListener()}stopSubscriptionsMaintenance(){log$g.info("Stopping subscriptions maintenance"),this.stopKeepAlivePings(),this.stopConnectionListener()}startConnectionListener(){this.connectionManager.addEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}stopConnectionListener(){this.connectionManager.removeEventListener(EConnectionStateEvents.CONNECTION_STATUS,this.connectionListener.bind(this))}async connectionListener({detail:et}){if(!et){this.stopKeepAlivePings();return}try{await this.ping()}catch(tt){log$g.error(`networkStateListener failed to recover: ${tt}`)}this.startKeepAlivePings(this.keepAliveTimeout)}startKeepAlivePings(et){if(this.keepAliveInterval){log$g.info("Recurring pings already set up.");return}this.keepAliveInterval=setInterval(()=>{this.ping()},et)}stopKeepAlivePings(){if(!this.keepAliveInterval){log$g.info("Already stopped recurring pings.");return}log$g.info("Stopping recurring pings."),clearInterval(this.keepAliveInterval),this.keepAliveInterval=null}async sendLightPushCheckMessage(et){if(this.lightPush&&this.libp2p&&this.reliabilityMonitor.shouldVerifyPeer(et.id)){const tt=createEncoder({contentTopic:this.buildLightPushContentTopic(),pubsubTopic:this.pubsubTopic,ephemeral:!0}),nt={payload:new Uint8Array(1)},rt=await tt.toProtoObj(nt);setTimeout(async()=>{const ot=await this.lightPush.protocol.send(tt,nt,et);if(this.reliabilityMonitor.notifyMessageSent(et.id,rt),ot.failure){log$g.error(`failed to send lightPush ping message to peer:${et.id.toString()} ${ot.failure.error}`);return}},DEFAULT_LIGHT_PUSH_FILTER_CHECK_INTERVAL)}}buildLightPushContentTopic(){return`/js-waku-subscription-ping/1/${this.libp2p.peerId.toString()}/utf8`}}async function pushMessage(o,et,tt){const{decoders:nt,callback:rt}=o,{contentTopic:ot}=tt;if(!ot){log$g.warn("Message has no content topic, skipping");return}try{const it=nt.map(at=>at.fromProtoObj(et,tt).then(ct=>ct||Promise.reject("Decoding failed"))),st=await Promise.any(it);await rt(st)}catch(it){log$g.error("Error decoding message",it)}}const log$f=new Logger$1("sdk:filter");class Filter extends BaseProtocolSDK{constructor(tt,nt,rt,ot){super(new FilterCore(async(it,st,at)=>{const ct=this.getActiveSubscription(it);if(!ct){log$f.error(`No subscription locally registered for topic ${it}`);return}await ct.processIncomingMessage(st,at)},tt.configuredPubsubTopics,nt),tt,{numPeersToUse:ot==null?void 0:ot.numPeersToUse});Ct(this,"libp2p");Ct(this,"lightPush");Ct(this,"protocol");Ct(this,"activeSubscriptions",new Map);this.libp2p=nt,this.lightPush=rt,this.protocol=this.core,this.activeSubscriptions=new Map}async subscribe(tt,nt,rt,ot=DEFAULT_SUBSCRIBE_OPTIONS){const it=this.getUniquePubsubTopics(tt);if(it.length!==1)return{subscription:null,error:ProtocolError$1.INVALID_DECODER_TOPICS,results:null};const st=it[0],{subscription:at,error:ct}=await this.createSubscription(st,rt);if(ct)return{subscription:null,error:ct,results:null};const{failures:lt,successes:dt}=await at.subscribe(tt,nt,ot);return{subscription:at,error:null,results:{failures:lt,successes:dt}}}async createSubscription(tt,nt){var st;nt={autoRetry:!0,...nt};const rt=typeof tt=="string"?tt:(st=shardInfoToPubsubTopics(tt))==null?void 0:st[0];return ensurePubsubTopicIsConfigured(rt,this.protocol.pubsubTopics),await this.hasPeers(nt)?(log$f.info(`Creating filter subscription with ${this.connectedPeers.length} peers: `,this.connectedPeers.map(at=>at.id.toString())),{error:null,subscription:this.getActiveSubscription(rt)??this.setActiveSubscription(rt,new SubscriptionManager(rt,this.protocol,this.connectionManager,()=>this.connectedPeers,this.renewPeer.bind(this),this.libp2p,this.lightPush))}):{error:ProtocolError$1.NO_PEER_AVAILABLE,subscription:null}}async subscribeWithUnsubscribe(tt,nt,rt=DEFAULT_SUBSCRIBE_OPTIONS){const ot=this.getUniquePubsubTopics(tt);if(ot.length===0)throw Error("Failed to subscribe: no pubsubTopic found on decoders provided.");if(ot.length>1)throw Error("Failed to subscribe: all decoders should have the same pubsub topic. Use createSubscription to be more agile.");const{subscription:it,error:st}=await this.createSubscription(ot[0]);if(st)throw Error(`Failed to create subscription: ${st}`);await it.subscribe(tt,nt,rt);const at=Array.from(groupByContentTopic(Array.isArray(tt)?tt:[tt]).keys());return async()=>{await it.unsubscribe(at)}}toSubscriptionIterator(tt){return toAsyncIterator(this,tt)}getActiveSubscription(tt){return this.activeSubscriptions.get(tt)}setActiveSubscription(tt,nt){return this.activeSubscriptions.set(tt,nt),nt}getUniquePubsubTopics(tt){return Array.isArray(tt)?tt.length===0?[]:[...new Set(tt.map(rt=>rt.pubsubTopic))]:[tt.pubsubTopic]}}function wakuFilter(o,et,tt){return nt=>new Filter(o,nt,et,tt)}const log$e=new Logger$1("sdk:light-push"),DEFAULT_MAX_ATTEMPTS=3,DEFAULT_SEND_OPTIONS={autoRetry:!1,maxAttempts:DEFAULT_MAX_ATTEMPTS};class LightPush{constructor(et,tt,nt){Ct(this,"libp2p");Ct(this,"numPeersToUse",DEFAULT_NUM_PEERS_TO_USE);Ct(this,"protocol");this.libp2p=tt,this.numPeersToUse=(nt==null?void 0:nt.numPeersToUse)??DEFAULT_NUM_PEERS_TO_USE,this.protocol=new LightPushCore(et.configuredPubsubTopics,tt)}async send(et,tt,nt=DEFAULT_SEND_OPTIONS){const rt=[],ot=[],{pubsubTopic:it}=et;try{ensurePubsubTopicIsConfigured(it,this.protocol.pubsubTopics)}catch{return log$e.error("Failed to send waku light push: pubsub topic not configured"),{successes:rt,failures:[{error:ProtocolError$1.TOPIC_NOT_CONFIGURED}]}}const st=await this.getConnectedPeers();if(st.length===0)return{successes:rt,failures:[{error:ProtocolError$1.NO_PEER_AVAILABLE}]};const at=await Promise.allSettled(st.map(ct=>this.protocol.send(et,tt,ct)));for(const ct of at){if(ct.status!=="fulfilled"){log$e.error("Failed unexpectedly while sending:",ct.reason),ot.push({error:ProtocolError$1.GENERIC_FAIL});continue}const{failure:lt,success:dt}=ct.value;if(dt){rt.push(dt);continue}lt&&(ot.push(lt),nt!=null&&nt.autoRetry&&this.attemptRetries(ht=>this.protocol.send(et,tt,ht),nt.maxAttempts))}return getHealthManager().updateProtocolHealth(this.protocol.multicodec,rt.length),{successes:rt,failures:ot}}async attemptRetries(et,tt){var rt;tt=tt||DEFAULT_MAX_ATTEMPTS;const nt=await this.getConnectedPeers();if(nt.length===0){log$e.warn("Cannot retry with no connected peers.");return}for(let ot=0;ot{try{return await this.libp2p.peerStore.get(nt)}catch{return null}}))).filter(nt=>!!nt).filter(nt=>nt.protocols.includes(LightPushCodec)).slice(0,this.numPeersToUse)}}function wakuLightPush(o,et={}){return tt=>new LightPush(o,tt,et)}const DEFAULT_NUM_PEERS=1,log$d=new Logger$1("waku:store:sdk");class Store extends BaseProtocolSDK{constructor(tt,nt,rt){super(new StoreCore(tt.configuredPubsubTopics,nt),tt,{numPeersToUse:DEFAULT_NUM_PEERS});Ct(this,"peerIdStrToUse");Ct(this,"protocol");this.peerIdStrToUse=rt,this.protocol=this.core}async*queryGenerator(tt,nt){const{pubsubTopic:rt,contentTopics:ot,decodersAsMap:it}=this.validateDecodersAndPubsubTopic(tt),st={pubsubTopic:rt,contentTopics:ot,includeData:!0,paginationForward:!0,...nt},at=(await this.protocol.getPeers({numPeers:this.numPeersToUse,maxBootstrapPeers:1,peerIdStr:this.peerIdStrToUse}))[0];if(!at)throw log$d.error("No peers available to query"),new Error("No peers available to query");log$d.info(`Querying store with options: ${JSON.stringify(nt)}`);const ct=this.protocol.queryPerPage(st,it,at);for await(const lt of ct)yield lt}async queryWithOrderedCallback(tt,nt,rt){log$d.info("Querying store with ordered callback");for await(const ot of this.queryGenerator(tt,rt))if(await this.processMessages(ot,nt))break}async queryWithPromiseCallback(tt,nt,rt){log$d.info("Querying store with promise callback");let ot=!1;for await(const it of this.queryGenerator(tt,rt)){const st=it.map(async at=>{ot||(ot=!!await nt(at))});if(await Promise.all(st),ot)break}}async processMessages(tt,nt){let rt=!1;const it=(await Promise.all(tt)).filter(isDefined);return await Promise.all(it.map(async st=>{st&&!rt&&(rt=!!await nt(st))})),rt}createCursor(tt){return messageHash(tt.pubsubTopic,tt)}validateDecodersAndPubsubTopic(tt){if(tt.length===0)throw log$d.error("No decoders provided"),new Error("No decoders provided");const nt=Array.from(new Set(tt.map(st=>st.pubsubTopic)));if(nt.length>1)throw log$d.error("API does not support querying multiple pubsub topics at once"),new Error("API does not support querying multiple pubsub topics at once");const rt=nt[0];ensurePubsubTopicIsConfigured(rt,this.protocol.pubsubTopics);const ot=new Map;tt.forEach(st=>{if(ot.has(st.contentTopic))throw log$d.error("API does not support different decoder per content topic"),new Error("API does not support different decoder per content topic");ot.set(st.contentTopic,st)});const it=tt.filter(st=>st.pubsubTopic===rt).map(st=>st.contentTopic);if(it.length===0)throw log$d.error(`No decoders found for topic ${rt}`),new Error("No decoders found for topic "+rt);return{pubsubTopic:rt,contentTopics:it,decodersAsMap:ot}}}function wakuStore(o,et){return tt=>new Store(o,tt,et)}const log$c=new Logger$1("wait-for-remote-peer");async function waitForRemotePeer(o,et,tt){et=et!=null&&et.length?et:getEnabledProtocols(o);const nt=o.libp2p.getConnections();if(!o.isStarted())throw Error("Waku node is not started");for(const ot of et)switch(ot){case Protocols.Relay:if(!o.relay)throw Error("Cannot wait for Relay peer: protocol not mounted");break;case Protocols.LightPush:if(!o.lightPush)throw Error("Cannot wait for LightPush peer: protocol not mounted");break;case Protocols.Store:if(!o.store)throw Error("Cannot wait for Store peer: protocol not mounted");break;case Protocols.Filter:if(!o.filter)throw Error("Cannot wait for Filter peer: protocol not mounted");break}const rt=[waitForProtocols(o,et)];nt.length>0&&!et.includes(Protocols.Relay)&&rt.push(waitForMetadata(o,et)),tt?await rejectOnTimeout(Promise.any(rt),tt,"Timed out waiting for a remote peer."):await Promise.any(rt)}async function waitForProtocols(o,et){const tt=[];return o.relay&&et.includes(Protocols.Relay)&&tt.push(o.relay.waitForPeers()),o.store&&et.includes(Protocols.Store)&&tt.push(waitForConnectedPeer(StoreCodec,o.libp2p)),o.lightPush&&et.includes(Protocols.LightPush)&&tt.push(waitForConnectedPeer(LightPushCodec,o.libp2p)),o.filter&&et.includes(Protocols.Filter)&&tt.push(waitForConnectedPeer(FilterCodecs.SUBSCRIBE,o.libp2p)),Promise.all(tt)}async function waitForConnectedPeer(o,et){log$c.info(`Waiting for ${o} peer.`),await new Promise(tt=>{const nt=async rt=>{var ot,it;if((it=(ot=rt.detail)==null?void 0:ot.protocols)!=null&&it.includes(o)){const st=et.services.metadata;if(!st){et.removeEventListener("peer:identify",nt),tt();return}try{await st.confirmOrAttemptHandshake(rt.detail.peerId),et.removeEventListener("peer:identify",nt),tt()}catch(at){at.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error waiting for metadata: ${at}`)}}};et.addEventListener("peer:identify",nt)})}async function waitForMetadata(o,et){const tt=o.libp2p.getPeers(),nt=o.libp2p.services.metadata,rt=mapProtocolsToCodecs(et);if(!tt.length||!nt){log$c.info(`Skipping waitForMetadata due to missing connections:${tt.length} or metadataService:${!!nt}`);return}for(const ot of tt)try{const it=await o.libp2p.peerStore.get(ot);if(it.protocols.some(at=>rt.has(at))&&!(await nt.confirmOrAttemptHandshake(ot)).error&&(it.protocols.forEach(lt=>{rt.has(lt)&&rt.set(lt,!0)}),Array.from(rt.values()).every(lt=>lt)))return}catch(it){it.code==="ERR_CONNECTION_BEING_CLOSED"&&log$c.error("Connection closed. Some peers can be on different shard."),log$c.error(`Error while iterating through peers: ${it}`);continue}}const awaitTimeout=(o,et)=>new Promise((tt,nt)=>setTimeout(()=>nt(Error(et)),o));async function rejectOnTimeout(o,et,tt){await Promise.race([o,awaitTimeout(et,tt)])}function getEnabledProtocols(o){const et=[];return o.relay&&et.push(Protocols.Relay),o.filter&&et.push(Protocols.Filter),o.store&&et.push(Protocols.Store),o.lightPush&&et.push(Protocols.LightPush),et}function mapProtocolsToCodecs(o){const et=new Map,tt={[Protocols.Filter]:FilterCodecs.SUBSCRIBE,[Protocols.LightPush]:LightPushCodec,[Protocols.Store]:StoreCodec};for(const nt of o)tt[nt]&&et.set(tt[nt],!1);return et}const DefaultPingKeepAliveValueSecs=5*60,DefaultRelayKeepAliveValueSecs=5*60,DefaultUserAgent="js-waku",DefaultPingMaxInboundStreams=10,log$b=new Logger$1("waku");class WakuNode{constructor(et,tt,nt,rt,ot){Ct(this,"pubsubTopics");Ct(this,"libp2p");Ct(this,"relay");Ct(this,"store");Ct(this,"filter");Ct(this,"lightPush");Ct(this,"connectionManager");Ct(this,"health");var ct;this.pubsubTopics=et,this.relay=ot,this.libp2p=nt,rt={filter:!1,lightpush:!1,store:!1,...rt};const it=tt.pingKeepAlive||DefaultPingKeepAliveValueSecs,st=this.relay?tt.relayKeepAlive||DefaultRelayKeepAliveValueSecs:0,at=this.libp2p.peerId.toString();if(this.connectionManager=ConnectionManager.create(at,nt,{pingKeepAlive:it,relayKeepAlive:st},this.pubsubTopics,this.relay),this.health=getHealthManager(),rt.store){let lt;(ct=tt.nodeToUse)!=null&&ct.store&&this.dialMultiaddr(tt.nodeToUse.store,StoreCodec).catch(ht=>{log$b.error("Failed to dial store peer",ht)});const dt=wakuStore(this.connectionManager,lt);this.store=dt(nt)}if(rt.lightpush){const lt=wakuLightPush(this.connectionManager,tt);this.lightPush=lt(nt)}if(rt.filter){const lt=wakuFilter(this.connectionManager,this.lightPush,tt);this.filter=lt(nt)}log$b.info("Waku node created",at,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}get peerId(){return this.libp2p.peerId}get protocols(){return this.libp2p.getProtocols()}async dial(et,tt){const nt=tt??[],rt=this.mapToPeerIdOrMultiaddr(et);typeof tt>"u"&&(this.relay&&nt.push(Protocols.Relay),this.store&&nt.push(Protocols.Store),this.filter&&nt.push(Protocols.Filter),this.lightPush&&nt.push(Protocols.LightPush));const ot=[];return nt.includes(Protocols.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach(it=>ot.push(it)):log$b.error("Relay codec not included in dial codec: protocol not mounted locally")),nt.includes(Protocols.Store)&&(this.store?ot.push(this.store.protocol.multicodec):log$b.error("Store codec not included in dial codec: protocol not mounted locally")),nt.includes(Protocols.LightPush)&&(this.lightPush?ot.push(this.lightPush.protocol.multicodec):log$b.error("Light Push codec not included in dial codec: protocol not mounted locally")),nt.includes(Protocols.Filter)&&(this.filter?ot.push(this.filter.protocol.multicodec):log$b.error("Filter codec not included in dial codec: protocol not mounted locally")),log$b.info(`Dialing to ${rt.toString()} with protocols ${nt}`),this.libp2p.dialProtocol(rt,ot)}async start(){await this.libp2p.start()}async stop(){ReliabilityMonitorManager.stopAll(),this.connectionManager.stop(),await this.libp2p.stop()}async waitForPeers(et,tt){return waitForRemotePeer(this,et,tt)}isStarted(){return this.libp2p.status=="started"}isConnected(){return this.connectionManager.isConnected()}async dialMultiaddr(et,tt){const nt=multiaddr(et);if(!nt.getPeerId())throw new Error("Failed to dial multiaddr: missing peer ID");return await this.libp2p.dialProtocol(nt,[tt]),nt.getPeerId()}mapToPeerIdOrMultiaddr(et){return isPeerId$2(et)?et:multiaddr(et)}}var ls;let InvalidParametersError$3=(ls=class extends Error{constructor(et="Invalid parameters"){super(et),this.name="InvalidParametersError"}},Ct(ls,"name","InvalidParametersError"),ls);class InvalidPublicKeyError extends Error{constructor(et="Invalid public key"){super(et),this.name="InvalidPublicKeyError"}}Ct(InvalidPublicKeyError,"name","InvalidPublicKeyError");var us;let UnsupportedKeyTypeError$1=(us=class extends Error{constructor(et="Unsupported key type"){super(et),this.name="UnsupportedKeyTypeError"}},Ct(us,"name","UnsupportedKeyTypeError"),us);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1),_2n$2=BigInt(2),_8n$2=BigInt(8),VERIFY_DEFAULT={zip215:!0};function validateOpts$1(o){const et=validateBasic(o);return validateObject(o,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...et})}function twistedEdwards(o){const et=validateOpts$1(o),{Fp:tt,n:nt,prehash:rt,hash:ot,randomBytes:it,nByteLength:st,h:at}=et,ct=_2n$2<{try{return{isValid:!0,value:tt.sqrt(Yt*tt.inv(Ht))}}catch{return{isValid:!1,value:_0n$2}}}),pt=et.adjustScalarBytes||(Yt=>Yt),mt=et.domain||((Yt,Ht,Ut)=>{if(abool("phflag",Ut),Ht.length||Ut)throw new Error("Contexts/pre-hash are not supported");return Yt});function ft(Yt,Ht){aInRange("coordinate "+Yt,Ht,_0n$2,ct)}function yt(Yt){if(!(Yt instanceof vt))throw new Error("ExtendedPoint expected")}const gt=memoized((Yt,Ht)=>{const{ex:Ut,ey:qt,ez:Lt}=Yt,Zt=Yt.is0();Ht==null&&(Ht=Zt?_8n$2:tt.inv(Lt));const Qt=lt(Ut*Ht),Nt=lt(qt*Ht),Gt=lt(Lt*Ht);if(Zt)return{x:_0n$2,y:_1n$3};if(Gt!==_1n$3)throw new Error("invZ was invalid");return{x:Qt,y:Nt}}),xt=memoized(Yt=>{const{a:Ht,d:Ut}=et;if(Yt.is0())throw new Error("bad point: ZERO");const{ex:qt,ey:Lt,ez:Zt,et:Qt}=Yt,Nt=lt(qt*qt),Gt=lt(Lt*Lt),nn=lt(Zt*Zt),Wt=lt(nn*nn),hn=lt(Nt*Ht),Xt=lt(nn*lt(hn+Gt)),Jt=lt(Wt+lt(Ut*lt(Nt*Gt)));if(Xt!==Jt)throw new Error("bad point: equation left != right (1)");const tn=lt(qt*Lt),_t=lt(Zt*Qt);if(tn!==_t)throw new Error("bad point: equation left != right (2)");return!0});class vt{constructor(Ht,Ut,qt,Lt){this.ex=Ht,this.ey=Ut,this.ez=qt,this.et=Lt,ft("x",Ht),ft("y",Ut),ft("z",qt),ft("t",Lt),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(Ht){if(Ht instanceof vt)throw new Error("extended point not allowed");const{x:Ut,y:qt}=Ht||{};return ft("x",Ut),ft("y",qt),new vt(Ut,qt,_1n$3,lt(Ut*qt))}static normalizeZ(Ht){const Ut=tt.invertBatch(Ht.map(qt=>qt.ez));return Ht.map((qt,Lt)=>qt.toAffine(Ut[Lt])).map(vt.fromAffine)}static msm(Ht,Ut){return pippenger(vt,dt,Ht,Ut)}_setWindowSize(Ht){wt.setWindowSize(this,Ht)}assertValidity(){xt(this)}equals(Ht){yt(Ht);const{ex:Ut,ey:qt,ez:Lt}=this,{ex:Zt,ey:Qt,ez:Nt}=Ht,Gt=lt(Ut*Nt),nn=lt(Zt*Lt),Wt=lt(qt*Nt),hn=lt(Qt*Lt);return Gt===nn&&Wt===hn}is0(){return this.equals(vt.ZERO)}negate(){return new vt(lt(-this.ex),this.ey,this.ez,lt(-this.et))}double(){const{a:Ht}=et,{ex:Ut,ey:qt,ez:Lt}=this,Zt=lt(Ut*Ut),Qt=lt(qt*qt),Nt=lt(_2n$2*lt(Lt*Lt)),Gt=lt(Ht*Zt),nn=Ut+qt,Wt=lt(lt(nn*nn)-Zt-Qt),hn=Gt+Qt,Xt=hn-Nt,Jt=Gt-Qt,tn=lt(Wt*Xt),_t=lt(hn*Jt),Dt=lt(Wt*Jt),Vt=lt(Xt*hn);return new vt(tn,_t,Vt,Dt)}add(Ht){yt(Ht);const{a:Ut,d:qt}=et,{ex:Lt,ey:Zt,ez:Qt,et:Nt}=this,{ex:Gt,ey:nn,ez:Wt,et:hn}=Ht;if(Ut===BigInt(-1)){const mn=lt((Zt-Lt)*(nn+Gt)),wn=lt((Zt+Lt)*(nn-Gt)),Tn=lt(wn-mn);if(Tn===_0n$2)return this.double();const Pn=lt(Qt*_2n$2*hn),yn=lt(Nt*_2n$2*Wt),En=yn+Pn,on=wn+mn,Tt=yn-Pn,St=lt(En*Tn),At=lt(on*Tt),$t=lt(En*Tt),Kt=lt(Tn*on);return new vt(St,At,Kt,$t)}const Xt=lt(Lt*Gt),Jt=lt(Zt*nn),tn=lt(Nt*qt*hn),_t=lt(Qt*Wt),Dt=lt((Lt+Zt)*(Gt+nn)-Xt-Jt),Vt=_t-tn,en=_t+tn,an=lt(Jt-Ut*Xt),dn=lt(Dt*Vt),ln=lt(en*an),pn=lt(Dt*an),kn=lt(Vt*en);return new vt(dn,ln,kn,pn)}subtract(Ht){return this.add(Ht.negate())}wNAF(Ht){return wt.wNAFCached(this,Ht,vt.normalizeZ)}multiply(Ht){const Ut=Ht;aInRange("scalar",Ut,_1n$3,nt);const{p:qt,f:Lt}=this.wNAF(Ut);return vt.normalizeZ([qt,Lt])[0]}multiplyUnsafe(Ht){const Ut=Ht;return aInRange("scalar",Ut,_0n$2,nt),Ut===_0n$2?Et:this.equals(Et)||Ut===_1n$3?this:this.equals(bt)?this.wNAF(Ut).p:wt.unsafeLadder(this,Ut)}isSmallOrder(){return this.multiplyUnsafe(at).is0()}isTorsionFree(){return wt.unsafeLadder(this,nt).is0()}toAffine(Ht){return gt(this,Ht)}clearCofactor(){const{h:Ht}=et;return Ht===_1n$3?this:this.multiplyUnsafe(Ht)}static fromHex(Ht,Ut=!1){const{d:qt,a:Lt}=et,Zt=tt.BYTES;Ht=ensureBytes$1("pointHex",Ht,Zt),abool("zip215",Ut);const Qt=Ht.slice(),Nt=Ht[Zt-1];Qt[Zt-1]=Nt&-129;const Gt=bytesToNumberLE(Qt),nn=Ut?ct:tt.ORDER;aInRange("pointHex.y",Gt,_0n$2,nn);const Wt=lt(Gt*Gt),hn=lt(Wt-_1n$3),Xt=lt(qt*Wt-Lt);let{isValid:Jt,value:tn}=ht(hn,Xt);if(!Jt)throw new Error("Point.fromHex: invalid y coordinate");const _t=(tn&_1n$3)===_1n$3,Dt=(Nt&128)!==0;if(!Ut&&tn===_0n$2&&Dt)throw new Error("Point.fromHex: x=0 and x_0=1");return Dt!==_t&&(tn=lt(-tn)),vt.fromAffine({x:tn,y:Gt})}static fromPrivateKey(Ht){return Rt(Ht).point}toRawBytes(){const{x:Ht,y:Ut}=this.toAffine(),qt=numberToBytesLE(Ut,tt.BYTES);return qt[qt.length-1]|=Ht&_1n$3?128:0,qt}toHex(){return bytesToHex$2(this.toRawBytes())}}vt.BASE=new vt(et.Gx,et.Gy,_1n$3,lt(et.Gx*et.Gy)),vt.ZERO=new vt(_0n$2,_1n$3,_1n$3,_0n$2);const{BASE:bt,ZERO:Et}=vt,wt=wNAF(vt,st*8);function kt(Yt){return mod$1(Yt,nt)}function It(Yt){return kt(bytesToNumberLE(Yt))}function Rt(Yt){const Ht=st;Yt=ensureBytes$1("private key",Yt,Ht);const Ut=ensureBytes$1("hashed private key",ot(Yt),2*Ht),qt=pt(Ut.slice(0,Ht)),Lt=Ut.slice(Ht,2*Ht),Zt=It(qt),Qt=bt.multiply(Zt),Nt=Qt.toRawBytes();return{head:qt,prefix:Lt,scalar:Zt,point:Qt,pointBytes:Nt}}function Pt(Yt){return Rt(Yt).pointBytes}function jt(Yt=new Uint8Array,...Ht){const Ut=concatBytes$1(...Ht);return It(ot(mt(Ut,ensureBytes$1("context",Yt),!!rt)))}function Ot(Yt,Ht,Ut={}){Yt=ensureBytes$1("message",Yt),rt&&(Yt=rt(Yt));const{prefix:qt,scalar:Lt,pointBytes:Zt}=Rt(Ht),Qt=jt(Ut.context,qt,Yt),Nt=bt.multiply(Qt).toRawBytes(),Gt=jt(Ut.context,Nt,Zt,Yt),nn=kt(Qt+Gt*Lt);aInRange("signature.s",nn,_0n$2,nt);const Wt=concatBytes$1(Nt,numberToBytesLE(nn,tt.BYTES));return ensureBytes$1("result",Wt,st*2)}const Bt=VERIFY_DEFAULT;function zt(Yt,Ht,Ut,qt=Bt){const{context:Lt,zip215:Zt}=qt,Qt=tt.BYTES;Yt=ensureBytes$1("signature",Yt,2*Qt),Ht=ensureBytes$1("message",Ht),Zt!==void 0&&abool("zip215",Zt),rt&&(Ht=rt(Ht));const Nt=bytesToNumberLE(Yt.slice(Qt,2*Qt));let Gt,nn,Wt;try{Gt=vt.fromHex(Ut,Zt),nn=vt.fromHex(Yt.slice(0,Qt),Zt),Wt=bt.multiplyUnsafe(Nt)}catch{return!1}if(!Zt&&Gt.isSmallOrder())return!1;const hn=jt(Lt,nn.toRawBytes(),Gt.toRawBytes(),Ht);return nn.add(Gt.multiplyUnsafe(hn)).subtract(Wt).clearCofactor().equals(vt.ZERO)}return bt._setWindowSize(8),{CURVE:et,getPublicKey:Pt,sign:Ot,verify:zt,ExtendedPoint:vt,utils:{getExtendedPublicKey:Rt,randomPrivateKey:()=>it(tt.BYTES),precompute(Yt=8,Ht=vt.BASE){return Ht._setWindowSize(Yt),Ht.multiply(BigInt(3)),Ht}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1);function validateOpts(o){return validateObject(o,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...o})}function montgomery(o){const et=validateOpts(o),{P:tt}=et,nt=xt=>mod$1(xt,tt),rt=et.montgomeryBits,ot=Math.ceil(rt/8),it=et.nByteLength,st=et.adjustScalarBytes||(xt=>xt),at=et.powPminus2||(xt=>pow(xt,tt-BigInt(2),tt));function ct(xt,vt,bt){const Et=nt(xt*(vt-bt));return vt=nt(vt-Et),bt=nt(bt+Et),[vt,bt]}const lt=(et.a-BigInt(2))/BigInt(4);function dt(xt,vt){aInRange("u",xt,_0n$1,tt),aInRange("scalar",vt,_0n$1,tt);const bt=vt,Et=xt;let wt=_1n$2,kt=_0n$1,It=xt,Rt=_1n$2,Pt=_0n$1,jt;for(let Bt=BigInt(rt-1);Bt>=_0n$1;Bt--){const zt=bt>>Bt&_1n$2;Pt^=zt,jt=ct(Pt,wt,It),wt=jt[0],It=jt[1],jt=ct(Pt,kt,Rt),kt=jt[0],Rt=jt[1],Pt=zt;const Ft=wt+kt,Yt=nt(Ft*Ft),Ht=wt-kt,Ut=nt(Ht*Ht),qt=Yt-Ut,Lt=It+Rt,Zt=It-Rt,Qt=nt(Zt*Ft),Nt=nt(Lt*Ht),Gt=Qt+Nt,nn=Qt-Nt;It=nt(Gt*Gt),Rt=nt(Et*nt(nn*nn)),wt=nt(Yt*Ut),kt=nt(qt*(Yt+nt(lt*qt)))}jt=ct(Pt,wt,It),wt=jt[0],It=jt[1],jt=ct(Pt,kt,Rt),kt=jt[0],Rt=jt[1];const Ot=at(kt);return nt(wt*Ot)}function ht(xt){return numberToBytesLE(nt(xt),ot)}function pt(xt){const vt=ensureBytes$1("u coordinate",xt,ot);return it===32&&(vt[31]&=127),bytesToNumberLE(vt)}function mt(xt){const vt=ensureBytes$1("scalar",xt),bt=vt.length;if(bt!==ot&&bt!==it)throw new Error(`Expected ${ot} or ${it} bytes, got ${bt}`);return bytesToNumberLE(st(vt))}function ft(xt,vt){const bt=pt(vt),Et=mt(xt),wt=dt(bt,Et);if(wt===_0n$1)throw new Error("Invalid private or public key received");return ht(wt)}const yt=ht(et.Gu);function gt(xt){return ft(xt,yt)}return{scalarMult:ft,scalarMultBase:gt,getSharedSecret:(xt,vt)=>ft(xt,vt),getPublicKey:xt=>gt(xt),utils:{randomPrivateKey:()=>et.randomBytes(et.nByteLength)},GuBytes:yt}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n$1=BigInt(1),_2n$1=BigInt(2),_3n$1=BigInt(3),_5n=BigInt(5),_8n$1=BigInt(8);function ed25519_pow_2_252_3(o){const et=BigInt(10),tt=BigInt(20),nt=BigInt(40),rt=BigInt(80),ot=ED25519_P,st=o*o%ot*o%ot,at=pow2$1(st,_2n$1,ot)*st%ot,ct=pow2$1(at,_1n$1,ot)*o%ot,lt=pow2$1(ct,_5n,ot)*ct%ot,dt=pow2$1(lt,et,ot)*lt%ot,ht=pow2$1(dt,tt,ot)*dt%ot,pt=pow2$1(ht,nt,ot)*ht%ot,mt=pow2$1(pt,rt,ot)*pt%ot,ft=pow2$1(mt,rt,ot)*pt%ot,yt=pow2$1(ft,et,ot)*lt%ot;return{pow_p_5_8:pow2$1(yt,_2n$1,ot)*o%ot,b2:st}}function adjustScalarBytes(o){return o[0]&=248,o[31]&=127,o[31]|=64,o}function uvRatio(o,et){const tt=ED25519_P,nt=mod$1(et*et*et,tt),rt=mod$1(nt*nt*et,tt),ot=ed25519_pow_2_252_3(o*rt).pow_p_5_8;let it=mod$1(o*nt*ot,tt);const st=mod$1(et*it*it,tt),at=it,ct=mod$1(it*ED25519_SQRT_M1,tt),lt=st===o,dt=st===mod$1(-o,tt),ht=st===mod$1(-o*ED25519_SQRT_M1,tt);return lt&&(it=at),(dt||ht)&&(it=ct),isNegativeLE(it,tt)&&(it=mod$1(-it,tt)),{isValid:lt||dt,value:it}}const Fp=Field$1(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_8n$1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512,randomBytes:randomBytes$1,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults),x25519=montgomery({P:ED25519_P,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:o=>{const et=ED25519_P,{pow_p_5_8:tt,b2:nt}=ed25519_pow_2_252_3(o);return mod$1(pow2$1(tt,_3n$1,et)*nt,et)},adjustScalarBytes,randomBytes:randomBytes$1}),PUBLIC_KEY_BYTE_LENGTH=32,PRIVATE_KEY_BYTE_LENGTH=64,KEYS_BYTE_LENGTH=32;function generateKey(){const o=ed25519.utils.randomPrivateKey(),et=ed25519.getPublicKey(o);return{privateKey:concatKeys(o,et),publicKey:et}}function hashAndSign(o,et){const tt=o.subarray(0,KEYS_BYTE_LENGTH);return ed25519.sign(et instanceof Uint8Array?et:et.subarray(),tt)}function hashAndVerify$2(o,et,tt){return ed25519.verify(et,tt instanceof Uint8Array?tt:tt.subarray(),o)}function concatKeys(o,et){const tt=new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);for(let nt=0;ntenumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.Type!=null&&(nt.uint32(8),KeyType.codec().encode(tt.Type,nt)),tt.Data!=null&&(nt.uint32(18),nt.bytes(tt.Data)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PublicKey||(PublicKey={}));var PrivateKey;(function(o){let et;o.codec=()=>(et==null&&(et=message$1((tt,nt,rt={})=>{rt.lengthDelimited!==!1&&nt.fork(),tt.Type!=null&&(nt.uint32(8),KeyType.codec().encode(tt.Type,nt)),tt.Data!=null&&(nt.uint32(18),nt.bytes(tt.Data)),rt.lengthDelimited!==!1&&nt.ldelim()},(tt,nt,rt={})=>{const ot={},it=nt==null?tt.len:tt.pos+nt;for(;tt.pos>>3){case 1:{ot.Type=KeyType.codec().decode(tt);break}case 2:{ot.Data=tt.bytes();break}default:{tt.skipType(st&7);break}}}return ot})),et),o.encode=tt=>encodeMessage(tt,o.codec()),o.decode=(tt,nt)=>decodeMessage(tt,o.codec(),nt)})(PrivateKey||(PrivateKey={}));/*! * MIT License * * Copyright (c) 2017-2022 Peculiar Ventures, LLC @@ -4154,7 +4154,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${et.d `;)Et++;return Et}function ft(){if(st.length>0)return st.shift();if(at)return lt();var bt,Et,wt,kt,It,Rt=tt===0;do{if(tt===nt)return null;for(bt=!1;whitespaceRe.test(wt=dt(tt));)if(wt===` `&&(Rt=!0,++rt),++tt===nt)return null;if(dt(tt)==="/"){if(++tt===nt)throw ct("comment");if(dt(tt)==="/")if(et){if(kt=tt,It=!1,pt(tt-1)){It=!0;do if(tt=mt(tt),tt===nt||(tt++,!Rt))break;while(pt(tt))}else tt=Math.min(nt,mt(tt)+1);It&&(ht(kt,tt,Rt),Rt=!0),rt++,bt=!0}else{for(It=dt(kt=tt+1)==="/";dt(++tt)!==` `;)if(tt===nt)return null;++tt,It&&(ht(kt,tt-1,Rt),Rt=!0),++rt,bt=!0}else if((wt=dt(tt))==="*"){kt=tt+1,It=et||dt(kt)==="*";do{if(wt===` -`&&++rt,++tt===nt)throw ct("comment");Et=wt,wt=dt(tt)}while(Et!=="*"||wt!=="/");++tt,It&&(ht(kt,tt-2,Rt),Rt=!0),bt=!0}else return"/"}}while(bt);var Pt=tt;delimRe.lastIndex=0;var jt=delimRe.test(dt(Pt++));if(!jt)for(;Pt");var Dt=ot();if(!nameRe$1.test(Dt))throw xt(Dt,"name");at("=");var Vt=new MapField(gt(Dt),kt(ot()),tn,_t);Ot(Vt,function(an){if(an==="option")Lt(Vt,an),at(";");else throw xt(an)},function(){Gt(Vt)}),Jt.add(Vt)}function Ht(Jt,tn){if(!nameRe$1.test(tn=ot()))throw xt(tn,"name");var _t=new OneOf(gt(tn));Ot(_t,function(Vt){Vt==="option"?(Lt(_t,Vt),at(";")):(it(Vt),zt(_t,"optional"))}),Jt.add(_t)}function Ut(Jt,tn){if(!nameRe$1.test(tn=ot()))throw xt(tn,"name");var _t=new Enum(tn);Ot(_t,function(Vt){switch(Vt){case"option":Lt(_t,Vt),at(";");break;case"reserved":Et(_t.reserved||(_t.reserved=[]),!0);break;default:qt(_t,Vt)}}),Jt.add(_t)}function qt(Jt,tn){if(!nameRe$1.test(tn))throw xt(tn,"name");at("=");var _t=kt(ot(),!0),Dt={options:void 0};Dt.setOption=function(Vt,en){this.options===void 0&&(this.options={}),this.options[Vt]=en},Ot(Dt,function(en){if(en==="option")Lt(Dt,en),at(";");else throw xt(en)},function(){Gt(Dt)}),Jt.add(tn,_t,Dt.comment,Dt.options)}function Lt(Jt,tn){var _t=at("(",!0);if(!typeRefRe.test(tn=ot()))throw xt(tn,"name");var Dt=tn,Vt=Dt,en;_t&&(at(")"),Dt="("+Dt+")",Vt=Dt,tn=st(),fqTypeRefRe.test(tn)&&(en=tn.slice(1),Dt+=tn,ot())),at("=");var an=Zt(Jt,Dt);Nt(Jt,Vt,an,en)}function Zt(Jt,tn){if(at("{",!0)){for(var _t={};!at("}",!0);){if(!nameRe$1.test(Xt=ot()))throw xt(Xt,"name");if(Xt===null)throw xt(Xt,"end of input");var Dt,Vt=Xt;if(at(":",!0),st()==="{")Dt=Zt(Jt,tn+"."+Xt);else if(st()==="["){Dt=[];var en;if(at("[",!0)){do en=bt(),Dt.push(en);while(at(",",!0));at("]"),typeof en<"u"&&Qt(Jt,tn+"."+Xt,en)}}else Dt=bt(),Qt(Jt,tn+"."+Xt,Dt);var an=_t[Vt];an&&(Dt=[].concat(an).concat(Dt)),_t[Vt]=Dt,at(",",!0),at(";",!0)}return _t}var dn=bt();return Qt(Jt,tn,dn),dn}function Qt(Jt,tn,_t){Jt.setOption&&Jt.setOption(tn,_t)}function Nt(Jt,tn,_t,Dt){Jt.setParsedOption&&Jt.setParsedOption(tn,_t,Dt)}function Gt(Jt){if(at("[",!0)){do Lt(Jt,"option");while(at(",",!0));at("]")}return Jt}function nn(Jt,tn){if(!nameRe$1.test(tn=ot()))throw xt(tn,"service name");var _t=new Service(tn);Ot(_t,function(Vt){if(!jt(_t,Vt))if(Vt==="rpc")Wt(_t,Vt);else throw xt(Vt)}),Jt.add(_t)}function Wt(Jt,tn){var _t=ct(),Dt=tn;if(!nameRe$1.test(tn=ot()))throw xt(tn,"name");var Vt=tn,en,an,dn,ln;if(at("("),at("stream",!0)&&(an=!0),!typeRefRe.test(tn=ot())||(en=tn,at(")"),at("returns"),at("("),at("stream",!0)&&(ln=!0),!typeRefRe.test(tn=ot())))throw xt(tn);dn=tn,at(")");var pn=new Method(Vt,Dt,en,dn,an,ln);pn.comment=_t,Ot(pn,function(mn){if(mn==="option")Lt(pn,mn),at(";");else throw xt(mn)}),Jt.add(pn)}function hn(Jt,tn){if(!typeRefRe.test(tn=ot()))throw xt(tn,"reference");var _t=tn;Ot(null,function(Vt){switch(Vt){case"required":case"repeated":zt(Jt,Vt,_t);break;case"optional":ft?zt(Jt,"proto3_optional",_t):zt(Jt,"optional",_t);break;default:if(!ft||!typeRefRe.test(Vt))throw xt(Vt);it(Vt),zt(Jt,"optional",_t);break}})}for(var Xt;(Xt=ot())!==null;)switch(Xt){case"package":if(!lt)throw xt(Xt);It();break;case"import":if(!lt)throw xt(Xt);Rt();break;case"syntax":if(!lt)throw xt(Xt);Pt();break;case"option":Lt(yt,Xt),at(";");break;default:if(jt(yt,Xt)){lt=!1;continue}throw xt(Xt)}return parse$1.filename=null,{package:dt,imports:ht,weakImports:pt,syntax:mt,root:et}}var common_1=common,commonRe=/\/|\./;function common(o,et){commonRe.test(o)||(o="google/protobuf/"+o+".proto",et={nested:{google:{nested:{protobuf:{nested:et}}}}}),common[o]=et}common("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}});var timeType;common("duration",{Duration:timeType={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}});common("timestamp",{Timestamp:timeType});common("empty",{Empty:{fields:{}}});common("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}});common("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}});common("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}});common.get=function o(et){return common[et]||null};var protobuf$1=src.exports=indexLightExports;protobuf$1.build="full";protobuf$1.tokenize=tokenize_1;protobuf$1.parse=parse_1;protobuf$1.common=common_1;protobuf$1.Root._configure(protobuf$1.Type,protobuf$1.parse,protobuf$1.common);var srcExports=src.exports,protobufjs=srcExports;const protobuf=getDefaultExportFromCjs(protobufjs),WAKU_NODE_OPTIONS={defaultBootstrap:!0},contentTopic="/buddybook-devcon/1/chain/proto",encoder=createEncoder({contentTopic,ephemeral:!1}),decoder=createDecoder(contentTopic),block=new protobuf.Type("block").add(new protobuf.Field("chainUUID",1,"string")).add(new protobuf.Field("blockUUID",2,"string")).add(new protobuf.Field("title",3,"string")).add(new protobuf.Field("description",4,"string")).add(new protobuf.Field("signedMessage",5,"string")).add(new protobuf.Field("timestamp",6,"uint64")).add(new protobuf.Field("signatures",7,"string","repeated")).add(new protobuf.Field("parentBlockUUID",8,"string"));function createMessage({chainUUID:o,blockUUID:et,title:tt,description:nt,signedMessage:rt,timestamp:ot,signatures:it,parentBlockUUID:st}){const at=block.create({chainUUID:o,blockUUID:et,title:tt,description:nt,signedMessage:rt,timestamp:ot,signatures:it.map(lt=>JSON.stringify(lt)),parentBlockUUID:st});return{payload:block.encode(at).finish()}}async function*getMessagesFromStore(o){console.time("getMessagesFromStore");try{for await(const et of o.store.queryGenerator([decoder])){const tt=await Promise.all(et);for(const nt of tt){if(!(nt!=null&&nt.payload))continue;const rt=block.decode(nt.payload);rt.signatures=rt.signatures.map(ot=>JSON.parse(ot)),yield rt}}}finally{console.timeEnd("getMessagesFromStore")}}async function subscribeToFilter(o,et){const{error:tt,subscription:nt,results:rt}=await o.filter.subscribe([decoder],ot=>{if(console.log("message received from filter",ot),ot.payload){const it=block.decode(ot.payload);it.signatures=it.signatures.map(st=>JSON.parse(st)),et(it)}});if(console.log("results",rt),tt&&console.log("Error subscribing to filter",tt),!nt||tt||rt.successes.length===0||rt.failures.length>0)throw new Error("Failed to subscribe to filter")}function useWalletPrompt(){const{isConnected:o}=useAccount(),{connect:et,connectors:tt}=useConnect$1();return{ensureWalletConnected:async()=>{if(!o)try{const rt=tt[0];if(rt)return/iPad|iPhone|iPod/.test(navigator.userAgent)&&(window.location.href="metamask:///",await new Promise(it=>setTimeout(it,1e3))),await et({connector:rt}),await new Promise(it=>setTimeout(it,1e3)),!0}catch(rt){return console.error("Error connecting wallet:",rt),typeof window.ethereum>"u"&&window.open("https://metamask.io/download/","_blank"),!1}return!0}}}const DEFAULT_FORM_DATA={title:"Devcon24 DeFi Dynamo",description:"A revolutionary blockchain for Devcon 24, focusing on scalable DeFi solutions and cross-chain interoperability.",uuid:v4()},ChainCreationForm=()=>{const[o,et]=reactExports.useState(DEFAULT_FORM_DATA),[tt,nt]=reactExports.useState({}),[rt,ot]=reactExports.useState(!1),[it,st]=reactExports.useState(!1),[at,ct]=reactExports.useState(!1),[lt,dt]=reactExports.useState(null),[ht,pt]=reactExports.useState(null),[mt,ft]=reactExports.useState(null),{node:yt}=useWaku(),{address:gt}=useAccount(),{signMessage:xt}=useSignMessage({mutation:{async onSuccess(Rt){if(!gt||!yt)return;pt(Rt);const Pt=v4();ft(Pt);const jt=createMessage({chainUUID:o.uuid,blockUUID:Pt,title:o.title,description:o.description,signedMessage:Rt,timestamp:Date.now(),signatures:[{address:gt,signature:Rt}],parentBlockUUID:null});await(yt==null?void 0:yt.lightPush.send(encoder,jt)),ct(!0),st(!1)},onError(Rt){console.error("Error signing message:",Rt),st(!1),dt("Error signing message. Please try again.")}}}),{ensureWalletConnected:vt}=useWalletPrompt(),bt=Rt=>{const{name:Pt,value:jt}=Rt.target;et(Ot=>({...Ot,[Pt]:jt})),tt[Pt]&&nt(Ot=>({...Ot,[Pt]:void 0}))},Et=()=>{const Rt={};return o.title.trim()||(Rt.title="Title is required"),o.description.trim()||(Rt.description="Description is required"),nt(Rt),Object.keys(Rt).length===0},wt=Rt=>{Rt.preventDefault(),vt()&&Et()&&ot(!0)},kt=async()=>{st(!0),dt(null);const Rt=`Create Chain: +`&&++rt,++tt===nt)throw ct("comment");Et=wt,wt=dt(tt)}while(Et!=="*"||wt!=="/");++tt,It&&(ht(kt,tt-2,Rt),Rt=!0),bt=!0}else return"/"}}while(bt);var Pt=tt;delimRe.lastIndex=0;var jt=delimRe.test(dt(Pt++));if(!jt)for(;Pt");var Dt=ot();if(!nameRe$1.test(Dt))throw xt(Dt,"name");at("=");var Vt=new MapField(gt(Dt),kt(ot()),tn,_t);Ot(Vt,function(an){if(an==="option")Lt(Vt,an),at(";");else throw xt(an)},function(){Gt(Vt)}),Jt.add(Vt)}function Ht(Jt,tn){if(!nameRe$1.test(tn=ot()))throw xt(tn,"name");var _t=new OneOf(gt(tn));Ot(_t,function(Vt){Vt==="option"?(Lt(_t,Vt),at(";")):(it(Vt),zt(_t,"optional"))}),Jt.add(_t)}function Ut(Jt,tn){if(!nameRe$1.test(tn=ot()))throw xt(tn,"name");var _t=new Enum(tn);Ot(_t,function(Vt){switch(Vt){case"option":Lt(_t,Vt),at(";");break;case"reserved":Et(_t.reserved||(_t.reserved=[]),!0);break;default:qt(_t,Vt)}}),Jt.add(_t)}function qt(Jt,tn){if(!nameRe$1.test(tn))throw xt(tn,"name");at("=");var _t=kt(ot(),!0),Dt={options:void 0};Dt.setOption=function(Vt,en){this.options===void 0&&(this.options={}),this.options[Vt]=en},Ot(Dt,function(en){if(en==="option")Lt(Dt,en),at(";");else throw xt(en)},function(){Gt(Dt)}),Jt.add(tn,_t,Dt.comment,Dt.options)}function Lt(Jt,tn){var _t=at("(",!0);if(!typeRefRe.test(tn=ot()))throw xt(tn,"name");var Dt=tn,Vt=Dt,en;_t&&(at(")"),Dt="("+Dt+")",Vt=Dt,tn=st(),fqTypeRefRe.test(tn)&&(en=tn.slice(1),Dt+=tn,ot())),at("=");var an=Zt(Jt,Dt);Nt(Jt,Vt,an,en)}function Zt(Jt,tn){if(at("{",!0)){for(var _t={};!at("}",!0);){if(!nameRe$1.test(Xt=ot()))throw xt(Xt,"name");if(Xt===null)throw xt(Xt,"end of input");var Dt,Vt=Xt;if(at(":",!0),st()==="{")Dt=Zt(Jt,tn+"."+Xt);else if(st()==="["){Dt=[];var en;if(at("[",!0)){do en=bt(),Dt.push(en);while(at(",",!0));at("]"),typeof en<"u"&&Qt(Jt,tn+"."+Xt,en)}}else Dt=bt(),Qt(Jt,tn+"."+Xt,Dt);var an=_t[Vt];an&&(Dt=[].concat(an).concat(Dt)),_t[Vt]=Dt,at(",",!0),at(";",!0)}return _t}var dn=bt();return Qt(Jt,tn,dn),dn}function Qt(Jt,tn,_t){Jt.setOption&&Jt.setOption(tn,_t)}function Nt(Jt,tn,_t,Dt){Jt.setParsedOption&&Jt.setParsedOption(tn,_t,Dt)}function Gt(Jt){if(at("[",!0)){do Lt(Jt,"option");while(at(",",!0));at("]")}return Jt}function nn(Jt,tn){if(!nameRe$1.test(tn=ot()))throw xt(tn,"service name");var _t=new Service(tn);Ot(_t,function(Vt){if(!jt(_t,Vt))if(Vt==="rpc")Wt(_t,Vt);else throw xt(Vt)}),Jt.add(_t)}function Wt(Jt,tn){var _t=ct(),Dt=tn;if(!nameRe$1.test(tn=ot()))throw xt(tn,"name");var Vt=tn,en,an,dn,ln;if(at("("),at("stream",!0)&&(an=!0),!typeRefRe.test(tn=ot())||(en=tn,at(")"),at("returns"),at("("),at("stream",!0)&&(ln=!0),!typeRefRe.test(tn=ot())))throw xt(tn);dn=tn,at(")");var pn=new Method(Vt,Dt,en,dn,an,ln);pn.comment=_t,Ot(pn,function(mn){if(mn==="option")Lt(pn,mn),at(";");else throw xt(mn)}),Jt.add(pn)}function hn(Jt,tn){if(!typeRefRe.test(tn=ot()))throw xt(tn,"reference");var _t=tn;Ot(null,function(Vt){switch(Vt){case"required":case"repeated":zt(Jt,Vt,_t);break;case"optional":ft?zt(Jt,"proto3_optional",_t):zt(Jt,"optional",_t);break;default:if(!ft||!typeRefRe.test(Vt))throw xt(Vt);it(Vt),zt(Jt,"optional",_t);break}})}for(var Xt;(Xt=ot())!==null;)switch(Xt){case"package":if(!lt)throw xt(Xt);It();break;case"import":if(!lt)throw xt(Xt);Rt();break;case"syntax":if(!lt)throw xt(Xt);Pt();break;case"option":Lt(yt,Xt),at(";");break;default:if(jt(yt,Xt)){lt=!1;continue}throw xt(Xt)}return parse$1.filename=null,{package:dt,imports:ht,weakImports:pt,syntax:mt,root:et}}var common_1=common,commonRe=/\/|\./;function common(o,et){commonRe.test(o)||(o="google/protobuf/"+o+".proto",et={nested:{google:{nested:{protobuf:{nested:et}}}}}),common[o]=et}common("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}});var timeType;common("duration",{Duration:timeType={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}});common("timestamp",{Timestamp:timeType});common("empty",{Empty:{fields:{}}});common("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}});common("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}});common("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}});common.get=function o(et){return common[et]||null};var protobuf$1=src.exports=indexLightExports;protobuf$1.build="full";protobuf$1.tokenize=tokenize_1;protobuf$1.parse=parse_1;protobuf$1.common=common_1;protobuf$1.Root._configure(protobuf$1.Type,protobuf$1.parse,protobuf$1.common);var srcExports=src.exports,protobufjs=srcExports;const protobuf=getDefaultExportFromCjs(protobufjs),WAKU_NODE_OPTIONS={defaultBootstrap:!0,nodeToUse:{store:"/dns4/boot-01.do-ams3.status.staging.status.im/tcp/443/wss/p2p/16Uiu2HAmEqqio4UR1SWqAc7KY19t6qyDvtmyjreZpzUBJvb4u65R"}},contentTopic="/buddybook-devcon/1/chain/proto",encoder=createEncoder({contentTopic,ephemeral:!1}),decoder=createDecoder(contentTopic),block=new protobuf.Type("block").add(new protobuf.Field("chainUUID",1,"string")).add(new protobuf.Field("blockUUID",2,"string")).add(new protobuf.Field("title",3,"string")).add(new protobuf.Field("description",4,"string")).add(new protobuf.Field("signedMessage",5,"string")).add(new protobuf.Field("timestamp",6,"uint64")).add(new protobuf.Field("signatures",7,"string","repeated")).add(new protobuf.Field("parentBlockUUID",8,"string"));function createMessage({chainUUID:o,blockUUID:et,title:tt,description:nt,signedMessage:rt,timestamp:ot,signatures:it,parentBlockUUID:st}){const at=block.create({chainUUID:o,blockUUID:et,title:tt,description:nt,signedMessage:rt,timestamp:ot,signatures:it.map(lt=>JSON.stringify(lt)),parentBlockUUID:st});return{payload:block.encode(at).finish()}}async function*getMessagesFromStore(o){console.time("getMessagesFromStore");try{for await(const et of o.store.queryGenerator([decoder])){const tt=await Promise.all(et);for(const nt of tt){if(!(nt!=null&&nt.payload))continue;const rt=block.decode(nt.payload);rt.signatures=rt.signatures.map(ot=>JSON.parse(ot)),yield rt}}}finally{console.timeEnd("getMessagesFromStore")}}async function subscribeToFilter(o,et){const{error:tt,subscription:nt,results:rt}=await o.filter.subscribe([decoder],ot=>{if(console.log("message received from filter",ot),ot.payload){const it=block.decode(ot.payload);it.signatures=it.signatures.map(st=>JSON.parse(st)),et(it)}});if(console.log("results",rt),tt&&console.log("Error subscribing to filter",tt),!nt||tt||rt.successes.length===0||rt.failures.length>0)throw new Error("Failed to subscribe to filter")}function useWalletPrompt(){const{isConnected:o}=useAccount(),{connect:et,connectors:tt}=useConnect$1();return{ensureWalletConnected:async()=>{if(!o)try{const rt=tt[0];if(rt)return/iPad|iPhone|iPod/.test(navigator.userAgent)&&(window.location.href="metamask:///",await new Promise(it=>setTimeout(it,1e3))),await et({connector:rt}),await new Promise(it=>setTimeout(it,1e3)),!0}catch(rt){return console.error("Error connecting wallet:",rt),typeof window.ethereum>"u"&&window.open("https://metamask.io/download/","_blank"),!1}return!0}}}const DEFAULT_FORM_DATA={title:"Devcon24 DeFi Dynamo",description:"A revolutionary blockchain for Devcon 24, focusing on scalable DeFi solutions and cross-chain interoperability.",uuid:v4()},ChainCreationForm=()=>{const[o,et]=reactExports.useState(DEFAULT_FORM_DATA),[tt,nt]=reactExports.useState({}),[rt,ot]=reactExports.useState(!1),[it,st]=reactExports.useState(!1),[at,ct]=reactExports.useState(!1),[lt,dt]=reactExports.useState(null),[ht,pt]=reactExports.useState(null),[mt,ft]=reactExports.useState(null),{node:yt}=useWaku(),{address:gt}=useAccount(),{signMessage:xt}=useSignMessage({mutation:{async onSuccess(Rt){if(!gt||!yt)return;pt(Rt);const Pt=v4();ft(Pt);const jt=createMessage({chainUUID:o.uuid,blockUUID:Pt,title:o.title,description:o.description,signedMessage:Rt,timestamp:Date.now(),signatures:[{address:gt,signature:Rt}],parentBlockUUID:null});await(yt==null?void 0:yt.lightPush.send(encoder,jt)),ct(!0),st(!1)},onError(Rt){console.error("Error signing message:",Rt),st(!1),dt("Error signing message. Please try again.")}}}),{ensureWalletConnected:vt}=useWalletPrompt(),bt=Rt=>{const{name:Pt,value:jt}=Rt.target;et(Ot=>({...Ot,[Pt]:jt})),tt[Pt]&&nt(Ot=>({...Ot,[Pt]:void 0}))},Et=()=>{const Rt={};return o.title.trim()||(Rt.title="Title is required"),o.description.trim()||(Rt.description="Description is required"),nt(Rt),Object.keys(Rt).length===0},wt=Rt=>{Rt.preventDefault(),vt()&&Et()&&ot(!0)},kt=async()=>{st(!0),dt(null);const Rt=`Create Chain: Chain UUID: ${o.uuid} Title: ${o.title} Description: ${o.description} diff --git a/buddybook/assets/index-DOzQxzSO.js b/buddybook/assets/index-CHNnLDtA.js similarity index 99% rename from buddybook/assets/index-DOzQxzSO.js rename to buddybook/assets/index-CHNnLDtA.js index 76bd215..ec89fa8 100644 --- a/buddybook/assets/index-DOzQxzSO.js +++ b/buddybook/assets/index-CHNnLDtA.js @@ -1,4 +1,4 @@ -import{T as $t,M as re,R as N,E as k,C as $,a as X,b as Bo,O as Z,c as ht}from"./index-Dzj92ueM.js";import{C as Wo}from"./index-uonIXzgQ.js";class Uo{setAnimation(t){this.animation=t,t==null||t.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}function jo(e,t){e.indexOf(t)===-1&&e.push(t)}const Gr=(e,t,r)=>Math.min(Math.max(r,e),t),V={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},ne=e=>typeof e=="number",bt=e=>Array.isArray(e)&&!ne(e[0]),ko=(e,t,r)=>{const n=t-e;return((r-e)%n+n)%n+e};function Ho(e,t){return bt(e)?e[ko(0,e.length,t)]:e}const Jr=(e,t,r)=>-r*e+r*t+e,Qr=()=>{},et=e=>e,ur=(e,t,r)=>t-e===0?1:(r-e)/(t-e);function Xr(e,t){const r=e[e.length-1];for(let n=1;n<=t;n++){const o=ur(0,t,n);e.push(Jr(r,1,o))}}function zo(e){const t=[0];return Xr(t,e-1),t}function Fo(e,t=zo(e.length),r=et){const n=e.length,o=n-t.length;return o>0&&Xr(t,o),i=>{let s=0;for(;sArray.isArray(e)&&ne(e[0]),ke=e=>typeof e=="object"&&!!e.createAnimation,xt=e=>typeof e=="function",Vo=e=>typeof e=="string",Nt={ms:e=>e*1e3,s:e=>e/1e3},eo=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e,Zo=1e-7,Ko=12;function qo(e,t,r,n,o){let i,s,l=0;do s=t+(r-t)/2,i=eo(s,n,o)-e,i>0?r=s:t=s;while(Math.abs(i)>Zo&&++lqo(i,0,1,e,r);return i=>i===0||i===1?i:eo(o(i),t,n)}const Yo=(e,t="end")=>r=>{r=t==="end"?Math.min(r,.999):Math.max(r,.001);const n=r*e,o=t==="end"?Math.floor(n):Math.ceil(n);return Gr(0,1,o/e)},Go={ease:Lt(.25,.1,.25,1),"ease-in":Lt(.42,0,1,1),"ease-in-out":Lt(.42,0,.58,1),"ease-out":Lt(0,0,.58,1)},Jo=/\((.*?)\)/;function Er(e){if(xt(e))return e;if(to(e))return Lt(...e);const t=Go[e];if(t)return t;if(e.startsWith("steps")){const r=Jo.exec(e);if(r){const n=r[1].split(",");return Yo(parseFloat(n[0]),n[1].trim())}}return et}class ro{constructor(t,r=[0,1],{easing:n,duration:o=V.duration,delay:i=V.delay,endDelay:s=V.endDelay,repeat:l=V.repeat,offset:a,direction:c="normal",autoplay:d=!0}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=et,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((h,p)=>{this.resolve=h,this.reject=p}),n=n||V.easing,ke(n)){const h=n.createAnimation(r);n=h.easing,r=h.keyframes||r,o=h.duration||o}this.repeat=l,this.easing=bt(n)?et:Er(n),this.updateDuration(o);const y=Fo(r,a,bt(n)?n.map(Er):et);this.tick=h=>{var p;i=i;let g=0;this.pauseTime!==void 0?g=this.pauseTime:g=(h-this.startTime)*this.rate,this.t=g,g/=1e3,g=Math.max(g-i,0),this.playState==="finished"&&this.pauseTime===void 0&&(g=this.totalDuration);const f=g/this.duration;let O=Math.floor(f),m=f%1;!m&&f>=1&&(m=1),m===1&&O--;const b=O%2;(c==="reverse"||c==="alternate"&&b||c==="alternate-reverse"&&!b)&&(m=1-m);const w=g>=this.totalDuration?1:Math.min(m,1),v=y(this.easing(w));t(v),this.pauseTime===void 0&&(this.playState==="finished"||g>=this.totalDuration+s)?(this.playState="finished",(p=this.resolve)===null||p===void 0||p.call(this,v)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},d&&this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(t=this.reject)===null||t===void 0||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){this.pauseTime!==void 0||this.rate===0?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}/** +import{T as $t,M as re,R as N,E as k,C as $,a as X,b as Bo,O as Z,c as ht}from"./index-Dt2-TQyK.js";import{C as Wo}from"./index-BpI4vT-j.js";class Uo{setAnimation(t){this.animation=t,t==null||t.finished.then(()=>this.clearAnimation()).catch(()=>{})}clearAnimation(){this.animation=this.generator=void 0}}function jo(e,t){e.indexOf(t)===-1&&e.push(t)}const Gr=(e,t,r)=>Math.min(Math.max(r,e),t),V={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},ne=e=>typeof e=="number",bt=e=>Array.isArray(e)&&!ne(e[0]),ko=(e,t,r)=>{const n=t-e;return((r-e)%n+n)%n+e};function Ho(e,t){return bt(e)?e[ko(0,e.length,t)]:e}const Jr=(e,t,r)=>-r*e+r*t+e,Qr=()=>{},et=e=>e,ur=(e,t,r)=>t-e===0?1:(r-e)/(t-e);function Xr(e,t){const r=e[e.length-1];for(let n=1;n<=t;n++){const o=ur(0,t,n);e.push(Jr(r,1,o))}}function zo(e){const t=[0];return Xr(t,e-1),t}function Fo(e,t=zo(e.length),r=et){const n=e.length,o=n-t.length;return o>0&&Xr(t,o),i=>{let s=0;for(;sArray.isArray(e)&&ne(e[0]),ke=e=>typeof e=="object"&&!!e.createAnimation,xt=e=>typeof e=="function",Vo=e=>typeof e=="string",Nt={ms:e=>e*1e3,s:e=>e/1e3},eo=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e,Zo=1e-7,Ko=12;function qo(e,t,r,n,o){let i,s,l=0;do s=t+(r-t)/2,i=eo(s,n,o)-e,i>0?r=s:t=s;while(Math.abs(i)>Zo&&++lqo(i,0,1,e,r);return i=>i===0||i===1?i:eo(o(i),t,n)}const Yo=(e,t="end")=>r=>{r=t==="end"?Math.min(r,.999):Math.max(r,.001);const n=r*e,o=t==="end"?Math.floor(n):Math.ceil(n);return Gr(0,1,o/e)},Go={ease:Lt(.25,.1,.25,1),"ease-in":Lt(.42,0,1,1),"ease-in-out":Lt(.42,0,.58,1),"ease-out":Lt(0,0,.58,1)},Jo=/\((.*?)\)/;function Er(e){if(xt(e))return e;if(to(e))return Lt(...e);const t=Go[e];if(t)return t;if(e.startsWith("steps")){const r=Jo.exec(e);if(r){const n=r[1].split(",");return Yo(parseFloat(n[0]),n[1].trim())}}return et}class ro{constructor(t,r=[0,1],{easing:n,duration:o=V.duration,delay:i=V.delay,endDelay:s=V.endDelay,repeat:l=V.repeat,offset:a,direction:c="normal",autoplay:d=!0}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.easing=et,this.duration=0,this.totalDuration=0,this.repeat=0,this.playState="idle",this.finished=new Promise((h,p)=>{this.resolve=h,this.reject=p}),n=n||V.easing,ke(n)){const h=n.createAnimation(r);n=h.easing,r=h.keyframes||r,o=h.duration||o}this.repeat=l,this.easing=bt(n)?et:Er(n),this.updateDuration(o);const y=Fo(r,a,bt(n)?n.map(Er):et);this.tick=h=>{var p;i=i;let g=0;this.pauseTime!==void 0?g=this.pauseTime:g=(h-this.startTime)*this.rate,this.t=g,g/=1e3,g=Math.max(g-i,0),this.playState==="finished"&&this.pauseTime===void 0&&(g=this.totalDuration);const f=g/this.duration;let O=Math.floor(f),m=f%1;!m&&f>=1&&(m=1),m===1&&O--;const b=O%2;(c==="reverse"||c==="alternate"&&b||c==="alternate-reverse"&&!b)&&(m=1-m);const w=g>=this.totalDuration?1:Math.min(m,1),v=y(this.easing(w));t(v),this.pauseTime===void 0&&(this.playState==="finished"||g>=this.totalDuration+s)?(this.playState="finished",(p=this.resolve)===null||p===void 0||p.call(this,v)):this.playState!=="idle"&&(this.frameRequestId=requestAnimationFrame(this.tick))},d&&this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime!==void 0?this.startTime=t-this.pauseTime:this.startTime||(this.startTime=t),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,this.frameRequestId=requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=this.t}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",this.frameRequestId!==void 0&&cancelAnimationFrame(this.frameRequestId),(t=this.reject)===null||t===void 0||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}updateDuration(t){this.duration=t,this.totalDuration=t*(this.repeat+1)}get currentTime(){return this.t}set currentTime(t){this.pauseTime!==void 0||this.rate===0?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause diff --git a/buddybook/assets/index-DlENImLn.js b/buddybook/assets/index-Ctx71FWU.js similarity index 99% rename from buddybook/assets/index-DlENImLn.js rename to buddybook/assets/index-Ctx71FWU.js index 3b0f9f7..6c00c3c 100644 --- a/buddybook/assets/index-DlENImLn.js +++ b/buddybook/assets/index-Ctx71FWU.js @@ -1,2 +1,2 @@ -import{B as k,k as m,c as q,e as F,t as $,n as Ye,i as Ze,I as xe,s as B,a as et,b as G,d as tt,f as p,g as W}from"./index-uonIXzgQ.js";const nt=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,st=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;class it extends k{constructor({primaryType:t,types:n}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(n))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class at extends k{constructor({type:t}){super(`Struct type "${t}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function ct(e){const{domain:t={},message:n,primaryType:s}=e,r={EIP712Domain:lt({domain:t}),...e.types};dt({domain:t,message:n,primaryType:s,types:r});const i=["0x1901"];return t&&i.push(rt({domain:t,types:r})),s!=="EIP712Domain"&&i.push(K({data:n,primaryType:s,types:r})),m(q(i))}function rt({domain:e,types:t}){return K({data:e,primaryType:"EIP712Domain",types:t})}function K({data:e,primaryType:t,types:n}){const s=X({data:e,primaryType:t,types:n});return m(s)}function X({data:e,primaryType:t,types:n}){const s=[{type:"bytes32"}],r=[ot({primaryType:t,types:n})];for(const i of n[t]){const[u,l]=z({types:n,name:i.name,type:i.type,value:e[i.name]});s.push(u),r.push(l)}return F(s,r)}function ot({primaryType:e,types:t}){const n=$(ut({primaryType:e,types:t}));return m(n)}function ut({primaryType:e,types:t}){let n="";const s=Q({primaryType:e,types:t});s.delete(e);const r=[e,...Array.from(s).sort()];for(const i of r)n+=`${i}(${t[i].map(({name:u,type:l})=>`${l} ${u}`).join(",")})`;return n}function Q({primaryType:e,types:t},n=new Set){const s=e.match(/^\w*/u),r=s==null?void 0:s[0];if(n.has(r)||t[r]===void 0)return n;n.add(r);for(const i of t[r])Q({primaryType:i.type,types:t},n);return n}function z({types:e,name:t,type:n,value:s}){if(e[n]!==void 0)return[{type:"bytes32"},m(X({data:s,primaryType:n,types:e}))];if(n==="bytes")return s=`0x${(s.length%2?"0":"")+s.slice(2)}`,[{type:"bytes32"},m(s)];if(n==="string")return[{type:"bytes32"},m($(s))];if(n.lastIndexOf("]")===n.length-1){const r=n.slice(0,n.lastIndexOf("[")),i=s.map(u=>z({name:t,type:r,types:e,value:u}));return[{type:"bytes32"},m(F(i.map(([u])=>u),i.map(([,u])=>u)))]}return[{type:n},s]}function dt(e){const{domain:t,message:n,primaryType:s,types:r}=e,i=(u,l)=>{for(const g of u){const{name:v,type:f}=g,h=l[v],N=f.match(st);if(N&&(typeof h=="number"||typeof h=="bigint")){const[M,S,L]=N;Ye(h,{signed:S==="int",size:Number.parseInt(L)/8})}if(f==="address"&&typeof h=="string"&&!Ze(h))throw new xe({address:h});const C=f.match(nt);if(C){const[M,S]=C;if(S&&B(h)!==Number.parseInt(S))throw new et({expectedSize:Number.parseInt(S),givenSize:B(h)})}const D=r[f];D&&(ft(f),i(D,h))}};if(r.EIP712Domain&&t&&i(r.EIP712Domain,t),s!=="EIP712Domain")if(r[s])i(r[s],n);else throw new it({primaryType:s,types:r})}function lt({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},typeof(e==null?void 0:e.chainId)=="number"&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function ft(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new at({type:e})}const gt=`Ethereum Signed Message: +import{B as k,k as m,c as q,e as F,t as $,n as Ye,i as Ze,I as xe,s as B,a as et,b as G,d as tt,f as p,g as W}from"./index-BpI4vT-j.js";const nt=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,st=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;class it extends k{constructor({primaryType:t,types:n}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(n))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class at extends k{constructor({type:t}){super(`Struct type "${t}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function ct(e){const{domain:t={},message:n,primaryType:s}=e,r={EIP712Domain:lt({domain:t}),...e.types};dt({domain:t,message:n,primaryType:s,types:r});const i=["0x1901"];return t&&i.push(rt({domain:t,types:r})),s!=="EIP712Domain"&&i.push(K({data:n,primaryType:s,types:r})),m(q(i))}function rt({domain:e,types:t}){return K({data:e,primaryType:"EIP712Domain",types:t})}function K({data:e,primaryType:t,types:n}){const s=X({data:e,primaryType:t,types:n});return m(s)}function X({data:e,primaryType:t,types:n}){const s=[{type:"bytes32"}],r=[ot({primaryType:t,types:n})];for(const i of n[t]){const[u,l]=z({types:n,name:i.name,type:i.type,value:e[i.name]});s.push(u),r.push(l)}return F(s,r)}function ot({primaryType:e,types:t}){const n=$(ut({primaryType:e,types:t}));return m(n)}function ut({primaryType:e,types:t}){let n="";const s=Q({primaryType:e,types:t});s.delete(e);const r=[e,...Array.from(s).sort()];for(const i of r)n+=`${i}(${t[i].map(({name:u,type:l})=>`${l} ${u}`).join(",")})`;return n}function Q({primaryType:e,types:t},n=new Set){const s=e.match(/^\w*/u),r=s==null?void 0:s[0];if(n.has(r)||t[r]===void 0)return n;n.add(r);for(const i of t[r])Q({primaryType:i.type,types:t},n);return n}function z({types:e,name:t,type:n,value:s}){if(e[n]!==void 0)return[{type:"bytes32"},m(X({data:s,primaryType:n,types:e}))];if(n==="bytes")return s=`0x${(s.length%2?"0":"")+s.slice(2)}`,[{type:"bytes32"},m(s)];if(n==="string")return[{type:"bytes32"},m($(s))];if(n.lastIndexOf("]")===n.length-1){const r=n.slice(0,n.lastIndexOf("[")),i=s.map(u=>z({name:t,type:r,types:e,value:u}));return[{type:"bytes32"},m(F(i.map(([u])=>u),i.map(([,u])=>u)))]}return[{type:n},s]}function dt(e){const{domain:t,message:n,primaryType:s,types:r}=e,i=(u,l)=>{for(const g of u){const{name:v,type:f}=g,h=l[v],N=f.match(st);if(N&&(typeof h=="number"||typeof h=="bigint")){const[M,S,L]=N;Ye(h,{signed:S==="int",size:Number.parseInt(L)/8})}if(f==="address"&&typeof h=="string"&&!Ze(h))throw new xe({address:h});const C=f.match(nt);if(C){const[M,S]=C;if(S&&B(h)!==Number.parseInt(S))throw new et({expectedSize:Number.parseInt(S),givenSize:B(h)})}const D=r[f];D&&(ft(f),i(D,h))}};if(r.EIP712Domain&&t&&i(r.EIP712Domain,t),s!=="EIP712Domain")if(r[s])i(r[s],n);else throw new it({primaryType:s,types:r})}function lt({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},typeof(e==null?void 0:e.chainId)=="number"&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function ft(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new at({type:e})}const gt=`Ethereum Signed Message: `;function ht(e){const t=typeof e=="string"?G(e):typeof e.raw=="string"?e.raw:tt(e.raw),n=G(`${gt}${B(t)}`);return q([n,t])}function Et(e,t){return m(ht(e),t)}const yt=()=>"9.1.0",_t=e=>e.toString(16).padStart(2,"0"),Tt=e=>{const t=new Uint8Array(e/2);return window.crypto.getRandomValues(t),Array.from(t,_t).join("")},vt=()=>typeof window<"u"?Tt(10):new Date().getTime().toString(36);class w{}w.makeRequest=(e,t)=>({id:vt(),method:e,params:t,env:{sdkVersion:yt()}});w.makeResponse=(e,t,n)=>({id:e,success:!0,version:n,data:t});w.makeErrorResponse=(e,t,n)=>({id:e,success:!1,error:t,version:n});var E;(function(e){e.sendTransactions="sendTransactions",e.rpcCall="rpcCall",e.getChainInfo="getChainInfo",e.getSafeInfo="getSafeInfo",e.getTxBySafeTxHash="getTxBySafeTxHash",e.getSafeBalances="getSafeBalances",e.signMessage="signMessage",e.signTypedMessage="signTypedMessage",e.getEnvironmentInfo="getEnvironmentInfo",e.getOffChainSignature="getOffChainSignature",e.requestAddressBook="requestAddressBook",e.wallet_getPermissions="wallet_getPermissions",e.wallet_requestPermissions="wallet_requestPermissions"})(E||(E={}));var H;(function(e){e.requestAddressBook="requestAddressBook"})(H||(H={}));class It{constructor(t=null,n=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer=typeof window>"u",this.isValidMessage=({origin:s,data:r,source:i})=>{const u=!r,l=!this.isServer&&i===window.parent,g=typeof r.version<"u"&&parseInt(r.version.split(".")[0]),v=typeof g=="number"&&g>=1;let f=!0;return Array.isArray(this.allowedOrigins)&&(f=this.allowedOrigins.find(h=>h.test(s))!==void 0),!u&&l&&v&&f},this.logIncomingMessage=s=>{console.info(`Safe Apps SDK v1: A message was received from origin ${s.origin}. `,s.data)},this.onParentMessage=s=>{this.isValidMessage(s)&&(this.debugMode&&this.logIncomingMessage(s),this.handleIncomingMessage(s.data))},this.handleIncomingMessage=s=>{const{id:r}=s,i=this.callbacks.get(r);i&&(i(s),this.callbacks.delete(r))},this.send=(s,r)=>{const i=w.makeRequest(s,r);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(i,"*"),new Promise((u,l)=>{this.callbacks.set(i.id,g=>{if(!g.success){l(new Error(g.error));return}u(g)})})},this.allowedOrigins=t,this.debugMode=n,this.isServer||window.addEventListener("message",this.onParentMessage)}}const J=e=>typeof e=="object"&&e!=null&&"domain"in e&&"types"in e&&"message"in e;var At={},_={},T={},j=p&&p.__awaiter||function(e,t,n,s){function r(i){return i instanceof n?i:new n(function(u){u(i)})}return new(n||(n=Promise))(function(i,u){function l(f){try{v(s.next(f))}catch(h){u(h)}}function g(f){try{v(s.throw(f))}catch(h){u(h)}}function v(f){f.done?i(f.value):r(f.value).then(l,g)}v((s=s.apply(e,t||[])).next())})};Object.defineProperty(T,"__esModule",{value:!0});T.getData=T.fetchData=T.stringifyQuery=T.insertParams=void 0;const mt=e=>typeof e=="object"&&e!==null&&"code"in e&&"message"in e;function St(e,t,n){return e.replace(new RegExp(`\\{${t}\\}`,"g"),n)}function Ot(e,t){return t?Object.keys(t).reduce((n,s)=>St(n,s,String(t[s])),e):e}T.insertParams=Ot;function pt(e){if(!e)return"";const t=new URLSearchParams;Object.keys(e).forEach(s=>{e[s]!=null&&t.append(s,String(e[s]))});const n=t.toString();return n?`?${n}`:""}T.stringifyQuery=pt;function Y(e){return j(this,void 0,void 0,function*(){let t;try{t=yield e.json()}catch{t={}}if(!e.ok){const n=mt(t)?`CGW error - ${t.code}: ${t.message}`:`CGW error - status ${e.statusText}`;throw new Error(n)}return t})}function bt(e,t,n,s,r){return j(this,void 0,void 0,function*(){const i=Object.assign({"Content-Type":"application/json"},s),u={method:t??"POST",headers:i};r&&(u.credentials=r),n!=null&&(u.body=typeof n=="string"?n:JSON.stringify(n));const l=yield fetch(e,u);return Y(l)})}T.fetchData=bt;function Nt(e,t,n){return j(this,void 0,void 0,function*(){const s={method:"GET"};t&&(s.headers=Object.assign(Object.assign({},t),{"Content-Type":"application/json"})),n&&(s.credentials=n);const r=yield fetch(e,s);return Y(r)})}T.getData=Nt;Object.defineProperty(_,"__esModule",{value:!0});_.getEndpoint=_.deleteEndpoint=_.putEndpoint=_.postEndpoint=void 0;const O=T;function P(e,t,n,s){const r=(0,O.insertParams)(t,n),i=(0,O.stringifyQuery)(s);return`${e}${r}${i}`}function Ct(e,t,n){const s=P(e,t,n==null?void 0:n.path,n==null?void 0:n.query);return(0,O.fetchData)(s,"POST",n==null?void 0:n.body,n==null?void 0:n.headers,n==null?void 0:n.credentials)}_.postEndpoint=Ct;function Dt(e,t,n){const s=P(e,t,n==null?void 0:n.path,n==null?void 0:n.query);return(0,O.fetchData)(s,"PUT",n==null?void 0:n.body,n==null?void 0:n.headers,n==null?void 0:n.credentials)}_.putEndpoint=Dt;function wt(e,t,n){const s=P(e,t,n==null?void 0:n.path,n==null?void 0:n.query);return(0,O.fetchData)(s,"DELETE",n==null?void 0:n.body,n==null?void 0:n.headers,n==null?void 0:n.credentials)}_.deleteEndpoint=wt;function Pt(e,t,n,s){if(s)return(0,O.getData)(s,void 0,n==null?void 0:n.credentials);const r=P(e,t,n==null?void 0:n.path,n==null?void 0:n.query);return(0,O.getData)(r,n==null?void 0:n.headers,n==null?void 0:n.credentials)}_.getEndpoint=Pt;var R={};Object.defineProperty(R,"__esModule",{value:!0});R.DEFAULT_BASE_URL=void 0;R.DEFAULT_BASE_URL="https://safe-client.safe.global";var Z={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,function(t){t.UP_TO_DATE="UP_TO_DATE",t.OUTDATED="OUTDATED",t.UNKNOWN="UNKNOWN"}(e.ImplementationVersionState||(e.ImplementationVersionState={}))})(Z);var x={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,function(t){t.NoRestrictions="NO_RESTRICTIONS",t.DomainAllowlist="DOMAIN_ALLOWLIST"}(e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})),function(t){t.BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS"}(e.SafeAppFeatures||(e.SafeAppFeatures={})),function(t){t.TWITTER="TWITTER",t.GITHUB="GITHUB",t.DISCORD="DISCORD"}(e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={}))})(x);var ee={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.StartTimeValue=e.DurationType=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,function(t){t[t.CALL=0]="CALL",t[t.DELEGATE=1]="DELEGATE"}(e.Operation||(e.Operation={})),function(t){t.AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",t.AWAITING_EXECUTION="AWAITING_EXECUTION",t.CANCELLED="CANCELLED",t.FAILED="FAILED",t.SUCCESS="SUCCESS"}(e.TransactionStatus||(e.TransactionStatus={})),function(t){t.INCOMING="INCOMING",t.OUTGOING="OUTGOING",t.UNKNOWN="UNKNOWN"}(e.TransferDirection||(e.TransferDirection={})),function(t){t.ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_COIN="NATIVE_COIN"}(e.TransactionTokenType||(e.TransactionTokenType={})),function(t){t.SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",t.ADD_OWNER="ADD_OWNER",t.REMOVE_OWNER="REMOVE_OWNER",t.SWAP_OWNER="SWAP_OWNER",t.CHANGE_THRESHOLD="CHANGE_THRESHOLD",t.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",t.ENABLE_MODULE="ENABLE_MODULE",t.DISABLE_MODULE="DISABLE_MODULE",t.SET_GUARD="SET_GUARD",t.DELETE_GUARD="DELETE_GUARD"}(e.SettingsInfoType||(e.SettingsInfoType={})),function(t){t.TRANSFER="Transfer",t.SETTINGS_CHANGE="SettingsChange",t.CUSTOM="Custom",t.CREATION="Creation",t.SWAP_ORDER="SwapOrder",t.TWAP_ORDER="TwapOrder",t.SWAP_TRANSFER="SwapTransfer"}(e.TransactionInfoType||(e.TransactionInfoType={})),function(t){t.NONE="None",t.HAS_NEXT="HasNext",t.END="End"}(e.ConflictType||(e.ConflictType={})),function(t){t.TRANSACTION="TRANSACTION",t.LABEL="LABEL",t.CONFLICT_HEADER="CONFLICT_HEADER",t.DATE_LABEL="DATE_LABEL"}(e.TransactionListItemType||(e.TransactionListItemType={})),function(t){t.MULTISIG="MULTISIG",t.MODULE="MODULE"}(e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})),function(t){t.AUTO="AUTO",t.LIMIT_DURATION="LIMIT_DURATION"}(e.DurationType||(e.DurationType={})),function(t){t.AT_MINING_TIME="AT_MINING_TIME",t.AT_EPOCH="AT_EPOCH"}(e.StartTimeValue||(e.StartTimeValue={})),function(t){t.Queued="Queued",t.Next="Next"}(e.LabelValue||(e.LabelValue={}))})(ee);var te={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,function(t){t.API_KEY_PATH="API_KEY_PATH",t.NO_AUTHENTICATION="NO_AUTHENTICATION",t.UNKNOWN="UNKNOWN"}(e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})),function(t){t.ORACLE="ORACLE",t.FIXED="FIXED",t.FIXED_1559="FIXED1559",t.UNKNOWN="UNKNOWN"}(e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})),function(t){t.ERC721="ERC721",t.SAFE_APPS="SAFE_APPS",t.CONTRACT_INTERACTION="CONTRACT_INTERACTION",t.DOMAIN_LOOKUP="DOMAIN_LOOKUP",t.SPENDING_LIMIT="SPENDING_LIMIT",t.EIP1559="EIP1559",t.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",t.TX_SIMULATION="TX_SIMULATION",t.EIP1271="EIP1271"}(e.FEATURES||(e.FEATURES={}))})(te);var ne={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,function(t){t.ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_TOKEN="NATIVE_TOKEN"}(e.TokenType||(e.TokenType={}))})(ne);var se={};Object.defineProperty(se,"__esModule",{value:!0});var ie={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ConfirmationViewTypes=void 0,function(t){t.COW_SWAP_ORDER="COW_SWAP_ORDER",t.COW_SWAP_TWAP_ORDER="COW_SWAP_TWAP_ORDER"}(e.ConfirmationViewTypes||(e.ConfirmationViewTypes={}))})(ie);var ae={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,function(t){t.DATE_LABEL="DATE_LABEL",t.MESSAGE="MESSAGE"}(e.SafeMessageListItemType||(e.SafeMessageListItemType={})),function(t){t.NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",t.CONFIRMED="CONFIRMED"}(e.SafeMessageStatus||(e.SafeMessageStatus={}))})(ae);var ce={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DeviceType=void 0,function(t){t.ANDROID="ANDROID",t.IOS="IOS",t.WEB="WEB"}(e.DeviceType||(e.DeviceType={}))})(ce);var re={};Object.defineProperty(re,"__esModule",{value:!0});(function(e){var t=p&&p.__createBinding||(Object.create?function(a,c,o,d){d===void 0&&(d=o);var A=Object.getOwnPropertyDescriptor(c,o);(!A||("get"in A?!c.__esModule:A.writable||A.configurable))&&(A={enumerable:!0,get:function(){return c[o]}}),Object.defineProperty(a,d,A)}:function(a,c,o,d){d===void 0&&(d=o),a[d]=c[o]}),n=p&&p.__exportStar||function(a,c){for(var o in a)o!=="default"&&!Object.prototype.hasOwnProperty.call(c,o)&&t(c,a,o)};Object.defineProperty(e,"__esModule",{value:!0}),e.deleteAccount=e.getAccount=e.createAccount=e.verifyAuth=e.getAuthNonce=e.getContract=e.getSafeOverviews=e.unsubscribeAll=e.unsubscribeSingle=e.registerRecoveryModule=e.deleteRegisteredEmail=e.getRegisteredEmail=e.verifyEmail=e.resendEmailVerificationCode=e.changeEmail=e.registerEmail=e.unregisterDevice=e.unregisterSafe=e.registerDevice=e.getDelegates=e.confirmSafeMessage=e.proposeSafeMessage=e.getSafeMessage=e.getSafeMessages=e.getDecodedData=e.getMasterCopies=e.getSafeApps=e.getChainConfig=e.getChainsConfig=e.getConfirmationView=e.proposeTransaction=e.getNonces=e.postSafeGasEstimation=e.deleteTransaction=e.getTransactionDetails=e.getTransactionQueue=e.getTransactionHistory=e.getCollectiblesPage=e.getCollectibles=e.getAllOwnedSafes=e.getOwnedSafes=e.getFiatCurrencies=e.getBalances=e.getMultisigTransactions=e.getModuleTransactions=e.getIncomingTransfers=e.getSafeInfo=e.getRelayCount=e.relayTransaction=e.setBaseUrl=void 0,e.putAccountDataSettings=e.getAccountDataSettings=e.getAccountDataTypes=void 0;const s=_,r=R;n(Z,e),n(x,e),n(ee,e),n(te,e),n(ne,e),n(se,e),n(ie,e),n(ae,e),n(ce,e),n(re,e);let i=r.DEFAULT_BASE_URL;const u=a=>{i=a};e.setBaseUrl=u;function l(a,c){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/relay",{path:{chainId:a},body:c})}e.relayTransaction=l;function g(a,c){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/relay/{address}",{path:{chainId:a,address:c}})}e.getRelayCount=g;function v(a,c){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:a,address:c}})}e.getSafeInfo=v;function f(a,c,o,d){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:a,address:c},query:o},d)}e.getIncomingTransfers=f;function h(a,c,o,d){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:a,address:c},query:o},d)}e.getModuleTransactions=h;function N(a,c,o,d){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:a,address:c},query:o},d)}e.getMultisigTransactions=N;function C(a,c,o="usd",d={}){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:a,address:c,currency:o},query:d})}e.getBalances=C;function D(){return(0,s.getEndpoint)(i,"/v1/balances/supported-fiat-codes")}e.getFiatCurrencies=D;function M(a,c){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:a,address:c}})}e.getOwnedSafes=M;function S(a){return(0,s.getEndpoint)(i,"/v1/owners/{address}/safes",{path:{address:a}})}e.getAllOwnedSafes=S;function L(a,c,o={}){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:a,address:c},query:o})}e.getCollectibles=L;function de(a,c,o={},d){return(0,s.getEndpoint)(i,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:a,address:c},query:o},d)}e.getCollectiblesPage=de;function le(a,c,o={},d){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:a,safe_address:c},query:o},d)}e.getTransactionHistory=le;function fe(a,c,o={},d){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:a,safe_address:c},query:o},d)}e.getTransactionQueue=fe;function ge(a,c){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:a,transactionId:c}})}e.getTransactionDetails=ge;function he(a,c,o){return(0,s.deleteEndpoint)(i,"/v1/chains/{chainId}/transactions/{safeTxHash}",{path:{chainId:a,safeTxHash:c},body:{signature:o}})}e.deleteTransaction=he;function Ee(a,c,o){return(0,s.postEndpoint)(i,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:a,safe_address:c},body:o})}e.postSafeGasEstimation=Ee;function ye(a,c){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/nonces",{path:{chainId:a,safe_address:c}})}e.getNonces=ye;function _e(a,c,o){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:a,safe_address:c},body:o})}e.proposeTransaction=_e;function Te(a,c,o,d){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation",{path:{chainId:a,safe_address:c},body:{data:o,to:d}})}e.getConfirmationView=Te;function ve(a){return(0,s.getEndpoint)(i,"/v1/chains",{query:a})}e.getChainsConfig=ve;function Ie(a){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}",{path:{chainId:a}})}e.getChainConfig=Ie;function Ae(a,c={}){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safe-apps",{path:{chainId:a},query:c})}e.getSafeApps=Ae;function me(a){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:a}})}e.getMasterCopies=me;function Se(a,c,o){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/data-decoder",{path:{chainId:a},body:{data:c,to:o}})}e.getDecodedData=Se;function Oe(a,c,o){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:a,safe_address:c},query:{}},o)}e.getSafeMessages=Oe;function pe(a,c){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:a,message_hash:c}})}e.getSafeMessage=pe;function be(a,c,o){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:a,safe_address:c},body:o})}e.proposeSafeMessage=be;function Ne(a,c,o){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:a,message_hash:c},body:o})}e.confirmSafeMessage=Ne;function Ce(a,c={}){return(0,s.getEndpoint)(i,"/v2/chains/{chainId}/delegates",{path:{chainId:a},query:c})}e.getDelegates=Ce;function De(a){return(0,s.postEndpoint)(i,"/v1/register/notifications",{body:a})}e.registerDevice=De;function we(a,c,o){return(0,s.deleteEndpoint)(i,"/v1/chains/{chainId}/notifications/devices/{uuid}/safes/{safe_address}",{path:{chainId:a,safe_address:c,uuid:o}})}e.unregisterSafe=we;function Pe(a,c){return(0,s.deleteEndpoint)(i,"/v1/chains/{chainId}/notifications/devices/{uuid}",{path:{chainId:a,uuid:c}})}e.unregisterDevice=Pe;function Re(a,c,o,d){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/emails",{path:{chainId:a,safe_address:c},body:o,headers:d})}e.registerEmail=Re;function Me(a,c,o,d,A){return(0,s.putEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}",{path:{chainId:a,safe_address:c,signer:o},body:d,headers:A})}e.changeEmail=Me;function Le(a,c,o){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify-resend",{path:{chainId:a,safe_address:c,signer:o},body:""})}e.resendEmailVerificationCode=Le;function Be(a,c,o,d){return(0,s.putEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}/verify",{path:{chainId:a,safe_address:c,signer:o},body:d})}e.verifyEmail=Be;function He(a,c,o,d){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}",{path:{chainId:a,safe_address:c,signer:o},headers:d})}e.getRegisteredEmail=He;function Ue(a,c,o,d){return(0,s.deleteEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/emails/{signer}",{path:{chainId:a,safe_address:c,signer:o},headers:d})}e.deleteRegisteredEmail=Ue;function je(a,c,o){return(0,s.postEndpoint)(i,"/v1/chains/{chainId}/safes/{safe_address}/recovery",{path:{chainId:a,safe_address:c},body:o})}e.registerRecoveryModule=je;function Ge(a){return(0,s.deleteEndpoint)(i,"/v1/subscriptions",{query:a})}e.unsubscribeSingle=Ge;function We(a){return(0,s.deleteEndpoint)(i,"/v1/subscriptions/all",{query:a})}e.unsubscribeAll=We;function Ve(a,c){return(0,s.getEndpoint)(i,"/v1/safes",{query:Object.assign(Object.assign({},c),{safes:a.join(",")})})}e.getSafeOverviews=Ve;function ke(a,c){return(0,s.getEndpoint)(i,"/v1/chains/{chainId}/contracts/{contractAddress}",{path:{chainId:a,contractAddress:c}})}e.getContract=ke;function qe(){return(0,s.getEndpoint)(i,"/v1/auth/nonce",{credentials:"include"})}e.getAuthNonce=qe;function Fe(a){return(0,s.postEndpoint)(i,"/v1/auth/verify",{body:a,credentials:"include"})}e.verifyAuth=Fe;function $e(a){return(0,s.postEndpoint)(i,"/v1/accounts",{body:a,credentials:"include"})}e.createAccount=$e;function Ke(a){return(0,s.getEndpoint)(i,"/v1/accounts/{address}",{path:{address:a},credentials:"include"})}e.getAccount=Ke;function Xe(a){return(0,s.deleteEndpoint)(i,"/v1/accounts/{address}",{path:{address:a},credentials:"include"})}e.deleteAccount=Xe;function Qe(){return(0,s.getEndpoint)(i,"/v1/accounts/data-types")}e.getAccountDataTypes=Qe;function ze(a){return(0,s.getEndpoint)(i,"/v1/accounts/{address}/data-settings",{path:{address:a},credentials:"include"})}e.getAccountDataSettings=ze;function Je(a,c){return(0,s.putEndpoint)(i,"/v1/accounts/{address}/data-settings",{path:{address:a},body:c,credentials:"include"})}e.putAccountDataSettings=Je})(At);class Rt{constructor(t){this.communicator=t}async getBySafeTxHash(t){if(!t)throw new Error("Invalid safeTxHash");return(await this.communicator.send(E.getTxBySafeTxHash,{safeTxHash:t})).data}async signMessage(t){const n={message:t};return(await this.communicator.send(E.signMessage,n)).data}async signTypedMessage(t){if(!J(t))throw new Error("Invalid typed data");return(await this.communicator.send(E.signTypedMessage,{typedData:t})).data}async send({txs:t,params:n}){if(!t||!t.length)throw new Error("No transactions were passed");const s={txs:t,params:n};return(await this.communicator.send(E.sendTransactions,s)).data}}const y={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},I={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};class Mt{constructor(t){this.communicator=t,this.call=this.buildRequest({call:y.eth_call,formatters:[null,I.defaultBlockParam]}),this.getBalance=this.buildRequest({call:y.eth_getBalance,formatters:[null,I.defaultBlockParam]}),this.getCode=this.buildRequest({call:y.eth_getCode,formatters:[null,I.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:y.eth_getStorageAt,formatters:[null,I.blockNumberToHex,I.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:y.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:y.eth_getBlockByHash,formatters:[null,I.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:y.eth_getBlockByNumber,formatters:[I.blockNumberToHex,I.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:y.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:y.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:y.eth_getTransactionCount,formatters:[null,I.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:y.eth_gasPrice}),this.getEstimateGas=n=>this.buildRequest({call:y.eth_estimateGas})([n]),this.setSafeSettings=this.buildRequest({call:y.safe_setSettings})}buildRequest(t){const{call:n,formatters:s}=t;return async r=>{s&&Array.isArray(r)&&s.forEach((l,g)=>{l&&(r[g]=l(r[g]))});const i={call:n,params:r||[]};return(await this.communicator.send(E.rpcCall,i)).data}}}const Lt="0x1626ba7e",Bt="0x20c13b0b",U=4001;class b extends Error{constructor(t,n,s){super(t),this.code=n,this.data=s,Object.setPrototypeOf(this,b.prototype)}}class oe{constructor(t){this.communicator=t}async getPermissions(){return(await this.communicator.send(E.wallet_getPermissions,void 0)).data}async requestPermissions(t){if(!this.isPermissionRequestValid(t))throw new b("Permissions request is invalid",U);try{return(await this.communicator.send(E.wallet_requestPermissions,t)).data}catch{throw new b("Permissions rejected",U)}}isPermissionRequestValid(t){return t.every(n=>typeof n=="object"?Object.keys(n).every(s=>!!Object.values(H).includes(s)):!1)}}const V=(e,t)=>t.some(n=>n.parentCapability===e),Ht=()=>(e,t,n)=>{const s=n.value;return n.value=async function(){const r=new oe(this.communicator);let i=await r.getPermissions();if(V(t,i)||(i=await r.requestPermissions([{[t]:{}}])),!V(t,i))throw new b("Permissions rejected",U);return s.apply(this)},n};var Ut=function(e,t,n,s){var r=arguments.length,i=r<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(u=e[l])&&(i=(r<3?u(i):r>3?u(t,n,i):u(t,n))||i);return r>3&&i&&Object.defineProperty(t,n,i),i};class ue{constructor(t){this.communicator=t}async getChainInfo(){return(await this.communicator.send(E.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(E.getSafeInfo,void 0)).data}async experimental_getBalances({currency:t="usd"}={}){return(await this.communicator.send(E.getSafeBalances,{currency:t})).data}async check1271Signature(t,n="0x"){const s=await this.getInfo(),r=W({abi:[{constant:!1,inputs:[{name:"_dataHash",type:"bytes32"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[t,n]}),i={call:y.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(E.rpcCall,i)).data.slice(0,10).toLowerCase()===Lt}catch{return!1}}async check1271SignatureBytes(t,n="0x"){const s=await this.getInfo(),r=W({abi:[{constant:!1,inputs:[{name:"_data",type:"bytes"},{name:"_signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"",type:"bytes4"}],payable:!1,stateMutability:"nonpayable",type:"function"}],functionName:"isValidSignature",args:[t,n]}),i={call:y.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(E.rpcCall,i)).data.slice(0,10).toLowerCase()===Bt}catch{return!1}}calculateMessageHash(t){return Et(t)}calculateTypedMessageHash(t){const n=typeof t.domain.chainId=="object"?t.domain.chainId.toNumber():Number(t.domain.chainId);let s=t.primaryType;if(!s){const r=Object.values(t.types),i=Object.keys(t.types).filter(u=>r.every(l=>l.every(({type:g})=>g.replace("[","").replace("]","")!==u)));if(i.length===0||i.length>1)throw new Error("Please specify primaryType");s=i[0]}return ct({message:t.message,domain:{...t.domain,chainId:n,verifyingContract:t.domain.verifyingContract,salt:t.domain.salt},types:t.types,primaryType:s})}async getOffChainSignature(t){return(await this.communicator.send(E.getOffChainSignature,t)).data}async isMessageSigned(t,n="0x"){let s;if(typeof t=="string"&&(s=async()=>{const r=this.calculateMessageHash(t);return await this.isMessageHashSigned(r,n)}),J(t)&&(s=async()=>{const r=this.calculateTypedMessageHash(t);return await this.isMessageHashSigned(r,n)}),s)return await s();throw new Error("Invalid message type")}async isMessageHashSigned(t,n="0x"){const s=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const r of s)if(await r(t,n))return!0;return!1}async getEnvironmentInfo(){return(await this.communicator.send(E.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(E.requestAddressBook,void 0)).data}}Ut([Ht()],ue.prototype,"requestAddressBook",null);class Gt{constructor(t={}){const{allowedDomains:n=null,debug:s=!1}=t;this.communicator=new It(n,s),this.eth=new Mt(this.communicator),this.txs=new Rt(this.communicator),this.safe=new ue(this.communicator),this.wallet=new oe(this.communicator)}}export{w as MessageFormatter,E as Methods,y as RPC_CALLS,H as RestrictedMethods,Gt as default,yt as getSDKVersion,J as isObjectEIP712TypedData}; diff --git a/buddybook/assets/index-BpmIcSNW.js b/buddybook/assets/index-DskNhwDJ.js similarity index 96% rename from buddybook/assets/index-BpmIcSNW.js rename to buddybook/assets/index-DskNhwDJ.js index 0f99731..5d82304 100644 --- a/buddybook/assets/index-BpmIcSNW.js +++ b/buddybook/assets/index-DskNhwDJ.js @@ -1 +1 @@ -import{h as p}from"./index-uonIXzgQ.js";import{e as _}from"./events-xQ4utD7e.js";function m(n,a){for(var i=0;ie[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var l={},g={},f={};Object.defineProperty(f,"__esModule",{value:!0});f.getLowerCase=void 0;function w(n){return n&&n.toLowerCase()}f.getLowerCase=w;Object.defineProperty(g,"__esModule",{value:!0});g.SafeAppProvider=void 0;const k=_,u=f;class y extends k.EventEmitter{constructor(a,i){super(),this.submittedTxs=new Map,this.safe=a,this.sdk=i}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(a){const{method:i,params:e=[]}=a;switch(i){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[t,r]=e;if(this.safe.safeAddress.toLowerCase()!==r.toLowerCase())throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(t);return("signature"in h?h.signature:void 0)||"0x"}case"eth_sign":{const[t,r]=e;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase()||!r.startsWith("0x"))throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(r);return("signature"in h?h.signature:void 0)||"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[t,r]=e,h=typeof r=="string"?JSON.parse(r):r;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address is invalid");const c=await this.sdk.txs.signTypedMessage(h);return("signature"in c?c.signature:void 0)||"0x"}case"eth_sendTransaction":const s={...e[0],value:e[0].value||"0",data:e[0].data||"0x"};typeof s.gas=="string"&&s.gas.startsWith("0x")&&(s.gas=parseInt(s.gas,16));const o=await this.sdk.txs.send({txs:[s],params:{safeTxGas:s.gas}});return this.submittedTxs.set(o.safeTxHash,{from:this.safe.safeAddress,hash:o.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:s.data,value:s.value,to:s.to,blockHash:null,blockNumber:null,transactionIndex:null}),o.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,u.getLowerCase)(e[0]),e[1],e[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([e[0],e[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([e[0],e[1]]);case"eth_getTransactionByHash":let d=e[0];try{d=(await this.sdk.txs.getBySafeTxHash(d)).txHash||d}catch{}return this.submittedTxs.has(d)?this.submittedTxs.get(d):this.sdk.eth.getTransactionByHash([d]).then(t=>(t&&(t.hash=e[0]),t));case"eth_getTransactionReceipt":{let t=e[0];try{t=(await this.sdk.txs.getBySafeTxHash(t)).txHash||t}catch{}return this.sdk.eth.getTransactionReceipt([t]).then(r=>(r&&(r.transactionHash=e[0]),r))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(e[0]);case"eth_call":return this.sdk.eth.call([e[0],e[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([e[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(e[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([e[0]]);default:throw Error(`"${a.method}" not implemented`)}}send(a,i){a||i("Undefined request"),this.request(a).then(e=>i(null,{jsonrpc:"2.0",id:a.id,result:e})).catch(e=>i(e,null))}}g.SafeAppProvider=y;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.SafeAppProvider=void 0;var a=g;Object.defineProperty(n,"SafeAppProvider",{enumerable:!0,get:function(){return a.SafeAppProvider}})})(l);const x=p(l),C=m({__proto__:null,default:x},[l]);export{C as i}; +import{h as p}from"./index-BpI4vT-j.js";import{e as _}from"./events-DyQEop7s.js";function m(n,a){for(var i=0;ie[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var l={},g={},f={};Object.defineProperty(f,"__esModule",{value:!0});f.getLowerCase=void 0;function w(n){return n&&n.toLowerCase()}f.getLowerCase=w;Object.defineProperty(g,"__esModule",{value:!0});g.SafeAppProvider=void 0;const k=_,u=f;class y extends k.EventEmitter{constructor(a,i){super(),this.submittedTxs=new Map,this.safe=a,this.sdk=i}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(a){const{method:i,params:e=[]}=a;switch(i){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[t,r]=e;if(this.safe.safeAddress.toLowerCase()!==r.toLowerCase())throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(t);return("signature"in h?h.signature:void 0)||"0x"}case"eth_sign":{const[t,r]=e;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase()||!r.startsWith("0x"))throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(r);return("signature"in h?h.signature:void 0)||"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[t,r]=e,h=typeof r=="string"?JSON.parse(r):r;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address is invalid");const c=await this.sdk.txs.signTypedMessage(h);return("signature"in c?c.signature:void 0)||"0x"}case"eth_sendTransaction":const s={...e[0],value:e[0].value||"0",data:e[0].data||"0x"};typeof s.gas=="string"&&s.gas.startsWith("0x")&&(s.gas=parseInt(s.gas,16));const o=await this.sdk.txs.send({txs:[s],params:{safeTxGas:s.gas}});return this.submittedTxs.set(o.safeTxHash,{from:this.safe.safeAddress,hash:o.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:s.data,value:s.value,to:s.to,blockHash:null,blockNumber:null,transactionIndex:null}),o.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,u.getLowerCase)(e[0]),e[1],e[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([e[0],e[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([e[0],e[1]]);case"eth_getTransactionByHash":let d=e[0];try{d=(await this.sdk.txs.getBySafeTxHash(d)).txHash||d}catch{}return this.submittedTxs.has(d)?this.submittedTxs.get(d):this.sdk.eth.getTransactionByHash([d]).then(t=>(t&&(t.hash=e[0]),t));case"eth_getTransactionReceipt":{let t=e[0];try{t=(await this.sdk.txs.getBySafeTxHash(t)).txHash||t}catch{}return this.sdk.eth.getTransactionReceipt([t]).then(r=>(r&&(r.transactionHash=e[0]),r))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(e[0]);case"eth_call":return this.sdk.eth.call([e[0],e[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([e[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(e[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([e[0]]);default:throw Error(`"${a.method}" not implemented`)}}send(a,i){a||i("Undefined request"),this.request(a).then(e=>i(null,{jsonrpc:"2.0",id:a.id,result:e})).catch(e=>i(e,null))}}g.SafeAppProvider=y;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.SafeAppProvider=void 0;var a=g;Object.defineProperty(n,"SafeAppProvider",{enumerable:!0,get:function(){return a.SafeAppProvider}})})(l);const x=p(l),C=m({__proto__:null,default:x},[l]);export{C as i}; diff --git a/buddybook/assets/index-Dzj92ueM.js b/buddybook/assets/index-Dt2-TQyK.js similarity index 98% rename from buddybook/assets/index-Dzj92ueM.js rename to buddybook/assets/index-Dt2-TQyK.js index a49590d..446cb82 100644 --- a/buddybook/assets/index-Dzj92ueM.js +++ b/buddybook/assets/index-Dt2-TQyK.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DOzQxzSO.js","assets/index-uonIXzgQ.js","assets/index-Dd5JfyyB.css"])))=>i.map(i=>d[i]); -import{_ as pe}from"./index-uonIXzgQ.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:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},J=e=>typeof e=="object"&&e!==null,L=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>J(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 b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(b,!0),l.set(o,[g,b]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(b,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(L.has(O)){const[y,H]=L.get(O);A.value=c(y,H(),I)}Object.defineProperty(b,j,A)}),Object.preventExtensions(b)},d=new WeakMap,f=[1,1],W=o=>{if(!J(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,b=(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]],b(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 N=r[3](A(U));y.set(U,[r,N])}),()=>{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&&b(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),N=Reflect.get(i,a,h);if(U&&(e(N,r)||d.has(r)&&e(N,d.get(r))))return!0;Z(a),J(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(C=>{r.status="fulfilled",r.value=C,b(["resolve",[a],C])}).catch(C=>{r.status="rejected",r.reason=C,b(["reject",[a],C])});else{!L.has(r)&&s(r)&&(V=W(r));const C=!x.has(V)&&L.get(V);C&&H(a,C)}return Reflect.set(i,a,V,h),b(["set",[a],r,N]),!0}});d.set(o,R);const fe=[q,O,c,ue];return L.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,L,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=L.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 be(e,t){const s=L.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}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(be(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}),w={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(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.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 Ce=Object.defineProperty,oe=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Le.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:[]}),ke={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}=w.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(",")),w.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}),F={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=w.state;if(m.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=w.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 k=P({themeMode:Ue()?"dark":"light"}),ce={state:k,subscribe(e){return D(k,()=>e(k))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(k.themeMode=t),s&&(k.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=F.open,this.closeModal=F.close,this.subscribeModal=F.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-DOzQxzSO.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,ke as E,F as M,w 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-CHNnLDtA.js","assets/index-BpI4vT-j.js","assets/index-Dd5JfyyB.css"])))=>i.map(i=>d[i]); +import{_ as pe}from"./index-BpI4vT-j.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:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_WALLETCONNECT_PROJECT_ID:"1d93edc21291f98e3bed6ff7617ff539"},J=e=>typeof e=="object"&&e!==null,L=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>J(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 b=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(b,!0),l.set(o,[g,b]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(b,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(L.has(O)){const[y,H]=L.get(O);A.value=c(y,H(),I)}Object.defineProperty(b,j,A)}),Object.preventExtensions(b)},d=new WeakMap,f=[1,1],W=o=>{if(!J(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,b=(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]],b(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 N=r[3](A(U));y.set(U,[r,N])}),()=>{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&&b(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),N=Reflect.get(i,a,h);if(U&&(e(N,r)||d.has(r)&&e(N,d.get(r))))return!0;Z(a),J(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(C=>{r.status="fulfilled",r.value=C,b(["resolve",[a],C])}).catch(C=>{r.status="rejected",r.reason=C,b(["reject",[a],C])});else{!L.has(r)&&s(r)&&(V=W(r));const C=!x.has(V)&&L.get(V);C&&H(a,C)}return Reflect.set(i,a,V,h),b(["set",[a],r,N]),!0}});d.set(o,R);const fe=[q,O,c,ue];return L.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,L,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=L.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 be(e,t){const s=L.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}},we=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:we,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(be(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}),w={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(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.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 Ce=Object.defineProperty,oe=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Le.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:[]}),ke={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}=w.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(",")),w.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}),F={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=w.state;if(m.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=w.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 k=P({themeMode:Ue()?"dark":"light"}),ce={state:k,subscribe(e){return D(k,()=>e(k))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(k.themeMode=t),s&&(k.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=F.open,this.closeModal=F.close,this.subscribeModal=F.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-CHNnLDtA.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,ke as E,F as M,w as O,de as R,ce as T,Re as a,Ie as b,$ as c,Ve as i}; diff --git a/buddybook/assets/index.es-C5jEvyUt.js b/buddybook/assets/index.es-BwINMB1n.js similarity index 99% rename from buddybook/assets/index.es-C5jEvyUt.js rename to buddybook/assets/index.es-BwINMB1n.js index 911702c..6570362 100644 --- a/buddybook/assets/index.es-C5jEvyUt.js +++ b/buddybook/assets/index.es-BwINMB1n.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dzj92ueM.js","assets/index-uonIXzgQ.js","assets/index-Dd5JfyyB.css"])))=>i.map(i=>d[i]); -import{j as ev,f as tv,u as w4,h as Ld,_ as _4}from"./index-uonIXzgQ.js";import{e as Vi,J as Fd}from"./events-xQ4utD7e.js";import{r as zd,i as Pf}from"./inherits_browser-Bb3-ajt6.js";var Ae={};/*! ***************************************************************************** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dt2-TQyK.js","assets/index-BpI4vT-j.js","assets/index-Dd5JfyyB.css"])))=>i.map(i=>d[i]); +import{j as ev,f as tv,u as w4,h as Ld,_ as _4}from"./index-BpI4vT-j.js";import{e as Vi,J as Fd}from"./events-DyQEop7s.js";import{r as zd,i as Pf}from"./inherits_browser-B8fZ3Rhe.js";var Ae={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any @@ -67,4 +67,4 @@ __p += '`),Tt&&(ge+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+ge+`return __p -}`;var wt=v1(function(){return Bt(F,Je+"return "+ge).apply(t,Q)});if(wt.source=ge,nl(wt))throw wt;return wt}function M5(s){return $t(s).toLowerCase()}function I5(s){return $t(s).toUpperCase()}function C5(s,o,l){if(s=$t(s),s&&(l||o===t))return S0(s);if(!s||!(o=vi(o)))return s;var A=rn(s),T=rn(o),F=M0(A,T),Q=I0(A,T)+1;return Cs(A,F,Q).join("")}function P5(s,o,l){if(s=$t(s),s&&(l||o===t))return s.slice(0,P0(s)+1);if(!s||!(o=vi(o)))return s;var A=rn(s),T=I0(A,rn(o))+1;return Cs(A,0,T).join("")}function O5(s,o,l){if(s=$t(s),s&&(l||o===t))return s.replace(it,"");if(!s||!(o=vi(o)))return s;var A=rn(s),T=M0(A,rn(o));return Cs(A,T).join("")}function T5(s,o){var l=le,A=U;if(Zt(o)){var T="separator"in o?o.separator:T;l="length"in o?yt(o.length):l,A="omission"in o?vi(o.omission):A}s=$t(s);var F=s.length;if(Ba(s)){var Q=rn(s);F=Q.length}if(l>=F)return s;var X=l-$a(A);if(X<1)return A;var ie=Q?Cs(Q,0,X).join(""):s.slice(0,X);if(T===t)return ie+A;if(Q&&(X+=ie.length-X),sl(T)){if(s.slice(X).search(T)){var he,de=ie;for(T.global||(T=_h(T.source,$t(vt.exec(T))+"g")),T.lastIndex=0;he=T.exec(de);)var ge=he.index;ie=ie.slice(0,ge===t?X:ge)}}else if(s.indexOf(vi(T),X)!=X){var Ie=ie.lastIndexOf(T);Ie>-1&&(ie=ie.slice(0,Ie))}return ie+A}function R5(s){return s=$t(s),s&&Be.test(s)?s.replace(Et,cm):s}var N5=ka(function(s,o,l){return s+(l?" ":"")+o.toUpperCase()}),cl=mp("toUpperCase");function b1(s,o,l){return s=$t(s),o=l?t:o,o===t?im(s)?hm(s):J2(s):s.match(o)||[]}var v1=Dt(function(s,o){try{return vr(s,t,o)}catch(l){return nl(l)?l:new dt(l)}}),B5=ts(function(s,o){return Pi(o,function(l){l=En(l),Zn(s,l,rl(s[l],s))}),s});function $5(s){var o=s==null?0:s.length,l=nt();return s=o?Xt(s,function(A){if(typeof A[1]!="function")throw new Oi(c);return[l(A[0]),A[1]]}):[],Dt(function(A){for(var T=-1;++TM)return[];var l=b,A=qr(s,b);o=nt(o),s-=b;for(var T=mh(A,o);++l0||o<0)?new Mt(l):(s<0?l=l.takeRight(-s):s&&(l=l.drop(s)),o!==t&&(o=yt(o),l=o<0?l.dropRight(-o):l.take(o-s)),l)},Mt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},Mt.prototype.toArray=function(){return this.take(b)},_n(Mt.prototype,function(s,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),A=/^(?:head|last)$/.test(o),T=$[A?"take"+(o=="last"?"Right":""):o],F=A||/^find/.test(o);T&&($.prototype[o]=function(){var Q=this.__wrapped__,X=A?[1]:arguments,ie=Q instanceof Mt,he=X[0],de=ie||gt(Q),ge=function(At){var Tt=T.apply($,Es([At],X));return A&&Ie?Tt[0]:Tt};de&&l&&typeof he=="function"&&he.length!=1&&(ie=de=!1);var Ie=this.__chain__,Je=!!this.__actions__.length,ot=F&&!Ie,wt=ie&&!Je;if(!F&&de){Q=wt?Q:new Mt(this);var ct=s.apply(Q,X);return ct.__actions__.push({func:Bu,args:[ge],thisArg:t}),new Ti(ct,Ie)}return ot&&wt?s.apply(this,X):(ct=this.thru(ge),ot?A?ct.value()[0]:ct.value():ct)})}),Pi(["pop","push","shift","sort","splice","unshift"],function(s){var o=ou[s],l=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",A=/^(?:pop|shift)$/.test(s);$.prototype[s]=function(){var T=arguments;if(A&&!this.__chain__){var F=this.value();return o.apply(gt(F)?F:[],T)}return this[l](function(Q){return o.apply(gt(Q)?Q:[],T)})}}),_n(Mt.prototype,function(s,o){var l=$[o];if(l){var A=l.name+"";qt.call(Fa,A)||(Fa[A]=[]),Fa[A].push({name:o,func:l})}}),Fa[Iu(t,Y).name]=[{name:"wrapper",func:t}],Mt.prototype.clone=Rm,Mt.prototype.reverse=Nm,Mt.prototype.value=Bm,$.prototype.at=f8,$.prototype.chain=h8,$.prototype.commit=l8,$.prototype.next=d8,$.prototype.plant=g8,$.prototype.reverse=b8,$.prototype.toJSON=$.prototype.valueOf=$.prototype.value=v8,$.prototype.first=$.prototype.head,Ro&&($.prototype[Ro]=p8),$},Ua=lm();sr?((sr.exports=Ua)._=Ua,kt._=Ua):Ot._=Ua}).call(ac)})($d,$d.exports);var SB=Object.defineProperty,MB=Object.defineProperties,IB=Object.getOwnPropertyDescriptors,jb=Object.getOwnPropertySymbols,CB=Object.prototype.hasOwnProperty,PB=Object.prototype.propertyIsEnumerable,kb=(r,e,t)=>e in r?SB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zu=(r,e)=>{for(var t in e||(e={}))CB.call(e,t)&&kb(r,t,e[t]);if(jb)for(var t of jb(e))PB.call(e,t)&&kb(r,t,e[t]);return r},OB=(r,e)=>MB(r,IB(e));function bn(r,e,t){var i;const n=fc(r);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${F2}?chainId=${n.namespace}:${n.reference}&projectId=${t}`}function Ca(r){return r.includes(":")?r.split(":")[1]:r}function z2(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function TB(r,e){const t=Object.keys(e.namespaces).filter(n=>n.includes(r));if(!t.length)return[];const i=[];return t.forEach(n=>{const a=e.namespaces[n].accounts;i.push(...a)}),i}function td(r={},e={}){const t=Hb(r),i=Hb(e);return $d.exports.merge(t,i)}function Hb(r){var e,t,i,n;const a={};if(!_c(r))return a;for(const[c,f]of Object.entries(r)){const g=f0(c)?[c]:f.chains,d=f.methods||[],m=f.events||[],w=f.rpcMap||{},O=uc(c);a[O]=OB(Zu(Zu({},a[O]),f),{chains:rf(g,(e=a[O])==null?void 0:e.chains),methods:rf(d,(t=a[O])==null?void 0:t.methods),events:rf(m,(i=a[O])==null?void 0:i.events),rpcMap:Zu(Zu({},w),(n=a[O])==null?void 0:n.rpcMap)})}return a}function RB(r){return r.includes(":")?r.split(":")[2]:r}function Kb(r){const e={};for(const[t,i]of Object.entries(r)){const n=i.methods||[],a=i.events||[],c=i.accounts||[],f=f0(t)?[t]:i.chains?i.chains:z2(i.accounts);e[t]={chains:f,methods:n,events:a,accounts:c}}return e}function rd(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const j2={},Ut=r=>j2[r],id=(r,e)=>{j2[r]=e};class NB{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}var BB=Object.defineProperty,$B=Object.defineProperties,UB=Object.getOwnPropertyDescriptors,Vb=Object.getOwnPropertySymbols,qB=Object.prototype.hasOwnProperty,LB=Object.prototype.propertyIsEnumerable,Gb=(r,e,t)=>e in r?BB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jb=(r,e)=>{for(var t in e||(e={}))qB.call(e,t)&&Gb(r,t,e[t]);if(Vb)for(var t of Vb(e))LB.call(e,t)&&Gb(r,t,e[t]);return r},Wb=(r,e)=>$B(r,UB(e));class FB{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("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,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(mn.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,t){const i=t||bn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=parseInt(Ca(t));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let n=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const a=parseInt(n,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. 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 t,i,n;const a=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const c=this.client.session.get(e.topic),f=((n=c==null?void 0:c.sessionProperties)==null?void 0:n.capabilities)||{};if(f!=null&&f[a])return f==null?void 0:f[a];const g=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Wb(Jb({},c.sessionProperties||{}),{capabilities:Wb(Jb({},f||{}),{[a]:g})})})}catch(d){console.warn("Failed to update session with capabilities",d)}return g}async getCallStatus(e){var t,i;const n=this.client.session.get(e.topic),a=(t=n.sessionProperties)==null?void 0:t.bundler_name;if(a){const f=this.getBundlerUrl(e.chainId,a);try{return await this.getUserOperationReceipt(f,e)}catch(g){console.warn("Failed to fetch call status from bundler",g,f)}}const c=(i=n.sessionProperties)==null?void 0:i.bundler_url;if(c)try{return await this.getUserOperationReceipt(c,e)}catch(f){console.warn("Failed to fetch call status from custom bundler",f,c)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const n=new URL(e),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Fs("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,t){return`${xB}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class zB{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class jB{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class kB{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||bn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new vn(new Wn(i,Ut("disableProviderPing")))}}class HB{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),n=Ca(t);e[n]=this.createHttpProvider(n,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class KB{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class VB{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class GB{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||bn(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace);return typeof i>"u"?void 0:new vn(new Wn(i,Ut("disableProviderPing")))}}class JB{constructor(e){this.name=Za,this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(n=>{const a=fc(n);i[`${a.namespace}:${a.reference}`]=this.createHttpProvider(n)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}var WB=Object.defineProperty,YB=Object.defineProperties,QB=Object.getOwnPropertyDescriptors,Yb=Object.getOwnPropertySymbols,XB=Object.prototype.hasOwnProperty,ZB=Object.prototype.propertyIsEnumerable,Qb=(r,e,t)=>e in r?WB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ef=(r,e)=>{for(var t in e||(e={}))XB.call(e,t)&&Qb(r,t,e[t]);if(Yb)for(var t of Yb(e))ZB.call(e,t)&&Qb(r,t,e[t]);return r},nd=(r,e)=>YB(r,QB(e));class y0{constructor(e){this.events=new Fd,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:Uc(Zf({level:(e==null?void 0:e.logger)||Fb})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new y0(e);return await t.initialize(),t}async request(e,t,i){const[n,a]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:ef({},e),chainId:`${n}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,n){const a=new Date().getTime();this.request(e,i,n).then(c=>t(null,th(a,c))).catch(c=>t(c,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:Lt("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:n}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await n();if(this.session=a.session,this.session){const c=Kb(this.session.namespaces);this.namespaces=td(this.namespaces,c),this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await n().then(a=>{this.session=a;const c=Kb(a.namespaces);this.namespaces=td(this.namespaces,c),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==L2)throw a;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,n]=this.validateChain(e),a=this.getProvider(i);a.name===Za?a.setDefaultChain(`${i}:${n}`,t):a.setDefaultChain(n,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Hn(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await m0.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Fb,relayUrl:this.providerOpts.relayUrl||DB,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(t=>uc(t)))];id("client",this.client),id("events",this.events),id("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=TB(t,this.session),n=z2(i),a=td(this.namespaces,this.optionalNamespaces),c=nd(ef({},a[t]),{accounts:i,chains:n});switch(t){case"eip155":this.rpcProviders[t]=new FB({namespace:c});break;case"algorand":this.rpcProviders[t]=new kB({namespace:c});break;case"solana":this.rpcProviders[t]=new zB({namespace:c});break;case"cosmos":this.rpcProviders[t]=new jB({namespace:c});break;case"polkadot":this.rpcProviders[t]=new NB({namespace:c});break;case"cip34":this.rpcProviders[t]=new HB({namespace:c});break;case"elrond":this.rpcProviders[t]=new KB({namespace:c});break;case"multiversx":this.rpcProviders[t]=new VB({namespace:c});break;case"near":this.rpcProviders[t]=new GB({namespace:c});break;default:this.rpcProviders[Za]?this.rpcProviders[Za].updateNamespace(c):this.rpcProviders[Za]=new JB({namespace:c})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const n=i.data;n&&Hn(n)&&this.events.emit("accountsChanged",n.map(RB))}else if(i.name==="chainChanged"){const n=t.chainId,a=t.event.data,c=uc(n),f=rd(n)!==rd(a)?`${c}:${rd(a)}`:n;this.onChainChanged(f)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:n}=t,a=(i=this.client)==null?void 0:i.session.get(e);this.session=nd(ef({},a),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",nd(ef({},Lt("USER_DISCONNECTED")),{data:e.topic}))}),this.on(mn.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Za]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:n}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=n,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(c=>uc(c)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const n=uc(Object.keys(this.namespaces)[0]),a=this.rpcProviders[n].getDefaultChain();return[n,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);n&&(t||this.getProvider(i).setDefaultChain(n),this.namespaces[i]?this.namespaces[i].defaultChain=n:this.namespaces[`${i}:${n}`]?this.namespaces[`${i}:${n}`].defaultChain=n:this.namespaces[`${i}:${n}`]={defaultChain:n},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${zb}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${zb}/${e}`)}}const e$=y0,t$="wc",r$="ethereum_provider",i$=`${t$}@2:${r$}:`,n$="https://rpc.walletconnect.org/v1/",Ud=["eth_sendTransaction","personal_sign"],s$=["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"],qd=["chainChanged","accountsChanged"],a$=["chainChanged","accountsChanged","message","disconnect","connect"];var o$=Object.defineProperty,c$=Object.defineProperties,u$=Object.getOwnPropertyDescriptors,Xb=Object.getOwnPropertySymbols,f$=Object.prototype.hasOwnProperty,h$=Object.prototype.propertyIsEnumerable,Zb=(r,e,t)=>e in r?o$(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,eo=(r,e)=>{for(var t in e||(e={}))f$.call(e,t)&&Zb(r,t,e[t]);if(Xb)for(var t of Xb(e))h$.call(e,t)&&Zb(r,t,e[t]);return r},sd=(r,e)=>c$(r,u$(e));function Cf(r){return Number(r[0].split(":")[1])}function tf(r){return`0x${r.toString(16)}`}function l$(r){const{chains:e,optionalChains:t,methods:i,optionalMethods:n,events:a,optionalEvents:c,rpcMap:f}=r;if(!Hn(e))throw new Error("Invalid chains");const g={chains:e,methods:i||Ud,events:a||qd,rpcMap:eo({},e.length?{[Cf(e)]:f[Cf(e)]}:{})},d=a==null?void 0:a.filter(C=>!qd.includes(C)),m=i==null?void 0:i.filter(C=>!Ud.includes(C));if(!t&&!c&&!n&&!(d!=null&&d.length)&&!(m!=null&&m.length))return{required:e.length?g:void 0};const w=(d==null?void 0:d.length)&&(m==null?void 0:m.length)||!t,O={chains:[...new Set(w?g.chains.concat(t||[]):t)],methods:[...new Set(g.methods.concat(n!=null&&n.length?n:s$))],events:[...new Set(g.events.concat(c!=null&&c.length?c:a$))],rpcMap:f};return{required:e.length?g:void 0,optional:t.length?O:void 0}}class w0{constructor(){this.events=new Vi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=i$,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new w0;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,i){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),i)}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:t,optional:i}=l$(this.rpc);try{const n=await new Promise(async(c,f)=>{var g;this.rpc.showQrModal&&((g=this.modal)==null||g.subscribeModal(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(sd(eo({namespaces:eo({},t&&{[this.namespace]:t})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(d=>{c(d)}).catch(d=>{f(new Error(d.message))})});if(!n)return;const a=X1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:tf(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(a,c)=>{var f;this.rpc.showQrModal&&((f=this.modal)==null||f.subscribeModal(g=>{!g.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(sd(eo({},e),{chains:this.rpc.chains}),t).then(g=>{a(g)}).catch(g=>{c(new Error(g.message))})}),n=i.session;if(n){const a=X1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:tf(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}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:t}=e,{event:i}=t;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",tf(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",sd(eo({},Lt("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,i;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(i=this.modal)==null||i.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 t=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",tf(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,i,n]=e.split(":");return{chainId:`${t}:${i}`,address:n}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;const n=(t=e==null?void 0:e.chains)!=null?t:[],a=(i=e==null?void 0:e.optionalChains)!=null?i:[],c=n.concat(a);if(!c.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const f=n.length?(e==null?void 0:e.methods)||Ud:[],g=n.length?(e==null?void 0:e.events)||qd:[],d=(e==null?void 0:e.optionalMethods)||[],m=(e==null?void 0:e.optionalEvents)||[],w=(e==null?void 0:e.rpcMap)||this.buildRpcMap(c,e.projectId),O=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:n==null?void 0:n.map(C=>this.formatChainId(C)),optionalChains:a.map(C=>this.formatChainId(C)),methods:f,events:g,optionalMethods:d,optionalEvents:m,rpcMap:w,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:O,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const i={};return e.forEach(n=>{i[n]=this.getRpcUrl(n,t)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Cf(this.rpc.chains):Cf(this.rpc.optionalChains),this.signer=await e$.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 t;try{const{WalletConnectModal:i}=await _4(()=>import("./index-Dzj92ueM.js").then(n=>n.i),__vite__mapDeps([0,1,2]));t=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(eo({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:i,rpcMap:n}=e;t&&Hn(t)&&(this.rpc.chains=t.map(a=>this.formatChainId(a)),t.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)})),i&&Hn(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(a=>this.formatChainId(a)),i.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)}))}getRpcUrl(e,t){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${n$}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}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(t=>this.parseAccount(t))}}const V$=w0;export{V$ as EthereumProvider,a$ as OPTIONAL_EVENTS,s$ as OPTIONAL_METHODS,qd as REQUIRED_EVENTS,Ud as REQUIRED_METHODS,w0 as default}; +}`;var wt=v1(function(){return Bt(F,Je+"return "+ge).apply(t,Q)});if(wt.source=ge,nl(wt))throw wt;return wt}function M5(s){return $t(s).toLowerCase()}function I5(s){return $t(s).toUpperCase()}function C5(s,o,l){if(s=$t(s),s&&(l||o===t))return S0(s);if(!s||!(o=vi(o)))return s;var A=rn(s),T=rn(o),F=M0(A,T),Q=I0(A,T)+1;return Cs(A,F,Q).join("")}function P5(s,o,l){if(s=$t(s),s&&(l||o===t))return s.slice(0,P0(s)+1);if(!s||!(o=vi(o)))return s;var A=rn(s),T=I0(A,rn(o))+1;return Cs(A,0,T).join("")}function O5(s,o,l){if(s=$t(s),s&&(l||o===t))return s.replace(it,"");if(!s||!(o=vi(o)))return s;var A=rn(s),T=M0(A,rn(o));return Cs(A,T).join("")}function T5(s,o){var l=le,A=U;if(Zt(o)){var T="separator"in o?o.separator:T;l="length"in o?yt(o.length):l,A="omission"in o?vi(o.omission):A}s=$t(s);var F=s.length;if(Ba(s)){var Q=rn(s);F=Q.length}if(l>=F)return s;var X=l-$a(A);if(X<1)return A;var ie=Q?Cs(Q,0,X).join(""):s.slice(0,X);if(T===t)return ie+A;if(Q&&(X+=ie.length-X),sl(T)){if(s.slice(X).search(T)){var he,de=ie;for(T.global||(T=_h(T.source,$t(vt.exec(T))+"g")),T.lastIndex=0;he=T.exec(de);)var ge=he.index;ie=ie.slice(0,ge===t?X:ge)}}else if(s.indexOf(vi(T),X)!=X){var Ie=ie.lastIndexOf(T);Ie>-1&&(ie=ie.slice(0,Ie))}return ie+A}function R5(s){return s=$t(s),s&&Be.test(s)?s.replace(Et,cm):s}var N5=ka(function(s,o,l){return s+(l?" ":"")+o.toUpperCase()}),cl=mp("toUpperCase");function b1(s,o,l){return s=$t(s),o=l?t:o,o===t?im(s)?hm(s):J2(s):s.match(o)||[]}var v1=Dt(function(s,o){try{return vr(s,t,o)}catch(l){return nl(l)?l:new dt(l)}}),B5=ts(function(s,o){return Pi(o,function(l){l=En(l),Zn(s,l,rl(s[l],s))}),s});function $5(s){var o=s==null?0:s.length,l=nt();return s=o?Xt(s,function(A){if(typeof A[1]!="function")throw new Oi(c);return[l(A[0]),A[1]]}):[],Dt(function(A){for(var T=-1;++TM)return[];var l=b,A=qr(s,b);o=nt(o),s-=b;for(var T=mh(A,o);++l0||o<0)?new Mt(l):(s<0?l=l.takeRight(-s):s&&(l=l.drop(s)),o!==t&&(o=yt(o),l=o<0?l.dropRight(-o):l.take(o-s)),l)},Mt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},Mt.prototype.toArray=function(){return this.take(b)},_n(Mt.prototype,function(s,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),A=/^(?:head|last)$/.test(o),T=$[A?"take"+(o=="last"?"Right":""):o],F=A||/^find/.test(o);T&&($.prototype[o]=function(){var Q=this.__wrapped__,X=A?[1]:arguments,ie=Q instanceof Mt,he=X[0],de=ie||gt(Q),ge=function(At){var Tt=T.apply($,Es([At],X));return A&&Ie?Tt[0]:Tt};de&&l&&typeof he=="function"&&he.length!=1&&(ie=de=!1);var Ie=this.__chain__,Je=!!this.__actions__.length,ot=F&&!Ie,wt=ie&&!Je;if(!F&&de){Q=wt?Q:new Mt(this);var ct=s.apply(Q,X);return ct.__actions__.push({func:Bu,args:[ge],thisArg:t}),new Ti(ct,Ie)}return ot&&wt?s.apply(this,X):(ct=this.thru(ge),ot?A?ct.value()[0]:ct.value():ct)})}),Pi(["pop","push","shift","sort","splice","unshift"],function(s){var o=ou[s],l=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",A=/^(?:pop|shift)$/.test(s);$.prototype[s]=function(){var T=arguments;if(A&&!this.__chain__){var F=this.value();return o.apply(gt(F)?F:[],T)}return this[l](function(Q){return o.apply(gt(Q)?Q:[],T)})}}),_n(Mt.prototype,function(s,o){var l=$[o];if(l){var A=l.name+"";qt.call(Fa,A)||(Fa[A]=[]),Fa[A].push({name:o,func:l})}}),Fa[Iu(t,Y).name]=[{name:"wrapper",func:t}],Mt.prototype.clone=Rm,Mt.prototype.reverse=Nm,Mt.prototype.value=Bm,$.prototype.at=f8,$.prototype.chain=h8,$.prototype.commit=l8,$.prototype.next=d8,$.prototype.plant=g8,$.prototype.reverse=b8,$.prototype.toJSON=$.prototype.valueOf=$.prototype.value=v8,$.prototype.first=$.prototype.head,Ro&&($.prototype[Ro]=p8),$},Ua=lm();sr?((sr.exports=Ua)._=Ua,kt._=Ua):Ot._=Ua}).call(ac)})($d,$d.exports);var SB=Object.defineProperty,MB=Object.defineProperties,IB=Object.getOwnPropertyDescriptors,jb=Object.getOwnPropertySymbols,CB=Object.prototype.hasOwnProperty,PB=Object.prototype.propertyIsEnumerable,kb=(r,e,t)=>e in r?SB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zu=(r,e)=>{for(var t in e||(e={}))CB.call(e,t)&&kb(r,t,e[t]);if(jb)for(var t of jb(e))PB.call(e,t)&&kb(r,t,e[t]);return r},OB=(r,e)=>MB(r,IB(e));function bn(r,e,t){var i;const n=fc(r);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${F2}?chainId=${n.namespace}:${n.reference}&projectId=${t}`}function Ca(r){return r.includes(":")?r.split(":")[1]:r}function z2(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function TB(r,e){const t=Object.keys(e.namespaces).filter(n=>n.includes(r));if(!t.length)return[];const i=[];return t.forEach(n=>{const a=e.namespaces[n].accounts;i.push(...a)}),i}function td(r={},e={}){const t=Hb(r),i=Hb(e);return $d.exports.merge(t,i)}function Hb(r){var e,t,i,n;const a={};if(!_c(r))return a;for(const[c,f]of Object.entries(r)){const g=f0(c)?[c]:f.chains,d=f.methods||[],m=f.events||[],w=f.rpcMap||{},O=uc(c);a[O]=OB(Zu(Zu({},a[O]),f),{chains:rf(g,(e=a[O])==null?void 0:e.chains),methods:rf(d,(t=a[O])==null?void 0:t.methods),events:rf(m,(i=a[O])==null?void 0:i.events),rpcMap:Zu(Zu({},w),(n=a[O])==null?void 0:n.rpcMap)})}return a}function RB(r){return r.includes(":")?r.split(":")[2]:r}function Kb(r){const e={};for(const[t,i]of Object.entries(r)){const n=i.methods||[],a=i.events||[],c=i.accounts||[],f=f0(t)?[t]:i.chains?i.chains:z2(i.accounts);e[t]={chains:f,methods:n,events:a,accounts:c}}return e}function rd(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const j2={},Ut=r=>j2[r],id=(r,e)=>{j2[r]=e};class NB{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}var BB=Object.defineProperty,$B=Object.defineProperties,UB=Object.getOwnPropertyDescriptors,Vb=Object.getOwnPropertySymbols,qB=Object.prototype.hasOwnProperty,LB=Object.prototype.propertyIsEnumerable,Gb=(r,e,t)=>e in r?BB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jb=(r,e)=>{for(var t in e||(e={}))qB.call(e,t)&&Gb(r,t,e[t]);if(Vb)for(var t of Vb(e))LB.call(e,t)&&Gb(r,t,e[t]);return r},Wb=(r,e)=>$B(r,UB(e));class FB{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("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,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(mn.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,t){const i=t||bn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=parseInt(Ca(t));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let n=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const a=parseInt(n,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. 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 t,i,n;const a=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const c=this.client.session.get(e.topic),f=((n=c==null?void 0:c.sessionProperties)==null?void 0:n.capabilities)||{};if(f!=null&&f[a])return f==null?void 0:f[a];const g=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Wb(Jb({},c.sessionProperties||{}),{capabilities:Wb(Jb({},f||{}),{[a]:g})})})}catch(d){console.warn("Failed to update session with capabilities",d)}return g}async getCallStatus(e){var t,i;const n=this.client.session.get(e.topic),a=(t=n.sessionProperties)==null?void 0:t.bundler_name;if(a){const f=this.getBundlerUrl(e.chainId,a);try{return await this.getUserOperationReceipt(f,e)}catch(g){console.warn("Failed to fetch call status from bundler",g,f)}}const c=(i=n.sessionProperties)==null?void 0:i.bundler_url;if(c)try{return await this.getUserOperationReceipt(c,e)}catch(f){console.warn("Failed to fetch call status from custom bundler",f,c)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const n=new URL(e),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Fs("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,t){return`${xB}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class zB{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class jB{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class kB{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||bn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new vn(new Wn(i,Ut("disableProviderPing")))}}class HB{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),n=Ca(t);e[n]=this.createHttpProvider(n,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class KB{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class VB{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class GB{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||bn(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace);return typeof i>"u"?void 0:new vn(new Wn(i,Ut("disableProviderPing")))}}class JB{constructor(e){this.name=Za,this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(n=>{const a=fc(n);i[`${a.namespace}:${a.reference}`]=this.createHttpProvider(n)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}var WB=Object.defineProperty,YB=Object.defineProperties,QB=Object.getOwnPropertyDescriptors,Yb=Object.getOwnPropertySymbols,XB=Object.prototype.hasOwnProperty,ZB=Object.prototype.propertyIsEnumerable,Qb=(r,e,t)=>e in r?WB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ef=(r,e)=>{for(var t in e||(e={}))XB.call(e,t)&&Qb(r,t,e[t]);if(Yb)for(var t of Yb(e))ZB.call(e,t)&&Qb(r,t,e[t]);return r},nd=(r,e)=>YB(r,QB(e));class y0{constructor(e){this.events=new Fd,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:Uc(Zf({level:(e==null?void 0:e.logger)||Fb})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new y0(e);return await t.initialize(),t}async request(e,t,i){const[n,a]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:ef({},e),chainId:`${n}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,n){const a=new Date().getTime();this.request(e,i,n).then(c=>t(null,th(a,c))).catch(c=>t(c,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:Lt("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:n}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await n();if(this.session=a.session,this.session){const c=Kb(this.session.namespaces);this.namespaces=td(this.namespaces,c),this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await n().then(a=>{this.session=a;const c=Kb(a.namespaces);this.namespaces=td(this.namespaces,c),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==L2)throw a;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,n]=this.validateChain(e),a=this.getProvider(i);a.name===Za?a.setDefaultChain(`${i}:${n}`,t):a.setDefaultChain(n,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Hn(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await m0.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Fb,relayUrl:this.providerOpts.relayUrl||DB,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(t=>uc(t)))];id("client",this.client),id("events",this.events),id("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=TB(t,this.session),n=z2(i),a=td(this.namespaces,this.optionalNamespaces),c=nd(ef({},a[t]),{accounts:i,chains:n});switch(t){case"eip155":this.rpcProviders[t]=new FB({namespace:c});break;case"algorand":this.rpcProviders[t]=new kB({namespace:c});break;case"solana":this.rpcProviders[t]=new zB({namespace:c});break;case"cosmos":this.rpcProviders[t]=new jB({namespace:c});break;case"polkadot":this.rpcProviders[t]=new NB({namespace:c});break;case"cip34":this.rpcProviders[t]=new HB({namespace:c});break;case"elrond":this.rpcProviders[t]=new KB({namespace:c});break;case"multiversx":this.rpcProviders[t]=new VB({namespace:c});break;case"near":this.rpcProviders[t]=new GB({namespace:c});break;default:this.rpcProviders[Za]?this.rpcProviders[Za].updateNamespace(c):this.rpcProviders[Za]=new JB({namespace:c})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const n=i.data;n&&Hn(n)&&this.events.emit("accountsChanged",n.map(RB))}else if(i.name==="chainChanged"){const n=t.chainId,a=t.event.data,c=uc(n),f=rd(n)!==rd(a)?`${c}:${rd(a)}`:n;this.onChainChanged(f)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:n}=t,a=(i=this.client)==null?void 0:i.session.get(e);this.session=nd(ef({},a),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",nd(ef({},Lt("USER_DISCONNECTED")),{data:e.topic}))}),this.on(mn.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Za]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:n}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=n,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(c=>uc(c)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const n=uc(Object.keys(this.namespaces)[0]),a=this.rpcProviders[n].getDefaultChain();return[n,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);n&&(t||this.getProvider(i).setDefaultChain(n),this.namespaces[i]?this.namespaces[i].defaultChain=n:this.namespaces[`${i}:${n}`]?this.namespaces[`${i}:${n}`].defaultChain=n:this.namespaces[`${i}:${n}`]={defaultChain:n},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${zb}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${zb}/${e}`)}}const e$=y0,t$="wc",r$="ethereum_provider",i$=`${t$}@2:${r$}:`,n$="https://rpc.walletconnect.org/v1/",Ud=["eth_sendTransaction","personal_sign"],s$=["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"],qd=["chainChanged","accountsChanged"],a$=["chainChanged","accountsChanged","message","disconnect","connect"];var o$=Object.defineProperty,c$=Object.defineProperties,u$=Object.getOwnPropertyDescriptors,Xb=Object.getOwnPropertySymbols,f$=Object.prototype.hasOwnProperty,h$=Object.prototype.propertyIsEnumerable,Zb=(r,e,t)=>e in r?o$(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,eo=(r,e)=>{for(var t in e||(e={}))f$.call(e,t)&&Zb(r,t,e[t]);if(Xb)for(var t of Xb(e))h$.call(e,t)&&Zb(r,t,e[t]);return r},sd=(r,e)=>c$(r,u$(e));function Cf(r){return Number(r[0].split(":")[1])}function tf(r){return`0x${r.toString(16)}`}function l$(r){const{chains:e,optionalChains:t,methods:i,optionalMethods:n,events:a,optionalEvents:c,rpcMap:f}=r;if(!Hn(e))throw new Error("Invalid chains");const g={chains:e,methods:i||Ud,events:a||qd,rpcMap:eo({},e.length?{[Cf(e)]:f[Cf(e)]}:{})},d=a==null?void 0:a.filter(C=>!qd.includes(C)),m=i==null?void 0:i.filter(C=>!Ud.includes(C));if(!t&&!c&&!n&&!(d!=null&&d.length)&&!(m!=null&&m.length))return{required:e.length?g:void 0};const w=(d==null?void 0:d.length)&&(m==null?void 0:m.length)||!t,O={chains:[...new Set(w?g.chains.concat(t||[]):t)],methods:[...new Set(g.methods.concat(n!=null&&n.length?n:s$))],events:[...new Set(g.events.concat(c!=null&&c.length?c:a$))],rpcMap:f};return{required:e.length?g:void 0,optional:t.length?O:void 0}}class w0{constructor(){this.events=new Vi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=i$,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new w0;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,i){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),i)}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:t,optional:i}=l$(this.rpc);try{const n=await new Promise(async(c,f)=>{var g;this.rpc.showQrModal&&((g=this.modal)==null||g.subscribeModal(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(sd(eo({namespaces:eo({},t&&{[this.namespace]:t})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(d=>{c(d)}).catch(d=>{f(new Error(d.message))})});if(!n)return;const a=X1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:tf(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(a,c)=>{var f;this.rpc.showQrModal&&((f=this.modal)==null||f.subscribeModal(g=>{!g.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(sd(eo({},e),{chains:this.rpc.chains}),t).then(g=>{a(g)}).catch(g=>{c(new Error(g.message))})}),n=i.session;if(n){const a=X1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:tf(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}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:t}=e,{event:i}=t;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",tf(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",sd(eo({},Lt("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,i;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(i=this.modal)==null||i.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 t=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",tf(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,i,n]=e.split(":");return{chainId:`${t}:${i}`,address:n}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;const n=(t=e==null?void 0:e.chains)!=null?t:[],a=(i=e==null?void 0:e.optionalChains)!=null?i:[],c=n.concat(a);if(!c.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const f=n.length?(e==null?void 0:e.methods)||Ud:[],g=n.length?(e==null?void 0:e.events)||qd:[],d=(e==null?void 0:e.optionalMethods)||[],m=(e==null?void 0:e.optionalEvents)||[],w=(e==null?void 0:e.rpcMap)||this.buildRpcMap(c,e.projectId),O=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:n==null?void 0:n.map(C=>this.formatChainId(C)),optionalChains:a.map(C=>this.formatChainId(C)),methods:f,events:g,optionalMethods:d,optionalEvents:m,rpcMap:w,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:O,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const i={};return e.forEach(n=>{i[n]=this.getRpcUrl(n,t)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Cf(this.rpc.chains):Cf(this.rpc.optionalChains),this.signer=await e$.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 t;try{const{WalletConnectModal:i}=await _4(()=>import("./index-Dt2-TQyK.js").then(n=>n.i),__vite__mapDeps([0,1,2]));t=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(eo({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:i,rpcMap:n}=e;t&&Hn(t)&&(this.rpc.chains=t.map(a=>this.formatChainId(a)),t.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)})),i&&Hn(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(a=>this.formatChainId(a)),i.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)}))}getRpcUrl(e,t){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${n$}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}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(t=>this.parseAccount(t))}}const V$=w0;export{V$ as EthereumProvider,a$ as OPTIONAL_EVENTS,s$ as OPTIONAL_METHODS,qd as REQUIRED_EVENTS,Ud as REQUIRED_METHODS,w0 as default}; diff --git a/buddybook/assets/inherits_browser-Bb3-ajt6.js b/buddybook/assets/inherits_browser-B8fZ3Rhe.js similarity index 85% rename from buddybook/assets/inherits_browser-Bb3-ajt6.js rename to buddybook/assets/inherits_browser-B8fZ3Rhe.js index 770a755..c9285ba 100644 --- a/buddybook/assets/inherits_browser-Bb3-ajt6.js +++ b/buddybook/assets/inherits_browser-B8fZ3Rhe.js @@ -1 +1 @@ -import{j as n,v as s}from"./index-uonIXzgQ.js";const a=n(s);var r={exports:{}};typeof Object.create=="function"?r.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(e,t){if(t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}};var f=r.exports;export{f as i,a as r}; +import{j as n,v as s}from"./index-BpI4vT-j.js";const a=n(s);var r={exports:{}};typeof Object.create=="function"?r.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(e,t){if(t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}};var f=r.exports;export{f as i,a as r}; diff --git a/buddybook/index.html b/buddybook/index.html index 06e7828..0a1e1ec 100644 --- a/buddybook/index.html +++ b/buddybook/index.html @@ -23,7 +23,7 @@ browser: true }; - + diff --git a/flush-notes/404.html b/flush-notes/404.html index 6243685..169d0bd 100644 --- a/flush-notes/404.html +++ b/flush-notes/404.html @@ -1 +1 @@ -Share notes

Loading...

\ No newline at end of file +Share notes

Loading...

\ No newline at end of file diff --git a/flush-notes/_next/static/QYaJ0AjbbxerL0dOZkk5s/_buildManifest.js b/flush-notes/_next/static/vaotwJXvn9hargiuIvufd/_buildManifest.js similarity index 100% rename from flush-notes/_next/static/QYaJ0AjbbxerL0dOZkk5s/_buildManifest.js rename to flush-notes/_next/static/vaotwJXvn9hargiuIvufd/_buildManifest.js diff --git a/flush-notes/_next/static/QYaJ0AjbbxerL0dOZkk5s/_ssgManifest.js b/flush-notes/_next/static/vaotwJXvn9hargiuIvufd/_ssgManifest.js similarity index 100% rename from flush-notes/_next/static/QYaJ0AjbbxerL0dOZkk5s/_ssgManifest.js rename to flush-notes/_next/static/vaotwJXvn9hargiuIvufd/_ssgManifest.js diff --git a/flush-notes/index.html b/flush-notes/index.html index 3e9bd12..7b76855 100644 --- a/flush-notes/index.html +++ b/flush-notes/index.html @@ -1 +1 @@ -Share notes

Loading...

\ No newline at end of file +Share notes

Loading...

\ No newline at end of file diff --git a/flush-notes/index.txt b/flush-notes/index.txt index 188a850..4c15a7d 100644 --- a/flush-notes/index.txt +++ b/flush-notes/index.txt @@ -1,6 +1,6 @@ 1:HL["/_next/static/media/a34f9d1faa5f3315-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 2:HL["/_next/static/css/93e318bfbcd18d37.css","style",{"crossOrigin":""}] -0:["QYaJ0AjbbxerL0dOZkk5s",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] +0:["vaotwJXvn9hargiuIvufd",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] 5:I[5685,["948","static/chunks/948-50bbf5866eb892b4.js","185","static/chunks/app/layout-6076b03a814c7003.js"],""] 6:I[6954,[],""] 7:I[7264,[],""] diff --git a/flush-notes/view.html b/flush-notes/view.html index 0ea05a7..e0d6ed0 100644 --- a/flush-notes/view.html +++ b/flush-notes/view.html @@ -1 +1 @@ -Share notes

Loading...

\ No newline at end of file +Share notes

Loading...

\ No newline at end of file diff --git a/flush-notes/view.txt b/flush-notes/view.txt index e5bab35..b25c1c1 100644 --- a/flush-notes/view.txt +++ b/flush-notes/view.txt @@ -1,6 +1,6 @@ 1:HL["/_next/static/media/a34f9d1faa5f3315-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 2:HL["/_next/static/css/93e318bfbcd18d37.css","style",{"crossOrigin":""}] -0:["QYaJ0AjbbxerL0dOZkk5s",[[["",{"children":["view",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] +0:["vaotwJXvn9hargiuIvufd",[[["",{"children":["view",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/93e318bfbcd18d37.css","precedence":"next","crossOrigin":""}]],"$L4"]]]] 5:I[5685,["948","static/chunks/948-50bbf5866eb892b4.js","185","static/chunks/app/layout-6076b03a814c7003.js"],""] 6:I[6954,[],""] 7:I[7264,[],""]