diff --git a/.github/workflows/release_candidate.yml b/.github/workflows/release_candidate.yml index b4987815c..d2152aacf 100644 --- a/.github/workflows/release_candidate.yml +++ b/.github/workflows/release_candidate.yml @@ -13,11 +13,10 @@ jobs: - name: build and deploy kinode uses: appleboy/ssh-action@master with: - host: ${{ secrets.SSH_HOST }} + host: ${{ secrets.SSH_API_HOST }} username: ${{ secrets.SSH_USER }} - key: ${{ secrets.SSH_ED25519KEY }} + key: ${{ secrets.SSH_API_ED25519KEY }} port: ${{ secrets.SSH_PORT }} command_timeout: 60m script: | - cd ~ - ./build-kinode.sh + curl -X PUT http://localhost:8000/monitor/build-kinode diff --git a/Cargo.lock b/Cargo.lock index 1bf42ecfb..02a8497dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3179,7 +3179,7 @@ dependencies = [ [[package]] name = "kinode" -version = "0.8.0" +version = "0.8.1" dependencies = [ "aes-gcm", "alloy", @@ -3249,7 +3249,7 @@ dependencies = [ [[package]] name = "kinode_lib" -version = "0.8.0" +version = "0.8.1" dependencies = [ "lib", ] @@ -3369,7 +3369,7 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "lib" -version = "0.8.0" +version = "0.8.1" dependencies = [ "alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=05f8162)", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=05f8162)", diff --git a/Cargo.toml b/Cargo.toml index fd11adba6..344d2b54c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kinode_lib" authors = ["KinodeDAO"] -version = "0.8.0" +version = "0.8.1" edition = "2021" description = "A general-purpose sovereign cloud computing platform" homepage = "https://kinode.org" diff --git a/kinode/Cargo.toml b/kinode/Cargo.toml index e52596a8b..c036387f5 100644 --- a/kinode/Cargo.toml +++ b/kinode/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kinode" authors = ["KinodeDAO"] -version = "0.8.0" +version = "0.8.1" edition = "2021" description = "A general-purpose sovereign cloud computing platform" homepage = "https://kinode.org" diff --git a/kinode/packages/app_store/pkg/ui/assets/index-I5kjLT9f.js b/kinode/packages/app_store/pkg/ui/assets/index-I7H8IZID.js similarity index 86% rename from kinode/packages/app_store/pkg/ui/assets/index-I5kjLT9f.js rename to kinode/packages/app_store/pkg/ui/assets/index-I7H8IZID.js index dfe522247..4aa54bd38 100644 --- a/kinode/packages/app_store/pkg/ui/assets/index-I5kjLT9f.js +++ b/kinode/packages/app_store/pkg/ui/assets/index-I7H8IZID.js @@ -87,8 +87,8 @@ Error generating stack: `+s.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ku=L,z3=U3;function $3(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var H3=typeof Object.is=="function"?Object.is:$3,V3=z3.useSyncExternalStore,q3=Ku.useRef,G3=Ku.useEffect,W3=Ku.useMemo,K3=Ku.useDebugValue;j1.useSyncExternalStoreWithSelector=function(t,e,r,n,i){var s=q3(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=W3(function(){function l(m){if(!u){if(u=!0,c=m,m=n(m),i!==void 0&&o.hasValue){var v=o.value;if(i(v,m))return h=v}return h=m}if(v=h,H3(c,m))return v;var b=n(m);return i!==void 0&&i(v,b)?v:(c=m,h=b)}var u=!1,c,h,p=r===void 0?null:r;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,r,n,i]);var a=V3(t,s[0],s[1]);return G3(function(){o.hasValue=!0,o.value=a},[a]),K3(a),a};T1.exports=j1;var Q3=T1.exports;const Qu=Si(Q3),{useSyncExternalStoreWithSelector:J3}=Qu;function D1(t,e=t.getState,r){const n=J3(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return L.useDebugValue(n),n}const Dp=t=>{const e=typeof t=="function"?O1(t):t,r=(n,i)=>D1(e,n,i);return Object.assign(r,e),r},F1=t=>t?Dp(t):Dp;var Y3=t=>F1(t);const X3=Object.freeze(Object.defineProperty({__proto__:null,create:F1,createStore:O1,default:Y3,useStore:D1},Symbol.toStringTag,{value:"Module"})),Z3=Ys(X3);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createWeb3ReactStoreAndActions=t.MAX_SAFE_CHAIN_ID=void 0;const e=C3,r=Z3;t.MAX_SAFE_CHAIN_ID=0xfffffffffffec;function n(a){if(!Number.isInteger(a)||a<=0||a>t.MAX_SAFE_CHAIN_ID)throw new Error(`Invalid chainId ${a}`)}function i(a){return(0,e.getAddress)(a)}const s={chainId:void 0,accounts:void 0,activating:!1};function o(){const a=(0,r.createStore)()(()=>s);let l=0;function u(){const p=++l;return a.setState(Object.assign(Object.assign({},s),{activating:!0})),()=>{l===p&&a.setState({activating:!1})}}function c(p){if(p.chainId!==void 0&&n(p.chainId),p.accounts!==void 0)for(let m=0;m{var v,b;const k=(v=p.chainId)!==null&&v!==void 0?v:m.chainId,x=(b=p.accounts)!==null&&b!==void 0?b:m.accounts;let w=m.activating;return w&&k&&x&&(w=!1),{chainId:k,accounts:x,activating:w}})}function h(){l++,a.setState(s)}return[a,{startActivation:u,update:c,resetState:h}]}t.createWeb3ReactStoreAndActions=o})(N1);var eE={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Fp=t=>{let e;const r=new Set,n=(l,u)=>{const c=typeof l=="function"?l(e):l;if(!Object.is(c,e)){const h=e;e=u??typeof c!="object"?c:Object.assign({},e,c),r.forEach(p=>p(e,h))}},i=()=>e,a={setState:n,getState:i,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{(eE?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,i,a),a},Vd=t=>t?Fp(t):Fp,{useSyncExternalStoreWithSelector:tE}=Qu;function U1(t,e=t.getState,r){const n=tE(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return L.useDebugValue(n),n}const Up=t=>{const e=typeof t=="function"?Vd(t):t,r=(n,i)=>U1(e,n,i);return Object.assign(r,e),r},z1=t=>t?Up(t):Up;var rE=t=>z1(t);const nE=Object.freeze(Object.defineProperty({__proto__:null,create:z1,createStore:Vd,default:rE,useStore:U1},Symbol.toStringTag,{value:"Module"})),iE=Ys(nE),{useSyncExternalStoreWithSelector:sE}=Qu;function $1(t,e=t.getState,r){const n=sE(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return L.useDebugValue(n),n}const zp=(t,e)=>{const r=Vd(t),n=(i,s=e)=>$1(r,i,s);return Object.assign(n,r),n},oE=(t,e)=>t?zp(t,e):zp,aE=Object.freeze(Object.defineProperty({__proto__:null,createWithEqualityFn:oE,useStoreWithEqualityFn:$1},Symbol.toStringTag,{value:"Module"})),lE=Ys(aE),uE="properties/5.7.0";var cE=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const su=new j(uE);function H(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function mr(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||typeof t.prototype!="object")break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function xt(t){return cE(this,void 0,void 0,function*(){const e=Object.keys(t).map(n=>{const i=t[n];return Promise.resolve(i).then(s=>({key:n,value:s}))});return(yield Promise.all(e)).reduce((n,i)=>(n[i.key]=i.value,n),{})})}function fE(t,e){(!t||typeof t!="object")&&su.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||su.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function at(t){const e={};for(const r in t)e[r]=t[r];return e}const hE={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function H1(t){if(t==null||hE[typeof t])return!0;if(Array.isArray(t)||typeof t=="object"){if(!Object.isFrozen(t))return!1;const e=Object.keys(t);for(let r=0;rlr(e)));if(typeof t=="object"){const e={};for(const r in t){const n=t[r];n!==void 0&&H(e,r,lr(n))}return e}return su.throwArgumentError(`Cannot deepCopy ${typeof t}`,"object",t)}function lr(t){return dE(t)}class Ca{constructor(e){for(const r in e)this[r]=lr(e[r])}}const pE="abstract-provider/5.7.0";var mE=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const gE=new j(pE);class vE extends Ca{static isForkEvent(e){return!!(e&&e._isForkEvent)}}class ro{constructor(){gE.checkAbstract(new.target,ro),H(this,"_isProvider",!0)}getFeeData(){return mE(this,void 0,void 0,function*(){const{block:e,gasPrice:r}=yield xt({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(o=>null)});let n=null,i=null,s=null;return e&&e.baseFeePerGas&&(n=e.baseFeePerGas,s=K.from("1500000000"),i=e.baseFeePerGas.mul(2).add(s)),{lastBaseFeePerGas:n,maxFeePerGas:i,maxPriorityFeePerGas:s,gasPrice:r}})}addListener(e,r){return this.on(e,r)}removeListener(e,r){return this.off(e,r)}static isProvider(e){return!!(e&&e._isProvider)}}const yE="networks/5.7.1",$p=new j(yE);function wE(t){return t&&typeof t.renetwork=="function"}function Cn(t){const e=function(r,n){n==null&&(n={});const i=[];if(r.InfuraProvider&&n.infura!=="-")try{i.push(new r.InfuraProvider(t,n.infura))}catch{}if(r.EtherscanProvider&&n.etherscan!=="-")try{i.push(new r.EtherscanProvider(t,n.etherscan))}catch{}if(r.AlchemyProvider&&n.alchemy!=="-")try{i.push(new r.AlchemyProvider(t,n.alchemy))}catch{}if(r.PocketProvider&&n.pocket!=="-"){const s=["goerli","ropsten","rinkeby","sepolia"];try{const o=new r.PocketProvider(t,n.pocket);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}}if(r.CloudflareProvider&&n.cloudflare!=="-")try{i.push(new r.CloudflareProvider(t))}catch{}if(r.AnkrProvider&&n.ankr!=="-")try{const s=["ropsten"],o=new r.AnkrProvider(t,n.ankr);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}if(i.length===0)return null;if(r.FallbackProvider){let s=1;return n.quorum!=null?s=n.quorum:t==="homestead"&&(s=2),new r.FallbackProvider(i,s)}return i[0]};return e.renetwork=function(r){return Cn(r)},e}function ou(t,e){const r=function(n,i){return n.JsonRpcProvider?new n.JsonRpcProvider(t,e):null};return r.renetwork=function(n){return ou(t,n)},r}const Hp={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:Cn("homestead")},Vp={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:Cn("ropsten")},qp={chainId:63,name:"classicMordor",_defaultProvider:ou("https://www.ethercluster.com/mordor","classicMordor")},Za={unspecified:{chainId:0,name:"unspecified"},homestead:Hp,mainnet:Hp,morden:{chainId:2,name:"morden"},ropsten:Vp,testnet:Vp,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:Cn("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:Cn("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:Cn("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:Cn("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:ou("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:qp,classicTestnet:qp,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:ou("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:Cn("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:Cn("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function qd(t){if(t==null)return null;if(typeof t=="number"){for(const n in Za){const i=Za[n];if(i.chainId===t)return{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress||null,_defaultProvider:i._defaultProvider||null}}return{chainId:t,name:"unknown"}}if(typeof t=="string"){const n=Za[t];return n==null?null:{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress,_defaultProvider:n._defaultProvider||null}}const e=Za[t.name];if(!e)return typeof t.chainId!="number"&&$p.throwArgumentError("invalid network chainId","network",t),t;t.chainId!==0&&t.chainId!==e.chainId&&$p.throwArgumentError("network chainId mismatch","network",t);let r=t._defaultProvider||null;return r==null&&e._defaultProvider&&(wE(e._defaultProvider)?r=e._defaultProvider.renetwork(t):r=e._defaultProvider),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:r}}function V1(t){t=atob(t);const e=[];for(let r=0;r0;)n.push(o%this.base),o=o/this.base|0}let i="";for(let s=0;r[s]===0&&s=0;--s)i+=this.alphabet[n[s]];return i}decode(e){if(typeof e!="string")throw new TypeError("Expected String");let r=[];if(e.length===0)return new Uint8Array(r);r.push(0);for(let n=0;n>=8;for(;s>0;)r.push(s&255),s>>=8}for(let n=0;e[n]===this._leader&&n>6===2;o++)s++;return s}return t===hr.OVERRUN?r.length-e-1:0}function NE(t,e,r,n,i){return t===hr.OVERLONG?(n.push(i),0):(n.push(65533),Q1(t,e,r))}const ME=Object.freeze({error:kE,ignore:Q1,replace:NE});function J1(t,e){e==null&&(e=ME.error),t=oe(t);const r=[];let n=0;for(;n>7)){r.push(i);continue}let s=null,o=null;if((i&224)===192)s=1,o=127;else if((i&240)===224)s=2,o=2047;else if((i&248)===240)s=3,o=65535;else{(i&192)===128?n+=e(hr.UNEXPECTED_CONTINUE,n-1,t,r):n+=e(hr.BAD_PREFIX,n-1,t,r);continue}if(n-1+s>=t.length){n+=e(hr.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-s-1)-1;for(let l=0;l1114111){n+=e(hr.OUT_OF_RANGE,n-1-s,t,r,a);continue}if(a>=55296&&a<=57343){n+=e(hr.UTF16_SURROGATE,n-1-s,t,r,a);continue}if(a<=o){n+=e(hr.OVERLONG,n-1-s,t,r,a);continue}r.push(a)}}return r}function yr(t,e=fa.current){e!=fa.current&&(K1.checkNormalize(),t=t.normalize(e));let r=[];for(let n=0;n>6|192),r.push(i&63|128);else if((i&64512)==55296){n++;const s=t.charCodeAt(n);if(n>=t.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((i&1023)<<10)+(s&1023);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(o&63|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128)}return oe(r)}function CE(t){return t.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Pa(t,e){return CE(J1(t,e))}function PE(t,e=fa.current){return J1(yr(t,e))}function Es(t){return ot(yr(t))}const Y1="hash/5.7.0";function X1(t,e){e==null&&(e=1);const r=[],n=r.forEach,i=function(s,o){n.call(s,function(a){o>0&&Array.isArray(a)?i(a,o-1):r.push(a)})};return i(t,e),r}function RE(t){const e={};for(let r=0;r>--l&1}const h=31,p=Math.pow(2,h),m=p>>>1,v=m>>1,b=p-1;let k=0;for(let I=0;I1;){let G=B+F>>>1;I>>1|c(),$=$<<1^m,V=(V^m)<<1|m|1;w=$,A=1+V-$}let T=n-4;return x.map(I=>{switch(I-T){case 3:return T+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return T+256+(t[a++]<<8|t[a++]);case 1:return T+t[a++];default:return I-1}})}function OE(t){let e=0;return()=>t[e++]}function TE(t){return OE(IE(t))}function jE(t){return t&1?~t>>1:t>>1}function LE(t,e){let r=Array(t);for(let n=0;ne[o]):r}function DE(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(UE(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(zE(r,t))}return RE(X1(e))}function FE(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(r)}return e}function Z1(t,e,r){let n=Array(t).fill(void 0).map(()=>[]);for(let i=0;in[o].push(s));return n}function UE(t,e){let r=1+e(),n=e(),i=FE(e),s=Z1(i.length,1+t,e);return X1(s.map((o,a)=>{const l=o[0],u=o.slice(1);return Array(i[a]).fill(void 0).map((c,h)=>{let p=h*n;return[l+h*r,u.map(m=>m+p)]})}))}function zE(t,e){let r=1+e();return Z1(r,1+t,e).map(i=>[i[0],i.slice(1)])}function $E(t){let e=au(t).sort((n,i)=>n-i);return r();function r(){let n=[];for(;;){let u=au(t,e);if(u.length==0)break;n.push({set:new Set(u),node:r()})}n.sort((u,c)=>c.set.size-u.set.size);let i=t(),s=i%3;i=i/3|0;let o=!!(i&1);i>>=1;let a=i==1,l=i==2;return{branches:n,valid:s,fe0f:o,save:a,check:l}}}function HE(){return TE(V1("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"))}const Ju=HE(),VE=new Set(au(Ju)),qE=new Set(au(Ju)),GE=DE(Ju),WE=$E(Ju),Wp=45,Kp=95;function ey(t){return PE(t)}function KE(t){return t.filter(e=>e!=65039)}function ty(t){for(let e of t.split(".")){let r=ey(e);try{for(let n=r.lastIndexOf(Kp)-1;n>=0;n--)if(r[n]!==Kp)throw new Error("underscore only allowed at start");if(r.length>=4&&r.every(n=>n<128)&&r[2]===Wp&&r[3]===Wp)throw new Error("invalid label extension")}catch(n){throw new Error(`Invalid label "${e}": ${n.message}`)}}return t}function QE(t){return ty(JE(t,KE))}function JE(t,e){let r=ey(t).reverse(),n=[];for(;r.length;){let i=XE(r);if(i){n.push(...e(i));continue}let s=r.pop();if(VE.has(s)){n.push(s);continue}if(qE.has(s))continue;let o=GE[s];if(o){n.push(...o);continue}throw new Error(`Disallowed codepoint: 0x${s.toString(16).toUpperCase()}`)}return ty(YE(String.fromCodePoint(...n)))}function YE(t){return t.normalize("NFC")}function XE(t,e){var r;let n=WE,i,s,o=[],a=t.length;for(e&&(e.length=0);a;){let l=t[--a];if(n=(r=n.branches.find(u=>u.set.has(l)))===null||r===void 0?void 0:r.node,!n)break;if(n.save)s=l;else if(n.check&&l===s)break;o.push(l),n.fe0f&&(o.push(65039),a>0&&t[a-1]==65039&&a--),n.valid&&(i=o.slice(),n.valid==2&&i.splice(1,1),e&&e.push(...t.slice(a).reverse()),t.length=a)}return i}const ZE=new j(Y1),ry=new Uint8Array(32);ry.fill(0);function Qp(t){if(t.length===0)throw new Error("invalid ENS name; empty component");return t}function ny(t){const e=yr(QE(t)),r=[];if(t.length===0)return r;let n=0;for(let i=0;i=e.length)throw new Error("invalid ENS name; empty component");return r.push(Qp(e.slice(n))),r}function kl(t){typeof t!="string"&&ZE.throwArgumentError("invalid ENS name; not a string","name",t);let e=ry;const r=ny(t);for(;r.length;)e=ot($t([e,ot(r.pop())]));return ne(e)}function e5(t){return ne($t(ny(t).map(e=>{if(e.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const r=new Uint8Array(e.length+1);return r.set(e,1),r[0]=r.length-1,r})))+"00"}var t5=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const ct=new j(Y1),iy=new Uint8Array(32);iy.fill(0);const r5=K.from(-1),sy=K.from(0),oy=K.from(1),n5=K.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function i5(t){const e=oe(t),r=e.length%32;return r?nr([e,iy.slice(r)]):ne(e)}const s5=gt(oy.toHexString(),32),o5=gt(sy.toHexString(),32),Jp={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},ef=["name","version","chainId","verifyingContract","salt"];function Yp(t){return function(e){return typeof e!="string"&&ct.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const a5={name:Yp("name"),version:Yp("version"),chainId:function(t){try{return K.from(t).toString()}catch{}return ct.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return vt(t).toLowerCase()}catch{}return ct.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=oe(t);if(e.length!==32)throw new Error("bad length");return ne(e)}catch{}return ct.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function tf(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=e[1]==="",n=parseInt(e[2]||"256");(n%8!==0||n>256||e[2]&&e[2]!==String(n))&&ct.throwArgumentError("invalid numeric width","type",t);const i=n5.mask(r?n-1:n),s=r?i.add(oy).mul(r5):sy;return function(o){const a=K.from(o);return(a.lt(s)||a.gt(i))&&ct.throwArgumentError(`value out-of-bounds for ${t}`,"value",o),gt(a.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(r===0||r>32||e[1]!==String(r))&&ct.throwArgumentError("invalid bytes width","type",t),function(n){return oe(n).length!==r&&ct.throwArgumentError(`invalid length for ${t}`,"value",n),i5(n)}}}switch(t){case"address":return function(e){return gt(vt(e),32)};case"bool":return function(e){return e?s5:o5};case"bytes":return function(e){return ot(e)};case"string":return function(e){return Es(e)}}return null}function Xp(t,e){return`${t}(${e.map(({name:r,type:n})=>n+" "+r).join(",")})`}class cr{constructor(e){H(this,"types",Object.freeze(lr(e))),H(this,"_encoderCache",{}),H(this,"_types",{});const r={},n={},i={};Object.keys(e).forEach(a=>{r[a]={},n[a]=[],i[a]={}});for(const a in e){const l={};e[a].forEach(u=>{l[u.name]&&ct.throwArgumentError(`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(a)}`,"types",e),l[u.name]=!0;const c=u.type.match(/^([^\x5b]*)(\x5b|$)/)[1];c===a&&ct.throwArgumentError(`circular type reference to ${JSON.stringify(c)}`,"types",e),!tf(c)&&(n[c]||ct.throwArgumentError(`unknown type ${JSON.stringify(c)}`,"types",e),n[c].push(a),r[a][c]=!0)})}const s=Object.keys(n).filter(a=>n[a].length===0);s.length===0?ct.throwArgumentError("missing primary type","types",e):s.length>1&&ct.throwArgumentError(`ambiguous primary types or unused types: ${s.map(a=>JSON.stringify(a)).join(", ")}`,"types",e),H(this,"primaryType",s[0]);function o(a,l){l[a]&&ct.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",e),l[a]=!0,Object.keys(r[a]).forEach(u=>{n[u]&&(o(u,l),Object.keys(l).forEach(c=>{i[c][u]=!0}))}),delete l[a]}o(this.primaryType,{});for(const a in i){const l=Object.keys(i[a]);l.sort(),this._types[a]=Xp(a,e[a])+l.map(u=>Xp(u,e[u])).join("")}}getEncoder(e){let r=this._encoderCache[e];return r||(r=this._encoderCache[e]=this._getEncoder(e)),r}_getEncoder(e){{const i=tf(e);if(i)return i}const r=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(r){const i=r[1],s=this.getEncoder(i),o=parseInt(r[3]);return a=>{o>=0&&a.length!==o&&ct.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",a);let l=a.map(s);return this._types[i]&&(l=l.map(ot)),ot(nr(l))}}const n=this.types[e];if(n){const i=Es(this._types[e]);return s=>{const o=n.map(({name:a,type:l})=>{const u=this.getEncoder(l)(s[a]);return this._types[l]?ot(u):u});return o.unshift(i),nr(o)}}return ct.throwArgumentError(`unknown type: ${e}`,"type",e)}encodeType(e){const r=this._types[e];return r||ct.throwArgumentError(`unknown type: ${JSON.stringify(e)}`,"name",e),r}encodeData(e,r){return this.getEncoder(e)(r)}hashStruct(e,r){return ot(this.encodeData(e,r))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,r,n){if(tf(e))return n(e,r);const i=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const o=i[1],a=parseInt(i[3]);return a>=0&&r.length!==a&&ct.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",r),r.map(l=>this._visit(o,l,n))}const s=this.types[e];return s?s.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,r[a],n),o),{}):ct.throwArgumentError(`unknown type: ${e}`,"type",e)}visit(e,r){return this._visit(this.primaryType,e,r)}static from(e){return new cr(e)}static getPrimaryType(e){return cr.from(e).primaryType}static hashStruct(e,r,n){return cr.from(r).hashStruct(e,n)}static hashDomain(e){const r=[];for(const n in e){const i=Jp[n];i||ct.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),r.push({name:n,type:i})}return r.sort((n,i)=>ef.indexOf(n.name)-ef.indexOf(i.name)),cr.hashStruct("EIP712Domain",{EIP712Domain:r},e)}static encode(e,r,n){return nr(["0x1901",cr.hashDomain(e),cr.from(r).hash(n)])}static hash(e,r,n){return ot(cr.encode(e,r,n))}static resolveNames(e,r,n,i){return t5(this,void 0,void 0,function*(){e=at(e);const s={};e.verifyingContract&&!me(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=cr.from(r);o.visit(n,(a,l)=>(a==="address"&&!me(l,20)&&(s[l]="0x"),l));for(const a in s)s[a]=yield i(a);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),n=o.visit(n,(a,l)=>a==="address"&&s[l]?s[l]:l),{domain:e,value:n}})}static getPayload(e,r,n){cr.hashDomain(e);const i={},s=[];ef.forEach(l=>{const u=e[l];u!=null&&(i[l]=a5[l](u),s.push({name:l,type:Jp[l]}))});const o=cr.from(r),a=at(r);return a.EIP712Domain?ct.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",r):a.EIP712Domain=s,o.encode(n),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(n,(l,u)=>{if(l.match(/^bytes(\d*)/))return ne(oe(u));if(l.match(/^u?int/))return K.from(u).toString();switch(l){case"address":return u.toLowerCase();case"bool":return!!u;case"string":return typeof u!="string"&&ct.throwArgumentError("invalid string","value",u),u}return ct.throwArgumentError("unsupported type","type",l)})}}}var ay={},xe={},Ra=ly;function ly(t,e){if(!t)throw new Error(e||"Assertion failed")}ly.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)};var _h={exports:{}};typeof Object.create=="function"?_h.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:_h.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}};var l5=_h.exports,u5=Ra,c5=l5;xe.inherits=c5;function f5(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function h5(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),i=0;i>6|192,r[n++]=s&63|128):f5(t,i)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++i)&1023),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=s&63|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=s&63|128)}else for(i=0;i>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}xe.htonl=uy;function p5(t,e){for(var r="",n=0;n>>0}return s}xe.join32=m5;function g5(t,e){for(var r=new Array(t.length*4),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=s&255):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=s&255)}return r}xe.split32=g5;function v5(t,e){return t>>>e|t<<32-e}xe.rotr32=v5;function y5(t,e){return t<>>32-e}xe.rotl32=y5;function w5(t,e){return t+e>>>0}xe.sum32=w5;function x5(t,e,r){return t+e+r>>>0}xe.sum32_3=x5;function b5(t,e,r,n){return t+e+r+n>>>0}xe.sum32_4=b5;function E5(t,e,r,n,i){return t+e+r+n+i>>>0}xe.sum32_5=E5;function A5(t,e,r,n){var i=t[e],s=t[e+1],o=n+s>>>0,a=(o>>0,t[e+1]=o}xe.sum64=A5;function _5(t,e,r,n){var i=e+n>>>0,s=(i>>0}xe.sum64_hi=_5;function S5(t,e,r,n){var i=e+n;return i>>>0}xe.sum64_lo=S5;function k5(t,e,r,n,i,s,o,a){var l=0,u=e;u=u+n>>>0,l+=u>>0,l+=u>>0,l+=u>>0}xe.sum64_4_hi=k5;function N5(t,e,r,n,i,s,o,a){var l=e+n+s+a;return l>>>0}xe.sum64_4_lo=N5;function M5(t,e,r,n,i,s,o,a,l,u){var c=0,h=e;h=h+n>>>0,c+=h>>0,c+=h>>0,c+=h>>0,c+=h>>0}xe.sum64_5_hi=M5;function C5(t,e,r,n,i,s,o,a,l,u){var c=e+n+s+a+u;return c>>>0}xe.sum64_5_lo=C5;function P5(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}xe.rotr64_hi=P5;function R5(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}xe.rotr64_lo=R5;function I5(t,e,r){return t>>>r}xe.shr64_hi=I5;function O5(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}xe.shr64_lo=O5;var no={},Zp=xe,T5=Ra;function Yu(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}no.BlockHash=Yu;Yu.prototype.update=function(e,r){if(e=Zp.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=Zp.join32(e,0,e.length-n,this.endian);for(var i=0;i>>24&255,i[s++]=e>>>16&255,i[s++]=e>>>8&255,i[s++]=e&255}else for(i[s++]=e&255,i[s++]=e>>>8&255,i[s++]=e>>>16&255,i[s++]=e>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,o=8;o>>3}bn.g0_256=F5;function U5(t){return dn(t,17)^dn(t,19)^t>>>10}bn.g1_256=U5;var Gs=xe,z5=no,$5=bn,rf=Gs.rotl32,go=Gs.sum32,H5=Gs.sum32_5,V5=$5.ft_1,my=z5.BlockHash,q5=[1518500249,1859775393,2400959708,3395469782];function yn(){if(!(this instanceof yn))return new yn;my.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Gs.inherits(yn,my);var G5=yn;yn.blockSize=512;yn.outSize=160;yn.hmacStrength=80;yn.padLength=64;yn.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;ithis.blockSize&&(e=new this.Hash().update(e).digest()),OA(e.length<=this.blockSize);for(var r=e.length;r{s[a.toLowerCase()]=o}):n.headers.keys().forEach(o=>{s[o.toLowerCase()]=n.headers.get(o)}),{headers:s,statusCode:n.status,statusMessage:n.statusText,body:oe(new Uint8Array(i))}})}var DA=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Ur=new j(jA);function im(t){return new Promise(e=>{setTimeout(e,t)})}function ni(t,e){if(t==null)return null;if(typeof t=="string")return t;if(Fd(t)){if(e&&(e.split("/")[0]==="text"||e.split(";")[0].trim()==="application/json"))try{return Pa(t)}catch{}return ne(t)}return t}function FA(t){return yr(t.replace(/%([0-9a-f][0-9a-f])/gi,(e,r)=>String.fromCharCode(parseInt(r,16))))}function UA(t,e,r){const n=typeof t=="object"&&t.throttleLimit!=null?t.throttleLimit:12;Ur.assertArgument(n>0&&n%1===0,"invalid connection throttle limit","connection.throttleLimit",n);const i=typeof t=="object"?t.throttleCallback:null,s=typeof t=="object"&&typeof t.throttleSlotInterval=="number"?t.throttleSlotInterval:100;Ur.assertArgument(s>0&&s%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",s);const o=typeof t=="object"?!!t.errorPassThrough:!1,a={};let l=null;const u={method:"GET"};let c=!1,h=2*60*1e3;if(typeof t=="string")l=t;else if(typeof t=="object"){if((t==null||t.url==null)&&Ur.throwArgumentError("missing URL","connection.url",t),l=t.url,typeof t.timeout=="number"&&t.timeout>0&&(h=t.timeout),t.headers)for(const x in t.headers)a[x.toLowerCase()]={key:x,value:String(t.headers[x])},["if-none-match","if-modified-since"].indexOf(x.toLowerCase())>=0&&(c=!0);if(u.allowGzip=!!t.allowGzip,t.user!=null&&t.password!=null){l.substring(0,6)!=="https:"&&t.allowInsecureAuthentication!==!0&&Ur.throwError("basic authentication requires a secure https url",j.errors.INVALID_ARGUMENT,{argument:"url",url:l,user:t.user,password:"[REDACTED]"});const x=t.user+":"+t.password;a.authorization={key:"Authorization",value:"Basic "+q1(yr(x))}}t.skipFetchSetup!=null&&(u.skipFetchSetup=!!t.skipFetchSetup),t.fetchOptions!=null&&(u.fetchOptions=at(t.fetchOptions))}const p=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),m=l?l.match(p):null;if(m)try{const x={statusCode:200,statusMessage:"OK",headers:{"content-type":m[1]||"text/plain"},body:m[2]?V1(m[3]):FA(m[3])};let w=x.body;return r&&(w=r(x.body,x)),Promise.resolve(w)}catch(x){Ur.throwError("processing response error",j.errors.SERVER_ERROR,{body:ni(m[1],m[2]),error:x,requestBody:null,requestMethod:"GET",url:l})}e&&(u.method="POST",u.body=e,a["content-type"]==null&&(a["content-type"]={key:"Content-Type",value:"application/octet-stream"}),a["content-length"]==null&&(a["content-length"]={key:"Content-Length",value:String(e.length)}));const v={};Object.keys(a).forEach(x=>{const w=a[x];v[w.key]=w.value}),u.headers=v;const b=function(){let x=null;return{promise:new Promise(function(T,I){h&&(x=setTimeout(()=>{x!=null&&(x=null,I(Ur.makeError("timeout",j.errors.TIMEOUT,{requestBody:ni(u.body,v["content-type"]),requestMethod:u.method,timeout:h,url:l})))},h))}),cancel:function(){x!=null&&(clearTimeout(x),x=null)}}}(),k=function(){return DA(this,void 0,void 0,function*(){for(let x=0;x=300)&&(b.cancel(),Ur.throwError("bad response",j.errors.SERVER_ERROR,{status:w.statusCode,headers:w.headers,body:ni(A,w.headers?w.headers["content-type"]:null),requestBody:ni(u.body,v["content-type"]),requestMethod:u.method,url:l})),r)try{const T=yield r(A,w);return b.cancel(),T}catch(T){if(T.throttleRetry&&x{let a=null;if(s!=null)try{a=JSON.parse(Pa(s))}catch(l){Ur.throwError("invalid JSON",j.errors.SERVER_ERROR,{body:s,error:l})}return r&&(a=r(a,o)),a},i=null;if(e!=null){i=yr(e);const s=typeof t=="string"?{url:t}:at(t);s.headers?Object.keys(s.headers).filter(a=>a.toLowerCase()==="content-type").length!==0||(s.headers=at(s.headers),s.headers["content-type"]="application/json"):s.headers={"content-type":"application/json"},t=s}return UA(t,i,n)}function As(t,e){return e||(e={}),e=at(e),e.floor==null&&(e.floor=0),e.ceiling==null&&(e.ceiling=1e4),e.interval==null&&(e.interval=250),new Promise(function(r,n){let i=null,s=!1;const o=()=>s?!1:(s=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{o()&&n(new Error("timeout"))},e.timeout));const a=e.retryLimit;let l=0;function u(){return t().then(function(c){if(c!==void 0)o()&&r(c);else if(e.oncePoll)e.oncePoll.once("poll",u);else if(e.onceBlock)e.onceBlock.once("block",u);else if(!s){if(l++,l>a){o()&&n(new Error("retry limit reached"));return}let h=e.interval*parseInt(String(Math.random()*Math.pow(2,l)));he.ceiling&&(h=e.ceiling),setTimeout(u,h)}return null},function(c){o()&&n(c)})}u()})}var lu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Nh={};for(var tl=0;tl>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function ky(t){for(var e=1,r=0;r126)return"Invalid prefix ("+t+")";e=js(e)^n>>5}for(e=js(e),r=0;rr)throw new TypeError("Exceeds length limit");t=t.toLowerCase();var n=ky(t);if(typeof n=="string")throw new Error(n);for(var i=t+"1",s=0;s>5)throw new Error("Non 5-bit word");n=js(n)^o,i+=lu.charAt(o)}for(s=0;s<6;++s)n=js(n);for(n^=1,s=0;s<6;++s){var a=n>>(5-s)*5&31;i+=lu.charAt(a)}return i}function Ny(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";var r=t.toLowerCase(),n=t.toUpperCase();if(t!==r&&t!==n)return"Mixed-case string "+t;t=r;var i=t.lastIndexOf("1");if(i===-1)return"No separator character for "+t;if(i===0)return"Missing prefix for "+t;var s=t.slice(0,i),o=t.slice(i+1);if(o.length<6)return"Data too short";var a=ky(s);if(typeof a=="string")return a;for(var l=[],u=0;u=o.length)&&l.push(h)}return a!==1?"Invalid checksum for "+t:{prefix:s,words:l}}function $A(){var t=Ny.apply(null,arguments);if(typeof t=="object")return t}function HA(t){var e=Ny.apply(null,arguments);if(typeof e=="object")return e;throw new Error(e)}function Xu(t,e,r,n){for(var i=0,s=0,o=(1<=r;)s-=r,a.push(i>>s&o);if(n)s>0&&a.push(i<=e)return"Excess padding";if(i<>8,p=c&255;h?l.push(h,p):l.push(p)}return l}r.toArray=n;function i(o){return o.length===1?"0"+o:o}r.zero2=i;function s(o){for(var a="",l=0;l(p>>1)-1?b=(p>>1)-k:b=k,m.isubn(b)):b=0,h[v]=b,m.iushrn(1)}return h}r.getNAF=n;function i(l,u){var c=[[],[]];l=l.clone(),u=u.clone();for(var h=0,p=0,m;l.cmpn(-h)>0||u.cmpn(-p)>0;){var v=l.andln(3)+h&3,b=u.andln(3)+p&3;v===3&&(v=-1),b===3&&(b=-1);var k;v&1?(m=l.andln(7)+h&7,(m===3||m===5)&&b===2?k=-v:k=v):k=0,c[0].push(k);var x;b&1?(m=u.andln(7)+p&7,(m===3||m===5)&&v===2?x=-b:x=b):x=0,c[1].push(x),2*h===k+1&&(h=1-h),2*p===x+1&&(p=1-p),l.iushrn(1),u.iushrn(1)}return c}r.getJSF=i;function s(l,u,c){var h="_"+u;l.prototype[u]=function(){return this[h]!==void 0?this[h]:this[h]=c.call(this)}}r.cachedProperty=s;function o(l){return typeof l=="string"?r.toArray(l,"hex"):l}r.parseBytes=o;function a(l){return new ce(l,"hex","le")}r.intFromLE=a}),uu=br.getNAF,JA=br.getJSF,cu=br.assert;function Ci(t,e){this.type=t,this.p=new ce(e.p,16),this.red=e.prime?ce.red(e.prime):ce.mont(this.p),this.zero=new ce(0).toRed(this.red),this.one=new ce(1).toRed(this.red),this.two=new ce(2).toRed(this.red),this.n=e.n&&new ce(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var ts=Ci;Ci.prototype.point=function(){throw new Error("Not implemented")};Ci.prototype.validate=function(){throw new Error("Not implemented")};Ci.prototype._fixedNafMul=function(e,r){cu(e.precomputed);var n=e._getDoubles(),i=uu(r,1,this._bitLength),s=(1<=a;u--)l=(l<<1)+i[u];o.push(l)}for(var c=this.jpoint(null,null,null),h=this.jpoint(null,null,null),p=s;p>0;p--){for(a=0;a=0;l--){for(var u=0;l>=0&&o[l]===0;l--)u++;if(l>=0&&u++,a=a.dblp(u),l<0)break;var c=o[l];cu(c!==0),e.type==="affine"?c>0?a=a.mixedAdd(s[c-1>>1]):a=a.mixedAdd(s[-c-1>>1].neg()):c>0?a=a.add(s[c-1>>1]):a=a.add(s[-c-1>>1].neg())}return e.type==="affine"?a.toP():a};Ci.prototype._wnafMulAdd=function(e,r,n,i,s){var o=this._wnafT1,a=this._wnafT2,l=this._wnafT3,u=0,c,h,p;for(c=0;c=1;c-=2){var v=c-1,b=c;if(o[v]!==1||o[b]!==1){l[v]=uu(n[v],o[v],this._bitLength),l[b]=uu(n[b],o[b],this._bitLength),u=Math.max(l[v].length,u),u=Math.max(l[b].length,u);continue}var k=[r[v],null,null,r[b]];r[v].y.cmp(r[b].y)===0?(k[1]=r[v].add(r[b]),k[2]=r[v].toJ().mixedAdd(r[b].neg())):r[v].y.cmp(r[b].y.redNeg())===0?(k[1]=r[v].toJ().mixedAdd(r[b]),k[2]=r[v].add(r[b].neg())):(k[1]=r[v].toJ().mixedAdd(r[b]),k[2]=r[v].toJ().mixedAdd(r[b].neg()));var x=[-3,-1,-5,-7,0,7,5,1,3],w=JA(n[v],n[b]);for(u=Math.max(w[0].length,u),l[v]=new Array(u),l[b]=new Array(u),h=0;h=0;c--){for(var F=0;c>=0;){var $=!0;for(h=0;h=0&&F++,I=I.dblp(F),c<0)break;for(h=0;h0?p=a[h][V-1>>1]:V<0&&(p=a[h][-V-1>>1].neg()),p.type==="affine"?I=I.mixedAdd(p):I=I.add(p))}}for(c=0;c=Math.ceil((e.bitLength()+1)/r.step):!1};Tr.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,s=0;s=0&&(m=u,v=c),h.negative&&(h=h.neg(),p=p.neg()),m.negative&&(m=m.neg(),v=v.neg()),[{a:h,b:p},{a:m,b:v}]};jr.prototype._endoSplit=function(e){var r=this.endo.basis,n=r[0],i=r[1],s=i.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=s.mul(n.a),l=o.mul(i.a),u=s.mul(n.b),c=o.mul(i.b),h=e.sub(a).sub(l),p=u.add(c).neg();return{k1:h,k2:p}};jr.prototype.pointFromX=function(e,r){e=new ce(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(r&&!s||!r&&s)&&(i=i.redNeg()),this.point(e,i)};jr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0};jr.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};Ct.prototype.isInfinity=function(){return this.inf};Ct.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)};Ct.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),s=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};Ct.prototype.getX=function(){return this.x.fromRed()};Ct.prototype.getY=function(){return this.y.fromRed()};Ct.prototype.mul=function(e){return e=new ce(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Ct.prototype.mulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)};Ct.prototype.jmulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)};Ct.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Ct.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(s){return s.neg()};r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r};Ct.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Bt(t,e,r,n){ts.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new ce(0)):(this.x=new ce(e,16),this.y=new ce(r,16),this.z=new ce(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Wd(Bt,ts.BasePoint);jr.prototype.jpoint=function(e,r,n){return new Bt(this,e,r,n)};Bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)};Bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),s=e.x.redMul(n),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),l=i.redSub(s),u=o.redSub(a);if(l.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=l.redSqr(),h=c.redMul(l),p=i.redMul(c),m=u.redSqr().redIAdd(h).redISub(p).redISub(p),v=u.redMul(p.redISub(m)).redISub(o.redMul(h)),b=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(m,v,b)};Bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=n.redSub(i),l=s.redSub(o);if(a.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),h=n.redMul(u),p=l.redSqr().redIAdd(c).redISub(h).redISub(h),m=l.redMul(h.redISub(p)).redISub(s.redMul(c)),v=this.z.redMul(a);return this.curve.jpoint(p,m,v)};Bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r=0)return!1;if(n.redIAdd(s),this.x.cmp(n)===0)return!0}};Bt.prototype.inspect=function(){return this.isInfinity()?"":""};Bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Nl=oo(function(t,e){var r=e;r.base=ts,r.short=XA,r.mont=null,r.edwards=null}),Ml=oo(function(t,e){var r=e,n=br.assert;function i(a){a.type==="short"?this.curve=new Nl.short(a):a.type==="edwards"?this.curve=new Nl.edwards(a):this.curve=new Nl.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=i;function s(a,l){Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get:function(){var u=new i(l);return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,value:u}),u}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:nn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:nn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:nn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:nn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:nn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:nn.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:nn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:nn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Gr.toArray(t.entropy,t.entropyEnc||"hex"),r=Gr.toArray(t.nonce,t.nonceEnc||"hex"),n=Gr.toArray(t.pers,t.persEnc||"hex");Gd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Cy=_i;_i.prototype._init=function(e,r,n){var i=e.concat(r).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1};_i.prototype.generate=function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=Gr.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length"};var ZA=br.assert;function Zu(t,e){if(t instanceof Zu)return t;this._importDER(t,e)||(ZA(t.r&&t.s,"Signature without r or s"),this.r=new ce(t.r,16),this.s=new ce(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var ec=Zu;function e4(){this.place=0}function af(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4)return!1;for(var i=0,s=0,o=e.place;s>>=0;return i<=127?!1:(e.place=o,i)}function om(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Zu.prototype.toDER=function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=om(r),n=om(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];lf(i,r.length),i=i.concat(r),i.push(2),lf(i,n.length);var s=i.concat(n),o=[48];return lf(o,s.length),o=o.concat(s),br.encode(o,e)};var t4=function(){throw new Error("unsupported")},Py=br.assert;function Or(t){if(!(this instanceof Or))return new Or(t);typeof t=="string"&&(Py(Object.prototype.hasOwnProperty.call(Ml,t),"Unknown curve "+t),t=Ml[t]),t instanceof Ml.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var r4=Or;Or.prototype.keyPair=function(e){return new Kd(this,e)};Or.prototype.keyFromPrivate=function(e,r){return Kd.fromPrivate(this,e,r)};Or.prototype.keyFromPublic=function(e,r){return Kd.fromPublic(this,e,r)};Or.prototype.genKeyPair=function(e){e||(e={});for(var r=new Cy({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||t4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new ce(2));;){var s=new ce(r.generate(n));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Or.prototype._truncateToN=function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e};Or.prototype.sign=function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new ce(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),l=new Cy({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new ce(1)),c=0;;c++){var h=i.k?i.k(c):new ce(l.generate(this.n.byteLength()));if(h=this._truncateToN(h,!0),!(h.cmpn(1)<=0||h.cmp(u)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var m=p.getX(),v=m.umod(this.n);if(v.cmpn(0)!==0){var b=h.invm(this.n).mul(v.mul(r.getPrivate()).iadd(e));if(b=b.umod(this.n),b.cmpn(0)!==0){var k=(p.getY().isOdd()?1:0)|(m.cmp(v)!==0?2:0);return i.canonical&&b.cmp(this.nh)>0&&(b=this.n.sub(b),k^=1),new ec({r:v,s:b,recoveryParam:k})}}}}}};Or.prototype.verify=function(e,r,n,i){e=this._truncateToN(new ce(e,16)),n=this.keyFromPublic(n,i),r=new ec(r,"hex");var s=r.r,o=r.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),l=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),c;return this.curve._maxwellTrick?(c=this.g.jmulAdd(l,n.getPublic(),u),c.isInfinity()?!1:c.eqXToP(s)):(c=this.g.mulAdd(l,n.getPublic(),u),c.isInfinity()?!1:c.getX().umod(this.n).cmp(s)===0)};Or.prototype.recoverPubKey=function(t,e,r,n){Py((3&r)===r,"The recovery param is more than two bits"),e=new ec(e,n);var i=this.n,s=new ce(t),o=e.r,a=e.s,l=r&1,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var c=e.r.invm(i),h=i.sub(s).mul(c).umod(i),p=a.mul(c).umod(i);return this.g.mulAdd(h,o,p)};Or.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new ec(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch{continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var n4=oo(function(t,e){var r=e;r.version="6.5.4",r.utils=br,r.rand=function(){throw new Error("unsupported")},r.curve=Nl,r.curves=Ml,r.ec=r4,r.eddsa=null}),i4=n4.ec;const s4="signing-key/5.7.0",Ch=new j(s4);let uf=null;function on(){return uf||(uf=new i4("secp256k1")),uf}class o4{constructor(e){H(this,"curve","secp256k1"),H(this,"privateKey",ne(e)),zn(this.privateKey)!==32&&Ch.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=on().keyFromPrivate(oe(this.privateKey));H(this,"publicKey","0x"+r.getPublic(!1,"hex")),H(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),H(this,"_isSigningKey",!0)}_addPoint(e){const r=on().keyFromPublic(oe(this.publicKey)),n=on().keyFromPublic(oe(e));return"0x"+r.pub.add(n.pub).encodeCompressed("hex")}signDigest(e){const r=on().keyFromPrivate(oe(this.privateKey)),n=oe(e);n.length!==32&&Ch.throwArgumentError("bad digest length","digest",e);const i=r.sign(n,{canonical:!0});return Gu({recoveryParam:i.recoveryParam,r:gt("0x"+i.r.toString(16),32),s:gt("0x"+i.s.toString(16),32)})}computeSharedSecret(e){const r=on().keyFromPrivate(oe(this.privateKey)),n=on().keyFromPublic(oe(Ry(e)));return gt("0x"+r.derive(n.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function a4(t,e){const r=Gu(e),n={r:oe(r.r),s:oe(r.s)};return"0x"+on().recoverPubKey(oe(t),n,r.recoveryParam).encode("hex",!1)}function Ry(t,e){const r=oe(t);if(r.length===32){const n=new o4(r);return e?"0x"+on().keyFromPrivate(r).getPublic(!0,"hex"):n.publicKey}else{if(r.length===33)return e?ne(r):"0x"+on().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+on().keyFromPublic(r).getPublic(!0,"hex"):ne(r)}return Ch.throwArgumentError("invalid public or private key","key","[REDACTED]")}const l4="transactions/5.7.0",qn=new j(l4);var am;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(am||(am={}));function Qd(t){return t==="0x"?null:vt(t)}function zt(t){return t==="0x"?W1:K.from(t)}function u4(t){const e=Ry(t);return vt(Tt(ot(Tt(e,1)),12))}function Iy(t,e){return u4(a4(oe(t),e))}function dr(t,e){const r=Vs(K.from(t).toHexString());return r.length>32&&qn.throwArgumentError("invalid length for "+e,"transaction:"+e,t),r}function cf(t,e){return{address:vt(t),storageKeys:(e||[]).map((r,n)=>(zn(r)!==32&&qn.throwArgumentError("invalid access list storageKey",`accessList[${t}:${n}]`,r),r.toLowerCase()))}}function rs(t){if(Array.isArray(t))return t.map((r,n)=>Array.isArray(r)?(r.length>2&&qn.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${n}]`,r),cf(r[0],r[1])):cf(r.address,r.storageKeys));const e=Object.keys(t).map(r=>{const n=t[r].reduce((i,s)=>(i[s]=!0,i),{});return cf(r,Object.keys(n).sort())});return e.sort((r,n)=>r.address.localeCompare(n.address)),e}function Oy(t){return rs(t).map(e=>[e.address,e.storageKeys])}function c4(t,e){if(t.gasPrice!=null){const n=K.from(t.gasPrice),i=K.from(t.maxFeePerGas||0);n.eq(i)||qn.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:n,maxFeePerGas:i})}const r=[dr(t.chainId||0,"chainId"),dr(t.nonce||0,"nonce"),dr(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),dr(t.maxFeePerGas||0,"maxFeePerGas"),dr(t.gasLimit||0,"gasLimit"),t.to!=null?vt(t.to):"0x",dr(t.value||0,"value"),t.data||"0x",Oy(t.accessList||[])];if(e){const n=Gu(e);r.push(dr(n.recoveryParam,"recoveryParam")),r.push(Vs(n.r)),r.push(Vs(n.s))}return nr(["0x02",Wu(r)])}function f4(t,e){const r=[dr(t.chainId||0,"chainId"),dr(t.nonce||0,"nonce"),dr(t.gasPrice||0,"gasPrice"),dr(t.gasLimit||0,"gasLimit"),t.to!=null?vt(t.to):"0x",dr(t.value||0,"value"),t.data||"0x",Oy(t.accessList||[])];if(e){const n=Gu(e);r.push(dr(n.recoveryParam,"recoveryParam")),r.push(Vs(n.r)),r.push(Vs(n.s))}return nr(["0x01",Wu(r)])}function Ty(t,e,r){try{const n=zt(e[0]).toNumber();if(n!==0&&n!==1)throw new Error("bad recid");t.v=n}catch{qn.throwArgumentError("invalid v for transaction type: 1","v",e[0])}t.r=gt(e[1],32),t.s=gt(e[2],32);try{const n=ot(r(t));t.from=Iy(n,{r:t.r,s:t.s,recoveryParam:t.v})}catch{}}function h4(t){const e=zd(t.slice(1));e.length!==9&&e.length!==12&&qn.throwArgumentError("invalid component count for transaction type: 2","payload",ne(t));const r=zt(e[2]),n=zt(e[3]),i={type:2,chainId:zt(e[0]).toNumber(),nonce:zt(e[1]).toNumber(),maxPriorityFeePerGas:r,maxFeePerGas:n,gasPrice:null,gasLimit:zt(e[4]),to:Qd(e[5]),value:zt(e[6]),data:e[7],accessList:rs(e[8])};return e.length===9||(i.hash=ot(t),Ty(i,e.slice(9),c4)),i}function d4(t){const e=zd(t.slice(1));e.length!==8&&e.length!==11&&qn.throwArgumentError("invalid component count for transaction type: 1","payload",ne(t));const r={type:1,chainId:zt(e[0]).toNumber(),nonce:zt(e[1]).toNumber(),gasPrice:zt(e[2]),gasLimit:zt(e[3]),to:Qd(e[4]),value:zt(e[5]),data:e[6],accessList:rs(e[7])};return e.length===8||(r.hash=ot(t),Ty(r,e.slice(8),f4)),r}function p4(t){const e=zd(t);e.length!==9&&e.length!==6&&qn.throwArgumentError("invalid raw transaction","rawTransaction",t);const r={nonce:zt(e[0]).toNumber(),gasPrice:zt(e[1]),gasLimit:zt(e[2]),to:Qd(e[3]),value:zt(e[4]),data:e[5],chainId:0};if(e.length===6)return r;try{r.v=K.from(e[6]).toNumber()}catch{return r}if(r.r=gt(e[7],32),r.s=gt(e[8],32),K.from(r.r).isZero()&&K.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27;const i=e.slice(0,6);r.chainId!==0&&(i.push(ne(r.chainId)),i.push("0x"),i.push("0x"),n-=r.chainId*2+8);const s=ot(Wu(i));try{r.from=Iy(s,{r:ne(r.r),s:ne(r.s),recoveryParam:n})}catch{}r.hash=ot(t)}return r.type=null,r}function m4(t){const e=oe(t);if(e[0]>127)return p4(e);switch(e[0]){case 1:return d4(e);case 2:return h4(e)}return qn.throwError(`unsupported transaction type: ${e[0]}`,j.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}const yo=new j(qt);class ee{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const e={},r=this.address.bind(this),n=this.bigNumber.bind(this),i=this.blockTag.bind(this),s=this.data.bind(this),o=this.hash.bind(this),a=this.hex.bind(this),l=this.number.bind(this),u=this.type.bind(this),c=h=>this.data(h,!0);return e.transaction={hash:o,type:u,accessList:ee.allowNull(this.accessList.bind(this),null),blockHash:ee.allowNull(o,null),blockNumber:ee.allowNull(l,null),transactionIndex:ee.allowNull(l,null),confirmations:ee.allowNull(l,null),from:r,gasPrice:ee.allowNull(n),maxPriorityFeePerGas:ee.allowNull(n),maxFeePerGas:ee.allowNull(n),gasLimit:n,to:ee.allowNull(r,null),value:n,nonce:l,data:s,r:ee.allowNull(this.uint256),s:ee.allowNull(this.uint256),v:ee.allowNull(l),creates:ee.allowNull(r,null),raw:ee.allowNull(s)},e.transactionRequest={from:ee.allowNull(r),nonce:ee.allowNull(l),gasLimit:ee.allowNull(n),gasPrice:ee.allowNull(n),maxPriorityFeePerGas:ee.allowNull(n),maxFeePerGas:ee.allowNull(n),to:ee.allowNull(r),value:ee.allowNull(n),data:ee.allowNull(c),type:ee.allowNull(l),accessList:ee.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:l,blockNumber:l,transactionHash:o,address:r,topics:ee.arrayOf(o),data:s,logIndex:l,blockHash:o},e.receipt={to:ee.allowNull(this.address,null),from:ee.allowNull(this.address,null),contractAddress:ee.allowNull(r,null),transactionIndex:l,root:ee.allowNull(a),gasUsed:n,logsBloom:ee.allowNull(s),blockHash:o,transactionHash:o,logs:ee.arrayOf(this.receiptLog.bind(this)),blockNumber:l,confirmations:ee.allowNull(l,null),cumulativeGasUsed:n,effectiveGasPrice:ee.allowNull(n),status:ee.allowNull(l),type:u},e.block={hash:ee.allowNull(o),parentHash:o,number:l,timestamp:l,nonce:ee.allowNull(a),difficulty:this.difficulty.bind(this),gasLimit:n,gasUsed:n,miner:ee.allowNull(r),extraData:s,transactions:ee.allowNull(ee.arrayOf(o)),baseFeePerGas:ee.allowNull(n)},e.blockWithTransactions=at(e.block),e.blockWithTransactions.transactions=ee.allowNull(ee.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:ee.allowNull(i,void 0),toBlock:ee.allowNull(i,void 0),blockHash:ee.allowNull(o,void 0),address:ee.allowNull(r,void 0),topics:ee.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:ee.allowNull(l),blockHash:ee.allowNull(o),transactionIndex:l,removed:ee.allowNull(this.boolean.bind(this)),address:r,data:ee.allowFalsish(s,"0x"),topics:ee.arrayOf(o),transactionHash:o,logIndex:l},e}accessList(e){return rs(e||[])}number(e){return e==="0x"?0:K.from(e).toNumber()}type(e){return e==="0x"||e==null?0:K.from(e).toNumber()}bigNumber(e){return K.from(e)}boolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return!0;if(e==="false")return!1}throw new Error("invalid boolean - "+e)}hex(e,r){return typeof e=="string"&&(!r&&e.substring(0,2)!=="0x"&&(e="0x"+e),me(e))?e.toLowerCase():yo.throwArgumentError("invalid hash","value",e)}data(e,r){const n=this.hex(e,r);if(n.length%2!==0)throw new Error("invalid data; odd-length - "+e);return n}address(e){return vt(e)}callAddress(e){if(!me(e,32))return null;const r=vt(Tt(e,12));return r===xE?null:r}contractAddress(e){return Hd(e)}blockTag(e){if(e==null)return"latest";if(e==="earliest")return"0x0";switch(e){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return e}if(typeof e=="number"||me(e))return qu(e);throw new Error("invalid blockTag")}hash(e,r){const n=this.hex(e,r);return zn(n)!==32?yo.throwArgumentError("invalid hash","value",e):n}difficulty(e){if(e==null)return null;const r=K.from(e);try{return r.toNumber()}catch{}return null}uint256(e){if(!me(e))throw new Error("invalid uint256");return gt(e,32)}_block(e,r){e.author!=null&&e.miner==null&&(e.miner=e.author);const n=e._difficulty!=null?e._difficulty:e.difficulty,i=ee.check(r,e);return i._difficulty=n==null?null:K.from(n),i}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return ee.check(this.formats.transactionRequest,e)}transactionResponse(e){e.gas!=null&&e.gasLimit==null&&(e.gasLimit=e.gas),e.to&&K.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),e.input!=null&&e.data==null&&(e.data=e.input),e.to==null&&e.creates==null&&(e.creates=this.contractAddress(e)),(e.type===1||e.type===2)&&e.accessList==null&&(e.accessList=[]);const r=ee.check(this.formats.transaction,e);if(e.chainId!=null){let n=e.chainId;me(n)&&(n=K.from(n).toNumber()),r.chainId=n}else{let n=e.networkId;n==null&&r.v==null&&(n=e.chainId),me(n)&&(n=K.from(n).toNumber()),typeof n!="number"&&r.v!=null&&(n=(r.v-35)/2,n<0&&(n=0),n=parseInt(n)),typeof n!="number"&&(n=0),r.chainId=n}return r.blockHash&&r.blockHash.replace(/0/g,"")==="x"&&(r.blockHash=null),r}transaction(e){return m4(e)}receiptLog(e){return ee.check(this.formats.receiptLog,e)}receipt(e){const r=ee.check(this.formats.receipt,e);if(r.root!=null)if(r.root.length<=4){const n=K.from(r.root).toNumber();n===0||n===1?(r.status!=null&&r.status!==n&&yo.throwArgumentError("alt-root-status/status mismatch","value",{root:r.root,status:r.status}),r.status=n,delete r.root):yo.throwArgumentError("invalid alt-root-status","value.root",r.root)}else r.root.length!==66&&yo.throwArgumentError("invalid root hash","value.root",r.root);return r.status!=null&&(r.byzantium=!0),r}topics(e){return Array.isArray(e)?e.map(r=>this.topics(r)):e!=null?this.hash(e,!0):null}filter(e){return ee.check(this.formats.filter,e)}filterLog(e){return ee.check(this.formats.filterLog,e)}static check(e,r){const n={};for(const i in e)try{const s=e[i](r[i]);s!==void 0&&(n[i]=s)}catch(s){throw s.checkKey=i,s.checkValue=r[i],s}return n}static allowNull(e,r){return function(n){return n==null?r:e(n)}}static allowFalsish(e,r){return function(n){return n?e(n):r}}static arrayOf(e){return function(r){if(!Array.isArray(r))throw new Error("not an array");const n=[];return r.forEach(function(i){n.push(e(i))}),n}}}function jy(t){return t&&typeof t.isCommunityResource=="function"}function Ph(t){return jy(t)&&t.isCommunityResource()}let lm=!1;function Oa(){lm||(lm=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var le=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const pe=new j(qt),g4=10;function um(t){return t==null?"null":(zn(t)!==32&&pe.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function cm(t){for(t=t.slice();t.length>0&&t[t.length-1]==null;)t.pop();return t.map(e=>{if(Array.isArray(e)){const r={};e.forEach(i=>{r[um(i)]=!0});const n=Object.keys(r);return n.sort(),n.join("|")}else return um(e)}).join("&")}function v4(t){return t===""?[]:t.split(/&/g).map(e=>{if(e==="")return[];const r=e.split("|").map(n=>n==="null"?null:n);return r.length===1?r[0]:r})}function is(t){if(typeof t=="string"){if(t=t.toLowerCase(),zn(t)===32)return"tx:"+t;if(t.indexOf(":")===-1)return t}else{if(Array.isArray(t))return"filter:*:"+cm(t);if(vE.isForkEvent(t))throw pe.warn("not implemented"),new Error("not implemented");if(t&&typeof t=="object")return"filter:"+(t.address||"*")+":"+cm(t.topics||[])}throw new Error("invalid event - "+t)}function wo(){return new Date().getTime()}function fm(t){return new Promise(e=>{setTimeout(e,t)})}const y4=["block","network","pending","poll"];class w4{constructor(e,r,n){H(this,"tag",e),H(this,"listener",r),H(this,"once",n),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const e=this.tag.split(":");return e[0]!=="tx"?null:e[1]}get filter(){const e=this.tag.split(":");if(e[0]!=="filter")return null;const r=e[1],n=v4(e[2]),i={};return n.length>0&&(i.topics=n),r&&r!=="*"&&(i.address=r),i}pollable(){return this.tag.indexOf(":")>=0||y4.indexOf(this.tag)>=0}}const x4={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function ff(t){return gt(K.from(t).toHexString(),32)}function hm(t){return Ah.encode($t([t,Tt(nm(nm(t)),0,4)]))}const Ly=new RegExp("^(ipfs)://(.*)$","i"),dm=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Ly,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Cl(t,e){try{return Pa(ha(t,e))}catch{}return null}function ha(t,e){if(t==="0x")return null;const r=K.from(Tt(t,e,e+32)).toNumber(),n=K.from(Tt(t,r,r+32)).toNumber();return Tt(t,r+32,r+32+n)}function hf(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):pe.throwArgumentError("unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}function pm(t){const e=oe(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}function b4(t){if(t.length%32===0)return t;const e=new Uint8Array(Math.ceil(t.length/32)*32);return e.set(t),e}function By(t){const e=[];let r=0;for(let n=0;nK.from(e).eq(1)).catch(e=>{if(e.code===j.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,e})),this._supportsEip2544}_fetch(e,r){return le(this,void 0,void 0,function*(){const n={to:this.address,ccipReadEnabled:!0,data:nr([e,kl(this.name),r||"0x"])};let i=!1;(yield this.supportsWildcard())&&(i=!0,n.data=nr(["0x9061b923",By([e5(this.name),n.data])]));try{let s=yield this.provider.call(n);return oe(s).length%32===4&&pe.throwError("resolver threw error",j.errors.CALL_EXCEPTION,{transaction:n,data:s}),i&&(s=ha(s,0)),s}catch(s){if(s.code===j.errors.CALL_EXCEPTION)return null;throw s}})}_fetchBytes(e,r){return le(this,void 0,void 0,function*(){const n=yield this._fetch(e,r);return n!=null?ha(n,0):null})}_getAddress(e,r){const n=x4[String(e)];if(n==null&&pe.throwError(`unsupported coin type: ${e}`,j.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),n.ilk==="eth")return this.provider.formatter.address(r);const i=oe(r);if(n.p2pkh!=null){const s=r.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return hm($t([[n.p2pkh],"0x"+s[2]]))}}if(n.p2sh!=null){const s=r.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return hm($t([[n.p2sh],"0x"+s[2]]))}}if(n.prefix!=null){const s=i[1];let o=i[0];if(o===0?s!==20&&s!==32&&(o=-1):o=-1,o>=0&&i.length===2+s&&s>=1&&s<=75){const a=sm.toWords(i.slice(2));return a.unshift(o),sm.encode(n.prefix,a)}}return null}getAddress(e){return le(this,void 0,void 0,function*(){if(e==null&&(e=60),e===60)try{const i=yield this._fetch("0x3b3b57de");return i==="0x"||i===_E?null:this.provider.formatter.callAddress(i)}catch(i){if(i.code===j.errors.CALL_EXCEPTION)return null;throw i}const r=yield this._fetchBytes("0xf1cb7e06",ff(e));if(r==null||r==="0x")return null;const n=this._getAddress(e,r);return n==null&&pe.throwError("invalid or unsupported coin data",j.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:r}),n})}getAvatar(){return le(this,void 0,void 0,function*(){const e=[{type:"name",content:this.name}];try{const r=yield this.getText("avatar");if(r==null)return null;for(let n=0;no[l])}return pe.throwError("invalid or unsupported content hash data",j.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})})}getText(e){return le(this,void 0,void 0,function*(){let r=yr(e);r=$t([ff(64),ff(r.length),r]),r.length%32!==0&&(r=$t([r,gt("0x",32-e.length%32)]));const n=yield this._fetchBytes("0x59d1d43c",ne(r));return n==null||n==="0x"?null:Pa(n)})}}let df=null,E4=1;class tc extends ro{constructor(e){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),H(this,"anyNetwork",e==="any"),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch(r=>{}),this._ready().catch(r=>{});else{const r=mr(new.target,"getNetwork")(e);r?(H(this,"_network",r),this.emit("network",r,null)):pe.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return le(this,void 0,void 0,function*(){if(this._network==null){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch{}e==null&&(e=yield this.detectNetwork()),e||pe.throwError("no network detected",j.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=e:H(this,"_network",e),this.emit("network",e,null))}return this._network})}get ready(){return As(()=>this._ready().then(e=>e,e=>{if(!(e.code===j.errors.NETWORK_ERROR&&e.event==="noNetwork"))throw e}))}static getFormatter(){return df==null&&(df=new ee),df}static getNetwork(e){return qd(e??"homestead")}ccipReadFetch(e,r,n){return le(this,void 0,void 0,function*(){if(this.disableCcipRead||n.length===0)return null;const i=e.to.toLowerCase(),s=r.toLowerCase(),o=[];for(let a=0;a=0?null:JSON.stringify({data:s,sender:i}),h=yield Ia({url:u,errorPassThrough:!0},c,(m,v)=>(m.status=v.statusCode,m));if(h.data)return h.data;const p=h.message||"unknown error";if(h.status>=400&&h.status<500)return pe.throwError(`response not found during CCIP fetch: ${p}`,j.errors.SERVER_ERROR,{url:l,errorMessage:p});o.push(p)}return pe.throwError(`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,j.errors.SERVER_ERROR,{urls:n,errorMessages:o})})}_getInternalBlockNumber(e){return le(this,void 0,void 0,function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){const i=this._internalBlockNumber;try{const s=yield i;if(wo()-s.respTime<=e)return s.blockNumber;break}catch{if(this._internalBlockNumber===i)break}}const r=wo(),n=xt({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(i=>null,i=>i)}).then(({blockNumber:i,networkError:s})=>{if(s)throw this._internalBlockNumber===n&&(this._internalBlockNumber=null),s;const o=wo();return i=K.from(i).toNumber(),i{this._internalBlockNumber===n&&(this._internalBlockNumber=null)}),(yield n).blockNumber})}poll(){return le(this,void 0,void 0,function*(){const e=E4++,r=[];let n=null;try{n=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(i){this.emit("error",i);return}if(this._setFastBlockNumber(n),this.emit("poll",e,n),n===this._lastBlockNumber){this.emit("didPoll",e);return}if(this._emitted.block===-2&&(this._emitted.block=n-1),Math.abs(this._emitted.block-n)>1e3)pe.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${n})`),this.emit("error",pe.makeError("network block skew detected",j.errors.NETWORK_ERROR,{blockNumber:n,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",n);else for(let i=this._emitted.block+1;i<=n;i++)this.emit("block",i);this._emitted.block!==n&&(this._emitted.block=n,Object.keys(this._emitted).forEach(i=>{if(i==="block")return;const s=this._emitted[i];s!=="pending"&&n-s>12&&delete this._emitted[i]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=n-1),this._events.forEach(i=>{switch(i.type){case"tx":{const s=i.hash;let o=this.getTransactionReceipt(s).then(a=>(!a||a.blockNumber==null||(this._emitted["t:"+s]=a.blockNumber,this.emit(s,a)),null)).catch(a=>{this.emit("error",a)});r.push(o);break}case"filter":{if(!i._inflight){i._inflight=!0,i._lastBlockNumber===-2&&(i._lastBlockNumber=n-1);const s=i.filter;s.fromBlock=i._lastBlockNumber+1,s.toBlock=n;const o=s.toBlock-this._maxFilterBlockRange;o>s.fromBlock&&(s.fromBlock=o),s.fromBlock<0&&(s.fromBlock=0);const a=this.getLogs(s).then(l=>{i._inflight=!1,l.length!==0&&l.forEach(u=>{u.blockNumber>i._lastBlockNumber&&(i._lastBlockNumber=u.blockNumber),this._emitted["b:"+u.blockHash]=u.blockNumber,this._emitted["t:"+u.transactionHash]=u.blockNumber,this.emit(s,u)})}).catch(l=>{this.emit("error",l),i._inflight=!1});r.push(a)}break}}}),this._lastBlockNumber=n,Promise.all(r).then(()=>{this.emit("didPoll",e)}).catch(i=>{this.emit("error",i)})})}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return le(this,void 0,void 0,function*(){return pe.throwError("provider does not support network detection",j.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return le(this,void 0,void 0,function*(){const e=yield this._ready(),r=yield this.detectNetwork();if(e.chainId!==r.chainId){if(this.anyNetwork)return this._network=r,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",r,e),yield fm(0),this._network;const n=pe.makeError("underlying network changed",j.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:r});throw this.emit("error",n),n}return e})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(e=>{this._setFastBlockNumber(e)},e=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(e){e&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if(typeof e!="number"||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const e=wo();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then(r=>((this._fastBlockNumber==null||r>this._fastBlockNumber)&&(this._fastBlockNumber=r),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(e){this._fastBlockNumber!=null&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,r,n){return le(this,void 0,void 0,function*(){return this._waitForTransaction(e,r??1,n||0,null)})}_waitForTransaction(e,r,n,i){return le(this,void 0,void 0,function*(){const s=yield this.getTransactionReceipt(e);return(s?s.confirmations:0)>=r?s:new Promise((o,a)=>{const l=[];let u=!1;const c=function(){return u?!0:(u=!0,l.forEach(p=>{p()}),!1)},h=p=>{p.confirmations{this.removeListener(e,h)}),i){let p=i.startBlock,m=null;const v=b=>le(this,void 0,void 0,function*(){u||(yield fm(1e3),this.getTransactionCount(i.from).then(k=>le(this,void 0,void 0,function*(){if(!u){if(k<=i.nonce)p=b;else{{const x=yield this.getTransaction(e);if(x&&x.blockNumber!=null)return}for(m==null&&(m=p-3,m{u||this.once("block",v)}))});if(u)return;this.once("block",v),l.push(()=>{this.removeListener("block",v)})}if(typeof n=="number"&&n>0){const p=setTimeout(()=>{c()||a(pe.makeError("timeout exceeded",j.errors.TIMEOUT,{timeout:n}))},n);p.unref&&p.unref(),l.push(()=>{clearTimeout(p)})}})})}getBlockNumber(){return le(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return le(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield this.perform("getGasPrice",{});try{return K.from(e)}catch(r){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:r})}})}getBalance(e,r){return le(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(r)}),i=yield this.perform("getBalance",n);try{return K.from(i)}catch(s){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getBalance",params:n,result:i,error:s})}})}getTransactionCount(e,r){return le(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(r)}),i=yield this.perform("getTransactionCount",n);try{return K.from(i).toNumber()}catch(s){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getTransactionCount",params:n,result:i,error:s})}})}getCode(e,r){return le(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(r)}),i=yield this.perform("getCode",n);try{return ne(i)}catch(s){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getCode",params:n,result:i,error:s})}})}getStorageAt(e,r,n){return le(this,void 0,void 0,function*(){yield this.getNetwork();const i=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(n),position:Promise.resolve(r).then(o=>qu(o))}),s=yield this.perform("getStorageAt",i);try{return ne(s)}catch(o){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getStorageAt",params:i,result:s,error:o})}})}_wrapTransaction(e,r,n){if(r!=null&&zn(r)!==32)throw new Error("invalid response - sendTransaction");const i=e;return r!=null&&e.hash!==r&&pe.throwError("Transaction hash mismatch from Provider.sendTransaction.",j.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:r}),i.wait=(s,o)=>le(this,void 0,void 0,function*(){s==null&&(s=1),o==null&&(o=0);let a;s!==0&&n!=null&&(a={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:n});const l=yield this._waitForTransaction(e.hash,s,o,a);return l==null&&s===0?null:(this._emitted["t:"+e.hash]=l.blockNumber,l.status===0&&pe.throwError("transaction failed",j.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:l}),l)}),i}sendTransaction(e){return le(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield Promise.resolve(e).then(s=>ne(s)),n=this.formatter.transaction(e);n.confirmations==null&&(n.confirmations=0);const i=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const s=yield this.perform("sendTransaction",{signedTransaction:r});return this._wrapTransaction(n,s,i)}catch(s){throw s.transaction=n,s.transactionHash=n.hash,s}})}_getTransactionRequest(e){return le(this,void 0,void 0,function*(){const r=yield e,n={};return["from","to"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s?this._getAddress(s):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s?K.from(s):null))}),["type"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s??null))}),r.accessList&&(n.accessList=this.formatter.accessList(r.accessList)),["data"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s?ne(s):null))}),this.formatter.transactionRequest(yield xt(n))})}_getFilter(e){return le(this,void 0,void 0,function*(){e=yield e;const r={};return e.address!=null&&(r.address=this._getAddress(e.address)),["blockHash","topics"].forEach(n=>{e[n]!=null&&(r[n]=e[n])}),["fromBlock","toBlock"].forEach(n=>{e[n]!=null&&(r[n]=this._getBlockTag(e[n]))}),this.formatter.filter(yield xt(r))})}_call(e,r,n){return le(this,void 0,void 0,function*(){n>=g4&&pe.throwError("CCIP read exceeded maximum redirections",j.errors.SERVER_ERROR,{redirects:n,transaction:e});const i=e.to,s=yield this.perform("call",{transaction:e,blockTag:r});if(n>=0&&r==="latest"&&i!=null&&s.substring(0,10)==="0x556f1830"&&zn(s)%32===4)try{const o=Tt(s,4),a=Tt(o,0,32);K.from(a).eq(i)||pe.throwError("CCIP Read sender did not match",j.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:s});const l=[],u=K.from(Tt(o,32,64)).toNumber(),c=K.from(Tt(o,u,u+32)).toNumber(),h=Tt(o,u+32);for(let x=0;xle(this,void 0,void 0,function*(){const s=yield this.perform("getBlock",i);if(s==null)return i.blockHash!=null&&this._emitted["b:"+i.blockHash]==null||i.blockTag!=null&&n>this._emitted.block?null:void 0;if(r){let o=null;for(let l=0;lthis._wrapTransaction(l)),a}return this.formatter.block(s)}),{oncePoll:this})})}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return le(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const r={transactionHash:this.formatter.hash(e,!0)};return As(()=>le(this,void 0,void 0,function*(){const n=yield this.perform("getTransaction",r);if(n==null)return this._emitted["t:"+e]==null?null:void 0;const i=this.formatter.transactionResponse(n);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return this._wrapTransaction(i)}),{oncePoll:this})})}getTransactionReceipt(e){return le(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const r={transactionHash:this.formatter.hash(e,!0)};return As(()=>le(this,void 0,void 0,function*(){const n=yield this.perform("getTransactionReceipt",r);if(n==null)return this._emitted["t:"+e]==null?null:void 0;if(n.blockHash==null)return;const i=this.formatter.receipt(n);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return i}),{oncePoll:this})})}getLogs(e){return le(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield xt({filter:this._getFilter(e)}),n=yield this.perform("getLogs",r);return n.forEach(i=>{i.removed==null&&(i.removed=!1)}),ee.arrayOf(this.formatter.filterLog.bind(this.formatter))(n)})}getEtherPrice(){return le(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(e){return le(this,void 0,void 0,function*(){if(e=yield e,typeof e=="number"&&e<0){e%1&&pe.throwArgumentError("invalid BlockTag","blockTag",e);let r=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return r+=e,r<0&&(r=0),this.formatter.blockTag(r)}return this.formatter.blockTag(e)})}getResolver(e){return le(this,void 0,void 0,function*(){let r=e;for(;;){if(r===""||r==="."||e!=="eth"&&r==="eth")return null;const n=yield this._getResolver(r,"getResolver");if(n!=null){const i=new Rh(this,n,e);return r!==e&&!(yield i.supportsWildcard())?null:i}r=r.split(".").slice(1).join(".")}})}_getResolver(e,r){return le(this,void 0,void 0,function*(){r==null&&(r="ENS");const n=yield this.getNetwork();n.ensAddress||pe.throwError("network does not support ENS",j.errors.UNSUPPORTED_OPERATION,{operation:r,network:n.name});try{const i=yield this.call({to:n.ensAddress,data:"0x0178b8bf"+kl(e).substring(2)});return this.formatter.callAddress(i)}catch{}return null})}resolveName(e){return le(this,void 0,void 0,function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(n){if(me(e))throw n}typeof e!="string"&&pe.throwArgumentError("invalid ENS name","name",e);const r=yield this.getResolver(e);return r?yield r.getAddress():null})}lookupAddress(e){return le(this,void 0,void 0,function*(){e=yield e,e=this.formatter.address(e);const r=e.substring(2).toLowerCase()+".addr.reverse",n=yield this._getResolver(r,"lookupAddress");if(n==null)return null;const i=Cl(yield this.call({to:n,data:"0x691f3431"+kl(r).substring(2)}),0);return(yield this.resolveName(i))!=e?null:i})}getAvatar(e){return le(this,void 0,void 0,function*(){let r=null;if(me(e)){const s=this.formatter.address(e).substring(2).toLowerCase()+".addr.reverse",o=yield this._getResolver(s,"getAvatar");if(!o)return null;r=new Rh(this,o,s);try{const a=yield r.getAvatar();if(a)return a.url}catch(a){if(a.code!==j.errors.CALL_EXCEPTION)throw a}try{const a=Cl(yield this.call({to:o,data:"0x691f3431"+kl(s).substring(2)}),0);r=yield this.getResolver(a)}catch(a){if(a.code!==j.errors.CALL_EXCEPTION)throw a;return null}}else if(r=yield this.getResolver(e),!r)return null;const n=yield r.getAvatar();return n==null?null:n.url})}perform(e,r){return pe.throwError(e+" not implemented",j.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter(r=>r.pollable()).length>0}_stopEvent(e){this.polling=this._events.filter(r=>r.pollable()).length>0}_addEventListener(e,r,n){const i=new w4(is(e),r,n);return this._events.push(i),this._startEvent(i),this}on(e,r){return this._addEventListener(e,r,!1)}once(e,r){return this._addEventListener(e,r,!0)}emit(e,...r){let n=!1,i=[],s=is(e);return this._events=this._events.filter(o=>o.tag!==s?!0:(setTimeout(()=>{o.listener.apply(this,r)},0),n=!0,o.once?(i.push(o),!1):!0)),i.forEach(o=>{this._stopEvent(o)}),n}listenerCount(e){if(!e)return this._events.length;let r=is(e);return this._events.filter(n=>n.tag===r).length}listeners(e){if(e==null)return this._events.map(n=>n.listener);let r=is(e);return this._events.filter(n=>n.tag===r).map(n=>n.listener)}off(e,r){if(r==null)return this.removeAllListeners(e);const n=[];let i=!1,s=is(e);return this._events=this._events.filter(o=>o.tag!==s||o.listener!=r||i?!0:(i=!0,n.push(o),!1)),n.forEach(o=>{this._stopEvent(o)}),this}removeAllListeners(e){let r=[];if(e==null)r=this._events,this._events=[];else{const n=is(e);this._events=this._events.filter(i=>i.tag!==n?!0:(r.push(i),!1))}return r.forEach(n=>{this._stopEvent(n)}),this}}const A4="abstract-signer/5.7.0";var Fr=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Sr=new j(A4),_4=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],S4=[j.errors.INSUFFICIENT_FUNDS,j.errors.NONCE_EXPIRED,j.errors.REPLACEMENT_UNDERPRICED];class Ta{constructor(){Sr.checkAbstract(new.target,Ta),H(this,"_isSigner",!0)}getBalance(e){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),e)})}getTransactionCount(e){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),e)})}estimateGas(e){return Fr(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const r=yield xt(this.checkTransaction(e));return yield this.provider.estimateGas(r)})}call(e,r){return Fr(this,void 0,void 0,function*(){this._checkProvider("call");const n=yield xt(this.checkTransaction(e));return yield this.provider.call(n,r)})}sendTransaction(e){return Fr(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const r=yield this.populateTransaction(e),n=yield this.signTransaction(r);return yield this.provider.sendTransaction(n)})}getChainId(){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(e){return Fr(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(e)})}checkTransaction(e){for(const n in e)_4.indexOf(n)===-1&&Sr.throwArgumentError("invalid transaction key: "+n,"transaction",e);const r=at(e);return r.from==null?r.from=this.getAddress():r.from=Promise.all([Promise.resolve(r.from),this.getAddress()]).then(n=>(n[0].toLowerCase()!==n[1].toLowerCase()&&Sr.throwArgumentError("from address mismatch","transaction",e),n[0])),r}populateTransaction(e){return Fr(this,void 0,void 0,function*(){const r=yield xt(this.checkTransaction(e));r.to!=null&&(r.to=Promise.resolve(r.to).then(i=>Fr(this,void 0,void 0,function*(){if(i==null)return null;const s=yield this.resolveName(i);return s==null&&Sr.throwArgumentError("provided ENS name resolves to null","tx.to",i),s})),r.to.catch(i=>{}));const n=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||n)?Sr.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",e):(r.type===0||r.type===1)&&n&&Sr.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1)r.gasPrice==null&&(r.gasPrice=this.getGasPrice());else{const i=yield this.getFeeData();if(r.type==null)if(i.maxFeePerGas!=null&&i.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const s=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=s,r.maxPriorityFeePerGas=s}else r.maxFeePerGas==null&&(r.maxFeePerGas=i.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=i.maxPriorityFeePerGas);else i.gasPrice!=null?(n&&Sr.throwError("network does not support EIP-1559",j.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=i.gasPrice),r.type=0):Sr.throwError("failed to get consistent fee data",j.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else r.type===2&&(r.maxFeePerGas==null&&(r.maxFeePerGas=i.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=i.maxPriorityFeePerGas))}return r.nonce==null&&(r.nonce=this.getTransactionCount("pending")),r.gasLimit==null&&(r.gasLimit=this.estimateGas(r).catch(i=>{if(S4.indexOf(i.code)>=0)throw i;return Sr.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{error:i,tx:r})})),r.chainId==null?r.chainId=this.getChainId():r.chainId=Promise.all([Promise.resolve(r.chainId),this.getChainId()]).then(i=>(i[1]!==0&&i[0]!==i[1]&&Sr.throwArgumentError("chainId address mismatch","transaction",e),i[0])),yield xt(r)})}_checkProvider(e){this.provider||Sr.throwError("missing provider",j.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})}static isSigner(e){return!!(e&&e._isSigner)}}class Jd extends Ta{constructor(e,r){super(),H(this,"address",e),H(this,"provider",r||null)}getAddress(){return Promise.resolve(this.address)}_fail(e,r){return Promise.resolve().then(()=>{Sr.throwError(e,j.errors.UNSUPPORTED_OPERATION,{operation:r})})}signMessage(e){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(e,r,n){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(e){return new Jd(this.address,e)}}var Nn=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const bt=new j(qt),k4=["call","estimateGas"];function Do(t,e){if(t==null)return null;if(typeof t.message=="string"&&t.message.match("reverted")){const r=me(t.data)?t.data:null;if(!e||r)return{message:t.message,data:r}}if(typeof t=="object"){for(const r in t){const n=Do(t[r],e);if(n)return n}return null}if(typeof t=="string")try{return Do(JSON.parse(t),e)}catch{}return null}function Dy(t,e,r){const n=r.transaction||r.signedTransaction;if(t==="call"){const s=Do(e,!0);if(s)return s.data;bt.throwError("missing revert data in call exception; Transaction reverted without a reason string",j.errors.CALL_EXCEPTION,{data:"0x",transaction:n,error:e})}if(t==="estimateGas"){let s=Do(e.body,!1);s==null&&(s=Do(e,!1)),s&&bt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{reason:s.message,method:t,transaction:n,error:e})}let i=e.message;throw e.code===j.errors.SERVER_ERROR&&e.error&&typeof e.error.message=="string"?i=e.error.message:typeof e.body=="string"?i=e.body:typeof e.responseText=="string"&&(i=e.responseText),i=(i||"").toLowerCase(),i.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&bt.throwError("insufficient funds for intrinsic transaction cost",j.errors.INSUFFICIENT_FUNDS,{error:e,method:t,transaction:n}),i.match(/nonce (is )?too low/i)&&bt.throwError("nonce has already been used",j.errors.NONCE_EXPIRED,{error:e,method:t,transaction:n}),i.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&bt.throwError("replacement fee too low",j.errors.REPLACEMENT_UNDERPRICED,{error:e,method:t,transaction:n}),i.match(/only replay-protected/i)&&bt.throwError("legacy pre-eip-155 transactions not supported",j.errors.UNSUPPORTED_OPERATION,{error:e,method:t,transaction:n}),k4.indexOf(t)>=0&&i.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&bt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:t,transaction:n}),e}function mm(t){return new Promise(function(e){setTimeout(e,t)})}function N4(t){if(t.error){const e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function xo(t){return t&&t.toLowerCase()}const Ih={};class Yd extends Ta{constructor(e,r,n){if(super(),e!==Ih)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");H(this,"provider",r),n==null&&(n=0),typeof n=="string"?(H(this,"_address",this.provider.formatter.address(n)),H(this,"_index",null)):typeof n=="number"?(H(this,"_index",n),H(this,"_address",null)):bt.throwArgumentError("invalid address or index","addressOrIndex",n)}connect(e){return bt.throwError("cannot alter JSON-RPC Signer connection",j.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new M4(Ih,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(e=>(e.length<=this._index&&bt.throwError("unknown account #"+this._index,j.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index])))}sendUncheckedTransaction(e){e=at(e);const r=this.getAddress().then(n=>(n&&(n=n.toLowerCase()),n));if(e.gasLimit==null){const n=at(e);n.from=r,e.gasLimit=this.provider.estimateGas(n)}return e.to!=null&&(e.to=Promise.resolve(e.to).then(n=>Nn(this,void 0,void 0,function*(){if(n==null)return null;const i=yield this.provider.resolveName(n);return i==null&&bt.throwArgumentError("provided ENS name resolves to null","tx.to",n),i}))),xt({tx:xt(e),sender:r}).then(({tx:n,sender:i})=>{n.from!=null?n.from.toLowerCase()!==i&&bt.throwArgumentError("from address mismatch","transaction",e):n.from=i;const s=this.provider.constructor.hexlifyTransaction(n,{from:!0});return this.provider.send("eth_sendTransaction",[s]).then(o=>o,o=>(typeof o.message=="string"&&o.message.match(/user denied/i)&&bt.throwError("user rejected transaction",j.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:n}),Dy("sendTransaction",o,s)))})}signTransaction(e){return bt.throwError("signing transactions is unsupported",j.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return Nn(this,void 0,void 0,function*(){const r=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),n=yield this.sendUncheckedTransaction(e);try{return yield As(()=>Nn(this,void 0,void 0,function*(){const i=yield this.provider.getTransaction(n);if(i!==null)return this.provider._wrapTransaction(i,n,r)}),{oncePoll:this.provider})}catch(i){throw i.transactionHash=n,i}})}signMessage(e){return Nn(this,void 0,void 0,function*(){const r=typeof e=="string"?yr(e):e,n=yield this.getAddress();try{return yield this.provider.send("personal_sign",[ne(r),n.toLowerCase()])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&bt.throwError("user rejected signing",j.errors.ACTION_REJECTED,{action:"signMessage",from:n,messageData:e}),i}})}_legacySignMessage(e){return Nn(this,void 0,void 0,function*(){const r=typeof e=="string"?yr(e):e,n=yield this.getAddress();try{return yield this.provider.send("eth_sign",[n.toLowerCase(),ne(r)])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&bt.throwError("user rejected signing",j.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:n,messageData:e}),i}})}_signTypedData(e,r,n){return Nn(this,void 0,void 0,function*(){const i=yield cr.resolveNames(e,r,n,o=>this.provider.resolveName(o)),s=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[s.toLowerCase(),JSON.stringify(cr.getPayload(i.domain,r,i.value))])}catch(o){throw typeof o.message=="string"&&o.message.match(/user denied/i)&&bt.throwError("user rejected signing",j.errors.ACTION_REJECTED,{action:"_signTypedData",from:s,messageData:{domain:i.domain,types:r,value:i.value}}),o}})}unlock(e){return Nn(this,void 0,void 0,function*(){const r=this.provider,n=yield this.getAddress();return r.send("personal_unlockAccount",[n.toLowerCase(),e,null])})}}class M4 extends Yd{sendTransaction(e){return this.sendUncheckedTransaction(e).then(r=>({hash:r,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:n=>this.provider.waitForTransaction(r,n)}))}}const C4={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class Qi extends tc{constructor(e,r){let n=r;n==null&&(n=new Promise((i,s)=>{setTimeout(()=>{this.detectNetwork().then(o=>{i(o)},o=>{s(o)})},0)})),super(n),e||(e=mr(this.constructor,"defaultUrl")()),typeof e=="string"?H(this,"connection",Object.freeze({url:e})):H(this,"connection",Object.freeze(at(e))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return Nn(this,void 0,void 0,function*(){yield mm(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch{try{e=yield this.send("net_version",[])}catch{}}if(e!=null){const r=mr(this.constructor,"getNetwork");try{return r(K.from(e).toNumber())}catch(n){return bt.throwError("could not detect network",j.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:n})}}return bt.throwError("could not detect network",j.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(e){return new Yd(Ih,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(e=>e.map(r=>this.formatter.address(r)))}send(e,r){const n={method:e,params:r,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:lr(n),provider:this});const i=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(i&&this._cache[e])return this._cache[e];const s=Ia(this.connection,JSON.stringify(n),N4).then(o=>(this.emit("debug",{action:"response",request:n,response:o,provider:this}),o),o=>{throw this.emit("debug",{action:"response",error:o,request:n,provider:this}),o});return i&&(this._cache[e]=s,setTimeout(()=>{this._cache[e]=null},0)),s}prepareRequest(e,r){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[xo(r.address),r.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[xo(r.address),r.blockTag]];case"getCode":return["eth_getCode",[xo(r.address),r.blockTag]];case"getStorageAt":return["eth_getStorageAt",[xo(r.address),gt(r.position,32),r.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[r.signedTransaction]];case"getBlock":return r.blockTag?["eth_getBlockByNumber",[r.blockTag,!!r.includeTransactions]]:r.blockHash?["eth_getBlockByHash",[r.blockHash,!!r.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[r.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[r.transactionHash]];case"call":return["eth_call",[mr(this.constructor,"hexlifyTransaction")(r.transaction,{from:!0}),r.blockTag]];case"estimateGas":return["eth_estimateGas",[mr(this.constructor,"hexlifyTransaction")(r.transaction,{from:!0})]];case"getLogs":return r.filter&&r.filter.address!=null&&(r.filter.address=xo(r.filter.address)),["eth_getLogs",[r.filter]]}return null}perform(e,r){return Nn(this,void 0,void 0,function*(){if(e==="call"||e==="estimateGas"){const i=r.transaction;if(i&&i.type!=null&&K.from(i.type).isZero()&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=yield this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(r=at(r),r.transaction=at(i),delete r.transaction.type)}}const n=this.prepareRequest(e,r);n==null&&bt.throwError(e+" not implemented",j.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(n[0],n[1])}catch(i){return Dy(e,i,r)}})}_startEvent(e){e.tag==="pending"&&this._startPending(),super._startEvent(e)}_startPending(){if(this._pendingFilter!=null)return;const e=this,r=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=r,r.then(function(n){function i(){e.send("eth_getFilterChanges",[n]).then(function(s){if(e._pendingFilter!=r)return null;let o=Promise.resolve();return s.forEach(function(a){e._emitted["t:"+a.toLowerCase()]="pending",o=o.then(function(){return e.getTransaction(a).then(function(l){return e.emit("pending",l),null})})}),o.then(function(){return mm(1e3)})}).then(function(){if(e._pendingFilter!=r){e.send("eth_uninstallFilter",[n]);return}return setTimeout(function(){i()},0),null}).catch(s=>{})}return i(),n}).catch(n=>{})}_stopEvent(e){e.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,r){const n=at(C4);if(r)for(const s in r)r[s]&&(n[s]=!0);fE(e,n);const i={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(s){if(e[s]==null)return;const o=qu(K.from(e[s]));s==="gasLimit"&&(s="gas"),i[s]=o}),["from","to","data"].forEach(function(s){e[s]!=null&&(i[s]=ne(e[s]))}),e.accessList&&(i.accessList=rs(e.accessList)),i}}let Fo=null;try{if(Fo=WebSocket,Fo==null)throw new Error("inject please")}catch{const e=new j(qt);Fo=function(){e.throwError("WebSockets not supported in this environment",j.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var pf=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const rl=new j(qt);let P4=1;class rc extends Qi{constructor(e,r){r==="any"&&rl.throwError("WebSocketProvider does not support 'any' network yet",j.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),typeof e=="string"?super(e,r):super("_websocket",r),this._pollingInterval=-1,this._wsReady=!1,typeof e=="string"?H(this,"_websocket",new Fo(this.connection.url)):H(this,"_websocket",e),H(this,"_requests",{}),H(this,"_subs",{}),H(this,"_subIds",{}),H(this,"_detectNetwork",super.detectNetwork()),this.websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach(i=>{this.websocket.send(this._requests[i].payload)})},this.websocket.onmessage=i=>{const s=i.data,o=JSON.parse(s);if(o.id!=null){const a=String(o.id),l=this._requests[a];if(delete this._requests[a],o.result!==void 0)l.callback(null,o.result),this.emit("debug",{action:"response",request:JSON.parse(l.payload),response:o.result,provider:this});else{let u=null;o.error?(u=new Error(o.error.message||"unknown error"),H(u,"code",o.error.code||null),H(u,"response",s)):u=new Error("unknown error"),l.callback(u,void 0),this.emit("debug",{action:"response",error:u,request:JSON.parse(l.payload),provider:this})}}else if(o.method==="eth_subscription"){const a=this._subs[o.params.subscription];a&&a.processFunc(o.params.result)}else console.warn("this should not happen")};const n=setInterval(()=>{this.emit("poll")},1e3);n.unref&&n.unref()}get websocket(){return this._websocket}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){rl.throwError("cannot reset events block on WebSocketProvider",j.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){rl.throwError("cannot set polling interval on WebSocketProvider",j.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return pf(this,void 0,void 0,function*(){return null})}set polling(e){e&&rl.throwError("cannot set polling on WebSocketProvider",j.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,r){const n=P4++;return new Promise((i,s)=>{function o(l,u){return l?s(l):i(u)}const a=JSON.stringify({method:e,params:r,id:n,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(a),provider:this}),this._requests[String(n)]={callback:o,payload:a},this._wsReady&&this.websocket.send(a)})}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,r,n){return pf(this,void 0,void 0,function*(){let i=this._subIds[e];i==null&&(i=Promise.all(r).then(o=>this.send("eth_subscribe",o)),this._subIds[e]=i);const s=yield i;this._subs[s]={tag:e,processFunc:n}})}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],r=>{const n=K.from(r.number).toNumber();this._emitted.block=n,this.emit("block",n)});break;case"pending":this._subscribe("pending",["newPendingTransactions"],r=>{this.emit("pending",r)});break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],r=>{r.removed==null&&(r.removed=!1),this.emit(e.filter,this.formatter.filterLog(r))});break;case"tx":{const r=n=>{const i=n.hash;this.getTransactionReceipt(i).then(s=>{s&&this.emit(i,s)})};r(e),this._subscribe("tx",["newHeads"],n=>{this._events.filter(i=>i.type==="tx").forEach(r)});break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e);break}}_stopEvent(e){let r=e.tag;if(e.type==="tx"){if(this._events.filter(i=>i.type==="tx").length)return;r="tx"}else if(this.listenerCount(e.event))return;const n=this._subIds[r];n&&(delete this._subIds[r],n.then(i=>{this._subs[i]&&(delete this._subs[i],this.send("eth_unsubscribe",[i]))}))}destroy(){return pf(this,void 0,void 0,function*(){this.websocket.readyState===Fo.CONNECTING&&(yield new Promise(e=>{this.websocket.onopen=function(){e(!0)},this.websocket.onerror=function(){e(!1)}})),this.websocket.close(1e3)})}}var R4=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const No=new j(qt);class Fy extends Qi{detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return R4(this,void 0,void 0,function*(){let r=this.network;return r==null&&(r=yield e.detectNetwork.call(this),r||No.throwError("no network detected",j.errors.UNKNOWN_ERROR,{}),this._network==null&&(H(this,"_network",r),this.emit("network",r,null))),r})}}class Gn extends Fy{constructor(e,r){No.checkAbstract(new.target,Gn),e=mr(new.target,"getNetwork")(e),r=mr(new.target,"getApiKey")(r);const n=mr(new.target,"getUrl")(e,r);super(n,e),typeof r=="string"?H(this,"apiKey",r):r!=null&&Object.keys(r).forEach(i=>{H(this,i,r[i])})}_startPending(){No.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return No.throwError("API provider does not support signing",j.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,r){return No.throwError("not implemented; sub-classes must override getUrl",j.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const gm=new j(qt),Pl="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class Uy extends rc{constructor(e,r){const n=new Xd(e,r),i=n.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi.");super(i,n.network),H(this,"apiKey",n.apiKey)}isCommunityResource(){return this.apiKey===Pl}}class Xd extends Gn{static getWebSocketProvider(e,r){return new Uy(e,r)}static getApiKey(e){return e==null?Pl:(e&&typeof e!="string"&&gm.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,r){let n=null;switch(e.name){case"homestead":n="eth-mainnet.alchemyapi.io/v2/";break;case"goerli":n="eth-goerli.g.alchemy.com/v2/";break;case"matic":n="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":n="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":n="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-goerli":n="arb-goerli.g.alchemy.com/v2/";break;case"optimism":n="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-goerli":n="opt-goerli.g.alchemy.com/v2/";break;default:gm.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+n+r,throttleCallback:(i,s)=>(r===Pl&&Oa(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===Pl}}const I4=new j(qt),nl="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function O4(t){switch(t){case"homestead":return"rpc.ankr.com/eth/";case"ropsten":return"rpc.ankr.com/eth_ropsten/";case"rinkeby":return"rpc.ankr.com/eth_rinkeby/";case"goerli":return"rpc.ankr.com/eth_goerli/";case"matic":return"rpc.ankr.com/polygon/";case"arbitrum":return"rpc.ankr.com/arbitrum/"}return I4.throwArgumentError("unsupported network","name",t)}class zy extends Gn{isCommunityResource(){return this.apiKey===nl}static getApiKey(e){return e??nl}static getUrl(e,r){r==null&&(r=nl);const n={allowGzip:!0,url:"https://"+O4(e.name)+r,throttleCallback:(i,s)=>(r.apiKey===nl&&Oa(),Promise.resolve(!0))};return r.projectSecret!=null&&(n.user="",n.password=r.projectSecret),n}}var T4=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const vm=new j(qt);class $y extends Gn{static getApiKey(e){return e!=null&&vm.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,r){let n=null;switch(e.name){case"homestead":n="https://cloudflare-eth.com/";break;default:vm.throwArgumentError("unsupported network","network",arguments[0])}return n}perform(e,r){const n=Object.create(null,{perform:{get:()=>super.perform}});return T4(this,void 0,void 0,function*(){return e==="getBlockNumber"?(yield n.perform.call(this,"getBlock",{blockTag:"latest"})).number:n.perform.call(this,e,r)})}}var il=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const li=new j(qt);function ym(t){const e={};for(let r in t){if(t[r]==null)continue;let n=t[r];r==="type"&&n===0||({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[r]?n=qu(ne(n)):r==="accessList"?n="["+rs(n).map(i=>`{address:"${i.address}",storageKeys:["${i.storageKeys.join('","')}"]}`).join(",")+"]":n=ne(n),e[r]=n)}return e}function j4(t){if(t.status==0&&(t.message==="No records found"||t.message==="No transactions found"))return t.result;if(t.status!=1||typeof t.message!="string"||!t.message.match(/^OK/)){const e=new Error("invalid response");throw e.result=JSON.stringify(t),(t.result||"").toLowerCase().indexOf("rate limit")>=0&&(e.throttleRetry=!0),e}return t.result}function wm(t){if(t&&t.status==0&&t.message=="NOTOK"&&(t.result||"").toLowerCase().indexOf("rate limit")>=0){const e=new Error("throttled response");throw e.result=JSON.stringify(t),e.throttleRetry=!0,e}if(t.jsonrpc!="2.0"){const e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){const e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function xm(t){if(t==="pending")throw new Error("pending not supported");return t==="latest"?t:parseInt(t.substring(2),16)}function mf(t,e,r){if(t==="call"&&e.code===j.errors.SERVER_ERROR){const i=e.error;if(i&&(i.message.match(/reverted/i)||i.message.match(/VM execution error/i))){let s=i.data;if(s&&(s="0x"+s.replace(/^.*0x/i,"")),me(s))return s;li.throwError("missing revert data in call exception",j.errors.CALL_EXCEPTION,{error:e,data:"0x"})}}let n=e.message;throw e.code===j.errors.SERVER_ERROR&&(e.error&&typeof e.error.message=="string"?n=e.error.message:typeof e.body=="string"?n=e.body:typeof e.responseText=="string"&&(n=e.responseText)),n=(n||"").toLowerCase(),n.match(/insufficient funds/)&&li.throwError("insufficient funds for intrinsic transaction cost",j.errors.INSUFFICIENT_FUNDS,{error:e,method:t,transaction:r}),n.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&li.throwError("nonce has already been used",j.errors.NONCE_EXPIRED,{error:e,method:t,transaction:r}),n.match(/another transaction with same nonce/)&&li.throwError("replacement fee too low",j.errors.REPLACEMENT_UNDERPRICED,{error:e,method:t,transaction:r}),n.match(/execution failed due to an exception|execution reverted/)&&li.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:t,transaction:r}),e}class Hy extends tc{constructor(e,r){super(e),H(this,"baseUrl",this.getBaseUrl()),H(this,"apiKey",r||null)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"matic":return"https://api.polygonscan.com";case"maticmum":return"https://api-testnet.polygonscan.com";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}return li.throwArgumentError("unsupported network","network",this.network.name)}getUrl(e,r){const n=Object.keys(r).reduce((s,o)=>{const a=r[o];return a!=null&&(s+=`&${o}=${a}`),s},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${n}${i}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,r){return r.module=e,r.apikey=this.apiKey,r}fetch(e,r,n){return il(this,void 0,void 0,function*(){const i=n?this.getPostUrl():this.getUrl(e,r),s=n?this.getPostData(e,r):null,o=e==="proxy"?wm:j4;this.emit("debug",{action:"request",request:i,provider:this});const a={url:i,throttleSlotInterval:1e3,throttleCallback:(c,h)=>(this.isCommunityResource()&&Oa(),Promise.resolve(!0))};let l=null;s&&(a.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},l=Object.keys(s).map(c=>`${c}=${s[c]}`).join("&"));const u=yield Ia(a,l,o||wm);return this.emit("debug",{action:"response",request:i,response:lr(u),provider:this}),u})}detectNetwork(){return il(this,void 0,void 0,function*(){return this.network})}perform(e,r){const n=Object.create(null,{perform:{get:()=>super.perform}});return il(this,void 0,void 0,function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:r.address,tag:r.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:r.address,tag:r.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:r.address,tag:r.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:r.address,position:r.position,tag:r.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:r.signedTransaction},!0).catch(i=>mf("sendTransaction",i,r.signedTransaction));case"getBlock":if(r.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:r.blockTag,boolean:r.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:r.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:r.transactionHash});case"call":{if(r.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const i=ym(r.transaction);i.module="proxy",i.action="eth_call";try{return yield this.fetch("proxy",i,!0)}catch(s){return mf("call",s,r.transaction)}}case"estimateGas":{const i=ym(r.transaction);i.module="proxy",i.action="eth_estimateGas";try{return yield this.fetch("proxy",i,!0)}catch(s){return mf("estimateGas",s,r.transaction)}}case"getLogs":{const i={action:"getLogs"};if(r.filter.fromBlock&&(i.fromBlock=xm(r.filter.fromBlock)),r.filter.toBlock&&(i.toBlock=xm(r.filter.toBlock)),r.filter.address&&(i.address=r.filter.address),r.filter.topics&&r.filter.topics.length>0&&(r.filter.topics.length>1&&li.throwError("unsupported topic count",j.errors.UNSUPPORTED_OPERATION,{topics:r.filter.topics}),r.filter.topics.length===1)){const a=r.filter.topics[0];(typeof a!="string"||a.length!==66)&&li.throwError("unsupported topic format",j.errors.UNSUPPORTED_OPERATION,{topic0:a}),i.topic0=a}const s=yield this.fetch("logs",i);let o={};for(let a=0;a{["contractAddress","to"].forEach(function(l){o[l]==""&&delete o[l]}),o.creates==null&&o.contractAddress!=null&&(o.creates=o.contractAddress);const a=this.formatter.transactionResponse(o);return o.timeStamp&&(a.timestamp=parseInt(o.timeStamp)),a})})}isCommunityResource(){return this.apiKey==null}}function L4(t){t=t.slice();for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}var fu=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Ti=new j(qt);function sl(){return new Date().getTime()}function bm(t){let e=null;for(let r=0;re?null:(n+i)/2}function _s(t){if(t===null)return"null";if(typeof t=="number"||typeof t=="boolean")return JSON.stringify(t);if(typeof t=="string")return t;if(K.isBigNumber(t))return t.toString();if(Array.isArray(t))return JSON.stringify(t.map(e=>_s(e)));if(typeof t=="object"){const e=Object.keys(t);return e.sort(),"{"+e.map(r=>{let n=t[r];return typeof n=="function"?n="[function]":n=_s(n),JSON.stringify(r)+":"+n}).join(",")+"}"}throw new Error("unknown value type: "+typeof t)}let B4=1;function Am(t){let e=null,r=null,n=new Promise(o=>{e=function(){r&&(clearTimeout(r),r=null),o()},r=setTimeout(e,t)});const i=o=>(n=n.then(o),n);function s(){return n}return{cancel:e,getPromise:s,wait:i}}const D4=[j.errors.CALL_EXCEPTION,j.errors.INSUFFICIENT_FUNDS,j.errors.NONCE_EXPIRED,j.errors.REPLACEMENT_UNDERPRICED,j.errors.UNPREDICTABLE_GAS_LIMIT],F4=["address","args","errorArgs","errorSignature","method","transaction"];function ol(t,e){const r={weight:t.weight};return Object.defineProperty(r,"provider",{get:()=>t.provider}),t.start&&(r.start=t.start),e&&(r.duration=e-t.start),t.done&&(t.error?r.error=t.error:r.result=t.result||null),r}function U4(t,e){return function(r){const n={};r.forEach(s=>{const o=t(s.result);n[o]||(n[o]={count:0,result:s.result}),n[o].count++});const i=Object.keys(n);for(let s=0;s=e)return o.result}}}function z4(t,e,r){let n=_s;switch(e){case"getBlockNumber":return function(i){const s=i.map(a=>a.result);let o=Em(i.map(a=>a.result),2);if(o!=null)return o=Math.ceil(o),s.indexOf(o+1)>=0&&o++,o>=t._highestBlockNumber&&(t._highestBlockNumber=o),t._highestBlockNumber};case"getGasPrice":return function(i){const s=i.map(o=>o.result);return s.sort(),s[Math.floor(s.length/2)]};case"getEtherPrice":return function(i){return Em(i.map(s=>s.result))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":n=function(i){return i==null?null:(i=at(i),i.confirmations=-1,_s(i))};break;case"getBlock":r.includeTransactions?n=function(i){return i==null?null:(i=at(i),i.transactions=i.transactions.map(s=>(s=at(s),s.confirmations=-1,s)),_s(i))}:n=function(i){return i==null?null:_s(i)};break;default:throw new Error("unknown method: "+e)}return U4(n,t.quorum)}function bo(t,e){return fu(this,void 0,void 0,function*(){const r=t.provider;return r.blockNumber!=null&&r.blockNumber>=e||e===-1?r:As(()=>new Promise((n,i)=>{setTimeout(function(){return r.blockNumber>=e?n(r):t.cancelled?n(null):n(void 0)},0)}),{oncePoll:r})})}function $4(t,e,r,n){return fu(this,void 0,void 0,function*(){let i=t.provider;switch(r){case"getBlockNumber":case"getGasPrice":return i[r]();case"getEtherPrice":if(i.getEtherPrice)return i.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),i[r](n.address,n.blockTag||"latest");case"getStorageAt":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),i.getStorageAt(n.address,n.position,n.blockTag||"latest");case"getBlock":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),i[n.includeTransactions?"getBlockWithTransactions":"getBlock"](n.blockTag||n.blockHash);case"call":case"estimateGas":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),r==="call"&&n.blockTag?i[r](n.transaction,n.blockTag):i[r](n.transaction);case"getTransaction":case"getTransactionReceipt":return i[r](n.transactionHash);case"getLogs":{let s=n.filter;return(s.fromBlock&&me(s.fromBlock)||s.toBlock&&me(s.toBlock))&&(i=yield bo(t,e)),i.getLogs(s)}}return Ti.throwError("unknown method error",j.errors.UNKNOWN_ERROR,{method:r,params:n})})}class Vy extends tc{constructor(e,r){e.length===0&&Ti.throwArgumentError("missing providers","providers",e);const n=e.map((o,a)=>{if(ro.isProvider(o)){const c=Ph(o)?2e3:750;return Object.freeze({provider:o,weight:1,stallTimeout:c,priority:1})}const l=at(o);l.priority==null&&(l.priority=1),l.stallTimeout==null&&(l.stallTimeout=Ph(o)?2e3:750),l.weight==null&&(l.weight=1);const u=l.weight;return(u%1||u>512||u<1)&&Ti.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${a}].weight`,u),Object.freeze(l)}),i=n.reduce((o,a)=>o+a.weight,0);r==null?r=i/2:r>i&&Ti.throwArgumentError("quorum will always fail; larger than total weight","quorum",r);let s=bm(n.map(o=>o.provider.network));s==null&&(s=new Promise((o,a)=>{setTimeout(()=>{this.detectNetwork().then(o,a)},0)})),super(s),H(this,"providerConfigs",Object.freeze(n)),H(this,"quorum",r),this._highestBlockNumber=-1}detectNetwork(){return fu(this,void 0,void 0,function*(){const e=yield Promise.all(this.providerConfigs.map(r=>r.provider.getNetwork()));return bm(e)})}perform(e,r){return fu(this,void 0,void 0,function*(){if(e==="sendTransaction"){const l=yield Promise.all(this.providerConfigs.map(u=>u.provider.sendTransaction(r.signedTransaction).then(c=>c.hash,c=>c)));for(let u=0;ul.priority-u.priority);const s=this._highestBlockNumber;let o=0,a=!0;for(;;){const l=sl();let u=i.filter(m=>m.runner&&l-m.startm+v.weight,0);for(;u{m.staller=null}),m.runner=$4(m,s,e,r).then(b=>{m.done=!0,m.result=b,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:v,backend:ol(m,sl()),request:{method:e,params:lr(r)},provider:this})},b=>{m.done=!0,m.error=b,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:v,backend:ol(m,sl()),request:{method:e,params:lr(r)},provider:this})}),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:v,backend:ol(m,null),request:{method:e,params:lr(r)},provider:this}),u+=m.weight}const c=[];i.forEach(m=>{m.done||!m.runner||(c.push(m.runner),m.staller&&c.push(m.staller.getPromise()))}),c.length&&(yield Promise.race(c));const h=i.filter(m=>m.done&&m.error==null);if(h.length>=this.quorum){const m=n(h);if(m!==void 0)return i.forEach(v=>{v.staller&&v.staller.cancel(),v.cancelled=!0}),m;a||(yield Am(100).getPromise()),a=!1}const p=i.reduce((m,v)=>{if(!v.done||v.error==null)return m;const b=v.error.code;return D4.indexOf(b)>=0&&(m[b]||(m[b]={error:v.error,weight:0}),m[b].weight+=v.weight),m},{});if(Object.keys(p).forEach(m=>{const v=p[m];if(v.weight{x.staller&&x.staller.cancel(),x.cancelled=!0});const b=v.error,k={};F4.forEach(x=>{b[x]!=null&&(k[x]=b[x])}),Ti.throwError(b.reason||b.message,m,k)}),i.filter(m=>!m.done).length===0)break}return i.forEach(l=>{l.staller&&l.staller.cancel(),l.cancelled=!0}),Ti.throwError("failed to meet quorum",j.errors.SERVER_ERROR,{method:e,params:r,results:i.map(l=>ol(l)),provider:this})})}}const qy=null,Rl=new j(qt),Mo="84842078b09946638c03157f83405213";class Gy extends rc{constructor(e,r){const n=new Zd(e,r),i=n.connection;i.password&&Rl.throwError("INFURA WebSocket project secrets unsupported",j.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});const s=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(s,e),H(this,"apiKey",n.projectId),H(this,"projectId",n.projectId),H(this,"projectSecret",n.projectSecret)}isCommunityResource(){return this.projectId===Mo}}class Zd extends Gn{static getWebSocketProvider(e,r){return new Gy(e,r)}static getApiKey(e){const r={apiKey:Mo,projectId:Mo,projectSecret:null};return e==null||(typeof e=="string"?r.projectId=e:e.projectSecret!=null?(Rl.assertArgument(typeof e.projectId=="string","projectSecret requires a projectId","projectId",e.projectId),Rl.assertArgument(typeof e.projectSecret=="string","invalid projectSecret","projectSecret","[REDACTED]"),r.projectId=e.projectId,r.projectSecret=e.projectSecret):e.projectId&&(r.projectId=e.projectId),r.apiKey=r.projectId),r}static getUrl(e,r){let n=null;switch(e?e.name:"unknown"){case"homestead":n="mainnet.infura.io";break;case"goerli":n="goerli.infura.io";break;case"sepolia":n="sepolia.infura.io";break;case"matic":n="polygon-mainnet.infura.io";break;case"maticmum":n="polygon-mumbai.infura.io";break;case"optimism":n="optimism-mainnet.infura.io";break;case"optimism-goerli":n="optimism-goerli.infura.io";break;case"arbitrum":n="arbitrum-mainnet.infura.io";break;case"arbitrum-goerli":n="arbitrum-goerli.infura.io";break;default:Rl.throwError("unsupported network",j.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i={allowGzip:!0,url:"https://"+n+"/v3/"+r.projectId,throttleCallback:(s,o)=>(r.projectId===Mo&&Oa(),Promise.resolve(!0))};return r.projectSecret!=null&&(i.user="",i.password=r.projectSecret),i}isCommunityResource(){return this.projectId===Mo}}class H4 extends Qi{send(e,r){const n={method:e,params:r,id:this._nextId++,jsonrpc:"2.0"};this._pendingBatch==null&&(this._pendingBatch=[]);const i={request:n,resolve:null,reject:null},s=new Promise((o,a)=>{i.resolve=o,i.reject=a});return this._pendingBatch.push(i),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout(()=>{const o=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;const a=o.map(l=>l.request);return this.emit("debug",{action:"requestBatch",request:lr(a),provider:this}),Ia(this.connection,JSON.stringify(a)).then(l=>{this.emit("debug",{action:"response",request:a,response:l,provider:this}),o.forEach((u,c)=>{const h=l[c];if(h.error){const p=new Error(h.error.message);p.code=h.error.code,p.data=h.error.data,u.reject(p)}else u.resolve(h.result)})},l=>{this.emit("debug",{action:"response",error:l,request:a,provider:this}),o.forEach(u=>{u.reject(l)})})},10)),s}}const gf=new j(qt),V4="ETHERS_JS_SHARED";class Wy extends Gn{static getApiKey(e){return e&&typeof e!="string"&&gf.throwArgumentError("invalid apiKey","apiKey",e),e||V4}static getUrl(e,r){gf.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let n=null;switch(e.name){case"homestead":n="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":n="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":n="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":n="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":n="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:gf.throwArgumentError("unsupported network","network",arguments[0])}return n+"?apiKey="+r}}const _m=new j(qt),Sm="62e1ad51b37b8e00394bda3b";class Ky extends Gn{static getApiKey(e){const r={applicationId:null,loadBalancer:!0,applicationSecretKey:null};return e==null?r.applicationId=Sm:typeof e=="string"?r.applicationId=e:e.applicationSecretKey!=null?(r.applicationId=e.applicationId,r.applicationSecretKey=e.applicationSecretKey):e.applicationId?r.applicationId=e.applicationId:_m.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),r}static getUrl(e,r){let n=null;switch(e?e.name:"unknown"){case"goerli":n="eth-goerli.gateway.pokt.network";break;case"homestead":n="eth-mainnet.gateway.pokt.network";break;case"kovan":n="poa-kovan.gateway.pokt.network";break;case"matic":n="poly-mainnet.gateway.pokt.network";break;case"maticmum":n="polygon-mumbai-rpc.gateway.pokt.network";break;case"rinkeby":n="eth-rinkeby.gateway.pokt.network";break;case"ropsten":n="eth-ropsten.gateway.pokt.network";break;default:_m.throwError("unsupported network",j.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i=`https://${n}/v1/lb/${r.applicationId}`,s={headers:{},url:i};return r.applicationSecretKey!=null&&(s.user="",s.password=r.applicationSecretKey),s}isCommunityResource(){return this.applicationId===Sm}}const km=new j(qt);let q4=1;function Nm(t,e){const r="Web3LegacyFetcher";return function(n,i){const s={method:n,params:i,id:q4++,jsonrpc:"2.0"};return new Promise((o,a)=>{this.emit("debug",{action:"request",fetcher:r,request:lr(s),provider:this}),e(s,(l,u)=>{if(l)return this.emit("debug",{action:"response",fetcher:r,error:l,request:s,provider:this}),a(l);if(this.emit("debug",{action:"response",fetcher:r,request:s,response:u,provider:this}),u.error){const c=new Error(u.error.message);return c.code=u.error.code,c.data=u.error.data,a(c)}o(u.result)})})}}function G4(t){return function(e,r){r==null&&(r=[]);const n={method:e,params:r};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:lr(n),provider:this}),t.request(n).then(i=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,response:i,provider:this}),i),i=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,error:i,provider:this}),i})}}class Qy extends Qi{constructor(e,r){e==null&&km.throwArgumentError("missing provider","provider",e);let n=null,i=null,s=null;typeof e=="function"?(n="unknown:",i=e):(n=e.host||e.path||"",!n&&e.isMetaMask&&(n="metamask"),s=e,e.request?(n===""&&(n="eip-1193:"),i=G4(e)):e.sendAsync?i=Nm(e,e.sendAsync.bind(e)):e.send?i=Nm(e,e.send.bind(e)):km.throwArgumentError("unsupported provider","provider",e),n||(n="unknown:")),super(n,r),H(this,"jsonRpcFetchFunc",i),H(this,"provider",s)}send(e,r){return this.jsonRpcFetchFunc(e,r)}}const Mm=new j(qt);function W4(t,e){if(t==null&&(t="homestead"),typeof t=="string"){const n=t.match(/^(ws|http)s?:/i);if(n)switch(n[1].toLowerCase()){case"http":case"https":return new Qi(t);case"ws":case"wss":return new rc(t);default:Mm.throwArgumentError("unsupported URL scheme","network",t)}}const r=qd(t);return(!r||!r._defaultProvider)&&Mm.throwError("unsupported getDefaultProvider network",j.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider({FallbackProvider:Vy,AlchemyProvider:Xd,AnkrProvider:zy,CloudflareProvider:$y,EtherscanProvider:Hy,InfuraProvider:Zd,JsonRpcProvider:Qi,NodesmithProvider:Wy,PocketProvider:Ky,Web3Provider:Qy,IpcProvider:qy},e)}const K4=Object.freeze(Object.defineProperty({__proto__:null,AlchemyProvider:Xd,AlchemyWebSocketProvider:Uy,AnkrProvider:zy,BaseProvider:tc,CloudflareProvider:$y,EtherscanProvider:Hy,FallbackProvider:Vy,Formatter:ee,InfuraProvider:Zd,InfuraWebSocketProvider:Gy,IpcProvider:qy,JsonRpcBatchProvider:H4,JsonRpcProvider:Qi,JsonRpcSigner:Yd,NodesmithProvider:Wy,PocketProvider:Ky,Provider:ro,Resolver:Rh,StaticJsonRpcProvider:Fy,UrlJsonRpcProvider:Gn,Web3Provider:Qy,WebSocketProvider:rc,getDefaultProvider:W4,getNetwork:qd,isCommunityResourcable:jy,isCommunityResource:Ph,showThrottleMessage:Oa},Symbol.toStringTag,{value:"Module"})),Q4=Ys(K4);var J4=ze&&ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Y4=ze&&ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),X4=ze&&ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&J4(e,t,r);return Y4(e,t),e},Z4=ze&&ze.__awaiter||function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.getPriorityConnector=Ln.getSelectedConnector=Ln.initializeConnector=void 0;const e_=N1,Ss=L,Cm=iE,t_=lE;let Ls;function r_(){return Z4(this,void 0,void 0,function*(){if(Ls===void 0)try{const{Web3Provider:t}=yield Promise.resolve().then(()=>X4(Q4));Ls=t}catch{console.debug("@ethersproject/providers not available"),Ls=null}})}function n_(t){const[e,r]=(0,e_.createWeb3ReactStoreAndActions)(),n=t(r),i=c_(e),s=f_(i),o=h_(n,i,s);return[n,Object.assign(Object.assign(Object.assign({},i),s),o),e]}Ln.initializeConnector=n_;function i_({chainId:t,accounts:e,activating:r}){return!!(t&&e&&!r)}function Jy(...t){function e(h){const p=t.findIndex(([m])=>h===m);if(p===-1)throw new Error("Connector not found");return p}function r(h){const p=t[e(h)][2];if(!p)throw new Error("Stores not passed");return p}function n(h){return t.map(([,{useChainId:m}])=>m())[e(h)]}function i(h){return t.map(([,{useAccounts:m}])=>m())[e(h)]}function s(h){return t.map(([,{useIsActivating:m}])=>m())[e(h)]}function o(h){return t.map(([,{useAccount:m}])=>m())[e(h)]}function a(h){return t.map(([,{useIsActive:m}])=>m())[e(h)]}function l(h,p){const m=e(h);return t.map(([,{useProvider:b}],k)=>b(p,k===m))[m]}function u(h,p){const m=e(h);return t.map(([,{useENSNames:b}],k)=>b(k===m?p:void 0))[m]}function c(h,p){const m=e(h);return t.map(([,{useENSName:b}],k)=>b(k===m?p:void 0))[m]}return{useSelectedStore:r,useSelectedChainId:n,useSelectedAccounts:i,useSelectedIsActivating:s,useSelectedAccount:o,useSelectedIsActive:a,useSelectedProvider:l,useSelectedENSNames:u,useSelectedENSName:c}}Ln.getSelectedConnector=Jy;function s_(...t){const{useSelectedStore:e,useSelectedChainId:r,useSelectedAccounts:n,useSelectedIsActivating:i,useSelectedAccount:s,useSelectedIsActive:o,useSelectedProvider:a,useSelectedENSNames:l,useSelectedENSName:u}=Jy(...t);function c(){const I=t.map(([,{useIsActive:B}])=>B()).findIndex(B=>B);return t[I===-1?0:I][0]}function h(){return e(c())}function p(){return r(c())}function m(){return n(c())}function v(){return i(c())}function b(){return s(c())}function k(){return o(c())}function x(T){return a(c(),T)}function w(T){return l(c(),T)}function A(T){return u(c(),T)}return{useSelectedStore:e,useSelectedChainId:r,useSelectedAccounts:n,useSelectedIsActivating:i,useSelectedAccount:s,useSelectedIsActive:o,useSelectedProvider:a,useSelectedENSNames:l,useSelectedENSName:u,usePriorityConnector:c,usePriorityStore:h,usePriorityChainId:p,usePriorityAccounts:m,usePriorityIsActivating:v,usePriorityAccount:b,usePriorityIsActive:k,usePriorityProvider:x,usePriorityENSNames:w,usePriorityENSName:A}}Ln.getPriorityConnector=s_;const o_=({chainId:t})=>t,a_=({accounts:t})=>t,l_=({activating:t})=>t,u_=(t,e)=>t===void 0&&e===void 0||t!==void 0&&t.length===(e==null?void 0:e.length)&&t.every((r,n)=>r===e[n]);function c_(t){function e(){return(0,Cm.useStore)(t,o_)}function r(){return(0,t_.useStoreWithEqualityFn)(t,a_,u_)}function n(){return(0,Cm.useStore)(t,l_)}return{useChainId:e,useAccounts:r,useIsActivating:n}}function f_({useChainId:t,useAccounts:e,useIsActivating:r}){function n(){var s;return(s=e())===null||s===void 0?void 0:s[0]}function i(){const s=t(),o=e(),a=r();return i_({chainId:s,accounts:o,activating:a})}return{useAccount:n,useIsActive:i}}function Pm(t,e=[]){const[r,n]=(0,Ss.useState)();return(0,Ss.useEffect)(()=>{if(t&&e.length){let i=!1;return Promise.all(e.map(s=>t.lookupAddress(s))).then(s=>{i||n(s)}).catch(s=>{i||(console.debug("Could not fetch ENS names",s),n(new Array(e.length).fill(null)))}),()=>{i=!0,n(void 0)}}},[t,e]),r??new Array(e.length).fill(void 0)}function h_(t,{useAccounts:e,useChainId:r},{useAccount:n,useIsActive:i}){function s(l,u=!0){const c=i(),h=r(),[p,m]=(0,Ss.useState)(Ls!==void 0);return(0,Ss.useEffect)(()=>{if(p)return;let v=!1;return r_().then(()=>{v||m(!0)}),()=>{v=!0}},[p]),(0,Ss.useMemo)(()=>{if(u){if(t.customProvider)return t.customProvider;if(Ls&&t.provider)return new Ls(t.provider,l)}},[p,u,c,h,l])}function o(l){const u=e();return Pm(l,u)}function a(l){var u;const c=n(),h=(0,Ss.useMemo)(()=>c===void 0?void 0:[c],[c]);return(u=Pm(l,h))===null||u===void 0?void 0:u[0]}return{useProvider:s,useENSNames:o,useENSName:a}}var nc={},Yy={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function i(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function s(l,u,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var m=new i(c,h||l,p),v=r?r+u:u;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],m]:l._events[v].push(m):(l._events[v]=m,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new n:delete l._events[u]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)e.call(c,h)&&u.push(r?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},a.prototype.listeners=function(u){var c=r?r+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,m=h.length,v=new Array(m);pe),this.eth_accounts=jest.fn(e=>e),this.eth_requestAccounts=jest.fn(e=>e)}request(e){if(!this.chainId)return Promise.reject(new Error);switch(e.method){case"eth_chainId":return Promise.resolve(this.eth_chainId(this.chainId));case"eth_accounts":return Promise.resolve(this.eth_accounts(this.accounts));case"eth_requestAccounts":return Promise.resolve(this.eth_requestAccounts(this.accounts));default:throw new Error(`Method not supported on mock: ${JSON.stringify(e)}`)}}emitConnect(e){this.emit("connect",{chainId:e})}emitDisconnect(e){this.emit("disconnect",e)}emitChainChanged(e){this.emit("chainChanged",e)}emitAccountsChanged(e){this.emit("accountsChanged",e)}}nc.MockEIP1193Provider=m_;var Qs={},g_=ze&&ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),v_=ze&&ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),y_=ze&&ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&g_(e,t,r);return v_(e,t),e};Object.defineProperty(Qs,"__esModule",{value:!0});Qs.useWeb3React=Qs.Web3ReactProvider=void 0;const hu=y_(L),w_=Ln,Xy=(0,hu.createContext)(void 0);function x_({children:t,connectors:e,connectorOverride:r,network:n,lookupENS:i=!0}){const s=(0,hu.useRef)(e);if(e.length!=s.current.length||e.some((G,Y)=>{const $e=s.current[Y];return G[0]!==$e[0]}))throw new Error("The connectors prop passed to Web3ReactProvider must be referentially static. If connectors is changing, try providing a key prop to Web3ReactProvider that changes every time connectors changes.");const o=(0,w_.getPriorityConnector)(...e),{usePriorityConnector:a,useSelectedChainId:l,useSelectedAccounts:u,useSelectedIsActivating:c,useSelectedAccount:h,useSelectedIsActive:p,useSelectedProvider:m,useSelectedENSNames:v,useSelectedENSName:b}=o,k=a(),x=r??k,w=l(x),A=u(x),T=c(x),I=h(x),B=p(x),F=m(x,n),$=v(x,i?F:void 0),V=b(x,i?F:void 0);return hu.default.createElement(Xy.Provider,{value:{connector:x,chainId:w,accounts:A,isActivating:T,account:I,isActive:B,provider:F,ENSNames:$,ENSName:V,hooks:o}},t)}Qs.Web3ReactProvider=x_;function b_(){const t=(0,hu.useContext)(Xy);if(!t)throw Error("useWeb3React can only be used within the Web3ReactProvider component");return t}Qs.useWeb3React=b_;(function(t){var e=ze&&ze.__createBinding||(Object.create?function(n,i,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(i,s);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,o,a)}:function(n,i,s,o){o===void 0&&(o=s),n[o]=i[s]}),r=ze&&ze.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Ln,t),r(nc,t),r(Qs,t)})(Hu);const ja="abi/5.7.0",be=new j(ja),Ji={};let Rm={calldata:!0,memory:!0,storage:!0},E_={calldata:!0,memory:!0};function al(t,e){if(t==="bytes"||t==="string"){if(Rm[e])return!0}else if(t==="address"){if(e==="payable")return!0}else if((t.indexOf("[")>=0||t==="tuple")&&E_[e])return!0;return(Rm[e]||e==="payable")&&be.throwArgumentError("invalid modifier","name",e),!1}function A_(t,e){let r=t;function n(a){be.throwArgumentError(`unexpected character at position ${a}`,"param",t)}t=t.replace(/\s/g," ");function i(a){let l={type:"",name:"",parent:a,state:{allowType:!0}};return e&&(l.indexed=!1),l}let s={type:"",name:"",state:{allowType:!0}},o=s;for(let a=0;aJSON.parse(i.format(e)))),JSON.stringify(n)}let r="";return this.baseType==="array"?(r+=this.arrayChildren.format(e),r+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(e!==ke.sighash&&(r+=this.type),r+="("+this.components.map(n=>n.format(e)).join(e===ke.full?", ":",")+")"):r+=this.type,e!==ke.sighash&&(this.indexed===!0&&(r+=" indexed"),e===ke.full&&this.name&&(r+=" "+this.name)),r}static from(e,r){return typeof e=="string"?Nt.fromString(e,r):Nt.fromObject(e)}static fromObject(e){return Nt.isParamType(e)?e:new Nt(Ji,{name:e.name||null,type:as(e.type),indexed:e.indexed==null?null:!!e.indexed,components:e.components?e.components.map(Nt.fromObject):null})}static fromString(e,r){function n(i){return Nt.fromObject({name:i.name,type:i.type,indexed:i.indexed,components:i.components})}return n(A_(e,!!r))}static isParamType(e){return!!(e!=null&&e._isParamType)}}function da(t,e){return k_(t).map(r=>Nt.fromString(r,e))}class Tn{constructor(e,r){e!==Ji&&be.throwError("use a static from method",j.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Il(this,r),this._isFragment=!0,Object.freeze(this)}static from(e){return Tn.isFragment(e)?e:typeof e=="string"?Tn.fromString(e):Tn.fromObject(e)}static fromObject(e){if(Tn.isFragment(e))return e;switch(e.type){case"function":return un.fromObject(e);case"event":return Pn.fromObject(e);case"constructor":return ln.fromObject(e);case"error":return ui.fromObject(e);case"fallback":case"receive":return null}return be.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return e=e.replace(/\s/g," "),e=e.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),e=e.trim(),e.split(" ")[0]==="event"?Pn.fromString(e.substring(5).trim()):e.split(" ")[0]==="function"?un.fromString(e.substring(8).trim()):e.split("(")[0].trim()==="constructor"?ln.fromString(e.trim()):e.split(" ")[0]==="error"?ui.fromString(e.substring(5).trim()):be.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!!(e&&e._isFragment)}}class Pn extends Tn{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});let r="";return e!==ke.sighash&&(r+="event "),r+=this.name+"("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ",e!==ke.sighash&&this.anonymous&&(r+="anonymous "),r.trim()}static from(e){return typeof e=="string"?Pn.fromString(e):Pn.fromObject(e)}static fromObject(e){if(Pn.isEventFragment(e))return e;e.type!=="event"&&be.throwArgumentError("invalid event object","value",e);const r={name:pa(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Nt.fromObject):[],type:"event"};return new Pn(Ji,r)}static fromString(e){let r=e.match(ma);r||be.throwArgumentError("invalid event string","value",e);let n=!1;return r[3].split(" ").forEach(i=>{switch(i.trim()){case"anonymous":n=!0;break;case"":break;default:be.warn("unknown modifier: "+i)}}),Pn.fromObject({name:r[1].trim(),anonymous:n,inputs:da(r[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&e.type==="event"}}function Zy(t,e){e.gas=null;let r=t.split("@");return r.length!==1?(r.length>2&&be.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||be.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=K.from(r[1]),r[0]):t}function e2(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(r=>{switch(r.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+r)}})}function t2(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return t.stateMutability!=null?(e.stateMutability=t.stateMutability,e.constant=e.stateMutability==="view"||e.stateMutability==="pure",t.constant!=null&&!!t.constant!==e.constant&&be.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable=e.stateMutability==="payable",t.payable!=null&&!!t.payable!==e.payable&&be.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):t.payable!=null?(e.payable=!!t.payable,t.constant==null&&!e.payable&&t.type!=="constructor"&&be.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&be.throwArgumentError("cannot have constant payable function","value",t)):t.constant!=null?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):t.type!=="constructor"&&be.throwArgumentError("unable to determine stateMutability","value",t),e}class ln extends Tn{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});e===ke.sighash&&be.throwError("cannot format a constructor for sighash",j.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let r="constructor("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "),r.trim()}static from(e){return typeof e=="string"?ln.fromString(e):ln.fromObject(e)}static fromObject(e){if(ln.isConstructorFragment(e))return e;e.type!=="constructor"&&be.throwArgumentError("invalid constructor object","value",e);let r=t2(e);r.constant&&be.throwArgumentError("constructor cannot be constant","value",e);const n={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Nt.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?K.from(e.gas):null};return new ln(Ji,n)}static fromString(e){let r={type:"constructor"};e=Zy(e,r);let n=e.match(ma);return(!n||n[1].trim()!=="constructor")&&be.throwArgumentError("invalid constructor string","value",e),r.inputs=da(n[2].trim(),!1),e2(n[3].trim(),r),ln.fromObject(r)}static isConstructorFragment(e){return e&&e._isFragment&&e.type==="constructor"}}class un extends ln{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e))),outputs:this.outputs.map(n=>JSON.parse(n.format(e)))});let r="";return e!==ke.sighash&&(r+="function "),r+=this.name+"("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ",e!==ke.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "):this.constant&&(r+="view "),this.outputs&&this.outputs.length&&(r+="returns ("+this.outputs.map(n=>n.format(e)).join(", ")+") "),this.gas!=null&&(r+="@"+this.gas.toString()+" ")),r.trim()}static from(e){return typeof e=="string"?un.fromString(e):un.fromObject(e)}static fromObject(e){if(un.isFunctionFragment(e))return e;e.type!=="function"&&be.throwArgumentError("invalid function object","value",e);let r=t2(e);const n={type:e.type,name:pa(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(Nt.fromObject):[],outputs:e.outputs?e.outputs.map(Nt.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?K.from(e.gas):null};return new un(Ji,n)}static fromString(e){let r={type:"function"};e=Zy(e,r);let n=e.split(" returns ");n.length>2&&be.throwArgumentError("invalid function string","value",e);let i=n[0].match(ma);if(i||be.throwArgumentError("invalid function signature","value",e),r.name=i[1].trim(),r.name&&pa(r.name),r.inputs=da(i[2],!1),e2(i[3].trim(),r),n.length>1){let s=n[1].match(ma);(s[1].trim()!=""||s[3].trim()!="")&&be.throwArgumentError("unexpected tokens","value",e),r.outputs=da(s[2],!1)}else r.outputs=[];return un.fromObject(r)}static isFunctionFragment(e){return e&&e._isFragment&&e.type==="function"}}function Im(t){const e=t.format();return(e==="Error(string)"||e==="Panic(uint256)")&&be.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}class ui extends Tn{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});let r="";return e!==ke.sighash&&(r+="error "),r+=this.name+"("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ",r.trim()}static from(e){return typeof e=="string"?ui.fromString(e):ui.fromObject(e)}static fromObject(e){if(ui.isErrorFragment(e))return e;e.type!=="error"&&be.throwArgumentError("invalid error object","value",e);const r={type:e.type,name:pa(e.name),inputs:e.inputs?e.inputs.map(Nt.fromObject):[]};return Im(new ui(Ji,r))}static fromString(e){let r={type:"error"},n=e.match(ma);return n||be.throwArgumentError("invalid error signature","value",e),r.name=n[1].trim(),r.name&&pa(r.name),r.inputs=da(n[2],!1),Im(ui.fromObject(r))}static isErrorFragment(e){return e&&e._isFragment&&e.type==="error"}}function as(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const S_=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function pa(t){return(!t||!t.match(S_))&&be.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}const ma=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function k_(t){t=t.trim();let e=[],r="",n=0;for(let i=0;ithis.wordSize&&e0.throwError("value out-of-bounds",j.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:r.length}),r.length%this.wordSize&&(r=$t([this._padding.slice(r.length%this.wordSize),r])),r}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,r=>{this._data[e]=this._getValue(r)}}}class du{constructor(e,r,n,i){H(this,"_data",oe(e)),H(this,"wordSize",r||32),H(this,"_coerceFunc",n),H(this,"allowLoose",i),this._offset=0}get data(){return ne(this._data)}get consumed(){return this._offset}static coerce(e,r){let n=e.match("^u?int([0-9]+)$");return n&&parseInt(n[1])<=48&&(r=r.toNumber()),r}coerce(e,r){return this._coerceFunc?this._coerceFunc(e,r):du.coerce(e,r)}_peekBytes(e,r,n){let i=Math.ceil(r/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&n&&this._offset+r<=this._data.length?i=r:e0.throwError("data out-of-bounds",j.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(e){return new du(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,r){let n=this._peekBytes(0,e,!!r);return this._offset+=n.length,n.slice(0,e)}readValue(){return K.from(this.readBytes(this.wordSize))}}class M_ extends Wn{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,r){try{r=vt(r)}catch(n){this._throwError(n.message,r)}return e.writeValue(r)}decode(e){return vt(gt(e.readValue().toHexString(),20))}}class C_ extends Wn{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}}const ks=new j(ja);function r2(t,e,r){let n=null;if(Array.isArray(r))n=r;else if(r&&typeof r=="object"){let l={};n=e.map(u=>{const c=u.localName;return c||ks.throwError("cannot encode object for signature with missing names",j.errors.INVALID_ARGUMENT,{argument:"values",coder:u,value:r}),l[c]&&ks.throwError("cannot encode object for signature with duplicate names",j.errors.INVALID_ARGUMENT,{argument:"values",coder:u,value:r}),l[c]=!0,r[c]})}else ks.throwArgumentError("invalid tuple value","tuple",r);e.length!==n.length&&ks.throwArgumentError("types/value length mismatch","tuple",r);let i=new Oh(t.wordSize),s=new Oh(t.wordSize),o=[];e.forEach((l,u)=>{let c=n[u];if(l.dynamic){let h=s.length;l.encode(s,c);let p=i.writeUpdatableValue();o.push(m=>{p(m+h)})}else l.encode(i,c)}),o.forEach(l=>{l(i.length)});let a=t.appendWriter(i);return a+=t.appendWriter(s),a}function n2(t,e){let r=[],n=t.subReader(0);e.forEach(s=>{let o=null;if(s.dynamic){let a=t.readValue(),l=n.subReader(a.toNumber());try{o=s.decode(l)}catch(u){if(u.code===j.errors.BUFFER_OVERRUN)throw u;o=u,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(t)}catch(a){if(a.code===j.errors.BUFFER_OVERRUN)throw a;o=a,o.baseType=s.name,o.name=s.localName,o.type=s.type}o!=null&&r.push(o)});const i=e.reduce((s,o)=>{const a=o.localName;return a&&(s[a]||(s[a]=0),s[a]++),s},{});e.forEach((s,o)=>{let a=s.localName;if(!a||i[a]!==1||(a==="length"&&(a="_length"),r[a]!=null))return;const l=r[o];l instanceof Error?Object.defineProperty(r,a,{enumerable:!0,get:()=>{throw l}}):r[a]=l});for(let s=0;s{throw o}})}return Object.freeze(r)}class P_ extends Wn{constructor(e,r,n){const i=e.type+"["+(r>=0?r:"")+"]",s=r===-1||e.dynamic;super("array",i,n,s),this.coder=e,this.length=r}defaultValue(){const e=this.coder.defaultValue(),r=[];for(let n=0;ne._data.length&&ks.throwError("insufficient data length",j.errors.BUFFER_OVERRUN,{length:e._data.length,count:r}));let n=[];for(let i=0;i{o.dynamic&&(n=!0),i.push(o.type)});const s="tuple("+i.join(",")+")";super("tuple",s,r,n),this.coders=e}defaultValue(){const e=[];this.coders.forEach(n=>{e.push(n.defaultValue())});const r=this.coders.reduce((n,i)=>{const s=i.localName;return s&&(n[s]||(n[s]=0),n[s]++),n},{});return this.coders.forEach((n,i)=>{let s=n.localName;!s||r[s]!==1||(s==="length"&&(s="_length"),e[s]==null&&(e[s]=e[i]))}),Object.freeze(e)}encode(e,r){return r2(e,this.coders,r)}decode(e){return e.coerce(this.name,n2(e,this.coders))}}const ul=new j(ja),B_=new RegExp(/^bytes([0-9]*)$/),D_=new RegExp(/^(u?int)([0-9]*)$/);class F_{constructor(e){H(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new M_(e.name);case"bool":return new R_(e.name);case"string":return new L_(e.name);case"bytes":return new I_(e.name);case"array":return new P_(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new ll((e.components||[]).map(n=>this._getCoder(n)),e.name);case"":return new T_(e.name)}let r=e.type.match(D_);if(r){let n=parseInt(r[2]||"256");return(n===0||n>256||n%8!==0)&&ul.throwArgumentError("invalid "+r[1]+" bit length","param",e),new j_(n/8,r[1]==="int",e.name)}if(r=e.type.match(B_),r){let n=parseInt(r[1]);return(n===0||n>32)&&ul.throwArgumentError("invalid bytes length","param",e),new O_(n,e.name)}return ul.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,r){return new du(e,this._getWordSize(),this.coerceFunc,r)}_getWriter(){return new Oh(this._getWordSize())}getDefaultValue(e){const r=e.map(i=>this._getCoder(Nt.from(i)));return new ll(r,"_").defaultValue()}encode(e,r){e.length!==r.length&&ul.throwError("types/values length mismatch",j.errors.INVALID_ARGUMENT,{count:{types:e.length,values:r.length},value:{types:e,values:r}});const n=e.map(o=>this._getCoder(Nt.from(o))),i=new ll(n,"_"),s=this._getWriter();return i.encode(s,r),s.data}decode(e,r,n){const i=e.map(o=>this._getCoder(Nt.from(o)));return new ll(i,"_").decode(this._getReader(oe(r),n))}}const U_=new F_,ut=new j(ja);class z_ extends Ca{}class $_ extends Ca{}class H_ extends Ca{}class Th extends Ca{static isIndexed(e){return!!(e&&e._isIndexed)}}const V_={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function Om(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);return r.error=e,r}class jh{constructor(e){let r=[];typeof e=="string"?r=JSON.parse(e):r=e,H(this,"fragments",r.map(n=>Tn.from(n)).filter(n=>n!=null)),H(this,"_abiCoder",mr(new.target,"getAbiCoder")()),H(this,"functions",{}),H(this,"errors",{}),H(this,"events",{}),H(this,"structs",{}),this.fragments.forEach(n=>{let i=null;switch(n.type){case"constructor":if(this.deploy){ut.warn("duplicate definition - constructor");return}H(this,"deploy",n);return;case"function":i=this.functions;break;case"event":i=this.events;break;case"error":i=this.errors;break;default:return}let s=n.format();if(i[s]){ut.warn("duplicate definition - "+s);return}i[s]=n}),this.deploy||H(this,"deploy",ln.from({payable:!1,type:"constructor"})),H(this,"_isInterface",!0)}format(e){e||(e=ke.full),e===ke.sighash&&ut.throwArgumentError("interface does not support formatting sighash","format",e);const r=this.fragments.map(n=>n.format(e));return e===ke.json?JSON.stringify(r.map(n=>JSON.parse(n))):r}static getAbiCoder(){return U_}static getAddress(e){return vt(e)}static getSighash(e){return Tt(Es(e.format()),0,4)}static getEventTopic(e){return Es(e.format())}getFunction(e){if(me(e)){for(const n in this.functions)if(e===this.getSighash(n))return this.functions[n];ut.throwArgumentError("no matching function","sighash",e)}if(e.indexOf("(")===-1){const n=e.trim(),i=Object.keys(this.functions).filter(s=>s.split("(")[0]===n);return i.length===0?ut.throwArgumentError("no matching function","name",n):i.length>1&&ut.throwArgumentError("multiple matching functions","name",n),this.functions[i[0]]}const r=this.functions[un.fromString(e).format()];return r||ut.throwArgumentError("no matching function","signature",e),r}getEvent(e){if(me(e)){const n=e.toLowerCase();for(const i in this.events)if(n===this.getEventTopic(i))return this.events[i];ut.throwArgumentError("no matching event","topichash",n)}if(e.indexOf("(")===-1){const n=e.trim(),i=Object.keys(this.events).filter(s=>s.split("(")[0]===n);return i.length===0?ut.throwArgumentError("no matching event","name",n):i.length>1&&ut.throwArgumentError("multiple matching events","name",n),this.events[i[0]]}const r=this.events[Pn.fromString(e).format()];return r||ut.throwArgumentError("no matching event","signature",e),r}getError(e){if(me(e)){const n=mr(this.constructor,"getSighash");for(const i in this.errors){const s=this.errors[i];if(e===n(s))return this.errors[i]}ut.throwArgumentError("no matching error","sighash",e)}if(e.indexOf("(")===-1){const n=e.trim(),i=Object.keys(this.errors).filter(s=>s.split("(")[0]===n);return i.length===0?ut.throwArgumentError("no matching error","name",n):i.length>1&&ut.throwArgumentError("multiple matching errors","name",n),this.errors[i[0]]}const r=this.errors[un.fromString(e).format()];return r||ut.throwArgumentError("no matching error","signature",e),r}getSighash(e){if(typeof e=="string")try{e=this.getFunction(e)}catch(r){try{e=this.getError(e)}catch{throw r}}return mr(this.constructor,"getSighash")(e)}getEventTopic(e){return typeof e=="string"&&(e=this.getEvent(e)),mr(this.constructor,"getEventTopic")(e)}_decodeParams(e,r){return this._abiCoder.decode(e,r)}_encodeParams(e,r){return this._abiCoder.encode(e,r)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,r){typeof e=="string"&&(e=this.getError(e));const n=oe(r);return ne(n.slice(0,4))!==this.getSighash(e)&&ut.throwArgumentError(`data signature does not match error ${e.name}.`,"data",ne(n)),this._decodeParams(e.inputs,n.slice(4))}encodeErrorResult(e,r){return typeof e=="string"&&(e=this.getError(e)),ne($t([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionData(e,r){typeof e=="string"&&(e=this.getFunction(e));const n=oe(r);return ne(n.slice(0,4))!==this.getSighash(e)&&ut.throwArgumentError(`data signature does not match function ${e.name}.`,"data",ne(n)),this._decodeParams(e.inputs,n.slice(4))}encodeFunctionData(e,r){return typeof e=="string"&&(e=this.getFunction(e)),ne($t([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionResult(e,r){typeof e=="string"&&(e=this.getFunction(e));let n=oe(r),i=null,s="",o=null,a=null,l=null;switch(n.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,n)}catch{}break;case 4:{const u=ne(n.slice(0,4)),c=V_[u];if(c)o=this._abiCoder.decode(c.inputs,n.slice(4)),a=c.name,l=c.signature,c.reason&&(i=o[0]),a==="Error"?s=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(o[0])}`:a==="Panic"&&(s=`; VM Exception while processing transaction: reverted with panic code ${o[0]}`);else try{const h=this.getError(u);o=this._abiCoder.decode(h.inputs,n.slice(4)),a=h.name,l=h.format()}catch{}break}}return ut.throwError("call revert exception"+s,j.errors.CALL_EXCEPTION,{method:e.format(),data:ne(r),errorArgs:o,errorName:a,errorSignature:l,reason:i})}encodeFunctionResult(e,r){return typeof e=="string"&&(e=this.getFunction(e)),ne(this._abiCoder.encode(e.outputs,r||[]))}encodeFilterTopics(e,r){typeof e=="string"&&(e=this.getEvent(e)),r.length>e.inputs.length&&ut.throwError("too many arguments for "+e.format(),j.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:r});let n=[];e.anonymous||n.push(this.getEventTopic(e));const i=(s,o)=>s.type==="string"?Es(o):s.type==="bytes"?ot(ne(o)):(s.type==="bool"&&typeof o=="boolean"&&(o=o?"0x01":"0x00"),s.type.match(/^u?int/)&&(o=K.from(o).toHexString()),s.type==="address"&&this._abiCoder.encode(["address"],[o]),gt(ne(o),32));for(r.forEach((s,o)=>{let a=e.inputs[o];if(!a.indexed){s!=null&&ut.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,s);return}s==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?ut.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,s):Array.isArray(s)?n.push(s.map(l=>i(a,l))):n.push(i(a,s))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,r){typeof e=="string"&&(e=this.getEvent(e));const n=[],i=[],s=[];return e.anonymous||n.push(this.getEventTopic(e)),r.length!==e.inputs.length&&ut.throwArgumentError("event arguments/values mismatch","values",r),e.inputs.forEach((o,a)=>{const l=r[a];if(o.indexed)if(o.type==="string")n.push(Es(l));else if(o.type==="bytes")n.push(ot(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(this._abiCoder.encode([o.type],[l]))}else i.push(o),s.push(l)}),{data:this._abiCoder.encode(i,s),topics:n}}decodeEventLog(e,r,n){if(typeof e=="string"&&(e=this.getEvent(e)),n!=null&&!e.anonymous){let p=this.getEventTopic(e);(!me(n[0],32)||n[0].toLowerCase()!==p)&&ut.throwError("fragment/topic mismatch",j.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:p,value:n[0]}),n=n.slice(1)}let i=[],s=[],o=[];e.inputs.forEach((p,m)=>{p.indexed?p.type==="string"||p.type==="bytes"||p.baseType==="tuple"||p.baseType==="array"?(i.push(Nt.fromObject({type:"bytes32",name:p.name})),o.push(!0)):(i.push(p),o.push(!1)):(s.push(p),o.push(!1))});let a=n!=null?this._abiCoder.decode(i,$t(n)):null,l=this._abiCoder.decode(s,r,!0),u=[],c=0,h=0;e.inputs.forEach((p,m)=>{if(p.indexed)if(a==null)u[m]=new Th({_isIndexed:!0,hash:null});else if(o[m])u[m]=new Th({_isIndexed:!0,hash:a[h++]});else try{u[m]=a[h++]}catch(v){u[m]=v}else try{u[m]=l[c++]}catch(v){u[m]=v}if(p.name&&u[p.name]==null){const v=u[m];v instanceof Error?Object.defineProperty(u,p.name,{enumerable:!0,get:()=>{throw Om(`property ${JSON.stringify(p.name)}`,v)}}):u[p.name]=v}});for(let p=0;p{throw Om(`index ${p}`,m)}})}return Object.freeze(u)}parseTransaction(e){let r=this.getFunction(e.data.substring(0,10).toLowerCase());return r?new $_({args:this._abiCoder.decode(r.inputs,"0x"+e.data.substring(10)),functionFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r),value:K.from(e.value||"0")}):null}parseLog(e){let r=this.getEvent(e.topics[0]);return!r||r.anonymous?null:new z_({eventFragment:r,name:r.name,signature:r.format(),topic:this.getEventTopic(r),args:this.decodeEventLog(r,e.data,e.topics)})}parseError(e){const r=ne(e);let n=this.getError(r.substring(0,10).toLowerCase());return n?new H_({args:this._abiCoder.decode(n.inputs,"0x"+r.substring(10)),errorFragment:n,name:n.name,signature:n.format(),sighash:this.getSighash(n)}):null}static isInterface(e){return!!(e&&e._isInterface)}}const q_="contracts/5.7.0";var Yi=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const yt=new j(q_);function pu(t,e){return Yi(this,void 0,void 0,function*(){const r=yield e;typeof r!="string"&&yt.throwArgumentError("invalid address or ENS name","name",r);try{return vt(r)}catch{}t||yt.throwError("a provider or signer is needed to resolve ENS names",j.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const n=yield t.resolveName(r);return n==null&&yt.throwArgumentError("resolver or addr is not configured for ENS name","name",r),n})}function Ol(t,e,r){return Yi(this,void 0,void 0,function*(){return Array.isArray(r)?yield Promise.all(r.map((n,i)=>Ol(t,Array.isArray(e)?e[i]:e[n.name],n))):r.type==="address"?yield pu(t,e):r.type==="tuple"?yield Ol(t,e,r.components):r.baseType==="array"?Array.isArray(e)?yield Promise.all(e.map(n=>Ol(t,n,r.arrayChildren))):Promise.reject(yt.makeError("invalid value for array",j.errors.INVALID_ARGUMENT,{argument:"value",value:e})):e})}function ic(t,e,r){return Yi(this,void 0,void 0,function*(){let n={};r.length===e.inputs.length+1&&typeof r[r.length-1]=="object"&&(n=at(r.pop())),yt.checkArgumentCount(r.length,e.inputs.length,"passed to contract"),t.signer?n.from?n.from=xt({override:pu(t.signer,n.from),signer:t.signer.getAddress()}).then(u=>Yi(this,void 0,void 0,function*(){return vt(u.signer)!==u.override&&yt.throwError("Contract with a Signer cannot override from",j.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),u.override})):n.from=t.signer.getAddress():n.from&&(n.from=pu(t.provider,n.from));const i=yield xt({args:Ol(t.signer||t.provider,r,e.inputs),address:t.resolvedAddress,overrides:xt(n)||{}}),s=t.interface.encodeFunctionData(e,i.args),o={data:s,to:i.address},a=i.overrides;if(a.nonce!=null&&(o.nonce=K.from(a.nonce).toNumber()),a.gasLimit!=null&&(o.gasLimit=K.from(a.gasLimit)),a.gasPrice!=null&&(o.gasPrice=K.from(a.gasPrice)),a.maxFeePerGas!=null&&(o.maxFeePerGas=K.from(a.maxFeePerGas)),a.maxPriorityFeePerGas!=null&&(o.maxPriorityFeePerGas=K.from(a.maxPriorityFeePerGas)),a.from!=null&&(o.from=a.from),a.type!=null&&(o.type=a.type),a.accessList!=null&&(o.accessList=rs(a.accessList)),o.gasLimit==null&&e.gas!=null){let u=21e3;const c=oe(s);for(let h=0;hn[u]!=null);return l.length&&yt.throwError(`cannot override ${l.map(u=>JSON.stringify(u)).join(",")}`,j.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:l}),o})}function G_(t,e){return function(...r){return ic(t,e,r)}}function W_(t,e){const r=t.signer||t.provider;return function(...n){return Yi(this,void 0,void 0,function*(){r||yt.throwError("estimate require a provider or signer",j.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const i=yield ic(t,e,n);return yield r.estimateGas(i)})}}function K_(t,e){const r=e.wait.bind(e);e.wait=n=>r(n).then(i=>(i.events=i.logs.map(s=>{let o=lr(s),a=null;try{a=t.interface.parseLog(s)}catch{}return a&&(o.args=a.args,o.decode=(l,u)=>t.interface.decodeEventLog(a.eventFragment,l,u),o.event=a.name,o.eventSignature=a.signature),o.removeListener=()=>t.provider,o.getBlock=()=>t.provider.getBlock(i.blockHash),o.getTransaction=()=>t.provider.getTransaction(i.transactionHash),o.getTransactionReceipt=()=>Promise.resolve(i),o}),i))}function s2(t,e,r){const n=t.signer||t.provider;return function(...i){return Yi(this,void 0,void 0,function*(){let s;if(i.length===e.inputs.length+1&&typeof i[i.length-1]=="object"){const l=at(i.pop());l.blockTag!=null&&(s=yield l.blockTag),delete l.blockTag,i.push(l)}t.deployTransaction!=null&&(yield t._deployed(s));const o=yield ic(t,e,i),a=yield n.call(o,s);try{let l=t.interface.decodeFunctionResult(e,a);return r&&e.outputs.length===1&&(l=l[0]),l}catch(l){throw l.code===j.errors.CALL_EXCEPTION&&(l.address=t.address,l.args=i,l.transaction=o),l}})}}function Q_(t,e){return function(...r){return Yi(this,void 0,void 0,function*(){t.signer||yt.throwError("sending a transaction requires a signer",j.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.deployTransaction!=null&&(yield t._deployed());const n=yield ic(t,e,r),i=yield t.signer.sendTransaction(n);return K_(t,i),i})}}function Tm(t,e,r){return e.constant?s2(t,e,r):Q_(t,e)}function o2(t){return t.address&&(t.topics==null||t.topics.length===0)?"*":(t.address||"*")+"@"+(t.topics?t.topics.map(e=>Array.isArray(e)?e.join("|"):e).join(":"):"")}class ga{constructor(e,r){H(this,"tag",e),H(this,"filter",r),this._listeners=[]}addListener(e,r){this._listeners.push({listener:e,once:r})}removeListener(e){let r=!1;this._listeners=this._listeners.filter(n=>r||n.listener!==e?!0:(r=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(e=>e.listener)}listenerCount(){return this._listeners.length}run(e){const r=this.listenerCount();return this._listeners=this._listeners.filter(n=>{const i=e.slice();return setTimeout(()=>{n.listener.apply(this,i)},0),!n.once}),r}prepareEvent(e){}getEmit(e){return[e]}}class J_ extends ga{constructor(){super("error",null)}}class jm extends ga{constructor(e,r,n,i){const s={address:e};let o=r.getEventTopic(n);i?(o!==i[0]&&yt.throwArgumentError("topic mismatch","topics",i),s.topics=i.slice()):s.topics=[o],super(o2(s),s),H(this,"address",e),H(this,"interface",r),H(this,"fragment",n)}prepareEvent(e){super.prepareEvent(e),e.event=this.fragment.name,e.eventSignature=this.fragment.format(),e.decode=(r,n)=>this.interface.decodeEventLog(this.fragment,r,n);try{e.args=this.interface.decodeEventLog(this.fragment,e.data,e.topics)}catch(r){e.args=null,e.decodeError=r}}getEmit(e){const r=N_(e.args);if(r.length)throw r[0].error;const n=(e.args||[]).slice();return n.push(e),n}}class Lm extends ga{constructor(e,r){super("*",{address:e}),H(this,"address",e),H(this,"interface",r)}prepareEvent(e){super.prepareEvent(e);try{const r=this.interface.parseLog(e);e.event=r.name,e.eventSignature=r.signature,e.decode=(n,i)=>this.interface.decodeEventLog(r.eventFragment,n,i),e.args=r.args}catch{}}}class Y_{constructor(e,r,n){H(this,"interface",mr(new.target,"getInterface")(r)),n==null?(H(this,"provider",null),H(this,"signer",null)):Ta.isSigner(n)?(H(this,"provider",n.provider||null),H(this,"signer",n)):ro.isProvider(n)?(H(this,"provider",n),H(this,"signer",null)):yt.throwArgumentError("invalid signer or provider","signerOrProvider",n),H(this,"callStatic",{}),H(this,"estimateGas",{}),H(this,"functions",{}),H(this,"populateTransaction",{}),H(this,"filters",{});{const o={};Object.keys(this.interface.events).forEach(a=>{const l=this.interface.events[a];H(this.filters,a,(...u)=>({address:this.address,topics:this.interface.encodeFilterTopics(l,u)})),o[l.name]||(o[l.name]=[]),o[l.name].push(a)}),Object.keys(o).forEach(a=>{const l=o[a];l.length===1?H(this.filters,a,this.filters[l[0]]):yt.warn(`Duplicate definition of ${a} (${l.join(", ")})`)})}if(H(this,"_runningEvents",{}),H(this,"_wrappedEmits",{}),e==null&&yt.throwArgumentError("invalid contract address or ENS name","addressOrName",e),H(this,"address",e),this.provider)H(this,"resolvedAddress",pu(this.provider,e));else try{H(this,"resolvedAddress",Promise.resolve(vt(e)))}catch{yt.throwError("provider is required to use ENS name as contract address",j.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(o=>{});const i={},s={};Object.keys(this.interface.functions).forEach(o=>{const a=this.interface.functions[o];if(s[o]){yt.warn(`Duplicate ABI entry for ${JSON.stringify(o)}`);return}s[o]=!0;{const l=a.name;i[`%${l}`]||(i[`%${l}`]=[]),i[`%${l}`].push(o)}this[o]==null&&H(this,o,Tm(this,a,!0)),this.functions[o]==null&&H(this.functions,o,Tm(this,a,!1)),this.callStatic[o]==null&&H(this.callStatic,o,s2(this,a,!0)),this.populateTransaction[o]==null&&H(this.populateTransaction,o,G_(this,a)),this.estimateGas[o]==null&&H(this.estimateGas,o,W_(this,a))}),Object.keys(i).forEach(o=>{const a=i[o];if(a.length>1)return;o=o.substring(1);const l=a[0];try{this[o]==null&&H(this,o,this[l])}catch{}this.functions[o]==null&&H(this.functions,o,this.functions[l]),this.callStatic[o]==null&&H(this.callStatic,o,this.callStatic[l]),this.populateTransaction[o]==null&&H(this.populateTransaction,o,this.populateTransaction[l]),this.estimateGas[o]==null&&H(this.estimateGas,o,this.estimateGas[l])})}static getContractAddress(e){return Hd(e)}static getInterface(e){return jh.isInterface(e)?e:new jh(e)}deployed(){return this._deployed()}_deployed(e){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,e).then(r=>(r==="0x"&&yt.throwError("contract not deployed",j.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(e){this.signer||yt.throwError("sending a transactions require a signer",j.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const r=at(e||{});return["from","to"].forEach(function(n){r[n]!=null&&yt.throwError("cannot override "+n,j.errors.UNSUPPORTED_OPERATION,{operation:n})}),r.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(r))}connect(e){typeof e=="string"&&(e=new Jd(e,this.provider));const r=new this.constructor(this.address,this.interface,e);return this.deployTransaction&&H(r,"deployTransaction",this.deployTransaction),r}attach(e){return new this.constructor(e,this.interface,this.signer||this.provider)}static isIndexed(e){return Th.isIndexed(e)}_normalizeRunningEvent(e){return this._runningEvents[e.tag]?this._runningEvents[e.tag]:e}_getRunningEvent(e){if(typeof e=="string"){if(e==="error")return this._normalizeRunningEvent(new J_);if(e==="event")return this._normalizeRunningEvent(new ga("event",null));if(e==="*")return this._normalizeRunningEvent(new Lm(this.address,this.interface));const r=this.interface.getEvent(e);return this._normalizeRunningEvent(new jm(this.address,this.interface,r))}if(e.topics&&e.topics.length>0){try{const n=e.topics[0];if(typeof n!="string")throw new Error("invalid topic");const i=this.interface.getEvent(n);return this._normalizeRunningEvent(new jm(this.address,this.interface,i,e.topics))}catch{}const r={address:this.address,topics:e.topics};return this._normalizeRunningEvent(new ga(o2(r),r))}return this._normalizeRunningEvent(new Lm(this.address,this.interface))}_checkRunningEvents(e){if(e.listenerCount()===0){delete this._runningEvents[e.tag];const r=this._wrappedEmits[e.tag];r&&e.filter&&(this.provider.off(e.filter,r),delete this._wrappedEmits[e.tag])}}_wrapEvent(e,r,n){const i=lr(r);return i.removeListener=()=>{n&&(e.removeListener(n),this._checkRunningEvents(e))},i.getBlock=()=>this.provider.getBlock(r.blockHash),i.getTransaction=()=>this.provider.getTransaction(r.transactionHash),i.getTransactionReceipt=()=>this.provider.getTransactionReceipt(r.transactionHash),e.prepareEvent(i),i}_addEventListener(e,r,n){if(this.provider||yt.throwError("events require a provider or a signer with a provider",j.errors.UNSUPPORTED_OPERATION,{operation:"once"}),e.addListener(r,n),this._runningEvents[e.tag]=e,!this._wrappedEmits[e.tag]){const i=s=>{let o=this._wrapEvent(e,s,r);if(o.decodeError==null)try{const a=e.getEmit(o);this.emit(e.filter,...a)}catch(a){o.decodeError=a.error}e.filter!=null&&this.emit("event",o),o.decodeError!=null&&this.emit("error",o.decodeError,o)};this._wrappedEmits[e.tag]=i,e.filter!=null&&this.provider.on(e.filter,i)}}queryFilter(e,r,n){const i=this._getRunningEvent(e),s=at(i.filter);return typeof r=="string"&&me(r,32)?(n!=null&&yt.throwArgumentError("cannot specify toBlock with blockhash","toBlock",n),s.blockHash=r):(s.fromBlock=r??0,s.toBlock=n??"latest"),this.provider.getLogs(s).then(o=>o.map(a=>this._wrapEvent(i,a,null)))}on(e,r){return this._addEventListener(this._getRunningEvent(e),r,!1),this}once(e,r){return this._addEventListener(this._getRunningEvent(e),r,!0),this}emit(e,...r){if(!this.provider)return!1;const n=this._getRunningEvent(e),i=n.run(r)>0;return this._checkRunningEvents(n),i}listenerCount(e){return this.provider?e==null?Object.keys(this._runningEvents).reduce((r,n)=>r+this._runningEvents[n].listenerCount(),0):this._getRunningEvent(e).listenerCount():0}listeners(e){if(!this.provider)return[];if(e==null){const r=[];for(let n in this._runningEvents)this._runningEvents[n].listeners().forEach(i=>{r.push(i)});return r}return this._getRunningEvent(e).listeners()}removeAllListeners(e){if(!this.provider)return this;if(e==null){for(const n in this._runningEvents){const i=this._runningEvents[n];i.removeAllListeners(),this._checkRunningEvents(i)}return this}const r=this._getRunningEvent(e);return r.removeAllListeners(),this._checkRunningEvents(r),this}off(e,r){if(!this.provider)return this;const n=this._getRunningEvent(e);return n.removeListener(r),this._checkRunningEvents(n),this}removeListener(e,r){return this.off(e,r)}}class X_ extends Y_{}const Z_="solidity/5.7.0",e6=new RegExp("^bytes([0-9]+)$"),t6=new RegExp("^(u?int)([0-9]*)$"),r6=new RegExp("^(.*)\\[([0-9]*)\\]$"),n6="0000000000000000000000000000000000000000000000000000000000000000",ls=new j(Z_);function a2(t,e,r){switch(t){case"address":return r?Sl(e,32):oe(e);case"string":return yr(e);case"bytes":return oe(e);case"bool":return e=e?"0x01":"0x00",r?Sl(e,32):oe(e)}let n=t.match(t6);if(n){let i=parseInt(n[2]||"256");return(n[2]&&String(i)!==n[2]||i%8!==0||i===0||i>256)&&ls.throwArgumentError("invalid number type","type",t),r&&(i=256),e=K.from(e).toTwos(i),Sl(e,i/8)}if(n=t.match(e6),n){const i=parseInt(n[1]);return(String(i)!==n[1]||i===0||i>32)&&ls.throwArgumentError("invalid bytes type","type",t),oe(e).byteLength!==i&&ls.throwArgumentError(`invalid value for ${t}`,"value",e),r?oe((e+n6).substring(0,66)):e}if(n=t.match(r6),n&&Array.isArray(e)){const i=n[1];parseInt(n[2]||String(e.length))!=e.length&&ls.throwArgumentError(`invalid array length for ${t}`,"value",e);const o=[];return e.forEach(function(a){o.push(a2(i,a,!0))}),$t(o)}return ls.throwArgumentError("invalid type","type",t)}function l2(t,e){t.length!=e.length&&ls.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);const r=[];return t.forEach(function(n,i){r.push(a2(n,e[i]))}),ne($t(r))}function i6(t,e){return ot(l2(t,e))}const vf=[{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"approve",inputs:[{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"apps",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherKnsNodeId",type:"bytes32",internalType:"bytes32"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"balanceOf",inputs:[{name:"owner",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"contractURI",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"getApproved",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"getInitializedVersion",inputs:[],outputs:[{name:"",type:"uint64",internalType:"uint64"}],stateMutability:"view"},{type:"function",name:"getPackageId",inputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherName",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"pure"},{type:"function",name:"getPackageInfo",inputs:[{name:"package",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"tuple",internalType:"struct IKinodeAppStore.PackageInfo",components:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherKnsNodeId",type:"bytes32",internalType:"bytes32"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}]}],stateMutability:"view"},{type:"function",name:"getPackageInfo",inputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherName",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"tuple",internalType:"struct IKinodeAppStore.PackageInfo",components:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherKnsNodeId",type:"bytes32",internalType:"bytes32"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}]}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[{name:"_knsResolver",type:"address",internalType:"contract KNSRegistryResolver"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"isApprovedForAll",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"operator",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"knsResolver",inputs:[],outputs:[{name:"",type:"address",internalType:"contract KNSRegistryResolver"}],stateMutability:"view"},{type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"ownerOf",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"registerApp",inputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherName",type:"bytes",internalType:"bytes"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setApprovalForAll",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"approved",type:"bool",internalType:"bool"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"supportsInterface",inputs:[{name:"interfaceId",type:"bytes4",internalType:"bytes4"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"tokenURI",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"transferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"unlistPacakge",inputs:[{name:"package",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateContractURI",inputs:[{name:"uri",type:"string",internalType:"string"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateMetadata",inputs:[{name:"package",type:"uint256",internalType:"uint256"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"upgradeToAndCall",inputs:[{name:"newImplementation",type:"address",internalType:"address"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"event",name:"AppMetadataUpdated",inputs:[{name:"package",type:"uint256",indexed:!0,internalType:"uint256"},{name:"metadataUrl",type:"string",indexed:!1,internalType:"string"},{name:"metadataHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"AppRegistered",inputs:[{name:"package",type:"uint256",indexed:!0,internalType:"uint256"},{name:"packageName",type:"string",indexed:!1,internalType:"string"},{name:"publisherName",type:"bytes",indexed:!1,internalType:"bytes"},{name:"metadataUrl",type:"string",indexed:!1,internalType:"string"},{name:"metadataHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"Approval",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"ApprovalForAll",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"operator",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"version",type:"uint64",indexed:!1,internalType:"uint64"}],anonymous:!1},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Transfer",inputs:[{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Upgraded",inputs:[{name:"implementation",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressEmptyCode",inputs:[{name:"target",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ERC721IncorrectOwner",inputs:[{name:"sender",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InsufficientApproval",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ERC721InvalidApprover",inputs:[{name:"approver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOperator",inputs:[{name:"operator",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidReceiver",inputs:[{name:"receiver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidSender",inputs:[{name:"sender",type:"address",internalType:"address"}]},{type:"error",name:"ERC721NonexistentToken",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"FailedInnerCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"Unauthorized",inputs:[]}];class u2{static createInterface(){return new jh(vf)}static connect(e,r){return new X_(e,vf,r)}}o0(u2,"abi",vf);var c2={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Bm=Wr.createContext&&Wr.createContext(c2),s6=["attr","size","title"];function o6(t,e){if(t==null)return{};var r=a6(t,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function a6(t,e){if(t==null)return{};var r={},n=Object.keys(t),i,s;for(s=0;s=0)&&(r[i]=t[i]);return r}function mu(){return mu=Object.assign?Object.assign.bind():function(t){for(var e=1;eWr.createElement(e.tag,gu({key:r},e.attr),f2(e.child)))}function Pt(t){return e=>Wr.createElement(f6,mu({attr:gu({},t.attr)},e),f2(t.child))}function f6(t){var e=r=>{var{attr:n,size:i,title:s}=t,o=o6(t,s6),a=i||r.size||"1em",l;return r.className&&(l=r.className),t.className&&(l=(l?l+" ":"")+t.className),Wr.createElement("svg",mu({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,n,o,{className:l,style:gu(gu({color:t.color||r.color},r.style),t.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&Wr.createElement("title",null,s),t.children)};return Bm!==void 0?Wr.createElement(Bm.Consumer,null,r=>e(r)):e(c2)}function h6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"},child:[]}]})(t)}function d6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"},child:[]}]})(t)}function p6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z"},child:[]}]})(t)}function h2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"},child:[]}]})(t)}function m6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(t)}var g6={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Fm=t=>{let e;const r=new Set,n=(l,u)=>{const c=typeof l=="function"?l(e):l;if(!Object.is(c,e)){const h=e;e=u??(typeof c!="object"||c===null)?c:Object.assign({},e,c),r.forEach(p=>p(e,h))}},i=()=>e,a={setState:n,getState:i,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{(g6?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,i,a),a},v6=t=>t?Fm(t):Fm;var d2={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:y6}=Wr,{useSyncExternalStoreWithSelector:w6}=Qu;let Um=!1;function x6(t,e=t.getState,r){(d2?"production":void 0)!=="production"&&r&&!Um&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Um=!0);const n=w6(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return y6(n),n}const zm=t=>{(d2?"production":void 0)!=="production"&&typeof t!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof t=="function"?v6(t):t,r=(n,i)=>x6(e,n,i);return Object.assign(r,e),r},b6=t=>t?zm(t):zm;var E6={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};function p2(t,e){let r;try{r=t()}catch{return}return{getItem:i=>{var s;const o=l=>l===null?null:JSON.parse(l,e==null?void 0:e.reviver),a=(s=r.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>r.setItem(i,JSON.stringify(s,e==null?void 0:e.replacer)),removeItem:i=>r.removeItem(i)}}const va=t=>e=>{try{const r=t(e);return r instanceof Promise?r:{then(n){return va(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return va(n)(r)}}}},A6=(t,e)=>(r,n,i)=>{let s={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:k=>k,version:0,merge:(k,x)=>({...x,...k}),...e},o=!1;const a=new Set,l=new Set;let u;try{u=s.getStorage()}catch{}if(!u)return t((...k)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...k)},n,i);const c=va(s.serialize),h=()=>{const k=s.partialize({...n()});let x;const w=c({state:k,version:s.version}).then(A=>u.setItem(s.name,A)).catch(A=>{x=A});if(x)throw x;return w},p=i.setState;i.setState=(k,x)=>{p(k,x),h()};const m=t((...k)=>{r(...k),h()},n,i);let v;const b=()=>{var k;if(!u)return;o=!1,a.forEach(w=>w(n()));const x=((k=s.onRehydrateStorage)==null?void 0:k.call(s,n()))||void 0;return va(u.getItem.bind(u))(s.name).then(w=>{if(w)return s.deserialize(w)}).then(w=>{if(w)if(typeof w.version=="number"&&w.version!==s.version){if(s.migrate)return s.migrate(w.state,w.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return w.state}).then(w=>{var A;return v=s.merge(w,(A=n())!=null?A:m),r(v,!0),h()}).then(()=>{x==null||x(v,void 0),o=!0,l.forEach(w=>w(v))}).catch(w=>{x==null||x(void 0,w)})};return i.persist={setOptions:k=>{s={...s,...k},k.getStorage&&(u=k.getStorage())},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>b(),hasHydrated:()=>o,onHydrate:k=>(a.add(k),()=>{a.delete(k)}),onFinishHydration:k=>(l.add(k),()=>{l.delete(k)})},b(),v||m},_6=(t,e)=>(r,n,i)=>{let s={storage:p2(()=>localStorage),partialize:b=>b,version:0,merge:(b,k)=>({...k,...b}),...e},o=!1;const a=new Set,l=new Set;let u=s.storage;if(!u)return t((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...b)},n,i);const c=()=>{const b=s.partialize({...n()});return u.setItem(s.name,{state:b,version:s.version})},h=i.setState;i.setState=(b,k)=>{h(b,k),c()};const p=t((...b)=>{r(...b),c()},n,i);let m;const v=()=>{var b,k;if(!u)return;o=!1,a.forEach(w=>{var A;return w((A=n())!=null?A:p)});const x=((k=s.onRehydrateStorage)==null?void 0:k.call(s,(b=n())!=null?b:p))||void 0;return va(u.getItem.bind(u))(s.name).then(w=>{if(w)if(typeof w.version=="number"&&w.version!==s.version){if(s.migrate)return s.migrate(w.state,w.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return w.state}).then(w=>{var A;return m=s.merge(w,(A=n())!=null?A:p),r(m,!0),c()}).then(()=>{x==null||x(m,void 0),m=n(),o=!0,l.forEach(w=>w(m))}).catch(w=>{x==null||x(void 0,w)})};return i.persist={setOptions:b=>{s={...s,...b},b.storage&&(u=b.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>v(),hasHydrated:()=>o,onHydrate:b=>(a.add(b),()=>{a.delete(b)}),onFinishHydration:b=>(l.add(b),()=>{l.delete(b)})},s.skipHydration||v(),m||p},S6=(t,e)=>"getStorage"in e||"serialize"in e||"deserialize"in e?((E6?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),A6(t,e)):_6(t,e),k6=S6;var kr=(t=>(t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.FOUND=302]="FOUND",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t))(kr||{});const Ee=t=>`${t.package}:${t.publisher}`,Js=t=>{var e;return((e=t.metadata)==null?void 0:e.name)||Ee(t)},yf=t=>{var e,r;return t.publisher==="sys"?"system":(e=t.state)!=null&&e.our_version&&!((r=t.state)!=null&&r.caps_approved)?"downloaded":t.metadata?"installed":"local"},er="/main:app_store:sys",cl=(t,e)=>t.package===e.package&&t.publisher===e.publisher,Pi=b6()(k6((t,e)=>({myApps:{downloaded:[],installed:[],local:[],system:[]},listedApps:[],searchResults:[],query:"",getMyApps:async()=>{const r=await e().getListedApps(),s=(await(await fetch(`${er}/apps`)).json()).reduce((o,a)=>{const l=yf(a);return r.find(u=>u.metadata_hash===a.metadata_hash)&&console.log({listedappmatch:a}),o[l].push(a),o},{downloaded:[],installed:[],local:[],system:[]});return t(()=>({myApps:s})),s},getListedApps:async()=>{const n=await(await fetch(`${er}/apps/listed`)).json();return t({listedApps:n}),n},getMyApp:async r=>{const i=await(await fetch(`${er}/apps/${Ee(r)}`)).json(),s=yf(i),o=e().myApps;o[s]=o[s].map(l=>cl(l,i)?i:l);const a=[...e().listedApps].map(l=>cl(l,i)?i:l);return t({myApps:o,listedApps:a}),i},installApp:async r=>{if((await fetch(`${er}/apps/${Ee(r)}/caps`,{method:"POST"})).status!==kr.OK)throw new Error(`Failed to approve caps for app: ${Ee(r)}`);if((await fetch(`${er}/apps/${Ee(r)}`,{method:"POST"})).status!==kr.CREATED)throw new Error(`Failed to install app: ${Ee(r)}`)},updateApp:async r=>{if((await fetch(`${er}/apps/${Ee(r)}`,{method:"PUT"})).status!==kr.NO_CONTENT)throw new Error(`Failed to update app: ${Ee(r)}`)},uninstallApp:async r=>{if(!confirm(`Are you sure you want to remove ${Ee(r)}?`))return;if((await fetch(`${er}/apps/${Ee(r)}`,{method:"DELETE"})).status!==kr.NO_CONTENT)throw new Error(`Failed to remove app: ${Ee(r)}`);const i={...e().myApps},s=yf(r);i[s]=i[s].filter(a=>!cl(a,r));const o=e().listedApps.map(a=>cl(a,r)?{...a,state:void 0,installed:!1}:a);t({myApps:i,listedApps:o})},getListedApp:async r=>{const n=await fetch(`${er}/apps/listed/${r}`);if(n.status!==kr.OK)throw new Error(`Failed to get app: ${r}`);return await n.json()},downloadApp:async(r,n)=>{if((await fetch(`${er}/apps/listed/${Ee(r)}`,{method:"POST",body:JSON.stringify({download_from:n})})).status!==kr.CREATED)throw new Error(`Failed to get app: ${Ee(r)}`)},getCaps:async r=>{const n=await fetch(`${er}/apps/${Ee(r)}/caps`);if(n.status!==kr.OK)throw new Error(`Failed to get app: ${Ee(r)}`);return(await n.json())[0]},approveCaps:async r=>{if((await fetch(`${er}/apps/${Ee(r)}/caps`,{method:"POST"})).status!==kr.OK)throw new Error(`Failed to get app: ${Ee(r)}`)},rebuildIndex:async()=>{if((await fetch(`${er}/apps/rebuild-index`,{method:"POST"})).status!==kr.OK)throw new Error("Failed to rebuild index")},setMirroring:async(r,n)=>{if((await fetch(`${er}/apps/${Ee(r)}/mirror`,{method:n?"PUT":"DELETE"})).status!==kr.OK)throw new Error(`Failed to start mirror: ${Ee(r)}`);e().getMyApp(r)},setAutoUpdate:async(r,n)=>{if((await fetch(`${er}/apps/${Ee(r)}/auto-update`,{method:n?"PUT":"DELETE"})).status!==kr.OK)throw new Error(`Failed to change auto update: ${Ee(r)}`);e().getMyApp(r)},get:e,set:t}),{name:"app_store",storage:p2(()=>sessionStorage)}));var m2={exports:{}};/*! + */var Ku=L,z3=U3;function $3(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var H3=typeof Object.is=="function"?Object.is:$3,V3=z3.useSyncExternalStore,q3=Ku.useRef,G3=Ku.useEffect,W3=Ku.useMemo,K3=Ku.useDebugValue;j1.useSyncExternalStoreWithSelector=function(t,e,r,n,i){var s=q3(null);if(s.current===null){var o={hasValue:!1,value:null};s.current=o}else o=s.current;s=W3(function(){function l(m){if(!u){if(u=!0,c=m,m=n(m),i!==void 0&&o.hasValue){var v=o.value;if(i(v,m))return h=v}return h=m}if(v=h,H3(c,m))return v;var b=n(m);return i!==void 0&&i(v,b)?v:(c=m,h=b)}var u=!1,c,h,p=r===void 0?null:r;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,r,n,i]);var a=V3(t,s[0],s[1]);return G3(function(){o.hasValue=!0,o.value=a},[a]),K3(a),a};T1.exports=j1;var Q3=T1.exports;const Qu=Si(Q3),{useSyncExternalStoreWithSelector:J3}=Qu;function D1(t,e=t.getState,r){const n=J3(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return L.useDebugValue(n),n}const Dp=t=>{const e=typeof t=="function"?O1(t):t,r=(n,i)=>D1(e,n,i);return Object.assign(r,e),r},F1=t=>t?Dp(t):Dp;var Y3=t=>F1(t);const X3=Object.freeze(Object.defineProperty({__proto__:null,create:F1,createStore:O1,default:Y3,useStore:D1},Symbol.toStringTag,{value:"Module"})),Z3=Ys(X3);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createWeb3ReactStoreAndActions=t.MAX_SAFE_CHAIN_ID=void 0;const e=C3,r=Z3;t.MAX_SAFE_CHAIN_ID=0xfffffffffffec;function n(a){if(!Number.isInteger(a)||a<=0||a>t.MAX_SAFE_CHAIN_ID)throw new Error(`Invalid chainId ${a}`)}function i(a){return(0,e.getAddress)(a)}const s={chainId:void 0,accounts:void 0,activating:!1};function o(){const a=(0,r.createStore)()(()=>s);let l=0;function u(){const p=++l;return a.setState(Object.assign(Object.assign({},s),{activating:!0})),()=>{l===p&&a.setState({activating:!1})}}function c(p){if(p.chainId!==void 0&&n(p.chainId),p.accounts!==void 0)for(let m=0;m{var v,b;const k=(v=p.chainId)!==null&&v!==void 0?v:m.chainId,x=(b=p.accounts)!==null&&b!==void 0?b:m.accounts;let w=m.activating;return w&&k&&x&&(w=!1),{chainId:k,accounts:x,activating:w}})}function h(){l++,a.setState(s)}return[a,{startActivation:u,update:c,resetState:h}]}t.createWeb3ReactStoreAndActions=o})(N1);var eE={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Fp=t=>{let e;const r=new Set,n=(l,u)=>{const c=typeof l=="function"?l(e):l;if(!Object.is(c,e)){const h=e;e=u??typeof c!="object"?c:Object.assign({},e,c),r.forEach(p=>p(e,h))}},i=()=>e,a={setState:n,getState:i,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{(eE?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,i,a),a},Vd=t=>t?Fp(t):Fp,{useSyncExternalStoreWithSelector:tE}=Qu;function U1(t,e=t.getState,r){const n=tE(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return L.useDebugValue(n),n}const Up=t=>{const e=typeof t=="function"?Vd(t):t,r=(n,i)=>U1(e,n,i);return Object.assign(r,e),r},z1=t=>t?Up(t):Up;var rE=t=>z1(t);const nE=Object.freeze(Object.defineProperty({__proto__:null,create:z1,createStore:Vd,default:rE,useStore:U1},Symbol.toStringTag,{value:"Module"})),iE=Ys(nE),{useSyncExternalStoreWithSelector:sE}=Qu;function $1(t,e=t.getState,r){const n=sE(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return L.useDebugValue(n),n}const zp=(t,e)=>{const r=Vd(t),n=(i,s=e)=>$1(r,i,s);return Object.assign(n,r),n},oE=(t,e)=>t?zp(t,e):zp,aE=Object.freeze(Object.defineProperty({__proto__:null,createWithEqualityFn:oE,useStoreWithEqualityFn:$1},Symbol.toStringTag,{value:"Module"})),lE=Ys(aE),uE="properties/5.7.0";var cE=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const su=new j(uE);function H(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function mr(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||typeof t.prototype!="object")break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function xt(t){return cE(this,void 0,void 0,function*(){const e=Object.keys(t).map(n=>{const i=t[n];return Promise.resolve(i).then(s=>({key:n,value:s}))});return(yield Promise.all(e)).reduce((n,i)=>(n[i.key]=i.value,n),{})})}function fE(t,e){(!t||typeof t!="object")&&su.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||su.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function at(t){const e={};for(const r in t)e[r]=t[r];return e}const hE={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function H1(t){if(t==null||hE[typeof t])return!0;if(Array.isArray(t)||typeof t=="object"){if(!Object.isFrozen(t))return!1;const e=Object.keys(t);for(let r=0;rlr(e)));if(typeof t=="object"){const e={};for(const r in t){const n=t[r];n!==void 0&&H(e,r,lr(n))}return e}return su.throwArgumentError(`Cannot deepCopy ${typeof t}`,"object",t)}function lr(t){return dE(t)}class Ca{constructor(e){for(const r in e)this[r]=lr(e[r])}}const pE="abstract-provider/5.7.0";var mE=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const gE=new j(pE);class vE extends Ca{static isForkEvent(e){return!!(e&&e._isForkEvent)}}class ro{constructor(){gE.checkAbstract(new.target,ro),H(this,"_isProvider",!0)}getFeeData(){return mE(this,void 0,void 0,function*(){const{block:e,gasPrice:r}=yield xt({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(o=>null)});let n=null,i=null,s=null;return e&&e.baseFeePerGas&&(n=e.baseFeePerGas,s=K.from("1500000000"),i=e.baseFeePerGas.mul(2).add(s)),{lastBaseFeePerGas:n,maxFeePerGas:i,maxPriorityFeePerGas:s,gasPrice:r}})}addListener(e,r){return this.on(e,r)}removeListener(e,r){return this.off(e,r)}static isProvider(e){return!!(e&&e._isProvider)}}const yE="networks/5.7.1",$p=new j(yE);function wE(t){return t&&typeof t.renetwork=="function"}function Cn(t){const e=function(r,n){n==null&&(n={});const i=[];if(r.InfuraProvider&&n.infura!=="-")try{i.push(new r.InfuraProvider(t,n.infura))}catch{}if(r.EtherscanProvider&&n.etherscan!=="-")try{i.push(new r.EtherscanProvider(t,n.etherscan))}catch{}if(r.AlchemyProvider&&n.alchemy!=="-")try{i.push(new r.AlchemyProvider(t,n.alchemy))}catch{}if(r.PocketProvider&&n.pocket!=="-"){const s=["goerli","ropsten","rinkeby","sepolia"];try{const o=new r.PocketProvider(t,n.pocket);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}}if(r.CloudflareProvider&&n.cloudflare!=="-")try{i.push(new r.CloudflareProvider(t))}catch{}if(r.AnkrProvider&&n.ankr!=="-")try{const s=["ropsten"],o=new r.AnkrProvider(t,n.ankr);o.network&&s.indexOf(o.network.name)===-1&&i.push(o)}catch{}if(i.length===0)return null;if(r.FallbackProvider){let s=1;return n.quorum!=null?s=n.quorum:t==="homestead"&&(s=2),new r.FallbackProvider(i,s)}return i[0]};return e.renetwork=function(r){return Cn(r)},e}function ou(t,e){const r=function(n,i){return n.JsonRpcProvider?new n.JsonRpcProvider(t,e):null};return r.renetwork=function(n){return ou(t,n)},r}const Hp={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:Cn("homestead")},Vp={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:Cn("ropsten")},qp={chainId:63,name:"classicMordor",_defaultProvider:ou("https://www.ethercluster.com/mordor","classicMordor")},Za={unspecified:{chainId:0,name:"unspecified"},homestead:Hp,mainnet:Hp,morden:{chainId:2,name:"morden"},ropsten:Vp,testnet:Vp,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:Cn("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:Cn("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:Cn("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:Cn("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:ou("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:qp,classicTestnet:qp,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:ou("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:Cn("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:Cn("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function qd(t){if(t==null)return null;if(typeof t=="number"){for(const n in Za){const i=Za[n];if(i.chainId===t)return{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress||null,_defaultProvider:i._defaultProvider||null}}return{chainId:t,name:"unknown"}}if(typeof t=="string"){const n=Za[t];return n==null?null:{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress,_defaultProvider:n._defaultProvider||null}}const e=Za[t.name];if(!e)return typeof t.chainId!="number"&&$p.throwArgumentError("invalid network chainId","network",t),t;t.chainId!==0&&t.chainId!==e.chainId&&$p.throwArgumentError("network chainId mismatch","network",t);let r=t._defaultProvider||null;return r==null&&e._defaultProvider&&(wE(e._defaultProvider)?r=e._defaultProvider.renetwork(t):r=e._defaultProvider),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:r}}function V1(t){t=atob(t);const e=[];for(let r=0;r0;)n.push(o%this.base),o=o/this.base|0}let i="";for(let s=0;r[s]===0&&s=0;--s)i+=this.alphabet[n[s]];return i}decode(e){if(typeof e!="string")throw new TypeError("Expected String");let r=[];if(e.length===0)return new Uint8Array(r);r.push(0);for(let n=0;n>=8;for(;s>0;)r.push(s&255),s>>=8}for(let n=0;e[n]===this._leader&&n>6===2;o++)s++;return s}return t===hr.OVERRUN?r.length-e-1:0}function NE(t,e,r,n,i){return t===hr.OVERLONG?(n.push(i),0):(n.push(65533),Q1(t,e,r))}const ME=Object.freeze({error:kE,ignore:Q1,replace:NE});function J1(t,e){e==null&&(e=ME.error),t=oe(t);const r=[];let n=0;for(;n>7)){r.push(i);continue}let s=null,o=null;if((i&224)===192)s=1,o=127;else if((i&240)===224)s=2,o=2047;else if((i&248)===240)s=3,o=65535;else{(i&192)===128?n+=e(hr.UNEXPECTED_CONTINUE,n-1,t,r):n+=e(hr.BAD_PREFIX,n-1,t,r);continue}if(n-1+s>=t.length){n+=e(hr.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-s-1)-1;for(let l=0;l1114111){n+=e(hr.OUT_OF_RANGE,n-1-s,t,r,a);continue}if(a>=55296&&a<=57343){n+=e(hr.UTF16_SURROGATE,n-1-s,t,r,a);continue}if(a<=o){n+=e(hr.OVERLONG,n-1-s,t,r,a);continue}r.push(a)}}return r}function yr(t,e=fa.current){e!=fa.current&&(K1.checkNormalize(),t=t.normalize(e));let r=[];for(let n=0;n>6|192),r.push(i&63|128);else if((i&64512)==55296){n++;const s=t.charCodeAt(n);if(n>=t.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((i&1023)<<10)+(s&1023);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(o&63|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128)}return oe(r)}function CE(t){return t.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Pa(t,e){return CE(J1(t,e))}function PE(t,e=fa.current){return J1(yr(t,e))}function Es(t){return ot(yr(t))}const Y1="hash/5.7.0";function X1(t,e){e==null&&(e=1);const r=[],n=r.forEach,i=function(s,o){n.call(s,function(a){o>0&&Array.isArray(a)?i(a,o-1):r.push(a)})};return i(t,e),r}function RE(t){const e={};for(let r=0;r>--l&1}const h=31,p=Math.pow(2,h),m=p>>>1,v=m>>1,b=p-1;let k=0;for(let I=0;I1;){let G=B+F>>>1;I>>1|c(),$=$<<1^m,V=(V^m)<<1|m|1;w=$,A=1+V-$}let T=n-4;return x.map(I=>{switch(I-T){case 3:return T+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return T+256+(t[a++]<<8|t[a++]);case 1:return T+t[a++];default:return I-1}})}function OE(t){let e=0;return()=>t[e++]}function TE(t){return OE(IE(t))}function jE(t){return t&1?~t>>1:t>>1}function LE(t,e){let r=Array(t);for(let n=0;ne[o]):r}function DE(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(UE(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(zE(r,t))}return RE(X1(e))}function FE(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(r)}return e}function Z1(t,e,r){let n=Array(t).fill(void 0).map(()=>[]);for(let i=0;in[o].push(s));return n}function UE(t,e){let r=1+e(),n=e(),i=FE(e),s=Z1(i.length,1+t,e);return X1(s.map((o,a)=>{const l=o[0],u=o.slice(1);return Array(i[a]).fill(void 0).map((c,h)=>{let p=h*n;return[l+h*r,u.map(m=>m+p)]})}))}function zE(t,e){let r=1+e();return Z1(r,1+t,e).map(i=>[i[0],i.slice(1)])}function $E(t){let e=au(t).sort((n,i)=>n-i);return r();function r(){let n=[];for(;;){let u=au(t,e);if(u.length==0)break;n.push({set:new Set(u),node:r()})}n.sort((u,c)=>c.set.size-u.set.size);let i=t(),s=i%3;i=i/3|0;let o=!!(i&1);i>>=1;let a=i==1,l=i==2;return{branches:n,valid:s,fe0f:o,save:a,check:l}}}function HE(){return TE(V1("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"))}const Ju=HE(),VE=new Set(au(Ju)),qE=new Set(au(Ju)),GE=DE(Ju),WE=$E(Ju),Wp=45,Kp=95;function ey(t){return PE(t)}function KE(t){return t.filter(e=>e!=65039)}function ty(t){for(let e of t.split(".")){let r=ey(e);try{for(let n=r.lastIndexOf(Kp)-1;n>=0;n--)if(r[n]!==Kp)throw new Error("underscore only allowed at start");if(r.length>=4&&r.every(n=>n<128)&&r[2]===Wp&&r[3]===Wp)throw new Error("invalid label extension")}catch(n){throw new Error(`Invalid label "${e}": ${n.message}`)}}return t}function QE(t){return ty(JE(t,KE))}function JE(t,e){let r=ey(t).reverse(),n=[];for(;r.length;){let i=XE(r);if(i){n.push(...e(i));continue}let s=r.pop();if(VE.has(s)){n.push(s);continue}if(qE.has(s))continue;let o=GE[s];if(o){n.push(...o);continue}throw new Error(`Disallowed codepoint: 0x${s.toString(16).toUpperCase()}`)}return ty(YE(String.fromCodePoint(...n)))}function YE(t){return t.normalize("NFC")}function XE(t,e){var r;let n=WE,i,s,o=[],a=t.length;for(e&&(e.length=0);a;){let l=t[--a];if(n=(r=n.branches.find(u=>u.set.has(l)))===null||r===void 0?void 0:r.node,!n)break;if(n.save)s=l;else if(n.check&&l===s)break;o.push(l),n.fe0f&&(o.push(65039),a>0&&t[a-1]==65039&&a--),n.valid&&(i=o.slice(),n.valid==2&&i.splice(1,1),e&&e.push(...t.slice(a).reverse()),t.length=a)}return i}const ZE=new j(Y1),ry=new Uint8Array(32);ry.fill(0);function Qp(t){if(t.length===0)throw new Error("invalid ENS name; empty component");return t}function ny(t){const e=yr(QE(t)),r=[];if(t.length===0)return r;let n=0;for(let i=0;i=e.length)throw new Error("invalid ENS name; empty component");return r.push(Qp(e.slice(n))),r}function kl(t){typeof t!="string"&&ZE.throwArgumentError("invalid ENS name; not a string","name",t);let e=ry;const r=ny(t);for(;r.length;)e=ot($t([e,ot(r.pop())]));return ne(e)}function e5(t){return ne($t(ny(t).map(e=>{if(e.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const r=new Uint8Array(e.length+1);return r.set(e,1),r[0]=r.length-1,r})))+"00"}var t5=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const ct=new j(Y1),iy=new Uint8Array(32);iy.fill(0);const r5=K.from(-1),sy=K.from(0),oy=K.from(1),n5=K.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function i5(t){const e=oe(t),r=e.length%32;return r?nr([e,iy.slice(r)]):ne(e)}const s5=gt(oy.toHexString(),32),o5=gt(sy.toHexString(),32),Jp={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},ef=["name","version","chainId","verifyingContract","salt"];function Yp(t){return function(e){return typeof e!="string"&&ct.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const a5={name:Yp("name"),version:Yp("version"),chainId:function(t){try{return K.from(t).toString()}catch{}return ct.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return vt(t).toLowerCase()}catch{}return ct.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=oe(t);if(e.length!==32)throw new Error("bad length");return ne(e)}catch{}return ct.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function tf(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=e[1]==="",n=parseInt(e[2]||"256");(n%8!==0||n>256||e[2]&&e[2]!==String(n))&&ct.throwArgumentError("invalid numeric width","type",t);const i=n5.mask(r?n-1:n),s=r?i.add(oy).mul(r5):sy;return function(o){const a=K.from(o);return(a.lt(s)||a.gt(i))&&ct.throwArgumentError(`value out-of-bounds for ${t}`,"value",o),gt(a.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(r===0||r>32||e[1]!==String(r))&&ct.throwArgumentError("invalid bytes width","type",t),function(n){return oe(n).length!==r&&ct.throwArgumentError(`invalid length for ${t}`,"value",n),i5(n)}}}switch(t){case"address":return function(e){return gt(vt(e),32)};case"bool":return function(e){return e?s5:o5};case"bytes":return function(e){return ot(e)};case"string":return function(e){return Es(e)}}return null}function Xp(t,e){return`${t}(${e.map(({name:r,type:n})=>n+" "+r).join(",")})`}class cr{constructor(e){H(this,"types",Object.freeze(lr(e))),H(this,"_encoderCache",{}),H(this,"_types",{});const r={},n={},i={};Object.keys(e).forEach(a=>{r[a]={},n[a]=[],i[a]={}});for(const a in e){const l={};e[a].forEach(u=>{l[u.name]&&ct.throwArgumentError(`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(a)}`,"types",e),l[u.name]=!0;const c=u.type.match(/^([^\x5b]*)(\x5b|$)/)[1];c===a&&ct.throwArgumentError(`circular type reference to ${JSON.stringify(c)}`,"types",e),!tf(c)&&(n[c]||ct.throwArgumentError(`unknown type ${JSON.stringify(c)}`,"types",e),n[c].push(a),r[a][c]=!0)})}const s=Object.keys(n).filter(a=>n[a].length===0);s.length===0?ct.throwArgumentError("missing primary type","types",e):s.length>1&&ct.throwArgumentError(`ambiguous primary types or unused types: ${s.map(a=>JSON.stringify(a)).join(", ")}`,"types",e),H(this,"primaryType",s[0]);function o(a,l){l[a]&&ct.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",e),l[a]=!0,Object.keys(r[a]).forEach(u=>{n[u]&&(o(u,l),Object.keys(l).forEach(c=>{i[c][u]=!0}))}),delete l[a]}o(this.primaryType,{});for(const a in i){const l=Object.keys(i[a]);l.sort(),this._types[a]=Xp(a,e[a])+l.map(u=>Xp(u,e[u])).join("")}}getEncoder(e){let r=this._encoderCache[e];return r||(r=this._encoderCache[e]=this._getEncoder(e)),r}_getEncoder(e){{const i=tf(e);if(i)return i}const r=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(r){const i=r[1],s=this.getEncoder(i),o=parseInt(r[3]);return a=>{o>=0&&a.length!==o&&ct.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",a);let l=a.map(s);return this._types[i]&&(l=l.map(ot)),ot(nr(l))}}const n=this.types[e];if(n){const i=Es(this._types[e]);return s=>{const o=n.map(({name:a,type:l})=>{const u=this.getEncoder(l)(s[a]);return this._types[l]?ot(u):u});return o.unshift(i),nr(o)}}return ct.throwArgumentError(`unknown type: ${e}`,"type",e)}encodeType(e){const r=this._types[e];return r||ct.throwArgumentError(`unknown type: ${JSON.stringify(e)}`,"name",e),r}encodeData(e,r){return this.getEncoder(e)(r)}hashStruct(e,r){return ot(this.encodeData(e,r))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,r,n){if(tf(e))return n(e,r);const i=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const o=i[1],a=parseInt(i[3]);return a>=0&&r.length!==a&&ct.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",r),r.map(l=>this._visit(o,l,n))}const s=this.types[e];return s?s.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,r[a],n),o),{}):ct.throwArgumentError(`unknown type: ${e}`,"type",e)}visit(e,r){return this._visit(this.primaryType,e,r)}static from(e){return new cr(e)}static getPrimaryType(e){return cr.from(e).primaryType}static hashStruct(e,r,n){return cr.from(r).hashStruct(e,n)}static hashDomain(e){const r=[];for(const n in e){const i=Jp[n];i||ct.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),r.push({name:n,type:i})}return r.sort((n,i)=>ef.indexOf(n.name)-ef.indexOf(i.name)),cr.hashStruct("EIP712Domain",{EIP712Domain:r},e)}static encode(e,r,n){return nr(["0x1901",cr.hashDomain(e),cr.from(r).hash(n)])}static hash(e,r,n){return ot(cr.encode(e,r,n))}static resolveNames(e,r,n,i){return t5(this,void 0,void 0,function*(){e=at(e);const s={};e.verifyingContract&&!me(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const o=cr.from(r);o.visit(n,(a,l)=>(a==="address"&&!me(l,20)&&(s[l]="0x"),l));for(const a in s)s[a]=yield i(a);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),n=o.visit(n,(a,l)=>a==="address"&&s[l]?s[l]:l),{domain:e,value:n}})}static getPayload(e,r,n){cr.hashDomain(e);const i={},s=[];ef.forEach(l=>{const u=e[l];u!=null&&(i[l]=a5[l](u),s.push({name:l,type:Jp[l]}))});const o=cr.from(r),a=at(r);return a.EIP712Domain?ct.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",r):a.EIP712Domain=s,o.encode(n),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(n,(l,u)=>{if(l.match(/^bytes(\d*)/))return ne(oe(u));if(l.match(/^u?int/))return K.from(u).toString();switch(l){case"address":return u.toLowerCase();case"bool":return!!u;case"string":return typeof u!="string"&&ct.throwArgumentError("invalid string","value",u),u}return ct.throwArgumentError("unsupported type","type",l)})}}}var ay={},xe={},Ra=ly;function ly(t,e){if(!t)throw new Error(e||"Assertion failed")}ly.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)};var _h={exports:{}};typeof Object.create=="function"?_h.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:_h.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}};var l5=_h.exports,u5=Ra,c5=l5;xe.inherits=c5;function f5(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function h5(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),i=0;i>6|192,r[n++]=s&63|128):f5(t,i)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++i)&1023),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=s&63|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=s&63|128)}else for(i=0;i>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}xe.htonl=uy;function p5(t,e){for(var r="",n=0;n>>0}return s}xe.join32=m5;function g5(t,e){for(var r=new Array(t.length*4),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=s&255):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=s&255)}return r}xe.split32=g5;function v5(t,e){return t>>>e|t<<32-e}xe.rotr32=v5;function y5(t,e){return t<>>32-e}xe.rotl32=y5;function w5(t,e){return t+e>>>0}xe.sum32=w5;function x5(t,e,r){return t+e+r>>>0}xe.sum32_3=x5;function b5(t,e,r,n){return t+e+r+n>>>0}xe.sum32_4=b5;function E5(t,e,r,n,i){return t+e+r+n+i>>>0}xe.sum32_5=E5;function A5(t,e,r,n){var i=t[e],s=t[e+1],o=n+s>>>0,a=(o>>0,t[e+1]=o}xe.sum64=A5;function _5(t,e,r,n){var i=e+n>>>0,s=(i>>0}xe.sum64_hi=_5;function S5(t,e,r,n){var i=e+n;return i>>>0}xe.sum64_lo=S5;function k5(t,e,r,n,i,s,o,a){var l=0,u=e;u=u+n>>>0,l+=u>>0,l+=u>>0,l+=u>>0}xe.sum64_4_hi=k5;function N5(t,e,r,n,i,s,o,a){var l=e+n+s+a;return l>>>0}xe.sum64_4_lo=N5;function M5(t,e,r,n,i,s,o,a,l,u){var c=0,h=e;h=h+n>>>0,c+=h>>0,c+=h>>0,c+=h>>0,c+=h>>0}xe.sum64_5_hi=M5;function C5(t,e,r,n,i,s,o,a,l,u){var c=e+n+s+a+u;return c>>>0}xe.sum64_5_lo=C5;function P5(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}xe.rotr64_hi=P5;function R5(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}xe.rotr64_lo=R5;function I5(t,e,r){return t>>>r}xe.shr64_hi=I5;function O5(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}xe.shr64_lo=O5;var no={},Zp=xe,T5=Ra;function Yu(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}no.BlockHash=Yu;Yu.prototype.update=function(e,r){if(e=Zp.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=Zp.join32(e,0,e.length-n,this.endian);for(var i=0;i>>24&255,i[s++]=e>>>16&255,i[s++]=e>>>8&255,i[s++]=e&255}else for(i[s++]=e&255,i[s++]=e>>>8&255,i[s++]=e>>>16&255,i[s++]=e>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,o=8;o>>3}bn.g0_256=F5;function U5(t){return dn(t,17)^dn(t,19)^t>>>10}bn.g1_256=U5;var Gs=xe,z5=no,$5=bn,rf=Gs.rotl32,go=Gs.sum32,H5=Gs.sum32_5,V5=$5.ft_1,my=z5.BlockHash,q5=[1518500249,1859775393,2400959708,3395469782];function yn(){if(!(this instanceof yn))return new yn;my.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Gs.inherits(yn,my);var G5=yn;yn.blockSize=512;yn.outSize=160;yn.hmacStrength=80;yn.padLength=64;yn.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;ithis.blockSize&&(e=new this.Hash().update(e).digest()),OA(e.length<=this.blockSize);for(var r=e.length;r{s[a.toLowerCase()]=o}):n.headers.keys().forEach(o=>{s[o.toLowerCase()]=n.headers.get(o)}),{headers:s,statusCode:n.status,statusMessage:n.statusText,body:oe(new Uint8Array(i))}})}var DA=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Ur=new j(jA);function im(t){return new Promise(e=>{setTimeout(e,t)})}function ni(t,e){if(t==null)return null;if(typeof t=="string")return t;if(Fd(t)){if(e&&(e.split("/")[0]==="text"||e.split(";")[0].trim()==="application/json"))try{return Pa(t)}catch{}return ne(t)}return t}function FA(t){return yr(t.replace(/%([0-9a-f][0-9a-f])/gi,(e,r)=>String.fromCharCode(parseInt(r,16))))}function UA(t,e,r){const n=typeof t=="object"&&t.throttleLimit!=null?t.throttleLimit:12;Ur.assertArgument(n>0&&n%1===0,"invalid connection throttle limit","connection.throttleLimit",n);const i=typeof t=="object"?t.throttleCallback:null,s=typeof t=="object"&&typeof t.throttleSlotInterval=="number"?t.throttleSlotInterval:100;Ur.assertArgument(s>0&&s%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",s);const o=typeof t=="object"?!!t.errorPassThrough:!1,a={};let l=null;const u={method:"GET"};let c=!1,h=2*60*1e3;if(typeof t=="string")l=t;else if(typeof t=="object"){if((t==null||t.url==null)&&Ur.throwArgumentError("missing URL","connection.url",t),l=t.url,typeof t.timeout=="number"&&t.timeout>0&&(h=t.timeout),t.headers)for(const x in t.headers)a[x.toLowerCase()]={key:x,value:String(t.headers[x])},["if-none-match","if-modified-since"].indexOf(x.toLowerCase())>=0&&(c=!0);if(u.allowGzip=!!t.allowGzip,t.user!=null&&t.password!=null){l.substring(0,6)!=="https:"&&t.allowInsecureAuthentication!==!0&&Ur.throwError("basic authentication requires a secure https url",j.errors.INVALID_ARGUMENT,{argument:"url",url:l,user:t.user,password:"[REDACTED]"});const x=t.user+":"+t.password;a.authorization={key:"Authorization",value:"Basic "+q1(yr(x))}}t.skipFetchSetup!=null&&(u.skipFetchSetup=!!t.skipFetchSetup),t.fetchOptions!=null&&(u.fetchOptions=at(t.fetchOptions))}const p=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),m=l?l.match(p):null;if(m)try{const x={statusCode:200,statusMessage:"OK",headers:{"content-type":m[1]||"text/plain"},body:m[2]?V1(m[3]):FA(m[3])};let w=x.body;return r&&(w=r(x.body,x)),Promise.resolve(w)}catch(x){Ur.throwError("processing response error",j.errors.SERVER_ERROR,{body:ni(m[1],m[2]),error:x,requestBody:null,requestMethod:"GET",url:l})}e&&(u.method="POST",u.body=e,a["content-type"]==null&&(a["content-type"]={key:"Content-Type",value:"application/octet-stream"}),a["content-length"]==null&&(a["content-length"]={key:"Content-Length",value:String(e.length)}));const v={};Object.keys(a).forEach(x=>{const w=a[x];v[w.key]=w.value}),u.headers=v;const b=function(){let x=null;return{promise:new Promise(function(T,I){h&&(x=setTimeout(()=>{x!=null&&(x=null,I(Ur.makeError("timeout",j.errors.TIMEOUT,{requestBody:ni(u.body,v["content-type"]),requestMethod:u.method,timeout:h,url:l})))},h))}),cancel:function(){x!=null&&(clearTimeout(x),x=null)}}}(),k=function(){return DA(this,void 0,void 0,function*(){for(let x=0;x=300)&&(b.cancel(),Ur.throwError("bad response",j.errors.SERVER_ERROR,{status:w.statusCode,headers:w.headers,body:ni(A,w.headers?w.headers["content-type"]:null),requestBody:ni(u.body,v["content-type"]),requestMethod:u.method,url:l})),r)try{const T=yield r(A,w);return b.cancel(),T}catch(T){if(T.throttleRetry&&x{let a=null;if(s!=null)try{a=JSON.parse(Pa(s))}catch(l){Ur.throwError("invalid JSON",j.errors.SERVER_ERROR,{body:s,error:l})}return r&&(a=r(a,o)),a},i=null;if(e!=null){i=yr(e);const s=typeof t=="string"?{url:t}:at(t);s.headers?Object.keys(s.headers).filter(a=>a.toLowerCase()==="content-type").length!==0||(s.headers=at(s.headers),s.headers["content-type"]="application/json"):s.headers={"content-type":"application/json"},t=s}return UA(t,i,n)}function As(t,e){return e||(e={}),e=at(e),e.floor==null&&(e.floor=0),e.ceiling==null&&(e.ceiling=1e4),e.interval==null&&(e.interval=250),new Promise(function(r,n){let i=null,s=!1;const o=()=>s?!1:(s=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{o()&&n(new Error("timeout"))},e.timeout));const a=e.retryLimit;let l=0;function u(){return t().then(function(c){if(c!==void 0)o()&&r(c);else if(e.oncePoll)e.oncePoll.once("poll",u);else if(e.onceBlock)e.onceBlock.once("block",u);else if(!s){if(l++,l>a){o()&&n(new Error("retry limit reached"));return}let h=e.interval*parseInt(String(Math.random()*Math.pow(2,l)));he.ceiling&&(h=e.ceiling),setTimeout(u,h)}return null},function(c){o()&&n(c)})}u()})}var lu="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Nh={};for(var tl=0;tl>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function ky(t){for(var e=1,r=0;r126)return"Invalid prefix ("+t+")";e=js(e)^n>>5}for(e=js(e),r=0;rr)throw new TypeError("Exceeds length limit");t=t.toLowerCase();var n=ky(t);if(typeof n=="string")throw new Error(n);for(var i=t+"1",s=0;s>5)throw new Error("Non 5-bit word");n=js(n)^o,i+=lu.charAt(o)}for(s=0;s<6;++s)n=js(n);for(n^=1,s=0;s<6;++s){var a=n>>(5-s)*5&31;i+=lu.charAt(a)}return i}function Ny(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";var r=t.toLowerCase(),n=t.toUpperCase();if(t!==r&&t!==n)return"Mixed-case string "+t;t=r;var i=t.lastIndexOf("1");if(i===-1)return"No separator character for "+t;if(i===0)return"Missing prefix for "+t;var s=t.slice(0,i),o=t.slice(i+1);if(o.length<6)return"Data too short";var a=ky(s);if(typeof a=="string")return a;for(var l=[],u=0;u=o.length)&&l.push(h)}return a!==1?"Invalid checksum for "+t:{prefix:s,words:l}}function $A(){var t=Ny.apply(null,arguments);if(typeof t=="object")return t}function HA(t){var e=Ny.apply(null,arguments);if(typeof e=="object")return e;throw new Error(e)}function Xu(t,e,r,n){for(var i=0,s=0,o=(1<=r;)s-=r,a.push(i>>s&o);if(n)s>0&&a.push(i<=e)return"Excess padding";if(i<>8,p=c&255;h?l.push(h,p):l.push(p)}return l}r.toArray=n;function i(o){return o.length===1?"0"+o:o}r.zero2=i;function s(o){for(var a="",l=0;l(p>>1)-1?b=(p>>1)-k:b=k,m.isubn(b)):b=0,h[v]=b,m.iushrn(1)}return h}r.getNAF=n;function i(l,u){var c=[[],[]];l=l.clone(),u=u.clone();for(var h=0,p=0,m;l.cmpn(-h)>0||u.cmpn(-p)>0;){var v=l.andln(3)+h&3,b=u.andln(3)+p&3;v===3&&(v=-1),b===3&&(b=-1);var k;v&1?(m=l.andln(7)+h&7,(m===3||m===5)&&b===2?k=-v:k=v):k=0,c[0].push(k);var x;b&1?(m=u.andln(7)+p&7,(m===3||m===5)&&v===2?x=-b:x=b):x=0,c[1].push(x),2*h===k+1&&(h=1-h),2*p===x+1&&(p=1-p),l.iushrn(1),u.iushrn(1)}return c}r.getJSF=i;function s(l,u,c){var h="_"+u;l.prototype[u]=function(){return this[h]!==void 0?this[h]:this[h]=c.call(this)}}r.cachedProperty=s;function o(l){return typeof l=="string"?r.toArray(l,"hex"):l}r.parseBytes=o;function a(l){return new ce(l,"hex","le")}r.intFromLE=a}),uu=br.getNAF,JA=br.getJSF,cu=br.assert;function Ci(t,e){this.type=t,this.p=new ce(e.p,16),this.red=e.prime?ce.red(e.prime):ce.mont(this.p),this.zero=new ce(0).toRed(this.red),this.one=new ce(1).toRed(this.red),this.two=new ce(2).toRed(this.red),this.n=e.n&&new ce(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var ts=Ci;Ci.prototype.point=function(){throw new Error("Not implemented")};Ci.prototype.validate=function(){throw new Error("Not implemented")};Ci.prototype._fixedNafMul=function(e,r){cu(e.precomputed);var n=e._getDoubles(),i=uu(r,1,this._bitLength),s=(1<=a;u--)l=(l<<1)+i[u];o.push(l)}for(var c=this.jpoint(null,null,null),h=this.jpoint(null,null,null),p=s;p>0;p--){for(a=0;a=0;l--){for(var u=0;l>=0&&o[l]===0;l--)u++;if(l>=0&&u++,a=a.dblp(u),l<0)break;var c=o[l];cu(c!==0),e.type==="affine"?c>0?a=a.mixedAdd(s[c-1>>1]):a=a.mixedAdd(s[-c-1>>1].neg()):c>0?a=a.add(s[c-1>>1]):a=a.add(s[-c-1>>1].neg())}return e.type==="affine"?a.toP():a};Ci.prototype._wnafMulAdd=function(e,r,n,i,s){var o=this._wnafT1,a=this._wnafT2,l=this._wnafT3,u=0,c,h,p;for(c=0;c=1;c-=2){var v=c-1,b=c;if(o[v]!==1||o[b]!==1){l[v]=uu(n[v],o[v],this._bitLength),l[b]=uu(n[b],o[b],this._bitLength),u=Math.max(l[v].length,u),u=Math.max(l[b].length,u);continue}var k=[r[v],null,null,r[b]];r[v].y.cmp(r[b].y)===0?(k[1]=r[v].add(r[b]),k[2]=r[v].toJ().mixedAdd(r[b].neg())):r[v].y.cmp(r[b].y.redNeg())===0?(k[1]=r[v].toJ().mixedAdd(r[b]),k[2]=r[v].add(r[b].neg())):(k[1]=r[v].toJ().mixedAdd(r[b]),k[2]=r[v].toJ().mixedAdd(r[b].neg()));var x=[-3,-1,-5,-7,0,7,5,1,3],w=JA(n[v],n[b]);for(u=Math.max(w[0].length,u),l[v]=new Array(u),l[b]=new Array(u),h=0;h=0;c--){for(var F=0;c>=0;){var $=!0;for(h=0;h=0&&F++,I=I.dblp(F),c<0)break;for(h=0;h0?p=a[h][V-1>>1]:V<0&&(p=a[h][-V-1>>1].neg()),p.type==="affine"?I=I.mixedAdd(p):I=I.add(p))}}for(c=0;c=Math.ceil((e.bitLength()+1)/r.step):!1};Tr.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,s=0;s=0&&(m=u,v=c),h.negative&&(h=h.neg(),p=p.neg()),m.negative&&(m=m.neg(),v=v.neg()),[{a:h,b:p},{a:m,b:v}]};jr.prototype._endoSplit=function(e){var r=this.endo.basis,n=r[0],i=r[1],s=i.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=s.mul(n.a),l=o.mul(i.a),u=s.mul(n.b),c=o.mul(i.b),h=e.sub(a).sub(l),p=u.add(c).neg();return{k1:h,k2:p}};jr.prototype.pointFromX=function(e,r){e=new ce(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(r&&!s||!r&&s)&&(i=i.redNeg()),this.point(e,i)};jr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0};jr.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};Ct.prototype.isInfinity=function(){return this.inf};Ct.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)};Ct.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),s=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};Ct.prototype.getX=function(){return this.x.fromRed()};Ct.prototype.getY=function(){return this.y.fromRed()};Ct.prototype.mul=function(e){return e=new ce(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};Ct.prototype.mulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)};Ct.prototype.jmulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)};Ct.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};Ct.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(s){return s.neg()};r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r};Ct.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Bt(t,e,r,n){ts.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new ce(0)):(this.x=new ce(e,16),this.y=new ce(r,16),this.z=new ce(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Wd(Bt,ts.BasePoint);jr.prototype.jpoint=function(e,r,n){return new Bt(this,e,r,n)};Bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)};Bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),s=e.x.redMul(n),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),l=i.redSub(s),u=o.redSub(a);if(l.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=l.redSqr(),h=c.redMul(l),p=i.redMul(c),m=u.redSqr().redIAdd(h).redISub(p).redISub(p),v=u.redMul(p.redISub(m)).redISub(o.redMul(h)),b=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(m,v,b)};Bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=n.redSub(i),l=s.redSub(o);if(a.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),h=n.redMul(u),p=l.redSqr().redIAdd(c).redISub(h).redISub(h),m=l.redMul(h.redISub(p)).redISub(s.redMul(c)),v=this.z.redMul(a);return this.curve.jpoint(p,m,v)};Bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r=0)return!1;if(n.redIAdd(s),this.x.cmp(n)===0)return!0}};Bt.prototype.inspect=function(){return this.isInfinity()?"":""};Bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Nl=oo(function(t,e){var r=e;r.base=ts,r.short=XA,r.mont=null,r.edwards=null}),Ml=oo(function(t,e){var r=e,n=br.assert;function i(a){a.type==="short"?this.curve=new Nl.short(a):a.type==="edwards"?this.curve=new Nl.edwards(a):this.curve=new Nl.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=i;function s(a,l){Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get:function(){var u=new i(l);return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,value:u}),u}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:nn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:nn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:nn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:nn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:nn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:nn.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:nn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:nn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Gr.toArray(t.entropy,t.entropyEnc||"hex"),r=Gr.toArray(t.nonce,t.nonceEnc||"hex"),n=Gr.toArray(t.pers,t.persEnc||"hex");Gd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Cy=_i;_i.prototype._init=function(e,r,n){var i=e.concat(r).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1};_i.prototype.generate=function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=Gr.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length"};var ZA=br.assert;function Zu(t,e){if(t instanceof Zu)return t;this._importDER(t,e)||(ZA(t.r&&t.s,"Signature without r or s"),this.r=new ce(t.r,16),this.s=new ce(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var ec=Zu;function e4(){this.place=0}function af(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4)return!1;for(var i=0,s=0,o=e.place;s>>=0;return i<=127?!1:(e.place=o,i)}function om(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Zu.prototype.toDER=function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=om(r),n=om(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];lf(i,r.length),i=i.concat(r),i.push(2),lf(i,n.length);var s=i.concat(n),o=[48];return lf(o,s.length),o=o.concat(s),br.encode(o,e)};var t4=function(){throw new Error("unsupported")},Py=br.assert;function Or(t){if(!(this instanceof Or))return new Or(t);typeof t=="string"&&(Py(Object.prototype.hasOwnProperty.call(Ml,t),"Unknown curve "+t),t=Ml[t]),t instanceof Ml.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var r4=Or;Or.prototype.keyPair=function(e){return new Kd(this,e)};Or.prototype.keyFromPrivate=function(e,r){return Kd.fromPrivate(this,e,r)};Or.prototype.keyFromPublic=function(e,r){return Kd.fromPublic(this,e,r)};Or.prototype.genKeyPair=function(e){e||(e={});for(var r=new Cy({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||t4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new ce(2));;){var s=new ce(r.generate(n));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Or.prototype._truncateToN=function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e};Or.prototype.sign=function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new ce(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),l=new Cy({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new ce(1)),c=0;;c++){var h=i.k?i.k(c):new ce(l.generate(this.n.byteLength()));if(h=this._truncateToN(h,!0),!(h.cmpn(1)<=0||h.cmp(u)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var m=p.getX(),v=m.umod(this.n);if(v.cmpn(0)!==0){var b=h.invm(this.n).mul(v.mul(r.getPrivate()).iadd(e));if(b=b.umod(this.n),b.cmpn(0)!==0){var k=(p.getY().isOdd()?1:0)|(m.cmp(v)!==0?2:0);return i.canonical&&b.cmp(this.nh)>0&&(b=this.n.sub(b),k^=1),new ec({r:v,s:b,recoveryParam:k})}}}}}};Or.prototype.verify=function(e,r,n,i){e=this._truncateToN(new ce(e,16)),n=this.keyFromPublic(n,i),r=new ec(r,"hex");var s=r.r,o=r.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),l=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),c;return this.curve._maxwellTrick?(c=this.g.jmulAdd(l,n.getPublic(),u),c.isInfinity()?!1:c.eqXToP(s)):(c=this.g.mulAdd(l,n.getPublic(),u),c.isInfinity()?!1:c.getX().umod(this.n).cmp(s)===0)};Or.prototype.recoverPubKey=function(t,e,r,n){Py((3&r)===r,"The recovery param is more than two bits"),e=new ec(e,n);var i=this.n,s=new ce(t),o=e.r,a=e.s,l=r&1,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var c=e.r.invm(i),h=i.sub(s).mul(c).umod(i),p=a.mul(c).umod(i);return this.g.mulAdd(h,o,p)};Or.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new ec(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch{continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var n4=oo(function(t,e){var r=e;r.version="6.5.4",r.utils=br,r.rand=function(){throw new Error("unsupported")},r.curve=Nl,r.curves=Ml,r.ec=r4,r.eddsa=null}),i4=n4.ec;const s4="signing-key/5.7.0",Ch=new j(s4);let uf=null;function on(){return uf||(uf=new i4("secp256k1")),uf}class o4{constructor(e){H(this,"curve","secp256k1"),H(this,"privateKey",ne(e)),zn(this.privateKey)!==32&&Ch.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=on().keyFromPrivate(oe(this.privateKey));H(this,"publicKey","0x"+r.getPublic(!1,"hex")),H(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),H(this,"_isSigningKey",!0)}_addPoint(e){const r=on().keyFromPublic(oe(this.publicKey)),n=on().keyFromPublic(oe(e));return"0x"+r.pub.add(n.pub).encodeCompressed("hex")}signDigest(e){const r=on().keyFromPrivate(oe(this.privateKey)),n=oe(e);n.length!==32&&Ch.throwArgumentError("bad digest length","digest",e);const i=r.sign(n,{canonical:!0});return Gu({recoveryParam:i.recoveryParam,r:gt("0x"+i.r.toString(16),32),s:gt("0x"+i.s.toString(16),32)})}computeSharedSecret(e){const r=on().keyFromPrivate(oe(this.privateKey)),n=on().keyFromPublic(oe(Ry(e)));return gt("0x"+r.derive(n.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function a4(t,e){const r=Gu(e),n={r:oe(r.r),s:oe(r.s)};return"0x"+on().recoverPubKey(oe(t),n,r.recoveryParam).encode("hex",!1)}function Ry(t,e){const r=oe(t);if(r.length===32){const n=new o4(r);return e?"0x"+on().keyFromPrivate(r).getPublic(!0,"hex"):n.publicKey}else{if(r.length===33)return e?ne(r):"0x"+on().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+on().keyFromPublic(r).getPublic(!0,"hex"):ne(r)}return Ch.throwArgumentError("invalid public or private key","key","[REDACTED]")}const l4="transactions/5.7.0",qn=new j(l4);var am;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(am||(am={}));function Qd(t){return t==="0x"?null:vt(t)}function zt(t){return t==="0x"?W1:K.from(t)}function u4(t){const e=Ry(t);return vt(Tt(ot(Tt(e,1)),12))}function Iy(t,e){return u4(a4(oe(t),e))}function dr(t,e){const r=Vs(K.from(t).toHexString());return r.length>32&&qn.throwArgumentError("invalid length for "+e,"transaction:"+e,t),r}function cf(t,e){return{address:vt(t),storageKeys:(e||[]).map((r,n)=>(zn(r)!==32&&qn.throwArgumentError("invalid access list storageKey",`accessList[${t}:${n}]`,r),r.toLowerCase()))}}function rs(t){if(Array.isArray(t))return t.map((r,n)=>Array.isArray(r)?(r.length>2&&qn.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${n}]`,r),cf(r[0],r[1])):cf(r.address,r.storageKeys));const e=Object.keys(t).map(r=>{const n=t[r].reduce((i,s)=>(i[s]=!0,i),{});return cf(r,Object.keys(n).sort())});return e.sort((r,n)=>r.address.localeCompare(n.address)),e}function Oy(t){return rs(t).map(e=>[e.address,e.storageKeys])}function c4(t,e){if(t.gasPrice!=null){const n=K.from(t.gasPrice),i=K.from(t.maxFeePerGas||0);n.eq(i)||qn.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:n,maxFeePerGas:i})}const r=[dr(t.chainId||0,"chainId"),dr(t.nonce||0,"nonce"),dr(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),dr(t.maxFeePerGas||0,"maxFeePerGas"),dr(t.gasLimit||0,"gasLimit"),t.to!=null?vt(t.to):"0x",dr(t.value||0,"value"),t.data||"0x",Oy(t.accessList||[])];if(e){const n=Gu(e);r.push(dr(n.recoveryParam,"recoveryParam")),r.push(Vs(n.r)),r.push(Vs(n.s))}return nr(["0x02",Wu(r)])}function f4(t,e){const r=[dr(t.chainId||0,"chainId"),dr(t.nonce||0,"nonce"),dr(t.gasPrice||0,"gasPrice"),dr(t.gasLimit||0,"gasLimit"),t.to!=null?vt(t.to):"0x",dr(t.value||0,"value"),t.data||"0x",Oy(t.accessList||[])];if(e){const n=Gu(e);r.push(dr(n.recoveryParam,"recoveryParam")),r.push(Vs(n.r)),r.push(Vs(n.s))}return nr(["0x01",Wu(r)])}function Ty(t,e,r){try{const n=zt(e[0]).toNumber();if(n!==0&&n!==1)throw new Error("bad recid");t.v=n}catch{qn.throwArgumentError("invalid v for transaction type: 1","v",e[0])}t.r=gt(e[1],32),t.s=gt(e[2],32);try{const n=ot(r(t));t.from=Iy(n,{r:t.r,s:t.s,recoveryParam:t.v})}catch{}}function h4(t){const e=zd(t.slice(1));e.length!==9&&e.length!==12&&qn.throwArgumentError("invalid component count for transaction type: 2","payload",ne(t));const r=zt(e[2]),n=zt(e[3]),i={type:2,chainId:zt(e[0]).toNumber(),nonce:zt(e[1]).toNumber(),maxPriorityFeePerGas:r,maxFeePerGas:n,gasPrice:null,gasLimit:zt(e[4]),to:Qd(e[5]),value:zt(e[6]),data:e[7],accessList:rs(e[8])};return e.length===9||(i.hash=ot(t),Ty(i,e.slice(9),c4)),i}function d4(t){const e=zd(t.slice(1));e.length!==8&&e.length!==11&&qn.throwArgumentError("invalid component count for transaction type: 1","payload",ne(t));const r={type:1,chainId:zt(e[0]).toNumber(),nonce:zt(e[1]).toNumber(),gasPrice:zt(e[2]),gasLimit:zt(e[3]),to:Qd(e[4]),value:zt(e[5]),data:e[6],accessList:rs(e[7])};return e.length===8||(r.hash=ot(t),Ty(r,e.slice(8),f4)),r}function p4(t){const e=zd(t);e.length!==9&&e.length!==6&&qn.throwArgumentError("invalid raw transaction","rawTransaction",t);const r={nonce:zt(e[0]).toNumber(),gasPrice:zt(e[1]),gasLimit:zt(e[2]),to:Qd(e[3]),value:zt(e[4]),data:e[5],chainId:0};if(e.length===6)return r;try{r.v=K.from(e[6]).toNumber()}catch{return r}if(r.r=gt(e[7],32),r.s=gt(e[8],32),K.from(r.r).isZero()&&K.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27;const i=e.slice(0,6);r.chainId!==0&&(i.push(ne(r.chainId)),i.push("0x"),i.push("0x"),n-=r.chainId*2+8);const s=ot(Wu(i));try{r.from=Iy(s,{r:ne(r.r),s:ne(r.s),recoveryParam:n})}catch{}r.hash=ot(t)}return r.type=null,r}function m4(t){const e=oe(t);if(e[0]>127)return p4(e);switch(e[0]){case 1:return d4(e);case 2:return h4(e)}return qn.throwError(`unsupported transaction type: ${e[0]}`,j.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}const yo=new j(qt);class ee{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const e={},r=this.address.bind(this),n=this.bigNumber.bind(this),i=this.blockTag.bind(this),s=this.data.bind(this),o=this.hash.bind(this),a=this.hex.bind(this),l=this.number.bind(this),u=this.type.bind(this),c=h=>this.data(h,!0);return e.transaction={hash:o,type:u,accessList:ee.allowNull(this.accessList.bind(this),null),blockHash:ee.allowNull(o,null),blockNumber:ee.allowNull(l,null),transactionIndex:ee.allowNull(l,null),confirmations:ee.allowNull(l,null),from:r,gasPrice:ee.allowNull(n),maxPriorityFeePerGas:ee.allowNull(n),maxFeePerGas:ee.allowNull(n),gasLimit:n,to:ee.allowNull(r,null),value:n,nonce:l,data:s,r:ee.allowNull(this.uint256),s:ee.allowNull(this.uint256),v:ee.allowNull(l),creates:ee.allowNull(r,null),raw:ee.allowNull(s)},e.transactionRequest={from:ee.allowNull(r),nonce:ee.allowNull(l),gasLimit:ee.allowNull(n),gasPrice:ee.allowNull(n),maxPriorityFeePerGas:ee.allowNull(n),maxFeePerGas:ee.allowNull(n),to:ee.allowNull(r),value:ee.allowNull(n),data:ee.allowNull(c),type:ee.allowNull(l),accessList:ee.allowNull(this.accessList.bind(this),null)},e.receiptLog={transactionIndex:l,blockNumber:l,transactionHash:o,address:r,topics:ee.arrayOf(o),data:s,logIndex:l,blockHash:o},e.receipt={to:ee.allowNull(this.address,null),from:ee.allowNull(this.address,null),contractAddress:ee.allowNull(r,null),transactionIndex:l,root:ee.allowNull(a),gasUsed:n,logsBloom:ee.allowNull(s),blockHash:o,transactionHash:o,logs:ee.arrayOf(this.receiptLog.bind(this)),blockNumber:l,confirmations:ee.allowNull(l,null),cumulativeGasUsed:n,effectiveGasPrice:ee.allowNull(n),status:ee.allowNull(l),type:u},e.block={hash:ee.allowNull(o),parentHash:o,number:l,timestamp:l,nonce:ee.allowNull(a),difficulty:this.difficulty.bind(this),gasLimit:n,gasUsed:n,miner:ee.allowNull(r),extraData:s,transactions:ee.allowNull(ee.arrayOf(o)),baseFeePerGas:ee.allowNull(n)},e.blockWithTransactions=at(e.block),e.blockWithTransactions.transactions=ee.allowNull(ee.arrayOf(this.transactionResponse.bind(this))),e.filter={fromBlock:ee.allowNull(i,void 0),toBlock:ee.allowNull(i,void 0),blockHash:ee.allowNull(o,void 0),address:ee.allowNull(r,void 0),topics:ee.allowNull(this.topics.bind(this),void 0)},e.filterLog={blockNumber:ee.allowNull(l),blockHash:ee.allowNull(o),transactionIndex:l,removed:ee.allowNull(this.boolean.bind(this)),address:r,data:ee.allowFalsish(s,"0x"),topics:ee.arrayOf(o),transactionHash:o,logIndex:l},e}accessList(e){return rs(e||[])}number(e){return e==="0x"?0:K.from(e).toNumber()}type(e){return e==="0x"||e==null?0:K.from(e).toNumber()}bigNumber(e){return K.from(e)}boolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){if(e=e.toLowerCase(),e==="true")return!0;if(e==="false")return!1}throw new Error("invalid boolean - "+e)}hex(e,r){return typeof e=="string"&&(!r&&e.substring(0,2)!=="0x"&&(e="0x"+e),me(e))?e.toLowerCase():yo.throwArgumentError("invalid hash","value",e)}data(e,r){const n=this.hex(e,r);if(n.length%2!==0)throw new Error("invalid data; odd-length - "+e);return n}address(e){return vt(e)}callAddress(e){if(!me(e,32))return null;const r=vt(Tt(e,12));return r===xE?null:r}contractAddress(e){return Hd(e)}blockTag(e){if(e==null)return"latest";if(e==="earliest")return"0x0";switch(e){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return e}if(typeof e=="number"||me(e))return qu(e);throw new Error("invalid blockTag")}hash(e,r){const n=this.hex(e,r);return zn(n)!==32?yo.throwArgumentError("invalid hash","value",e):n}difficulty(e){if(e==null)return null;const r=K.from(e);try{return r.toNumber()}catch{}return null}uint256(e){if(!me(e))throw new Error("invalid uint256");return gt(e,32)}_block(e,r){e.author!=null&&e.miner==null&&(e.miner=e.author);const n=e._difficulty!=null?e._difficulty:e.difficulty,i=ee.check(r,e);return i._difficulty=n==null?null:K.from(n),i}block(e){return this._block(e,this.formats.block)}blockWithTransactions(e){return this._block(e,this.formats.blockWithTransactions)}transactionRequest(e){return ee.check(this.formats.transactionRequest,e)}transactionResponse(e){e.gas!=null&&e.gasLimit==null&&(e.gasLimit=e.gas),e.to&&K.from(e.to).isZero()&&(e.to="0x0000000000000000000000000000000000000000"),e.input!=null&&e.data==null&&(e.data=e.input),e.to==null&&e.creates==null&&(e.creates=this.contractAddress(e)),(e.type===1||e.type===2)&&e.accessList==null&&(e.accessList=[]);const r=ee.check(this.formats.transaction,e);if(e.chainId!=null){let n=e.chainId;me(n)&&(n=K.from(n).toNumber()),r.chainId=n}else{let n=e.networkId;n==null&&r.v==null&&(n=e.chainId),me(n)&&(n=K.from(n).toNumber()),typeof n!="number"&&r.v!=null&&(n=(r.v-35)/2,n<0&&(n=0),n=parseInt(n)),typeof n!="number"&&(n=0),r.chainId=n}return r.blockHash&&r.blockHash.replace(/0/g,"")==="x"&&(r.blockHash=null),r}transaction(e){return m4(e)}receiptLog(e){return ee.check(this.formats.receiptLog,e)}receipt(e){const r=ee.check(this.formats.receipt,e);if(r.root!=null)if(r.root.length<=4){const n=K.from(r.root).toNumber();n===0||n===1?(r.status!=null&&r.status!==n&&yo.throwArgumentError("alt-root-status/status mismatch","value",{root:r.root,status:r.status}),r.status=n,delete r.root):yo.throwArgumentError("invalid alt-root-status","value.root",r.root)}else r.root.length!==66&&yo.throwArgumentError("invalid root hash","value.root",r.root);return r.status!=null&&(r.byzantium=!0),r}topics(e){return Array.isArray(e)?e.map(r=>this.topics(r)):e!=null?this.hash(e,!0):null}filter(e){return ee.check(this.formats.filter,e)}filterLog(e){return ee.check(this.formats.filterLog,e)}static check(e,r){const n={};for(const i in e)try{const s=e[i](r[i]);s!==void 0&&(n[i]=s)}catch(s){throw s.checkKey=i,s.checkValue=r[i],s}return n}static allowNull(e,r){return function(n){return n==null?r:e(n)}}static allowFalsish(e,r){return function(n){return n?e(n):r}}static arrayOf(e){return function(r){if(!Array.isArray(r))throw new Error("not an array");const n=[];return r.forEach(function(i){n.push(e(i))}),n}}}function jy(t){return t&&typeof t.isCommunityResource=="function"}function Ph(t){return jy(t)&&t.isCommunityResource()}let lm=!1;function Oa(){lm||(lm=!0,console.log("========= NOTICE ========="),console.log("Request-Rate Exceeded (this message will not be repeated)"),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.io/api-keys/"),console.log("=========================="))}var le=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const pe=new j(qt),g4=10;function um(t){return t==null?"null":(zn(t)!==32&&pe.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function cm(t){for(t=t.slice();t.length>0&&t[t.length-1]==null;)t.pop();return t.map(e=>{if(Array.isArray(e)){const r={};e.forEach(i=>{r[um(i)]=!0});const n=Object.keys(r);return n.sort(),n.join("|")}else return um(e)}).join("&")}function v4(t){return t===""?[]:t.split(/&/g).map(e=>{if(e==="")return[];const r=e.split("|").map(n=>n==="null"?null:n);return r.length===1?r[0]:r})}function is(t){if(typeof t=="string"){if(t=t.toLowerCase(),zn(t)===32)return"tx:"+t;if(t.indexOf(":")===-1)return t}else{if(Array.isArray(t))return"filter:*:"+cm(t);if(vE.isForkEvent(t))throw pe.warn("not implemented"),new Error("not implemented");if(t&&typeof t=="object")return"filter:"+(t.address||"*")+":"+cm(t.topics||[])}throw new Error("invalid event - "+t)}function wo(){return new Date().getTime()}function fm(t){return new Promise(e=>{setTimeout(e,t)})}const y4=["block","network","pending","poll"];class w4{constructor(e,r,n){H(this,"tag",e),H(this,"listener",r),H(this,"once",n),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const e=this.tag.split(":");return e[0]!=="tx"?null:e[1]}get filter(){const e=this.tag.split(":");if(e[0]!=="filter")return null;const r=e[1],n=v4(e[2]),i={};return n.length>0&&(i.topics=n),r&&r!=="*"&&(i.address=r),i}pollable(){return this.tag.indexOf(":")>=0||y4.indexOf(this.tag)>=0}}const x4={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function ff(t){return gt(K.from(t).toHexString(),32)}function hm(t){return Ah.encode($t([t,Tt(nm(nm(t)),0,4)]))}const Ly=new RegExp("^(ipfs)://(.*)$","i"),dm=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Ly,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function Cl(t,e){try{return Pa(ha(t,e))}catch{}return null}function ha(t,e){if(t==="0x")return null;const r=K.from(Tt(t,e,e+32)).toNumber(),n=K.from(Tt(t,r,r+32)).toNumber();return Tt(t,r+32,r+32+n)}function hf(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):pe.throwArgumentError("unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}function pm(t){const e=oe(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}function b4(t){if(t.length%32===0)return t;const e=new Uint8Array(Math.ceil(t.length/32)*32);return e.set(t),e}function By(t){const e=[];let r=0;for(let n=0;nK.from(e).eq(1)).catch(e=>{if(e.code===j.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,e})),this._supportsEip2544}_fetch(e,r){return le(this,void 0,void 0,function*(){const n={to:this.address,ccipReadEnabled:!0,data:nr([e,kl(this.name),r||"0x"])};let i=!1;(yield this.supportsWildcard())&&(i=!0,n.data=nr(["0x9061b923",By([e5(this.name),n.data])]));try{let s=yield this.provider.call(n);return oe(s).length%32===4&&pe.throwError("resolver threw error",j.errors.CALL_EXCEPTION,{transaction:n,data:s}),i&&(s=ha(s,0)),s}catch(s){if(s.code===j.errors.CALL_EXCEPTION)return null;throw s}})}_fetchBytes(e,r){return le(this,void 0,void 0,function*(){const n=yield this._fetch(e,r);return n!=null?ha(n,0):null})}_getAddress(e,r){const n=x4[String(e)];if(n==null&&pe.throwError(`unsupported coin type: ${e}`,j.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`}),n.ilk==="eth")return this.provider.formatter.address(r);const i=oe(r);if(n.p2pkh!=null){const s=r.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return hm($t([[n.p2pkh],"0x"+s[2]]))}}if(n.p2sh!=null){const s=r.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(s){const o=parseInt(s[1],16);if(s[2].length===o*2&&o>=1&&o<=75)return hm($t([[n.p2sh],"0x"+s[2]]))}}if(n.prefix!=null){const s=i[1];let o=i[0];if(o===0?s!==20&&s!==32&&(o=-1):o=-1,o>=0&&i.length===2+s&&s>=1&&s<=75){const a=sm.toWords(i.slice(2));return a.unshift(o),sm.encode(n.prefix,a)}}return null}getAddress(e){return le(this,void 0,void 0,function*(){if(e==null&&(e=60),e===60)try{const i=yield this._fetch("0x3b3b57de");return i==="0x"||i===_E?null:this.provider.formatter.callAddress(i)}catch(i){if(i.code===j.errors.CALL_EXCEPTION)return null;throw i}const r=yield this._fetchBytes("0xf1cb7e06",ff(e));if(r==null||r==="0x")return null;const n=this._getAddress(e,r);return n==null&&pe.throwError("invalid or unsupported coin data",j.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${e})`,coinType:e,data:r}),n})}getAvatar(){return le(this,void 0,void 0,function*(){const e=[{type:"name",content:this.name}];try{const r=yield this.getText("avatar");if(r==null)return null;for(let n=0;no[l])}return pe.throwError("invalid or unsupported content hash data",j.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:e})})}getText(e){return le(this,void 0,void 0,function*(){let r=yr(e);r=$t([ff(64),ff(r.length),r]),r.length%32!==0&&(r=$t([r,gt("0x",32-e.length%32)]));const n=yield this._fetchBytes("0x59d1d43c",ne(r));return n==null||n==="0x"?null:Pa(n)})}}let df=null,E4=1;class tc extends ro{constructor(e){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),H(this,"anyNetwork",e==="any"),this.anyNetwork&&(e=this.detectNetwork()),e instanceof Promise)this._networkPromise=e,e.catch(r=>{}),this._ready().catch(r=>{});else{const r=mr(new.target,"getNetwork")(e);r?(H(this,"_network",r),this.emit("network",r,null)):pe.throwArgumentError("invalid network","network",e)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return le(this,void 0,void 0,function*(){if(this._network==null){let e=null;if(this._networkPromise)try{e=yield this._networkPromise}catch{}e==null&&(e=yield this.detectNetwork()),e||pe.throwError("no network detected",j.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=e:H(this,"_network",e),this.emit("network",e,null))}return this._network})}get ready(){return As(()=>this._ready().then(e=>e,e=>{if(!(e.code===j.errors.NETWORK_ERROR&&e.event==="noNetwork"))throw e}))}static getFormatter(){return df==null&&(df=new ee),df}static getNetwork(e){return qd(e??"homestead")}ccipReadFetch(e,r,n){return le(this,void 0,void 0,function*(){if(this.disableCcipRead||n.length===0)return null;const i=e.to.toLowerCase(),s=r.toLowerCase(),o=[];for(let a=0;a=0?null:JSON.stringify({data:s,sender:i}),h=yield Ia({url:u,errorPassThrough:!0},c,(m,v)=>(m.status=v.statusCode,m));if(h.data)return h.data;const p=h.message||"unknown error";if(h.status>=400&&h.status<500)return pe.throwError(`response not found during CCIP fetch: ${p}`,j.errors.SERVER_ERROR,{url:l,errorMessage:p});o.push(p)}return pe.throwError(`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,j.errors.SERVER_ERROR,{urls:n,errorMessages:o})})}_getInternalBlockNumber(e){return le(this,void 0,void 0,function*(){if(yield this._ready(),e>0)for(;this._internalBlockNumber;){const i=this._internalBlockNumber;try{const s=yield i;if(wo()-s.respTime<=e)return s.blockNumber;break}catch{if(this._internalBlockNumber===i)break}}const r=wo(),n=xt({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(i=>null,i=>i)}).then(({blockNumber:i,networkError:s})=>{if(s)throw this._internalBlockNumber===n&&(this._internalBlockNumber=null),s;const o=wo();return i=K.from(i).toNumber(),i{this._internalBlockNumber===n&&(this._internalBlockNumber=null)}),(yield n).blockNumber})}poll(){return le(this,void 0,void 0,function*(){const e=E4++,r=[];let n=null;try{n=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(i){this.emit("error",i);return}if(this._setFastBlockNumber(n),this.emit("poll",e,n),n===this._lastBlockNumber){this.emit("didPoll",e);return}if(this._emitted.block===-2&&(this._emitted.block=n-1),Math.abs(this._emitted.block-n)>1e3)pe.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${n})`),this.emit("error",pe.makeError("network block skew detected",j.errors.NETWORK_ERROR,{blockNumber:n,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",n);else for(let i=this._emitted.block+1;i<=n;i++)this.emit("block",i);this._emitted.block!==n&&(this._emitted.block=n,Object.keys(this._emitted).forEach(i=>{if(i==="block")return;const s=this._emitted[i];s!=="pending"&&n-s>12&&delete this._emitted[i]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=n-1),this._events.forEach(i=>{switch(i.type){case"tx":{const s=i.hash;let o=this.getTransactionReceipt(s).then(a=>(!a||a.blockNumber==null||(this._emitted["t:"+s]=a.blockNumber,this.emit(s,a)),null)).catch(a=>{this.emit("error",a)});r.push(o);break}case"filter":{if(!i._inflight){i._inflight=!0,i._lastBlockNumber===-2&&(i._lastBlockNumber=n-1);const s=i.filter;s.fromBlock=i._lastBlockNumber+1,s.toBlock=n;const o=s.toBlock-this._maxFilterBlockRange;o>s.fromBlock&&(s.fromBlock=o),s.fromBlock<0&&(s.fromBlock=0);const a=this.getLogs(s).then(l=>{i._inflight=!1,l.length!==0&&l.forEach(u=>{u.blockNumber>i._lastBlockNumber&&(i._lastBlockNumber=u.blockNumber),this._emitted["b:"+u.blockHash]=u.blockNumber,this._emitted["t:"+u.transactionHash]=u.blockNumber,this.emit(s,u)})}).catch(l=>{this.emit("error",l),i._inflight=!1});r.push(a)}break}}}),this._lastBlockNumber=n,Promise.all(r).then(()=>{this.emit("didPoll",e)}).catch(i=>{this.emit("error",i)})})}resetEventsBlock(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return le(this,void 0,void 0,function*(){return pe.throwError("provider does not support network detection",j.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return le(this,void 0,void 0,function*(){const e=yield this._ready(),r=yield this.detectNetwork();if(e.chainId!==r.chainId){if(this.anyNetwork)return this._network=r,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",r,e),yield fm(0),this._network;const n=pe.makeError("underlying network changed",j.errors.NETWORK_ERROR,{event:"changed",network:e,detectedNetwork:r});throw this.emit("error",n),n}return e})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(e=>{this._setFastBlockNumber(e)},e=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(e){e&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(e){if(typeof e!="number"||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const e=wo();return e-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=e,this._fastBlockNumberPromise=this.getBlockNumber().then(r=>((this._fastBlockNumber==null||r>this._fastBlockNumber)&&(this._fastBlockNumber=r),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(e){this._fastBlockNumber!=null&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}waitForTransaction(e,r,n){return le(this,void 0,void 0,function*(){return this._waitForTransaction(e,r??1,n||0,null)})}_waitForTransaction(e,r,n,i){return le(this,void 0,void 0,function*(){const s=yield this.getTransactionReceipt(e);return(s?s.confirmations:0)>=r?s:new Promise((o,a)=>{const l=[];let u=!1;const c=function(){return u?!0:(u=!0,l.forEach(p=>{p()}),!1)},h=p=>{p.confirmations{this.removeListener(e,h)}),i){let p=i.startBlock,m=null;const v=b=>le(this,void 0,void 0,function*(){u||(yield fm(1e3),this.getTransactionCount(i.from).then(k=>le(this,void 0,void 0,function*(){if(!u){if(k<=i.nonce)p=b;else{{const x=yield this.getTransaction(e);if(x&&x.blockNumber!=null)return}for(m==null&&(m=p-3,m{u||this.once("block",v)}))});if(u)return;this.once("block",v),l.push(()=>{this.removeListener("block",v)})}if(typeof n=="number"&&n>0){const p=setTimeout(()=>{c()||a(pe.makeError("timeout exceeded",j.errors.TIMEOUT,{timeout:n}))},n);p.unref&&p.unref(),l.push(()=>{clearTimeout(p)})}})})}getBlockNumber(){return le(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return le(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield this.perform("getGasPrice",{});try{return K.from(e)}catch(r){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getGasPrice",result:e,error:r})}})}getBalance(e,r){return le(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(r)}),i=yield this.perform("getBalance",n);try{return K.from(i)}catch(s){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getBalance",params:n,result:i,error:s})}})}getTransactionCount(e,r){return le(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(r)}),i=yield this.perform("getTransactionCount",n);try{return K.from(i).toNumber()}catch(s){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getTransactionCount",params:n,result:i,error:s})}})}getCode(e,r){return le(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(r)}),i=yield this.perform("getCode",n);try{return ne(i)}catch(s){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getCode",params:n,result:i,error:s})}})}getStorageAt(e,r,n){return le(this,void 0,void 0,function*(){yield this.getNetwork();const i=yield xt({address:this._getAddress(e),blockTag:this._getBlockTag(n),position:Promise.resolve(r).then(o=>qu(o))}),s=yield this.perform("getStorageAt",i);try{return ne(s)}catch(o){return pe.throwError("bad result from backend",j.errors.SERVER_ERROR,{method:"getStorageAt",params:i,result:s,error:o})}})}_wrapTransaction(e,r,n){if(r!=null&&zn(r)!==32)throw new Error("invalid response - sendTransaction");const i=e;return r!=null&&e.hash!==r&&pe.throwError("Transaction hash mismatch from Provider.sendTransaction.",j.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:r}),i.wait=(s,o)=>le(this,void 0,void 0,function*(){s==null&&(s=1),o==null&&(o=0);let a;s!==0&&n!=null&&(a={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:n});const l=yield this._waitForTransaction(e.hash,s,o,a);return l==null&&s===0?null:(this._emitted["t:"+e.hash]=l.blockNumber,l.status===0&&pe.throwError("transaction failed",j.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:l}),l)}),i}sendTransaction(e){return le(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield Promise.resolve(e).then(s=>ne(s)),n=this.formatter.transaction(e);n.confirmations==null&&(n.confirmations=0);const i=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const s=yield this.perform("sendTransaction",{signedTransaction:r});return this._wrapTransaction(n,s,i)}catch(s){throw s.transaction=n,s.transactionHash=n.hash,s}})}_getTransactionRequest(e){return le(this,void 0,void 0,function*(){const r=yield e,n={};return["from","to"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s?this._getAddress(s):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s?K.from(s):null))}),["type"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s??null))}),r.accessList&&(n.accessList=this.formatter.accessList(r.accessList)),["data"].forEach(i=>{r[i]!=null&&(n[i]=Promise.resolve(r[i]).then(s=>s?ne(s):null))}),this.formatter.transactionRequest(yield xt(n))})}_getFilter(e){return le(this,void 0,void 0,function*(){e=yield e;const r={};return e.address!=null&&(r.address=this._getAddress(e.address)),["blockHash","topics"].forEach(n=>{e[n]!=null&&(r[n]=e[n])}),["fromBlock","toBlock"].forEach(n=>{e[n]!=null&&(r[n]=this._getBlockTag(e[n]))}),this.formatter.filter(yield xt(r))})}_call(e,r,n){return le(this,void 0,void 0,function*(){n>=g4&&pe.throwError("CCIP read exceeded maximum redirections",j.errors.SERVER_ERROR,{redirects:n,transaction:e});const i=e.to,s=yield this.perform("call",{transaction:e,blockTag:r});if(n>=0&&r==="latest"&&i!=null&&s.substring(0,10)==="0x556f1830"&&zn(s)%32===4)try{const o=Tt(s,4),a=Tt(o,0,32);K.from(a).eq(i)||pe.throwError("CCIP Read sender did not match",j.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:s});const l=[],u=K.from(Tt(o,32,64)).toNumber(),c=K.from(Tt(o,u,u+32)).toNumber(),h=Tt(o,u+32);for(let x=0;xle(this,void 0,void 0,function*(){const s=yield this.perform("getBlock",i);if(s==null)return i.blockHash!=null&&this._emitted["b:"+i.blockHash]==null||i.blockTag!=null&&n>this._emitted.block?null:void 0;if(r){let o=null;for(let l=0;lthis._wrapTransaction(l)),a}return this.formatter.block(s)}),{oncePoll:this})})}getBlock(e){return this._getBlock(e,!1)}getBlockWithTransactions(e){return this._getBlock(e,!0)}getTransaction(e){return le(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const r={transactionHash:this.formatter.hash(e,!0)};return As(()=>le(this,void 0,void 0,function*(){const n=yield this.perform("getTransaction",r);if(n==null)return this._emitted["t:"+e]==null?null:void 0;const i=this.formatter.transactionResponse(n);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return this._wrapTransaction(i)}),{oncePoll:this})})}getTransactionReceipt(e){return le(this,void 0,void 0,function*(){yield this.getNetwork(),e=yield e;const r={transactionHash:this.formatter.hash(e,!0)};return As(()=>le(this,void 0,void 0,function*(){const n=yield this.perform("getTransactionReceipt",r);if(n==null)return this._emitted["t:"+e]==null?null:void 0;if(n.blockHash==null)return;const i=this.formatter.receipt(n);if(i.blockNumber==null)i.confirmations=0;else if(i.confirmations==null){let o=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-i.blockNumber+1;o<=0&&(o=1),i.confirmations=o}return i}),{oncePoll:this})})}getLogs(e){return le(this,void 0,void 0,function*(){yield this.getNetwork();const r=yield xt({filter:this._getFilter(e)}),n=yield this.perform("getLogs",r);return n.forEach(i=>{i.removed==null&&(i.removed=!1)}),ee.arrayOf(this.formatter.filterLog.bind(this.formatter))(n)})}getEtherPrice(){return le(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(e){return le(this,void 0,void 0,function*(){if(e=yield e,typeof e=="number"&&e<0){e%1&&pe.throwArgumentError("invalid BlockTag","blockTag",e);let r=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return r+=e,r<0&&(r=0),this.formatter.blockTag(r)}return this.formatter.blockTag(e)})}getResolver(e){return le(this,void 0,void 0,function*(){let r=e;for(;;){if(r===""||r==="."||e!=="eth"&&r==="eth")return null;const n=yield this._getResolver(r,"getResolver");if(n!=null){const i=new Rh(this,n,e);return r!==e&&!(yield i.supportsWildcard())?null:i}r=r.split(".").slice(1).join(".")}})}_getResolver(e,r){return le(this,void 0,void 0,function*(){r==null&&(r="ENS");const n=yield this.getNetwork();n.ensAddress||pe.throwError("network does not support ENS",j.errors.UNSUPPORTED_OPERATION,{operation:r,network:n.name});try{const i=yield this.call({to:n.ensAddress,data:"0x0178b8bf"+kl(e).substring(2)});return this.formatter.callAddress(i)}catch{}return null})}resolveName(e){return le(this,void 0,void 0,function*(){e=yield e;try{return Promise.resolve(this.formatter.address(e))}catch(n){if(me(e))throw n}typeof e!="string"&&pe.throwArgumentError("invalid ENS name","name",e);const r=yield this.getResolver(e);return r?yield r.getAddress():null})}lookupAddress(e){return le(this,void 0,void 0,function*(){e=yield e,e=this.formatter.address(e);const r=e.substring(2).toLowerCase()+".addr.reverse",n=yield this._getResolver(r,"lookupAddress");if(n==null)return null;const i=Cl(yield this.call({to:n,data:"0x691f3431"+kl(r).substring(2)}),0);return(yield this.resolveName(i))!=e?null:i})}getAvatar(e){return le(this,void 0,void 0,function*(){let r=null;if(me(e)){const s=this.formatter.address(e).substring(2).toLowerCase()+".addr.reverse",o=yield this._getResolver(s,"getAvatar");if(!o)return null;r=new Rh(this,o,s);try{const a=yield r.getAvatar();if(a)return a.url}catch(a){if(a.code!==j.errors.CALL_EXCEPTION)throw a}try{const a=Cl(yield this.call({to:o,data:"0x691f3431"+kl(s).substring(2)}),0);r=yield this.getResolver(a)}catch(a){if(a.code!==j.errors.CALL_EXCEPTION)throw a;return null}}else if(r=yield this.getResolver(e),!r)return null;const n=yield r.getAvatar();return n==null?null:n.url})}perform(e,r){return pe.throwError(e+" not implemented",j.errors.NOT_IMPLEMENTED,{operation:e})}_startEvent(e){this.polling=this._events.filter(r=>r.pollable()).length>0}_stopEvent(e){this.polling=this._events.filter(r=>r.pollable()).length>0}_addEventListener(e,r,n){const i=new w4(is(e),r,n);return this._events.push(i),this._startEvent(i),this}on(e,r){return this._addEventListener(e,r,!1)}once(e,r){return this._addEventListener(e,r,!0)}emit(e,...r){let n=!1,i=[],s=is(e);return this._events=this._events.filter(o=>o.tag!==s?!0:(setTimeout(()=>{o.listener.apply(this,r)},0),n=!0,o.once?(i.push(o),!1):!0)),i.forEach(o=>{this._stopEvent(o)}),n}listenerCount(e){if(!e)return this._events.length;let r=is(e);return this._events.filter(n=>n.tag===r).length}listeners(e){if(e==null)return this._events.map(n=>n.listener);let r=is(e);return this._events.filter(n=>n.tag===r).map(n=>n.listener)}off(e,r){if(r==null)return this.removeAllListeners(e);const n=[];let i=!1,s=is(e);return this._events=this._events.filter(o=>o.tag!==s||o.listener!=r||i?!0:(i=!0,n.push(o),!1)),n.forEach(o=>{this._stopEvent(o)}),this}removeAllListeners(e){let r=[];if(e==null)r=this._events,this._events=[];else{const n=is(e);this._events=this._events.filter(i=>i.tag!==n?!0:(r.push(i),!1))}return r.forEach(n=>{this._stopEvent(n)}),this}}const A4="abstract-signer/5.7.0";var Fr=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Sr=new j(A4),_4=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],S4=[j.errors.INSUFFICIENT_FUNDS,j.errors.NONCE_EXPIRED,j.errors.REPLACEMENT_UNDERPRICED];class Ta{constructor(){Sr.checkAbstract(new.target,Ta),H(this,"_isSigner",!0)}getBalance(e){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),e)})}getTransactionCount(e){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),e)})}estimateGas(e){return Fr(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const r=yield xt(this.checkTransaction(e));return yield this.provider.estimateGas(r)})}call(e,r){return Fr(this,void 0,void 0,function*(){this._checkProvider("call");const n=yield xt(this.checkTransaction(e));return yield this.provider.call(n,r)})}sendTransaction(e){return Fr(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const r=yield this.populateTransaction(e),n=yield this.signTransaction(r);return yield this.provider.sendTransaction(n)})}getChainId(){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return Fr(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(e){return Fr(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(e)})}checkTransaction(e){for(const n in e)_4.indexOf(n)===-1&&Sr.throwArgumentError("invalid transaction key: "+n,"transaction",e);const r=at(e);return r.from==null?r.from=this.getAddress():r.from=Promise.all([Promise.resolve(r.from),this.getAddress()]).then(n=>(n[0].toLowerCase()!==n[1].toLowerCase()&&Sr.throwArgumentError("from address mismatch","transaction",e),n[0])),r}populateTransaction(e){return Fr(this,void 0,void 0,function*(){const r=yield xt(this.checkTransaction(e));r.to!=null&&(r.to=Promise.resolve(r.to).then(i=>Fr(this,void 0,void 0,function*(){if(i==null)return null;const s=yield this.resolveName(i);return s==null&&Sr.throwArgumentError("provided ENS name resolves to null","tx.to",i),s})),r.to.catch(i=>{}));const n=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||n)?Sr.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",e):(r.type===0||r.type===1)&&n&&Sr.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1)r.gasPrice==null&&(r.gasPrice=this.getGasPrice());else{const i=yield this.getFeeData();if(r.type==null)if(i.maxFeePerGas!=null&&i.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const s=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=s,r.maxPriorityFeePerGas=s}else r.maxFeePerGas==null&&(r.maxFeePerGas=i.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=i.maxPriorityFeePerGas);else i.gasPrice!=null?(n&&Sr.throwError("network does not support EIP-1559",j.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=i.gasPrice),r.type=0):Sr.throwError("failed to get consistent fee data",j.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else r.type===2&&(r.maxFeePerGas==null&&(r.maxFeePerGas=i.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=i.maxPriorityFeePerGas))}return r.nonce==null&&(r.nonce=this.getTransactionCount("pending")),r.gasLimit==null&&(r.gasLimit=this.estimateGas(r).catch(i=>{if(S4.indexOf(i.code)>=0)throw i;return Sr.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{error:i,tx:r})})),r.chainId==null?r.chainId=this.getChainId():r.chainId=Promise.all([Promise.resolve(r.chainId),this.getChainId()]).then(i=>(i[1]!==0&&i[0]!==i[1]&&Sr.throwArgumentError("chainId address mismatch","transaction",e),i[0])),yield xt(r)})}_checkProvider(e){this.provider||Sr.throwError("missing provider",j.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})}static isSigner(e){return!!(e&&e._isSigner)}}class Jd extends Ta{constructor(e,r){super(),H(this,"address",e),H(this,"provider",r||null)}getAddress(){return Promise.resolve(this.address)}_fail(e,r){return Promise.resolve().then(()=>{Sr.throwError(e,j.errors.UNSUPPORTED_OPERATION,{operation:r})})}signMessage(e){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(e,r,n){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(e){return new Jd(this.address,e)}}var Nn=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const bt=new j(qt),k4=["call","estimateGas"];function Do(t,e){if(t==null)return null;if(typeof t.message=="string"&&t.message.match("reverted")){const r=me(t.data)?t.data:null;if(!e||r)return{message:t.message,data:r}}if(typeof t=="object"){for(const r in t){const n=Do(t[r],e);if(n)return n}return null}if(typeof t=="string")try{return Do(JSON.parse(t),e)}catch{}return null}function Dy(t,e,r){const n=r.transaction||r.signedTransaction;if(t==="call"){const s=Do(e,!0);if(s)return s.data;bt.throwError("missing revert data in call exception; Transaction reverted without a reason string",j.errors.CALL_EXCEPTION,{data:"0x",transaction:n,error:e})}if(t==="estimateGas"){let s=Do(e.body,!1);s==null&&(s=Do(e,!1)),s&&bt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{reason:s.message,method:t,transaction:n,error:e})}let i=e.message;throw e.code===j.errors.SERVER_ERROR&&e.error&&typeof e.error.message=="string"?i=e.error.message:typeof e.body=="string"?i=e.body:typeof e.responseText=="string"&&(i=e.responseText),i=(i||"").toLowerCase(),i.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&bt.throwError("insufficient funds for intrinsic transaction cost",j.errors.INSUFFICIENT_FUNDS,{error:e,method:t,transaction:n}),i.match(/nonce (is )?too low/i)&&bt.throwError("nonce has already been used",j.errors.NONCE_EXPIRED,{error:e,method:t,transaction:n}),i.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&bt.throwError("replacement fee too low",j.errors.REPLACEMENT_UNDERPRICED,{error:e,method:t,transaction:n}),i.match(/only replay-protected/i)&&bt.throwError("legacy pre-eip-155 transactions not supported",j.errors.UNSUPPORTED_OPERATION,{error:e,method:t,transaction:n}),k4.indexOf(t)>=0&&i.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&bt.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:t,transaction:n}),e}function mm(t){return new Promise(function(e){setTimeout(e,t)})}function N4(t){if(t.error){const e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function xo(t){return t&&t.toLowerCase()}const Ih={};class Yd extends Ta{constructor(e,r,n){if(super(),e!==Ih)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");H(this,"provider",r),n==null&&(n=0),typeof n=="string"?(H(this,"_address",this.provider.formatter.address(n)),H(this,"_index",null)):typeof n=="number"?(H(this,"_index",n),H(this,"_address",null)):bt.throwArgumentError("invalid address or index","addressOrIndex",n)}connect(e){return bt.throwError("cannot alter JSON-RPC Signer connection",j.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new M4(Ih,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(e=>(e.length<=this._index&&bt.throwError("unknown account #"+this._index,j.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(e[this._index])))}sendUncheckedTransaction(e){e=at(e);const r=this.getAddress().then(n=>(n&&(n=n.toLowerCase()),n));if(e.gasLimit==null){const n=at(e);n.from=r,e.gasLimit=this.provider.estimateGas(n)}return e.to!=null&&(e.to=Promise.resolve(e.to).then(n=>Nn(this,void 0,void 0,function*(){if(n==null)return null;const i=yield this.provider.resolveName(n);return i==null&&bt.throwArgumentError("provided ENS name resolves to null","tx.to",n),i}))),xt({tx:xt(e),sender:r}).then(({tx:n,sender:i})=>{n.from!=null?n.from.toLowerCase()!==i&&bt.throwArgumentError("from address mismatch","transaction",e):n.from=i;const s=this.provider.constructor.hexlifyTransaction(n,{from:!0});return this.provider.send("eth_sendTransaction",[s]).then(o=>o,o=>(typeof o.message=="string"&&o.message.match(/user denied/i)&&bt.throwError("user rejected transaction",j.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:n}),Dy("sendTransaction",o,s)))})}signTransaction(e){return bt.throwError("signing transactions is unsupported",j.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(e){return Nn(this,void 0,void 0,function*(){const r=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),n=yield this.sendUncheckedTransaction(e);try{return yield As(()=>Nn(this,void 0,void 0,function*(){const i=yield this.provider.getTransaction(n);if(i!==null)return this.provider._wrapTransaction(i,n,r)}),{oncePoll:this.provider})}catch(i){throw i.transactionHash=n,i}})}signMessage(e){return Nn(this,void 0,void 0,function*(){const r=typeof e=="string"?yr(e):e,n=yield this.getAddress();try{return yield this.provider.send("personal_sign",[ne(r),n.toLowerCase()])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&bt.throwError("user rejected signing",j.errors.ACTION_REJECTED,{action:"signMessage",from:n,messageData:e}),i}})}_legacySignMessage(e){return Nn(this,void 0,void 0,function*(){const r=typeof e=="string"?yr(e):e,n=yield this.getAddress();try{return yield this.provider.send("eth_sign",[n.toLowerCase(),ne(r)])}catch(i){throw typeof i.message=="string"&&i.message.match(/user denied/i)&&bt.throwError("user rejected signing",j.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:n,messageData:e}),i}})}_signTypedData(e,r,n){return Nn(this,void 0,void 0,function*(){const i=yield cr.resolveNames(e,r,n,o=>this.provider.resolveName(o)),s=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[s.toLowerCase(),JSON.stringify(cr.getPayload(i.domain,r,i.value))])}catch(o){throw typeof o.message=="string"&&o.message.match(/user denied/i)&&bt.throwError("user rejected signing",j.errors.ACTION_REJECTED,{action:"_signTypedData",from:s,messageData:{domain:i.domain,types:r,value:i.value}}),o}})}unlock(e){return Nn(this,void 0,void 0,function*(){const r=this.provider,n=yield this.getAddress();return r.send("personal_unlockAccount",[n.toLowerCase(),e,null])})}}class M4 extends Yd{sendTransaction(e){return this.sendUncheckedTransaction(e).then(r=>({hash:r,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:n=>this.provider.waitForTransaction(r,n)}))}}const C4={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class Qi extends tc{constructor(e,r){let n=r;n==null&&(n=new Promise((i,s)=>{setTimeout(()=>{this.detectNetwork().then(o=>{i(o)},o=>{s(o)})},0)})),super(n),e||(e=mr(this.constructor,"defaultUrl")()),typeof e=="string"?H(this,"connection",Object.freeze({url:e})):H(this,"connection",Object.freeze(at(e))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return Nn(this,void 0,void 0,function*(){yield mm(0);let e=null;try{e=yield this.send("eth_chainId",[])}catch{try{e=yield this.send("net_version",[])}catch{}}if(e!=null){const r=mr(this.constructor,"getNetwork");try{return r(K.from(e).toNumber())}catch(n){return bt.throwError("could not detect network",j.errors.NETWORK_ERROR,{chainId:e,event:"invalidNetwork",serverError:n})}}return bt.throwError("could not detect network",j.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(e){return new Yd(Ih,this,e)}getUncheckedSigner(e){return this.getSigner(e).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(e=>e.map(r=>this.formatter.address(r)))}send(e,r){const n={method:e,params:r,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:lr(n),provider:this});const i=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(i&&this._cache[e])return this._cache[e];const s=Ia(this.connection,JSON.stringify(n),N4).then(o=>(this.emit("debug",{action:"response",request:n,response:o,provider:this}),o),o=>{throw this.emit("debug",{action:"response",error:o,request:n,provider:this}),o});return i&&(this._cache[e]=s,setTimeout(()=>{this._cache[e]=null},0)),s}prepareRequest(e,r){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[xo(r.address),r.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[xo(r.address),r.blockTag]];case"getCode":return["eth_getCode",[xo(r.address),r.blockTag]];case"getStorageAt":return["eth_getStorageAt",[xo(r.address),gt(r.position,32),r.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[r.signedTransaction]];case"getBlock":return r.blockTag?["eth_getBlockByNumber",[r.blockTag,!!r.includeTransactions]]:r.blockHash?["eth_getBlockByHash",[r.blockHash,!!r.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[r.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[r.transactionHash]];case"call":return["eth_call",[mr(this.constructor,"hexlifyTransaction")(r.transaction,{from:!0}),r.blockTag]];case"estimateGas":return["eth_estimateGas",[mr(this.constructor,"hexlifyTransaction")(r.transaction,{from:!0})]];case"getLogs":return r.filter&&r.filter.address!=null&&(r.filter.address=xo(r.filter.address)),["eth_getLogs",[r.filter]]}return null}perform(e,r){return Nn(this,void 0,void 0,function*(){if(e==="call"||e==="estimateGas"){const i=r.transaction;if(i&&i.type!=null&&K.from(i.type).isZero()&&i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null){const s=yield this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(r=at(r),r.transaction=at(i),delete r.transaction.type)}}const n=this.prepareRequest(e,r);n==null&&bt.throwError(e+" not implemented",j.errors.NOT_IMPLEMENTED,{operation:e});try{return yield this.send(n[0],n[1])}catch(i){return Dy(e,i,r)}})}_startEvent(e){e.tag==="pending"&&this._startPending(),super._startEvent(e)}_startPending(){if(this._pendingFilter!=null)return;const e=this,r=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=r,r.then(function(n){function i(){e.send("eth_getFilterChanges",[n]).then(function(s){if(e._pendingFilter!=r)return null;let o=Promise.resolve();return s.forEach(function(a){e._emitted["t:"+a.toLowerCase()]="pending",o=o.then(function(){return e.getTransaction(a).then(function(l){return e.emit("pending",l),null})})}),o.then(function(){return mm(1e3)})}).then(function(){if(e._pendingFilter!=r){e.send("eth_uninstallFilter",[n]);return}return setTimeout(function(){i()},0),null}).catch(s=>{})}return i(),n}).catch(n=>{})}_stopEvent(e){e.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(e)}static hexlifyTransaction(e,r){const n=at(C4);if(r)for(const s in r)r[s]&&(n[s]=!0);fE(e,n);const i={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(s){if(e[s]==null)return;const o=qu(K.from(e[s]));s==="gasLimit"&&(s="gas"),i[s]=o}),["from","to","data"].forEach(function(s){e[s]!=null&&(i[s]=ne(e[s]))}),e.accessList&&(i.accessList=rs(e.accessList)),i}}let Fo=null;try{if(Fo=WebSocket,Fo==null)throw new Error("inject please")}catch{const e=new j(qt);Fo=function(){e.throwError("WebSockets not supported in this environment",j.errors.UNSUPPORTED_OPERATION,{operation:"new WebSocket()"})}}var pf=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const rl=new j(qt);let P4=1;class rc extends Qi{constructor(e,r){r==="any"&&rl.throwError("WebSocketProvider does not support 'any' network yet",j.errors.UNSUPPORTED_OPERATION,{operation:"network:any"}),typeof e=="string"?super(e,r):super("_websocket",r),this._pollingInterval=-1,this._wsReady=!1,typeof e=="string"?H(this,"_websocket",new Fo(this.connection.url)):H(this,"_websocket",e),H(this,"_requests",{}),H(this,"_subs",{}),H(this,"_subIds",{}),H(this,"_detectNetwork",super.detectNetwork()),this.websocket.onopen=()=>{this._wsReady=!0,Object.keys(this._requests).forEach(i=>{this.websocket.send(this._requests[i].payload)})},this.websocket.onmessage=i=>{const s=i.data,o=JSON.parse(s);if(o.id!=null){const a=String(o.id),l=this._requests[a];if(delete this._requests[a],o.result!==void 0)l.callback(null,o.result),this.emit("debug",{action:"response",request:JSON.parse(l.payload),response:o.result,provider:this});else{let u=null;o.error?(u=new Error(o.error.message||"unknown error"),H(u,"code",o.error.code||null),H(u,"response",s)):u=new Error("unknown error"),l.callback(u,void 0),this.emit("debug",{action:"response",error:u,request:JSON.parse(l.payload),provider:this})}}else if(o.method==="eth_subscription"){const a=this._subs[o.params.subscription];a&&a.processFunc(o.params.result)}else console.warn("this should not happen")};const n=setInterval(()=>{this.emit("poll")},1e3);n.unref&&n.unref()}get websocket(){return this._websocket}detectNetwork(){return this._detectNetwork}get pollingInterval(){return 0}resetEventsBlock(e){rl.throwError("cannot reset events block on WebSocketProvider",j.errors.UNSUPPORTED_OPERATION,{operation:"resetEventBlock"})}set pollingInterval(e){rl.throwError("cannot set polling interval on WebSocketProvider",j.errors.UNSUPPORTED_OPERATION,{operation:"setPollingInterval"})}poll(){return pf(this,void 0,void 0,function*(){return null})}set polling(e){e&&rl.throwError("cannot set polling on WebSocketProvider",j.errors.UNSUPPORTED_OPERATION,{operation:"setPolling"})}send(e,r){const n=P4++;return new Promise((i,s)=>{function o(l,u){return l?s(l):i(u)}const a=JSON.stringify({method:e,params:r,id:n,jsonrpc:"2.0"});this.emit("debug",{action:"request",request:JSON.parse(a),provider:this}),this._requests[String(n)]={callback:o,payload:a},this._wsReady&&this.websocket.send(a)})}static defaultUrl(){return"ws://localhost:8546"}_subscribe(e,r,n){return pf(this,void 0,void 0,function*(){let i=this._subIds[e];i==null&&(i=Promise.all(r).then(o=>this.send("eth_subscribe",o)),this._subIds[e]=i);const s=yield i;this._subs[s]={tag:e,processFunc:n}})}_startEvent(e){switch(e.type){case"block":this._subscribe("block",["newHeads"],r=>{const n=K.from(r.number).toNumber();this._emitted.block=n,this.emit("block",n)});break;case"pending":this._subscribe("pending",["newPendingTransactions"],r=>{this.emit("pending",r)});break;case"filter":this._subscribe(e.tag,["logs",this._getFilter(e.filter)],r=>{r.removed==null&&(r.removed=!1),this.emit(e.filter,this.formatter.filterLog(r))});break;case"tx":{const r=n=>{const i=n.hash;this.getTransactionReceipt(i).then(s=>{s&&this.emit(i,s)})};r(e),this._subscribe("tx",["newHeads"],n=>{this._events.filter(i=>i.type==="tx").forEach(r)});break}case"debug":case"poll":case"willPoll":case"didPoll":case"error":break;default:console.log("unhandled:",e);break}}_stopEvent(e){let r=e.tag;if(e.type==="tx"){if(this._events.filter(i=>i.type==="tx").length)return;r="tx"}else if(this.listenerCount(e.event))return;const n=this._subIds[r];n&&(delete this._subIds[r],n.then(i=>{this._subs[i]&&(delete this._subs[i],this.send("eth_unsubscribe",[i]))}))}destroy(){return pf(this,void 0,void 0,function*(){this.websocket.readyState===Fo.CONNECTING&&(yield new Promise(e=>{this.websocket.onopen=function(){e(!0)},this.websocket.onerror=function(){e(!1)}})),this.websocket.close(1e3)})}}var R4=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const No=new j(qt);class Fy extends Qi{detectNetwork(){const e=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return R4(this,void 0,void 0,function*(){let r=this.network;return r==null&&(r=yield e.detectNetwork.call(this),r||No.throwError("no network detected",j.errors.UNKNOWN_ERROR,{}),this._network==null&&(H(this,"_network",r),this.emit("network",r,null))),r})}}class Gn extends Fy{constructor(e,r){No.checkAbstract(new.target,Gn),e=mr(new.target,"getNetwork")(e),r=mr(new.target,"getApiKey")(r);const n=mr(new.target,"getUrl")(e,r);super(n,e),typeof r=="string"?H(this,"apiKey",r):r!=null&&Object.keys(r).forEach(i=>{H(this,i,r[i])})}_startPending(){No.warn("WARNING: API provider does not support pending filters")}isCommunityResource(){return!1}getSigner(e){return No.throwError("API provider does not support signing",j.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"})}listAccounts(){return Promise.resolve([])}static getApiKey(e){return e}static getUrl(e,r){return No.throwError("not implemented; sub-classes must override getUrl",j.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const gm=new j(qt),Pl="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";class Uy extends rc{constructor(e,r){const n=new Xd(e,r),i=n.connection.url.replace(/^http/i,"ws").replace(".alchemyapi.",".ws.alchemyapi.");super(i,n.network),H(this,"apiKey",n.apiKey)}isCommunityResource(){return this.apiKey===Pl}}class Xd extends Gn{static getWebSocketProvider(e,r){return new Uy(e,r)}static getApiKey(e){return e==null?Pl:(e&&typeof e!="string"&&gm.throwArgumentError("invalid apiKey","apiKey",e),e)}static getUrl(e,r){let n=null;switch(e.name){case"homestead":n="eth-mainnet.alchemyapi.io/v2/";break;case"goerli":n="eth-goerli.g.alchemy.com/v2/";break;case"matic":n="polygon-mainnet.g.alchemy.com/v2/";break;case"maticmum":n="polygon-mumbai.g.alchemy.com/v2/";break;case"arbitrum":n="arb-mainnet.g.alchemy.com/v2/";break;case"arbitrum-goerli":n="arb-goerli.g.alchemy.com/v2/";break;case"optimism":n="opt-mainnet.g.alchemy.com/v2/";break;case"optimism-goerli":n="opt-goerli.g.alchemy.com/v2/";break;default:gm.throwArgumentError("unsupported network","network",arguments[0])}return{allowGzip:!0,url:"https://"+n+r,throttleCallback:(i,s)=>(r===Pl&&Oa(),Promise.resolve(!0))}}isCommunityResource(){return this.apiKey===Pl}}const I4=new j(qt),nl="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function O4(t){switch(t){case"homestead":return"rpc.ankr.com/eth/";case"ropsten":return"rpc.ankr.com/eth_ropsten/";case"rinkeby":return"rpc.ankr.com/eth_rinkeby/";case"goerli":return"rpc.ankr.com/eth_goerli/";case"matic":return"rpc.ankr.com/polygon/";case"arbitrum":return"rpc.ankr.com/arbitrum/"}return I4.throwArgumentError("unsupported network","name",t)}class zy extends Gn{isCommunityResource(){return this.apiKey===nl}static getApiKey(e){return e??nl}static getUrl(e,r){r==null&&(r=nl);const n={allowGzip:!0,url:"https://"+O4(e.name)+r,throttleCallback:(i,s)=>(r.apiKey===nl&&Oa(),Promise.resolve(!0))};return r.projectSecret!=null&&(n.user="",n.password=r.projectSecret),n}}var T4=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const vm=new j(qt);class $y extends Gn{static getApiKey(e){return e!=null&&vm.throwArgumentError("apiKey not supported for cloudflare","apiKey",e),null}static getUrl(e,r){let n=null;switch(e.name){case"homestead":n="https://cloudflare-eth.com/";break;default:vm.throwArgumentError("unsupported network","network",arguments[0])}return n}perform(e,r){const n=Object.create(null,{perform:{get:()=>super.perform}});return T4(this,void 0,void 0,function*(){return e==="getBlockNumber"?(yield n.perform.call(this,"getBlock",{blockTag:"latest"})).number:n.perform.call(this,e,r)})}}var il=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const li=new j(qt);function ym(t){const e={};for(let r in t){if(t[r]==null)continue;let n=t[r];r==="type"&&n===0||({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[r]?n=qu(ne(n)):r==="accessList"?n="["+rs(n).map(i=>`{address:"${i.address}",storageKeys:["${i.storageKeys.join('","')}"]}`).join(",")+"]":n=ne(n),e[r]=n)}return e}function j4(t){if(t.status==0&&(t.message==="No records found"||t.message==="No transactions found"))return t.result;if(t.status!=1||typeof t.message!="string"||!t.message.match(/^OK/)){const e=new Error("invalid response");throw e.result=JSON.stringify(t),(t.result||"").toLowerCase().indexOf("rate limit")>=0&&(e.throttleRetry=!0),e}return t.result}function wm(t){if(t&&t.status==0&&t.message=="NOTOK"&&(t.result||"").toLowerCase().indexOf("rate limit")>=0){const e=new Error("throttled response");throw e.result=JSON.stringify(t),e.throttleRetry=!0,e}if(t.jsonrpc!="2.0"){const e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){const e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function xm(t){if(t==="pending")throw new Error("pending not supported");return t==="latest"?t:parseInt(t.substring(2),16)}function mf(t,e,r){if(t==="call"&&e.code===j.errors.SERVER_ERROR){const i=e.error;if(i&&(i.message.match(/reverted/i)||i.message.match(/VM execution error/i))){let s=i.data;if(s&&(s="0x"+s.replace(/^.*0x/i,"")),me(s))return s;li.throwError("missing revert data in call exception",j.errors.CALL_EXCEPTION,{error:e,data:"0x"})}}let n=e.message;throw e.code===j.errors.SERVER_ERROR&&(e.error&&typeof e.error.message=="string"?n=e.error.message:typeof e.body=="string"?n=e.body:typeof e.responseText=="string"&&(n=e.responseText)),n=(n||"").toLowerCase(),n.match(/insufficient funds/)&&li.throwError("insufficient funds for intrinsic transaction cost",j.errors.INSUFFICIENT_FUNDS,{error:e,method:t,transaction:r}),n.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&li.throwError("nonce has already been used",j.errors.NONCE_EXPIRED,{error:e,method:t,transaction:r}),n.match(/another transaction with same nonce/)&&li.throwError("replacement fee too low",j.errors.REPLACEMENT_UNDERPRICED,{error:e,method:t,transaction:r}),n.match(/execution failed due to an exception|execution reverted/)&&li.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",j.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:t,transaction:r}),e}class Hy extends tc{constructor(e,r){super(e),H(this,"baseUrl",this.getBaseUrl()),H(this,"apiKey",r||null)}getBaseUrl(){switch(this.network?this.network.name:"invalid"){case"homestead":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"matic":return"https://api.polygonscan.com";case"maticmum":return"https://api-testnet.polygonscan.com";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}return li.throwArgumentError("unsupported network","network",this.network.name)}getUrl(e,r){const n=Object.keys(r).reduce((s,o)=>{const a=r[o];return a!=null&&(s+=`&${o}=${a}`),s},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.baseUrl}/api?module=${e}${n}${i}`}getPostUrl(){return`${this.baseUrl}/api`}getPostData(e,r){return r.module=e,r.apikey=this.apiKey,r}fetch(e,r,n){return il(this,void 0,void 0,function*(){const i=n?this.getPostUrl():this.getUrl(e,r),s=n?this.getPostData(e,r):null,o=e==="proxy"?wm:j4;this.emit("debug",{action:"request",request:i,provider:this});const a={url:i,throttleSlotInterval:1e3,throttleCallback:(c,h)=>(this.isCommunityResource()&&Oa(),Promise.resolve(!0))};let l=null;s&&(a.headers={"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},l=Object.keys(s).map(c=>`${c}=${s[c]}`).join("&"));const u=yield Ia(a,l,o||wm);return this.emit("debug",{action:"response",request:i,response:lr(u),provider:this}),u})}detectNetwork(){return il(this,void 0,void 0,function*(){return this.network})}perform(e,r){const n=Object.create(null,{perform:{get:()=>super.perform}});return il(this,void 0,void 0,function*(){switch(e){case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getBalance":return this.fetch("account",{action:"balance",address:r.address,tag:r.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:r.address,tag:r.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:r.address,tag:r.blockTag});case"getStorageAt":return this.fetch("proxy",{action:"eth_getStorageAt",address:r.address,position:r.position,tag:r.blockTag});case"sendTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:r.signedTransaction},!0).catch(i=>mf("sendTransaction",i,r.signedTransaction));case"getBlock":if(r.blockTag)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:r.blockTag,boolean:r.includeTransactions?"true":"false"});throw new Error("getBlock by blockHash not implemented");case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:r.transactionHash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:r.transactionHash});case"call":{if(r.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const i=ym(r.transaction);i.module="proxy",i.action="eth_call";try{return yield this.fetch("proxy",i,!0)}catch(s){return mf("call",s,r.transaction)}}case"estimateGas":{const i=ym(r.transaction);i.module="proxy",i.action="eth_estimateGas";try{return yield this.fetch("proxy",i,!0)}catch(s){return mf("estimateGas",s,r.transaction)}}case"getLogs":{const i={action:"getLogs"};if(r.filter.fromBlock&&(i.fromBlock=xm(r.filter.fromBlock)),r.filter.toBlock&&(i.toBlock=xm(r.filter.toBlock)),r.filter.address&&(i.address=r.filter.address),r.filter.topics&&r.filter.topics.length>0&&(r.filter.topics.length>1&&li.throwError("unsupported topic count",j.errors.UNSUPPORTED_OPERATION,{topics:r.filter.topics}),r.filter.topics.length===1)){const a=r.filter.topics[0];(typeof a!="string"||a.length!==66)&&li.throwError("unsupported topic format",j.errors.UNSUPPORTED_OPERATION,{topic0:a}),i.topic0=a}const s=yield this.fetch("logs",i);let o={};for(let a=0;a{["contractAddress","to"].forEach(function(l){o[l]==""&&delete o[l]}),o.creates==null&&o.contractAddress!=null&&(o.creates=o.contractAddress);const a=this.formatter.transactionResponse(o);return o.timeStamp&&(a.timestamp=parseInt(o.timeStamp)),a})})}isCommunityResource(){return this.apiKey==null}}function L4(t){t=t.slice();for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}var fu=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const Ti=new j(qt);function sl(){return new Date().getTime()}function bm(t){let e=null;for(let r=0;re?null:(n+i)/2}function _s(t){if(t===null)return"null";if(typeof t=="number"||typeof t=="boolean")return JSON.stringify(t);if(typeof t=="string")return t;if(K.isBigNumber(t))return t.toString();if(Array.isArray(t))return JSON.stringify(t.map(e=>_s(e)));if(typeof t=="object"){const e=Object.keys(t);return e.sort(),"{"+e.map(r=>{let n=t[r];return typeof n=="function"?n="[function]":n=_s(n),JSON.stringify(r)+":"+n}).join(",")+"}"}throw new Error("unknown value type: "+typeof t)}let B4=1;function Am(t){let e=null,r=null,n=new Promise(o=>{e=function(){r&&(clearTimeout(r),r=null),o()},r=setTimeout(e,t)});const i=o=>(n=n.then(o),n);function s(){return n}return{cancel:e,getPromise:s,wait:i}}const D4=[j.errors.CALL_EXCEPTION,j.errors.INSUFFICIENT_FUNDS,j.errors.NONCE_EXPIRED,j.errors.REPLACEMENT_UNDERPRICED,j.errors.UNPREDICTABLE_GAS_LIMIT],F4=["address","args","errorArgs","errorSignature","method","transaction"];function ol(t,e){const r={weight:t.weight};return Object.defineProperty(r,"provider",{get:()=>t.provider}),t.start&&(r.start=t.start),e&&(r.duration=e-t.start),t.done&&(t.error?r.error=t.error:r.result=t.result||null),r}function U4(t,e){return function(r){const n={};r.forEach(s=>{const o=t(s.result);n[o]||(n[o]={count:0,result:s.result}),n[o].count++});const i=Object.keys(n);for(let s=0;s=e)return o.result}}}function z4(t,e,r){let n=_s;switch(e){case"getBlockNumber":return function(i){const s=i.map(a=>a.result);let o=Em(i.map(a=>a.result),2);if(o!=null)return o=Math.ceil(o),s.indexOf(o+1)>=0&&o++,o>=t._highestBlockNumber&&(t._highestBlockNumber=o),t._highestBlockNumber};case"getGasPrice":return function(i){const s=i.map(o=>o.result);return s.sort(),s[Math.floor(s.length/2)]};case"getEtherPrice":return function(i){return Em(i.map(s=>s.result))};case"getBalance":case"getTransactionCount":case"getCode":case"getStorageAt":case"call":case"estimateGas":case"getLogs":break;case"getTransaction":case"getTransactionReceipt":n=function(i){return i==null?null:(i=at(i),i.confirmations=-1,_s(i))};break;case"getBlock":r.includeTransactions?n=function(i){return i==null?null:(i=at(i),i.transactions=i.transactions.map(s=>(s=at(s),s.confirmations=-1,s)),_s(i))}:n=function(i){return i==null?null:_s(i)};break;default:throw new Error("unknown method: "+e)}return U4(n,t.quorum)}function bo(t,e){return fu(this,void 0,void 0,function*(){const r=t.provider;return r.blockNumber!=null&&r.blockNumber>=e||e===-1?r:As(()=>new Promise((n,i)=>{setTimeout(function(){return r.blockNumber>=e?n(r):t.cancelled?n(null):n(void 0)},0)}),{oncePoll:r})})}function $4(t,e,r,n){return fu(this,void 0,void 0,function*(){let i=t.provider;switch(r){case"getBlockNumber":case"getGasPrice":return i[r]();case"getEtherPrice":if(i.getEtherPrice)return i.getEtherPrice();break;case"getBalance":case"getTransactionCount":case"getCode":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),i[r](n.address,n.blockTag||"latest");case"getStorageAt":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),i.getStorageAt(n.address,n.position,n.blockTag||"latest");case"getBlock":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),i[n.includeTransactions?"getBlockWithTransactions":"getBlock"](n.blockTag||n.blockHash);case"call":case"estimateGas":return n.blockTag&&me(n.blockTag)&&(i=yield bo(t,e)),r==="call"&&n.blockTag?i[r](n.transaction,n.blockTag):i[r](n.transaction);case"getTransaction":case"getTransactionReceipt":return i[r](n.transactionHash);case"getLogs":{let s=n.filter;return(s.fromBlock&&me(s.fromBlock)||s.toBlock&&me(s.toBlock))&&(i=yield bo(t,e)),i.getLogs(s)}}return Ti.throwError("unknown method error",j.errors.UNKNOWN_ERROR,{method:r,params:n})})}class Vy extends tc{constructor(e,r){e.length===0&&Ti.throwArgumentError("missing providers","providers",e);const n=e.map((o,a)=>{if(ro.isProvider(o)){const c=Ph(o)?2e3:750;return Object.freeze({provider:o,weight:1,stallTimeout:c,priority:1})}const l=at(o);l.priority==null&&(l.priority=1),l.stallTimeout==null&&(l.stallTimeout=Ph(o)?2e3:750),l.weight==null&&(l.weight=1);const u=l.weight;return(u%1||u>512||u<1)&&Ti.throwArgumentError("invalid weight; must be integer in [1, 512]",`providers[${a}].weight`,u),Object.freeze(l)}),i=n.reduce((o,a)=>o+a.weight,0);r==null?r=i/2:r>i&&Ti.throwArgumentError("quorum will always fail; larger than total weight","quorum",r);let s=bm(n.map(o=>o.provider.network));s==null&&(s=new Promise((o,a)=>{setTimeout(()=>{this.detectNetwork().then(o,a)},0)})),super(s),H(this,"providerConfigs",Object.freeze(n)),H(this,"quorum",r),this._highestBlockNumber=-1}detectNetwork(){return fu(this,void 0,void 0,function*(){const e=yield Promise.all(this.providerConfigs.map(r=>r.provider.getNetwork()));return bm(e)})}perform(e,r){return fu(this,void 0,void 0,function*(){if(e==="sendTransaction"){const l=yield Promise.all(this.providerConfigs.map(u=>u.provider.sendTransaction(r.signedTransaction).then(c=>c.hash,c=>c)));for(let u=0;ul.priority-u.priority);const s=this._highestBlockNumber;let o=0,a=!0;for(;;){const l=sl();let u=i.filter(m=>m.runner&&l-m.startm+v.weight,0);for(;u{m.staller=null}),m.runner=$4(m,s,e,r).then(b=>{m.done=!0,m.result=b,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:v,backend:ol(m,sl()),request:{method:e,params:lr(r)},provider:this})},b=>{m.done=!0,m.error=b,this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:v,backend:ol(m,sl()),request:{method:e,params:lr(r)},provider:this})}),this.listenerCount("debug")&&this.emit("debug",{action:"request",rid:v,backend:ol(m,null),request:{method:e,params:lr(r)},provider:this}),u+=m.weight}const c=[];i.forEach(m=>{m.done||!m.runner||(c.push(m.runner),m.staller&&c.push(m.staller.getPromise()))}),c.length&&(yield Promise.race(c));const h=i.filter(m=>m.done&&m.error==null);if(h.length>=this.quorum){const m=n(h);if(m!==void 0)return i.forEach(v=>{v.staller&&v.staller.cancel(),v.cancelled=!0}),m;a||(yield Am(100).getPromise()),a=!1}const p=i.reduce((m,v)=>{if(!v.done||v.error==null)return m;const b=v.error.code;return D4.indexOf(b)>=0&&(m[b]||(m[b]={error:v.error,weight:0}),m[b].weight+=v.weight),m},{});if(Object.keys(p).forEach(m=>{const v=p[m];if(v.weight{x.staller&&x.staller.cancel(),x.cancelled=!0});const b=v.error,k={};F4.forEach(x=>{b[x]!=null&&(k[x]=b[x])}),Ti.throwError(b.reason||b.message,m,k)}),i.filter(m=>!m.done).length===0)break}return i.forEach(l=>{l.staller&&l.staller.cancel(),l.cancelled=!0}),Ti.throwError("failed to meet quorum",j.errors.SERVER_ERROR,{method:e,params:r,results:i.map(l=>ol(l)),provider:this})})}}const qy=null,Rl=new j(qt),Mo="84842078b09946638c03157f83405213";class Gy extends rc{constructor(e,r){const n=new Zd(e,r),i=n.connection;i.password&&Rl.throwError("INFURA WebSocket project secrets unsupported",j.errors.UNSUPPORTED_OPERATION,{operation:"InfuraProvider.getWebSocketProvider()"});const s=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(s,e),H(this,"apiKey",n.projectId),H(this,"projectId",n.projectId),H(this,"projectSecret",n.projectSecret)}isCommunityResource(){return this.projectId===Mo}}class Zd extends Gn{static getWebSocketProvider(e,r){return new Gy(e,r)}static getApiKey(e){const r={apiKey:Mo,projectId:Mo,projectSecret:null};return e==null||(typeof e=="string"?r.projectId=e:e.projectSecret!=null?(Rl.assertArgument(typeof e.projectId=="string","projectSecret requires a projectId","projectId",e.projectId),Rl.assertArgument(typeof e.projectSecret=="string","invalid projectSecret","projectSecret","[REDACTED]"),r.projectId=e.projectId,r.projectSecret=e.projectSecret):e.projectId&&(r.projectId=e.projectId),r.apiKey=r.projectId),r}static getUrl(e,r){let n=null;switch(e?e.name:"unknown"){case"homestead":n="mainnet.infura.io";break;case"goerli":n="goerli.infura.io";break;case"sepolia":n="sepolia.infura.io";break;case"matic":n="polygon-mainnet.infura.io";break;case"maticmum":n="polygon-mumbai.infura.io";break;case"optimism":n="optimism-mainnet.infura.io";break;case"optimism-goerli":n="optimism-goerli.infura.io";break;case"arbitrum":n="arbitrum-mainnet.infura.io";break;case"arbitrum-goerli":n="arbitrum-goerli.infura.io";break;default:Rl.throwError("unsupported network",j.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i={allowGzip:!0,url:"https://"+n+"/v3/"+r.projectId,throttleCallback:(s,o)=>(r.projectId===Mo&&Oa(),Promise.resolve(!0))};return r.projectSecret!=null&&(i.user="",i.password=r.projectSecret),i}isCommunityResource(){return this.projectId===Mo}}class H4 extends Qi{send(e,r){const n={method:e,params:r,id:this._nextId++,jsonrpc:"2.0"};this._pendingBatch==null&&(this._pendingBatch=[]);const i={request:n,resolve:null,reject:null},s=new Promise((o,a)=>{i.resolve=o,i.reject=a});return this._pendingBatch.push(i),this._pendingBatchAggregator||(this._pendingBatchAggregator=setTimeout(()=>{const o=this._pendingBatch;this._pendingBatch=null,this._pendingBatchAggregator=null;const a=o.map(l=>l.request);return this.emit("debug",{action:"requestBatch",request:lr(a),provider:this}),Ia(this.connection,JSON.stringify(a)).then(l=>{this.emit("debug",{action:"response",request:a,response:l,provider:this}),o.forEach((u,c)=>{const h=l[c];if(h.error){const p=new Error(h.error.message);p.code=h.error.code,p.data=h.error.data,u.reject(p)}else u.resolve(h.result)})},l=>{this.emit("debug",{action:"response",error:l,request:a,provider:this}),o.forEach(u=>{u.reject(l)})})},10)),s}}const gf=new j(qt),V4="ETHERS_JS_SHARED";class Wy extends Gn{static getApiKey(e){return e&&typeof e!="string"&&gf.throwArgumentError("invalid apiKey","apiKey",e),e||V4}static getUrl(e,r){gf.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");let n=null;switch(e.name){case"homestead":n="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":n="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":n="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":n="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":n="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:gf.throwArgumentError("unsupported network","network",arguments[0])}return n+"?apiKey="+r}}const _m=new j(qt),Sm="62e1ad51b37b8e00394bda3b";class Ky extends Gn{static getApiKey(e){const r={applicationId:null,loadBalancer:!0,applicationSecretKey:null};return e==null?r.applicationId=Sm:typeof e=="string"?r.applicationId=e:e.applicationSecretKey!=null?(r.applicationId=e.applicationId,r.applicationSecretKey=e.applicationSecretKey):e.applicationId?r.applicationId=e.applicationId:_m.throwArgumentError("unsupported PocketProvider apiKey","apiKey",e),r}static getUrl(e,r){let n=null;switch(e?e.name:"unknown"){case"goerli":n="eth-goerli.gateway.pokt.network";break;case"homestead":n="eth-mainnet.gateway.pokt.network";break;case"kovan":n="poa-kovan.gateway.pokt.network";break;case"matic":n="poly-mainnet.gateway.pokt.network";break;case"maticmum":n="polygon-mumbai-rpc.gateway.pokt.network";break;case"rinkeby":n="eth-rinkeby.gateway.pokt.network";break;case"ropsten":n="eth-ropsten.gateway.pokt.network";break;default:_m.throwError("unsupported network",j.errors.INVALID_ARGUMENT,{argument:"network",value:e})}const i=`https://${n}/v1/lb/${r.applicationId}`,s={headers:{},url:i};return r.applicationSecretKey!=null&&(s.user="",s.password=r.applicationSecretKey),s}isCommunityResource(){return this.applicationId===Sm}}const km=new j(qt);let q4=1;function Nm(t,e){const r="Web3LegacyFetcher";return function(n,i){const s={method:n,params:i,id:q4++,jsonrpc:"2.0"};return new Promise((o,a)=>{this.emit("debug",{action:"request",fetcher:r,request:lr(s),provider:this}),e(s,(l,u)=>{if(l)return this.emit("debug",{action:"response",fetcher:r,error:l,request:s,provider:this}),a(l);if(this.emit("debug",{action:"response",fetcher:r,request:s,response:u,provider:this}),u.error){const c=new Error(u.error.message);return c.code=u.error.code,c.data=u.error.data,a(c)}o(u.result)})})}}function G4(t){return function(e,r){r==null&&(r=[]);const n={method:e,params:r};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:lr(n),provider:this}),t.request(n).then(i=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,response:i,provider:this}),i),i=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:n,error:i,provider:this}),i})}}class Qy extends Qi{constructor(e,r){e==null&&km.throwArgumentError("missing provider","provider",e);let n=null,i=null,s=null;typeof e=="function"?(n="unknown:",i=e):(n=e.host||e.path||"",!n&&e.isMetaMask&&(n="metamask"),s=e,e.request?(n===""&&(n="eip-1193:"),i=G4(e)):e.sendAsync?i=Nm(e,e.sendAsync.bind(e)):e.send?i=Nm(e,e.send.bind(e)):km.throwArgumentError("unsupported provider","provider",e),n||(n="unknown:")),super(n,r),H(this,"jsonRpcFetchFunc",i),H(this,"provider",s)}send(e,r){return this.jsonRpcFetchFunc(e,r)}}const Mm=new j(qt);function W4(t,e){if(t==null&&(t="homestead"),typeof t=="string"){const n=t.match(/^(ws|http)s?:/i);if(n)switch(n[1].toLowerCase()){case"http":case"https":return new Qi(t);case"ws":case"wss":return new rc(t);default:Mm.throwArgumentError("unsupported URL scheme","network",t)}}const r=qd(t);return(!r||!r._defaultProvider)&&Mm.throwError("unsupported getDefaultProvider network",j.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider({FallbackProvider:Vy,AlchemyProvider:Xd,AnkrProvider:zy,CloudflareProvider:$y,EtherscanProvider:Hy,InfuraProvider:Zd,JsonRpcProvider:Qi,NodesmithProvider:Wy,PocketProvider:Ky,Web3Provider:Qy,IpcProvider:qy},e)}const K4=Object.freeze(Object.defineProperty({__proto__:null,AlchemyProvider:Xd,AlchemyWebSocketProvider:Uy,AnkrProvider:zy,BaseProvider:tc,CloudflareProvider:$y,EtherscanProvider:Hy,FallbackProvider:Vy,Formatter:ee,InfuraProvider:Zd,InfuraWebSocketProvider:Gy,IpcProvider:qy,JsonRpcBatchProvider:H4,JsonRpcProvider:Qi,JsonRpcSigner:Yd,NodesmithProvider:Wy,PocketProvider:Ky,Provider:ro,Resolver:Rh,StaticJsonRpcProvider:Fy,UrlJsonRpcProvider:Gn,Web3Provider:Qy,WebSocketProvider:rc,getDefaultProvider:W4,getNetwork:qd,isCommunityResourcable:jy,isCommunityResource:Ph,showThrottleMessage:Oa},Symbol.toStringTag,{value:"Module"})),Q4=Ys(K4);var J4=ze&&ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Y4=ze&&ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),X4=ze&&ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&J4(e,t,r);return Y4(e,t),e},Z4=ze&&ze.__awaiter||function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.getPriorityConnector=Ln.getSelectedConnector=Ln.initializeConnector=void 0;const e_=N1,Ss=L,Cm=iE,t_=lE;let Ls;function r_(){return Z4(this,void 0,void 0,function*(){if(Ls===void 0)try{const{Web3Provider:t}=yield Promise.resolve().then(()=>X4(Q4));Ls=t}catch{console.debug("@ethersproject/providers not available"),Ls=null}})}function n_(t){const[e,r]=(0,e_.createWeb3ReactStoreAndActions)(),n=t(r),i=c_(e),s=f_(i),o=h_(n,i,s);return[n,Object.assign(Object.assign(Object.assign({},i),s),o),e]}Ln.initializeConnector=n_;function i_({chainId:t,accounts:e,activating:r}){return!!(t&&e&&!r)}function Jy(...t){function e(h){const p=t.findIndex(([m])=>h===m);if(p===-1)throw new Error("Connector not found");return p}function r(h){const p=t[e(h)][2];if(!p)throw new Error("Stores not passed");return p}function n(h){return t.map(([,{useChainId:m}])=>m())[e(h)]}function i(h){return t.map(([,{useAccounts:m}])=>m())[e(h)]}function s(h){return t.map(([,{useIsActivating:m}])=>m())[e(h)]}function o(h){return t.map(([,{useAccount:m}])=>m())[e(h)]}function a(h){return t.map(([,{useIsActive:m}])=>m())[e(h)]}function l(h,p){const m=e(h);return t.map(([,{useProvider:b}],k)=>b(p,k===m))[m]}function u(h,p){const m=e(h);return t.map(([,{useENSNames:b}],k)=>b(k===m?p:void 0))[m]}function c(h,p){const m=e(h);return t.map(([,{useENSName:b}],k)=>b(k===m?p:void 0))[m]}return{useSelectedStore:r,useSelectedChainId:n,useSelectedAccounts:i,useSelectedIsActivating:s,useSelectedAccount:o,useSelectedIsActive:a,useSelectedProvider:l,useSelectedENSNames:u,useSelectedENSName:c}}Ln.getSelectedConnector=Jy;function s_(...t){const{useSelectedStore:e,useSelectedChainId:r,useSelectedAccounts:n,useSelectedIsActivating:i,useSelectedAccount:s,useSelectedIsActive:o,useSelectedProvider:a,useSelectedENSNames:l,useSelectedENSName:u}=Jy(...t);function c(){const I=t.map(([,{useIsActive:B}])=>B()).findIndex(B=>B);return t[I===-1?0:I][0]}function h(){return e(c())}function p(){return r(c())}function m(){return n(c())}function v(){return i(c())}function b(){return s(c())}function k(){return o(c())}function x(T){return a(c(),T)}function w(T){return l(c(),T)}function A(T){return u(c(),T)}return{useSelectedStore:e,useSelectedChainId:r,useSelectedAccounts:n,useSelectedIsActivating:i,useSelectedAccount:s,useSelectedIsActive:o,useSelectedProvider:a,useSelectedENSNames:l,useSelectedENSName:u,usePriorityConnector:c,usePriorityStore:h,usePriorityChainId:p,usePriorityAccounts:m,usePriorityIsActivating:v,usePriorityAccount:b,usePriorityIsActive:k,usePriorityProvider:x,usePriorityENSNames:w,usePriorityENSName:A}}Ln.getPriorityConnector=s_;const o_=({chainId:t})=>t,a_=({accounts:t})=>t,l_=({activating:t})=>t,u_=(t,e)=>t===void 0&&e===void 0||t!==void 0&&t.length===(e==null?void 0:e.length)&&t.every((r,n)=>r===e[n]);function c_(t){function e(){return(0,Cm.useStore)(t,o_)}function r(){return(0,t_.useStoreWithEqualityFn)(t,a_,u_)}function n(){return(0,Cm.useStore)(t,l_)}return{useChainId:e,useAccounts:r,useIsActivating:n}}function f_({useChainId:t,useAccounts:e,useIsActivating:r}){function n(){var s;return(s=e())===null||s===void 0?void 0:s[0]}function i(){const s=t(),o=e(),a=r();return i_({chainId:s,accounts:o,activating:a})}return{useAccount:n,useIsActive:i}}function Pm(t,e=[]){const[r,n]=(0,Ss.useState)();return(0,Ss.useEffect)(()=>{if(t&&e.length){let i=!1;return Promise.all(e.map(s=>t.lookupAddress(s))).then(s=>{i||n(s)}).catch(s=>{i||(console.debug("Could not fetch ENS names",s),n(new Array(e.length).fill(null)))}),()=>{i=!0,n(void 0)}}},[t,e]),r??new Array(e.length).fill(void 0)}function h_(t,{useAccounts:e,useChainId:r},{useAccount:n,useIsActive:i}){function s(l,u=!0){const c=i(),h=r(),[p,m]=(0,Ss.useState)(Ls!==void 0);return(0,Ss.useEffect)(()=>{if(p)return;let v=!1;return r_().then(()=>{v||m(!0)}),()=>{v=!0}},[p]),(0,Ss.useMemo)(()=>{if(u){if(t.customProvider)return t.customProvider;if(Ls&&t.provider)return new Ls(t.provider,l)}},[p,u,c,h,l])}function o(l){const u=e();return Pm(l,u)}function a(l){var u;const c=n(),h=(0,Ss.useMemo)(()=>c===void 0?void 0:[c],[c]);return(u=Pm(l,h))===null||u===void 0?void 0:u[0]}return{useProvider:s,useENSNames:o,useENSName:a}}var nc={},Yy={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function i(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function s(l,u,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var m=new i(c,h||l,p),v=r?r+u:u;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],m]:l._events[v].push(m):(l._events[v]=m,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new n:delete l._events[u]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)e.call(c,h)&&u.push(r?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},a.prototype.listeners=function(u){var c=r?r+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,m=h.length,v=new Array(m);pe),this.eth_accounts=jest.fn(e=>e),this.eth_requestAccounts=jest.fn(e=>e)}request(e){if(!this.chainId)return Promise.reject(new Error);switch(e.method){case"eth_chainId":return Promise.resolve(this.eth_chainId(this.chainId));case"eth_accounts":return Promise.resolve(this.eth_accounts(this.accounts));case"eth_requestAccounts":return Promise.resolve(this.eth_requestAccounts(this.accounts));default:throw new Error(`Method not supported on mock: ${JSON.stringify(e)}`)}}emitConnect(e){this.emit("connect",{chainId:e})}emitDisconnect(e){this.emit("disconnect",e)}emitChainChanged(e){this.emit("chainChanged",e)}emitAccountsChanged(e){this.emit("accountsChanged",e)}}nc.MockEIP1193Provider=m_;var Qs={},g_=ze&&ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),v_=ze&&ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),y_=ze&&ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&g_(e,t,r);return v_(e,t),e};Object.defineProperty(Qs,"__esModule",{value:!0});Qs.useWeb3React=Qs.Web3ReactProvider=void 0;const hu=y_(L),w_=Ln,Xy=(0,hu.createContext)(void 0);function x_({children:t,connectors:e,connectorOverride:r,network:n,lookupENS:i=!0}){const s=(0,hu.useRef)(e);if(e.length!=s.current.length||e.some((G,Y)=>{const $e=s.current[Y];return G[0]!==$e[0]}))throw new Error("The connectors prop passed to Web3ReactProvider must be referentially static. If connectors is changing, try providing a key prop to Web3ReactProvider that changes every time connectors changes.");const o=(0,w_.getPriorityConnector)(...e),{usePriorityConnector:a,useSelectedChainId:l,useSelectedAccounts:u,useSelectedIsActivating:c,useSelectedAccount:h,useSelectedIsActive:p,useSelectedProvider:m,useSelectedENSNames:v,useSelectedENSName:b}=o,k=a(),x=r??k,w=l(x),A=u(x),T=c(x),I=h(x),B=p(x),F=m(x,n),$=v(x,i?F:void 0),V=b(x,i?F:void 0);return hu.default.createElement(Xy.Provider,{value:{connector:x,chainId:w,accounts:A,isActivating:T,account:I,isActive:B,provider:F,ENSNames:$,ENSName:V,hooks:o}},t)}Qs.Web3ReactProvider=x_;function b_(){const t=(0,hu.useContext)(Xy);if(!t)throw Error("useWeb3React can only be used within the Web3ReactProvider component");return t}Qs.useWeb3React=b_;(function(t){var e=ze&&ze.__createBinding||(Object.create?function(n,i,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(i,s);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(n,o,a)}:function(n,i,s,o){o===void 0&&(o=s),n[o]=i[s]}),r=ze&&ze.__exportStar||function(n,i){for(var s in n)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Ln,t),r(nc,t),r(Qs,t)})(Hu);const ja="abi/5.7.0",be=new j(ja),Ji={};let Rm={calldata:!0,memory:!0,storage:!0},E_={calldata:!0,memory:!0};function al(t,e){if(t==="bytes"||t==="string"){if(Rm[e])return!0}else if(t==="address"){if(e==="payable")return!0}else if((t.indexOf("[")>=0||t==="tuple")&&E_[e])return!0;return(Rm[e]||e==="payable")&&be.throwArgumentError("invalid modifier","name",e),!1}function A_(t,e){let r=t;function n(a){be.throwArgumentError(`unexpected character at position ${a}`,"param",t)}t=t.replace(/\s/g," ");function i(a){let l={type:"",name:"",parent:a,state:{allowType:!0}};return e&&(l.indexed=!1),l}let s={type:"",name:"",state:{allowType:!0}},o=s;for(let a=0;aJSON.parse(i.format(e)))),JSON.stringify(n)}let r="";return this.baseType==="array"?(r+=this.arrayChildren.format(e),r+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(e!==ke.sighash&&(r+=this.type),r+="("+this.components.map(n=>n.format(e)).join(e===ke.full?", ":",")+")"):r+=this.type,e!==ke.sighash&&(this.indexed===!0&&(r+=" indexed"),e===ke.full&&this.name&&(r+=" "+this.name)),r}static from(e,r){return typeof e=="string"?Nt.fromString(e,r):Nt.fromObject(e)}static fromObject(e){return Nt.isParamType(e)?e:new Nt(Ji,{name:e.name||null,type:as(e.type),indexed:e.indexed==null?null:!!e.indexed,components:e.components?e.components.map(Nt.fromObject):null})}static fromString(e,r){function n(i){return Nt.fromObject({name:i.name,type:i.type,indexed:i.indexed,components:i.components})}return n(A_(e,!!r))}static isParamType(e){return!!(e!=null&&e._isParamType)}}function da(t,e){return k_(t).map(r=>Nt.fromString(r,e))}class Tn{constructor(e,r){e!==Ji&&be.throwError("use a static from method",j.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Il(this,r),this._isFragment=!0,Object.freeze(this)}static from(e){return Tn.isFragment(e)?e:typeof e=="string"?Tn.fromString(e):Tn.fromObject(e)}static fromObject(e){if(Tn.isFragment(e))return e;switch(e.type){case"function":return un.fromObject(e);case"event":return Pn.fromObject(e);case"constructor":return ln.fromObject(e);case"error":return ui.fromObject(e);case"fallback":case"receive":return null}return be.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return e=e.replace(/\s/g," "),e=e.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),e=e.trim(),e.split(" ")[0]==="event"?Pn.fromString(e.substring(5).trim()):e.split(" ")[0]==="function"?un.fromString(e.substring(8).trim()):e.split("(")[0].trim()==="constructor"?ln.fromString(e.trim()):e.split(" ")[0]==="error"?ui.fromString(e.substring(5).trim()):be.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!!(e&&e._isFragment)}}class Pn extends Tn{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});let r="";return e!==ke.sighash&&(r+="event "),r+=this.name+"("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ",e!==ke.sighash&&this.anonymous&&(r+="anonymous "),r.trim()}static from(e){return typeof e=="string"?Pn.fromString(e):Pn.fromObject(e)}static fromObject(e){if(Pn.isEventFragment(e))return e;e.type!=="event"&&be.throwArgumentError("invalid event object","value",e);const r={name:pa(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Nt.fromObject):[],type:"event"};return new Pn(Ji,r)}static fromString(e){let r=e.match(ma);r||be.throwArgumentError("invalid event string","value",e);let n=!1;return r[3].split(" ").forEach(i=>{switch(i.trim()){case"anonymous":n=!0;break;case"":break;default:be.warn("unknown modifier: "+i)}}),Pn.fromObject({name:r[1].trim(),anonymous:n,inputs:da(r[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&e.type==="event"}}function Zy(t,e){e.gas=null;let r=t.split("@");return r.length!==1?(r.length>2&&be.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||be.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=K.from(r[1]),r[0]):t}function e2(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(r=>{switch(r.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+r)}})}function t2(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return t.stateMutability!=null?(e.stateMutability=t.stateMutability,e.constant=e.stateMutability==="view"||e.stateMutability==="pure",t.constant!=null&&!!t.constant!==e.constant&&be.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable=e.stateMutability==="payable",t.payable!=null&&!!t.payable!==e.payable&&be.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):t.payable!=null?(e.payable=!!t.payable,t.constant==null&&!e.payable&&t.type!=="constructor"&&be.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&be.throwArgumentError("cannot have constant payable function","value",t)):t.constant!=null?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):t.type!=="constructor"&&be.throwArgumentError("unable to determine stateMutability","value",t),e}class ln extends Tn{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});e===ke.sighash&&be.throwError("cannot format a constructor for sighash",j.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let r="constructor("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "),r.trim()}static from(e){return typeof e=="string"?ln.fromString(e):ln.fromObject(e)}static fromObject(e){if(ln.isConstructorFragment(e))return e;e.type!=="constructor"&&be.throwArgumentError("invalid constructor object","value",e);let r=t2(e);r.constant&&be.throwArgumentError("constructor cannot be constant","value",e);const n={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Nt.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?K.from(e.gas):null};return new ln(Ji,n)}static fromString(e){let r={type:"constructor"};e=Zy(e,r);let n=e.match(ma);return(!n||n[1].trim()!=="constructor")&&be.throwArgumentError("invalid constructor string","value",e),r.inputs=da(n[2].trim(),!1),e2(n[3].trim(),r),ln.fromObject(r)}static isConstructorFragment(e){return e&&e._isFragment&&e.type==="constructor"}}class un extends ln{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e))),outputs:this.outputs.map(n=>JSON.parse(n.format(e)))});let r="";return e!==ke.sighash&&(r+="function "),r+=this.name+"("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ",e!==ke.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "):this.constant&&(r+="view "),this.outputs&&this.outputs.length&&(r+="returns ("+this.outputs.map(n=>n.format(e)).join(", ")+") "),this.gas!=null&&(r+="@"+this.gas.toString()+" ")),r.trim()}static from(e){return typeof e=="string"?un.fromString(e):un.fromObject(e)}static fromObject(e){if(un.isFunctionFragment(e))return e;e.type!=="function"&&be.throwArgumentError("invalid function object","value",e);let r=t2(e);const n={type:e.type,name:pa(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(Nt.fromObject):[],outputs:e.outputs?e.outputs.map(Nt.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?K.from(e.gas):null};return new un(Ji,n)}static fromString(e){let r={type:"function"};e=Zy(e,r);let n=e.split(" returns ");n.length>2&&be.throwArgumentError("invalid function string","value",e);let i=n[0].match(ma);if(i||be.throwArgumentError("invalid function signature","value",e),r.name=i[1].trim(),r.name&&pa(r.name),r.inputs=da(i[2],!1),e2(i[3].trim(),r),n.length>1){let s=n[1].match(ma);(s[1].trim()!=""||s[3].trim()!="")&&be.throwArgumentError("unexpected tokens","value",e),r.outputs=da(s[2],!1)}else r.outputs=[];return un.fromObject(r)}static isFunctionFragment(e){return e&&e._isFragment&&e.type==="function"}}function Im(t){const e=t.format();return(e==="Error(string)"||e==="Panic(uint256)")&&be.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}class ui extends Tn{format(e){if(e||(e=ke.sighash),ke[e]||be.throwArgumentError("invalid format type","format",e),e===ke.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});let r="";return e!==ke.sighash&&(r+="error "),r+=this.name+"("+this.inputs.map(n=>n.format(e)).join(e===ke.full?", ":",")+") ",r.trim()}static from(e){return typeof e=="string"?ui.fromString(e):ui.fromObject(e)}static fromObject(e){if(ui.isErrorFragment(e))return e;e.type!=="error"&&be.throwArgumentError("invalid error object","value",e);const r={type:e.type,name:pa(e.name),inputs:e.inputs?e.inputs.map(Nt.fromObject):[]};return Im(new ui(Ji,r))}static fromString(e){let r={type:"error"},n=e.match(ma);return n||be.throwArgumentError("invalid error signature","value",e),r.name=n[1].trim(),r.name&&pa(r.name),r.inputs=da(n[2],!1),Im(ui.fromObject(r))}static isErrorFragment(e){return e&&e._isFragment&&e.type==="error"}}function as(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const S_=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function pa(t){return(!t||!t.match(S_))&&be.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}const ma=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function k_(t){t=t.trim();let e=[],r="",n=0;for(let i=0;ithis.wordSize&&e0.throwError("value out-of-bounds",j.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:r.length}),r.length%this.wordSize&&(r=$t([this._padding.slice(r.length%this.wordSize),r])),r}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,r=>{this._data[e]=this._getValue(r)}}}class du{constructor(e,r,n,i){H(this,"_data",oe(e)),H(this,"wordSize",r||32),H(this,"_coerceFunc",n),H(this,"allowLoose",i),this._offset=0}get data(){return ne(this._data)}get consumed(){return this._offset}static coerce(e,r){let n=e.match("^u?int([0-9]+)$");return n&&parseInt(n[1])<=48&&(r=r.toNumber()),r}coerce(e,r){return this._coerceFunc?this._coerceFunc(e,r):du.coerce(e,r)}_peekBytes(e,r,n){let i=Math.ceil(r/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&n&&this._offset+r<=this._data.length?i=r:e0.throwError("data out-of-bounds",j.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(e){return new du(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,r){let n=this._peekBytes(0,e,!!r);return this._offset+=n.length,n.slice(0,e)}readValue(){return K.from(this.readBytes(this.wordSize))}}class M_ extends Wn{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,r){try{r=vt(r)}catch(n){this._throwError(n.message,r)}return e.writeValue(r)}decode(e){return vt(gt(e.readValue().toHexString(),20))}}class C_ extends Wn{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}}const ks=new j(ja);function r2(t,e,r){let n=null;if(Array.isArray(r))n=r;else if(r&&typeof r=="object"){let l={};n=e.map(u=>{const c=u.localName;return c||ks.throwError("cannot encode object for signature with missing names",j.errors.INVALID_ARGUMENT,{argument:"values",coder:u,value:r}),l[c]&&ks.throwError("cannot encode object for signature with duplicate names",j.errors.INVALID_ARGUMENT,{argument:"values",coder:u,value:r}),l[c]=!0,r[c]})}else ks.throwArgumentError("invalid tuple value","tuple",r);e.length!==n.length&&ks.throwArgumentError("types/value length mismatch","tuple",r);let i=new Oh(t.wordSize),s=new Oh(t.wordSize),o=[];e.forEach((l,u)=>{let c=n[u];if(l.dynamic){let h=s.length;l.encode(s,c);let p=i.writeUpdatableValue();o.push(m=>{p(m+h)})}else l.encode(i,c)}),o.forEach(l=>{l(i.length)});let a=t.appendWriter(i);return a+=t.appendWriter(s),a}function n2(t,e){let r=[],n=t.subReader(0);e.forEach(s=>{let o=null;if(s.dynamic){let a=t.readValue(),l=n.subReader(a.toNumber());try{o=s.decode(l)}catch(u){if(u.code===j.errors.BUFFER_OVERRUN)throw u;o=u,o.baseType=s.name,o.name=s.localName,o.type=s.type}}else try{o=s.decode(t)}catch(a){if(a.code===j.errors.BUFFER_OVERRUN)throw a;o=a,o.baseType=s.name,o.name=s.localName,o.type=s.type}o!=null&&r.push(o)});const i=e.reduce((s,o)=>{const a=o.localName;return a&&(s[a]||(s[a]=0),s[a]++),s},{});e.forEach((s,o)=>{let a=s.localName;if(!a||i[a]!==1||(a==="length"&&(a="_length"),r[a]!=null))return;const l=r[o];l instanceof Error?Object.defineProperty(r,a,{enumerable:!0,get:()=>{throw l}}):r[a]=l});for(let s=0;s{throw o}})}return Object.freeze(r)}class P_ extends Wn{constructor(e,r,n){const i=e.type+"["+(r>=0?r:"")+"]",s=r===-1||e.dynamic;super("array",i,n,s),this.coder=e,this.length=r}defaultValue(){const e=this.coder.defaultValue(),r=[];for(let n=0;ne._data.length&&ks.throwError("insufficient data length",j.errors.BUFFER_OVERRUN,{length:e._data.length,count:r}));let n=[];for(let i=0;i{o.dynamic&&(n=!0),i.push(o.type)});const s="tuple("+i.join(",")+")";super("tuple",s,r,n),this.coders=e}defaultValue(){const e=[];this.coders.forEach(n=>{e.push(n.defaultValue())});const r=this.coders.reduce((n,i)=>{const s=i.localName;return s&&(n[s]||(n[s]=0),n[s]++),n},{});return this.coders.forEach((n,i)=>{let s=n.localName;!s||r[s]!==1||(s==="length"&&(s="_length"),e[s]==null&&(e[s]=e[i]))}),Object.freeze(e)}encode(e,r){return r2(e,this.coders,r)}decode(e){return e.coerce(this.name,n2(e,this.coders))}}const ul=new j(ja),B_=new RegExp(/^bytes([0-9]*)$/),D_=new RegExp(/^(u?int)([0-9]*)$/);class F_{constructor(e){H(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new M_(e.name);case"bool":return new R_(e.name);case"string":return new L_(e.name);case"bytes":return new I_(e.name);case"array":return new P_(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new ll((e.components||[]).map(n=>this._getCoder(n)),e.name);case"":return new T_(e.name)}let r=e.type.match(D_);if(r){let n=parseInt(r[2]||"256");return(n===0||n>256||n%8!==0)&&ul.throwArgumentError("invalid "+r[1]+" bit length","param",e),new j_(n/8,r[1]==="int",e.name)}if(r=e.type.match(B_),r){let n=parseInt(r[1]);return(n===0||n>32)&&ul.throwArgumentError("invalid bytes length","param",e),new O_(n,e.name)}return ul.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,r){return new du(e,this._getWordSize(),this.coerceFunc,r)}_getWriter(){return new Oh(this._getWordSize())}getDefaultValue(e){const r=e.map(i=>this._getCoder(Nt.from(i)));return new ll(r,"_").defaultValue()}encode(e,r){e.length!==r.length&&ul.throwError("types/values length mismatch",j.errors.INVALID_ARGUMENT,{count:{types:e.length,values:r.length},value:{types:e,values:r}});const n=e.map(o=>this._getCoder(Nt.from(o))),i=new ll(n,"_"),s=this._getWriter();return i.encode(s,r),s.data}decode(e,r,n){const i=e.map(o=>this._getCoder(Nt.from(o)));return new ll(i,"_").decode(this._getReader(oe(r),n))}}const U_=new F_,ut=new j(ja);class z_ extends Ca{}class $_ extends Ca{}class H_ extends Ca{}class Th extends Ca{static isIndexed(e){return!!(e&&e._isIndexed)}}const V_={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function Om(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);return r.error=e,r}class jh{constructor(e){let r=[];typeof e=="string"?r=JSON.parse(e):r=e,H(this,"fragments",r.map(n=>Tn.from(n)).filter(n=>n!=null)),H(this,"_abiCoder",mr(new.target,"getAbiCoder")()),H(this,"functions",{}),H(this,"errors",{}),H(this,"events",{}),H(this,"structs",{}),this.fragments.forEach(n=>{let i=null;switch(n.type){case"constructor":if(this.deploy){ut.warn("duplicate definition - constructor");return}H(this,"deploy",n);return;case"function":i=this.functions;break;case"event":i=this.events;break;case"error":i=this.errors;break;default:return}let s=n.format();if(i[s]){ut.warn("duplicate definition - "+s);return}i[s]=n}),this.deploy||H(this,"deploy",ln.from({payable:!1,type:"constructor"})),H(this,"_isInterface",!0)}format(e){e||(e=ke.full),e===ke.sighash&&ut.throwArgumentError("interface does not support formatting sighash","format",e);const r=this.fragments.map(n=>n.format(e));return e===ke.json?JSON.stringify(r.map(n=>JSON.parse(n))):r}static getAbiCoder(){return U_}static getAddress(e){return vt(e)}static getSighash(e){return Tt(Es(e.format()),0,4)}static getEventTopic(e){return Es(e.format())}getFunction(e){if(me(e)){for(const n in this.functions)if(e===this.getSighash(n))return this.functions[n];ut.throwArgumentError("no matching function","sighash",e)}if(e.indexOf("(")===-1){const n=e.trim(),i=Object.keys(this.functions).filter(s=>s.split("(")[0]===n);return i.length===0?ut.throwArgumentError("no matching function","name",n):i.length>1&&ut.throwArgumentError("multiple matching functions","name",n),this.functions[i[0]]}const r=this.functions[un.fromString(e).format()];return r||ut.throwArgumentError("no matching function","signature",e),r}getEvent(e){if(me(e)){const n=e.toLowerCase();for(const i in this.events)if(n===this.getEventTopic(i))return this.events[i];ut.throwArgumentError("no matching event","topichash",n)}if(e.indexOf("(")===-1){const n=e.trim(),i=Object.keys(this.events).filter(s=>s.split("(")[0]===n);return i.length===0?ut.throwArgumentError("no matching event","name",n):i.length>1&&ut.throwArgumentError("multiple matching events","name",n),this.events[i[0]]}const r=this.events[Pn.fromString(e).format()];return r||ut.throwArgumentError("no matching event","signature",e),r}getError(e){if(me(e)){const n=mr(this.constructor,"getSighash");for(const i in this.errors){const s=this.errors[i];if(e===n(s))return this.errors[i]}ut.throwArgumentError("no matching error","sighash",e)}if(e.indexOf("(")===-1){const n=e.trim(),i=Object.keys(this.errors).filter(s=>s.split("(")[0]===n);return i.length===0?ut.throwArgumentError("no matching error","name",n):i.length>1&&ut.throwArgumentError("multiple matching errors","name",n),this.errors[i[0]]}const r=this.errors[un.fromString(e).format()];return r||ut.throwArgumentError("no matching error","signature",e),r}getSighash(e){if(typeof e=="string")try{e=this.getFunction(e)}catch(r){try{e=this.getError(e)}catch{throw r}}return mr(this.constructor,"getSighash")(e)}getEventTopic(e){return typeof e=="string"&&(e=this.getEvent(e)),mr(this.constructor,"getEventTopic")(e)}_decodeParams(e,r){return this._abiCoder.decode(e,r)}_encodeParams(e,r){return this._abiCoder.encode(e,r)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,r){typeof e=="string"&&(e=this.getError(e));const n=oe(r);return ne(n.slice(0,4))!==this.getSighash(e)&&ut.throwArgumentError(`data signature does not match error ${e.name}.`,"data",ne(n)),this._decodeParams(e.inputs,n.slice(4))}encodeErrorResult(e,r){return typeof e=="string"&&(e=this.getError(e)),ne($t([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionData(e,r){typeof e=="string"&&(e=this.getFunction(e));const n=oe(r);return ne(n.slice(0,4))!==this.getSighash(e)&&ut.throwArgumentError(`data signature does not match function ${e.name}.`,"data",ne(n)),this._decodeParams(e.inputs,n.slice(4))}encodeFunctionData(e,r){return typeof e=="string"&&(e=this.getFunction(e)),ne($t([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionResult(e,r){typeof e=="string"&&(e=this.getFunction(e));let n=oe(r),i=null,s="",o=null,a=null,l=null;switch(n.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,n)}catch{}break;case 4:{const u=ne(n.slice(0,4)),c=V_[u];if(c)o=this._abiCoder.decode(c.inputs,n.slice(4)),a=c.name,l=c.signature,c.reason&&(i=o[0]),a==="Error"?s=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(o[0])}`:a==="Panic"&&(s=`; VM Exception while processing transaction: reverted with panic code ${o[0]}`);else try{const h=this.getError(u);o=this._abiCoder.decode(h.inputs,n.slice(4)),a=h.name,l=h.format()}catch{}break}}return ut.throwError("call revert exception"+s,j.errors.CALL_EXCEPTION,{method:e.format(),data:ne(r),errorArgs:o,errorName:a,errorSignature:l,reason:i})}encodeFunctionResult(e,r){return typeof e=="string"&&(e=this.getFunction(e)),ne(this._abiCoder.encode(e.outputs,r||[]))}encodeFilterTopics(e,r){typeof e=="string"&&(e=this.getEvent(e)),r.length>e.inputs.length&&ut.throwError("too many arguments for "+e.format(),j.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:r});let n=[];e.anonymous||n.push(this.getEventTopic(e));const i=(s,o)=>s.type==="string"?Es(o):s.type==="bytes"?ot(ne(o)):(s.type==="bool"&&typeof o=="boolean"&&(o=o?"0x01":"0x00"),s.type.match(/^u?int/)&&(o=K.from(o).toHexString()),s.type==="address"&&this._abiCoder.encode(["address"],[o]),gt(ne(o),32));for(r.forEach((s,o)=>{let a=e.inputs[o];if(!a.indexed){s!=null&&ut.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,s);return}s==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?ut.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,s):Array.isArray(s)?n.push(s.map(l=>i(a,l))):n.push(i(a,s))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,r){typeof e=="string"&&(e=this.getEvent(e));const n=[],i=[],s=[];return e.anonymous||n.push(this.getEventTopic(e)),r.length!==e.inputs.length&&ut.throwArgumentError("event arguments/values mismatch","values",r),e.inputs.forEach((o,a)=>{const l=r[a];if(o.indexed)if(o.type==="string")n.push(Es(l));else if(o.type==="bytes")n.push(ot(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(this._abiCoder.encode([o.type],[l]))}else i.push(o),s.push(l)}),{data:this._abiCoder.encode(i,s),topics:n}}decodeEventLog(e,r,n){if(typeof e=="string"&&(e=this.getEvent(e)),n!=null&&!e.anonymous){let p=this.getEventTopic(e);(!me(n[0],32)||n[0].toLowerCase()!==p)&&ut.throwError("fragment/topic mismatch",j.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:p,value:n[0]}),n=n.slice(1)}let i=[],s=[],o=[];e.inputs.forEach((p,m)=>{p.indexed?p.type==="string"||p.type==="bytes"||p.baseType==="tuple"||p.baseType==="array"?(i.push(Nt.fromObject({type:"bytes32",name:p.name})),o.push(!0)):(i.push(p),o.push(!1)):(s.push(p),o.push(!1))});let a=n!=null?this._abiCoder.decode(i,$t(n)):null,l=this._abiCoder.decode(s,r,!0),u=[],c=0,h=0;e.inputs.forEach((p,m)=>{if(p.indexed)if(a==null)u[m]=new Th({_isIndexed:!0,hash:null});else if(o[m])u[m]=new Th({_isIndexed:!0,hash:a[h++]});else try{u[m]=a[h++]}catch(v){u[m]=v}else try{u[m]=l[c++]}catch(v){u[m]=v}if(p.name&&u[p.name]==null){const v=u[m];v instanceof Error?Object.defineProperty(u,p.name,{enumerable:!0,get:()=>{throw Om(`property ${JSON.stringify(p.name)}`,v)}}):u[p.name]=v}});for(let p=0;p{throw Om(`index ${p}`,m)}})}return Object.freeze(u)}parseTransaction(e){let r=this.getFunction(e.data.substring(0,10).toLowerCase());return r?new $_({args:this._abiCoder.decode(r.inputs,"0x"+e.data.substring(10)),functionFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r),value:K.from(e.value||"0")}):null}parseLog(e){let r=this.getEvent(e.topics[0]);return!r||r.anonymous?null:new z_({eventFragment:r,name:r.name,signature:r.format(),topic:this.getEventTopic(r),args:this.decodeEventLog(r,e.data,e.topics)})}parseError(e){const r=ne(e);let n=this.getError(r.substring(0,10).toLowerCase());return n?new H_({args:this._abiCoder.decode(n.inputs,"0x"+r.substring(10)),errorFragment:n,name:n.name,signature:n.format(),sighash:this.getSighash(n)}):null}static isInterface(e){return!!(e&&e._isInterface)}}const q_="contracts/5.7.0";var Yi=function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};const yt=new j(q_);function pu(t,e){return Yi(this,void 0,void 0,function*(){const r=yield e;typeof r!="string"&&yt.throwArgumentError("invalid address or ENS name","name",r);try{return vt(r)}catch{}t||yt.throwError("a provider or signer is needed to resolve ENS names",j.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const n=yield t.resolveName(r);return n==null&&yt.throwArgumentError("resolver or addr is not configured for ENS name","name",r),n})}function Ol(t,e,r){return Yi(this,void 0,void 0,function*(){return Array.isArray(r)?yield Promise.all(r.map((n,i)=>Ol(t,Array.isArray(e)?e[i]:e[n.name],n))):r.type==="address"?yield pu(t,e):r.type==="tuple"?yield Ol(t,e,r.components):r.baseType==="array"?Array.isArray(e)?yield Promise.all(e.map(n=>Ol(t,n,r.arrayChildren))):Promise.reject(yt.makeError("invalid value for array",j.errors.INVALID_ARGUMENT,{argument:"value",value:e})):e})}function ic(t,e,r){return Yi(this,void 0,void 0,function*(){let n={};r.length===e.inputs.length+1&&typeof r[r.length-1]=="object"&&(n=at(r.pop())),yt.checkArgumentCount(r.length,e.inputs.length,"passed to contract"),t.signer?n.from?n.from=xt({override:pu(t.signer,n.from),signer:t.signer.getAddress()}).then(u=>Yi(this,void 0,void 0,function*(){return vt(u.signer)!==u.override&&yt.throwError("Contract with a Signer cannot override from",j.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),u.override})):n.from=t.signer.getAddress():n.from&&(n.from=pu(t.provider,n.from));const i=yield xt({args:Ol(t.signer||t.provider,r,e.inputs),address:t.resolvedAddress,overrides:xt(n)||{}}),s=t.interface.encodeFunctionData(e,i.args),o={data:s,to:i.address},a=i.overrides;if(a.nonce!=null&&(o.nonce=K.from(a.nonce).toNumber()),a.gasLimit!=null&&(o.gasLimit=K.from(a.gasLimit)),a.gasPrice!=null&&(o.gasPrice=K.from(a.gasPrice)),a.maxFeePerGas!=null&&(o.maxFeePerGas=K.from(a.maxFeePerGas)),a.maxPriorityFeePerGas!=null&&(o.maxPriorityFeePerGas=K.from(a.maxPriorityFeePerGas)),a.from!=null&&(o.from=a.from),a.type!=null&&(o.type=a.type),a.accessList!=null&&(o.accessList=rs(a.accessList)),o.gasLimit==null&&e.gas!=null){let u=21e3;const c=oe(s);for(let h=0;hn[u]!=null);return l.length&&yt.throwError(`cannot override ${l.map(u=>JSON.stringify(u)).join(",")}`,j.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:l}),o})}function G_(t,e){return function(...r){return ic(t,e,r)}}function W_(t,e){const r=t.signer||t.provider;return function(...n){return Yi(this,void 0,void 0,function*(){r||yt.throwError("estimate require a provider or signer",j.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const i=yield ic(t,e,n);return yield r.estimateGas(i)})}}function K_(t,e){const r=e.wait.bind(e);e.wait=n=>r(n).then(i=>(i.events=i.logs.map(s=>{let o=lr(s),a=null;try{a=t.interface.parseLog(s)}catch{}return a&&(o.args=a.args,o.decode=(l,u)=>t.interface.decodeEventLog(a.eventFragment,l,u),o.event=a.name,o.eventSignature=a.signature),o.removeListener=()=>t.provider,o.getBlock=()=>t.provider.getBlock(i.blockHash),o.getTransaction=()=>t.provider.getTransaction(i.transactionHash),o.getTransactionReceipt=()=>Promise.resolve(i),o}),i))}function s2(t,e,r){const n=t.signer||t.provider;return function(...i){return Yi(this,void 0,void 0,function*(){let s;if(i.length===e.inputs.length+1&&typeof i[i.length-1]=="object"){const l=at(i.pop());l.blockTag!=null&&(s=yield l.blockTag),delete l.blockTag,i.push(l)}t.deployTransaction!=null&&(yield t._deployed(s));const o=yield ic(t,e,i),a=yield n.call(o,s);try{let l=t.interface.decodeFunctionResult(e,a);return r&&e.outputs.length===1&&(l=l[0]),l}catch(l){throw l.code===j.errors.CALL_EXCEPTION&&(l.address=t.address,l.args=i,l.transaction=o),l}})}}function Q_(t,e){return function(...r){return Yi(this,void 0,void 0,function*(){t.signer||yt.throwError("sending a transaction requires a signer",j.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.deployTransaction!=null&&(yield t._deployed());const n=yield ic(t,e,r),i=yield t.signer.sendTransaction(n);return K_(t,i),i})}}function Tm(t,e,r){return e.constant?s2(t,e,r):Q_(t,e)}function o2(t){return t.address&&(t.topics==null||t.topics.length===0)?"*":(t.address||"*")+"@"+(t.topics?t.topics.map(e=>Array.isArray(e)?e.join("|"):e).join(":"):"")}class ga{constructor(e,r){H(this,"tag",e),H(this,"filter",r),this._listeners=[]}addListener(e,r){this._listeners.push({listener:e,once:r})}removeListener(e){let r=!1;this._listeners=this._listeners.filter(n=>r||n.listener!==e?!0:(r=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(e=>e.listener)}listenerCount(){return this._listeners.length}run(e){const r=this.listenerCount();return this._listeners=this._listeners.filter(n=>{const i=e.slice();return setTimeout(()=>{n.listener.apply(this,i)},0),!n.once}),r}prepareEvent(e){}getEmit(e){return[e]}}class J_ extends ga{constructor(){super("error",null)}}class jm extends ga{constructor(e,r,n,i){const s={address:e};let o=r.getEventTopic(n);i?(o!==i[0]&&yt.throwArgumentError("topic mismatch","topics",i),s.topics=i.slice()):s.topics=[o],super(o2(s),s),H(this,"address",e),H(this,"interface",r),H(this,"fragment",n)}prepareEvent(e){super.prepareEvent(e),e.event=this.fragment.name,e.eventSignature=this.fragment.format(),e.decode=(r,n)=>this.interface.decodeEventLog(this.fragment,r,n);try{e.args=this.interface.decodeEventLog(this.fragment,e.data,e.topics)}catch(r){e.args=null,e.decodeError=r}}getEmit(e){const r=N_(e.args);if(r.length)throw r[0].error;const n=(e.args||[]).slice();return n.push(e),n}}class Lm extends ga{constructor(e,r){super("*",{address:e}),H(this,"address",e),H(this,"interface",r)}prepareEvent(e){super.prepareEvent(e);try{const r=this.interface.parseLog(e);e.event=r.name,e.eventSignature=r.signature,e.decode=(n,i)=>this.interface.decodeEventLog(r.eventFragment,n,i),e.args=r.args}catch{}}}class Y_{constructor(e,r,n){H(this,"interface",mr(new.target,"getInterface")(r)),n==null?(H(this,"provider",null),H(this,"signer",null)):Ta.isSigner(n)?(H(this,"provider",n.provider||null),H(this,"signer",n)):ro.isProvider(n)?(H(this,"provider",n),H(this,"signer",null)):yt.throwArgumentError("invalid signer or provider","signerOrProvider",n),H(this,"callStatic",{}),H(this,"estimateGas",{}),H(this,"functions",{}),H(this,"populateTransaction",{}),H(this,"filters",{});{const o={};Object.keys(this.interface.events).forEach(a=>{const l=this.interface.events[a];H(this.filters,a,(...u)=>({address:this.address,topics:this.interface.encodeFilterTopics(l,u)})),o[l.name]||(o[l.name]=[]),o[l.name].push(a)}),Object.keys(o).forEach(a=>{const l=o[a];l.length===1?H(this.filters,a,this.filters[l[0]]):yt.warn(`Duplicate definition of ${a} (${l.join(", ")})`)})}if(H(this,"_runningEvents",{}),H(this,"_wrappedEmits",{}),e==null&&yt.throwArgumentError("invalid contract address or ENS name","addressOrName",e),H(this,"address",e),this.provider)H(this,"resolvedAddress",pu(this.provider,e));else try{H(this,"resolvedAddress",Promise.resolve(vt(e)))}catch{yt.throwError("provider is required to use ENS name as contract address",j.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(o=>{});const i={},s={};Object.keys(this.interface.functions).forEach(o=>{const a=this.interface.functions[o];if(s[o]){yt.warn(`Duplicate ABI entry for ${JSON.stringify(o)}`);return}s[o]=!0;{const l=a.name;i[`%${l}`]||(i[`%${l}`]=[]),i[`%${l}`].push(o)}this[o]==null&&H(this,o,Tm(this,a,!0)),this.functions[o]==null&&H(this.functions,o,Tm(this,a,!1)),this.callStatic[o]==null&&H(this.callStatic,o,s2(this,a,!0)),this.populateTransaction[o]==null&&H(this.populateTransaction,o,G_(this,a)),this.estimateGas[o]==null&&H(this.estimateGas,o,W_(this,a))}),Object.keys(i).forEach(o=>{const a=i[o];if(a.length>1)return;o=o.substring(1);const l=a[0];try{this[o]==null&&H(this,o,this[l])}catch{}this.functions[o]==null&&H(this.functions,o,this.functions[l]),this.callStatic[o]==null&&H(this.callStatic,o,this.callStatic[l]),this.populateTransaction[o]==null&&H(this.populateTransaction,o,this.populateTransaction[l]),this.estimateGas[o]==null&&H(this.estimateGas,o,this.estimateGas[l])})}static getContractAddress(e){return Hd(e)}static getInterface(e){return jh.isInterface(e)?e:new jh(e)}deployed(){return this._deployed()}_deployed(e){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,e).then(r=>(r==="0x"&&yt.throwError("contract not deployed",j.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(e){this.signer||yt.throwError("sending a transactions require a signer",j.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const r=at(e||{});return["from","to"].forEach(function(n){r[n]!=null&&yt.throwError("cannot override "+n,j.errors.UNSUPPORTED_OPERATION,{operation:n})}),r.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(r))}connect(e){typeof e=="string"&&(e=new Jd(e,this.provider));const r=new this.constructor(this.address,this.interface,e);return this.deployTransaction&&H(r,"deployTransaction",this.deployTransaction),r}attach(e){return new this.constructor(e,this.interface,this.signer||this.provider)}static isIndexed(e){return Th.isIndexed(e)}_normalizeRunningEvent(e){return this._runningEvents[e.tag]?this._runningEvents[e.tag]:e}_getRunningEvent(e){if(typeof e=="string"){if(e==="error")return this._normalizeRunningEvent(new J_);if(e==="event")return this._normalizeRunningEvent(new ga("event",null));if(e==="*")return this._normalizeRunningEvent(new Lm(this.address,this.interface));const r=this.interface.getEvent(e);return this._normalizeRunningEvent(new jm(this.address,this.interface,r))}if(e.topics&&e.topics.length>0){try{const n=e.topics[0];if(typeof n!="string")throw new Error("invalid topic");const i=this.interface.getEvent(n);return this._normalizeRunningEvent(new jm(this.address,this.interface,i,e.topics))}catch{}const r={address:this.address,topics:e.topics};return this._normalizeRunningEvent(new ga(o2(r),r))}return this._normalizeRunningEvent(new Lm(this.address,this.interface))}_checkRunningEvents(e){if(e.listenerCount()===0){delete this._runningEvents[e.tag];const r=this._wrappedEmits[e.tag];r&&e.filter&&(this.provider.off(e.filter,r),delete this._wrappedEmits[e.tag])}}_wrapEvent(e,r,n){const i=lr(r);return i.removeListener=()=>{n&&(e.removeListener(n),this._checkRunningEvents(e))},i.getBlock=()=>this.provider.getBlock(r.blockHash),i.getTransaction=()=>this.provider.getTransaction(r.transactionHash),i.getTransactionReceipt=()=>this.provider.getTransactionReceipt(r.transactionHash),e.prepareEvent(i),i}_addEventListener(e,r,n){if(this.provider||yt.throwError("events require a provider or a signer with a provider",j.errors.UNSUPPORTED_OPERATION,{operation:"once"}),e.addListener(r,n),this._runningEvents[e.tag]=e,!this._wrappedEmits[e.tag]){const i=s=>{let o=this._wrapEvent(e,s,r);if(o.decodeError==null)try{const a=e.getEmit(o);this.emit(e.filter,...a)}catch(a){o.decodeError=a.error}e.filter!=null&&this.emit("event",o),o.decodeError!=null&&this.emit("error",o.decodeError,o)};this._wrappedEmits[e.tag]=i,e.filter!=null&&this.provider.on(e.filter,i)}}queryFilter(e,r,n){const i=this._getRunningEvent(e),s=at(i.filter);return typeof r=="string"&&me(r,32)?(n!=null&&yt.throwArgumentError("cannot specify toBlock with blockhash","toBlock",n),s.blockHash=r):(s.fromBlock=r??0,s.toBlock=n??"latest"),this.provider.getLogs(s).then(o=>o.map(a=>this._wrapEvent(i,a,null)))}on(e,r){return this._addEventListener(this._getRunningEvent(e),r,!1),this}once(e,r){return this._addEventListener(this._getRunningEvent(e),r,!0),this}emit(e,...r){if(!this.provider)return!1;const n=this._getRunningEvent(e),i=n.run(r)>0;return this._checkRunningEvents(n),i}listenerCount(e){return this.provider?e==null?Object.keys(this._runningEvents).reduce((r,n)=>r+this._runningEvents[n].listenerCount(),0):this._getRunningEvent(e).listenerCount():0}listeners(e){if(!this.provider)return[];if(e==null){const r=[];for(let n in this._runningEvents)this._runningEvents[n].listeners().forEach(i=>{r.push(i)});return r}return this._getRunningEvent(e).listeners()}removeAllListeners(e){if(!this.provider)return this;if(e==null){for(const n in this._runningEvents){const i=this._runningEvents[n];i.removeAllListeners(),this._checkRunningEvents(i)}return this}const r=this._getRunningEvent(e);return r.removeAllListeners(),this._checkRunningEvents(r),this}off(e,r){if(!this.provider)return this;const n=this._getRunningEvent(e);return n.removeListener(r),this._checkRunningEvents(n),this}removeListener(e,r){return this.off(e,r)}}class X_ extends Y_{}const Z_="solidity/5.7.0",e6=new RegExp("^bytes([0-9]+)$"),t6=new RegExp("^(u?int)([0-9]*)$"),r6=new RegExp("^(.*)\\[([0-9]*)\\]$"),n6="0000000000000000000000000000000000000000000000000000000000000000",ls=new j(Z_);function a2(t,e,r){switch(t){case"address":return r?Sl(e,32):oe(e);case"string":return yr(e);case"bytes":return oe(e);case"bool":return e=e?"0x01":"0x00",r?Sl(e,32):oe(e)}let n=t.match(t6);if(n){let i=parseInt(n[2]||"256");return(n[2]&&String(i)!==n[2]||i%8!==0||i===0||i>256)&&ls.throwArgumentError("invalid number type","type",t),r&&(i=256),e=K.from(e).toTwos(i),Sl(e,i/8)}if(n=t.match(e6),n){const i=parseInt(n[1]);return(String(i)!==n[1]||i===0||i>32)&&ls.throwArgumentError("invalid bytes type","type",t),oe(e).byteLength!==i&&ls.throwArgumentError(`invalid value for ${t}`,"value",e),r?oe((e+n6).substring(0,66)):e}if(n=t.match(r6),n&&Array.isArray(e)){const i=n[1];parseInt(n[2]||String(e.length))!=e.length&&ls.throwArgumentError(`invalid array length for ${t}`,"value",e);const o=[];return e.forEach(function(a){o.push(a2(i,a,!0))}),$t(o)}return ls.throwArgumentError("invalid type","type",t)}function l2(t,e){t.length!=e.length&&ls.throwArgumentError("wrong number of values; expected ${ types.length }","values",e);const r=[];return t.forEach(function(n,i){r.push(a2(n,e[i]))}),ne($t(r))}function i6(t,e){return ot(l2(t,e))}const vf=[{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"approve",inputs:[{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"apps",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherKnsNodeId",type:"bytes32",internalType:"bytes32"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"balanceOf",inputs:[{name:"owner",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"contractURI",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"getApproved",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"getInitializedVersion",inputs:[],outputs:[{name:"",type:"uint64",internalType:"uint64"}],stateMutability:"view"},{type:"function",name:"getPackageId",inputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherName",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"pure"},{type:"function",name:"getPackageInfo",inputs:[{name:"package",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"tuple",internalType:"struct IKinodeAppStore.PackageInfo",components:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherKnsNodeId",type:"bytes32",internalType:"bytes32"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}]}],stateMutability:"view"},{type:"function",name:"getPackageInfo",inputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherName",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"tuple",internalType:"struct IKinodeAppStore.PackageInfo",components:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherKnsNodeId",type:"bytes32",internalType:"bytes32"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}]}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[{name:"_knsResolver",type:"address",internalType:"contract KNSRegistryResolver"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"isApprovedForAll",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"operator",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"knsResolver",inputs:[],outputs:[{name:"",type:"address",internalType:"contract KNSRegistryResolver"}],stateMutability:"view"},{type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"ownerOf",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"registerApp",inputs:[{name:"packageName",type:"string",internalType:"string"},{name:"publisherName",type:"bytes",internalType:"bytes"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setApprovalForAll",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"approved",type:"bool",internalType:"bool"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"supportsInterface",inputs:[{name:"interfaceId",type:"bytes4",internalType:"bytes4"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"tokenURI",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"transferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"unlistPacakge",inputs:[{name:"package",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateContractURI",inputs:[{name:"uri",type:"string",internalType:"string"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateMetadata",inputs:[{name:"package",type:"uint256",internalType:"uint256"},{name:"metadataUrl",type:"string",internalType:"string"},{name:"metadataHash",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"upgradeToAndCall",inputs:[{name:"newImplementation",type:"address",internalType:"address"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"event",name:"AppMetadataUpdated",inputs:[{name:"package",type:"uint256",indexed:!0,internalType:"uint256"},{name:"metadataUrl",type:"string",indexed:!1,internalType:"string"},{name:"metadataHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"AppRegistered",inputs:[{name:"package",type:"uint256",indexed:!0,internalType:"uint256"},{name:"packageName",type:"string",indexed:!1,internalType:"string"},{name:"publisherName",type:"bytes",indexed:!1,internalType:"bytes"},{name:"metadataUrl",type:"string",indexed:!1,internalType:"string"},{name:"metadataHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"Approval",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"ApprovalForAll",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"operator",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"version",type:"uint64",indexed:!1,internalType:"uint64"}],anonymous:!1},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Transfer",inputs:[{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Upgraded",inputs:[{name:"implementation",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressEmptyCode",inputs:[{name:"target",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ERC721IncorrectOwner",inputs:[{name:"sender",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InsufficientApproval",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ERC721InvalidApprover",inputs:[{name:"approver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOperator",inputs:[{name:"operator",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidReceiver",inputs:[{name:"receiver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidSender",inputs:[{name:"sender",type:"address",internalType:"address"}]},{type:"error",name:"ERC721NonexistentToken",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"FailedInnerCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"Unauthorized",inputs:[]}];class u2{static createInterface(){return new jh(vf)}static connect(e,r){return new X_(e,vf,r)}}o0(u2,"abi",vf);var c2={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Bm=Wr.createContext&&Wr.createContext(c2),s6=["attr","size","title"];function o6(t,e){if(t==null)return{};var r=a6(t,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function a6(t,e){if(t==null)return{};var r={},n=Object.keys(t),i,s;for(s=0;s=0)&&(r[i]=t[i]);return r}function mu(){return mu=Object.assign?Object.assign.bind():function(t){for(var e=1;eWr.createElement(e.tag,gu({key:r},e.attr),f2(e.child)))}function Pt(t){return e=>Wr.createElement(f6,mu({attr:gu({},t.attr)},e),f2(t.child))}function f6(t){var e=r=>{var{attr:n,size:i,title:s}=t,o=o6(t,s6),a=i||r.size||"1em",l;return r.className&&(l=r.className),t.className&&(l=(l?l+" ":"")+t.className),Wr.createElement("svg",mu({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,n,o,{className:l,style:gu(gu({color:t.color||r.color},r.style),t.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&Wr.createElement("title",null,s),t.children)};return Bm!==void 0?Wr.createElement(Bm.Consumer,null,r=>e(r)):e(c2)}function h6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"},child:[]}]})(t)}function d6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"},child:[]}]})(t)}function p6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z"},child:[]}]})(t)}function h2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"},child:[]}]})(t)}function m6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(t)}var g6={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Fm=t=>{let e;const r=new Set,n=(l,u)=>{const c=typeof l=="function"?l(e):l;if(!Object.is(c,e)){const h=e;e=u??(typeof c!="object"||c===null)?c:Object.assign({},e,c),r.forEach(p=>p(e,h))}},i=()=>e,a={setState:n,getState:i,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{(g6?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,i,a),a},v6=t=>t?Fm(t):Fm;var d2={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:y6}=Wr,{useSyncExternalStoreWithSelector:w6}=Qu;let Um=!1;function x6(t,e=t.getState,r){(d2?"production":void 0)!=="production"&&r&&!Um&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Um=!0);const n=w6(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return y6(n),n}const zm=t=>{(d2?"production":void 0)!=="production"&&typeof t!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof t=="function"?v6(t):t,r=(n,i)=>x6(e,n,i);return Object.assign(r,e),r},b6=t=>t?zm(t):zm;var E6={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};function p2(t,e){let r;try{r=t()}catch{return}return{getItem:i=>{var s;const o=l=>l===null?null:JSON.parse(l,e==null?void 0:e.reviver),a=(s=r.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>r.setItem(i,JSON.stringify(s,e==null?void 0:e.replacer)),removeItem:i=>r.removeItem(i)}}const va=t=>e=>{try{const r=t(e);return r instanceof Promise?r:{then(n){return va(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return va(n)(r)}}}},A6=(t,e)=>(r,n,i)=>{let s={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:k=>k,version:0,merge:(k,x)=>({...x,...k}),...e},o=!1;const a=new Set,l=new Set;let u;try{u=s.getStorage()}catch{}if(!u)return t((...k)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...k)},n,i);const c=va(s.serialize),h=()=>{const k=s.partialize({...n()});let x;const w=c({state:k,version:s.version}).then(A=>u.setItem(s.name,A)).catch(A=>{x=A});if(x)throw x;return w},p=i.setState;i.setState=(k,x)=>{p(k,x),h()};const m=t((...k)=>{r(...k),h()},n,i);let v;const b=()=>{var k;if(!u)return;o=!1,a.forEach(w=>w(n()));const x=((k=s.onRehydrateStorage)==null?void 0:k.call(s,n()))||void 0;return va(u.getItem.bind(u))(s.name).then(w=>{if(w)return s.deserialize(w)}).then(w=>{if(w)if(typeof w.version=="number"&&w.version!==s.version){if(s.migrate)return s.migrate(w.state,w.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return w.state}).then(w=>{var A;return v=s.merge(w,(A=n())!=null?A:m),r(v,!0),h()}).then(()=>{x==null||x(v,void 0),o=!0,l.forEach(w=>w(v))}).catch(w=>{x==null||x(void 0,w)})};return i.persist={setOptions:k=>{s={...s,...k},k.getStorage&&(u=k.getStorage())},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>b(),hasHydrated:()=>o,onHydrate:k=>(a.add(k),()=>{a.delete(k)}),onFinishHydration:k=>(l.add(k),()=>{l.delete(k)})},b(),v||m},_6=(t,e)=>(r,n,i)=>{let s={storage:p2(()=>localStorage),partialize:b=>b,version:0,merge:(b,k)=>({...k,...b}),...e},o=!1;const a=new Set,l=new Set;let u=s.storage;if(!u)return t((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...b)},n,i);const c=()=>{const b=s.partialize({...n()});return u.setItem(s.name,{state:b,version:s.version})},h=i.setState;i.setState=(b,k)=>{h(b,k),c()};const p=t((...b)=>{r(...b),c()},n,i);let m;const v=()=>{var b,k;if(!u)return;o=!1,a.forEach(w=>{var A;return w((A=n())!=null?A:p)});const x=((k=s.onRehydrateStorage)==null?void 0:k.call(s,(b=n())!=null?b:p))||void 0;return va(u.getItem.bind(u))(s.name).then(w=>{if(w)if(typeof w.version=="number"&&w.version!==s.version){if(s.migrate)return s.migrate(w.state,w.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return w.state}).then(w=>{var A;return m=s.merge(w,(A=n())!=null?A:p),r(m,!0),c()}).then(()=>{x==null||x(m,void 0),m=n(),o=!0,l.forEach(w=>w(m))}).catch(w=>{x==null||x(void 0,w)})};return i.persist={setOptions:b=>{s={...s,...b},b.storage&&(u=b.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>v(),hasHydrated:()=>o,onHydrate:b=>(a.add(b),()=>{a.delete(b)}),onFinishHydration:b=>(l.add(b),()=>{l.delete(b)})},s.skipHydration||v(),m||p},S6=(t,e)=>"getStorage"in e||"serialize"in e||"deserialize"in e?((E6?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),A6(t,e)):_6(t,e),k6=S6;var kr=(t=>(t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.FOUND=302]="FOUND",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t))(kr||{});const Ee=t=>`${t.package}:${t.publisher}`,Js=t=>{var e;return((e=t.metadata)==null?void 0:e.name)||Ee(t)},yf=t=>{var e,r;return t.publisher==="sys"?"system":(e=t.state)!=null&&e.our_version&&!((r=t.state)!=null&&r.caps_approved)?"downloaded":t.metadata?"installed":"local"},er="/main:app_store:sys",cl=(t,e)=>t.package===e.package&&t.publisher===e.publisher,Pi=b6()(k6((t,e)=>({myApps:{downloaded:[],installed:[],local:[],system:[]},listedApps:[],searchResults:[],query:"",getMyApps:async()=>{const r=await e().getListedApps(),s=(await(await fetch(`${er}/apps`)).json()).reduce((o,a)=>{const l=yf(a);return r.find(u=>u.metadata_hash===a.metadata_hash)&&console.log({listedappmatch:a}),o[l].push(a),o},{downloaded:[],installed:[],local:[],system:[]});return t(()=>({myApps:s})),s},getListedApps:async()=>{const n=await(await fetch(`${er}/apps/listed`)).json();return t({listedApps:n}),n},getMyApp:async r=>{const i=await(await fetch(`${er}/apps/${Ee(r)}`)).json(),s=yf(i),o=e().myApps;o[s]=o[s].map(l=>cl(l,i)?i:l);const a=[...e().listedApps].map(l=>cl(l,i)?i:l);return t({myApps:o,listedApps:a}),i},installApp:async r=>{if((await fetch(`${er}/apps/${Ee(r)}/caps`,{method:"POST"})).status!==kr.OK)throw new Error(`Failed to approve caps for app: ${Ee(r)}`);if((await fetch(`${er}/apps/${Ee(r)}`,{method:"POST"})).status!==kr.CREATED)throw new Error(`Failed to install app: ${Ee(r)}`)},updateApp:async r=>{if((await fetch(`${er}/apps/${Ee(r)}`,{method:"PUT"})).status!==kr.NO_CONTENT)throw new Error(`Failed to update app: ${Ee(r)}`)},uninstallApp:async r=>{if(!confirm(`Are you sure you want to remove ${Ee(r)}?`))return;if((await fetch(`${er}/apps/${Ee(r)}`,{method:"DELETE"})).status!==kr.NO_CONTENT)throw new Error(`Failed to remove app: ${Ee(r)}`);const i={...e().myApps},s=yf(r);i[s]=i[s].filter(a=>!cl(a,r));const o=e().listedApps.map(a=>cl(a,r)?{...a,state:void 0,installed:!1}:a);t({myApps:i,listedApps:o})},getListedApp:async r=>{const n=await fetch(`${er}/apps/listed/${r}`);if(n.status!==kr.OK)throw new Error(`Failed to get app: ${r}`);return await n.json()},downloadApp:async(r,n)=>{if((await fetch(`${er}/apps/listed/${Ee(r)}`,{method:"POST",body:JSON.stringify({download_from:n})})).status!==kr.CREATED)throw new Error(`Failed to get app: ${Ee(r)}`)},getCaps:async r=>{const n=await fetch(`${er}/apps/${Ee(r)}/caps`);if(n.status!==kr.OK)throw new Error(`Failed to get app: ${Ee(r)}`);const i=await n.json();return console.log(i[0]),i[0]},approveCaps:async r=>{if((await fetch(`${er}/apps/${Ee(r)}/caps`,{method:"POST"})).status!==kr.OK)throw new Error(`Failed to get app: ${Ee(r)}`)},rebuildIndex:async()=>{if((await fetch(`${er}/apps/rebuild-index`,{method:"POST"})).status!==kr.OK)throw new Error("Failed to rebuild index")},setMirroring:async(r,n)=>{if((await fetch(`${er}/apps/${Ee(r)}/mirror`,{method:n?"PUT":"DELETE"})).status!==kr.OK)throw new Error(`Failed to start mirror: ${Ee(r)}`);e().getMyApp(r)},setAutoUpdate:async(r,n)=>{if((await fetch(`${er}/apps/${Ee(r)}/auto-update`,{method:n?"PUT":"DELETE"})).status!==kr.OK)throw new Error(`Failed to change auto update: ${Ee(r)}`);e().getMyApp(r)},get:e,set:t}),{name:"app_store",storage:p2(()=>sessionStorage)}));var m2={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(t){(function(){var e={}.hasOwnProperty;function r(){for(var s="",o=0;owindow.innerWidth<=600,M6=({text:t,className:e,size:r})=>{var o;const i=`/icons/${((o=t.split("").pop())==null?void 0:o.toUpperCase())||"0"}`;if(!i)return null;const s=Kn();return _.jsx("img",{src:i,className:ue("m-0 align-self-center rounded-full",{"h-32 w-32":!s&&r==="large","h-18 w-18":!s&&r==="medium","h-12 w-12":s||r==="small"},e)})};function g2({app:t,size:e="medium",overrideImageSize:r,...n}){var a,l,u,c,h;const i=Kn(),s=_.jsx("div",{className:ue({"text-3xl font-[OpenSans]":!i&&e==="large","text-xl":!i&&e!=="large","text-lg":i}),children:((a=t.metadata)==null?void 0:a.name)||Ee(t)}),o=r||e;return _.jsxs("div",{...n,className:ue("flex w-full justify-content-start",e,n.className,{"flex-col":e==="small","gap-2":i,"gap-4":!i,"gap-6":!i&&e==="large"}),children:[e==="small"&&s,(l=t.metadata)!=null&&l.image?_.jsx("img",{src:t.metadata.image,alt:"app icon",className:ue("object-cover",{rounded:!o,"rounded-md":o==="small","rounded-lg":o==="medium","rounded-2xl":o==="large","h-32":o==="large"||o==="small","h-20":o==="medium"})}):_.jsx(M6,{text:t.metadata_hash||((c=(u=t.state)==null?void 0:u.our_version)==null?void 0:c.toString())||"",size:o}),_.jsxs("div",{className:ue("flex flex-col",{"gap-2":i,"gap-4 max-w-3/4":i&&e!=="small"}),children:[e!=="small"&&s,((h=t.metadata)==null?void 0:h.description)&&_.jsx("div",{style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},className:ue({"text-2xl":e==="large"}),children:t.metadata.description})]})]})}function C6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"},child:[]}]})(t)}function P6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M386.3 160H336c-17.7 0-32 14.3-32 32s14.3 32 32 32H464c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32s-32 14.3-32 32v51.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0s-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3s163.8-62.5 226.3 0L386.3 160z"},child:[]}]})(t)}function v2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},child:[]}]})(t)}function R6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M222.7 32.1c5 16.9-4.6 34.8-21.5 39.8C121.8 95.6 64 169.1 64 256c0 106 86 192 192 192s192-86 192-192c0-86.9-57.8-160.4-137.1-184.1c-16.9-5-26.6-22.9-21.5-39.8s22.9-26.6 39.8-21.5C434.9 42.1 512 140 512 256c0 141.4-114.6 256-256 256S0 397.4 0 256C0 140 77.1 42.1 182.9 10.6c16.9-5 34.8 4.6 39.8 21.5z"},child:[]}]})(t)}function y2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"},child:[]}]})(t)}function I6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M352 256c0 22.2-1.2 43.6-3.3 64H163.3c-2.2-20.4-3.3-41.8-3.3-64s1.2-43.6 3.3-64H348.7c2.2 20.4 3.3 41.8 3.3 64zm28.8-64H503.9c5.3 20.5 8.1 41.9 8.1 64s-2.8 43.5-8.1 64H380.8c2.1-20.6 3.2-42 3.2-64s-1.1-43.4-3.2-64zm112.6-32H376.7c-10-63.9-29.8-117.4-55.3-151.6c78.3 20.7 142 77.5 171.9 151.6zm-149.1 0H167.7c6.1-36.4 15.5-68.6 27-94.7c10.5-23.6 22.2-40.7 33.5-51.5C239.4 3.2 248.7 0 256 0s16.6 3.2 27.8 13.8c11.3 10.8 23 27.9 33.5 51.5c11.6 26 20.9 58.2 27 94.7zm-209 0H18.6C48.6 85.9 112.2 29.1 190.6 8.4C165.1 42.6 145.3 96.1 135.3 160zM8.1 192H131.2c-2.1 20.6-3.2 42-3.2 64s1.1 43.4 3.2 64H8.1C2.8 299.5 0 278.1 0 256s2.8-43.5 8.1-64zM194.7 446.6c-11.6-26-20.9-58.2-27-94.6H344.3c-6.1 36.4-15.5 68.6-27 94.6c-10.5 23.6-22.2 40.7-33.5 51.5C272.6 508.8 263.3 512 256 512s-16.6-3.2-27.8-13.8c-11.3-10.8-23-27.9-33.5-51.5zM135.3 352c10 63.9 29.8 117.4 55.3 151.6C112.2 482.9 48.6 426.1 18.6 352H135.3zm358.1 0c-30 74.1-93.6 130.9-171.9 151.6c25.5-34.2 45.2-87.7 55.3-151.6H493.4z"},child:[]}]})(t)}function O6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M32 32C14.3 32 0 46.3 0 64S14.3 96 32 96h96V416H32c-17.7 0-32 14.3-32 32s14.3 32 32 32H288c17.7 0 32-14.3 32-32s-14.3-32-32-32H192V96h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H160 32z"},child:[]}]})(t)}function T6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"},child:[]}]})(t)}function j6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M72 88a56 56 0 1 1 112 0A56 56 0 1 1 72 88zM64 245.7C54 256.9 48 271.8 48 288s6 31.1 16 42.3V245.7zm144.4-49.3C178.7 222.7 160 261.2 160 304c0 34.3 12 65.8 32 90.5V416c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V389.2C26.2 371.2 0 332.7 0 288c0-61.9 50.1-112 112-112h32c24 0 46.2 7.5 64.4 20.3zM448 416V394.5c20-24.7 32-56.2 32-90.5c0-42.8-18.7-81.3-48.4-107.7C449.8 183.5 472 176 496 176h32c61.9 0 112 50.1 112 112c0 44.7-26.2 83.2-64 101.2V416c0 17.7-14.3 32-32 32H480c-17.7 0-32-14.3-32-32zm8-328a56 56 0 1 1 112 0A56 56 0 1 1 456 88zM576 245.7v84.7c10-11.3 16-26.1 16-42.3s-6-31.1-16-42.3zM320 32a64 64 0 1 1 0 128 64 64 0 1 1 0-128zM240 304c0 16.2 6 31 16 42.3V261.7c-10 11.3-16 26.1-16 42.3zm144-42.3v84.7c10-11.3 16-26.1 16-42.3s-6-31.1-16-42.3zM448 304c0 44.7-26.2 83.2-64 101.2V448c0 17.7-14.3 32-32 32H288c-17.7 0-32-14.3-32-32V405.2c-37.8-18-64-56.5-64-101.2c0-61.9 50.1-112 112-112h32c61.9 0 112 50.1 112 112z"},child:[]}]})(t)}function L6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80V432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z"},child:[]}]})(t)}function B6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M32 32c17.7 0 32 14.3 32 32V288c0 70.7 57.3 128 128 128s128-57.3 128-128V64c0-17.7 14.3-32 32-32s32 14.3 32 32V288c0 106-86 192-192 192S0 394 0 288V64C0 46.3 14.3 32 32 32z"},child:[]}]})(t)}function D6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M288 109.3V352c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-73.4 73.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0l128 128c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L288 109.3zM64 352H192c0 35.3 28.7 64 64 64s64-28.7 64-64H448c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V416c0-35.3 28.7-64 64-64zM432 456a24 24 0 1 0 0-48 24 24 0 1 0 0 48z"},child:[]}]})(t)}function w2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M376.6 84.5c11.3-13.6 9.5-33.8-4.1-45.1s-33.8-9.5-45.1 4.1L192 206 56.6 43.5C45.3 29.9 25.1 28.1 11.5 39.4S-3.9 70.9 7.4 84.5L150.3 256 7.4 427.5c-11.3 13.6-9.5 33.8 4.1 45.1s33.8 9.5 45.1-4.1L192 306 327.4 468.5c11.3 13.6 31.5 15.4 45.1 4.1s15.4-31.5 4.1-45.1L233.7 256 376.6 84.5z"},child:[]}]})(t)}const t0=({show:t,hide:e,hideClose:r=!1,title:n,...i})=>{const s=o=>{o.stopPropagation()};return t?_.jsx("div",{className:ue("bg-black/25 backdrop-blur-lg fixed top-0 bottom-0 left-0 right-0 flex flex-col c z-30 min-h-[10em] min-w-[30em]",{show:t}),onClick:e,children:_.jsxs("div",{...i,className:`flex flex-col relative bg-black/90 rounded-lg py-6 px-12 ${i.className||""}`,onClick:s,children:[!!n&&_.jsx("h4",{className:"mt-0 mb-2",children:n}),!r&&_.jsx("button",{className:"icon absolute top-1 right-1",onClick:e,children:_.jsx(w2,{})}),_.jsx("div",{className:"flex flex-col items-center w-full",onClick:s,children:i.children})]})}):null};function ya({msg:t}){return _.jsxs("div",{id:"loading",className:"flex-col-center text-center gap-4",children:[_.jsx("h4",{children:t}),_.jsx(R6,{className:"animate-spin rounded-full h-8 w-8"})]})}function $m({app:t,isIcon:e=!1,...r}){const{updateApp:n,getCaps:i,getMyApp:s,getMyApps:o}=Pi(),[a,l]=L.useState(!1),[u,c]=L.useState([]),[h,p]=L.useState(""),m=L.useCallback(async b=>{b.preventDefault(),i(t).then(k=>{c(k.request_capabilities)}),l(!0)},[t,l,i]),v=L.useCallback(async()=>{try{p(`Updating ${Js(t)}...`),await n(t);const b=setInterval(()=>{s(t).then(k=>{k.installed&&(p(""),l(!1),clearInterval(b),o())}).catch(console.log)},2e3)}catch(b){console.error(b),window.alert("Failed to update, please try again."),p("")}},[t,n,s]);return _.jsxs(_.Fragment,{children:[_.jsx("button",{...r,type:"button",className:ue("text-sm self-start",r.className,{"icon clear":e}),onClick:m,children:e?_.jsx(B6,{}):"Update"}),_.jsx(t0,{show:a,hide:()=>l(!1),children:h?_.jsx(ya,{msg:h}):_.jsxs(_.Fragment,{children:[_.jsx("h4",{children:"Approve App Permissions"}),_.jsxs("h5",{className:"m-0",children:[Js(t)," needs the following permissions:"]}),_.jsx("br",{}),_.jsx("ul",{className:"flex flex-col items-start",children:u.map(b=>_.jsx("li",{children:b},b))}),_.jsx("button",{type:"button",onClick:v,children:"Approve & Update"})]})})]})}function F6({app:t,isIcon:e=!1,...r}){var w,A,T,I,B,F,$;const{downloadApp:n,getCaps:i,getMyApp:s,getMyApps:o}=Pi(),[a,l]=L.useState(!1),[u,c]=L.useState(((T=(A=(w=t.metadata)==null?void 0:w.properties)==null?void 0:A.mirrors)==null?void 0:T[0])||"Other"),[h,p]=L.useState(""),[m,v]=L.useState("");L.useEffect(()=>{var V,G,Y;c(((Y=(G=(V=t.metadata)==null?void 0:V.properties)==null?void 0:G.mirrors)==null?void 0:Y[0])||"Other")},[(B=(I=t.metadata)==null?void 0:I.properties)==null?void 0:B.mirrors]);const b=L.useCallback(async V=>{V.preventDefault(),l(!0)},[t,l,i]),k=L.useCallback(async V=>{V.preventDefault(),V.stopPropagation();const G=u==="Other"?h:u;if(!G){window.alert("Please select a mirror");return}try{v(`Downloading ${Js(t)}...`),await n(t,G);const Y=setInterval(()=>{s(t).then(()=>{v(""),l(!1),clearInterval(Y),o()}).catch(console.log)},2e3)}catch(Y){console.error(Y),window.alert(`Failed to download app from ${G}, please try a different mirror.`),v("")}},[u,h,t,n,s]),x=Js(t);return _.jsxs(_.Fragment,{children:[_.jsx("button",{...r,type:"button",className:ue("text-sm self-start",r.className,{"icon clear":e,black:!e}),disabled:!!m,onClick:b,children:e?_.jsx(y2,{}):m?"Downloading...":"Download"}),_.jsx(t0,{show:a,hide:()=>l(!1),children:m?_.jsxs("div",{className:"flex-col-center gap-4",children:[_.jsx(ya,{msg:m}),_.jsx("div",{className:"text-center",children:"App is downloading in the background. You can safely close this window."})]}):_.jsxs("form",{className:"flex flex-col items-center gap-2",onSubmit:k,children:[_.jsxs("h4",{children:["Download '",x,"'"]}),_.jsx("h5",{children:"Select Mirror"}),_.jsx("select",{value:u,onChange:V=>c(V.target.value),children:((($=(F=t.metadata)==null?void 0:F.properties)==null?void 0:$.mirrors)||[]).concat(["Other"]).map(V=>_.jsx("option",{value:V,children:V},V))}),u==="Other"&&_.jsx("input",{type:"text",value:h,onChange:V=>p(V.target.value),placeholder:"Mirror, i.e. 'template.os'",className:"p-1 max-w-[240px] w-full",required:!0,autoFocus:!0}),_.jsx("button",{type:"submit",children:"Download"})]})})]})}function U6({app:t,isIcon:e=!1,...r}){const{installApp:n,getCaps:i,getMyApp:s,getMyApps:o}=Pi(),[a,l]=L.useState(!1),[u,c]=L.useState([]),[h,p]=L.useState(""),m=L.useCallback(async b=>{b.preventDefault(),i(t).then(k=>{c(k.request_capabilities)}),l(!0)},[t,l,i]),v=L.useCallback(async()=>{try{p(`Installing ${Js(t)}...`),await n(t);const b=setInterval(()=>{s(t).then(k=>{k.installed&&(p(""),l(!1),clearInterval(b),o())}).catch(console.log)},2e3)}catch(b){console.error(b),window.alert("Failed to install, please try again."),p("")}},[t,n,s]);return _.jsxs(_.Fragment,{children:[_.jsx("button",{...r,type:"button",className:ue("text-sm self-start",r.className,{"icon clear":e}),onClick:m,disabled:!!h,children:e?_.jsx(O6,{}):h?"Installing...":"Install"}),_.jsx(t0,{show:a,hide:()=>l(!1),children:h?_.jsxs("div",{className:"flex-col-center gap-4",children:[_.jsx(ya,{msg:h}),_.jsx("div",{className:"text-center",children:"App is installing in the background. You can safely close this window."})]}):_.jsxs("div",{className:"flex-col-center gap-2",children:[_.jsx("h4",{children:"Approve App Permissions"}),_.jsxs("h5",{className:"m-0",children:[Js(t)," needs the following permissions:"]}),_.jsx("ul",{className:"flex flex-col items-start",children:u.map(b=>_.jsx("li",{children:b},b))}),_.jsx("button",{type:"button",onClick:v,children:"Approve & Install"})]})})]})}function z6({app:t,launchPath:e,isIcon:r=!1,...n}){const i=L.useCallback(async s=>{s.preventDefault(),window.location.href=`/${e.replace("/","")}`},[t,e]);return _.jsx(_.Fragment,{children:_.jsx("button",{...n,type:"button",className:ue("text-sm self-start",n.className,{"icon clear":r,alt:!r}),onClick:i,children:r?_.jsx(L6,{}):"Launch"})})}function x2({app:t,launchPath:e="",isIcon:r=!1,permitMultiButton:n=!1,...i}){const{installed:s,downloaded:o,updatable:a}=L.useMemo(()=>{var m,v,b,k;const u=(Object.entries(((v=(m=t==null?void 0:t.metadata)==null?void 0:m.properties)==null?void 0:v.code_hashes)||{}).find(([x])=>{var w,A;return x===((A=(w=t.metadata)==null?void 0:w.properties)==null?void 0:A.current_version)})||[])[1],c=t.installed,h=!!t.state,p=!!((b=t.state)!=null&&b.our_version&&u)&&((k=t.state)==null?void 0:k.our_version)!==u&&t.publisher!==window.our.node;return{installed:c,downloaded:h,updatable:p}},[t]);return _.jsxs(_.Fragment,{children:[n&&s&&a&&e&&_.jsx($m,{app:t,...i,isIcon:r}),s&&e?_.jsx(z6,{app:t,...i,isIcon:r,launchPath:e}):s&&a?_.jsx($m,{app:t,...i,isIcon:r}):o?s?r?_.jsx("button",{className:"pointer-events none icon clear absolute top-0 right-0",children:_.jsx(v2,{})}):_.jsx(_.Fragment,{}):_.jsx(U6,{app:t,...i,isIcon:r}):_.jsx(F6,{app:t,...i,isIcon:r})]})}const Lh="/my-apps",$6="/",sc="/publish",vu="/app-details",b2=t=>!!t&&t[0]==="o",Hm=oa.unstable_batchedUpdates||(t=>t()),ss=(t,e,r=1e-4)=>Math.abs(t-e)t===!0||!!(t&&t[e]),gn=(t,e)=>typeof t=="function"?t(e):t,E2="_szhsinMenu",H6=t=>t[E2],V6=(t,e)=>Object.defineProperty(e,E2,{value:t}),r0=(t,e)=>(e&&Object.keys(e).forEach(r=>{const n=t[r],i=e[r];typeof i=="function"&&n?t[r]=(...s)=>{i(...s),n(...s)}:t[r]=i}),t),q6=t=>{if(typeof t!="string")return{top:0,right:0,bottom:0,left:0};const e=t.trim().split(/\s+/,4).map(parseFloat),r=isNaN(e[0])?0:e[0],n=isNaN(e[1])?r:e[1];return{top:r,right:n,bottom:isNaN(e[2])?r:e[2],left:isNaN(e[3])?n:e[3]}},wf=t=>{for(;t;){if(t=t.parentNode,!t||t===document.body||!t.parentNode)return;const{overflow:e,overflowX:r,overflowY:n}=getComputedStyle(t);if(/auto|scroll|overlay|hidden/.test(e+n+r))return t}};function G6(t,e){return{"aria-disabled":t||void 0,tabIndex:e?0:-1}}function Vm(t,e){for(let r=0;rL.useMemo(()=>{const i=e?`${t}__${e}`:t;let s=i;r&&Object.keys(r).forEach(a=>{const l=r[a];l&&(s+=` ${i}--${l===!0?a:`${a}-${l}`}`)});let o=typeof n=="function"?n(r):n;return typeof o=="string"&&(o=o.trim(),o&&(s+=` ${o}`)),s},[t,e,r,n]),W6="szh-menu-container",xf="szh-menu",K6="szh-menu-button",Q6="arrow",J6=L.createContext(),Y6=L.createContext({}),qm=L.createContext({}),X6=L.createContext({}),A2=L.createContext({}),Rn=Object.freeze({ENTER:"Enter",ESC:"Escape",SPACE:" ",HOME:"Home",END:"End",LEFT:"ArrowLeft",RIGHT:"ArrowRight",UP:"ArrowUp",DOWN:"ArrowDown"}),Ot=Object.freeze({RESET:0,SET:1,UNSET:2,INCREASE:3,DECREASE:4,FIRST:5,LAST:6,SET_INDEX:7}),xa=Object.freeze({CLICK:"click",CANCEL:"cancel",BLUR:"blur",SCROLL:"scroll"}),Uo=Object.freeze({FIRST:"first",LAST:"last"}),Z6=Object.freeze({entering:"opening",entered:"open",exiting:"closing",exited:"closed"}),bf="absolute",eS="menuitem",Gm={"aria-hidden":!0,role:eS},tS=V6("MenuButton",L.forwardRef(function({className:e,isOpen:r,disabled:n,children:i,...s},o){const a=L.useMemo(()=>({open:r}),[r]);return _.jsx("button",{"aria-haspopup":!0,"aria-expanded":r,"aria-disabled":n||void 0,type:"button",disabled:n,...s,ref:o,className:yu({block:K6,modifiers:a,className:e}),children:i})})),rS=({className:t,containerRef:e,containerProps:r,children:n,isOpen:i,theming:s,transition:o,onClose:a})=>{const l=wa(o,"item"),u=({key:h})=>{switch(h){case Rn.ESC:gn(a,{key:h,reason:xa.CANCEL});break}},c=h=>{i&&!h.currentTarget.contains(h.relatedTarget)&&gn(a,{reason:xa.BLUR})};return _.jsx("div",{...r0({onKeyDown:u,onBlur:c},r),className:yu({block:W6,modifiers:L.useMemo(()=>({theme:s,itemTransition:l}),[s,l]),className:t}),style:{position:"absolute",...r==null?void 0:r.style},ref:e,children:n})},nS=()=>{let t,e=0;return{toggle:r=>{r?e++:e--,e=Math.max(e,0)},on:(r,n,i)=>{e?t||(t=setTimeout(()=>{t=0,n()},r)):i==null||i()},off:()=>{t&&(clearTimeout(t),t=0)}}},iS=(t,e)=>{const[r,n]=L.useState(),s=L.useRef({items:[],hoverIndex:-1,sorted:!1}).current,o=L.useCallback((l,u)=>{const{items:c}=s;if(!l)s.items=[];else if(u)c.push(l);else{const h=c.indexOf(l);h>-1&&(c.splice(h,1),l.contains(document.activeElement)&&(e.current.focus(),n()))}s.hoverIndex=-1,s.sorted=!1},[s,e]),a=L.useCallback((l,u,c)=>{const{items:h,hoverIndex:p}=s,m=()=>{if(s.sorted)return;const k=t.current.querySelectorAll(".szh-menu__item");h.sort((x,w)=>Vm(k,x)-Vm(k,w)),s.sorted=!0};let v=-1,b;switch(l){case Ot.RESET:break;case Ot.SET:b=u;break;case Ot.UNSET:b=k=>k===u?void 0:k;break;case Ot.FIRST:m(),v=0,b=h[v];break;case Ot.LAST:m(),v=h.length-1,b=h[v];break;case Ot.SET_INDEX:m(),v=c,b=h[v];break;case Ot.INCREASE:m(),v=p,v<0&&(v=h.indexOf(u)),v++,v>=h.length&&(v=0),b=h[v];break;case Ot.DECREASE:m(),v=p,v<0&&(v=h.indexOf(u)),v--,v<0&&(v=h.length-1),b=h[v];break}b||(v=-1),n(b),s.hoverIndex=v},[t,s]);return{hoverItem:r,dispatch:a,updateItems:o}},sS=(t,e,r,n)=>{const i=e.current.getBoundingClientRect(),s=t.current.getBoundingClientRect(),o=r===window?{left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight}:r.getBoundingClientRect(),a=q6(n),l=v=>v+s.left-o.left-a.left,u=v=>v+s.left+i.width-o.right+a.right,c=v=>v+s.top-o.top-a.top,h=v=>v+s.top+i.height-o.bottom+a.bottom;return{menuRect:i,containerRect:s,getLeftOverflow:l,getRightOverflow:u,getTopOverflow:c,getBottomOverflow:h,confineHorizontally:v=>{let b=l(v);if(b<0)v-=b;else{const k=u(v);k>0&&(v-=k,b=l(v),b<0&&(v-=b))}return v},confineVertically:v=>{let b=c(v);if(b<0)v-=b;else{const k=h(v);k>0&&(v-=k,b=c(v),b<0&&(v-=b))}return v}}},oS=({arrowRef:t,menuY:e,anchorRect:r,containerRect:n,menuRect:i})=>{let s=r.top-n.top-e+r.height/2;const o=t.current.offsetHeight*1.25;return s=Math.max(o,s),s=Math.min(s,i.height-o),s},aS=({anchorRect:t,containerRect:e,menuRect:r,placeLeftorRightY:n,placeLeftX:i,placeRightX:s,getLeftOverflow:o,getRightOverflow:a,confineHorizontally:l,confineVertically:u,arrowRef:c,arrow:h,direction:p,position:m})=>{let v=p,b=n;m!=="initial"&&(b=u(b),m==="anchor"&&(b=Math.min(b,t.bottom-e.top),b=Math.max(b,t.top-e.top-r.height)));let k,x,w;return v==="left"?(k=i,m!=="initial"&&(x=o(k),x<0&&(w=a(s),(w<=0||-x>w)&&(k=s,v="right")))):(k=s,m!=="initial"&&(w=a(k),w>0&&(x=o(i),(x>=0||-x{let s=r.left-n.left-e+r.width/2;const o=t.current.offsetWidth*1.25;return s=Math.max(o,s),s=Math.min(s,i.width-o),s},uS=({anchorRect:t,containerRect:e,menuRect:r,placeToporBottomX:n,placeTopY:i,placeBottomY:s,getTopOverflow:o,getBottomOverflow:a,confineHorizontally:l,confineVertically:u,arrowRef:c,arrow:h,direction:p,position:m})=>{let v=p==="top"?"top":"bottom",b=n;m!=="initial"&&(b=l(b),m==="anchor"&&(b=Math.min(b,t.right-e.left),b=Math.max(b,t.left-e.left-r.width)));let k,x,w;return v==="top"?(k=i,m!=="initial"&&(x=o(k),x<0&&(w=a(s),(w<=0||-x>w)&&(k=s,v="bottom")))):(k=s,m!=="initial"&&(w=a(k),w>0&&(x=o(i),(x>=0||-x{const{menuRect:u,containerRect:c}=l,h=r==="left"||r==="right";let p=h?n:i,m=h?i:n;if(t){const I=a.current;h?p+=I.offsetWidth:m+=I.offsetHeight}const v=o.left-c.left-u.width-p,b=o.right-c.left+p,k=o.top-c.top-u.height-m,x=o.bottom-c.top+m;let w,A;e==="end"?(w=o.right-c.left-u.width,A=o.bottom-c.top-u.height):e==="center"?(w=o.left-c.left-(u.width-o.width)/2,A=o.top-c.top-(u.height-o.height)/2):(w=o.left-c.left,A=o.top-c.top),w+=p,A+=m;const T={...l,anchorRect:o,placeLeftX:v,placeRightX:b,placeLeftorRightY:A,placeTopY:k,placeBottomY:x,placeToporBottomX:w,arrowRef:a,arrow:t,direction:r,position:s};switch(r){case"left":case"right":return aS(T);case"top":case"bottom":default:return uS(T)}},Ef=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?L.useLayoutEffect:L.useEffect;function Wm(t,e){typeof t=="function"?t(e):t.current=e}const _2=(t,e)=>L.useMemo(()=>t?e?r=>{Wm(t,r),Wm(e,r)}:t:e,[t,e]),Km=-9999,fS=({ariaLabel:t,menuClassName:e,menuStyle:r,arrow:n,arrowProps:i={},anchorPoint:s,anchorRef:o,containerRef:a,containerProps:l,focusProps:u,externalRef:c,parentScrollingRef:h,align:p="start",direction:m="bottom",position:v="auto",overflow:b="visible",setDownOverflow:k,repositionFlag:x,captureFocus:w=!0,state:A,endTransition:T,isDisabled:I,menuItemFocus:B,gap:F=0,shift:$=0,children:V,onClose:G,...Y})=>{const[$e,R]=L.useState({x:Km,y:Km}),[f,g]=L.useState({}),[E,M]=L.useState(),[S,P]=L.useState(m),[O]=L.useState(nS),[N,d]=L.useReducer(ie=>ie+1,1),{transition:C,boundingBoxRef:te,boundingBoxPadding:y,rootMenuRef:D,rootAnchorRef:U,scrollNodesRef:z,reposition:W,viewScroll:se,submenuCloseDelay:X}=L.useContext(A2),{submenuCtx:Q,reposSubmenu:Xe=x}=L.useContext(qm),J=L.useRef(null),ae=L.useRef(),Xr=L.useRef(),Te=L.useRef(!1),Me=L.useRef({width:0,height:0}),Zr=L.useRef(()=>{}),{hoverItem:Ce,dispatch:fe,updateItems:Er}=iS(J,ae),he=b2(A),je=wa(C,"open"),en=wa(C,"close"),ge=z.current,He=ie=>{switch(ie.key){case Rn.HOME:fe(Ot.FIRST);break;case Rn.END:fe(Ot.LAST);break;case Rn.UP:fe(Ot.DECREASE,Ce);break;case Rn.DOWN:fe(Ot.INCREASE,Ce);break;case Rn.SPACE:ie.target&&ie.target.className.indexOf(xf)!==-1&&ie.preventDefault();return;default:return}ie.preventDefault(),ie.stopPropagation()},En=()=>{A==="closing"&&M(),gn(T)},Ve=ie=>{ie.stopPropagation(),O.on(X,()=>{fe(Ot.RESET),ae.current.focus()})},qe=ie=>{ie.target===ie.currentTarget&&O.off()},Gt=L.useCallback(ie=>{var lt;const ve=o?(lt=o.current)==null?void 0:lt.getBoundingClientRect():s?{left:s.x,right:s.x,top:s.y,bottom:s.y,width:0,height:0}:null;if(!ve)return;ge.menu||(ge.menu=(te?te.current:wf(D.current))||window);const de=sS(a,J,ge.menu,y);let{arrowX:it,arrowY:_e,x:Se,y:Rt,computedDirection:Re}=cS({arrow:n,align:p,direction:m,gap:F,shift:$,position:v,anchorRect:ve,arrowRef:Xr,positionHelpers:de});const{menuRect:Fe}=de;let Yt=Fe.height;if(!ie&&b!=="visible"){const{getTopOverflow:Qe,getBottomOverflow:Je}=de;let Xt,Ie;const Ue=Me.current.height,Ar=Je(Rt);if(Ar>0||ss(Ar,0)&&ss(Yt,Ue))Xt=Yt-Ar,Ie=Ar;else{const Ne=Qe(Rt);(Ne<0||ss(Ne,0)&&ss(Yt,Ue))&&(Xt=Yt+Ne,Ie=0-Ne,Xt>=0&&(Rt-=Ne))}Xt>=0?(Yt=Xt,M({height:Xt,overflowAmt:Ie})):M()}n&&g({x:it,y:_e}),R({x:Se,y:Rt}),P(Re),Me.current={width:Fe.width,height:Yt}},[n,p,y,m,F,$,v,b,s,o,a,te,D,ge]);Ef(()=>{he&&(Gt(),Te.current&&d()),Te.current=he,Zr.current=Gt},[he,Gt,Xe]),Ef(()=>{E&&!k&&(J.current.scrollTop=0)},[E,k]),Ef(()=>Er,[Er]),L.useEffect(()=>{let{menu:ie}=ge;if(!he||!ie)return;if(ie=ie.addEventListener?ie:window,!ge.anchors){ge.anchors=[];let it=wf(U&&U.current);for(;it&&it!==ie;)ge.anchors.push(it),it=wf(it)}let lt=se;if(ge.anchors.length&<==="initial"&&(lt="auto"),lt==="initial")return;const ve=()=>{lt==="auto"?Hm(()=>Gt(!0)):gn(G,{reason:xa.SCROLL})},de=ge.anchors.concat(se!=="initial"?ie:[]);return de.forEach(it=>it.addEventListener("scroll",ve)),()=>de.forEach(it=>it.removeEventListener("scroll",ve))},[U,ge,he,G,se,Gt]);const Le=!!E&&E.overflowAmt>0;L.useEffect(()=>{if(Le||!he||!h)return;const ie=()=>Hm(Gt),lt=h.current;return lt.addEventListener("scroll",ie),()=>lt.removeEventListener("scroll",ie)},[he,Le,h,Gt]),L.useEffect(()=>{if(typeof ResizeObserver!="function"||W==="initial")return;const ie=new ResizeObserver(([ve])=>{const{borderBoxSize:de,target:it}=ve;let _e,Se;if(de){const{inlineSize:Rt,blockSize:Re}=de[0]||de;_e=Rt,Se=Re}else{const Rt=it.getBoundingClientRect();_e=Rt.width,Se=Rt.height}_e===0||Se===0||ss(_e,Me.current.width,1)&&ss(Se,Me.current.height,1)||oa.flushSync(()=>{Zr.current(),d()})}),lt=J.current;return ie.observe(lt,{box:"border-box"}),()=>ie.unobserve(lt)},[W]),L.useEffect(()=>{if(!he){fe(Ot.RESET),en||M();return}const{position:ie,alwaysUpdate:lt}=B||{},ve=()=>{ie===Uo.FIRST?fe(Ot.FIRST):ie===Uo.LAST?fe(Ot.LAST):ie>=-1&&fe(Ot.SET_INDEX,void 0,ie)};if(lt)ve();else if(w){const de=setTimeout(()=>{const it=J.current;it&&!it.contains(document.activeElement)&&(ae.current.focus(),ve())},je?170:100);return()=>clearTimeout(de)}},[he,je,en,w,B,fe]);const Ge=L.useMemo(()=>({isParentOpen:he,submenuCtx:O,dispatch:fe,updateItems:Er}),[he,O,fe,Er]);let Lr,Pe;E&&(k?Pe=E.overflowAmt:Lr=E.height);const We=L.useMemo(()=>({reposSubmenu:N,submenuCtx:O,overflow:b,overflowAmt:Pe,parentMenuRef:J,parentDir:S}),[N,O,b,Pe,S]),An=Lr>=0?{maxHeight:Lr,overflow:b}:void 0,Be=L.useMemo(()=>({state:A,dir:S}),[A,S]),Ke=L.useMemo(()=>({dir:S}),[S]),_n=yu({block:xf,element:Q6,modifiers:Ke,className:i.className}),De=_.jsxs("ul",{role:"menu","aria-label":t,...G6(I),...r0({onPointerEnter:Q==null?void 0:Q.off,onPointerMove:Ve,onPointerLeave:qe,onKeyDown:He,onAnimationEnd:En},Y),ref:_2(c,J),className:yu({block:xf,modifiers:Be,className:e}),style:{...r,...An,margin:0,display:A==="closed"?"none":void 0,position:bf,left:$e.x,top:$e.y},children:[_.jsx("li",{tabIndex:-1,style:{position:bf,left:0,top:0,display:"block",outline:"none"},ref:ae,...Gm,...u}),n&&_.jsx("li",{...Gm,...i,className:_n,style:{display:"block",position:bf,left:f.x,top:f.y,...i.style},ref:Xr}),_.jsx(qm.Provider,{value:We,children:_.jsx(Y6.Provider,{value:Ge,children:_.jsx(J6.Provider,{value:Ce,children:gn(V,Be)})})})]});return l?_.jsx(rS,{...l,isOpen:he,children:De}):De},hS=L.forwardRef(function({"aria-label":e,className:r,containerProps:n,initialMounted:i,unmountOnClose:s,transition:o,transitionTimeout:a,boundingBoxRef:l,boundingBoxPadding:u,reposition:c="auto",submenuOpenDelay:h=300,submenuCloseDelay:p=150,viewScroll:m="initial",portal:v,theming:b,onItemClick:k,...x},w){const A=L.useRef(null),T=L.useRef({}),{anchorRef:I,state:B,onClose:F}=x,$=L.useMemo(()=>({initialMounted:i,unmountOnClose:s,transition:o,transitionTimeout:a,boundingBoxRef:l,boundingBoxPadding:u,rootMenuRef:A,rootAnchorRef:I,scrollNodesRef:T,reposition:c,viewScroll:m,submenuOpenDelay:h,submenuCloseDelay:p}),[i,s,o,a,I,l,u,c,m,h,p]),V=L.useMemo(()=>({handleClick(Y,$e){Y.stopPropagation||gn(k,Y);let R=Y.keepOpen;R===void 0&&(R=$e&&Y.key===Rn.SPACE),R||gn(F,{value:Y.value,key:Y.key,reason:xa.CLICK})},handleClose(Y){gn(F,{key:Y,reason:xa.CLICK})}}),[k,F]);if(!B)return null;const G=_.jsx(A2.Provider,{value:$,children:_.jsx(X6.Provider,{value:V,children:_.jsx(fS,{...x,ariaLabel:e||"Menu",externalRef:w,containerRef:A,containerProps:{className:r,containerRef:A,containerProps:n,theming:b,transition:o,onClose:F}})})});return v===!0&&typeof document<"u"?oa.createPortal(G,document.body):v?v.target?oa.createPortal(G,v.target):v.stablePosition?null:G:G}),Bh=0,Dh=1,wu=2,xu=3,bu=4,dS=5,S2=6,pS=["preEnter","entering","entered","preExit","exiting","exited","unmounted"],k2=t=>({_s:t,status:pS[t],isEnter:tbu}),Fh=t=>t?S2:dS,mS=(t,e)=>{switch(t){case Dh:case Bh:return wu;case bu:case xu:return Fh(e)}},gS=t=>typeof t=="object"?[t.enter,t.exit]:[t,t],vS=(t,e)=>setTimeout(()=>{isNaN(document.body.offsetTop)||t(e+1)},0),Qm=(t,e,r,n,i)=>{clearTimeout(n.current);const s=k2(t);e(s),r.current=s,i&&i({current:s})},yS=({enter:t=!0,exit:e=!0,preEnter:r,preExit:n,timeout:i,initialEntered:s,mountOnEnter:o,unmountOnExit:a,onStateChange:l}={})=>{const[u,c]=L.useState(()=>k2(s?wu:Fh(o))),h=L.useRef(u),p=L.useRef(),[m,v]=gS(i),b=L.useCallback(()=>{const x=mS(h.current._s,a);x&&Qm(x,c,h,p,l)},[l,a]),k=L.useCallback(x=>{const w=T=>{switch(Qm(T,c,h,p,l),T){case Dh:m>=0&&(p.current=setTimeout(b,m));break;case bu:v>=0&&(p.current=setTimeout(b,v));break;case Bh:case xu:p.current=vS(w,T);break}},A=h.current.isEnter;typeof x!="boolean"&&(x=!A),x?!A&&w(t?r?Bh:Dh:wu):A&&w(e?n?xu:bu:Fh(a))},[b,l,t,e,r,n,m,v,a]);return L.useEffect(()=>()=>clearTimeout(p.current),[]),[u,k,b]},wS=({initialOpen:t,initialMounted:e,unmountOnClose:r,transition:n,transitionTimeout:i=500}={})=>{const[{status:s},o,a]=yS({initialEntered:t,mountOnEnter:!e,unmountOnExit:r,timeout:i,enter:wa(n,"open"),exit:wa(n,"close")});return[{state:Z6[s],endTransition:a},o]},xS=t=>{const[e,r]=wS(t),[n,i]=L.useState(),s=(o,a)=>{i({position:o,alwaysUpdate:a}),r(!0)};return[{menuItemFocus:n,...e},r,s]},bS=(t,e)=>{const[r]=L.useState({});return{onMouseDown:()=>{r.v=t&&t!=="closed"},onClick:n=>r.v?r.v=!1:e(!0,n)}},ES=(t,e)=>{const r=L.useRef(e);L.useEffect(()=>{r.current!==e&&gn(t,{open:e}),r.current=e},[t,e])},AS=L.forwardRef(function({"aria-label":e,captureFocus:r,initialOpen:n,menuButton:i,instanceRef:s,onMenuChange:o,...a},l){const[u,c,h]=xS(a),{state:p}=u,m=b2(p),v=L.useRef(null),b=bS(p,(I,B)=>h(B.detail?void 0:Uo.FIRST)),k=L.useCallback(I=>{c(!1),I.key&&v.current.focus()},[c]),x=I=>{switch(I.key){case Rn.UP:h(Uo.LAST);break;case Rn.DOWN:h(Uo.FIRST);break;default:return}I.preventDefault()},w=gn(i,{open:m});if(!w||!w.type)throw new Error("Menu requires a menuButton prop.");const A={ref:_2(w.ref,v),...r0({onKeyDown:x,...b},w.props)};H6(w.type)==="MenuButton"&&(A.isOpen=m);const T=L.cloneElement(w,A);return ES(o,m),L.useImperativeHandle(s,()=>({openMenu:h,closeMenu:()=>c(!1)})),_.jsxs(L.Fragment,{children:[T,_.jsx(hS,{...a,...u,"aria-label":e||(typeof w.props.children=="string"?w.props.children:"Menu"),anchorRef:v,ref:l,onClose:k})]})});function Jm({...t}){return _.jsx(AS,{...t,unmountOnClose:!0,className:ue("relative",t.className),direction:"left",menuButton:_.jsx(tS,{className:"small",children:_.jsx(p6,{className:"-mb-1"})}),children:t.children})}function _S({app:t,className:e}){var a,l,u,c,h;const{uninstallApp:r,setMirroring:n,setAutoUpdate:i}=Pi(),s=Ma();return!t.state?t.metadata?_.jsx(Jm,{className:e,children:_.jsxs("div",{className:"flex flex-col backdrop-blur-lg bg-black/10 p-2 rounded-lg relative z-10",children:[((a=t.metadata)==null?void 0:a.description)&&_.jsx("button",{className:"my-1 whitespace-nowrap clear",onClick:()=>s(`/${vu}/${Ee(t)}`),children:"View Details"}),((l=t.metadata)==null?void 0:l.external_url)&&_.jsx("a",{target:"_blank",href:(u=t.metadata)==null?void 0:u.external_url,className:"mb-1 whitespace-nowrap button clear",children:"View Site"})]})}):_.jsx(_.Fragment,{}):_.jsx(Jm,{className:e,children:_.jsxs("div",{className:"flex flex-col p-2 rounded-lg backdrop-blur-lg relative z-10",children:[_.jsx("button",{className:"my-1 whitespace-nowrap clear",onClick:()=>s(`/${vu}/${Ee(t)}`),children:"View Details"}),t.installed&&_.jsxs(_.Fragment,{children:[_.jsx("button",{className:"mb-1 whitespace-nowrap clear",onClick:()=>r(t),children:"Uninstall"}),_.jsxs("button",{className:"mb-1 whitespace-nowrap clear",onClick:()=>{var p;return n(t,!((p=t.state)!=null&&p.mirroring))},children:[(c=t.state)!=null&&c.mirroring?"Stop":"Start"," Mirroring"]}),_.jsxs("button",{className:"mb-1 whitespace-nowrap clear",onClick:()=>{var p;return i(t,!((p=t.state)!=null&&p.auto_update))},children:[(h=t.state)!=null&&h.auto_update?"Disable":"Enable"," Auto Update"]})]})]})})}function Ns({app:t,size:e="medium",overrideImageSize:r,showMoreActions:n,launchPath:i,...s}){const o=Kn(),a=Ma();return L.createElement("div",{...s,key:Ee(t),className:ue("flex justify-between rounded-lg hover:bg-white/10 card cursor-pointer",s.className,{"flex-wrap gap-2":o,"flex-col relative":e!=="large"}),onClick:()=>{n||a(`/${vu}/${Ee(t)}`)}},_.jsx(g2,{app:t,size:e,overrideImageSize:r}),_.jsxs("div",{className:ue("flex items-center",{absolute:e!=="large","top-2 right-2":e!=="large"&&n,"top-0 right-0":e!=="large"&&!n,"ml-auto":e==="large"&&o,"min-w-1/5":e==="large"}),children:[_.jsx(x2,{app:t,launchPath:i,isIcon:!n&&e!=="large",className:ue({"bg-orange text-lg":e==="large","mr-2":n,"w-full":e==="large"})}),n&&_.jsx(_S,{app:t,className:"self-stretch"})]}))}function oc({value:t="",onChange:e=()=>null,onBack:r,hideSearch:n=!1,hidePublish:i=!1}){const s=Ma(),o=$u(),a=Wr.useRef(null),l=o.key!=="default",u=o.pathname===Lh,c=Kn();return _.jsxs("div",{className:ue("flex justify-between",{"gap-4":c,"gap-8":!c}),children:[o.pathname!=="/"?_.jsx("button",{className:"flex flex-col c icon icon-orange",onClick:()=>{r?r():s(l?-1:"/")},children:_.jsx(C6,{})}):c?_.jsx("button",{className:ue("icon icon-orange",{}),onClick:()=>window.location.href="/",children:_.jsx(h2,{})}):_.jsx(_.Fragment,{}),!i&&_.jsx("button",{className:"flex flex-col c icon icon-orange",onClick:()=>s(sc),children:_.jsx(D6,{})}),!n&&_.jsxs("div",{className:"flex flex-1 rounded-md relative",children:[_.jsx("input",{type:"text",ref:a,onChange:h=>e(h.target.value),value:t,placeholder:"Search for apps...",className:"w-full self-stretch grow"}),_.jsx("button",{className:ue("icon border-0 absolute top-1/2 -translate-y-1/2",{"right-2":c,"right-4":!c}),type:"button",onClick:()=>{var h;return(h=a.current)==null?void 0:h.focus()},children:_.jsx(T6,{})})]}),_.jsxs("button",{className:ue("flex c",{"gap-4":c,"gap-8 basis-1/5":!c}),onClick:()=>s(u?-1:Lh),children:[!c&&_.jsx("span",{children:"My Apps"}),_.jsx(y2,{})]})]})}const ac=()=>{const t=Kn();return _.jsx("button",{className:ue("clear absolute p-2",{"top-2 left-2":t,"top-8 left-8":!t}),onClick:()=>window.location.href="/",children:_.jsx(h2,{size:24})})};function SS(){const{listedApps:t,getListedApps:e,rebuildIndex:r}=Pi(),[n,i]=L.useState("Recently published"),[s,o]=L.useState(""),[a,l]=L.useState(t),[u,c]=L.useState(1),[h,p]=L.useState([]),[m,v]=L.useState({}),b=L.useMemo(()=>Array.from({length:Math.ceil(t.length/10)},(I,B)=>B+1),[t]),k=["dartfrog","kcal","memedeck","filter"];L.useEffect(()=>{const I=(u-1)*10,B=I+10;l(t.slice(I,B))},[t,u]),L.useEffect(()=>{e().then(I=>{l(Object.values(I));let B=[];for(const F of Object.values(I))B=B.concat((F.metadata||{}).tags||[]);B.length===0&&(B=["App","Tags","Coming","Soon","tm"]),p(Array.from(new Set(B)))}).catch(I=>console.error(I))},[]);const x=L.useCallback(async I=>{},[]),w=L.useCallback(I=>{o(I);const B=t.filter(F=>{var $,V,G,Y;return F.package.toLowerCase().includes(I.toLowerCase())||((V=($=F.metadata)==null?void 0:$.description)==null?void 0:V.toLowerCase().includes(I.toLowerCase()))||((Y=(G=F.metadata)==null?void 0:G.description)==null?void 0:Y.toLowerCase().includes(I.toLowerCase()))},[t]);l(B)},[t]),A=L.useCallback(async()=>{try{await r(),alert("Index rebuilt successfully."),await e()}catch(I){console.error(I)}},[r]),T=Kn();return L.useEffect(()=>{fetch("/apps").then(I=>I.json()).then(I=>{Array.isArray(I)&&t.forEach(B=>{const F=I.find($=>B.package===$.package_name);F&&v({...m,[B.package]:F.path})})})},[t]),_.jsxs("div",{className:ue("flex flex-col w-full max-h-screen p-2",{"gap-4 max-w-screen":T,"gap-6 max-w-[900px]":!T}),children:[!T&&_.jsx(ac,{}),_.jsx(oc,{value:s,onChange:w}),_.jsxs("div",{className:ue("flex items-center self-stretch justify-between",{"gap-4 flex-wrap":T,"gap-8 grow":!T}),children:[_.jsx("button",{className:"flex flex-col c icon icon-orange",onClick:A,title:"Rebuild index",children:_.jsx(P6,{})}),h.slice(0,T?3:6).map(I=>_.jsx("button",{className:"clear flex c rounded-full !bg-white/10 !hover:bg-white/25",onClick:()=>{console.log("clicked tag",I)},children:I},I)),_.jsxs("select",{value:n,onChange:I=>{i(I.target.value),x(I.target.value)},className:ue("hidden",{"basis-1/5":!T}),children:[_.jsx("option",{children:"Recently published"}),_.jsx("option",{children:"Most popular"}),_.jsx("option",{children:"Best rating"}),_.jsx("option",{children:"Recently updated"})]})]}),!s&&_.jsxs("div",{className:ue("flex flex-col",{"gap-4":!T,"grow overflow-y-auto gap-2 items-center px-2":T}),children:[_.jsx("h2",{children:"Featured Apps"}),_.jsx("div",{className:ue("flex gap-2",{"flex-col":T}),children:t.filter(I=>k.indexOf(I.package)!==-1).map(I=>{var B;return _.jsx(Ns,{size:"medium",app:I,launchPath:m[I.package],className:ue("grow",{"w-1/4":!T,"w-full":T})},Ee(I)+(((B=I.state)==null?void 0:B.our_version)||""))})})]}),_.jsx("h2",{children:s?"Search Results":"All Apps"}),_.jsx("div",{className:ue("flex flex-col grow overflow-y-auto",{"gap-2":T,"gap-4":!T}),children:a.filter(I=>s?!0:k.indexOf(I.package)===-1).map(I=>{var B;return _.jsx(Ns,{size:"large",app:I,className:"self-stretch",overrideImageSize:"medium"},Ee(I)+(((B=I.state)==null?void 0:B.our_version)||""))})}),b.length>1&&_.jsxs("div",{className:"flex flex-wrap self-center gap-2",children:[_.jsx("button",{className:"icon",onClick:()=>u!==b[0]&&c(u-1),children:_.jsx(h6,{})}),b.map(I=>_.jsx("button",{className:ue("icon",{"!bg-white/10":I===u}),onClick:()=>c(I),children:I},`page-${I}`)),_.jsx("button",{className:"icon",onClick:()=>u!==b[b.length-1]&&c(u+1),children:_.jsx(d6,{})})]})]})}function kS(){const{myApps:t,getMyApps:e}=Pi(),r=Ma(),[n,i]=L.useState(""),[s,o]=L.useState(t);L.useEffect(()=>{e().then(o).catch(u=>console.error(u))},[]);const a=L.useCallback(u=>{i(u);const c=Object.keys(t).reduce((h,p)=>(h[p]=t[p].filter(m=>{var v,b,k,x;return m.package.toLowerCase().includes(u.toLowerCase())||((b=(v=m.metadata)==null?void 0:v.description)==null?void 0:b.toLowerCase().includes(u.toLowerCase()))||((x=(k=m.metadata)==null?void 0:k.description)==null?void 0:x.toLowerCase().includes(u.toLowerCase()))}),h),{downloaded:[],installed:[],local:[],system:[]});o(c)},[t]);L.useEffect(()=>{n?a(n):o(t)},[t]);const l=Kn();return console.log({myApps:t}),_.jsxs("div",{className:ue("flex flex-col w-full h-screen p-2",{"gap-4 max-w-screen":l,"gap-8 max-w-[900px]":!l}),children:[_.jsx(ac,{}),_.jsx(oc,{value:n,onChange:a}),_.jsxs("div",{className:"flex justify-between items-center mt-2",children:[_.jsx("h3",{children:"My Packages"}),_.jsxs("button",{onClick:()=>r(sc),children:[_.jsx(m6,{className:"mr-2"}),"Publish Package"]})]}),_.jsxs("div",{className:ue("flex flex-col card gap-2 mt-2",{"max-h-[80vh] overflow-y-scroll overflow-x-visible":!l}),style:{scrollbarWidth:"thin",scrollbarColor:"#FFF5D9 transparent"},children:[s.downloaded.length>0&&_.jsx("h4",{children:"Downloaded"}),(s.downloaded||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u))),s.installed.length>0&&_.jsx("h4",{children:"Installed"}),(s.installed||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u))),s.local.length>0&&_.jsx("h4",{children:"Local"}),(s.local||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u))),s.system.length>0&&_.jsx("h4",{children:"System"}),(s.system||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u)))]})]})}function NS(){var b,k,x,w,A,T,I,B,F,$;const{myApps:t,listedApps:e,getListedApp:r}=Pi(),n=Ma(),i=Vb(),[s,o]=L.useState(void 0),[a,l]=L.useState("");L.useEffect(()=>{const V=t.local.find(G=>Ee(G)===i.id);if(V)return o(V);if(i.id){const G=e.find(Y=>Ee(Y)===i.id);G?o(G):r(i.id).then(Y=>o(Y)).catch(console.error)}},[i.id,t,e]);const u=L.useCallback(()=>{n(sc,{state:{app:s}})},[s,n]),c=L.useMemo(()=>{var V,G;return((G=(V=s==null?void 0:s.metadata)==null?void 0:V.properties)==null?void 0:G.current_version)||"Unknown"},[s]),h=Object.entries(((k=(b=s==null?void 0:s.metadata)==null?void 0:b.properties)==null?void 0:k.code_hashes)||{}),p=((x=s==null?void 0:s.state)==null?void 0:x.our_version)||(h[(h.length||1)-1]||["",""])[1],m=Kn(),v=[{top:_.jsx("div",{className:ue({"text-sm":m}),children:"Developer"}),middle:_.jsx(j6,{size:36}),bottom:_.jsx("div",{className:ue({"text-sm":m}),children:s==null?void 0:s.publisher})},{top:_.jsx("div",{className:ue({"text-sm":m}),children:"Version"}),middle:_.jsx("span",{className:"text-2xl",children:c}),bottom:_.jsxs("div",{className:ue({"text-xs":m}),children:[p.slice(0,5),"...",p.slice(-5)]})},{top:_.jsx("div",{className:ue({"text-sm":m}),children:"Mirrors"}),middle:_.jsx(I6,{size:36}),bottom:_.jsx("div",{className:ue({"text-sm":m}),children:((T=(A=(w=s==null?void 0:s.metadata)==null?void 0:w.properties)==null?void 0:A.mirrors)==null?void 0:T.length)||0})}];return L.useEffect(()=>{fetch("/apps").then(V=>V.json()).then(V=>{if(Array.isArray(V)){const G=V.find(Y=>(s==null?void 0:s.package)===Y.package_name);G&&l(G.path)}})},[s]),_.jsxs("div",{className:ue("flex flex-col w-full p-2",{"gap-4 max-w-screen":m,"gap-8 max-w-[900px]":!m}),children:[!m&&_.jsx(ac,{}),_.jsx(oc,{value:"",onChange:()=>null,hideSearch:!0,hidePublish:!0}),_.jsx("div",{className:ue("flex-col-center card !rounded-3xl",{"p-12 gap-4 grow overflow-y-auto":m,"p-24 gap-8":!m}),children:s?_.jsxs(_.Fragment,{children:[_.jsx(g2,{app:s,size:m?"medium":"large"}),_.jsx("div",{className:"w-5/6 h-0 border border-orange"}),_.jsx("div",{className:ue("flex items-start text-xl",{"gap-4 flex-wrap":m,"gap-8":!m}),children:v.map((V,G)=>_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:ue("flex-col-center gap-2 justify-between self-stretch",{"rounded-lg bg-white/10 p-1 min-w-1/4 grow":m,"opacity-50":!m}),children:[V.top,V.middle,V.bottom]},G),!m&&G!==v.length-1&&_.jsx("div",{className:"h-3/4 w-0 border border-orange self-center"})]}))}),Array.isArray((B=(I=s.metadata)==null?void 0:I.properties)==null?void 0:B.screenshots)&&((F=s.metadata)==null?void 0:F.properties.screenshots.length)>0&&_.jsx("div",{className:"flex flex-wrap overflow-x-auto max-w-full",children:s.metadata.properties.screenshots.map((V,G)=>_.jsx("img",{src:V,className:"mr-2 max-h-20 max-w-full rounded border border-black"},G+V))}),_.jsx("div",{className:ue("flex-center gap-2",{"flex-col":m}),children:_.jsx(x2,{app:s,launchPath:a,className:ue("self-center bg-orange text-lg px-12"),permitMultiButton:!0})}),s.installed&&(($=s.state)==null?void 0:$.mirroring)&&_.jsx("button",{type:"button",onClick:u,children:"Publish"})]}):_.jsxs(_.Fragment,{children:[_.jsx("h4",{children:"App details not found for "}),_.jsx("h4",{children:i.id})]})})]})}var Uh=(t=>(t[t.SEPOLIA=11155111]="SEPOLIA",t[t.OPTIMISM=10]="OPTIMISM",t[t.OPTIMISM_GOERLI=420]="OPTIMISM_GOERLI",t[t.LOCAL=1337]="LOCAL",t))(Uh||{});const Ym="0xaa36a7",zo="0xa",MS={10:"0x52185B6a6017E6f079B994452F234f7C2533787B"},CS="4902",Xm={[Ym]:{chainId:Ym,chainName:"Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:["https://rpc.sepolia.org"],blockExplorerUrls:["https://sepolia.etherscan.io"]},[zo]:{chainId:zo,chainName:"Optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:["https://mainnet.optimism.io"],blockExplorerUrls:["https://optimistic.etherscan.io"]}},PS=t=>{switch(t){case"1":case"0x1":return"Ethereum";case"10":case"a":case"0xa":return"Optimism";case"42161":return"Arbitrum";case"11155111":case"aa36a7":case"0xaa36a7":return"Sepolia";default:return"Unknown"}},Af=async t=>{var r,n,i;let e=await((r=window.ethereum)==null?void 0:r.request({method:"net_version"}).catch(()=>"1"));if(e="0x"+(typeof e=="string"?e.replace(/^0x/,""):e.toString(16)),!Xm[t]){console.error(`Invalid chain ID: ${t}`);return}if(t!==e)try{await((n=window.ethereum)==null?void 0:n.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]}))}catch(s){if(String(s).includes(CS))await((i=window.ethereum)==null?void 0:i.request({method:"wallet_addEthereumChain",params:[Xm[t]]}));else throw window.alert(`You must enable the ${PS(t)} network in your wallet.`),new Error(`User cancelled connection to ${t}`)}};var ba={},lc={};Object.defineProperty(lc,"__esModule",{value:!0});lc.Connector=void 0;class RS{constructor(e,r){this.actions=e,this.onError=r}resetState(){this.actions.resetState()}}lc.Connector=RS;var _f,Zm;function IS(){if(Zm)return _f;Zm=1;function t({mustBeMetaMask:e=!1,silent:r=!1,timeout:n=3e3}={}){s();let i=!1;return new Promise(o=>{window.ethereum?a():(window.addEventListener("ethereum#initialized",a,{once:!0}),setTimeout(()=>{a()},n));function a(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",a);const{ethereum:l}=window;l&&(!e||l.isMetaMask)?o(l):(!r&&console.error("@metamask/detect-provider:",e&&l?"Non-MetaMask window.ethereum detected.":"Unable to detect window.ethereum."),o(null))}});function s(){if(typeof e!="boolean")throw new Error("@metamask/detect-provider: Expected option 'mustBeMetaMask' to be a boolean.");if(typeof r!="boolean")throw new Error("@metamask/detect-provider: Expected option 'silent' to be a boolean.");if(typeof n!="number")throw new Error("@metamask/detect-provider: Expected option 'timeout' to be a number.")}}return _f=t,_f}var OS=ze&&ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),TS=ze&&ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),jS=ze&&ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&OS(e,t,r);return TS(e,t),e},os=ze&&ze.__awaiter||function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};Object.defineProperty(ba,"__esModule",{value:!0});var N2=ba.MetaMask=ba.NoMetaMaskError=void 0;const LS=lc;class Ea extends Error{constructor(){super("MetaMask not installed"),this.name=Ea.name,Object.setPrototypeOf(this,Ea.prototype)}}ba.NoMetaMaskError=Ea;function fl(t){return Number.parseInt(t,16)}class BS extends LS.Connector{constructor({actions:e,options:r,onError:n}){super(e,n),this.options=r}isomorphicInitialize(){return os(this,void 0,void 0,function*(){if(!this.eagerConnection)return this.eagerConnection=Promise.resolve().then(()=>jS(IS())).then(e=>os(this,void 0,void 0,function*(){var r,n;const i=yield e.default(this.options);i&&(this.provider=i,!((r=this.provider.providers)===null||r===void 0)&&r.length&&(this.provider=(n=this.provider.providers.find(s=>s.isMetaMask))!==null&&n!==void 0?n:this.provider.providers[0]),this.provider.on("connect",({chainId:s})=>{this.actions.update({chainId:fl(s)})}),this.provider.on("disconnect",s=>{var o;if(s.code===1013){console.debug('MetaMask logged connection error 1013: "Try again later"');return}this.actions.resetState(),(o=this.onError)===null||o===void 0||o.call(this,s)}),this.provider.on("chainChanged",s=>{this.actions.update({chainId:fl(s)})}),this.provider.on("accountsChanged",s=>{s.length===0?this.actions.resetState():this.actions.update({accounts:s})}))}))})}connectEagerly(){return os(this,void 0,void 0,function*(){const e=this.actions.startActivation();try{if(yield this.isomorphicInitialize(),!this.provider)return e();const r=yield this.provider.request({method:"eth_accounts"});if(!r.length)throw new Error("No accounts returned");const n=yield this.provider.request({method:"eth_chainId"});this.actions.update({chainId:fl(n),accounts:r})}catch(r){console.debug("Could not connect eagerly",r),this.actions.resetState()}})}activate(e){var r,n;return os(this,void 0,void 0,function*(){let i;return!((n=(r=this.provider)===null||r===void 0?void 0:r.isConnected)===null||n===void 0)&&n.call(r)||(i=this.actions.startActivation()),this.isomorphicInitialize().then(()=>os(this,void 0,void 0,function*(){if(!this.provider)throw new Ea;const s=yield this.provider.request({method:"eth_requestAccounts"}),o=yield this.provider.request({method:"eth_chainId"}),a=fl(o),l=typeof e=="number"?e:e==null?void 0:e.chainId;if(!l||a===l)return this.actions.update({chainId:a,accounts:s});const u=`0x${l.toString(16)}`;return this.provider.request({method:"wallet_switchEthereumChain",params:[{chainId:u}]}).catch(c=>{var h,p;if((((p=(h=c.data)===null||h===void 0?void 0:h.originalError)===null||p===void 0?void 0:p.code)||c.code)===4902&&typeof e!="number"){if(!this.provider)throw new Error("No provider");return this.provider.request({method:"wallet_addEthereumChain",params:[Object.assign(Object.assign({},e),{chainId:u})]})}throw c}).then(()=>this.activate(l))})).catch(s=>{throw i==null||i(),s})})}watchAsset({address:e,symbol:r,decimals:n,image:i}){return os(this,void 0,void 0,function*(){if(!this.provider)throw new Error("No provider");return this.provider.request({method:"wallet_watchAsset",params:{type:"ERC20",options:{address:e,symbol:r,decimals:n,image:i}}}).then(s=>{if(!s)throw new Error("Rejected");return!0})})}}N2=ba.MetaMask=BS;const[M2,n0]=Hu.initializeConnector(t=>new N2({actions:t}));function eg(t){const e=t.split("."),r=new Uint8Array(t.length+e.length);let n=0;for(const i of e){const s=i.length;r[n]=s,n++;for(let o=0;oi.toString(16).padStart(2,"0")).join("")}`}const tg=/^\d+\.\d+\.\d+$/,DS=({app:t,packageName:e,publisherId:r,goBack:n})=>{var h,p,m,v,b,k,x,w;const[i,s]=L.useState({name:((h=t==null?void 0:t.metadata)==null?void 0:h.name)||"",description:((p=t==null?void 0:t.metadata)==null?void 0:p.description)||"",image:((m=t==null?void 0:t.metadata)==null?void 0:m.image)||"",external_url:((v=t==null?void 0:t.metadata)==null?void 0:v.external_url)||"",animation_url:((b=t==null?void 0:t.metadata)==null?void 0:b.animation_url)||"",package_name:e,current_version:"",publisher:r,mirrors:[r]}),[o,a]=L.useState(Object.entries(((x=(k=t==null?void 0:t.metadata)==null?void 0:k.properties)==null?void 0:x.code_hashes)||{}).concat([["",((w=t==null?void 0:t.state)==null?void 0:w.our_version)||""]])),l=(A,T)=>{s({...i,[A]:T})};L.useEffect(()=>{l("package_name",e)},[e]),L.useEffect(()=>{l("publisher",r)},[r]);const u=L.useCallback(()=>{const A=o.reduce(($,[V,G])=>($[V]=G,$),{});if(tg.test(i.current_version))if(A[i.current_version]){if(!Object.keys(A).reduce(($,V)=>$&&tg.test(V),!0)){window.alert("Code hashes must be a JSON object with valid version keys");return}}else{window.alert(`Code hashes must include current version (${i.current_version})`);return}else{window.alert("Current version must be in the format x.y.z");return}const T=JSON.stringify({name:i.name,description:i.description,image:i.image,external_url:i.external_url,animation_url:i.animation_url,properties:{package_name:i.package_name,current_version:i.current_version,publisher:i.publisher,mirrors:i.mirrors,code_hashes:A}}),I=new Blob([T],{type:"application/json"}),B=URL.createObjectURL(I),F=document.createElement("a");F.href=B,F.download=i.package_name+"_"+i.publisher+"_metadata.json",F.click(),URL.revokeObjectURL(B)},[i,o]),c=()=>{s({name:"",description:"",image:"",external_url:"",animation_url:"",package_name:"",current_version:"",publisher:"",mirrors:[]}),a([])};return _.jsxs("form",{className:"flex flex-col card mt-2 gap-2",children:[_.jsx("h4",{children:"Fill out metadata"}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Name"}),_.jsx("input",{type:"text",placeholder:"Name",value:i.name,onChange:A=>l("name",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Description"}),_.jsx("input",{type:"text",placeholder:"Description",value:i.description,onChange:A=>l("description",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Image URL"}),_.jsx("input",{type:"text",placeholder:"Image URL",value:i.image,onChange:A=>l("image",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"External URL"}),_.jsx("input",{type:"text",placeholder:"External URL",value:i.external_url,onChange:A=>l("external_url",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Animation URL"}),_.jsx("input",{type:"text",placeholder:"Animation URL",value:i.animation_url,onChange:A=>l("animation_url",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Package Name"}),_.jsx("input",{type:"text",placeholder:"Package Name",value:i.package_name,onChange:A=>l("package_name",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Current Version"}),_.jsx("input",{type:"text",placeholder:"Current Version",value:i.current_version,onChange:A=>l("current_version",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Publisher"}),_.jsx("input",{type:"text",placeholder:"Publisher",value:i.publisher,onChange:A=>l("publisher",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Mirrors (separated by commas)"}),_.jsx("input",{type:"text",placeholder:"Mirrors (separated by commas)",value:i.mirrors.join(","),onChange:A=>l("mirrors",A.target.value.split(",").map(T=>T.trim()))})]}),_.jsxs("div",{className:"flex flex-col w-3/4 gap-2",children:[_.jsxs("div",{className:"flex gap-2 mt-0 justify-between w-full",children:[_.jsx("h5",{className:"m-0",children:"Code Hashes"}),_.jsx("button",{type:"button",onClick:()=>a([...o,["",""]]),className:"clear",children:"Add code hash"})]}),o.map(([A,T],I,B)=>_.jsxs("div",{className:"flex gap-2 mt-0 w-full",children:[_.jsx("input",{type:"text",placeholder:"Version",value:A,onChange:F=>a($=>{const V=[...$];return V[I][0]=F.target.value,V}),className:"flex-1"}),_.jsx("input",{type:"text",placeholder:"Hash",value:T,onChange:F=>a($=>{const V=[...$];return V[I][1]=F.target.value,V}),className:"flex-5"}),B.length>1&&_.jsx("button",{type:"button",onClick:()=>a(F=>F.filter(($,V)=>V!==I)),className:"icon",children:_.jsx(w2,{})})]},I+"_code_hash"))]}),_.jsxs("div",{className:"flex gap-2 my-4",children:[_.jsx("button",{type:"button",onClick:u,className:"alt",children:"Download JSON"}),_.jsx("button",{type:"button",onClick:c,className:"clear",children:"Clear Form"}),_.jsx("button",{type:"button",onClick:n,children:"Done"})]})]})};function FS({readOnly:t=!1,checked:e,setChecked:r}){return _.jsxs("div",{className:"relative",children:[_.jsx("input",{type:"checkbox",id:"checked",name:"checked",checked:e,onChange:n=>r&&r(n.target.checked),autoFocus:!0,readOnly:t}),e&&_.jsx(v2,{className:"absolute left-1 top-1 cursor-pointer",onClick:()=>r&&r(!1)})]})}var Qn=function(t){t==null&&(t=new Date().getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,t.constructor==Array?this.init_by_array(t,t.length):this.init_seed(t)};Qn.prototype.init_seed=function(t){for(this.mt[0]=t>>>0,this.mti=1;this.mti>>30;this.mt[this.mti]=(((t&4294901760)>>>16)*1812433253<<16)+(t&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0}};Qn.prototype.init_by_array=function(t,e){var r,n,i;for(this.init_seed(19650218),r=1,n=0,i=this.N>e?this.N:e;i;i--){var s=this.mt[r-1]^this.mt[r-1]>>>30;this.mt[r]=(this.mt[r]^(((s&4294901760)>>>16)*1664525<<16)+(s&65535)*1664525)+t[n]+n,this.mt[r]>>>=0,r++,n++,r>=this.N&&(this.mt[0]=this.mt[this.N-1],r=1),n>=e&&(n=0)}for(i=this.N-1;i;i--){var s=this.mt[r-1]^this.mt[r-1]>>>30;this.mt[r]=(this.mt[r]^(((s&4294901760)>>>16)*1566083941<<16)+(s&65535)*1566083941)-r,this.mt[r]>>>=0,r++,r>=this.N&&(this.mt[0]=this.mt[this.N-1],r=1)}this.mt[0]=2147483648};Qn.prototype.random_int=function(){var t,e=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var r;for(this.mti==this.N+1&&this.init_seed(5489),r=0;r>>1^e[t&1];for(;r>>1^e[t&1];t=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^t>>>1^e[t&1],this.mti=0}return t=this.mt[this.mti++],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0};Qn.prototype.random_int31=function(){return this.random_int()>>>1};Qn.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};Qn.prototype.random=function(){return this.random_int()*(1/4294967296)};Qn.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};Qn.prototype.random_long=function(){var t=this.random_int()>>>5,e=this.random_int()>>>6;return(t*67108864+e)*(1/9007199254740992)};var US=Qn;function zS(t,e){var r=document.createElement("div");return r.style.borderRadius="50px",r.style.overflow="hidden",r.style.padding="0px",r.style.margin="0px",r.style.width=""+t+"px",r.style.height=""+t+"px",r.style.display="inline-block",r.style.background=e,{container:r}}var $S=zS,C2={exports:{}};(function(t){var e=function(){function r(l,u,c,h){typeof u=="object"&&(c=u.depth,h=u.prototype,u.filter,u=u.circular);var p=[],m=[],v=typeof Buffer<"u";typeof u>"u"&&(u=!0),typeof c>"u"&&(c=1/0);function b(k,x){if(k===null)return null;if(x==0)return k;var w,A;if(typeof k!="object")return k;if(r.__isArray(k))w=[];else if(r.__isRegExp(k))w=new RegExp(k.source,a(k)),k.lastIndex&&(w.lastIndex=k.lastIndex);else if(r.__isDate(k))w=new Date(k.getTime());else{if(v&&Buffer.isBuffer(k))return Buffer.allocUnsafe?w=Buffer.allocUnsafe(k.length):w=new Buffer(k.length),k.copy(w),w;typeof h>"u"?(A=Object.getPrototypeOf(k),w=Object.create(A)):(w=Object.create(h),A=h)}if(u){var T=p.indexOf(k);if(T!=-1)return m[T];p.push(k),m.push(w)}for(var I in k){var B;A&&(B=Object.getOwnPropertyDescriptor(A,I)),!(B&&B.set==null)&&(w[I]=b(k[I],x-1))}return w}return b(l,c)}r.clonePrototype=function(u){if(u===null)return null;var c=function(){};return c.prototype=u,new c};function n(l){return Object.prototype.toString.call(l)}r.__objToStr=n;function i(l){return typeof l=="object"&&n(l)==="[object Date]"}r.__isDate=i;function s(l){return typeof l=="object"&&n(l)==="[object Array]"}r.__isArray=s;function o(l){return typeof l=="object"&&n(l)==="[object RegExp]"}r.__isRegExp=o;function a(l){var u="";return l.global&&(u+="g"),l.ignoreCase&&(u+="i"),l.multiline&&(u+="m"),u}return r.__getRegExpFlags=a,r}();t.exports&&(t.exports=e)})(C2);var HS=C2.exports,P2={exports:{}},VS={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},zi=VS,R2={};for(var Sf in zi)zi.hasOwnProperty(Sf)&&(R2[zi[Sf]]=Sf);var re=P2.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var tr in re)if(re.hasOwnProperty(tr)){if(!("channels"in re[tr]))throw new Error("missing channels property: "+tr);if(!("labels"in re[tr]))throw new Error("missing channel labels property: "+tr);if(re[tr].labels.length!==re[tr].channels)throw new Error("channel and label counts mismatch: "+tr);var qS=re[tr].channels,GS=re[tr].labels;delete re[tr].channels,delete re[tr].labels,Object.defineProperty(re[tr],"channels",{value:qS}),Object.defineProperty(re[tr],"labels",{value:GS})}re.rgb.hsl=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(e,r,n),s=Math.max(e,r,n),o=s-i,a,l,u;return s===i?a=0:e===s?a=(r-n)/o:r===s?a=2+(n-e)/o:n===s&&(a=4+(e-r)/o),a=Math.min(a*60,360),a<0&&(a+=360),u=(i+s)/2,s===i?l=0:u<=.5?l=o/(s+i):l=o/(2-s-i),[a,l*100,u*100]};re.rgb.hsv=function(t){var e,r,n,i,s,o=t[0]/255,a=t[1]/255,l=t[2]/255,u=Math.max(o,a,l),c=u-Math.min(o,a,l),h=function(p){return(u-p)/6/c+1/2};return c===0?i=s=0:(s=c/u,e=h(o),r=h(a),n=h(l),o===u?i=n-r:a===u?i=1/3+e-n:l===u&&(i=2/3+r-e),i<0?i+=1:i>1&&(i-=1)),[i*360,s*100,u*100]};re.rgb.hwb=function(t){var e=t[0],r=t[1],n=t[2],i=re.rgb.hsl(t)[0],s=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[i,s*100,n*100]};re.rgb.cmyk=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,i,s,o,a;return a=Math.min(1-e,1-r,1-n),i=(1-e-a)/(1-a)||0,s=(1-r-a)/(1-a)||0,o=(1-n-a)/(1-a)||0,[i*100,s*100,o*100,a*100]};function WS(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}re.rgb.keyword=function(t){var e=R2[t];if(e)return e;var r=1/0,n;for(var i in zi)if(zi.hasOwnProperty(i)){var s=zi[i],o=WS(t,s);o.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var i=e*.4124+r*.3576+n*.1805,s=e*.2126+r*.7152+n*.0722,o=e*.0193+r*.1192+n*.9505;return[i*100,s*100,o*100]};re.rgb.lab=function(t){var e=re.rgb.xyz(t),r=e[0],n=e[1],i=e[2],s,o,a;return r/=95.047,n/=100,i/=108.883,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=116*n-16,o=500*(r-n),a=200*(n-i),[s,o,a]};re.hsl.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,i,s,o,a,l;if(r===0)return l=n*255,[l,l,l];n<.5?s=n*(1+r):s=n+r-n*r,i=2*n-s,a=[0,0,0];for(var u=0;u<3;u++)o=e+1/3*-(u-1),o<0&&o++,o>1&&o--,6*o<1?l=i+(s-i)*6*o:2*o<1?l=s:3*o<2?l=i+(s-i)*(2/3-o)*6:l=i,a[u]=l*255;return a};re.hsl.hsv=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,i=r,s=Math.max(n,.01),o,a;return n*=2,r*=n<=1?n:2-n,i*=s<=1?s:2-s,a=(n+r)/2,o=n===0?2*i/(s+i):2*r/(n+r),[e,o*100,a*100]};re.hsv.rgb=function(t){var e=t[0]/60,r=t[1]/100,n=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*n*(1-r),a=255*n*(1-r*s),l=255*n*(1-r*(1-s));switch(n*=255,i){case 0:return[n,l,o];case 1:return[a,n,o];case 2:return[o,n,l];case 3:return[o,a,n];case 4:return[l,o,n];case 5:return[n,o,a]}};re.hsv.hsl=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,i=Math.max(n,.01),s,o,a;return a=(2-r)*n,s=(2-r)*i,o=r*i,o/=s<=1?s:2-s,o=o||0,a/=2,[e,o*100,a*100]};re.hwb.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,i=r+n,s,o,a,l;i>1&&(r/=i,n/=i),s=Math.floor(6*e),o=1-n,a=6*e-s,s&1&&(a=1-a),l=r+a*(o-r);var u,c,h;switch(s){default:case 6:case 0:u=o,c=l,h=r;break;case 1:u=l,c=o,h=r;break;case 2:u=r,c=o,h=l;break;case 3:u=r,c=l,h=o;break;case 4:u=l,c=r,h=o;break;case 5:u=o,c=r,h=l;break}return[u*255,c*255,h*255]};re.cmyk.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,i=t[3]/100,s,o,a;return s=1-Math.min(1,e*(1-i)+i),o=1-Math.min(1,r*(1-i)+i),a=1-Math.min(1,n*(1-i)+i),[s*255,o*255,a*255]};re.xyz.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,i,s,o;return i=e*3.2406+r*-1.5372+n*-.4986,s=e*-.9689+r*1.8758+n*.0415,o=e*.0557+r*-.204+n*1.057,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*12.92,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o*12.92,i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),[i*255,s*255,o*255]};re.xyz.lab=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;return e/=95.047,r/=100,n/=108.883,e=e>.008856?Math.pow(e,1/3):7.787*e+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,i=116*r-16,s=500*(e-r),o=200*(r-n),[i,s,o]};re.lab.xyz=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;s=(e+16)/116,i=r/500+s,o=s-n/200;var a=Math.pow(s,3),l=Math.pow(i,3),u=Math.pow(o,3);return s=a>.008856?a:(s-16/116)/7.787,i=l>.008856?l:(i-16/116)/7.787,o=u>.008856?u:(o-16/116)/7.787,i*=95.047,s*=100,o*=108.883,[i,s,o]};re.lab.lch=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;return i=Math.atan2(n,r),s=i*360/2/Math.PI,s<0&&(s+=360),o=Math.sqrt(r*r+n*n),[e,o,s]};re.lch.lab=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;return o=n/360*2*Math.PI,i=r*Math.cos(o),s=r*Math.sin(o),[e,i,s]};re.rgb.ansi16=function(t){var e=t[0],r=t[1],n=t[2],i=1 in arguments?arguments[1]:re.rgb.hsv(t)[2];if(i=Math.round(i/50),i===0)return 30;var s=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(e/255));return i===2&&(s+=60),s};re.hsv.ansi16=function(t){return re.rgb.ansi16(re.hsv.rgb(t),t[2])};re.rgb.ansi256=function(t){var e=t[0],r=t[1],n=t[2];if(e===r&&r===n)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;var i=16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5);return i};re.ansi16.rgb=function(t){var e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];var r=(~~(t>50)+1)*.5,n=(e&1)*r*255,i=(e>>1&1)*r*255,s=(e>>2&1)*r*255;return[n,i,s]};re.ansi256.rgb=function(t){if(t>=232){var e=(t-232)*10+8;return[e,e,e]}t-=16;var r,n=Math.floor(t/36)/5*255,i=Math.floor((r=t%36)/6)/5*255,s=r%6/5*255;return[n,i,s]};re.rgb.hex=function(t){var e=((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255),r=e.toString(16).toUpperCase();return"000000".substring(r.length)+r};re.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var r=e[0];e[0].length===3&&(r=r.split("").map(function(a){return a+a}).join(""));var n=parseInt(r,16),i=n>>16&255,s=n>>8&255,o=n&255;return[i,s,o]};re.rgb.hcg=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.max(Math.max(e,r),n),s=Math.min(Math.min(e,r),n),o=i-s,a,l;return o<1?a=s/(1-o):a=0,o<=0?l=0:i===e?l=(r-n)/o%6:i===r?l=2+(n-e)/o:l=4+(e-r)/o+4,l/=6,l%=1,[l*360,o*100,a*100]};re.hsl.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1,i=0;return r<.5?n=2*e*r:n=2*e*(1-r),n<1&&(i=(r-.5*n)/(1-n)),[t[0],n*100,i*100]};re.hsv.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=e*r,i=0;return n<1&&(i=(r-n)/(1-n)),[t[0],n*100,i*100]};re.hcg.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100;if(r===0)return[n*255,n*255,n*255];var i=[0,0,0],s=e%1*6,o=s%1,a=1-o,l=0;switch(Math.floor(s)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=a,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=a,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=a}return l=(1-r)*n,[(r*i[0]+l)*255,(r*i[1]+l)*255,(r*i[2]+l)*255]};re.hcg.hsv=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e),i=0;return n>0&&(i=e/n),[t[0],i*100,n*100]};re.hcg.hsl=function(t){var e=t[1]/100,r=t[2]/100,n=r*(1-e)+.5*e,i=0;return n>0&&n<.5?i=e/(2*n):n>=.5&&n<1&&(i=e/(2*(1-n))),[t[0],i*100,n*100]};re.hcg.hwb=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e);return[t[0],(n-e)*100,(1-n)*100]};re.hwb.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1-r,i=n-e,s=0;return i<1&&(s=(n-i)/(1-i)),[t[0],i*100,s*100]};re.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};re.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};re.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};re.gray.hsl=re.gray.hsv=function(t){return[0,0,t[0]]};re.gray.hwb=function(t){return[0,100,t[0]]};re.gray.cmyk=function(t){return[0,0,0,t[0]]};re.gray.lab=function(t){return[t[0],0,0]};re.gray.hex=function(t){var e=Math.round(t[0]/100*255)&255,r=(e<<16)+(e<<8)+e,n=r.toString(16).toUpperCase();return"000000".substring(n.length)+n};re.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[e/255*100]};var I2=P2.exports,Eu=I2;function KS(){for(var t={},e=Object.keys(Eu),r=e.length,n=0;n1&&(r=Array.prototype.slice.call(arguments)),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function rk(t){var e=function(r){if(r==null)return r;arguments.length>1&&(r=Array.prototype.slice.call(arguments));var n=t(r);if(typeof n=="object")for(var i=n.length,s=0;sr?(e+.05)/(r+.05):(r+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(t[0]*299+t[1]*587+t[2]*114)/1e3;return e<128},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;e<3;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=t[0]*.3+t[1]*.59+t[2]*.11;return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=e<0?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){var r=this,n=t,i=e===void 0?.5:e,s=2*i-1,o=r.alpha()-n.alpha(),a=((s*o===-1?s:(s+o)/(1+s*o))+1)/2,l=1-a;return this.rgb(a*r.red()+l*n.red(),a*r.green()+l*n.green(),a*r.blue()+l*n.blue()).alpha(r.alpha()*i+n.alpha()*(1-i))},toJSON:function(){return this.rgb()},clone:function(){var t=new vn;return t.values=mk(this.values),t}};vn.prototype.getValues=function(t){for(var e={},r=0;r{const n=L.useRef(null);return L.useEffect(()=>{if(t&&n.current){const i=parseInt(t.slice(2,10),16),s=Mk(e,i);n.current.innerHTML="",n.current.appendChild(s)}},[t,e]),_.jsx("div",{...r,ref:n})},{useIsActivating:Ck}=n0;function Pk({provider:t,packageAbi:e}){var g;const{state:r}=$u(),{listedApps:n}=Pi(),{account:i,isActive:s}=Hu.useWeb3React(),o=Ck(),[a,l]=L.useState(""),[u,c]=L.useState(),[h,p]=L.useState(!1),[m,v]=L.useState(""),[b,k]=L.useState(((g=window.our)==null?void 0:g.node)||""),[x,w]=L.useState(""),[A,T]=L.useState(""),[I,B]=L.useState(!1),[F,$]=L.useState([]);L.useEffect(()=>{const E=r==null?void 0:r.app;E&&(v(E.package),k(E.publisher),B(!0))},[r]),L.useEffect(()=>{$(n.filter(E=>{var M;return((M=E.owner)==null?void 0:M.toLowerCase())===(i==null?void 0:i.toLowerCase())}))},[n,i]);const V=L.useCallback(async()=>{await M2.activate().catch(()=>{});try{Af(zo)}catch(E){console.error(E)}},[]),G=L.useCallback(async()=>{if(!x){T("");return}try{const M=await(await fetch(x)).text();JSON.parse(M);const S=ot(yr(M));T(S)}catch{window.alert("Error calculating metadata hash. Please ensure the URL is valid and the metadata is in JSON format.")}},[x]),Y=L.useCallback(async E=>{var S;E.preventDefault(),E.stopPropagation();let M=A;try{if(!M){const N=await fetch(x);await N.json();const d=await N.text();M=ot(yr(d))}l("Please confirm the transaction in your wallet");const P=eg(b);await Af(zo);const O=await(I?e==null?void 0:e.updateMetadata(K.from(i6(["string","bytes"],[m,P])),x,M):e==null?void 0:e.registerApp(m,P,x,M));await new Promise(N=>setTimeout(N,2e3)),l("Publishing package..."),await(O==null?void 0:O.wait()),c({packageName:m,publisherId:b}),v(""),k(((S=window.our)==null?void 0:S.node)||b),w(""),T(""),B(!1)}catch(P){console.error(P),window.alert("Error publishing package. Please ensure the package name and publisher ID are valid, and the metadata is in JSON format.")}finally{l("")}},[m,I,b,x,A,e,c,v,k,w,T,B]),$e=L.useCallback(async(E,M)=>{try{await Af(zo);const S=await(e==null?void 0:e.unlistPacakge(ot(l2(["string","bytes"],[E,eg(M)]))));await new Promise(P=>setTimeout(P,2e3)),l("Unlisting package..."),await(S==null?void 0:S.wait())}catch(S){console.error(S),window.alert("Error unlisting package")}finally{l("")}},[e,l]),R=L.useCallback(async()=>{I||m&&b&&n.find(E=>E.package===m&&E.publisher===b)&&B(!0)},[n,m,b,I,B]),f=Kn();return _.jsxs("div",{className:ue("w-full flex flex-col gap-2",{"max-w-[900px]":!f,"p-2 h-screen w-screen":f}),children:[!f&&_.jsx(ac,{}),_.jsx(oc,{hideSearch:!0,hidePublish:!0,onBack:h?()=>p(!1):void 0}),_.jsxs("div",{className:"flex-center justify-between",children:[_.jsx("h4",{children:"Publish Package"}),!!i&&_.jsxs("div",{className:"card flex-center",children:[_.jsx("span",{children:"Publishing as:"}),_.jsx(ig,{address:i,className:"mx-2"}),_.jsxs("span",{className:"font-mono",children:[i==null?void 0:i.slice(0,4),"...",i==null?void 0:i.slice(-4)]})]})]}),a?_.jsx("div",{className:"flex-col-center",children:_.jsx(ya,{msg:a})}):u?_.jsxs("div",{className:"flex-col-center gap-2",children:[_.jsx("h4",{children:"Package Published!"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Package Name:"})," ",u.packageName]}),_.jsxs("div",{children:[_.jsx("strong",{children:"Publisher ID:"})," ",u.publisherId]}),_.jsx("button",{className:"flex ml-2",onClick:()=>c(void 0),children:"Publish Another Package"})]}):h?_.jsx(DS,{packageName:m,publisherId:b,app:r==null?void 0:r.app,goBack:()=>p(!1)}):!i||!s?_.jsxs(_.Fragment,{children:[_.jsxs("h4",{children:["Please connect your wallet ",f&&_.jsx("br",{})," to publish a package"]}),_.jsx("button",{className:"connect-wallet row",onClick:V,children:"Connect Wallet"})]}):o?_.jsx(ya,{msg:"Approve connection in your wallet"}):_.jsxs("form",{className:"flex flex-col flex-1 overflow-y-auto gap-2",onSubmit:Y,children:[_.jsxs("div",{className:"flex cursor-pointer p-2 -mb-2",onClick:()=>B(!I),children:[_.jsx(FS,{checked:I,readOnly:!0}),_.jsx("label",{htmlFor:"update",className:"cursor-pointer ml-4",children:"Update existing package"})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("label",{htmlFor:"package-name",children:"Package Name"}),_.jsx("input",{id:"package-name",type:"text",required:!0,placeholder:"my-package",value:m,onChange:E=>v(E.target.value),onBlur:R})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("label",{htmlFor:"publisher-id",children:"Publisher ID"}),_.jsx("input",{id:"publisher-id",type:"text",required:!0,value:b,onChange:E=>k(E.target.value),onBlur:R})]}),_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsx("label",{htmlFor:"metadata-url",children:"Metadata URL"}),_.jsx("input",{id:"metadata-url",type:"text",required:!0,value:x,onChange:E=>w(E.target.value),onBlur:G,placeholder:"https://github/my-org/my-repo/metadata.json"}),_.jsxs("div",{children:["Metadata is a JSON file that describes your package.",_.jsx("br",{})," You can"," ",_.jsx("a",{onClick:()=>p(!0),className:"underline cursor-pointer",children:"fill out a template here"}),"."]})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("label",{htmlFor:"metadata-hash",children:"Metadata Hash"}),_.jsx("input",{readOnly:!0,id:"metadata-hash",type:"text",value:A,onChange:E=>T(E.target.value),placeholder:"Calculated automatically from metadata URL"})]}),_.jsx("button",{type:"submit",children:"Publish"})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("h4",{children:"Packages You Own"}),F.length>0?_.jsx("div",{className:"flex flex-col",children:F.map(E=>_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("div",{className:"flex items-center",children:[_.jsx(ig,{address:E.publisher,className:"mr-2"}),_.jsx("span",{children:E.package})]}),_.jsx("button",{className:"flex items-center",onClick:()=>$e(E.package,E.publisher),children:_.jsx("span",{children:"Unpublish"})})]},`${E.package}${E.publisher}`))}):_.jsx("div",{className:"flex items-center",children:_.jsx("span",{children:"No packages published"})})]})]})}var Rk={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Ik=[[M2,n0]],{useProvider:Ok}=n0,$o="/main:app_store:sys";window.our&&(window.our.process=$o==null?void 0:$o.replace("/",""));const Tk=`${Rk.VITE_NODE_URL||"http://localhost:8080"}${$o}`;function jk(){const t=Ok(),[e,r]=L.useState(!0),[n,i]=L.useState(void 0);if(L.useEffect(()=>{if(!t)return;(async()=>{(await t.getNetwork()).chainId===Uh.OPTIMISM&&i(u2.connect(MS[Uh.OPTIMISM],t.getSigner()))})()},[t]),L.useEffect(()=>{},[]),!e)return _.jsxs("div",{className:"flex flex-col c",children:[_.jsx("h2",{style:{color:"red"},children:"Node not connected"}),_.jsxs("h4",{children:["You need to start a node at ",Tk," before you can use this UI in development."]})]});const s={provider:t,packageAbi:n};return _.jsx("div",{className:"flex flex-col c h-screen w-screen max-h-screen max-w-screen overflow-x-hidden special-appstore-background",children:_.jsx(Hu.Web3ReactProvider,{connectors:Ik,children:_.jsx(a3,{basename:$o,children:_.jsxs(s3,{children:[_.jsx(ko,{path:$6,element:_.jsx(SS,{})}),_.jsx(ko,{path:Lh,element:_.jsx(kS,{})}),_.jsx(ko,{path:`${vu}/:id`,element:_.jsx(NS,{})}),_.jsx(ko,{path:sc,element:_.jsx(Pk,{...s})})]})})})})}Nf.createRoot(document.getElementById("root")).render(_.jsx(Wr.StrictMode,{children:_.jsx(jk,{})})); +*/(function(t){(function(){var e={}.hasOwnProperty;function r(){for(var s="",o=0;owindow.innerWidth<=600,M6=({text:t,className:e,size:r})=>{var o;const i=`/icons/${((o=t.split("").pop())==null?void 0:o.toUpperCase())||"0"}`;if(!i)return null;const s=Kn();return _.jsx("img",{src:i,className:ue("m-0 align-self-center rounded-full",{"h-32 w-32":!s&&r==="large","h-18 w-18":!s&&r==="medium","h-12 w-12":s||r==="small"},e)})};function g2({app:t,size:e="medium",overrideImageSize:r,...n}){var a,l,u,c,h;const i=Kn(),s=_.jsx("div",{className:ue({"text-3xl font-[OpenSans]":!i&&e==="large","text-xl":!i&&e!=="large","text-lg":i}),children:((a=t.metadata)==null?void 0:a.name)||Ee(t)}),o=r||e;return _.jsxs("div",{...n,className:ue("flex w-full justify-content-start",e,n.className,{"flex-col":e==="small","gap-2":i,"gap-4":!i,"gap-6":!i&&e==="large"}),children:[e==="small"&&s,(l=t.metadata)!=null&&l.image?_.jsx("img",{src:t.metadata.image,alt:"app icon",className:ue("object-cover",{rounded:!o,"rounded-md":o==="small","rounded-lg":o==="medium","rounded-2xl":o==="large","h-32":o==="large"||o==="small","h-20":o==="medium"})}):_.jsx(M6,{text:t.metadata_hash||((c=(u=t.state)==null?void 0:u.our_version)==null?void 0:c.toString())||"",size:o}),_.jsxs("div",{className:ue("flex flex-col",{"gap-2":i,"gap-4 max-w-3/4":i&&e!=="small"}),children:[e!=="small"&&s,((h=t.metadata)==null?void 0:h.description)&&_.jsx("div",{style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},className:ue({"text-2xl":e==="large"}),children:t.metadata.description})]})]})}function C6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"},child:[]}]})(t)}function P6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M386.3 160H336c-17.7 0-32 14.3-32 32s14.3 32 32 32H464c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32s-32 14.3-32 32v51.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0s-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3s163.8-62.5 226.3 0L386.3 160z"},child:[]}]})(t)}function v2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},child:[]}]})(t)}function R6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M222.7 32.1c5 16.9-4.6 34.8-21.5 39.8C121.8 95.6 64 169.1 64 256c0 106 86 192 192 192s192-86 192-192c0-86.9-57.8-160.4-137.1-184.1c-16.9-5-26.6-22.9-21.5-39.8s22.9-26.6 39.8-21.5C434.9 42.1 512 140 512 256c0 141.4-114.6 256-256 256S0 397.4 0 256C0 140 77.1 42.1 182.9 10.6c16.9-5 34.8 4.6 39.8 21.5z"},child:[]}]})(t)}function y2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"},child:[]}]})(t)}function I6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M352 256c0 22.2-1.2 43.6-3.3 64H163.3c-2.2-20.4-3.3-41.8-3.3-64s1.2-43.6 3.3-64H348.7c2.2 20.4 3.3 41.8 3.3 64zm28.8-64H503.9c5.3 20.5 8.1 41.9 8.1 64s-2.8 43.5-8.1 64H380.8c2.1-20.6 3.2-42 3.2-64s-1.1-43.4-3.2-64zm112.6-32H376.7c-10-63.9-29.8-117.4-55.3-151.6c78.3 20.7 142 77.5 171.9 151.6zm-149.1 0H167.7c6.1-36.4 15.5-68.6 27-94.7c10.5-23.6 22.2-40.7 33.5-51.5C239.4 3.2 248.7 0 256 0s16.6 3.2 27.8 13.8c11.3 10.8 23 27.9 33.5 51.5c11.6 26 20.9 58.2 27 94.7zm-209 0H18.6C48.6 85.9 112.2 29.1 190.6 8.4C165.1 42.6 145.3 96.1 135.3 160zM8.1 192H131.2c-2.1 20.6-3.2 42-3.2 64s1.1 43.4 3.2 64H8.1C2.8 299.5 0 278.1 0 256s2.8-43.5 8.1-64zM194.7 446.6c-11.6-26-20.9-58.2-27-94.6H344.3c-6.1 36.4-15.5 68.6-27 94.6c-10.5 23.6-22.2 40.7-33.5 51.5C272.6 508.8 263.3 512 256 512s-16.6-3.2-27.8-13.8c-11.3-10.8-23-27.9-33.5-51.5zM135.3 352c10 63.9 29.8 117.4 55.3 151.6C112.2 482.9 48.6 426.1 18.6 352H135.3zm358.1 0c-30 74.1-93.6 130.9-171.9 151.6c25.5-34.2 45.2-87.7 55.3-151.6H493.4z"},child:[]}]})(t)}function O6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M32 32C14.3 32 0 46.3 0 64S14.3 96 32 96h96V416H32c-17.7 0-32 14.3-32 32s14.3 32 32 32H288c17.7 0 32-14.3 32-32s-14.3-32-32-32H192V96h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H160 32z"},child:[]}]})(t)}function T6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"},child:[]}]})(t)}function j6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M72 88a56 56 0 1 1 112 0A56 56 0 1 1 72 88zM64 245.7C54 256.9 48 271.8 48 288s6 31.1 16 42.3V245.7zm144.4-49.3C178.7 222.7 160 261.2 160 304c0 34.3 12 65.8 32 90.5V416c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V389.2C26.2 371.2 0 332.7 0 288c0-61.9 50.1-112 112-112h32c24 0 46.2 7.5 64.4 20.3zM448 416V394.5c20-24.7 32-56.2 32-90.5c0-42.8-18.7-81.3-48.4-107.7C449.8 183.5 472 176 496 176h32c61.9 0 112 50.1 112 112c0 44.7-26.2 83.2-64 101.2V416c0 17.7-14.3 32-32 32H480c-17.7 0-32-14.3-32-32zm8-328a56 56 0 1 1 112 0A56 56 0 1 1 456 88zM576 245.7v84.7c10-11.3 16-26.1 16-42.3s-6-31.1-16-42.3zM320 32a64 64 0 1 1 0 128 64 64 0 1 1 0-128zM240 304c0 16.2 6 31 16 42.3V261.7c-10 11.3-16 26.1-16 42.3zm144-42.3v84.7c10-11.3 16-26.1 16-42.3s-6-31.1-16-42.3zM448 304c0 44.7-26.2 83.2-64 101.2V448c0 17.7-14.3 32-32 32H288c-17.7 0-32-14.3-32-32V405.2c-37.8-18-64-56.5-64-101.2c0-61.9 50.1-112 112-112h32c61.9 0 112 50.1 112 112z"},child:[]}]})(t)}function L6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80V432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z"},child:[]}]})(t)}function B6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M32 32c17.7 0 32 14.3 32 32V288c0 70.7 57.3 128 128 128s128-57.3 128-128V64c0-17.7 14.3-32 32-32s32 14.3 32 32V288c0 106-86 192-192 192S0 394 0 288V64C0 46.3 14.3 32 32 32z"},child:[]}]})(t)}function D6(t){return Pt({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M288 109.3V352c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-73.4 73.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0l128 128c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L288 109.3zM64 352H192c0 35.3 28.7 64 64 64s64-28.7 64-64H448c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V416c0-35.3 28.7-64 64-64zM432 456a24 24 0 1 0 0-48 24 24 0 1 0 0 48z"},child:[]}]})(t)}function w2(t){return Pt({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M376.6 84.5c11.3-13.6 9.5-33.8-4.1-45.1s-33.8-9.5-45.1 4.1L192 206 56.6 43.5C45.3 29.9 25.1 28.1 11.5 39.4S-3.9 70.9 7.4 84.5L150.3 256 7.4 427.5c-11.3 13.6-9.5 33.8 4.1 45.1s33.8 9.5 45.1-4.1L192 306 327.4 468.5c11.3 13.6 31.5 15.4 45.1 4.1s15.4-31.5 4.1-45.1L233.7 256 376.6 84.5z"},child:[]}]})(t)}const t0=({show:t,hide:e,hideClose:r=!1,title:n,...i})=>{const s=o=>{o.stopPropagation()};return t?_.jsx("div",{className:ue("bg-black/25 backdrop-blur-lg fixed top-0 bottom-0 left-0 right-0 flex flex-col c z-30 min-h-[10em] min-w-[30em]",{show:t}),onClick:e,children:_.jsxs("div",{...i,className:`flex flex-col relative bg-black/90 rounded-lg py-6 px-12 ${i.className||""}`,onClick:s,children:[!!n&&_.jsx("h4",{className:"mt-0 mb-2",children:n}),!r&&_.jsx("button",{className:"icon absolute top-1 right-1",onClick:e,children:_.jsx(w2,{})}),_.jsx("div",{className:"flex flex-col items-center w-full",onClick:s,children:i.children})]})}):null};function ya({msg:t}){return _.jsxs("div",{id:"loading",className:"flex-col-center text-center gap-4",children:[_.jsx("h4",{children:t}),_.jsx(R6,{className:"animate-spin rounded-full h-8 w-8"})]})}function $m({app:t,isIcon:e=!1,...r}){const{updateApp:n,getCaps:i,getMyApp:s,getMyApps:o}=Pi(),[a,l]=L.useState(!1),[u,c]=L.useState([]),[h,p]=L.useState(""),m=L.useCallback(async b=>{b.preventDefault(),i(t).then(k=>{c(k.request_capabilities)}),l(!0)},[t,l,i]),v=L.useCallback(async()=>{try{p(`Updating ${Js(t)}...`),await n(t);const b=setInterval(()=>{s(t).then(k=>{k.installed&&(p(""),l(!1),clearInterval(b),o())}).catch(console.log)},2e3)}catch(b){console.error(b),window.alert("Failed to update, please try again."),p("")}},[t,n,s]);return _.jsxs(_.Fragment,{children:[_.jsx("button",{...r,type:"button",className:ue("text-sm self-start",r.className,{"icon clear":e}),onClick:m,children:e?_.jsx(B6,{}):"Update"}),_.jsx(t0,{show:a,hide:()=>l(!1),children:h?_.jsx(ya,{msg:h}):_.jsxs(_.Fragment,{children:[_.jsx("h4",{children:"Approve App Permissions"}),_.jsxs("h5",{className:"m-0",children:[Js(t)," needs the following permissions:"]}),_.jsx("br",{}),_.jsx("ul",{className:"flex flex-col items-start",children:u.map(b=>_.jsx("li",{children:b},b))}),_.jsx("button",{type:"button",onClick:v,children:"Approve & Update"})]})})]})}function F6({app:t,isIcon:e=!1,...r}){var w,A,T,I,B,F,$;const{downloadApp:n,getCaps:i,getMyApp:s,getMyApps:o}=Pi(),[a,l]=L.useState(!1),[u,c]=L.useState(((T=(A=(w=t.metadata)==null?void 0:w.properties)==null?void 0:A.mirrors)==null?void 0:T[0])||"Other"),[h,p]=L.useState(""),[m,v]=L.useState("");L.useEffect(()=>{var V,G,Y;c(((Y=(G=(V=t.metadata)==null?void 0:V.properties)==null?void 0:G.mirrors)==null?void 0:Y[0])||"Other")},[(B=(I=t.metadata)==null?void 0:I.properties)==null?void 0:B.mirrors]);const b=L.useCallback(async V=>{V.preventDefault(),l(!0)},[t,l,i]),k=L.useCallback(async V=>{V.preventDefault(),V.stopPropagation();const G=u==="Other"?h:u;if(!G){window.alert("Please select a mirror");return}try{v(`Downloading ${Js(t)}...`),await n(t,G);const Y=setInterval(()=>{s(t).then(()=>{v(""),l(!1),clearInterval(Y),o()}).catch(console.log)},2e3)}catch(Y){console.error(Y),window.alert(`Failed to download app from ${G}, please try a different mirror.`),v("")}},[u,h,t,n,s]),x=Js(t);return _.jsxs(_.Fragment,{children:[_.jsx("button",{...r,type:"button",className:ue("text-sm self-start",r.className,{"icon clear":e,black:!e}),disabled:!!m,onClick:b,children:e?_.jsx(y2,{}):m?"Downloading...":"Download"}),_.jsx(t0,{show:a,hide:()=>l(!1),children:m?_.jsxs("div",{className:"flex-col-center gap-4",children:[_.jsx(ya,{msg:m}),_.jsx("div",{className:"text-center",children:"App is downloading in the background. You can safely close this window."})]}):_.jsxs("form",{className:"flex flex-col items-center gap-2",onSubmit:k,children:[_.jsxs("h4",{children:["Download '",x,"'"]}),_.jsx("h5",{children:"Select Mirror"}),_.jsx("select",{value:u,onChange:V=>c(V.target.value),children:((($=(F=t.metadata)==null?void 0:F.properties)==null?void 0:$.mirrors)||[]).concat(["Other"]).map(V=>_.jsx("option",{value:V,children:V},V))}),u==="Other"&&_.jsx("input",{type:"text",value:h,onChange:V=>p(V.target.value),placeholder:"Mirror, i.e. 'template.os'",className:"p-1 max-w-[240px] w-full",required:!0,autoFocus:!0}),_.jsx("button",{type:"submit",children:"Download"})]})})]})}function U6({app:t,isIcon:e=!1,...r}){const{installApp:n,getCaps:i,getMyApp:s,getMyApps:o}=Pi(),[a,l]=L.useState(!1),[u,c]=L.useState([]),[h,p]=L.useState(""),m=L.useCallback(async b=>{b.preventDefault(),i(t).then(k=>{c(k.request_capabilities)}),l(!0)},[t,l,i]),v=L.useCallback(async()=>{try{p(`Installing ${Js(t)}...`),await n(t);const b=setInterval(()=>{s(t).then(k=>{k.installed&&(p(""),l(!1),clearInterval(b),o())}).catch(console.log)},2e3)}catch(b){console.error(b),window.alert("Failed to install, please try again."),p("")}},[t,n,s]);return _.jsxs(_.Fragment,{children:[_.jsx("button",{...r,type:"button",className:ue("text-sm self-start",r.className,{"icon clear":e}),onClick:m,disabled:!!h,children:e?_.jsx(O6,{}):h?"Installing...":"Install"}),_.jsx(t0,{show:a,hide:()=>l(!1),children:h?_.jsxs("div",{className:"flex-col-center gap-4",children:[_.jsx(ya,{msg:h}),_.jsx("div",{className:"text-center",children:"App is installing in the background. You can safely close this window."})]}):_.jsxs("div",{className:"flex-col-center gap-2",children:[_.jsx("h4",{children:"Approve App Permissions"}),_.jsxs("h5",{className:"m-0",children:[Js(t)," needs the following permissions:"]}),_.jsx("ul",{className:"flex flex-col items-start",children:u.map(b=>_.jsx("li",{children:JSON.stringify(b)}))}),_.jsx("button",{type:"button",onClick:v,children:"Approve & Install"})]})})]})}function z6({app:t,launchPath:e,isIcon:r=!1,...n}){const i=L.useCallback(async s=>{s.preventDefault(),window.location.href=`/${e.replace("/","")}`},[t,e]);return _.jsx(_.Fragment,{children:_.jsx("button",{...n,type:"button",className:ue("text-sm self-start",n.className,{"icon clear":r,alt:!r}),onClick:i,children:r?_.jsx(L6,{}):"Launch"})})}function x2({app:t,launchPath:e="",isIcon:r=!1,permitMultiButton:n=!1,...i}){const{installed:s,downloaded:o,updatable:a}=L.useMemo(()=>{var m,v,b,k;const u=(Object.entries(((v=(m=t==null?void 0:t.metadata)==null?void 0:m.properties)==null?void 0:v.code_hashes)||{}).find(([x])=>{var w,A;return x===((A=(w=t.metadata)==null?void 0:w.properties)==null?void 0:A.current_version)})||[])[1],c=t.installed,h=!!t.state,p=!!((b=t.state)!=null&&b.our_version&&u)&&((k=t.state)==null?void 0:k.our_version)!==u&&t.publisher!==window.our.node;return{installed:c,downloaded:h,updatable:p}},[t]);return _.jsxs(_.Fragment,{children:[n&&s&&a&&e&&_.jsx($m,{app:t,...i,isIcon:r}),s&&e?_.jsx(z6,{app:t,...i,isIcon:r,launchPath:e}):s&&a?_.jsx($m,{app:t,...i,isIcon:r}):o?s?r?_.jsx("button",{className:"pointer-events none icon clear absolute top-0 right-0",children:_.jsx(v2,{})}):_.jsx(_.Fragment,{}):_.jsx(U6,{app:t,...i,isIcon:r}):_.jsx(F6,{app:t,...i,isIcon:r})]})}const Lh="/my-apps",$6="/",sc="/publish",vu="/app-details",b2=t=>!!t&&t[0]==="o",Hm=oa.unstable_batchedUpdates||(t=>t()),ss=(t,e,r=1e-4)=>Math.abs(t-e)t===!0||!!(t&&t[e]),gn=(t,e)=>typeof t=="function"?t(e):t,E2="_szhsinMenu",H6=t=>t[E2],V6=(t,e)=>Object.defineProperty(e,E2,{value:t}),r0=(t,e)=>(e&&Object.keys(e).forEach(r=>{const n=t[r],i=e[r];typeof i=="function"&&n?t[r]=(...s)=>{i(...s),n(...s)}:t[r]=i}),t),q6=t=>{if(typeof t!="string")return{top:0,right:0,bottom:0,left:0};const e=t.trim().split(/\s+/,4).map(parseFloat),r=isNaN(e[0])?0:e[0],n=isNaN(e[1])?r:e[1];return{top:r,right:n,bottom:isNaN(e[2])?r:e[2],left:isNaN(e[3])?n:e[3]}},wf=t=>{for(;t;){if(t=t.parentNode,!t||t===document.body||!t.parentNode)return;const{overflow:e,overflowX:r,overflowY:n}=getComputedStyle(t);if(/auto|scroll|overlay|hidden/.test(e+n+r))return t}};function G6(t,e){return{"aria-disabled":t||void 0,tabIndex:e?0:-1}}function Vm(t,e){for(let r=0;rL.useMemo(()=>{const i=e?`${t}__${e}`:t;let s=i;r&&Object.keys(r).forEach(a=>{const l=r[a];l&&(s+=` ${i}--${l===!0?a:`${a}-${l}`}`)});let o=typeof n=="function"?n(r):n;return typeof o=="string"&&(o=o.trim(),o&&(s+=` ${o}`)),s},[t,e,r,n]),W6="szh-menu-container",xf="szh-menu",K6="szh-menu-button",Q6="arrow",J6=L.createContext(),Y6=L.createContext({}),qm=L.createContext({}),X6=L.createContext({}),A2=L.createContext({}),Rn=Object.freeze({ENTER:"Enter",ESC:"Escape",SPACE:" ",HOME:"Home",END:"End",LEFT:"ArrowLeft",RIGHT:"ArrowRight",UP:"ArrowUp",DOWN:"ArrowDown"}),Ot=Object.freeze({RESET:0,SET:1,UNSET:2,INCREASE:3,DECREASE:4,FIRST:5,LAST:6,SET_INDEX:7}),xa=Object.freeze({CLICK:"click",CANCEL:"cancel",BLUR:"blur",SCROLL:"scroll"}),Uo=Object.freeze({FIRST:"first",LAST:"last"}),Z6=Object.freeze({entering:"opening",entered:"open",exiting:"closing",exited:"closed"}),bf="absolute",eS="menuitem",Gm={"aria-hidden":!0,role:eS},tS=V6("MenuButton",L.forwardRef(function({className:e,isOpen:r,disabled:n,children:i,...s},o){const a=L.useMemo(()=>({open:r}),[r]);return _.jsx("button",{"aria-haspopup":!0,"aria-expanded":r,"aria-disabled":n||void 0,type:"button",disabled:n,...s,ref:o,className:yu({block:K6,modifiers:a,className:e}),children:i})})),rS=({className:t,containerRef:e,containerProps:r,children:n,isOpen:i,theming:s,transition:o,onClose:a})=>{const l=wa(o,"item"),u=({key:h})=>{switch(h){case Rn.ESC:gn(a,{key:h,reason:xa.CANCEL});break}},c=h=>{i&&!h.currentTarget.contains(h.relatedTarget)&&gn(a,{reason:xa.BLUR})};return _.jsx("div",{...r0({onKeyDown:u,onBlur:c},r),className:yu({block:W6,modifiers:L.useMemo(()=>({theme:s,itemTransition:l}),[s,l]),className:t}),style:{position:"absolute",...r==null?void 0:r.style},ref:e,children:n})},nS=()=>{let t,e=0;return{toggle:r=>{r?e++:e--,e=Math.max(e,0)},on:(r,n,i)=>{e?t||(t=setTimeout(()=>{t=0,n()},r)):i==null||i()},off:()=>{t&&(clearTimeout(t),t=0)}}},iS=(t,e)=>{const[r,n]=L.useState(),s=L.useRef({items:[],hoverIndex:-1,sorted:!1}).current,o=L.useCallback((l,u)=>{const{items:c}=s;if(!l)s.items=[];else if(u)c.push(l);else{const h=c.indexOf(l);h>-1&&(c.splice(h,1),l.contains(document.activeElement)&&(e.current.focus(),n()))}s.hoverIndex=-1,s.sorted=!1},[s,e]),a=L.useCallback((l,u,c)=>{const{items:h,hoverIndex:p}=s,m=()=>{if(s.sorted)return;const k=t.current.querySelectorAll(".szh-menu__item");h.sort((x,w)=>Vm(k,x)-Vm(k,w)),s.sorted=!0};let v=-1,b;switch(l){case Ot.RESET:break;case Ot.SET:b=u;break;case Ot.UNSET:b=k=>k===u?void 0:k;break;case Ot.FIRST:m(),v=0,b=h[v];break;case Ot.LAST:m(),v=h.length-1,b=h[v];break;case Ot.SET_INDEX:m(),v=c,b=h[v];break;case Ot.INCREASE:m(),v=p,v<0&&(v=h.indexOf(u)),v++,v>=h.length&&(v=0),b=h[v];break;case Ot.DECREASE:m(),v=p,v<0&&(v=h.indexOf(u)),v--,v<0&&(v=h.length-1),b=h[v];break}b||(v=-1),n(b),s.hoverIndex=v},[t,s]);return{hoverItem:r,dispatch:a,updateItems:o}},sS=(t,e,r,n)=>{const i=e.current.getBoundingClientRect(),s=t.current.getBoundingClientRect(),o=r===window?{left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight}:r.getBoundingClientRect(),a=q6(n),l=v=>v+s.left-o.left-a.left,u=v=>v+s.left+i.width-o.right+a.right,c=v=>v+s.top-o.top-a.top,h=v=>v+s.top+i.height-o.bottom+a.bottom;return{menuRect:i,containerRect:s,getLeftOverflow:l,getRightOverflow:u,getTopOverflow:c,getBottomOverflow:h,confineHorizontally:v=>{let b=l(v);if(b<0)v-=b;else{const k=u(v);k>0&&(v-=k,b=l(v),b<0&&(v-=b))}return v},confineVertically:v=>{let b=c(v);if(b<0)v-=b;else{const k=h(v);k>0&&(v-=k,b=c(v),b<0&&(v-=b))}return v}}},oS=({arrowRef:t,menuY:e,anchorRect:r,containerRect:n,menuRect:i})=>{let s=r.top-n.top-e+r.height/2;const o=t.current.offsetHeight*1.25;return s=Math.max(o,s),s=Math.min(s,i.height-o),s},aS=({anchorRect:t,containerRect:e,menuRect:r,placeLeftorRightY:n,placeLeftX:i,placeRightX:s,getLeftOverflow:o,getRightOverflow:a,confineHorizontally:l,confineVertically:u,arrowRef:c,arrow:h,direction:p,position:m})=>{let v=p,b=n;m!=="initial"&&(b=u(b),m==="anchor"&&(b=Math.min(b,t.bottom-e.top),b=Math.max(b,t.top-e.top-r.height)));let k,x,w;return v==="left"?(k=i,m!=="initial"&&(x=o(k),x<0&&(w=a(s),(w<=0||-x>w)&&(k=s,v="right")))):(k=s,m!=="initial"&&(w=a(k),w>0&&(x=o(i),(x>=0||-x{let s=r.left-n.left-e+r.width/2;const o=t.current.offsetWidth*1.25;return s=Math.max(o,s),s=Math.min(s,i.width-o),s},uS=({anchorRect:t,containerRect:e,menuRect:r,placeToporBottomX:n,placeTopY:i,placeBottomY:s,getTopOverflow:o,getBottomOverflow:a,confineHorizontally:l,confineVertically:u,arrowRef:c,arrow:h,direction:p,position:m})=>{let v=p==="top"?"top":"bottom",b=n;m!=="initial"&&(b=l(b),m==="anchor"&&(b=Math.min(b,t.right-e.left),b=Math.max(b,t.left-e.left-r.width)));let k,x,w;return v==="top"?(k=i,m!=="initial"&&(x=o(k),x<0&&(w=a(s),(w<=0||-x>w)&&(k=s,v="bottom")))):(k=s,m!=="initial"&&(w=a(k),w>0&&(x=o(i),(x>=0||-x{const{menuRect:u,containerRect:c}=l,h=r==="left"||r==="right";let p=h?n:i,m=h?i:n;if(t){const I=a.current;h?p+=I.offsetWidth:m+=I.offsetHeight}const v=o.left-c.left-u.width-p,b=o.right-c.left+p,k=o.top-c.top-u.height-m,x=o.bottom-c.top+m;let w,A;e==="end"?(w=o.right-c.left-u.width,A=o.bottom-c.top-u.height):e==="center"?(w=o.left-c.left-(u.width-o.width)/2,A=o.top-c.top-(u.height-o.height)/2):(w=o.left-c.left,A=o.top-c.top),w+=p,A+=m;const T={...l,anchorRect:o,placeLeftX:v,placeRightX:b,placeLeftorRightY:A,placeTopY:k,placeBottomY:x,placeToporBottomX:w,arrowRef:a,arrow:t,direction:r,position:s};switch(r){case"left":case"right":return aS(T);case"top":case"bottom":default:return uS(T)}},Ef=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?L.useLayoutEffect:L.useEffect;function Wm(t,e){typeof t=="function"?t(e):t.current=e}const _2=(t,e)=>L.useMemo(()=>t?e?r=>{Wm(t,r),Wm(e,r)}:t:e,[t,e]),Km=-9999,fS=({ariaLabel:t,menuClassName:e,menuStyle:r,arrow:n,arrowProps:i={},anchorPoint:s,anchorRef:o,containerRef:a,containerProps:l,focusProps:u,externalRef:c,parentScrollingRef:h,align:p="start",direction:m="bottom",position:v="auto",overflow:b="visible",setDownOverflow:k,repositionFlag:x,captureFocus:w=!0,state:A,endTransition:T,isDisabled:I,menuItemFocus:B,gap:F=0,shift:$=0,children:V,onClose:G,...Y})=>{const[$e,R]=L.useState({x:Km,y:Km}),[f,g]=L.useState({}),[E,M]=L.useState(),[S,P]=L.useState(m),[O]=L.useState(nS),[N,d]=L.useReducer(ie=>ie+1,1),{transition:C,boundingBoxRef:te,boundingBoxPadding:y,rootMenuRef:D,rootAnchorRef:U,scrollNodesRef:z,reposition:W,viewScroll:se,submenuCloseDelay:X}=L.useContext(A2),{submenuCtx:Q,reposSubmenu:Xe=x}=L.useContext(qm),J=L.useRef(null),ae=L.useRef(),Xr=L.useRef(),Te=L.useRef(!1),Me=L.useRef({width:0,height:0}),Zr=L.useRef(()=>{}),{hoverItem:Ce,dispatch:fe,updateItems:Er}=iS(J,ae),he=b2(A),je=wa(C,"open"),en=wa(C,"close"),ge=z.current,He=ie=>{switch(ie.key){case Rn.HOME:fe(Ot.FIRST);break;case Rn.END:fe(Ot.LAST);break;case Rn.UP:fe(Ot.DECREASE,Ce);break;case Rn.DOWN:fe(Ot.INCREASE,Ce);break;case Rn.SPACE:ie.target&&ie.target.className.indexOf(xf)!==-1&&ie.preventDefault();return;default:return}ie.preventDefault(),ie.stopPropagation()},En=()=>{A==="closing"&&M(),gn(T)},Ve=ie=>{ie.stopPropagation(),O.on(X,()=>{fe(Ot.RESET),ae.current.focus()})},qe=ie=>{ie.target===ie.currentTarget&&O.off()},Gt=L.useCallback(ie=>{var lt;const ve=o?(lt=o.current)==null?void 0:lt.getBoundingClientRect():s?{left:s.x,right:s.x,top:s.y,bottom:s.y,width:0,height:0}:null;if(!ve)return;ge.menu||(ge.menu=(te?te.current:wf(D.current))||window);const de=sS(a,J,ge.menu,y);let{arrowX:it,arrowY:_e,x:Se,y:Rt,computedDirection:Re}=cS({arrow:n,align:p,direction:m,gap:F,shift:$,position:v,anchorRect:ve,arrowRef:Xr,positionHelpers:de});const{menuRect:Fe}=de;let Yt=Fe.height;if(!ie&&b!=="visible"){const{getTopOverflow:Qe,getBottomOverflow:Je}=de;let Xt,Ie;const Ue=Me.current.height,Ar=Je(Rt);if(Ar>0||ss(Ar,0)&&ss(Yt,Ue))Xt=Yt-Ar,Ie=Ar;else{const Ne=Qe(Rt);(Ne<0||ss(Ne,0)&&ss(Yt,Ue))&&(Xt=Yt+Ne,Ie=0-Ne,Xt>=0&&(Rt-=Ne))}Xt>=0?(Yt=Xt,M({height:Xt,overflowAmt:Ie})):M()}n&&g({x:it,y:_e}),R({x:Se,y:Rt}),P(Re),Me.current={width:Fe.width,height:Yt}},[n,p,y,m,F,$,v,b,s,o,a,te,D,ge]);Ef(()=>{he&&(Gt(),Te.current&&d()),Te.current=he,Zr.current=Gt},[he,Gt,Xe]),Ef(()=>{E&&!k&&(J.current.scrollTop=0)},[E,k]),Ef(()=>Er,[Er]),L.useEffect(()=>{let{menu:ie}=ge;if(!he||!ie)return;if(ie=ie.addEventListener?ie:window,!ge.anchors){ge.anchors=[];let it=wf(U&&U.current);for(;it&&it!==ie;)ge.anchors.push(it),it=wf(it)}let lt=se;if(ge.anchors.length&<==="initial"&&(lt="auto"),lt==="initial")return;const ve=()=>{lt==="auto"?Hm(()=>Gt(!0)):gn(G,{reason:xa.SCROLL})},de=ge.anchors.concat(se!=="initial"?ie:[]);return de.forEach(it=>it.addEventListener("scroll",ve)),()=>de.forEach(it=>it.removeEventListener("scroll",ve))},[U,ge,he,G,se,Gt]);const Le=!!E&&E.overflowAmt>0;L.useEffect(()=>{if(Le||!he||!h)return;const ie=()=>Hm(Gt),lt=h.current;return lt.addEventListener("scroll",ie),()=>lt.removeEventListener("scroll",ie)},[he,Le,h,Gt]),L.useEffect(()=>{if(typeof ResizeObserver!="function"||W==="initial")return;const ie=new ResizeObserver(([ve])=>{const{borderBoxSize:de,target:it}=ve;let _e,Se;if(de){const{inlineSize:Rt,blockSize:Re}=de[0]||de;_e=Rt,Se=Re}else{const Rt=it.getBoundingClientRect();_e=Rt.width,Se=Rt.height}_e===0||Se===0||ss(_e,Me.current.width,1)&&ss(Se,Me.current.height,1)||oa.flushSync(()=>{Zr.current(),d()})}),lt=J.current;return ie.observe(lt,{box:"border-box"}),()=>ie.unobserve(lt)},[W]),L.useEffect(()=>{if(!he){fe(Ot.RESET),en||M();return}const{position:ie,alwaysUpdate:lt}=B||{},ve=()=>{ie===Uo.FIRST?fe(Ot.FIRST):ie===Uo.LAST?fe(Ot.LAST):ie>=-1&&fe(Ot.SET_INDEX,void 0,ie)};if(lt)ve();else if(w){const de=setTimeout(()=>{const it=J.current;it&&!it.contains(document.activeElement)&&(ae.current.focus(),ve())},je?170:100);return()=>clearTimeout(de)}},[he,je,en,w,B,fe]);const Ge=L.useMemo(()=>({isParentOpen:he,submenuCtx:O,dispatch:fe,updateItems:Er}),[he,O,fe,Er]);let Lr,Pe;E&&(k?Pe=E.overflowAmt:Lr=E.height);const We=L.useMemo(()=>({reposSubmenu:N,submenuCtx:O,overflow:b,overflowAmt:Pe,parentMenuRef:J,parentDir:S}),[N,O,b,Pe,S]),An=Lr>=0?{maxHeight:Lr,overflow:b}:void 0,Be=L.useMemo(()=>({state:A,dir:S}),[A,S]),Ke=L.useMemo(()=>({dir:S}),[S]),_n=yu({block:xf,element:Q6,modifiers:Ke,className:i.className}),De=_.jsxs("ul",{role:"menu","aria-label":t,...G6(I),...r0({onPointerEnter:Q==null?void 0:Q.off,onPointerMove:Ve,onPointerLeave:qe,onKeyDown:He,onAnimationEnd:En},Y),ref:_2(c,J),className:yu({block:xf,modifiers:Be,className:e}),style:{...r,...An,margin:0,display:A==="closed"?"none":void 0,position:bf,left:$e.x,top:$e.y},children:[_.jsx("li",{tabIndex:-1,style:{position:bf,left:0,top:0,display:"block",outline:"none"},ref:ae,...Gm,...u}),n&&_.jsx("li",{...Gm,...i,className:_n,style:{display:"block",position:bf,left:f.x,top:f.y,...i.style},ref:Xr}),_.jsx(qm.Provider,{value:We,children:_.jsx(Y6.Provider,{value:Ge,children:_.jsx(J6.Provider,{value:Ce,children:gn(V,Be)})})})]});return l?_.jsx(rS,{...l,isOpen:he,children:De}):De},hS=L.forwardRef(function({"aria-label":e,className:r,containerProps:n,initialMounted:i,unmountOnClose:s,transition:o,transitionTimeout:a,boundingBoxRef:l,boundingBoxPadding:u,reposition:c="auto",submenuOpenDelay:h=300,submenuCloseDelay:p=150,viewScroll:m="initial",portal:v,theming:b,onItemClick:k,...x},w){const A=L.useRef(null),T=L.useRef({}),{anchorRef:I,state:B,onClose:F}=x,$=L.useMemo(()=>({initialMounted:i,unmountOnClose:s,transition:o,transitionTimeout:a,boundingBoxRef:l,boundingBoxPadding:u,rootMenuRef:A,rootAnchorRef:I,scrollNodesRef:T,reposition:c,viewScroll:m,submenuOpenDelay:h,submenuCloseDelay:p}),[i,s,o,a,I,l,u,c,m,h,p]),V=L.useMemo(()=>({handleClick(Y,$e){Y.stopPropagation||gn(k,Y);let R=Y.keepOpen;R===void 0&&(R=$e&&Y.key===Rn.SPACE),R||gn(F,{value:Y.value,key:Y.key,reason:xa.CLICK})},handleClose(Y){gn(F,{key:Y,reason:xa.CLICK})}}),[k,F]);if(!B)return null;const G=_.jsx(A2.Provider,{value:$,children:_.jsx(X6.Provider,{value:V,children:_.jsx(fS,{...x,ariaLabel:e||"Menu",externalRef:w,containerRef:A,containerProps:{className:r,containerRef:A,containerProps:n,theming:b,transition:o,onClose:F}})})});return v===!0&&typeof document<"u"?oa.createPortal(G,document.body):v?v.target?oa.createPortal(G,v.target):v.stablePosition?null:G:G}),Bh=0,Dh=1,wu=2,xu=3,bu=4,dS=5,S2=6,pS=["preEnter","entering","entered","preExit","exiting","exited","unmounted"],k2=t=>({_s:t,status:pS[t],isEnter:tbu}),Fh=t=>t?S2:dS,mS=(t,e)=>{switch(t){case Dh:case Bh:return wu;case bu:case xu:return Fh(e)}},gS=t=>typeof t=="object"?[t.enter,t.exit]:[t,t],vS=(t,e)=>setTimeout(()=>{isNaN(document.body.offsetTop)||t(e+1)},0),Qm=(t,e,r,n,i)=>{clearTimeout(n.current);const s=k2(t);e(s),r.current=s,i&&i({current:s})},yS=({enter:t=!0,exit:e=!0,preEnter:r,preExit:n,timeout:i,initialEntered:s,mountOnEnter:o,unmountOnExit:a,onStateChange:l}={})=>{const[u,c]=L.useState(()=>k2(s?wu:Fh(o))),h=L.useRef(u),p=L.useRef(),[m,v]=gS(i),b=L.useCallback(()=>{const x=mS(h.current._s,a);x&&Qm(x,c,h,p,l)},[l,a]),k=L.useCallback(x=>{const w=T=>{switch(Qm(T,c,h,p,l),T){case Dh:m>=0&&(p.current=setTimeout(b,m));break;case bu:v>=0&&(p.current=setTimeout(b,v));break;case Bh:case xu:p.current=vS(w,T);break}},A=h.current.isEnter;typeof x!="boolean"&&(x=!A),x?!A&&w(t?r?Bh:Dh:wu):A&&w(e?n?xu:bu:Fh(a))},[b,l,t,e,r,n,m,v,a]);return L.useEffect(()=>()=>clearTimeout(p.current),[]),[u,k,b]},wS=({initialOpen:t,initialMounted:e,unmountOnClose:r,transition:n,transitionTimeout:i=500}={})=>{const[{status:s},o,a]=yS({initialEntered:t,mountOnEnter:!e,unmountOnExit:r,timeout:i,enter:wa(n,"open"),exit:wa(n,"close")});return[{state:Z6[s],endTransition:a},o]},xS=t=>{const[e,r]=wS(t),[n,i]=L.useState(),s=(o,a)=>{i({position:o,alwaysUpdate:a}),r(!0)};return[{menuItemFocus:n,...e},r,s]},bS=(t,e)=>{const[r]=L.useState({});return{onMouseDown:()=>{r.v=t&&t!=="closed"},onClick:n=>r.v?r.v=!1:e(!0,n)}},ES=(t,e)=>{const r=L.useRef(e);L.useEffect(()=>{r.current!==e&&gn(t,{open:e}),r.current=e},[t,e])},AS=L.forwardRef(function({"aria-label":e,captureFocus:r,initialOpen:n,menuButton:i,instanceRef:s,onMenuChange:o,...a},l){const[u,c,h]=xS(a),{state:p}=u,m=b2(p),v=L.useRef(null),b=bS(p,(I,B)=>h(B.detail?void 0:Uo.FIRST)),k=L.useCallback(I=>{c(!1),I.key&&v.current.focus()},[c]),x=I=>{switch(I.key){case Rn.UP:h(Uo.LAST);break;case Rn.DOWN:h(Uo.FIRST);break;default:return}I.preventDefault()},w=gn(i,{open:m});if(!w||!w.type)throw new Error("Menu requires a menuButton prop.");const A={ref:_2(w.ref,v),...r0({onKeyDown:x,...b},w.props)};H6(w.type)==="MenuButton"&&(A.isOpen=m);const T=L.cloneElement(w,A);return ES(o,m),L.useImperativeHandle(s,()=>({openMenu:h,closeMenu:()=>c(!1)})),_.jsxs(L.Fragment,{children:[T,_.jsx(hS,{...a,...u,"aria-label":e||(typeof w.props.children=="string"?w.props.children:"Menu"),anchorRef:v,ref:l,onClose:k})]})});function Jm({...t}){return _.jsx(AS,{...t,unmountOnClose:!0,className:ue("relative",t.className),direction:"left",menuButton:_.jsx(tS,{className:"small",children:_.jsx(p6,{className:"-mb-1"})}),children:t.children})}function _S({app:t,className:e}){var a,l,u,c,h;const{uninstallApp:r,setMirroring:n,setAutoUpdate:i}=Pi(),s=Ma();return!t.state?t.metadata?_.jsx(Jm,{className:e,children:_.jsxs("div",{className:"flex flex-col backdrop-blur-lg bg-black/10 p-2 rounded-lg relative z-10",children:[((a=t.metadata)==null?void 0:a.description)&&_.jsx("button",{className:"my-1 whitespace-nowrap clear",onClick:()=>s(`/${vu}/${Ee(t)}`),children:"View Details"}),((l=t.metadata)==null?void 0:l.external_url)&&_.jsx("a",{target:"_blank",href:(u=t.metadata)==null?void 0:u.external_url,className:"mb-1 whitespace-nowrap button clear",children:"View Site"})]})}):_.jsx(_.Fragment,{}):_.jsx(Jm,{className:e,children:_.jsxs("div",{className:"flex flex-col p-2 rounded-lg backdrop-blur-lg relative z-10",children:[_.jsx("button",{className:"my-1 whitespace-nowrap clear",onClick:()=>s(`/${vu}/${Ee(t)}`),children:"View Details"}),t.installed&&_.jsxs(_.Fragment,{children:[_.jsx("button",{className:"mb-1 whitespace-nowrap clear",onClick:()=>r(t),children:"Uninstall"}),_.jsxs("button",{className:"mb-1 whitespace-nowrap clear",onClick:()=>{var p;return n(t,!((p=t.state)!=null&&p.mirroring))},children:[(c=t.state)!=null&&c.mirroring?"Stop":"Start"," Mirroring"]}),_.jsxs("button",{className:"mb-1 whitespace-nowrap clear",onClick:()=>{var p;return i(t,!((p=t.state)!=null&&p.auto_update))},children:[(h=t.state)!=null&&h.auto_update?"Disable":"Enable"," Auto Update"]})]})]})})}function Ns({app:t,size:e="medium",overrideImageSize:r,showMoreActions:n,launchPath:i,...s}){const o=Kn(),a=Ma();return L.createElement("div",{...s,key:Ee(t),className:ue("flex justify-between rounded-lg hover:bg-white/10 card cursor-pointer",s.className,{"flex-wrap gap-2":o,"flex-col relative":e!=="large"}),onClick:()=>{n||a(`/${vu}/${Ee(t)}`)}},_.jsx(g2,{app:t,size:e,overrideImageSize:r}),_.jsxs("div",{className:ue("flex items-center",{absolute:e!=="large","top-2 right-2":e!=="large"&&n,"top-0 right-0":e!=="large"&&!n,"ml-auto":e==="large"&&o,"min-w-1/5":e==="large"}),children:[_.jsx(x2,{app:t,launchPath:i,isIcon:!n&&e!=="large",className:ue({"bg-orange text-lg":e==="large","mr-2":n,"w-full":e==="large"})}),n&&_.jsx(_S,{app:t,className:"self-stretch"})]}))}function oc({value:t="",onChange:e=()=>null,onBack:r,hideSearch:n=!1,hidePublish:i=!1}){const s=Ma(),o=$u(),a=Wr.useRef(null),l=o.key!=="default",u=o.pathname===Lh,c=Kn();return _.jsxs("div",{className:ue("flex justify-between",{"gap-4":c,"gap-8":!c}),children:[o.pathname!=="/"?_.jsx("button",{className:"flex flex-col c icon icon-orange",onClick:()=>{r?r():s(l?-1:"/")},children:_.jsx(C6,{})}):c?_.jsx("button",{className:ue("icon icon-orange",{}),onClick:()=>window.location.href="/",children:_.jsx(h2,{})}):_.jsx(_.Fragment,{}),!i&&_.jsx("button",{className:"flex flex-col c icon icon-orange",onClick:()=>s(sc),children:_.jsx(D6,{})}),!n&&_.jsxs("div",{className:"flex flex-1 rounded-md relative",children:[_.jsx("input",{type:"text",ref:a,onChange:h=>e(h.target.value),value:t,placeholder:"Search for apps...",className:"w-full self-stretch grow"}),_.jsx("button",{className:ue("icon border-0 absolute top-1/2 -translate-y-1/2",{"right-2":c,"right-4":!c}),type:"button",onClick:()=>{var h;return(h=a.current)==null?void 0:h.focus()},children:_.jsx(T6,{})})]}),_.jsxs("button",{className:ue("flex c",{"gap-4":c,"gap-8 basis-1/5":!c}),onClick:()=>s(u?-1:Lh),children:[!c&&_.jsx("span",{children:"My Apps"}),_.jsx(y2,{})]})]})}const ac=()=>{const t=Kn();return _.jsx("button",{className:ue("clear absolute p-2",{"top-2 left-2":t,"top-8 left-8":!t}),onClick:()=>window.location.href="/",children:_.jsx(h2,{size:24})})};function SS(){const{listedApps:t,getListedApps:e,rebuildIndex:r}=Pi(),[n,i]=L.useState("Recently published"),[s,o]=L.useState(""),[a,l]=L.useState(t),[u,c]=L.useState(1),[h,p]=L.useState([]),[m,v]=L.useState({}),b=L.useMemo(()=>Array.from({length:Math.ceil(t.length/10)},(I,B)=>B+1),[t]),k=["dartfrog","kcal","memedeck","filter"];L.useEffect(()=>{const I=(u-1)*10,B=I+10;l(t.slice(I,B))},[t,u]),L.useEffect(()=>{e().then(I=>{l(Object.values(I));let B=[];for(const F of Object.values(I))B=B.concat((F.metadata||{}).tags||[]);B.length===0&&(B=["App","Tags","Coming","Soon","tm"]),p(Array.from(new Set(B)))}).catch(I=>console.error(I))},[]);const x=L.useCallback(async I=>{},[]),w=L.useCallback(I=>{o(I);const B=t.filter(F=>{var $,V,G,Y;return F.package.toLowerCase().includes(I.toLowerCase())||((V=($=F.metadata)==null?void 0:$.description)==null?void 0:V.toLowerCase().includes(I.toLowerCase()))||((Y=(G=F.metadata)==null?void 0:G.description)==null?void 0:Y.toLowerCase().includes(I.toLowerCase()))},[t]);l(B)},[t]),A=L.useCallback(async()=>{try{await r(),alert("Index rebuilt successfully."),await e()}catch(I){console.error(I)}},[r]),T=Kn();return L.useEffect(()=>{fetch("/apps").then(I=>I.json()).then(I=>{Array.isArray(I)&&t.forEach(B=>{const F=I.find($=>B.package===$.package_name);F&&v({...m,[B.package]:F.path})})})},[t]),_.jsxs("div",{className:ue("flex flex-col w-full max-h-screen p-2",{"gap-4 max-w-screen":T,"gap-6 max-w-[900px]":!T}),children:[!T&&_.jsx(ac,{}),_.jsx(oc,{value:s,onChange:w}),_.jsxs("div",{className:ue("flex items-center self-stretch justify-between",{"gap-4 flex-wrap":T,"gap-8 grow":!T}),children:[_.jsx("button",{className:"flex flex-col c icon icon-orange",onClick:A,title:"Rebuild index",children:_.jsx(P6,{})}),h.slice(0,T?3:6).map(I=>_.jsx("button",{className:"clear flex c rounded-full !bg-white/10 !hover:bg-white/25",onClick:()=>{console.log("clicked tag",I)},children:I},I)),_.jsxs("select",{value:n,onChange:I=>{i(I.target.value),x(I.target.value)},className:ue("hidden",{"basis-1/5":!T}),children:[_.jsx("option",{children:"Recently published"}),_.jsx("option",{children:"Most popular"}),_.jsx("option",{children:"Best rating"}),_.jsx("option",{children:"Recently updated"})]})]}),!s&&_.jsxs("div",{className:ue("flex flex-col",{"gap-4":!T,"grow overflow-y-auto gap-2 items-center px-2":T}),children:[_.jsx("h2",{children:"Featured Apps"}),_.jsx("div",{className:ue("flex gap-2",{"flex-col":T}),children:t.filter(I=>k.indexOf(I.package)!==-1).map(I=>{var B;return _.jsx(Ns,{size:"medium",app:I,launchPath:m[I.package],className:ue("grow",{"w-1/4":!T,"w-full":T})},Ee(I)+(((B=I.state)==null?void 0:B.our_version)||""))})})]}),_.jsx("h2",{children:s?"Search Results":"All Apps"}),_.jsx("div",{className:ue("flex flex-col grow overflow-y-auto",{"gap-2":T,"gap-4":!T}),children:a.filter(I=>s?!0:k.indexOf(I.package)===-1).map(I=>{var B;return _.jsx(Ns,{size:"large",app:I,className:"self-stretch",overrideImageSize:"medium"},Ee(I)+(((B=I.state)==null?void 0:B.our_version)||""))})}),b.length>1&&_.jsxs("div",{className:"flex flex-wrap self-center gap-2",children:[_.jsx("button",{className:"icon",onClick:()=>u!==b[0]&&c(u-1),children:_.jsx(h6,{})}),b.map(I=>_.jsx("button",{className:ue("icon",{"!bg-white/10":I===u}),onClick:()=>c(I),children:I},`page-${I}`)),_.jsx("button",{className:"icon",onClick:()=>u!==b[b.length-1]&&c(u+1),children:_.jsx(d6,{})})]})]})}function kS(){const{myApps:t,getMyApps:e}=Pi(),r=Ma(),[n,i]=L.useState(""),[s,o]=L.useState(t);L.useEffect(()=>{e().then(o).catch(u=>console.error(u))},[]);const a=L.useCallback(u=>{i(u);const c=Object.keys(t).reduce((h,p)=>(h[p]=t[p].filter(m=>{var v,b,k,x;return m.package.toLowerCase().includes(u.toLowerCase())||((b=(v=m.metadata)==null?void 0:v.description)==null?void 0:b.toLowerCase().includes(u.toLowerCase()))||((x=(k=m.metadata)==null?void 0:k.description)==null?void 0:x.toLowerCase().includes(u.toLowerCase()))}),h),{downloaded:[],installed:[],local:[],system:[]});o(c)},[t]);L.useEffect(()=>{n?a(n):o(t)},[t]);const l=Kn();return console.log({myApps:t}),_.jsxs("div",{className:ue("flex flex-col w-full h-screen p-2",{"gap-4 max-w-screen":l,"gap-8 max-w-[900px]":!l}),children:[_.jsx(ac,{}),_.jsx(oc,{value:n,onChange:a}),_.jsxs("div",{className:"flex justify-between items-center mt-2",children:[_.jsx("h3",{children:"My Packages"}),_.jsxs("button",{onClick:()=>r(sc),children:[_.jsx(m6,{className:"mr-2"}),"Publish Package"]})]}),_.jsxs("div",{className:ue("flex flex-col card gap-2 mt-2",{"max-h-[80vh] overflow-y-scroll overflow-x-visible":!l}),style:{scrollbarWidth:"thin",scrollbarColor:"#FFF5D9 transparent"},children:[s.downloaded.length>0&&_.jsx("h4",{children:"Downloaded"}),(s.downloaded||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u))),s.installed.length>0&&_.jsx("h4",{children:"Installed"}),(s.installed||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u))),s.local.length>0&&_.jsx("h4",{children:"Local"}),(s.local||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u))),s.system.length>0&&_.jsx("h4",{children:"System"}),(s.system||[]).map(u=>_.jsx(Ns,{app:u,showMoreActions:!0},Ee(u)))]})]})}function NS(){var b,k,x,w,A,T,I,B,F,$;const{myApps:t,listedApps:e,getListedApp:r}=Pi(),n=Ma(),i=Vb(),[s,o]=L.useState(void 0),[a,l]=L.useState("");L.useEffect(()=>{const V=t.local.find(G=>Ee(G)===i.id);if(V)return o(V);if(i.id){const G=e.find(Y=>Ee(Y)===i.id);G?o(G):r(i.id).then(Y=>o(Y)).catch(console.error)}},[i.id,t,e]);const u=L.useCallback(()=>{n(sc,{state:{app:s}})},[s,n]),c=L.useMemo(()=>{var V,G;return((G=(V=s==null?void 0:s.metadata)==null?void 0:V.properties)==null?void 0:G.current_version)||"Unknown"},[s]),h=Object.entries(((k=(b=s==null?void 0:s.metadata)==null?void 0:b.properties)==null?void 0:k.code_hashes)||{}),p=((x=s==null?void 0:s.state)==null?void 0:x.our_version)||(h[(h.length||1)-1]||["",""])[1],m=Kn(),v=[{top:_.jsx("div",{className:ue({"text-sm":m}),children:"Developer"}),middle:_.jsx(j6,{size:36}),bottom:_.jsx("div",{className:ue({"text-sm":m}),children:s==null?void 0:s.publisher})},{top:_.jsx("div",{className:ue({"text-sm":m}),children:"Version"}),middle:_.jsx("span",{className:"text-2xl",children:c}),bottom:_.jsxs("div",{className:ue({"text-xs":m}),children:[p.slice(0,5),"...",p.slice(-5)]})},{top:_.jsx("div",{className:ue({"text-sm":m}),children:"Mirrors"}),middle:_.jsx(I6,{size:36}),bottom:_.jsx("div",{className:ue({"text-sm":m}),children:((T=(A=(w=s==null?void 0:s.metadata)==null?void 0:w.properties)==null?void 0:A.mirrors)==null?void 0:T.length)||0})}];return L.useEffect(()=>{fetch("/apps").then(V=>V.json()).then(V=>{if(Array.isArray(V)){const G=V.find(Y=>(s==null?void 0:s.package)===Y.package_name);G&&l(G.path)}})},[s]),_.jsxs("div",{className:ue("flex flex-col w-full p-2",{"gap-4 max-w-screen":m,"gap-8 max-w-[900px]":!m}),children:[!m&&_.jsx(ac,{}),_.jsx(oc,{value:"",onChange:()=>null,hideSearch:!0,hidePublish:!0}),_.jsx("div",{className:ue("flex-col-center card !rounded-3xl",{"p-12 gap-4 grow overflow-y-auto":m,"p-24 gap-8":!m}),children:s?_.jsxs(_.Fragment,{children:[_.jsx(g2,{app:s,size:m?"medium":"large"}),_.jsx("div",{className:"w-5/6 h-0 border border-orange"}),_.jsx("div",{className:ue("flex items-start text-xl",{"gap-4 flex-wrap":m,"gap-8":!m}),children:v.map((V,G)=>_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:ue("flex-col-center gap-2 justify-between self-stretch",{"rounded-lg bg-white/10 p-1 min-w-1/4 grow":m,"opacity-50":!m}),children:[V.top,V.middle,V.bottom]},G),!m&&G!==v.length-1&&_.jsx("div",{className:"h-3/4 w-0 border border-orange self-center"})]}))}),Array.isArray((B=(I=s.metadata)==null?void 0:I.properties)==null?void 0:B.screenshots)&&((F=s.metadata)==null?void 0:F.properties.screenshots.length)>0&&_.jsx("div",{className:"flex flex-wrap overflow-x-auto max-w-full",children:s.metadata.properties.screenshots.map((V,G)=>_.jsx("img",{src:V,className:"mr-2 max-h-20 max-w-full rounded border border-black"},G+V))}),_.jsx("div",{className:ue("flex-center gap-2",{"flex-col":m}),children:_.jsx(x2,{app:s,launchPath:a,className:ue("self-center bg-orange text-lg px-12"),permitMultiButton:!0})}),s.installed&&(($=s.state)==null?void 0:$.mirroring)&&_.jsx("button",{type:"button",onClick:u,children:"Publish"})]}):_.jsxs(_.Fragment,{children:[_.jsx("h4",{children:"App details not found for "}),_.jsx("h4",{children:i.id})]})})]})}var Uh=(t=>(t[t.SEPOLIA=11155111]="SEPOLIA",t[t.OPTIMISM=10]="OPTIMISM",t[t.OPTIMISM_GOERLI=420]="OPTIMISM_GOERLI",t[t.LOCAL=1337]="LOCAL",t))(Uh||{});const Ym="0xaa36a7",zo="0xa",MS={10:"0x52185B6a6017E6f079B994452F234f7C2533787B"},CS="4902",Xm={[Ym]:{chainId:Ym,chainName:"Sepolia",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:["https://rpc.sepolia.org"],blockExplorerUrls:["https://sepolia.etherscan.io"]},[zo]:{chainId:zo,chainName:"Optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:["https://mainnet.optimism.io"],blockExplorerUrls:["https://optimistic.etherscan.io"]}},PS=t=>{switch(t){case"1":case"0x1":return"Ethereum";case"10":case"a":case"0xa":return"Optimism";case"42161":return"Arbitrum";case"11155111":case"aa36a7":case"0xaa36a7":return"Sepolia";default:return"Unknown"}},Af=async t=>{var r,n,i;let e=await((r=window.ethereum)==null?void 0:r.request({method:"net_version"}).catch(()=>"1"));if(e="0x"+(typeof e=="string"?e.replace(/^0x/,""):e.toString(16)),!Xm[t]){console.error(`Invalid chain ID: ${t}`);return}if(t!==e)try{await((n=window.ethereum)==null?void 0:n.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]}))}catch(s){if(String(s).includes(CS))await((i=window.ethereum)==null?void 0:i.request({method:"wallet_addEthereumChain",params:[Xm[t]]}));else throw window.alert(`You must enable the ${PS(t)} network in your wallet.`),new Error(`User cancelled connection to ${t}`)}};var ba={},lc={};Object.defineProperty(lc,"__esModule",{value:!0});lc.Connector=void 0;class RS{constructor(e,r){this.actions=e,this.onError=r}resetState(){this.actions.resetState()}}lc.Connector=RS;var _f,Zm;function IS(){if(Zm)return _f;Zm=1;function t({mustBeMetaMask:e=!1,silent:r=!1,timeout:n=3e3}={}){s();let i=!1;return new Promise(o=>{window.ethereum?a():(window.addEventListener("ethereum#initialized",a,{once:!0}),setTimeout(()=>{a()},n));function a(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",a);const{ethereum:l}=window;l&&(!e||l.isMetaMask)?o(l):(!r&&console.error("@metamask/detect-provider:",e&&l?"Non-MetaMask window.ethereum detected.":"Unable to detect window.ethereum."),o(null))}});function s(){if(typeof e!="boolean")throw new Error("@metamask/detect-provider: Expected option 'mustBeMetaMask' to be a boolean.");if(typeof r!="boolean")throw new Error("@metamask/detect-provider: Expected option 'silent' to be a boolean.");if(typeof n!="number")throw new Error("@metamask/detect-provider: Expected option 'timeout' to be a number.")}}return _f=t,_f}var OS=ze&&ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),TS=ze&&ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),jS=ze&&ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&OS(e,t,r);return TS(e,t),e},os=ze&&ze.__awaiter||function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(c){try{u(n.next(c))}catch(h){o(h)}}function l(c){try{u(n.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):i(c.value).then(a,l)}u((n=n.apply(t,e||[])).next())})};Object.defineProperty(ba,"__esModule",{value:!0});var N2=ba.MetaMask=ba.NoMetaMaskError=void 0;const LS=lc;class Ea extends Error{constructor(){super("MetaMask not installed"),this.name=Ea.name,Object.setPrototypeOf(this,Ea.prototype)}}ba.NoMetaMaskError=Ea;function fl(t){return Number.parseInt(t,16)}class BS extends LS.Connector{constructor({actions:e,options:r,onError:n}){super(e,n),this.options=r}isomorphicInitialize(){return os(this,void 0,void 0,function*(){if(!this.eagerConnection)return this.eagerConnection=Promise.resolve().then(()=>jS(IS())).then(e=>os(this,void 0,void 0,function*(){var r,n;const i=yield e.default(this.options);i&&(this.provider=i,!((r=this.provider.providers)===null||r===void 0)&&r.length&&(this.provider=(n=this.provider.providers.find(s=>s.isMetaMask))!==null&&n!==void 0?n:this.provider.providers[0]),this.provider.on("connect",({chainId:s})=>{this.actions.update({chainId:fl(s)})}),this.provider.on("disconnect",s=>{var o;if(s.code===1013){console.debug('MetaMask logged connection error 1013: "Try again later"');return}this.actions.resetState(),(o=this.onError)===null||o===void 0||o.call(this,s)}),this.provider.on("chainChanged",s=>{this.actions.update({chainId:fl(s)})}),this.provider.on("accountsChanged",s=>{s.length===0?this.actions.resetState():this.actions.update({accounts:s})}))}))})}connectEagerly(){return os(this,void 0,void 0,function*(){const e=this.actions.startActivation();try{if(yield this.isomorphicInitialize(),!this.provider)return e();const r=yield this.provider.request({method:"eth_accounts"});if(!r.length)throw new Error("No accounts returned");const n=yield this.provider.request({method:"eth_chainId"});this.actions.update({chainId:fl(n),accounts:r})}catch(r){console.debug("Could not connect eagerly",r),this.actions.resetState()}})}activate(e){var r,n;return os(this,void 0,void 0,function*(){let i;return!((n=(r=this.provider)===null||r===void 0?void 0:r.isConnected)===null||n===void 0)&&n.call(r)||(i=this.actions.startActivation()),this.isomorphicInitialize().then(()=>os(this,void 0,void 0,function*(){if(!this.provider)throw new Ea;const s=yield this.provider.request({method:"eth_requestAccounts"}),o=yield this.provider.request({method:"eth_chainId"}),a=fl(o),l=typeof e=="number"?e:e==null?void 0:e.chainId;if(!l||a===l)return this.actions.update({chainId:a,accounts:s});const u=`0x${l.toString(16)}`;return this.provider.request({method:"wallet_switchEthereumChain",params:[{chainId:u}]}).catch(c=>{var h,p;if((((p=(h=c.data)===null||h===void 0?void 0:h.originalError)===null||p===void 0?void 0:p.code)||c.code)===4902&&typeof e!="number"){if(!this.provider)throw new Error("No provider");return this.provider.request({method:"wallet_addEthereumChain",params:[Object.assign(Object.assign({},e),{chainId:u})]})}throw c}).then(()=>this.activate(l))})).catch(s=>{throw i==null||i(),s})})}watchAsset({address:e,symbol:r,decimals:n,image:i}){return os(this,void 0,void 0,function*(){if(!this.provider)throw new Error("No provider");return this.provider.request({method:"wallet_watchAsset",params:{type:"ERC20",options:{address:e,symbol:r,decimals:n,image:i}}}).then(s=>{if(!s)throw new Error("Rejected");return!0})})}}N2=ba.MetaMask=BS;const[M2,n0]=Hu.initializeConnector(t=>new N2({actions:t}));function eg(t){const e=t.split("."),r=new Uint8Array(t.length+e.length);let n=0;for(const i of e){const s=i.length;r[n]=s,n++;for(let o=0;oi.toString(16).padStart(2,"0")).join("")}`}const tg=/^\d+\.\d+\.\d+$/,DS=({app:t,packageName:e,publisherId:r,goBack:n})=>{var h,p,m,v,b,k,x,w;const[i,s]=L.useState({name:((h=t==null?void 0:t.metadata)==null?void 0:h.name)||"",description:((p=t==null?void 0:t.metadata)==null?void 0:p.description)||"",image:((m=t==null?void 0:t.metadata)==null?void 0:m.image)||"",external_url:((v=t==null?void 0:t.metadata)==null?void 0:v.external_url)||"",animation_url:((b=t==null?void 0:t.metadata)==null?void 0:b.animation_url)||"",package_name:e,current_version:"",publisher:r,mirrors:[r]}),[o,a]=L.useState(Object.entries(((x=(k=t==null?void 0:t.metadata)==null?void 0:k.properties)==null?void 0:x.code_hashes)||{}).concat([["",((w=t==null?void 0:t.state)==null?void 0:w.our_version)||""]])),l=(A,T)=>{s({...i,[A]:T})};L.useEffect(()=>{l("package_name",e)},[e]),L.useEffect(()=>{l("publisher",r)},[r]);const u=L.useCallback(()=>{const A=o.reduce(($,[V,G])=>($[V]=G,$),{});if(tg.test(i.current_version))if(A[i.current_version]){if(!Object.keys(A).reduce(($,V)=>$&&tg.test(V),!0)){window.alert("Code hashes must be a JSON object with valid version keys");return}}else{window.alert(`Code hashes must include current version (${i.current_version})`);return}else{window.alert("Current version must be in the format x.y.z");return}const T=JSON.stringify({name:i.name,description:i.description,image:i.image,external_url:i.external_url,animation_url:i.animation_url,properties:{package_name:i.package_name,current_version:i.current_version,publisher:i.publisher,mirrors:i.mirrors,code_hashes:A}}),I=new Blob([T],{type:"application/json"}),B=URL.createObjectURL(I),F=document.createElement("a");F.href=B,F.download=i.package_name+"_"+i.publisher+"_metadata.json",F.click(),URL.revokeObjectURL(B)},[i,o]),c=()=>{s({name:"",description:"",image:"",external_url:"",animation_url:"",package_name:"",current_version:"",publisher:"",mirrors:[]}),a([])};return _.jsxs("form",{className:"flex flex-col card mt-2 gap-2",children:[_.jsx("h4",{children:"Fill out metadata"}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Name"}),_.jsx("input",{type:"text",placeholder:"Name",value:i.name,onChange:A=>l("name",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Description"}),_.jsx("input",{type:"text",placeholder:"Description",value:i.description,onChange:A=>l("description",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Image URL"}),_.jsx("input",{type:"text",placeholder:"Image URL",value:i.image,onChange:A=>l("image",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"External URL"}),_.jsx("input",{type:"text",placeholder:"External URL",value:i.external_url,onChange:A=>l("external_url",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Animation URL"}),_.jsx("input",{type:"text",placeholder:"Animation URL",value:i.animation_url,onChange:A=>l("animation_url",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Package Name"}),_.jsx("input",{type:"text",placeholder:"Package Name",value:i.package_name,onChange:A=>l("package_name",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Current Version"}),_.jsx("input",{type:"text",placeholder:"Current Version",value:i.current_version,onChange:A=>l("current_version",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Publisher"}),_.jsx("input",{type:"text",placeholder:"Publisher",value:i.publisher,onChange:A=>l("publisher",A.target.value)})]}),_.jsxs("div",{className:"flex flex-col w-3/4",children:[_.jsx("label",{className:"metadata-label",children:"Mirrors (separated by commas)"}),_.jsx("input",{type:"text",placeholder:"Mirrors (separated by commas)",value:i.mirrors.join(","),onChange:A=>l("mirrors",A.target.value.split(",").map(T=>T.trim()))})]}),_.jsxs("div",{className:"flex flex-col w-3/4 gap-2",children:[_.jsxs("div",{className:"flex gap-2 mt-0 justify-between w-full",children:[_.jsx("h5",{className:"m-0",children:"Code Hashes"}),_.jsx("button",{type:"button",onClick:()=>a([...o,["",""]]),className:"clear",children:"Add code hash"})]}),o.map(([A,T],I,B)=>_.jsxs("div",{className:"flex gap-2 mt-0 w-full",children:[_.jsx("input",{type:"text",placeholder:"Version",value:A,onChange:F=>a($=>{const V=[...$];return V[I][0]=F.target.value,V}),className:"flex-1"}),_.jsx("input",{type:"text",placeholder:"Hash",value:T,onChange:F=>a($=>{const V=[...$];return V[I][1]=F.target.value,V}),className:"flex-5"}),B.length>1&&_.jsx("button",{type:"button",onClick:()=>a(F=>F.filter(($,V)=>V!==I)),className:"icon",children:_.jsx(w2,{})})]},I+"_code_hash"))]}),_.jsxs("div",{className:"flex gap-2 my-4",children:[_.jsx("button",{type:"button",onClick:u,className:"alt",children:"Download JSON"}),_.jsx("button",{type:"button",onClick:c,className:"clear",children:"Clear Form"}),_.jsx("button",{type:"button",onClick:n,children:"Done"})]})]})};function FS({readOnly:t=!1,checked:e,setChecked:r}){return _.jsxs("div",{className:"relative",children:[_.jsx("input",{type:"checkbox",id:"checked",name:"checked",checked:e,onChange:n=>r&&r(n.target.checked),autoFocus:!0,readOnly:t}),e&&_.jsx(v2,{className:"absolute left-1 top-1 cursor-pointer",onClick:()=>r&&r(!1)})]})}var Qn=function(t){t==null&&(t=new Date().getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,t.constructor==Array?this.init_by_array(t,t.length):this.init_seed(t)};Qn.prototype.init_seed=function(t){for(this.mt[0]=t>>>0,this.mti=1;this.mti>>30;this.mt[this.mti]=(((t&4294901760)>>>16)*1812433253<<16)+(t&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0}};Qn.prototype.init_by_array=function(t,e){var r,n,i;for(this.init_seed(19650218),r=1,n=0,i=this.N>e?this.N:e;i;i--){var s=this.mt[r-1]^this.mt[r-1]>>>30;this.mt[r]=(this.mt[r]^(((s&4294901760)>>>16)*1664525<<16)+(s&65535)*1664525)+t[n]+n,this.mt[r]>>>=0,r++,n++,r>=this.N&&(this.mt[0]=this.mt[this.N-1],r=1),n>=e&&(n=0)}for(i=this.N-1;i;i--){var s=this.mt[r-1]^this.mt[r-1]>>>30;this.mt[r]=(this.mt[r]^(((s&4294901760)>>>16)*1566083941<<16)+(s&65535)*1566083941)-r,this.mt[r]>>>=0,r++,r>=this.N&&(this.mt[0]=this.mt[this.N-1],r=1)}this.mt[0]=2147483648};Qn.prototype.random_int=function(){var t,e=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var r;for(this.mti==this.N+1&&this.init_seed(5489),r=0;r>>1^e[t&1];for(;r>>1^e[t&1];t=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^t>>>1^e[t&1],this.mti=0}return t=this.mt[this.mti++],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0};Qn.prototype.random_int31=function(){return this.random_int()>>>1};Qn.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};Qn.prototype.random=function(){return this.random_int()*(1/4294967296)};Qn.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};Qn.prototype.random_long=function(){var t=this.random_int()>>>5,e=this.random_int()>>>6;return(t*67108864+e)*(1/9007199254740992)};var US=Qn;function zS(t,e){var r=document.createElement("div");return r.style.borderRadius="50px",r.style.overflow="hidden",r.style.padding="0px",r.style.margin="0px",r.style.width=""+t+"px",r.style.height=""+t+"px",r.style.display="inline-block",r.style.background=e,{container:r}}var $S=zS,C2={exports:{}};(function(t){var e=function(){function r(l,u,c,h){typeof u=="object"&&(c=u.depth,h=u.prototype,u.filter,u=u.circular);var p=[],m=[],v=typeof Buffer<"u";typeof u>"u"&&(u=!0),typeof c>"u"&&(c=1/0);function b(k,x){if(k===null)return null;if(x==0)return k;var w,A;if(typeof k!="object")return k;if(r.__isArray(k))w=[];else if(r.__isRegExp(k))w=new RegExp(k.source,a(k)),k.lastIndex&&(w.lastIndex=k.lastIndex);else if(r.__isDate(k))w=new Date(k.getTime());else{if(v&&Buffer.isBuffer(k))return Buffer.allocUnsafe?w=Buffer.allocUnsafe(k.length):w=new Buffer(k.length),k.copy(w),w;typeof h>"u"?(A=Object.getPrototypeOf(k),w=Object.create(A)):(w=Object.create(h),A=h)}if(u){var T=p.indexOf(k);if(T!=-1)return m[T];p.push(k),m.push(w)}for(var I in k){var B;A&&(B=Object.getOwnPropertyDescriptor(A,I)),!(B&&B.set==null)&&(w[I]=b(k[I],x-1))}return w}return b(l,c)}r.clonePrototype=function(u){if(u===null)return null;var c=function(){};return c.prototype=u,new c};function n(l){return Object.prototype.toString.call(l)}r.__objToStr=n;function i(l){return typeof l=="object"&&n(l)==="[object Date]"}r.__isDate=i;function s(l){return typeof l=="object"&&n(l)==="[object Array]"}r.__isArray=s;function o(l){return typeof l=="object"&&n(l)==="[object RegExp]"}r.__isRegExp=o;function a(l){var u="";return l.global&&(u+="g"),l.ignoreCase&&(u+="i"),l.multiline&&(u+="m"),u}return r.__getRegExpFlags=a,r}();t.exports&&(t.exports=e)})(C2);var HS=C2.exports,P2={exports:{}},VS={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},zi=VS,R2={};for(var Sf in zi)zi.hasOwnProperty(Sf)&&(R2[zi[Sf]]=Sf);var re=P2.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var tr in re)if(re.hasOwnProperty(tr)){if(!("channels"in re[tr]))throw new Error("missing channels property: "+tr);if(!("labels"in re[tr]))throw new Error("missing channel labels property: "+tr);if(re[tr].labels.length!==re[tr].channels)throw new Error("channel and label counts mismatch: "+tr);var qS=re[tr].channels,GS=re[tr].labels;delete re[tr].channels,delete re[tr].labels,Object.defineProperty(re[tr],"channels",{value:qS}),Object.defineProperty(re[tr],"labels",{value:GS})}re.rgb.hsl=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.min(e,r,n),s=Math.max(e,r,n),o=s-i,a,l,u;return s===i?a=0:e===s?a=(r-n)/o:r===s?a=2+(n-e)/o:n===s&&(a=4+(e-r)/o),a=Math.min(a*60,360),a<0&&(a+=360),u=(i+s)/2,s===i?l=0:u<=.5?l=o/(s+i):l=o/(2-s-i),[a,l*100,u*100]};re.rgb.hsv=function(t){var e,r,n,i,s,o=t[0]/255,a=t[1]/255,l=t[2]/255,u=Math.max(o,a,l),c=u-Math.min(o,a,l),h=function(p){return(u-p)/6/c+1/2};return c===0?i=s=0:(s=c/u,e=h(o),r=h(a),n=h(l),o===u?i=n-r:a===u?i=1/3+e-n:l===u&&(i=2/3+r-e),i<0?i+=1:i>1&&(i-=1)),[i*360,s*100,u*100]};re.rgb.hwb=function(t){var e=t[0],r=t[1],n=t[2],i=re.rgb.hsl(t)[0],s=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[i,s*100,n*100]};re.rgb.cmyk=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,i,s,o,a;return a=Math.min(1-e,1-r,1-n),i=(1-e-a)/(1-a)||0,s=(1-r-a)/(1-a)||0,o=(1-n-a)/(1-a)||0,[i*100,s*100,o*100,a*100]};function WS(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}re.rgb.keyword=function(t){var e=R2[t];if(e)return e;var r=1/0,n;for(var i in zi)if(zi.hasOwnProperty(i)){var s=zi[i],o=WS(t,s);o.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var i=e*.4124+r*.3576+n*.1805,s=e*.2126+r*.7152+n*.0722,o=e*.0193+r*.1192+n*.9505;return[i*100,s*100,o*100]};re.rgb.lab=function(t){var e=re.rgb.xyz(t),r=e[0],n=e[1],i=e[2],s,o,a;return r/=95.047,n/=100,i/=108.883,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=116*n-16,o=500*(r-n),a=200*(n-i),[s,o,a]};re.hsl.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,i,s,o,a,l;if(r===0)return l=n*255,[l,l,l];n<.5?s=n*(1+r):s=n+r-n*r,i=2*n-s,a=[0,0,0];for(var u=0;u<3;u++)o=e+1/3*-(u-1),o<0&&o++,o>1&&o--,6*o<1?l=i+(s-i)*6*o:2*o<1?l=s:3*o<2?l=i+(s-i)*(2/3-o)*6:l=i,a[u]=l*255;return a};re.hsl.hsv=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,i=r,s=Math.max(n,.01),o,a;return n*=2,r*=n<=1?n:2-n,i*=s<=1?s:2-s,a=(n+r)/2,o=n===0?2*i/(s+i):2*r/(n+r),[e,o*100,a*100]};re.hsv.rgb=function(t){var e=t[0]/60,r=t[1]/100,n=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*n*(1-r),a=255*n*(1-r*s),l=255*n*(1-r*(1-s));switch(n*=255,i){case 0:return[n,l,o];case 1:return[a,n,o];case 2:return[o,n,l];case 3:return[o,a,n];case 4:return[l,o,n];case 5:return[n,o,a]}};re.hsv.hsl=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,i=Math.max(n,.01),s,o,a;return a=(2-r)*n,s=(2-r)*i,o=r*i,o/=s<=1?s:2-s,o=o||0,a/=2,[e,o*100,a*100]};re.hwb.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,i=r+n,s,o,a,l;i>1&&(r/=i,n/=i),s=Math.floor(6*e),o=1-n,a=6*e-s,s&1&&(a=1-a),l=r+a*(o-r);var u,c,h;switch(s){default:case 6:case 0:u=o,c=l,h=r;break;case 1:u=l,c=o,h=r;break;case 2:u=r,c=o,h=l;break;case 3:u=r,c=l,h=o;break;case 4:u=l,c=r,h=o;break;case 5:u=o,c=r,h=l;break}return[u*255,c*255,h*255]};re.cmyk.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,i=t[3]/100,s,o,a;return s=1-Math.min(1,e*(1-i)+i),o=1-Math.min(1,r*(1-i)+i),a=1-Math.min(1,n*(1-i)+i),[s*255,o*255,a*255]};re.xyz.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,i,s,o;return i=e*3.2406+r*-1.5372+n*-.4986,s=e*-.9689+r*1.8758+n*.0415,o=e*.0557+r*-.204+n*1.057,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*12.92,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o*12.92,i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),o=Math.min(Math.max(0,o),1),[i*255,s*255,o*255]};re.xyz.lab=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;return e/=95.047,r/=100,n/=108.883,e=e>.008856?Math.pow(e,1/3):7.787*e+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,i=116*r-16,s=500*(e-r),o=200*(r-n),[i,s,o]};re.lab.xyz=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;s=(e+16)/116,i=r/500+s,o=s-n/200;var a=Math.pow(s,3),l=Math.pow(i,3),u=Math.pow(o,3);return s=a>.008856?a:(s-16/116)/7.787,i=l>.008856?l:(i-16/116)/7.787,o=u>.008856?u:(o-16/116)/7.787,i*=95.047,s*=100,o*=108.883,[i,s,o]};re.lab.lch=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;return i=Math.atan2(n,r),s=i*360/2/Math.PI,s<0&&(s+=360),o=Math.sqrt(r*r+n*n),[e,o,s]};re.lch.lab=function(t){var e=t[0],r=t[1],n=t[2],i,s,o;return o=n/360*2*Math.PI,i=r*Math.cos(o),s=r*Math.sin(o),[e,i,s]};re.rgb.ansi16=function(t){var e=t[0],r=t[1],n=t[2],i=1 in arguments?arguments[1]:re.rgb.hsv(t)[2];if(i=Math.round(i/50),i===0)return 30;var s=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(e/255));return i===2&&(s+=60),s};re.hsv.ansi16=function(t){return re.rgb.ansi16(re.hsv.rgb(t),t[2])};re.rgb.ansi256=function(t){var e=t[0],r=t[1],n=t[2];if(e===r&&r===n)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;var i=16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5);return i};re.ansi16.rgb=function(t){var e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];var r=(~~(t>50)+1)*.5,n=(e&1)*r*255,i=(e>>1&1)*r*255,s=(e>>2&1)*r*255;return[n,i,s]};re.ansi256.rgb=function(t){if(t>=232){var e=(t-232)*10+8;return[e,e,e]}t-=16;var r,n=Math.floor(t/36)/5*255,i=Math.floor((r=t%36)/6)/5*255,s=r%6/5*255;return[n,i,s]};re.rgb.hex=function(t){var e=((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255),r=e.toString(16).toUpperCase();return"000000".substring(r.length)+r};re.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var r=e[0];e[0].length===3&&(r=r.split("").map(function(a){return a+a}).join(""));var n=parseInt(r,16),i=n>>16&255,s=n>>8&255,o=n&255;return[i,s,o]};re.rgb.hcg=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,i=Math.max(Math.max(e,r),n),s=Math.min(Math.min(e,r),n),o=i-s,a,l;return o<1?a=s/(1-o):a=0,o<=0?l=0:i===e?l=(r-n)/o%6:i===r?l=2+(n-e)/o:l=4+(e-r)/o+4,l/=6,l%=1,[l*360,o*100,a*100]};re.hsl.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1,i=0;return r<.5?n=2*e*r:n=2*e*(1-r),n<1&&(i=(r-.5*n)/(1-n)),[t[0],n*100,i*100]};re.hsv.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=e*r,i=0;return n<1&&(i=(r-n)/(1-n)),[t[0],n*100,i*100]};re.hcg.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100;if(r===0)return[n*255,n*255,n*255];var i=[0,0,0],s=e%1*6,o=s%1,a=1-o,l=0;switch(Math.floor(s)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=a,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=a,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=a}return l=(1-r)*n,[(r*i[0]+l)*255,(r*i[1]+l)*255,(r*i[2]+l)*255]};re.hcg.hsv=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e),i=0;return n>0&&(i=e/n),[t[0],i*100,n*100]};re.hcg.hsl=function(t){var e=t[1]/100,r=t[2]/100,n=r*(1-e)+.5*e,i=0;return n>0&&n<.5?i=e/(2*n):n>=.5&&n<1&&(i=e/(2*(1-n))),[t[0],i*100,n*100]};re.hcg.hwb=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e);return[t[0],(n-e)*100,(1-n)*100]};re.hwb.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1-r,i=n-e,s=0;return i<1&&(s=(n-i)/(1-i)),[t[0],i*100,s*100]};re.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};re.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};re.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};re.gray.hsl=re.gray.hsv=function(t){return[0,0,t[0]]};re.gray.hwb=function(t){return[0,100,t[0]]};re.gray.cmyk=function(t){return[0,0,0,t[0]]};re.gray.lab=function(t){return[t[0],0,0]};re.gray.hex=function(t){var e=Math.round(t[0]/100*255)&255,r=(e<<16)+(e<<8)+e,n=r.toString(16).toUpperCase();return"000000".substring(n.length)+n};re.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[e/255*100]};var I2=P2.exports,Eu=I2;function KS(){for(var t={},e=Object.keys(Eu),r=e.length,n=0;n1&&(r=Array.prototype.slice.call(arguments)),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function rk(t){var e=function(r){if(r==null)return r;arguments.length>1&&(r=Array.prototype.slice.call(arguments));var n=t(r);if(typeof n=="object")for(var i=n.length,s=0;sr?(e+.05)/(r+.05):(r+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(t[0]*299+t[1]*587+t[2]*114)/1e3;return e<128},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;e<3;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=t[0]*.3+t[1]*.59+t[2]*.11;return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=e<0?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){var r=this,n=t,i=e===void 0?.5:e,s=2*i-1,o=r.alpha()-n.alpha(),a=((s*o===-1?s:(s+o)/(1+s*o))+1)/2,l=1-a;return this.rgb(a*r.red()+l*n.red(),a*r.green()+l*n.green(),a*r.blue()+l*n.blue()).alpha(r.alpha()*i+n.alpha()*(1-i))},toJSON:function(){return this.rgb()},clone:function(){var t=new vn;return t.values=mk(this.values),t}};vn.prototype.getValues=function(t){for(var e={},r=0;r{const n=L.useRef(null);return L.useEffect(()=>{if(t&&n.current){const i=parseInt(t.slice(2,10),16),s=Mk(e,i);n.current.innerHTML="",n.current.appendChild(s)}},[t,e]),_.jsx("div",{...r,ref:n})},{useIsActivating:Ck}=n0;function Pk({provider:t,packageAbi:e}){var g;const{state:r}=$u(),{listedApps:n}=Pi(),{account:i,isActive:s}=Hu.useWeb3React(),o=Ck(),[a,l]=L.useState(""),[u,c]=L.useState(),[h,p]=L.useState(!1),[m,v]=L.useState(""),[b,k]=L.useState(((g=window.our)==null?void 0:g.node)||""),[x,w]=L.useState(""),[A,T]=L.useState(""),[I,B]=L.useState(!1),[F,$]=L.useState([]);L.useEffect(()=>{const E=r==null?void 0:r.app;E&&(v(E.package),k(E.publisher),B(!0))},[r]),L.useEffect(()=>{$(n.filter(E=>{var M;return((M=E.owner)==null?void 0:M.toLowerCase())===(i==null?void 0:i.toLowerCase())}))},[n,i]);const V=L.useCallback(async()=>{await M2.activate().catch(()=>{});try{Af(zo)}catch(E){console.error(E)}},[]),G=L.useCallback(async()=>{if(!x){T("");return}try{const M=await(await fetch(x)).text();JSON.parse(M);const S=ot(yr(M));T(S)}catch{window.alert("Error calculating metadata hash. Please ensure the URL is valid and the metadata is in JSON format.")}},[x]),Y=L.useCallback(async E=>{var S;E.preventDefault(),E.stopPropagation();let M=A;try{if(!M){const N=await fetch(x);await N.json();const d=await N.text();M=ot(yr(d))}l("Please confirm the transaction in your wallet");const P=eg(b);await Af(zo);const O=await(I?e==null?void 0:e.updateMetadata(K.from(i6(["string","bytes"],[m,P])),x,M):e==null?void 0:e.registerApp(m,P,x,M));await new Promise(N=>setTimeout(N,2e3)),l("Publishing package..."),await(O==null?void 0:O.wait()),c({packageName:m,publisherId:b}),v(""),k(((S=window.our)==null?void 0:S.node)||b),w(""),T(""),B(!1)}catch(P){console.error(P),window.alert("Error publishing package. Please ensure the package name and publisher ID are valid, and the metadata is in JSON format.")}finally{l("")}},[m,I,b,x,A,e,c,v,k,w,T,B]),$e=L.useCallback(async(E,M)=>{try{await Af(zo);const S=await(e==null?void 0:e.unlistPacakge(ot(l2(["string","bytes"],[E,eg(M)]))));await new Promise(P=>setTimeout(P,2e3)),l("Unlisting package..."),await(S==null?void 0:S.wait())}catch(S){console.error(S),window.alert("Error unlisting package")}finally{l("")}},[e,l]),R=L.useCallback(async()=>{I||m&&b&&n.find(E=>E.package===m&&E.publisher===b)&&B(!0)},[n,m,b,I,B]),f=Kn();return _.jsxs("div",{className:ue("w-full flex flex-col gap-2",{"max-w-[900px]":!f,"p-2 h-screen w-screen":f}),children:[!f&&_.jsx(ac,{}),_.jsx(oc,{hideSearch:!0,hidePublish:!0,onBack:h?()=>p(!1):void 0}),_.jsxs("div",{className:"flex-center justify-between",children:[_.jsx("h4",{children:"Publish Package"}),!!i&&_.jsxs("div",{className:"card flex-center",children:[_.jsx("span",{children:"Publishing as:"}),_.jsx(ig,{address:i,className:"mx-2"}),_.jsxs("span",{className:"font-mono",children:[i==null?void 0:i.slice(0,4),"...",i==null?void 0:i.slice(-4)]})]})]}),a?_.jsx("div",{className:"flex-col-center",children:_.jsx(ya,{msg:a})}):u?_.jsxs("div",{className:"flex-col-center gap-2",children:[_.jsx("h4",{children:"Package Published!"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Package Name:"})," ",u.packageName]}),_.jsxs("div",{children:[_.jsx("strong",{children:"Publisher ID:"})," ",u.publisherId]}),_.jsx("button",{className:"flex ml-2",onClick:()=>c(void 0),children:"Publish Another Package"})]}):h?_.jsx(DS,{packageName:m,publisherId:b,app:r==null?void 0:r.app,goBack:()=>p(!1)}):!i||!s?_.jsxs(_.Fragment,{children:[_.jsxs("h4",{children:["Please connect your wallet ",f&&_.jsx("br",{})," to publish a package"]}),_.jsx("button",{className:"connect-wallet row",onClick:V,children:"Connect Wallet"})]}):o?_.jsx(ya,{msg:"Approve connection in your wallet"}):_.jsxs("form",{className:"flex flex-col flex-1 overflow-y-auto gap-2",onSubmit:Y,children:[_.jsxs("div",{className:"flex cursor-pointer p-2 -mb-2",onClick:()=>B(!I),children:[_.jsx(FS,{checked:I,readOnly:!0}),_.jsx("label",{htmlFor:"update",className:"cursor-pointer ml-4",children:"Update existing package"})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("label",{htmlFor:"package-name",children:"Package Name"}),_.jsx("input",{id:"package-name",type:"text",required:!0,placeholder:"my-package",value:m,onChange:E=>v(E.target.value),onBlur:R})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("label",{htmlFor:"publisher-id",children:"Publisher ID"}),_.jsx("input",{id:"publisher-id",type:"text",required:!0,value:b,onChange:E=>k(E.target.value),onBlur:R})]}),_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsx("label",{htmlFor:"metadata-url",children:"Metadata URL"}),_.jsx("input",{id:"metadata-url",type:"text",required:!0,value:x,onChange:E=>w(E.target.value),onBlur:G,placeholder:"https://github/my-org/my-repo/metadata.json"}),_.jsxs("div",{children:["Metadata is a JSON file that describes your package.",_.jsx("br",{})," You can"," ",_.jsx("a",{onClick:()=>p(!0),className:"underline cursor-pointer",children:"fill out a template here"}),"."]})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("label",{htmlFor:"metadata-hash",children:"Metadata Hash"}),_.jsx("input",{readOnly:!0,id:"metadata-hash",type:"text",value:A,onChange:E=>T(E.target.value),placeholder:"Calculated automatically from metadata URL"})]}),_.jsx("button",{type:"submit",children:"Publish"})]}),_.jsxs("div",{className:"flex flex-col",children:[_.jsx("h4",{children:"Packages You Own"}),F.length>0?_.jsx("div",{className:"flex flex-col",children:F.map(E=>_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("div",{className:"flex items-center",children:[_.jsx(ig,{address:E.publisher,className:"mr-2"}),_.jsx("span",{children:E.package})]}),_.jsx("button",{className:"flex items-center",onClick:()=>$e(E.package,E.publisher),children:_.jsx("span",{children:"Unpublish"})})]},`${E.package}${E.publisher}`))}):_.jsx("div",{className:"flex items-center",children:_.jsx("span",{children:"No packages published"})})]})]})}var Rk={BASE_URL:"/main:app_store:sys",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Ik=[[M2,n0]],{useProvider:Ok}=n0,$o="/main:app_store:sys";window.our&&(window.our.process=$o==null?void 0:$o.replace("/",""));const Tk=`${Rk.VITE_NODE_URL||"http://localhost:8080"}${$o}`;function jk(){const t=Ok(),[e,r]=L.useState(!0),[n,i]=L.useState(void 0);if(L.useEffect(()=>{if(!t)return;(async()=>{(await t.getNetwork()).chainId===Uh.OPTIMISM&&i(u2.connect(MS[Uh.OPTIMISM],t.getSigner()))})()},[t]),L.useEffect(()=>{},[]),!e)return _.jsxs("div",{className:"flex flex-col c",children:[_.jsx("h2",{style:{color:"red"},children:"Node not connected"}),_.jsxs("h4",{children:["You need to start a node at ",Tk," before you can use this UI in development."]})]});const s={provider:t,packageAbi:n};return _.jsx("div",{className:"flex flex-col c h-screen w-screen max-h-screen max-w-screen overflow-x-hidden special-appstore-background",children:_.jsx(Hu.Web3ReactProvider,{connectors:Ik,children:_.jsx(a3,{basename:$o,children:_.jsxs(s3,{children:[_.jsx(ko,{path:$6,element:_.jsx(SS,{})}),_.jsx(ko,{path:Lh,element:_.jsx(kS,{})}),_.jsx(ko,{path:`${vu}/:id`,element:_.jsx(NS,{})}),_.jsx(ko,{path:sc,element:_.jsx(Pk,{...s})})]})})})})}Nf.createRoot(document.getElementById("root")).render(_.jsx(Wr.StrictMode,{children:_.jsx(jk,{})})); diff --git a/kinode/packages/app_store/pkg/ui/index.html b/kinode/packages/app_store/pkg/ui/index.html index 4b723f3db..9c24627cd 100644 --- a/kinode/packages/app_store/pkg/ui/index.html +++ b/kinode/packages/app_store/pkg/ui/index.html @@ -14,7 +14,7 @@ - + diff --git a/kinode/packages/app_store/ui/src/components/InstallButton.tsx b/kinode/packages/app_store/ui/src/components/InstallButton.tsx index fa3c09eee..12cbf9561 100644 --- a/kinode/packages/app_store/ui/src/components/InstallButton.tsx +++ b/kinode/packages/app_store/ui/src/components/InstallButton.tsx @@ -16,7 +16,7 @@ export default function InstallButton({ app, isIcon = false, ...props }: Install const { installApp, getCaps, getMyApp, getMyApps } = useAppsStore(); const [showModal, setShowModal] = useState(false); - const [caps, setCaps] = useState([]); + const [caps, setCaps] = useState([]); const [installing, setInstalling] = useState(""); const onClick = useCallback(async (e: React.MouseEvent) => { @@ -83,7 +83,7 @@ export default function InstallButton({ app, isIcon = false, ...props }: Install
    {caps.map((cap) => ( -
  • {cap}
  • +
  • {JSON.stringify(cap)}
  • ))}